@formant/data-sdk 1.10.0 → 1.11.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -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 j, SignalingPromiseClient as N } 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(
@@ -344,14 +344,14 @@ function Ae(a) {
344
344
  };
345
345
  return window.addEventListener("message", e), () => window.removeEventListener("message", e);
346
346
  }
347
- function De(a) {
347
+ function je(a) {
348
348
  const e = (t) => {
349
349
  const n = t.data;
350
350
  n.type === "module_configuration" && a(n);
351
351
  };
352
352
  return window.addEventListener("message", e), () => window.removeEventListener("message", e);
353
353
  }
354
- function Pe(a) {
354
+ function Ne(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 De(a) {
368
368
  T({ type: "request_devices" });
369
369
  const e = (t) => {
370
370
  const n = t.data;
@@ -372,10 +372,10 @@ 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,
375
+ const Pe = 1, F = 1e3, W = 60 * F, H = 60 * W, I = 24 * H, Ie = 7 * I, Le = 30 * I, _e = 365 * I, L = {
376
+ millisecond: Pe,
377
+ second: F,
378
+ minute: W,
379
379
  hour: H,
380
380
  day: I,
381
381
  week: Ie,
@@ -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");
402
+ r(this, "entries", /* @__PURE__ */ new Map());
403
+ r(this, "metadata", /* @__PURE__ */ new Map());
404
+ r(this, "capacity");
405
+ r(this, "timeout");
406
406
  this.capacity = e || 1e4, this.timeout = t || L.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
467
  timeout: 20 * L.second
468
468
  }));
469
- s(this, "liveQueryStoreCache", new x({
469
+ r(this, "liveQueryStoreCache", new x({
470
470
  capacity: 1e4,
471
471
  timeout: 200 * L.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);
479
+ }, p = this.query(d, i, s, c);
480
480
  return p === void 0 || p === "too much data" ? p : $e(p, 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,18 +600,18 @@ 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
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);
611
+ r(y, "getCurrentModuleContext", k), // senders
612
+ r(y, "disableAnalyticsBottomBar", ve), r(y, "goToDevice", Te), r(y, "goToTime", Ce), r(y, "refreshAuthToken", V), r(y, "requestModuleData", Se), r(y, "sendChannelData", Ee), r(y, "setModuleDateTimeRange", ke), r(y, "setupModuleMenus", Oe), r(y, "showMessage", Re), // listeners
613
+ r(y, "addAccessTokenRefreshListener", G), r(y, "addChannelDataListener", be), r(y, "addMenuListener", Ae), r(y, "addModuleConfigurationListener", je), r(y, "addModuleDataListener", Ne), r(y, "addOverviewDeviceListener", De), r(y, "addStreamListener", qe), // bidirectional
614
+ r(y, "getDate", xe), r(y, "prompt", Ue), r(y, "_isOnline", null);
615
615
  function f(a, e) {
616
616
  if (a !== void 0)
617
617
  return a;
@@ -622,7 +622,7 @@ const g = {
622
622
  TELEOP: 1,
623
623
  PORT_FORWARD: 2,
624
624
  OBSERVE: 3
625
- }, Ht = {
625
+ }, Xt = {
626
626
  ...g,
627
627
  Unknown: g.UNKNOWN,
628
628
  Teleop: g.TELEOP,
@@ -633,26 +633,26 @@ const g = {
633
633
  portForward: g.PORT_FORWARD,
634
634
  observe: g.OBSERVE
635
635
  }, O = Symbol("RtcClientPool.instance");
636
- var qt;
637
- class j {
636
+ var Jt;
637
+ class D {
638
638
  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) => {
639
+ r(this, Jt, null);
640
+ r(this, "createClient");
641
+ r(this, "ttlMs");
642
+ r(this, "proxyHandler");
643
+ r(this, "proxyReceivers", /* @__PURE__ */ new Map());
644
+ r(this, "teardownTimeout", null);
645
+ r(this, "dispatch", (e, t) => {
646
646
  this.proxyReceivers.forEach((n) => n == null ? void 0 : n(e, t));
647
647
  });
648
648
  const { createClient: t, ttlMs: n = 0 } = e;
649
649
  this.createClient = t, this.ttlMs = Math.max(n, 0), this.proxyHandler = {
650
- get: (i, r, c) => {
651
- switch (r) {
650
+ get: (i, s, c) => {
651
+ switch (s) {
652
652
  case "shutdown":
653
653
  return () => this.releaseInstance(c);
654
654
  default:
655
- return Reflect.get(i, r, c);
655
+ return Reflect.get(i, s, c);
656
656
  }
657
657
  }
658
658
  };
@@ -691,40 +691,40 @@ class j {
691
691
  }, this.ttlMs)), !0) : (console.warn("this instance has already been released!"), !1);
692
692
  }
693
693
  }
694
- qt = O;
695
- const N = async () => f(o.token, "Realtime when user isn't authorized"), R = {
696
- [g.UNKNOWN]: new j({
694
+ Jt = O;
695
+ const P = async () => f(o.token, "Realtime when user isn't authorized"), R = {
696
+ [g.UNKNOWN]: new D({
697
697
  ttlMs: 2500,
698
- createClient: (a) => new D({
699
- signalingClient: new P(h),
700
- getToken: N,
698
+ createClient: (a) => new j({
699
+ signalingClient: new N(h),
700
+ getToken: P,
701
701
  sessionType: g.UNKNOWN,
702
702
  receive: a
703
703
  })
704
704
  }),
705
- [g.TELEOP]: new j({
705
+ [g.TELEOP]: new D({
706
706
  ttlMs: 2500,
707
- createClient: (a) => new D({
708
- signalingClient: new P(h),
709
- getToken: N,
707
+ createClient: (a) => new j({
708
+ signalingClient: new N(h),
709
+ getToken: P,
710
710
  sessionType: g.TELEOP,
711
711
  receive: a
712
712
  })
713
713
  }),
714
- [g.PORT_FORWARD]: new j({
714
+ [g.PORT_FORWARD]: new D({
715
715
  ttlMs: 2500,
716
- createClient: (a) => new D({
717
- signalingClient: new P(h),
718
- getToken: N,
716
+ createClient: (a) => new j({
717
+ signalingClient: new N(h),
718
+ getToken: P,
719
719
  sessionType: g.PORT_FORWARD,
720
720
  receive: a
721
721
  })
722
722
  }),
723
- [g.OBSERVE]: new j({
723
+ [g.OBSERVE]: new D({
724
724
  ttlMs: 2500,
725
- createClient: (a) => new D({
726
- signalingClient: new P(h),
727
- getToken: N,
725
+ createClient: (a) => new j({
726
+ signalingClient: new N(h),
727
+ getToken: P,
728
728
  sessionType: g.OBSERVE,
729
729
  receive: a
730
730
  })
@@ -739,9 +739,9 @@ const N = async () => f(o.token, "Realtime when user isn't authorized"), R = {
739
739
  const { sessionType: e } = a;
740
740
  return e ? Je[e] : $;
741
741
  };
742
- class Fe {
742
+ class Ge {
743
743
  constructor(e) {
744
- s(this, "token");
744
+ r(this, "token");
745
745
  this.captureSession = e;
746
746
  }
747
747
  async ingestJSON(e) {
@@ -772,17 +772,17 @@ class Fe {
772
772
  function b(a) {
773
773
  return new Promise((e) => setTimeout(e, a));
774
774
  }
775
- const We = (a) => a !== void 0 && a.capabilities !== void 0 && a.capabilitySet !== void 0;
776
- class Ge {
775
+ const Fe = (a) => a !== void 0 && a.capabilities !== void 0 && a.capabilitySet !== void 0;
776
+ class We {
777
777
  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());
778
+ r(this, "ready", !1);
779
+ r(this, "listeners", []);
780
+ r(this, "openListeners", []);
781
+ r(this, "closeListeners", []);
782
+ r(this, "errorListeners", []);
783
+ r(this, "binaryListeners", []);
784
+ r(this, "error");
785
+ r(this, "decoder", new TextDecoder());
786
786
  this.dataChannel = e, this.dataChannel.binaryType = "arraybuffer", this.dataChannel.onopen = () => {
787
787
  this.setReady();
788
788
  }, this.dataChannel.onclose = () => {
@@ -791,8 +791,8 @@ class Ge {
791
791
  console.error(t), this.error = "An error occurred in DataChannel", this.errorListeners.forEach((n) => n(t));
792
792
  }, this.dataChannel.onmessage = (t) => {
793
793
  this.listeners.forEach((n) => {
794
- const i = new Uint8Array(t.data), r = this.decoder.decode(i);
795
- n(r);
794
+ const i = new Uint8Array(t.data), s = this.decoder.decode(i);
795
+ n(s);
796
796
  }), this.binaryListeners.forEach((n) => {
797
797
  n(new Uint8Array(t.data));
798
798
  });
@@ -861,8 +861,8 @@ class Ge {
861
861
  }
862
862
  class He {
863
863
  constructor(e, t) {
864
- s(this, "currentListeners", []);
865
- s(this, "onRealtimeMessage", (e, t) => {
864
+ r(this, "currentListeners", []);
865
+ r(this, "onRealtimeMessage", (e, t) => {
866
866
  t.payload.jointState && this.currentListeners.forEach((n) => {
867
867
  t.payload.jointState && n(t.payload.jointState);
868
868
  });
@@ -885,8 +885,8 @@ class He {
885
885
  }
886
886
  class K {
887
887
  constructor(e, t, n) {
888
- s(this, "channel");
889
- s(this, "requestIdToResponseMap", /* @__PURE__ */ new Map());
888
+ r(this, "channel");
889
+ r(this, "requestIdToResponseMap", /* @__PURE__ */ new Map());
890
890
  this.device = e, this.channel_name = t, this.timeout = n;
891
891
  }
892
892
  addOpenListener(e) {
@@ -917,8 +917,8 @@ class K {
917
917
  class Ke extends K {
918
918
  constructor() {
919
919
  super(...arguments);
920
- s(this, "RESPONSE_SUCCESS_BYTE", 0);
921
- s(this, "decoder", new TextDecoder());
920
+ r(this, "RESPONSE_SUCCESS_BYTE", 0);
921
+ r(this, "decoder", new TextDecoder());
922
922
  }
923
923
  /*
924
924
  Request binary payload layout:
@@ -940,21 +940,21 @@ class Ke extends K {
940
940
  const i = t.slice(0, 16).toString();
941
941
  if (i.length === 0)
942
942
  throw new Error("Invalid response");
943
- const r = t.slice(16);
944
- if (r.length === 0)
943
+ const s = t.slice(16);
944
+ if (s.length === 0)
945
945
  throw new Error("Invalid response");
946
- this.requestIdToResponseMap.has(i) && this.requestIdToResponseMap.set(i, r);
946
+ this.requestIdToResponseMap.has(i) && this.requestIdToResponseMap.set(i, s);
947
947
  });
948
948
  }
949
949
  async request(t) {
950
950
  if (this.channel || await this.initialize(), !this.channel)
951
951
  throw new Error("Failed to create channel");
952
- const { channel: n, requestIdToResponseMap: i, timeout: r } = this;
952
+ const { channel: n, requestIdToResponseMap: i, timeout: s } = this;
953
953
  await n.waitTilReady();
954
954
  const c = this.generateBinaryId(), d = c.toString();
955
955
  i.set(d, !0), n.sendBinary(new Uint8Array([...c, ...t]));
956
956
  const p = (/* @__PURE__ */ new Date()).getTime();
957
- for (; (/* @__PURE__ */ new Date()).getTime() < p + r; )
957
+ for (; (/* @__PURE__ */ new Date()).getTime() < p + s; )
958
958
  if (await b(50), i.has(d)) {
959
959
  const m = i.get(d);
960
960
  if (m !== !0) {
@@ -970,7 +970,7 @@ class Ke extends K {
970
970
  }
971
971
  throw i.delete(d), console.error({
972
972
  name: "TimeoutError",
973
- message: `Request timed out after ${r / 1e3} seconds`
973
+ message: `Request timed out after ${s / 1e3} seconds`
974
974
  }), new Error("Binary request data channel request timed out");
975
975
  }
976
976
  }
@@ -980,10 +980,10 @@ class Qe extends K {
980
980
  }
981
981
  async initialize() {
982
982
  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;
983
+ const t = JSON.parse(e), { id: n, data: i, error: s } = t;
984
984
  if (!n)
985
985
  throw new Error("Invalid response");
986
- if (!i && !r)
986
+ if (!i && !s)
987
987
  throw new Error("Invalid response");
988
988
  this.requestIdToResponseMap.has(n) && this.requestIdToResponseMap.set(n, t);
989
989
  });
@@ -993,19 +993,19 @@ class Qe extends K {
993
993
  throw new Error("Failed to create channel");
994
994
  const { channel: t, requestIdToResponseMap: n, timeout: i } = this;
995
995
  await t.waitTilReady();
996
- const r = this.generateTextId();
997
- n.set(r, !0), t.send(
996
+ const s = this.generateTextId();
997
+ n.set(s, !0), t.send(
998
998
  JSON.stringify({
999
- id: r,
999
+ id: s,
1000
1000
  data: e
1001
1001
  })
1002
1002
  );
1003
1003
  const c = (/* @__PURE__ */ new Date()).getTime();
1004
1004
  for (; (/* @__PURE__ */ new Date()).getTime() < c + i; )
1005
- if (await b(50), n.has(r)) {
1006
- const d = n.get(r);
1005
+ if (await b(50), n.has(s)) {
1006
+ const d = n.get(s);
1007
1007
  if (d !== !0) {
1008
- n.delete(r);
1008
+ n.delete(s);
1009
1009
  const { data: p, error: m } = d;
1010
1010
  if (p)
1011
1011
  return p;
@@ -1016,20 +1016,20 @@ class Qe extends K {
1016
1016
  }), new Error("Text request datachannel adapter error");
1017
1017
  }
1018
1018
  }
1019
- throw n.delete(r), console.error({
1019
+ throw n.delete(s), console.error({
1020
1020
  name: "TimeoutError",
1021
1021
  message: `Request timed out after ${i / 1e3} seconds`
1022
1022
  }), new Error("Text request datachannel request timed out");
1023
1023
  }
1024
1024
  }
1025
- class Q extends ue {
1025
+ class Q extends le {
1026
1026
  constructor() {
1027
1027
  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) => {
1028
+ r(this, "rtcClient");
1029
+ r(this, "remoteDevicePeerId", null);
1030
+ r(this, "realtimeListeners", []);
1031
+ r(this, "connectionMonitorInterval");
1032
+ r(this, "handleMessage", (t, n) => {
1033
1033
  this.realtimeListeners.forEach((i) => i(t, n));
1034
1034
  });
1035
1035
  }
@@ -1076,13 +1076,13 @@ class Q extends ue {
1076
1076
  return n;
1077
1077
  }
1078
1078
  async getRealtimeVideoStreams() {
1079
- var i, r, c;
1079
+ var i, s, c;
1080
1080
  const t = await this.getConfiguration(), n = [];
1081
1081
  for (const d of ((i = t.teleop) == null ? void 0 : i.hardwareStreams) ?? [])
1082
1082
  d.rtcStreamType === "h264-video-frame" && n.push({
1083
1083
  name: d.name
1084
1084
  });
1085
- for (const d of ((r = t.teleop) == null ? void 0 : r.rosStreams) ?? [])
1085
+ for (const d of ((s = t.teleop) == null ? void 0 : s.rosStreams) ?? [])
1086
1086
  d.topicType == "formant/H264VideoFrame" && n.push({
1087
1087
  name: d.topicName
1088
1088
  }), (d.topicType === "sensor_msgs/Image" || d.topicType === "sensor_msgs/CompressedImage") && d.encodeVideo && n.push({
@@ -1170,8 +1170,8 @@ class Q extends ue {
1170
1170
  const i = f(
1171
1171
  this.rtcClient,
1172
1172
  "Realtime connection has not been started"
1173
- ), r = await this.getRemotePeer();
1174
- i.controlRemoteStream(f(r).id, {
1173
+ ), s = await this.getRemotePeer();
1174
+ i.controlRemoteStream(f(s).id, {
1175
1175
  streamName: t,
1176
1176
  setAudioFormat: n
1177
1177
  });
@@ -1180,9 +1180,9 @@ class Q extends ue {
1180
1180
  const i = f(
1181
1181
  this.rtcClient,
1182
1182
  "Realtime connection has not been started"
1183
- ), r = await this.getRemotePeer(), c = await new Promise((d) => {
1183
+ ), s = await this.getRemotePeer(), c = await new Promise((d) => {
1184
1184
  i.createCustomDataChannel(
1185
- f(r).id,
1185
+ f(s).id,
1186
1186
  t,
1187
1187
  {
1188
1188
  ordered: !0,
@@ -1190,7 +1190,7 @@ class Q extends ue {
1190
1190
  },
1191
1191
  !1,
1192
1192
  (p, m) => {
1193
- const w = new Ge(m);
1193
+ const w = new We(m);
1194
1194
  d(w);
1195
1195
  }
1196
1196
  );
@@ -1203,17 +1203,17 @@ class Q extends ue {
1203
1203
  const i = f(
1204
1204
  this.rtcClient,
1205
1205
  "Realtime connection has not been started"
1206
- ), r = await this.getRemotePeer();
1207
- i.send(f(r).id, t, n);
1206
+ ), s = await this.getRemotePeer();
1207
+ i.send(f(s).id, t, n);
1208
1208
  }
1209
1209
  async getRealtimeAudioStreams() {
1210
- var i, r, c;
1210
+ var i, s, c;
1211
1211
  const t = await this.getConfiguration(), n = [];
1212
1212
  for (const d of ((i = t.teleop) == null ? void 0 : i.hardwareStreams) ?? [])
1213
1213
  d.rtcStreamType === "audio-chunk" && n.push({
1214
1214
  name: d.name
1215
1215
  });
1216
- for (const d of ((r = t.teleop) == null ? void 0 : r.rosStreams) ?? [])
1216
+ for (const d of ((s = t.teleop) == null ? void 0 : s.rosStreams) ?? [])
1217
1217
  d.topicType == "audio_common_msgs/AudioData" && n.push({
1218
1218
  name: d.topicName
1219
1219
  });
@@ -1254,12 +1254,12 @@ async function Y(a, e) {
1254
1254
  "Content-Type": "application/json",
1255
1255
  Authorization: "Bearer " + o.token
1256
1256
  }
1257
- }), r = h.replace("api", "app"), { code: c } = await i.json();
1258
- return `${r}/shares/${c}#${Ye({
1257
+ }), s = h.replace("api", "app"), { code: c } = await i.json();
1258
+ return `${s}/shares/${c}#${Ye({
1259
1259
  viewId: n[0].id
1260
1260
  })}`;
1261
1261
  }
1262
- const Kt = [
1262
+ const Yt = [
1263
1263
  "day",
1264
1264
  "week",
1265
1265
  "month",
@@ -1267,7 +1267,7 @@ const Kt = [
1267
1267
  "hour",
1268
1268
  "minute",
1269
1269
  "quarter"
1270
- ], Qt = [
1270
+ ], Zt = [
1271
1271
  "interval",
1272
1272
  "start",
1273
1273
  "end",
@@ -1295,7 +1295,7 @@ function it(a) {
1295
1295
  function ot(a) {
1296
1296
  return a.count;
1297
1297
  }
1298
- const Xt = {
1298
+ const en = {
1299
1299
  min: nt,
1300
1300
  max: tt,
1301
1301
  "standard deviation": et,
@@ -1304,53 +1304,53 @@ const Xt = {
1304
1304
  count: ot
1305
1305
  }, Z = {
1306
1306
  day: {
1307
- interval: u.eachDayOfInterval,
1308
- start: u.startOfDay,
1309
- end: u.endOfDay,
1310
- sub: u.subDays,
1311
- get: u.getDay
1307
+ interval: l.eachDayOfInterval,
1308
+ start: l.startOfDay,
1309
+ end: l.endOfDay,
1310
+ sub: l.subDays,
1311
+ get: l.getDay
1312
1312
  },
1313
1313
  week: {
1314
- interval: u.eachWeekOfInterval,
1315
- start: u.startOfWeek,
1316
- end: u.endOfWeek,
1317
- sub: u.subWeeks,
1318
- get: u.getWeek
1314
+ interval: l.eachWeekOfInterval,
1315
+ start: l.startOfWeek,
1316
+ end: l.endOfWeek,
1317
+ sub: l.subWeeks,
1318
+ get: l.getWeek
1319
1319
  },
1320
1320
  month: {
1321
- interval: u.eachMonthOfInterval,
1322
- start: u.startOfMonth,
1323
- end: u.endOfMonth,
1324
- sub: u.subMonths,
1325
- get: u.getMonth
1321
+ interval: l.eachMonthOfInterval,
1322
+ start: l.startOfMonth,
1323
+ end: l.endOfMonth,
1324
+ sub: l.subMonths,
1325
+ get: l.getMonth
1326
1326
  },
1327
1327
  year: {
1328
- interval: u.eachYearOfInterval,
1329
- start: u.startOfYear,
1330
- end: u.endOfYear,
1331
- sub: u.subYears,
1332
- get: u.getYear
1328
+ interval: l.eachYearOfInterval,
1329
+ start: l.startOfYear,
1330
+ end: l.endOfYear,
1331
+ sub: l.subYears,
1332
+ get: l.getYear
1333
1333
  },
1334
1334
  hour: {
1335
- interval: u.eachHourOfInterval,
1336
- start: u.startOfHour,
1337
- end: u.endOfHour,
1338
- sub: u.subHours,
1339
- get: u.getHours
1335
+ interval: l.eachHourOfInterval,
1336
+ start: l.startOfHour,
1337
+ end: l.endOfHour,
1338
+ sub: l.subHours,
1339
+ get: l.getHours
1340
1340
  },
1341
1341
  minute: {
1342
- interval: u.eachMinuteOfInterval,
1343
- start: u.startOfMinute,
1344
- end: u.endOfMinute,
1345
- sub: u.subMinutes,
1346
- get: u.getMinutes
1342
+ interval: l.eachMinuteOfInterval,
1343
+ start: l.startOfMinute,
1344
+ end: l.endOfMinute,
1345
+ sub: l.subMinutes,
1346
+ get: l.getMinutes
1347
1347
  },
1348
1348
  quarter: {
1349
- interval: u.eachQuarterOfInterval,
1350
- start: u.startOfQuarter,
1351
- end: u.endOfQuarter,
1352
- sub: u.subQuarters,
1353
- get: u.getQuarter
1349
+ interval: l.eachQuarterOfInterval,
1350
+ start: l.startOfQuarter,
1351
+ end: l.endOfQuarter,
1352
+ sub: l.subQuarters,
1353
+ get: l.getQuarter
1354
1354
  }
1355
1355
  }, rt = (a, e) => (
1356
1356
  // FIXME this doesn't work for *a lot* locales, other than en-US
@@ -1372,14 +1372,14 @@ async function z(a) {
1372
1372
  })).json()).items;
1373
1373
  }
1374
1374
  async function ee(a, e, t, n, i) {
1375
- const r = Z[e];
1375
+ const s = Z[e];
1376
1376
  return await Promise.all(
1377
1377
  Array(t).fill(0).map(async (c, d) => {
1378
- const p = new Date(n), m = r.sub(
1379
- r.start(p),
1378
+ const p = new Date(n), m = s.sub(
1379
+ s.start(p),
1380
1380
  t - d - 1
1381
- ), w = r.sub(
1382
- r.end(p),
1381
+ ), w = s.sub(
1382
+ s.end(p),
1383
1383
  t - d - 1
1384
1384
  ), v = rt(
1385
1385
  m.toLocaleDateString(),
@@ -1399,10 +1399,10 @@ async function B(a, e) {
1399
1399
  ...a,
1400
1400
  eventTypes: ["annotation"]
1401
1401
  })).filter(
1402
- (r) => !!r.tags && Object.keys(r.tags).includes(e)
1403
- ).reduce((r, c) => {
1402
+ (s) => !!s.tags && Object.keys(s.tags).includes(e)
1403
+ ).reduce((s, c) => {
1404
1404
  const d = c.tags[e];
1405
- return d in r ? (r[d] += 1, r) : (r[d] = 1, r);
1405
+ return d in s ? (s[d] += 1, s) : (s[d] = 1, s);
1406
1406
  }, {});
1407
1407
  }
1408
1408
  async function te(a, e, t) {
@@ -1426,13 +1426,13 @@ async function te(a, e, t) {
1426
1426
  }));
1427
1427
  }
1428
1428
  async function ne(a, e, t, n, i) {
1429
- let r = a;
1430
- Array.isArray(a) || (r = [a]);
1429
+ let s = a;
1430
+ Array.isArray(a) || (s = [a]);
1431
1431
  let c = e;
1432
1432
  return Array.isArray(e) || (c = [e]), (await (await fetch(`${h}/v1/queries/queries`, {
1433
1433
  method: "POST",
1434
1434
  body: JSON.stringify({
1435
- deviceIds: r,
1435
+ deviceIds: s,
1436
1436
  end: n.toISOString(),
1437
1437
  names: c,
1438
1438
  start: t.toISOString(),
@@ -1512,7 +1512,7 @@ async function ht(a) {
1512
1512
  }
1513
1513
  })).json()).items;
1514
1514
  }
1515
- async function lt(a) {
1515
+ async function ut(a) {
1516
1516
  if (!o.token)
1517
1517
  throw new Error("Not authenticated");
1518
1518
  return await (await fetch(
@@ -1645,7 +1645,7 @@ class S extends Q {
1645
1645
  }
1646
1646
  async getRemoteDevicePeerId(e) {
1647
1647
  const n = (await e.getPeers()).find((i) => i.deviceId === this.id);
1648
- if (!We(n))
1648
+ if (!Fe(n))
1649
1649
  throw new Error("Cannot find peer, is the robot offline?");
1650
1650
  return n.id;
1651
1651
  }
@@ -1767,7 +1767,7 @@ class S extends Q {
1767
1767
  Authorization: "Bearer " + o.token
1768
1768
  }
1769
1769
  })).json();
1770
- return new Fe(n);
1770
+ return new Ge(n);
1771
1771
  }
1772
1772
  async getTelemetry(e, t, n, i) {
1773
1773
  return await ne(
@@ -1844,9 +1844,9 @@ class S extends Q {
1844
1844
  n
1845
1845
  );
1846
1846
  }
1847
- async eventsCounter(e, t, n, i, r) {
1847
+ async eventsCounter(e, t, n, i, s) {
1848
1848
  return await ee(e, t, n, i, {
1849
- ...r,
1849
+ ...s,
1850
1850
  deviceIds: [this.id]
1851
1851
  });
1852
1852
  }
@@ -1854,24 +1854,24 @@ class S extends Q {
1854
1854
  return e.scope.deviceIds = [this.id], await Y(e, t);
1855
1855
  }
1856
1856
  }
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 {
1857
+ r(S, "createDevice", st), r(S, "patchDevice", ct), r(S, "getDevicesData", dt), r(S, "queryDevicesData", ht), r(S, "disableDevice", ut);
1858
+ class lt extends Q {
1859
1859
  constructor(t) {
1860
1860
  super();
1861
- s(this, "id");
1862
- s(this, "telemetryStreamActive", !1);
1863
- s(this, "streamTelemetry", {});
1861
+ r(this, "id");
1862
+ r(this, "telemetryStreamActive", !1);
1863
+ r(this, "streamTelemetry", {});
1864
1864
  this.peerUrl = t;
1865
1865
  }
1866
1866
  async getLatestTelemetry() {
1867
1867
  this.telemetryStreamActive || this.subscribeToTelemetry();
1868
1868
  const t = this.streamTelemetry;
1869
- return Object.entries(t).map(([i, r]) => ({
1869
+ return Object.entries(t).map(([i, s]) => ({
1870
1870
  deviceId: this.id,
1871
1871
  streamName: i,
1872
1872
  streamType: "json",
1873
- currentValue: r,
1874
- currentValueTime: r.timestamp,
1873
+ currentValue: s,
1874
+ currentValueTime: s.timestamp,
1875
1875
  tags: {}
1876
1876
  }));
1877
1877
  }
@@ -1888,8 +1888,8 @@ class ut extends Q {
1888
1888
  }), n.addEventListener("readystatechange", (i) => {
1889
1889
  n.readyState === XMLHttpRequest.DONE && this.handleXHRError("closed");
1890
1890
  }), n.addEventListener("progress", (i) => {
1891
- const r = i.loaded, c = r - t;
1892
- t = r, n.responseText.substr(-c).split(`
1891
+ const s = i.loaded, c = s - t;
1892
+ t = s, n.responseText.substr(-c).split(`
1893
1893
  `).forEach((m) => {
1894
1894
  var w;
1895
1895
  if (m.length > 0) {
@@ -1919,7 +1919,7 @@ class ut extends Q {
1919
1919
  this.rtcClient && console.warn(
1920
1920
  "overwriting existing rtcClient due to missing connectionMonitorInterval"
1921
1921
  );
1922
- const n = new D({
1922
+ const n = new j({
1923
1923
  lanOnlyMode: !0,
1924
1924
  receive: this.handleMessage,
1925
1925
  sessionType: t
@@ -1958,11 +1958,11 @@ class ut extends Q {
1958
1958
  if (t)
1959
1959
  throw new Error(`Realtime connection hasn't been started for ${this.id}`);
1960
1960
  }
1961
- async sendCommand(t, n, i, r) {
1961
+ async sendCommand(t, n, i, s) {
1962
1962
  const c = {
1963
1963
  value: n,
1964
1964
  scrubberTime: (i || /* @__PURE__ */ new Date()).toISOString(),
1965
- meta: r
1965
+ meta: s
1966
1966
  };
1967
1967
  return await fetch(`${this.peerUrl}/v1/enqueue-command`, {
1968
1968
  method: "POST",
@@ -2227,7 +2227,7 @@ async function At() {
2227
2227
  );
2228
2228
  return (await M()).filter((i) => t.includes(i.id));
2229
2229
  }
2230
- async function Dt() {
2230
+ async function jt() {
2231
2231
  if (!o.token)
2232
2232
  throw new Error("Not authenticated");
2233
2233
  return (await (await fetch(`${h}/v1/admin/streams`, {
@@ -2240,7 +2240,7 @@ async function Dt() {
2240
2240
  (t) => t.enabled
2241
2241
  );
2242
2242
  }
2243
- async function Pt(a) {
2243
+ async function Nt(a) {
2244
2244
  if (!o.token)
2245
2245
  throw new Error("Not authenticated");
2246
2246
  return await (await fetch(
@@ -2255,7 +2255,7 @@ async function Pt(a) {
2255
2255
  }
2256
2256
  )).json();
2257
2257
  }
2258
- async function jt() {
2258
+ async function Dt() {
2259
2259
  if (!o.token)
2260
2260
  throw new Error("Not authenticated");
2261
2261
  return (await (await fetch(
@@ -2269,7 +2269,7 @@ async function jt() {
2269
2269
  }
2270
2270
  )).json()).items;
2271
2271
  }
2272
- async function Nt() {
2272
+ async function Pt() {
2273
2273
  if (!o.token)
2274
2274
  throw new Error("Not authenticated");
2275
2275
  return (await (await fetch(`${h}/v1/admin/fleets`, {
@@ -2343,6 +2343,46 @@ async function zt(a) {
2343
2343
  }
2344
2344
  })).json();
2345
2345
  }
2346
+ async function Bt() {
2347
+ if (!o.token)
2348
+ throw new Error("Not authenticated");
2349
+ return (await (await fetch(`${h}/v1/admin/event-trigger-groups`, {
2350
+ method: "GET",
2351
+ headers: {
2352
+ "Content-Type": "application/json",
2353
+ Authorization: "Bearer " + o.token
2354
+ }
2355
+ })).json()).items;
2356
+ }
2357
+ async function Mt(a) {
2358
+ if (!o.token)
2359
+ throw new Error("Not authenticated");
2360
+ return await (await fetch(
2361
+ `${h}/v1/admin/event-trigger-groups/${a}`,
2362
+ {
2363
+ method: "GET",
2364
+ headers: {
2365
+ "Content-Type": "application/json",
2366
+ Authorization: "Bearer " + o.token
2367
+ }
2368
+ }
2369
+ )).json();
2370
+ }
2371
+ async function qt(a, e) {
2372
+ if (!o.token)
2373
+ throw new Error("Not authenticated");
2374
+ return await (await fetch(
2375
+ `${h}/v1/admin/event-trigger-groups/${a}`,
2376
+ {
2377
+ method: "PATCH",
2378
+ body: JSON.stringify(e),
2379
+ headers: {
2380
+ "Content-Type": "application/json",
2381
+ Authorization: "Bearer " + o.token
2382
+ }
2383
+ }
2384
+ )).json();
2385
+ }
2346
2386
  const E = class {
2347
2387
  static async setDefaultDevice(e) {
2348
2388
  E.defaultDeviceId = e;
@@ -2363,16 +2403,16 @@ const E = class {
2363
2403
  }
2364
2404
  )).json()).items.find(
2365
2405
  (c) => c.id === E.defaultDeviceId
2366
- ), i = n.name, r = new S(
2406
+ ), i = n.name, s = new S(
2367
2407
  E.defaultDeviceId,
2368
2408
  i,
2369
2409
  f(o.currentOrganization),
2370
2410
  n.tags
2371
2411
  );
2372
- return E.knownContext.push(new WeakRef(r)), r;
2412
+ return E.knownContext.push(new WeakRef(s)), s;
2373
2413
  }
2374
2414
  static async getPeerDevice(e) {
2375
- const t = new ut(e);
2415
+ const t = new lt(e);
2376
2416
  return t.id = await t.getDeviceId(), t;
2377
2417
  }
2378
2418
  static async getDevice(e) {
@@ -2380,9 +2420,9 @@ const E = class {
2380
2420
  return E.knownContext.push(new WeakRef(t)), t;
2381
2421
  }
2382
2422
  };
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 {
2423
+ let u = E;
2424
+ r(u, "defaultDeviceId"), r(u, "knownContext", []), r(u, "createFleet", zt), r(u, "listFleets", Pt), r(u, "getFleet", Et), r(u, "patchFleet", It), 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", bt), r(u, "getPeers", ie), r(u, "getRealtimeDevices", At), r(u, "getRealtimeSessions", ae), r(u, "getStreams", jt), r(u, "getTaskReportRows", Nt), r(u, "getTaskReportTables", Dt), r(u, "getTelemetry", ne), r(u, "getViews", X), r(u, "patchStream", Lt), 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);
2425
+ class tn {
2386
2426
  static async set(e, t, n) {
2387
2427
  try {
2388
2428
  const i = await fetch(h + "/v1/admin/key-value", {
@@ -2397,9 +2437,9 @@ class Yt {
2397
2437
  "Content-Type": "application/json",
2398
2438
  Authorization: "Bearer " + o.token
2399
2439
  }
2400
- }), r = await i.json();
2440
+ }), s = await i.json();
2401
2441
  if (i.status !== 200)
2402
- throw new Error(r.message);
2442
+ throw new Error(s.message);
2403
2443
  } catch (i) {
2404
2444
  throw i;
2405
2445
  }
@@ -2478,37 +2518,37 @@ class Yt {
2478
2518
  }
2479
2519
  }
2480
2520
  }
2481
- function Bt(a) {
2521
+ function xt(a) {
2482
2522
  return Uint8Array.from(J(a), (e) => e.charCodeAt(0));
2483
2523
  }
2484
2524
  function U() {
2485
2525
  const { userAgent: a } = navigator;
2486
2526
  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
2527
  }
2488
- const Mt = "audio-chunk";
2489
- class Zt {
2528
+ const Ut = "audio-chunk";
2529
+ class nn {
2490
2530
  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) => {
2531
+ r(this, "muted", !1);
2532
+ r(this, "hasReceivedData", !1);
2533
+ r(this, "audioContext");
2534
+ r(this, "chunks", []);
2535
+ r(this, "isPlaying", !1);
2536
+ r(this, "startTime", 0);
2537
+ r(this, "lastChunkOffset", 0);
2538
+ r(this, "bufferSize", 3);
2539
+ r(this, "receive", async (e) => {
2500
2540
  var c;
2501
2541
  const t = (c = e.payload.audioChunk) == null ? void 0 : c.chunk_data;
2502
2542
  if (!t)
2503
2543
  return;
2504
2544
  this.hasReceivedData || (this.hasReceivedData = !0);
2505
2545
  const { audioContext: n, muted: i } = this;
2506
- if (!n || e.header.stream.streamType !== Mt || i !== !1)
2546
+ if (!n || e.header.stream.streamType !== Ut || i !== !1)
2507
2547
  return;
2508
- const r = Bt(t);
2548
+ const s = xt(t);
2509
2549
  try {
2510
2550
  await n.decodeAudioData(
2511
- r.buffer,
2551
+ s.buffer,
2512
2552
  this.scheduleChunk
2513
2553
  );
2514
2554
  } catch (d) {
@@ -2518,7 +2558,7 @@ class Zt {
2518
2558
  ), this.changeAudioWireFormat("wav");
2519
2559
  }
2520
2560
  });
2521
- s(this, "scheduleChunk", (e) => {
2561
+ r(this, "scheduleChunk", (e) => {
2522
2562
  const { audioContext: t } = this;
2523
2563
  if (!t)
2524
2564
  return;
@@ -2528,8 +2568,8 @@ class Zt {
2528
2568
  const n = this.createChunk(e);
2529
2569
  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
2570
  });
2531
- this.device = e, this.stream = t, this.device.startListeningToRealtimeDataStream(t), this.device.addRealtimeListener((i, r) => {
2532
- this.receive(r);
2571
+ this.device = e, this.stream = t, this.device.startListeningToRealtimeDataStream(t), this.device.addRealtimeListener((i, s) => {
2572
+ this.receive(s);
2533
2573
  }), U() === "Safari" || U() === "IE" ? this.changeAudioWireFormat("wav") : this.changeAudioWireFormat("opus");
2534
2574
  const n = window.AudioContext || window.webkitAudioContext;
2535
2575
  this.audioContext = new n();
@@ -2558,7 +2598,7 @@ class Zt {
2558
2598
  (async () => await this.device.changeStreamAudioType(t.name, e))();
2559
2599
  }
2560
2600
  }
2561
- class en {
2601
+ class an {
2562
2602
  static async listAccounts() {
2563
2603
  if (!o.token)
2564
2604
  throw new Error("Not authenticated");
@@ -2631,7 +2671,7 @@ class en {
2631
2671
  )).json();
2632
2672
  }
2633
2673
  }
2634
- class tn {
2674
+ class on {
2635
2675
  static async listRoles() {
2636
2676
  if (!o.token)
2637
2677
  throw new Error("Not authenticated");
@@ -2690,7 +2730,7 @@ class tn {
2690
2730
  });
2691
2731
  }
2692
2732
  }
2693
- class nn {
2733
+ class rn {
2694
2734
  static async listUsers() {
2695
2735
  if (!o.token)
2696
2736
  throw new Error("Not authenticated");
@@ -2750,14 +2790,14 @@ class nn {
2750
2790
  });
2751
2791
  }
2752
2792
  }
2753
- const an = ["viewer", "operator", "administrator"], on = "viewer", rn = "operator", sn = "administrator", cn = [
2793
+ const sn = ["viewer", "operator", "administrator"], cn = "viewer", dn = "operator", hn = "administrator", un = [
2754
2794
  "year",
2755
2795
  "month",
2756
2796
  "week",
2757
2797
  "day",
2758
2798
  "hour",
2759
2799
  "minute"
2760
- ], dn = ["tag", "sheet", "user"], hn = [
2800
+ ], ln = ["tag", "sheet", "user"], mn = [
2761
2801
  "triggered-event",
2762
2802
  "intervention-request",
2763
2803
  "teleop-session-record",
@@ -2769,44 +2809,44 @@ const an = ["viewer", "operator", "administrator"], on = "viewer", rn = "operato
2769
2809
  "comment",
2770
2810
  "system",
2771
2811
  "annotation"
2772
- ], ln = [
2812
+ ], fn = [
2773
2813
  "unknown",
2774
2814
  "operational",
2775
2815
  "offline",
2776
2816
  "error"
2777
- ], un = ["selection", "labeling", "teleop"], mn = ["info", "warning", "error", "critical"], fn = ["video/mp4"], wn = (a) => new Promise((e) => setTimeout(e, a * 1e3));
2817
+ ], wn = ["selection", "labeling", "teleop"], pn = ["info", "warning", "error", "critical"], yn = ["video/mp4"], gn = (a) => new Promise((e) => setTimeout(e, a * 1e3));
2778
2818
  try {
2779
2819
  const a = typeof window < "u" && window.location ? new URLSearchParams(window.location.search) : new URLSearchParams(""), e = a.get("device");
2780
- e && l.setDefaultDevice(e);
2820
+ e && u.setDefaultDevice(e);
2781
2821
  const t = a.get("auth");
2782
2822
  t && o.loginWithToken(t), a.get("module") && o.listenForRefresh(), typeof window < "u" && y.listenForConnectionEvents();
2783
2823
  } catch {
2784
2824
  }
2785
2825
  export {
2786
- en as Account,
2826
+ an as Account,
2787
2827
  y as App,
2788
- Zt as AudioPlayer,
2828
+ nn as AudioPlayer,
2789
2829
  o as Authentication,
2790
2830
  Ke as BinaryRequestDataChannel,
2791
- Fe as CaptureStream,
2792
- Ge as DataChannel,
2831
+ Ge as CaptureStream,
2832
+ We as DataChannel,
2793
2833
  S as Device,
2794
- l as Fleet,
2795
- Yt as KeyValue,
2834
+ u as Fleet,
2835
+ tn as KeyValue,
2796
2836
  He as Manipulator,
2797
- ut as PeerDevice,
2798
- tn as Role,
2799
- Ht as SessionType,
2837
+ lt as PeerDevice,
2838
+ on as Role,
2839
+ Xt as SessionType,
2800
2840
  Qe as TextRequestDataChannel,
2801
- nn as User,
2802
- an as accessLevels,
2803
- sn as administrator,
2841
+ rn as User,
2842
+ sn as accessLevels,
2843
+ hn as administrator,
2804
2844
  Z as aggregateByDateFunctions,
2805
- Xt as aggregateFunctionMap,
2806
- Qt as aggregateFunctions,
2807
- cn as aggregateLevels,
2808
- dn as annotationTypes,
2809
- hn as eventTypes,
2845
+ en as aggregateFunctionMap,
2846
+ Zt as aggregateFunctions,
2847
+ un as aggregateLevels,
2848
+ ln as annotationTypes,
2849
+ mn as eventTypes,
2810
2850
  rt as formatTimeFrameText,
2811
2851
  at as getAverage,
2812
2852
  ot as getCount,
@@ -2815,13 +2855,13 @@ export {
2815
2855
  et as getStandardDeviation,
2816
2856
  it as getSum,
2817
2857
  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
2858
+ fn as healthStatuses,
2859
+ wn as interventionTypes,
2860
+ dn as operator,
2861
+ pn as severities,
2862
+ gn as timeout,
2863
+ Yt as vailableAggregationIntervals,
2864
+ yn as videoMimeTypes,
2865
+ cn as viewer
2826
2866
  };
2827
2867
  //# sourceMappingURL=data-sdk.es.js.map