@acrobits/ipc-sdk 0.8.1-alpha.9 → 0.9.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.
package/lib/ipc-sdk.js CHANGED
@@ -1,6 +1,6 @@
1
1
  var Pe = Object.defineProperty;
2
2
  var _e = (n, t, e) => t in n ? Pe(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
- var I = (n, t, e) => (_e(n, typeof t != "symbol" ? t + "" : t, e), e);
3
+ var x = (n, t, e) => (_e(n, typeof t != "symbol" ? t + "" : t, e), e);
4
4
  var w = /* @__PURE__ */ ((n) => (n.BadgeQuery = "BADGE QUERY", n.Lifecycle = "LIFECYCLE", n.PushToken = "PUSH TOKEN", n))(w || {}), q = function(n, t) {
5
5
  return q = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
6
6
  e.__proto__ = r;
@@ -56,7 +56,7 @@ function D(n, t, e) {
56
56
  (i || !(r in t)) && (i || (i = Array.prototype.slice.call(t, 0, r)), i[r] = t[r]);
57
57
  return n.concat(i || Array.prototype.slice.call(t));
58
58
  }
59
- function E(n) {
59
+ function S(n) {
60
60
  return typeof n == "function";
61
61
  }
62
62
  function X(n) {
@@ -96,8 +96,8 @@ var R = function() {
96
96
  var u = c.value;
97
97
  u.remove(this);
98
98
  }
99
- } catch (v) {
100
- t = { error: v };
99
+ } catch (y) {
100
+ t = { error: y };
101
101
  } finally {
102
102
  try {
103
103
  c && !c.done && (e = a.return) && e.call(a);
@@ -109,29 +109,29 @@ var R = function() {
109
109
  else
110
110
  o.remove(this);
111
111
  var l = this.initialTeardown;
112
- if (E(l))
112
+ if (S(l))
113
113
  try {
114
114
  l();
115
- } catch (v) {
116
- i = v instanceof N ? v.errors : [v];
115
+ } catch (y) {
116
+ i = y instanceof N ? y.errors : [y];
117
117
  }
118
- var d = this._finalizers;
119
- if (d) {
118
+ var h = this._finalizers;
119
+ if (h) {
120
120
  this._finalizers = null;
121
121
  try {
122
- for (var y = G(d), b = y.next(); !b.done; b = y.next()) {
123
- var k = b.value;
122
+ for (var b = G(h), v = b.next(); !v.done; v = b.next()) {
123
+ var k = v.value;
124
124
  try {
125
125
  se(k);
126
- } catch (v) {
127
- i = i ?? [], v instanceof N ? i = D(D([], $(i)), $(v.errors)) : i.push(v);
126
+ } catch (y) {
127
+ i = i ?? [], y instanceof N ? i = D(D([], $(i)), $(y.errors)) : i.push(y);
128
128
  }
129
129
  }
130
- } catch (v) {
131
- r = { error: v };
130
+ } catch (y) {
131
+ r = { error: y };
132
132
  } finally {
133
133
  try {
134
- b && !b.done && (s = y.return) && s.call(y);
134
+ v && !v.done && (s = b.return) && s.call(b);
135
135
  } finally {
136
136
  if (r)
137
137
  throw r.error;
@@ -172,10 +172,10 @@ var R = function() {
172
172
  }(), n;
173
173
  }(), be = R.EMPTY;
174
174
  function me(n) {
175
- return n instanceof R || n && "closed" in n && E(n.remove) && E(n.add) && E(n.unsubscribe);
175
+ return n instanceof R || n && "closed" in n && S(n.remove) && S(n.add) && S(n.unsubscribe);
176
176
  }
177
177
  function se(n) {
178
- E(n) ? n() : n.unsubscribe();
178
+ S(n) ? n() : n.unsubscribe();
179
179
  }
180
180
  var we = {
181
181
  onUnhandledError: null,
@@ -183,20 +183,20 @@ var we = {
183
183
  Promise: void 0,
184
184
  useDeprecatedSynchronousErrorHandling: !1,
185
185
  useDeprecatedNextContext: !1
186
- }, Ee = {
186
+ }, Se = {
187
187
  setTimeout: function(n, t) {
188
188
  for (var e = [], r = 2; r < arguments.length; r++)
189
189
  e[r - 2] = arguments[r];
190
190
  return setTimeout.apply(void 0, D([n, t], $(e)));
191
191
  },
192
192
  clearTimeout: function(n) {
193
- var t = Ee.delegate;
193
+ var t = Se.delegate;
194
194
  return ((t == null ? void 0 : t.clearTimeout) || clearTimeout)(n);
195
195
  },
196
196
  delegate: void 0
197
197
  };
198
198
  function Ae(n) {
199
- Ee.setTimeout(function() {
199
+ Se.setTimeout(function() {
200
200
  throw n;
201
201
  });
202
202
  }
@@ -275,7 +275,7 @@ var Le = function() {
275
275
  M(t, n);
276
276
  function t(e, r, s) {
277
277
  var i = n.call(this) || this, o;
278
- if (E(e) || !e)
278
+ if (S(e) || !e)
279
279
  o = {
280
280
  next: e ?? void 0,
281
281
  error: r ?? void 0,
@@ -309,11 +309,11 @@ var $e = {
309
309
  }, De = function() {
310
310
  return typeof Symbol == "function" && Symbol.observable || "@@observable";
311
311
  }();
312
- function Se(n) {
312
+ function Ee(n) {
313
313
  return n;
314
314
  }
315
315
  function Fe(n) {
316
- return n.length === 0 ? Se : n.length === 1 ? n[0] : function(e) {
316
+ return n.length === 0 ? Ee : n.length === 1 ? n[0] : function(e) {
317
317
  return n.reduce(function(r, s) {
318
318
  return s(r);
319
319
  }, e);
@@ -384,13 +384,13 @@ function oe(n) {
384
384
  return (t = n ?? we.Promise) !== null && t !== void 0 ? t : Promise;
385
385
  }
386
386
  function He(n) {
387
- return n && E(n.next) && E(n.error) && E(n.complete);
387
+ return n && S(n.next) && S(n.error) && S(n.complete);
388
388
  }
389
389
  function ke(n) {
390
390
  return n && n instanceof Z || He(n) && me(n);
391
391
  }
392
392
  function Ne(n) {
393
- return E(n == null ? void 0 : n.lift);
393
+ return S(n == null ? void 0 : n.lift);
394
394
  }
395
395
  function Ce(n) {
396
396
  return function(t) {
@@ -644,11 +644,7 @@ var Ve = function(n) {
644
644
  throw s;
645
645
  }
646
646
  }, t;
647
- }(ce), Ye = new Be(Ge), ze = Ye;
648
- function We(n) {
649
- return n && E(n.schedule);
650
- }
651
- var Ke = X(function(n) {
647
+ }(ce), Ye = new Be(Ge), ze = Ye, We = X(function(n) {
652
648
  return function() {
653
649
  n(this), this.name = "EmptyError", this.message = "no elements in sequence";
654
650
  };
@@ -662,13 +658,13 @@ function T(n, t) {
662
658
  },
663
659
  error: s,
664
660
  complete: function() {
665
- e ? r(t.defaultValue) : s(new Ke());
661
+ e ? r(t.defaultValue) : s(new We());
666
662
  }
667
663
  });
668
664
  n.subscribe(i);
669
665
  });
670
666
  }
671
- function Je(n) {
667
+ function Ke(n) {
672
668
  return n instanceof Date && !isNaN(n);
673
669
  }
674
670
  function O(n, t) {
@@ -679,20 +675,18 @@ function O(n, t) {
679
675
  }));
680
676
  });
681
677
  }
682
- function Xe(n, t, e) {
683
- n === void 0 && (n = 0), e === void 0 && (e = ze);
684
- var r = -1;
685
- return t != null && (We(t) ? e = t : r = t), new B(function(s) {
686
- var i = Je(n) ? +n - e.now() : n;
687
- i < 0 && (i = 0);
688
- var o = 0;
678
+ function Je(n, t, e) {
679
+ return e === void 0 && (e = ze), new B(function(r) {
680
+ var s = Ke(n) ? +n - e.now() : n;
681
+ s < 0 && (s = 0);
682
+ var i = 0;
689
683
  return e.schedule(function() {
690
- s.closed || (s.next(o++), 0 <= r ? this.schedule(void 0, r) : s.complete());
691
- }, i);
684
+ r.closed || (r.next(i++), r.complete());
685
+ }, s);
692
686
  });
693
687
  }
694
- function Ze(n, t, e) {
695
- var r = E(n) || t || e ? { next: n, error: t, complete: e } : n;
688
+ function Xe(n, t, e) {
689
+ var r = S(n) || t || e ? { next: n, error: t, complete: e } : n;
696
690
  return r ? Ce(function(s, i) {
697
691
  var o;
698
692
  (o = r.subscribe) === null || o === void 0 || o.call(r);
@@ -710,27 +704,27 @@ function Ze(n, t, e) {
710
704
  var c, u;
711
705
  a && ((c = r.unsubscribe) === null || c === void 0 || c.call(r)), (u = r.finalize) === null || u === void 0 || u.call(r);
712
706
  }));
713
- }) : Se;
707
+ }) : Ee;
714
708
  }
715
- var et = Object.defineProperty, tt = (n, t, e) => t in n ? et(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, C = (n, t, e) => (tt(n, typeof t != "symbol" ? t + "" : t, e), e);
716
- class h extends Error {
709
+ var Ze = Object.defineProperty, et = (n, t, e) => t in n ? Ze(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, C = (n, t, e) => (et(n, typeof t != "symbol" ? t + "" : t, e), e);
710
+ class d extends Error {
717
711
  constructor(t) {
718
712
  super(`Incorrect context (${t}). Cannot perform the requested operation.`), C(this, "context"), this.context = t;
719
713
  }
720
714
  }
721
- class x extends Error {
715
+ class I extends Error {
722
716
  constructor(t, e, r) {
723
717
  super(`Invalid parameter (${t}). ${r}`), this.param = t, this.value = e, this.reason = r;
724
718
  }
725
719
  }
726
- class rt extends Error {
720
+ class tt extends Error {
727
721
  constructor(t, e) {
728
722
  super(
729
723
  `'streamId' value of "${t}" is different from what we expected ("${e}")`
730
724
  ), this.streamId = t, this.expectedStreamId = e;
731
725
  }
732
726
  }
733
- class nt extends Error {
727
+ class rt extends Error {
734
728
  constructor(t) {
735
729
  super(`Invalid version format: ${t}`);
736
730
  }
@@ -746,15 +740,15 @@ class le extends Error {
746
740
  e && (r += ` Minimum version supported is ${e}.`), super(r), this.version = t;
747
741
  }
748
742
  }
749
- function S(n) {
743
+ function E(n) {
750
744
  return typeof n == "function";
751
745
  }
752
- function st(n) {
753
- return S(n == null ? void 0 : n.lift);
746
+ function nt(n) {
747
+ return E(n == null ? void 0 : n.lift);
754
748
  }
755
749
  function P(n) {
756
750
  return function(t) {
757
- if (st(t))
751
+ if (nt(t))
758
752
  return t.lift(function(e) {
759
753
  try {
760
754
  return n(e, this);
@@ -815,18 +809,18 @@ function W(n, t) {
815
809
  return i;
816
810
  }
817
811
  function K(n, t, e) {
818
- if (e || arguments.length === 2)
812
+ if (arguments.length === 2)
819
813
  for (var r = 0, s = t.length, i; r < s; r++)
820
814
  (i || !(r in t)) && (i || (i = Array.prototype.slice.call(t, 0, r)), i[r] = t[r]);
821
815
  return n.concat(i || Array.prototype.slice.call(t));
822
816
  }
823
- function it(n) {
817
+ function st(n) {
824
818
  var t = function(r) {
825
819
  Error.call(r), r.stack = new Error().stack;
826
820
  }, e = n(t);
827
821
  return e.prototype = Object.create(Error.prototype), e.prototype.constructor = e, e;
828
822
  }
829
- var j = it(function(n) {
823
+ var j = st(function(n) {
830
824
  return function(t) {
831
825
  n(this), this.message = t ? t.length + ` errors occurred during unsubscription:
832
826
  ` + t.map(function(e, r) {
@@ -857,8 +851,8 @@ var te = function() {
857
851
  var u = c.value;
858
852
  u.remove(this);
859
853
  }
860
- } catch (v) {
861
- t = { error: v };
854
+ } catch (y) {
855
+ t = { error: y };
862
856
  } finally {
863
857
  try {
864
858
  c && !c.done && (e = a.return) && e.call(a);
@@ -870,29 +864,29 @@ var te = function() {
870
864
  else
871
865
  o.remove(this);
872
866
  var l = this.initialTeardown;
873
- if (S(l))
867
+ if (E(l))
874
868
  try {
875
869
  l();
876
- } catch (v) {
877
- i = v instanceof j ? v.errors : [v];
870
+ } catch (y) {
871
+ i = y instanceof j ? y.errors : [y];
878
872
  }
879
- var d = this._finalizers;
880
- if (d) {
873
+ var h = this._finalizers;
874
+ if (h) {
881
875
  this._finalizers = null;
882
876
  try {
883
- for (var y = he(d), b = y.next(); !b.done; b = y.next()) {
884
- var k = b.value;
877
+ for (var b = he(h), v = b.next(); !v.done; v = b.next()) {
878
+ var k = v.value;
885
879
  try {
886
880
  pe(k);
887
- } catch (v) {
888
- i = i ?? [], v instanceof j ? i = K(K([], W(i)), W(v.errors)) : i.push(v);
881
+ } catch (y) {
882
+ i = i ?? [], y instanceof j ? i = K(K([], W(i)), W(y.errors)) : i.push(y);
889
883
  }
890
884
  }
891
- } catch (v) {
892
- r = { error: v };
885
+ } catch (y) {
886
+ r = { error: y };
893
887
  } finally {
894
888
  try {
895
- b && !b.done && (s = y.return) && s.call(y);
889
+ v && !v.done && (s = b.return) && s.call(b);
896
890
  } finally {
897
891
  if (r)
898
892
  throw r.error;
@@ -934,10 +928,10 @@ var te = function() {
934
928
  }();
935
929
  te.EMPTY;
936
930
  function Ie(n) {
937
- return n instanceof te || n && "closed" in n && S(n.remove) && S(n.add) && S(n.unsubscribe);
931
+ return n instanceof te || n && "closed" in n && E(n.remove) && E(n.add) && E(n.unsubscribe);
938
932
  }
939
933
  function pe(n) {
940
- S(n) ? n() : n.unsubscribe();
934
+ E(n) ? n() : n.unsubscribe();
941
935
  }
942
936
  var Te = {
943
937
  onUnhandledError: null,
@@ -945,7 +939,7 @@ var Te = {
945
939
  Promise: void 0,
946
940
  useDeprecatedSynchronousErrorHandling: !1,
947
941
  useDeprecatedNextContext: !1
948
- }, ot = {
942
+ }, it = {
949
943
  setTimeout: function(n, t) {
950
944
  for (var e = [], r = 2; r < arguments.length; r++)
951
945
  e[r - 2] = arguments[r];
@@ -956,21 +950,21 @@ var Te = {
956
950
  },
957
951
  delegate: void 0
958
952
  };
959
- function at(n) {
960
- ot.setTimeout(function() {
953
+ function ot(n) {
954
+ it.setTimeout(function() {
961
955
  throw n;
962
956
  });
963
957
  }
964
958
  function fe() {
965
959
  }
966
- function ct(n) {
960
+ function at(n) {
967
961
  n();
968
962
  }
969
963
  var re = function(n) {
970
964
  ee(t, n);
971
965
  function t(e) {
972
966
  var r = n.call(this) || this;
973
- return r.isStopped = !1, e ? (r.destination = e, Ie(e) && e.add(r)) : r.destination = dt, r;
967
+ return r.isStopped = !1, e ? (r.destination = e, Ie(e) && e.add(r)) : r.destination = ht, r;
974
968
  }
975
969
  return t.create = function(e, r, s) {
976
970
  return new J(e, r, s);
@@ -997,11 +991,11 @@ var re = function(n) {
997
991
  this.unsubscribe();
998
992
  }
999
993
  }, t;
1000
- }(te), ut = Function.prototype.bind;
994
+ }(te), ct = Function.prototype.bind;
1001
995
  function Q(n, t) {
1002
- return ut.call(n, t);
996
+ return ct.call(n, t);
1003
997
  }
1004
- var lt = function() {
998
+ var ut = function() {
1005
999
  function n(t) {
1006
1000
  this.partialObserver = t;
1007
1001
  }
@@ -1036,7 +1030,7 @@ var lt = function() {
1036
1030
  ee(t, n);
1037
1031
  function t(e, r, s) {
1038
1032
  var i = n.call(this) || this, o;
1039
- if (S(e) || !e)
1033
+ if (E(e) || !e)
1040
1034
  o = {
1041
1035
  next: e ?? void 0,
1042
1036
  error: r ?? void 0,
@@ -1052,35 +1046,35 @@ var lt = function() {
1052
1046
  complete: e.complete && Q(e.complete, a)
1053
1047
  }) : o = e;
1054
1048
  }
1055
- return i.destination = new lt(o), i;
1049
+ return i.destination = new ut(o), i;
1056
1050
  }
1057
1051
  return t;
1058
1052
  }(re);
1059
1053
  function L(n) {
1060
- at(n);
1054
+ ot(n);
1061
1055
  }
1062
- function ht(n) {
1056
+ function lt(n) {
1063
1057
  throw n;
1064
1058
  }
1065
- var dt = {
1059
+ var ht = {
1066
1060
  closed: !0,
1067
1061
  next: fe,
1068
- error: ht,
1062
+ error: lt,
1069
1063
  complete: fe
1070
- }, pt = function() {
1064
+ }, dt = function() {
1071
1065
  return typeof Symbol == "function" && Symbol.observable || "@@observable";
1072
1066
  }();
1073
1067
  function Re(n) {
1074
1068
  return n;
1075
1069
  }
1076
- function ft(n) {
1070
+ function pt(n) {
1077
1071
  return n.length === 0 ? Re : n.length === 1 ? n[0] : function(t) {
1078
1072
  return n.reduce(function(e, r) {
1079
1073
  return r(e);
1080
1074
  }, t);
1081
1075
  };
1082
1076
  }
1083
- var gt = function() {
1077
+ var ft = function() {
1084
1078
  function n(t) {
1085
1079
  t && (this._subscribe = t);
1086
1080
  }
@@ -1088,8 +1082,8 @@ var gt = function() {
1088
1082
  var e = new n();
1089
1083
  return e.source = this, e.operator = t, e;
1090
1084
  }, n.prototype.subscribe = function(t, e, r) {
1091
- var s = this, i = yt(t) ? t : new J(t, e, r);
1092
- return ct(function() {
1085
+ var s = this, i = vt(t) ? t : new J(t, e, r);
1086
+ return at(function() {
1093
1087
  var o = s, a = o.operator, c = o.source;
1094
1088
  i.add(a ? a.call(i, c) : c ? s._subscribe(i) : s._trySubscribe(i));
1095
1089
  }), i;
@@ -1118,12 +1112,12 @@ var gt = function() {
1118
1112
  }, n.prototype._subscribe = function(t) {
1119
1113
  var e;
1120
1114
  return (e = this.source) === null || e === void 0 ? void 0 : e.subscribe(t);
1121
- }, n.prototype[pt] = function() {
1115
+ }, n.prototype[dt] = function() {
1122
1116
  return this;
1123
1117
  }, n.prototype.pipe = function() {
1124
1118
  for (var t = [], e = 0; e < arguments.length; e++)
1125
1119
  t[e] = arguments[e];
1126
- return ft(t)(this);
1120
+ return pt(t)(this);
1127
1121
  }, n.prototype.toPromise = function(t) {
1128
1122
  var e = this;
1129
1123
  return t = ge(t), new t(function(r, s) {
@@ -1144,16 +1138,16 @@ function ge(n) {
1144
1138
  var t;
1145
1139
  return (t = n ?? Te.Promise) !== null && t !== void 0 ? t : Promise;
1146
1140
  }
1147
- function vt(n) {
1148
- return n && S(n.next) && S(n.error) && S(n.complete);
1141
+ function gt(n) {
1142
+ return n && E(n.next) && E(n.error) && E(n.complete);
1149
1143
  }
1150
- function yt(n) {
1151
- return n && n instanceof re || vt(n) && Ie(n);
1144
+ function vt(n) {
1145
+ return n && n instanceof re || gt(n) && Ie(n);
1152
1146
  }
1153
1147
  function _(n, t, e, r, s) {
1154
- return new bt(n, t, e, r, s);
1148
+ return new yt(n, t, e, r, s);
1155
1149
  }
1156
- var bt = function(n) {
1150
+ var yt = function(n) {
1157
1151
  ee(t, n);
1158
1152
  function t(e, r, s, i, o, a) {
1159
1153
  var c = n.call(this, e) || this;
@@ -1197,12 +1191,12 @@ function p(n, t) {
1197
1191
  }));
1198
1192
  });
1199
1193
  }
1200
- var mt = new gt(function(n) {
1194
+ var bt = new ft(function(n) {
1201
1195
  return n.complete();
1202
1196
  });
1203
1197
  function m(n) {
1204
1198
  return n <= 0 ? function() {
1205
- return mt;
1199
+ return bt;
1206
1200
  } : P(function(t, e) {
1207
1201
  var r = 0;
1208
1202
  t.subscribe(_(e, function(s) {
@@ -1218,8 +1212,8 @@ function g(n, t) {
1218
1212
  }));
1219
1213
  });
1220
1214
  }
1221
- function wt(n, t) {
1222
- return t === void 0 && (t = !1), P(function(e, r) {
1215
+ function mt(n, t) {
1216
+ return P(function(e, r) {
1223
1217
  var s = 0;
1224
1218
  e.subscribe(_(r, function(i) {
1225
1219
  var o = n(i, s++);
@@ -1228,7 +1222,7 @@ function wt(n, t) {
1228
1222
  });
1229
1223
  }
1230
1224
  function f(n, t, e) {
1231
- var r = S(n) || t || e ? { next: n, error: t, complete: e } : n;
1225
+ var r = E(n) || t || e ? { next: n, error: t, complete: e } : n;
1232
1226
  return r ? P(function(s, i) {
1233
1227
  var o;
1234
1228
  (o = r.subscribe) === null || o === void 0 || o.call(r);
@@ -1248,14 +1242,14 @@ function f(n, t, e) {
1248
1242
  }));
1249
1243
  }) : Re;
1250
1244
  }
1251
- const Et = /^(\d+)\.(\d+)$/;
1245
+ const wt = /^(\d+)\.(\d+)$/;
1252
1246
  function St(n) {
1253
1247
  if (typeof n == "string") {
1254
- const t = n.match(Et);
1248
+ const t = n.match(wt);
1255
1249
  if (t)
1256
1250
  return `${t[1]}.${t[2]}`;
1257
1251
  }
1258
- throw new nt(n);
1252
+ throw new rt(n);
1259
1253
  }
1260
1254
  function ve(n) {
1261
1255
  const t = St(n), [e, r] = t.split("."), [s, i] = [parseInt(e), parseInt(r)];
@@ -1265,14 +1259,14 @@ function ne(n, t) {
1265
1259
  const [e, r] = ve(n), [s, i] = ve(t);
1266
1260
  return e < s ? -1 : e > s ? 1 : r < i ? -1 : r > i ? 1 : 0;
1267
1261
  }
1268
- function Ct(n, t) {
1262
+ function Et(n, t) {
1269
1263
  return ne(n, t) === 1;
1270
1264
  }
1271
- function Mt(n, t) {
1265
+ function Ct(n, t) {
1272
1266
  return ne(n, t) >= 0;
1273
1267
  }
1274
1268
  const ye = "2.0";
1275
- class xt {
1269
+ class Mt {
1276
1270
  /**
1277
1271
  * Create a new instance of the {@link IpcHelper | IPC Protocol Helper}.
1278
1272
  *
@@ -1283,7 +1277,7 @@ class xt {
1283
1277
  * @param logService - An instance of a logging service or utility
1284
1278
  */
1285
1279
  constructor(t, e) {
1286
- if (C(this, "negotiatedProtocolVersion"), C(this, "currentContext"), C(this, "incomingMessages$"), C(this, "inIframe", !1), C(this, "embeddedResult"), C(this, "iframePort1"), C(this, "iframePort2"), this.supportedVersions = t, this.logService = e, this.incomingMessages$ = new xe(), this.supportedVersions = t.filter((r) => Mt(r, ye)), !this.supportedVersions.length)
1280
+ if (C(this, "negotiatedProtocolVersion"), C(this, "currentContext"), C(this, "incomingMessages$"), C(this, "inIframe", !1), C(this, "embeddedResult"), C(this, "iframePort1"), C(this, "iframePort2"), this.supportedVersions = t, this.logService = e, this.incomingMessages$ = new xe(), this.supportedVersions = t.filter((r) => Ct(r, ye)), !this.supportedVersions.length)
1287
1281
  throw new le(t, ye);
1288
1282
  this.negotiatedProtocolVersion = this.supportedVersions[0], this.embeddedResult = null, this.iframePort2 = null;
1289
1283
  }
@@ -1320,7 +1314,7 @@ class xt {
1320
1314
  * @returns Observable with the {@link AppContext} the app is running under. Emits once.
1321
1315
  */
1322
1316
  determineContext() {
1323
- return Xe(1e3).pipe(
1317
+ return Je(1e3).pipe(
1324
1318
  p(() => (this.isEmbedded() ? this.currentContext = "user" : this.currentContext = "guest", this.currentContext)),
1325
1319
  m(1)
1326
1320
  );
@@ -1333,15 +1327,15 @@ class xt {
1333
1327
  */
1334
1328
  openBridge() {
1335
1329
  if (!this.isEmbedded())
1336
- throw new h(this.currentContext);
1330
+ throw new d(this.currentContext);
1337
1331
  const t = "HELLO", e = this.createMessage(t);
1338
1332
  e.protocolVersions = this.supportedVersions, this.logCreated(t, e);
1339
1333
  const r = this.incomingMessages$.pipe(
1340
1334
  g((s) => s.type === t && s.replyTo === e.id),
1341
1335
  p((s) => s),
1342
- f(this.logReceived(t)),
1336
+ f(this.logReceived()),
1343
1337
  p((s) => {
1344
- if (this.supportedVersions.some((i) => Ct(i, s.protocolVersion)))
1338
+ if (this.supportedVersions.some((i) => Et(i, s.protocolVersion)))
1345
1339
  throw new le(s.protocolVersion, this.supportedVersions[0]);
1346
1340
  return s;
1347
1341
  }),
@@ -1363,13 +1357,13 @@ class xt {
1363
1357
  */
1364
1358
  requestSSOToken() {
1365
1359
  if (!this.isEmbedded())
1366
- throw new h(this.currentContext);
1360
+ throw new d(this.currentContext);
1367
1361
  const t = "TOKEN", e = this.createMessage(t);
1368
1362
  this.logCreated(t, e);
1369
1363
  const r = this.incomingMessages$.pipe(
1370
1364
  g((s) => s.type === t && s.replyTo === e.id),
1371
1365
  p((s) => s),
1372
- f(this.logReceived(t)),
1366
+ f(this.logReceived()),
1373
1367
  m(1)
1374
1368
  );
1375
1369
  return this.logService.debug(`Created ${t} Reply handler`), this.port2.postMessage(e), this.logSent(t, e), r;
@@ -1389,7 +1383,7 @@ class xt {
1389
1383
  */
1390
1384
  sendJoiningRoomMessage(t) {
1391
1385
  if (!this.isEmbedded())
1392
- throw new h(this.currentContext);
1386
+ throw new d(this.currentContext);
1393
1387
  const {
1394
1388
  roomName: e,
1395
1389
  roomInvite: r,
@@ -1399,8 +1393,8 @@ class xt {
1399
1393
  region: a,
1400
1394
  joinMicMuted: c,
1401
1395
  joinWithoutCamera: u
1402
- } = t, l = "JOINING ROOM", d = this.createMessage(l, !1);
1403
- d.roomName = e, d.jwtToken = i, d.serverUrl = o, d.region = a, d.roomInvite = r, d.joinMicMuted = c ?? !1, d.joinWithoutCamera = u ?? !1, d.displayName = s, this.logCreated(l, d), this.port2.postMessage(d), this.logSent(l, d);
1396
+ } = t, l = "JOINING ROOM", h = this.createMessage(l, !1);
1397
+ h.roomName = e, h.jwtToken = i, h.serverUrl = o, h.region = a, h.roomInvite = r, h.joinMicMuted = c ?? !1, h.joinWithoutCamera = u ?? !1, h.displayName = s, this.logCreated(l, h), this.port2.postMessage(h), this.logSent(l, h);
1404
1398
  }
1405
1399
  /**
1406
1400
  * Sends a {@link LeavingRoomMessage} lifecycle message to the Host app.
@@ -1415,7 +1409,7 @@ class xt {
1415
1409
  */
1416
1410
  sendLeavingRoomMessage(t) {
1417
1411
  if (!this.isEmbedded())
1418
- throw new h(this.currentContext);
1412
+ throw new d(this.currentContext);
1419
1413
  const e = "LEAVING ROOM", r = this.createMessage(e, !1);
1420
1414
  r.roomName = t, this.logCreated(e, r), this.port2.postMessage(r), this.logSent(e, r);
1421
1415
  }
@@ -1447,12 +1441,12 @@ class xt {
1447
1441
  */
1448
1442
  onJoinRoomMessage() {
1449
1443
  if (!this.isEmbedded())
1450
- throw new h(this.currentContext);
1444
+ throw new d(this.currentContext);
1451
1445
  const t = "JOIN ROOM";
1452
1446
  return this.incomingMessages$.pipe(
1453
1447
  g((e) => e.type === t && e.target === "client"),
1454
1448
  p((e) => e),
1455
- f(this.logReceived(t)),
1449
+ f(this.logReceived()),
1456
1450
  p((e) => e)
1457
1451
  );
1458
1452
  }
@@ -1483,12 +1477,12 @@ class xt {
1483
1477
  */
1484
1478
  onLeaveRoomMessage() {
1485
1479
  if (!this.isEmbedded())
1486
- throw new h(this.currentContext);
1480
+ throw new d(this.currentContext);
1487
1481
  const t = "LEAVE ROOM";
1488
1482
  return this.incomingMessages$.pipe(
1489
1483
  g((e) => e.type === t && e.target === "client"),
1490
1484
  p((e) => e),
1491
- f(this.logReceived(t)),
1485
+ f(this.logReceived()),
1492
1486
  p((e) => e)
1493
1487
  );
1494
1488
  }
@@ -1520,12 +1514,12 @@ class xt {
1520
1514
  */
1521
1515
  onConfigMessage() {
1522
1516
  if (!this.isEmbedded())
1523
- throw new h(this.currentContext);
1517
+ throw new d(this.currentContext);
1524
1518
  const t = "CONFIG";
1525
1519
  return this.incomingMessages$.pipe(
1526
1520
  g((e) => e.type === t && e.target === "client"),
1527
1521
  p((e) => e),
1528
- f(this.logReceived(t)),
1522
+ f(this.logReceived()),
1529
1523
  p((e) => ({
1530
1524
  preferredCameraType: e.preferredCameraType,
1531
1525
  preferredMicType: e.preferredMicType,
@@ -1542,13 +1536,13 @@ class xt {
1542
1536
  }
1543
1537
  sendScreenshareSourceMessage(t) {
1544
1538
  if (!this.isEmbedded())
1545
- throw new h(this.currentContext);
1539
+ throw new d(this.currentContext);
1546
1540
  const e = "SCREENSHARE SOURCE", r = this.createMessage(e);
1547
1541
  r.sourceTypes = t, this.logCreated(e, r);
1548
1542
  const s = this.incomingMessages$.pipe(
1549
1543
  g((i) => i.type === e && i.replyTo === r.id),
1550
1544
  p((i) => i),
1551
- f(this.logReceived(e)),
1545
+ f(this.logReceived()),
1552
1546
  p((i) => i),
1553
1547
  m(1)
1554
1548
  );
@@ -1556,13 +1550,13 @@ class xt {
1556
1550
  }
1557
1551
  layoutChange(t, e, r) {
1558
1552
  if (!this.isEmbedded())
1559
- throw new h(this.currentContext);
1553
+ throw new d(this.currentContext);
1560
1554
  const s = "LAYOUT CHANGE";
1561
1555
  let i, o;
1562
1556
  if (e && r ? (i = this.createMessage(s, !1, r), i.result = e) : (i = this.createMessage(s), o = this.incomingMessages$.pipe(
1563
1557
  g((a) => a.type === s && a.replyTo === i.id),
1564
1558
  p((a) => a),
1565
- f(this.logReceived(s)),
1559
+ f(this.logReceived()),
1566
1560
  p((a) => a),
1567
1561
  m(1)
1568
1562
  ), this.logService.debug(`Created ${s} Reply handler`)), i.layout = t, this.logCreated(s, i), this.port2.postMessage(i), this.logSent(s, i), o)
@@ -1601,46 +1595,46 @@ class xt {
1601
1595
  */
1602
1596
  onLayoutChangeMessage() {
1603
1597
  if (!this.isEmbedded())
1604
- throw new h(this.currentContext);
1598
+ throw new d(this.currentContext);
1605
1599
  const t = "LAYOUT CHANGE";
1606
1600
  return this.incomingMessages$.pipe(
1607
1601
  g((e) => e.type === t && e.target === "client" && e.replyTo === null),
1608
1602
  p((e) => e),
1609
- f(this.logReceived(t)),
1603
+ f(this.logReceived()),
1610
1604
  p((e) => e)
1611
1605
  );
1612
1606
  }
1613
1607
  requestOAuthToken(t) {
1614
1608
  if (!this.isEmbedded())
1615
- throw new h(this.currentContext);
1609
+ throw new d(this.currentContext);
1616
1610
  Array.isArray(t) || (t = [t]);
1617
1611
  const e = "OAUTH TOKEN", r = this.createMessage(e);
1618
1612
  r.providerTypes = t, this.logCreated(e, r);
1619
1613
  const s = this.incomingMessages$.pipe(
1620
1614
  g((i) => i.type === e && i.replyTo === r.id),
1621
1615
  p((i) => i),
1622
- f(this.logReceived(e)),
1616
+ f(this.logReceived()),
1623
1617
  m(1)
1624
1618
  );
1625
1619
  return this.logService.debug(`Created ${e} Reply handler`), this.port2.postMessage(r), this.logSent(e, r), s;
1626
1620
  }
1627
1621
  openUrl(t, e) {
1628
1622
  if (!this.isEmbedded())
1629
- throw new h(this.currentContext);
1623
+ throw new d(this.currentContext);
1630
1624
  const r = "OPEN URL", s = this.createMessage(r, !1);
1631
1625
  s.url = t, s.data = e, this.logCreated(r, s), this.port2.postMessage(s), this.logSent(r, s);
1632
1626
  }
1633
1627
  selectContacts(t, e, r, s) {
1634
1628
  if (!this.isEmbedded())
1635
- throw new h(this.currentContext);
1629
+ throw new d(this.currentContext);
1636
1630
  if (e === "group" && s === void 0)
1637
- throw new x(
1631
+ throw new I(
1638
1632
  "currentContacts",
1639
1633
  s,
1640
1634
  "currentContacts is required for group streams"
1641
1635
  );
1642
1636
  if (e === "direct" && s !== void 0)
1643
- throw new x(
1637
+ throw new I(
1644
1638
  "currentContacts",
1645
1639
  s,
1646
1640
  "currentContacts should not be passed for direct streams"
@@ -1649,13 +1643,16 @@ class xt {
1649
1643
  o.streamType = e, o.streamId = t, o.contactType = r, o.currentContacts = s, this.logCreated(i, o);
1650
1644
  const a = this.incomingMessages$.pipe(
1651
1645
  g((c) => c.type === i && c.replyTo === o.id),
1652
- f(this.logReceived(i)),
1646
+ f(this.logReceived()),
1653
1647
  // validate if `streamId` is the same as we sent
1654
1648
  p((c) => {
1655
1649
  const u = c;
1656
- if (u.streamId !== t)
1657
- throw new rt(u.streamId, t);
1658
- return e === "direct" && u.contacts.length > 1 && (u.contacts = [u.contacts[0]]), u;
1650
+ if (u.result === "success") {
1651
+ if (u.streamId !== t)
1652
+ throw new tt(u.streamId, t);
1653
+ e === "direct" && u.contacts.length > 1 && (u.contacts = [u.contacts[0]]);
1654
+ }
1655
+ return u;
1659
1656
  }),
1660
1657
  m(1)
1661
1658
  );
@@ -1671,14 +1668,14 @@ class xt {
1671
1668
  */
1672
1669
  matchContacts(t) {
1673
1670
  if (!this.isEmbedded())
1674
- throw new h(this.currentContext);
1671
+ throw new d(this.currentContext);
1675
1672
  if (!t.length)
1676
- throw new x("contacts", t, "At least one contact is required");
1673
+ throw new I("contacts", t, "At least one contact is required");
1677
1674
  const e = "MATCH CONTACTS", r = this.createMessage(e);
1678
1675
  r.contacts = [...t], this.logCreated(e, r);
1679
1676
  const s = this.incomingMessages$.pipe(
1680
1677
  g((i) => i.type === e && i.replyTo === r.id),
1681
- f(this.logReceived(e)),
1678
+ f(this.logReceived()),
1682
1679
  p((i) => i),
1683
1680
  m(1)
1684
1681
  );
@@ -1712,12 +1709,12 @@ class xt {
1712
1709
  */
1713
1710
  onPushMessageMessage() {
1714
1711
  if (!this.isEmbedded())
1715
- throw new h(this.currentContext);
1712
+ throw new d(this.currentContext);
1716
1713
  const t = "PUSH MESSAGE";
1717
1714
  return this.incomingMessages$.pipe(
1718
1715
  g((e) => e.type === t && e.target === "client"),
1719
1716
  p((e) => e),
1720
- f(this.logReceived(t))
1717
+ f(this.logReceived())
1721
1718
  );
1722
1719
  }
1723
1720
  /**
@@ -1731,12 +1728,12 @@ class xt {
1731
1728
  */
1732
1729
  requestPushToken() {
1733
1730
  if (!this.isEmbedded())
1734
- throw new h(this.currentContext);
1731
+ throw new d(this.currentContext);
1735
1732
  const t = "PUSH TOKEN", e = this.createMessage(t);
1736
1733
  this.logCreated(t, e);
1737
1734
  const r = this.incomingMessages$.pipe(
1738
1735
  g((s) => s.type === t && s.replyTo === e.id),
1739
- f(this.logReceived(t)),
1736
+ f(this.logReceived()),
1740
1737
  p((s) => s),
1741
1738
  m(1)
1742
1739
  );
@@ -1771,7 +1768,7 @@ class xt {
1771
1768
  */
1772
1769
  onPushTokenMessage() {
1773
1770
  if (!this.isEmbedded())
1774
- throw new h(this.currentContext);
1771
+ throw new d(this.currentContext);
1775
1772
  const t = "PUSH TOKEN";
1776
1773
  return this.incomingMessages$.pipe(
1777
1774
  g(
@@ -1783,7 +1780,7 @@ class xt {
1783
1780
  throw new Error("PushTokenMessage is missing required PushTokenPayload fields");
1784
1781
  }),
1785
1782
  f((e) => e.pushToken),
1786
- f(this.logReceived(t))
1783
+ f(this.logReceived())
1787
1784
  );
1788
1785
  }
1789
1786
  /**
@@ -1795,12 +1792,12 @@ class xt {
1795
1792
  */
1796
1793
  onBadgeQueryMessage() {
1797
1794
  if (!this.isEmbedded())
1798
- throw new h(this.currentContext);
1795
+ throw new d(this.currentContext);
1799
1796
  const t = "BADGE QUERY";
1800
1797
  return this.incomingMessages$.pipe(
1801
1798
  g((e) => e.type === t && e.target === "client"),
1802
1799
  p((e) => e),
1803
- f(this.logReceived(t))
1800
+ f(this.logReceived())
1804
1801
  );
1805
1802
  }
1806
1803
  /**
@@ -1817,7 +1814,7 @@ class xt {
1817
1814
  */
1818
1815
  sendBadgeUpdateMessage(t, e, r) {
1819
1816
  if (!this.isEmbedded())
1820
- throw new h(this.currentContext);
1817
+ throw new d(this.currentContext);
1821
1818
  const s = "BADGE UPDATE", i = this.createMessage(s, !1, r);
1822
1819
  i.count = t, i.activity = e ?? !1, this.logCreated(s, i), this.port2.postMessage(i), this.logSent(s, i);
1823
1820
  }
@@ -1836,7 +1833,7 @@ class xt {
1836
1833
  */
1837
1834
  sendLifecycleMessage(t, e) {
1838
1835
  if (!this.isEmbedded())
1839
- throw new h(this.currentContext);
1836
+ throw new d(this.currentContext);
1840
1837
  const r = "LIFECYCLE", s = this.createMessage(r, !1);
1841
1838
  s.eventName = t, s.payload = e, this.logCreated(r, s), this.port2.postMessage(s), this.logSent(r, s);
1842
1839
  }
@@ -1853,12 +1850,12 @@ class xt {
1853
1850
  */
1854
1851
  onLifecycleMessage() {
1855
1852
  if (!this.isEmbedded())
1856
- throw new h(this.currentContext);
1853
+ throw new d(this.currentContext);
1857
1854
  const t = "LIFECYCLE";
1858
1855
  return this.incomingMessages$.pipe(
1859
1856
  g((e) => e.type === t && e.target === "client"),
1860
1857
  p((e) => e),
1861
- f(this.logReceived(t))
1858
+ f(this.logReceived())
1862
1859
  );
1863
1860
  }
1864
1861
  /**
@@ -1875,7 +1872,7 @@ class xt {
1875
1872
  */
1876
1873
  sendLogMessage(t, e) {
1877
1874
  if (!this.isEmbedded())
1878
- throw new h(this.currentContext);
1875
+ throw new d(this.currentContext);
1879
1876
  const r = "LOG", s = this.createMessage(r, !1);
1880
1877
  s.level = t, s.message = e, this.logCreated(r, s), this.port2.postMessage(s), this.logSent(r, s);
1881
1878
  }
@@ -1893,12 +1890,12 @@ class xt {
1893
1890
  */
1894
1891
  onRequestLogsMessage() {
1895
1892
  if (!this.isEmbedded())
1896
- throw new h(this.currentContext);
1893
+ throw new d(this.currentContext);
1897
1894
  const t = "REQUEST LOGS";
1898
1895
  return this.incomingMessages$.pipe(
1899
1896
  g((e) => e.type === t && e.target === "client"),
1900
1897
  p((e) => e),
1901
- f(this.logReceived(t))
1898
+ f(this.logReceived())
1902
1899
  );
1903
1900
  }
1904
1901
  /**
@@ -1916,7 +1913,7 @@ class xt {
1916
1913
  */
1917
1914
  sendViewTransitionMessage(t, e) {
1918
1915
  if (!this.isEmbedded())
1919
- throw new h(this.currentContext);
1916
+ throw new d(this.currentContext);
1920
1917
  const r = "VIEW TRANSITION", s = this.createMessage(r, !1);
1921
1918
  s.transitionType = t, s.targetView = e, this.logCreated(r, s), this.port2.postMessage(s), this.logSent(r, s);
1922
1919
  }
@@ -1963,11 +1960,11 @@ class xt {
1963
1960
  */
1964
1961
  sendFileRequestMessage(t, e, r, s, i) {
1965
1962
  if (!this.isEmbedded())
1966
- throw new h(this.currentContext);
1963
+ throw new d(this.currentContext);
1967
1964
  const o = "FILE REQUEST", a = this.createMessage(o);
1968
1965
  if (a.fileId = t, a.fileHash = e.toLowerCase(), a.intent = r, a.maxChunkSizeInBytes = i, r === "attachment") {
1969
1966
  if (!s)
1970
- throw new x(
1967
+ throw new I(
1971
1968
  "streamId",
1972
1969
  s,
1973
1970
  "streamId is required for attachment intent"
@@ -1980,10 +1977,10 @@ class xt {
1980
1977
  g(
1981
1978
  (l) => l.type === o && l.replyTo === a.id
1982
1979
  ),
1983
- f(this.logReceived(o)),
1980
+ f(this.logReceived()),
1984
1981
  f(() => c++),
1985
1982
  p((l) => (l.result === "success" && (l.chunkHash = l.chunkHash.toLowerCase(), l.fileHash = l.fileHash.toLowerCase()), l)),
1986
- wt((l) => l.result === "success" && c < l.totalChunks, !0)
1983
+ mt((l) => l.result === "success" && c < l.totalChunks, !0)
1987
1984
  );
1988
1985
  return this.port2.postMessage(a), this.logSent(o, a), u;
1989
1986
  }
@@ -2008,7 +2005,7 @@ class xt {
2008
2005
  */
2009
2006
  sendFileRequestMessageReply(t, e) {
2010
2007
  if (!this.isEmbedded())
2011
- throw new h(this.currentContext);
2008
+ throw new d(this.currentContext);
2012
2009
  const r = "FILE REQUEST", s = Object.assign(
2013
2010
  e,
2014
2011
  this.createMessage(r, !1, t.id)
@@ -2029,14 +2026,14 @@ class xt {
2029
2026
  */
2030
2027
  onFileRequestMessage() {
2031
2028
  if (!this.isEmbedded())
2032
- throw new h(this.currentContext);
2029
+ throw new d(this.currentContext);
2033
2030
  const t = "FILE REQUEST";
2034
2031
  return this.incomingMessages$.pipe(
2035
2032
  g(
2036
2033
  (e) => e.type === t && e.target === "client" && e.replyTo === null
2037
2034
  ),
2038
2035
  p((e) => (e.fileHash = e.fileHash.toLowerCase(), e)),
2039
- f(this.logReceived(t))
2036
+ f(this.logReceived())
2040
2037
  );
2041
2038
  }
2042
2039
  /**
@@ -2063,17 +2060,17 @@ class xt {
2063
2060
  */
2064
2061
  sendFileSelectionMessage(t = "attachment", e, r, s, i, o) {
2065
2062
  if (!this.isEmbedded())
2066
- throw new h(this.currentContext);
2063
+ throw new d(this.currentContext);
2067
2064
  const a = "FILE SELECTION", c = this.createMessage(a);
2068
2065
  if (c.intent = t, c.maxCount = s, c.maxFileSizeInBytes = i, c.mimeTypes = o, t === "attachment") {
2069
2066
  if (!e)
2070
- throw new x(
2067
+ throw new I(
2071
2068
  "streamId",
2072
2069
  e,
2073
2070
  "streamId is required for attachment intent"
2074
2071
  );
2075
2072
  if (!r)
2076
- throw new x(
2073
+ throw new I(
2077
2074
  "correlationId",
2078
2075
  r,
2079
2076
  "correlationId is required for attachment intent"
@@ -2086,41 +2083,14 @@ class xt {
2086
2083
  (l) => l.type === a && l.replyTo === c.id
2087
2084
  ),
2088
2085
  p((l) => {
2089
- var d;
2090
- return l.files = (d = l.files) == null ? void 0 : d.map((y) => (y.original.fileHash = y.original.fileHash.toLowerCase(), y.preview && (y.preview.fileHash = y.preview.fileHash.toLowerCase()), y)), l;
2086
+ var h;
2087
+ return l.result === "success" && (l.files = (h = l.files) == null ? void 0 : h.map((b) => (b.original.fileHash = b.original.fileHash.toLowerCase(), b.preview && (b.preview.fileHash = b.preview.fileHash.toLowerCase()), b))), l;
2091
2088
  }),
2092
- f(this.logReceived(a)),
2089
+ f(this.logReceived()),
2093
2090
  m(1)
2094
2091
  );
2095
2092
  return this.port2.postMessage(c), this.logSent(a, c), u;
2096
2093
  }
2097
- /**
2098
- * Sends a {@link FileDownloadMessage} to the Host app, to request the download of a file.
2099
- *
2100
- * @remarks
2101
- * The file at the specified `url` is encrypted using the provided `key` and the Host app needs
2102
- * to decrypt it.
2103
- *
2104
- * @param url - The URL to download the file from
2105
- * @param key - The decryption key for the file stream
2106
- * @param fileName - The name of the file to download
2107
- * @param mimeType - The MIME type of the file to download
2108
- * @returns An observable which emits a {@link FileDownloadMessageReply} instance containing the
2109
- * file ID and the file size in bytes. Emits once.
2110
- */
2111
- sendFileDownloadMessage(t, e, r, s) {
2112
- if (!this.isEmbedded())
2113
- throw new h(this.currentContext);
2114
- const i = "FILE DOWNLOAD", o = this.createMessage(i);
2115
- o.url = t, o.key = e, o.fileName = r, o.mimeType = s, this.logCreated(i, o);
2116
- const a = this.incomingMessages$.pipe(
2117
- g((c) => c.type === i && c.replyTo === o.id),
2118
- f(this.logReceived(i)),
2119
- p((c) => c),
2120
- m(1)
2121
- );
2122
- return this.port2.postMessage(o), this.logSent(i, o), a;
2123
- }
2124
2094
  /**
2125
2095
  * Sends a {@link FileDownloadProgressQueryMessage} to the Host app, to query the progress of a
2126
2096
  * file download that was initiated by a {@link FileDownloadMessage}.
@@ -2133,25 +2103,26 @@ class xt {
2133
2103
  * The `Host` app should reply with a {@link FileDownloadProgressUpdateMessage} containing the
2134
2104
  * progress of the file download.
2135
2105
  *
2136
- * @param correlationId - A UUIDv4 string to identify the message this file was attached to.
2137
2106
  * @param fileHash - SHA256 hash of the decrypted file.
2138
2107
  * @param url - URL of the file being downloaded.
2108
+ * @param correlationId - _Optional_. A UUIDv4 string to identify the message this file was
2109
+ * attached to.
2139
2110
  * @returns An observable which emits a {@link FileDownloadProgressUpdateMessage} instance
2140
2111
  * containing the progress of the file download. Emits once.
2141
2112
  */
2142
2113
  sendFileDownloadProgressQueryMessage(t, e, r) {
2143
2114
  if (!this.isEmbedded())
2144
- throw new h(this.currentContext);
2115
+ throw new d(this.currentContext);
2145
2116
  const s = "FILE DOWNLOAD PROGRESS QUERY", i = this.createMessage(
2146
2117
  s,
2147
2118
  !0
2148
2119
  );
2149
- i.correlationId = t, i.fileHash = e.toLowerCase(), i.url = r, this.logCreated(s, i);
2120
+ i.fileHash = t.toLowerCase(), i.url = e, i.correlationId = r, this.logCreated(s, i);
2150
2121
  const o = this.incomingMessages$.pipe(
2151
2122
  g(
2152
2123
  (a) => a.type === "FILE DOWNLOAD PROGRESS UPDATE" && a.replyTo === i.id
2153
2124
  ),
2154
- f(this.logReceived(s)),
2125
+ f((a) => this.logReceived(a)),
2155
2126
  p((a) => (a.fileHash && (a.fileHash = a.fileHash.toLowerCase()), a)),
2156
2127
  m(1)
2157
2128
  );
@@ -2159,21 +2130,21 @@ class xt {
2159
2130
  }
2160
2131
  /**
2161
2132
  * Setup listener for {@link FileDownloadProgressQueryMessage}, which can be sent by a `Host` app
2162
- * to update the progress of a file download which was initiated by a {@link FileOpenMessage}.
2133
+ * to update the progress of a file download which was initiated by a {@link FileDownloadMessage}.
2163
2134
  *
2164
2135
  * @returns An observable which emits a {@link FileDownloadProgressUpdateMessage} instance
2165
2136
  * containing the progress of the file download. Emits once.
2166
2137
  */
2167
2138
  onFileDownloadProgressUpdateMessage() {
2168
2139
  if (!this.isEmbedded())
2169
- throw new h(this.currentContext);
2140
+ throw new d(this.currentContext);
2170
2141
  const t = "FILE DOWNLOAD PROGRESS UPDATE";
2171
2142
  return this.incomingMessages$.pipe(
2172
2143
  g(
2173
2144
  (e) => e.type === t && e.target === "client" && e.replyTo === null
2174
2145
  ),
2175
2146
  p((e) => (e.fileHash && (e.fileHash = e.fileHash.toLowerCase()), e)),
2176
- f(this.logReceived(t))
2147
+ f(this.logReceived())
2177
2148
  );
2178
2149
  }
2179
2150
  /**
@@ -2184,25 +2155,25 @@ class xt {
2184
2155
  * The `host` app should reply with a {@link FileUploadProgressUpdateMessage} containing the
2185
2156
  * progress of the file upload.
2186
2157
  *
2187
- * @param correlationId - A UUIDv4 string to identify the message this file was attached to.
2188
2158
  * @param fileHash - SHA256 hash of the decrypted file.
2189
2159
  * @param fileId - ID of the original file being uploaded.
2160
+ * @param correlationId - _Optional_. A UUIDv4 string to identify the message this file was attached to.
2190
2161
  * @returns An observable which emits a {@link FileUploadProgressUpdateMessage} instance
2191
2162
  * containing the progress of the file upload. Emits once.
2192
2163
  */
2193
2164
  sendFileUploadProgressQueryMessage(t, e, r) {
2194
2165
  if (!this.isEmbedded())
2195
- throw new h(this.currentContext);
2166
+ throw new d(this.currentContext);
2196
2167
  const s = "FILE UPLOAD PROGRESS QUERY", i = this.createMessage(
2197
2168
  s,
2198
2169
  !0
2199
2170
  );
2200
- i.correlationId = t, i.fileHash = e.toLowerCase(), i.fileId = r, this.logCreated(s, i);
2171
+ i.fileHash = t.toLowerCase(), i.fileId = e, i.correlationId = r, this.logCreated(s, i);
2201
2172
  const o = this.incomingMessages$.pipe(
2202
2173
  g(
2203
- (a) => a.type === "FILE DOWNLOAD PROGRESS UPDATE" && a.replyTo === i.id
2174
+ (a) => a.type === "FILE UPLOAD PROGRESS UPDATE" && a.replyTo === i.id
2204
2175
  ),
2205
- f(this.logReceived(s)),
2176
+ f(this.logReceived()),
2206
2177
  p((a) => (a.fileHash && (a.fileHash = a.fileHash.toLowerCase()), a)),
2207
2178
  m(1)
2208
2179
  );
@@ -2221,62 +2192,67 @@ class xt {
2221
2192
  */
2222
2193
  onFileUploadProgressUpdateMessage() {
2223
2194
  if (!this.isEmbedded())
2224
- throw new h(this.currentContext);
2195
+ throw new d(this.currentContext);
2225
2196
  const t = "FILE UPLOAD PROGRESS UPDATE";
2226
2197
  return this.incomingMessages$.pipe(
2227
2198
  g(
2228
2199
  (e) => e.type === t && e.target === "client" && e.replyTo === null
2229
2200
  ),
2230
2201
  p((e) => (e.fileHash && (e.fileHash = e.fileHash.toLowerCase()), e)),
2231
- f(this.logReceived(t))
2202
+ f(this.logReceived())
2232
2203
  );
2233
2204
  }
2234
2205
  /**
2235
- * Sends a {@link FileOpenMessage} to the Host app, to try and open a file the device may already
2236
- * have in it's storage.
2206
+ * Sends a {@link FileDownloadMessage} to the Host app, to download a file.
2237
2207
  *
2238
2208
  * @remarks
2239
2209
  * The `fileHash` parameter is the SHA256 hash of the decrypted file, which is used as an
2240
2210
  * identifier for the target file in the `Host` app as well as to verify the integrity of the
2241
2211
  * file.
2242
2212
  *
2243
- * @param fileHash - The SHA256 hash of the file to open.
2244
- * @param fileName - _Optional_. The name of the file to open.
2245
- * @param streamId - _Optional_. The ID of the message stream from which the file is opened from.
2246
- * @param url - _Optional_. URL from where the host can download the file if it isn't in storage.
2213
+ * If the `host` already has the file in it's storage, it can reply with a
2214
+ * {@link FileDownloadSkippedResult} to notify the client that the download was skipped.
2215
+ *
2216
+ * @param url - URL from where the host should download the file if it isn't in storage.
2217
+ * @param key - Key used to encrypt the original attachment.
2218
+ * @param fileHash - The SHA256 hash of the file to download.
2219
+ * @param mimeType - The MIME type of the file to download.
2220
+ * @param fileName - _Optional_. The name of the file to download.
2221
+ * @param streamId - _Optional_. ID of the message stream from which the file is downloaded from.
2247
2222
  * @param correlationId - _Optional_. Correlation ID of the message this file was attached to.
2248
- * @param key - _Optional_. Key used to encrypt the original attachment.
2249
2223
  * @param sender - _Optional_. The {@link ContactItem} of the sender of the file.
2224
+ * @param intent - _Optional_. The intent of the file download. Can be either `download` or
2225
+ * `open`. Defaults to `download`.
2250
2226
  *
2251
- * @returns An observable which emits a {@link FileOpenMessageReply} instance containing the
2227
+ * @returns An observable which emits a {@link FileDownloadMessageReply} instance containing the
2252
2228
  * result of the request. Emits once.
2253
2229
  */
2254
- sendFileOpenMessage(t, e, r, s, i, o, a) {
2230
+ sendFileDownloadMessage(t, e, r, s, i, o, a, c, u) {
2255
2231
  if (!this.isEmbedded())
2256
- throw new h(this.currentContext);
2257
- const c = "FILE OPEN", u = this.createMessage(c, !0);
2258
- u.fileHash = t.toLowerCase(), u.fileName = e, u.streamId = r, u.url = s, u.correlationId = i, u.key = o, u.sender = a, this.logCreated(c, u);
2259
- const l = this.incomingMessages$.pipe(
2260
- g((d) => d.type === c && d.replyTo === u.id),
2261
- f(this.logReceived(c)),
2262
- p((d) => d),
2232
+ throw new d(this.currentContext);
2233
+ const l = "FILE DOWNLOAD", h = this.createMessage(l, !0);
2234
+ h.url = t, h.key = e, h.fileHash = r.toLowerCase(), h.mimeType = s, h.fileName = i, h.streamId = o, h.correlationId = a, h.sender = c, h.intent = u ?? "download", this.logCreated(l, h);
2235
+ const b = this.incomingMessages$.pipe(
2236
+ g((v) => v.type === l && v.replyTo === h.id),
2237
+ f(this.logReceived()),
2238
+ p((v) => v),
2263
2239
  m(1)
2264
2240
  );
2265
- return this.port2.postMessage(u), this.logSent(c, u), l;
2241
+ return this.port2.postMessage(h), this.logSent(l, h), b;
2266
2242
  }
2267
2243
  /**
2268
- * Sends a {@link CancelFileOpenMessage} to the Host app, to cancel opening or download of a file
2269
- * that was initiated by a {@link FileOpenMessage} previously.
2244
+ * Sends a {@link CancelFileDownloadMessage} to the Host app, to cancel downloading of a file
2245
+ * that was initiated by a {@link FileDownloadMessage} previously.
2270
2246
  *
2271
- * @param correlationId - UUIDv4 string to identify the message this file was attached to.
2272
- * @param fileHash - SHA256 hash of the file to cancel opening.
2247
+ * @param fileHash - SHA256 hash of the file to cancel downloading.
2273
2248
  * @param url - URL of the file to cancel download.
2249
+ * @param correlationId - _Optional_. UUIDv4 string to identify the message this file was attached to.
2274
2250
  */
2275
- sendCancelFileOpenMessage(t, e, r) {
2251
+ sendCancelFileDownloadMessage(t, e, r) {
2276
2252
  if (!this.isEmbedded())
2277
- throw new h(this.currentContext);
2278
- const s = "CANCEL FILE OPEN", i = this.createMessage(s, !1);
2279
- i.correlationId = t, i.fileHash = e.toLowerCase(), i.url = r, this.logCreated(s, i), this.port2.postMessage(i), this.logSent(s, i);
2253
+ throw new d(this.currentContext);
2254
+ const s = "CANCEL FILE DOWNLOAD", i = this.createMessage(s, !1);
2255
+ i.fileHash = t.toLowerCase(), i.url = e, i.correlationId = r, this.logCreated(s, i), this.port2.postMessage(i), this.logSent(s, i);
2280
2256
  }
2281
2257
  /**
2282
2258
  * Sends a {@link FileRemoveMessage} to the Host app, to request removal of a file from the
@@ -2295,12 +2271,12 @@ class xt {
2295
2271
  */
2296
2272
  sendFileRemoveMessage(t, e) {
2297
2273
  if (!this.isEmbedded())
2298
- throw new h(this.currentContext);
2274
+ throw new d(this.currentContext);
2299
2275
  const r = "FILE REMOVE", s = this.createMessage(r, !0);
2300
2276
  s.hash = t.toLowerCase(), s.streamId = e, this.logCreated(r, s);
2301
2277
  const i = this.incomingMessages$.pipe(
2302
2278
  g((o) => o.type === r && o.replyTo === s.id),
2303
- f(this.logReceived(r)),
2279
+ f(this.logReceived()),
2304
2280
  p((o) => o),
2305
2281
  m(1)
2306
2282
  );
@@ -2321,7 +2297,7 @@ class xt {
2321
2297
  */
2322
2298
  sendAppResetMessage() {
2323
2299
  if (!this.isEmbedded())
2324
- throw new h(this.currentContext);
2300
+ throw new d(this.currentContext);
2325
2301
  const t = "APP RESET", e = this.createMessage(t, !1);
2326
2302
  this.logCreated(t, e), this.port2.postMessage(e), this.logSent(t, e);
2327
2303
  }
@@ -2345,7 +2321,7 @@ class xt {
2345
2321
  */
2346
2322
  sendMessageSentMessage(t, e) {
2347
2323
  if (!this.isEmbedded())
2348
- throw new h(this.currentContext);
2324
+ throw new d(this.currentContext);
2349
2325
  const r = "MESSAGE SENT", s = this.createMessage(r, !1);
2350
2326
  s.streamId = t, s.correlationId = e, this.logCreated(r, s), this.port2.postMessage(s), this.logSent(r, s);
2351
2327
  }
@@ -2369,16 +2345,16 @@ class xt {
2369
2345
  */
2370
2346
  sendSendMessageMessage(t, e, r, s = "TEXT", i, o, a, c = !0, u) {
2371
2347
  if (!this.isEmbedded())
2372
- throw new h(this.currentContext);
2373
- const l = "SEND MESSAGE", d = this.createMessage(l, !0);
2374
- d.streamId = t, d.correlationId = e, d.body = r, d.messageType = s, d.mentions = i ?? [], d.attachments = (o == null ? void 0 : o.map((b) => b.toLowerCase())) ?? [], d.relatedMessageId = a, d.setCursors = c, d.threadId = u, this.logCreated(l, d);
2375
- const y = this.incomingMessages$.pipe(
2376
- g((b) => b.type === l && b.replyTo === d.id),
2377
- f(this.logReceived(l)),
2378
- p((b) => b),
2348
+ throw new d(this.currentContext);
2349
+ const l = "SEND MESSAGE", h = this.createMessage(l, !0);
2350
+ h.streamId = t, h.correlationId = e, h.body = r, h.messageType = s, h.mentions = i ?? [], h.attachments = (o == null ? void 0 : o.map((v) => v.toLowerCase())) ?? [], h.relatedMessageId = a, h.setCursors = c, h.threadId = u, this.logCreated(l, h);
2351
+ const b = this.incomingMessages$.pipe(
2352
+ g((v) => v.type === l && v.replyTo === h.id),
2353
+ f(this.logReceived()),
2354
+ p((v) => v),
2379
2355
  m(1)
2380
2356
  );
2381
- return this.port2.postMessage(d), this.logSent(l, d), y;
2357
+ return this.port2.postMessage(h), this.logSent(l, h), b;
2382
2358
  }
2383
2359
  /**
2384
2360
  * Sends a {@link CancelSendMessageMessage} to the Host app, to cancel a message that was being
@@ -2391,7 +2367,7 @@ class xt {
2391
2367
  */
2392
2368
  sendCancelSendMessageMessage(t, e) {
2393
2369
  if (!this.isEmbedded())
2394
- throw new h(this.currentContext);
2370
+ throw new d(this.currentContext);
2395
2371
  const r = "CANCEL SEND MESSAGE", s = this.createMessage(r, !1);
2396
2372
  s.streamId = t, s.correlationId = e, this.logCreated(r, s), this.port2.postMessage(s), this.logSent(r, s);
2397
2373
  }
@@ -2404,7 +2380,7 @@ class xt {
2404
2380
  */
2405
2381
  sendMessageDeletedMessage(t, e) {
2406
2382
  if (!this.isEmbedded())
2407
- throw new h(this.currentContext);
2383
+ throw new d(this.currentContext);
2408
2384
  const r = "MESSAGE DELETED", s = this.createMessage(r, !1);
2409
2385
  s.correlationId = t, s.streamId = e, this.logCreated(r, s), this.port2.postMessage(s), this.logSent(r, s);
2410
2386
  }
@@ -2423,14 +2399,14 @@ class xt {
2423
2399
  */
2424
2400
  sendSendMessageStatusQueryMessage(t, e) {
2425
2401
  if (!this.isEmbedded())
2426
- throw new h(this.currentContext);
2402
+ throw new d(this.currentContext);
2427
2403
  const r = "SEND MESSAGE STATUS QUERY", s = this.createMessage(r, !0);
2428
2404
  s.correlationId = t, s.streamId = e, this.logCreated(r, s);
2429
2405
  const i = this.incomingMessages$.pipe(
2430
2406
  g(
2431
2407
  (o) => o.type === "SEND MESSAGE STATUS UPDATE" && o.replyTo === s.id
2432
2408
  ),
2433
- f(this.logReceived(r)),
2409
+ f(this.logReceived()),
2434
2410
  p((o) => o),
2435
2411
  m(1)
2436
2412
  );
@@ -2445,12 +2421,12 @@ class xt {
2445
2421
  */
2446
2422
  onSendMessageStatusUpdateMessage() {
2447
2423
  if (!this.isEmbedded())
2448
- throw new h(this.currentContext);
2424
+ throw new d(this.currentContext);
2449
2425
  const t = "SEND MESSAGE STATUS UPDATE";
2450
2426
  return this.incomingMessages$.pipe(
2451
2427
  g((e) => e.type === t && e.target === "client" && e.replyTo === null),
2452
2428
  p((e) => e),
2453
- f(this.logReceived(t))
2429
+ f(this.logReceived())
2454
2430
  );
2455
2431
  }
2456
2432
  /**
@@ -2461,7 +2437,7 @@ class xt {
2461
2437
  */
2462
2438
  sendSipCallMessage(t) {
2463
2439
  if (!this.isEmbedded())
2464
- throw new h(this.currentContext);
2440
+ throw new d(this.currentContext);
2465
2441
  const e = "SIP CALL", r = this.createMessage(e, !1);
2466
2442
  r.contact = t, this.logCreated(e, r), this.port2.postMessage(r), this.logSent(e, r);
2467
2443
  }
@@ -2504,10 +2480,16 @@ class xt {
2504
2480
  compareVersion(t) {
2505
2481
  return ne(this.negotiatedProtocolVersion, t);
2506
2482
  }
2507
- logReceived(t, e) {
2508
- e && It(e) && (e = { ...e, data: "..." });
2509
- const r = (s) => this.logService.debug(`[IPC] Received ${t} message`, s);
2510
- return e && r(e), r;
2483
+ logReceived(t) {
2484
+ const e = (r) => this.logService.debug(
2485
+ `[IPC] Received ${r.type} message${r.replyTo ? " reply" : ""}`,
2486
+ r
2487
+ );
2488
+ if (t) {
2489
+ xt(t) && (t = { ...t, data: "..." }), e(t);
2490
+ return;
2491
+ } else
2492
+ return e;
2511
2493
  }
2512
2494
  logSent(t, e) {
2513
2495
  e.type === "FILE REQUEST" && e.result === "success" && (e = { ...e, data: "..." }), this.logService.debug(`[IPC] Sent ${t} message`, e);
@@ -2548,11 +2530,11 @@ class xt {
2548
2530
  return s.join("");
2549
2531
  }
2550
2532
  }
2551
- function It(n) {
2533
+ function xt(n) {
2552
2534
  return n.type === "FILE REQUEST" && n.replyTo !== null;
2553
2535
  }
2554
- const Tt = ["2.0"];
2555
- class Pt {
2536
+ const It = ["2.0"];
2537
+ class Rt {
2556
2538
  /**
2557
2539
  * A class that manages the IPC communication between the `Client` and the `Host`.
2558
2540
  *
@@ -2567,15 +2549,19 @@ class Pt {
2567
2549
  /**
2568
2550
  * The type of the `Host` app the `Client` is embedded in.
2569
2551
  */
2570
- I(this, "host");
2552
+ x(this, "host");
2571
2553
  /**
2572
2554
  * The cloud ID of the `Host` app the `Client` is embedded in.
2573
2555
  */
2574
- I(this, "cloudId");
2575
- I(this, "logger");
2576
- I(this, "helper");
2577
- I(this, "listeners");
2578
- this.logger = t ?? console, this.helper = new xt(Tt, this.logger), this.listeners = /* @__PURE__ */ new Map(), this.listeners.set(w.BadgeQuery, /* @__PURE__ */ new Set()), this.listeners.set(w.Lifecycle, /* @__PURE__ */ new Set()), this.listeners.set(w.PushToken, /* @__PURE__ */ new Set());
2556
+ x(this, "cloudId");
2557
+ /**
2558
+ * The cloud username of the logged in user.
2559
+ */
2560
+ x(this, "cloudUsername");
2561
+ x(this, "logger");
2562
+ x(this, "helper");
2563
+ x(this, "listeners");
2564
+ this.logger = t ?? console, this.helper = new Mt(It, this.logger), this.listeners = /* @__PURE__ */ new Map(), this.listeners.set(w.BadgeQuery, /* @__PURE__ */ new Set()), this.listeners.set(w.Lifecycle, /* @__PURE__ */ new Set()), this.listeners.set(w.PushToken, /* @__PURE__ */ new Set());
2579
2565
  }
2580
2566
  /**
2581
2567
  * Returns whether the app is running inside a native WebView (`host` context) or as a
@@ -2613,7 +2599,7 @@ class Pt {
2613
2599
  initiateConnection() {
2614
2600
  return T(
2615
2601
  this.helper.openBridge().pipe(
2616
- Ze((t) => {
2602
+ Xe((t) => {
2617
2603
  this.helper.onBadgeQueryMessage().subscribe((e) => {
2618
2604
  var r;
2619
2605
  this.logger.debug("Received Badge Query: ", e);
@@ -2629,7 +2615,7 @@ class Pt {
2629
2615
  this.logger.debug("Received Push Token: ", e);
2630
2616
  for (const s of ((r = this.listeners.get(w.PushToken)) == null ? void 0 : r.values()) ?? [])
2631
2617
  s(e.pushToken, e.appId, e.selector);
2632
- }), this.cloudId = t.cloudId, this.host = t.host;
2618
+ }), this.cloudId = t.cloudId, this.cloudUsername = t.cloudUsername, this.host = t.host;
2633
2619
  }),
2634
2620
  O(() => {
2635
2621
  })
@@ -2641,7 +2627,7 @@ class Pt {
2641
2627
  let i;
2642
2628
  if (e === "multi") {
2643
2629
  if (!r || !Array.isArray(r))
2644
- throw new x(
2630
+ throw new I(
2645
2631
  "currentContacts",
2646
2632
  r,
2647
2633
  "currentContacts is required for group streams"
@@ -2654,7 +2640,16 @@ class Pt {
2654
2640
  );
2655
2641
  } else
2656
2642
  r ? s = r : s = "cloudUsername", i = this.helper.selectContacts(t.toString(), "direct", s);
2657
- return T(i.pipe(O((o) => o.contacts)));
2643
+ return T(
2644
+ i.pipe(
2645
+ O((o) => o.result === "error" ? {
2646
+ result: "error",
2647
+ errorMessage: o.errorMessage
2648
+ } : o.result === "cancelled" ? {
2649
+ result: "cancelled"
2650
+ } : o.contacts)
2651
+ )
2652
+ );
2658
2653
  }
2659
2654
  /**
2660
2655
  * Matches batch of {@link ContactItem} objects against the Host's contact list to fetch detailed
@@ -2775,5 +2770,5 @@ class Pt {
2775
2770
  }
2776
2771
  export {
2777
2772
  w as IPCEvents,
2778
- Pt as IPCManager
2773
+ Rt as IPCManager
2779
2774
  };