@acrobits/ipc-sdk 0.11.2-alpha.7 → 0.11.2-alpha.8

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
@@ -38,8 +38,8 @@ function $(s, t) {
38
38
  try {
39
39
  for (; (t === void 0 || t-- > 0) && !(n = r.next()).done; )
40
40
  i.push(n.value);
41
- } catch (c) {
42
- o = { error: c };
41
+ } catch (a) {
42
+ o = { error: a };
43
43
  } finally {
44
44
  try {
45
45
  n && !n.done && (e = r.return) && e.call(r);
@@ -92,15 +92,15 @@ var x = function() {
92
92
  if (o)
93
93
  if (this._parentage = null, Array.isArray(o))
94
94
  try {
95
- for (var c = Q(o), a = c.next(); !a.done; a = c.next()) {
96
- var u = a.value;
97
- u.remove(this);
95
+ for (var a = Q(o), c = a.next(); !c.done; c = a.next()) {
96
+ var l = c.value;
97
+ l.remove(this);
98
98
  }
99
99
  } catch (v) {
100
100
  t = { error: v };
101
101
  } finally {
102
102
  try {
103
- a && !a.done && (e = c.return) && e.call(c);
103
+ c && !c.done && (e = a.return) && e.call(a);
104
104
  } finally {
105
105
  if (t)
106
106
  throw t.error;
@@ -115,11 +115,11 @@ var x = function() {
115
115
  } catch (v) {
116
116
  i = v instanceof V ? v.errors : [v];
117
117
  }
118
- var l = this._finalizers;
119
- if (l) {
118
+ var u = this._finalizers;
119
+ if (u) {
120
120
  this._finalizers = null;
121
121
  try {
122
- for (var b = Q(l), p = b.next(); !p.done; p = b.next()) {
122
+ for (var b = Q(u), p = b.next(); !p.done; p = b.next()) {
123
123
  var F = p.value;
124
124
  try {
125
125
  se(F);
@@ -282,13 +282,13 @@ var Oe = function() {
282
282
  complete: n ?? void 0
283
283
  };
284
284
  else {
285
- var c;
286
- i && we.useDeprecatedNextContext ? (c = Object.create(e), c.unsubscribe = function() {
285
+ var a;
286
+ i && we.useDeprecatedNextContext ? (a = Object.create(e), a.unsubscribe = function() {
287
287
  return i.unsubscribe();
288
288
  }, o = {
289
- next: e.next && H(e.next, c),
290
- error: e.error && H(e.error, c),
291
- complete: e.complete && H(e.complete, c)
289
+ next: e.next && H(e.next, a),
290
+ error: e.error && H(e.error, a),
291
+ complete: e.complete && H(e.complete, a)
292
292
  }) : o = e;
293
293
  }
294
294
  return i.destination = new Oe(o), i;
@@ -329,8 +329,8 @@ var G = function() {
329
329
  }, s.prototype.subscribe = function(t, e, r) {
330
330
  var n = this, i = Ve(t) ? t : new N(t, e, r);
331
331
  return O(function() {
332
- var o = n, c = o.operator, a = o.source;
333
- i.add(c ? c.call(i, a) : a ? n._subscribe(i) : n._trySubscribe(i));
332
+ var o = n, a = o.operator, c = o.source;
333
+ i.add(a ? a.call(i, c) : c ? n._subscribe(i) : n._trySubscribe(i));
334
334
  }), i;
335
335
  }, s.prototype._trySubscribe = function(t) {
336
336
  try {
@@ -342,11 +342,11 @@ var G = function() {
342
342
  var r = this;
343
343
  return e = ie(e), new e(function(n, i) {
344
344
  var o = new N({
345
- next: function(c) {
345
+ next: function(a) {
346
346
  try {
347
- t(c);
348
- } catch (a) {
349
- i(a), o.unsubscribe();
347
+ t(a);
348
+ } catch (c) {
349
+ i(c), o.unsubscribe();
350
350
  }
351
351
  },
352
352
  error: i,
@@ -410,31 +410,31 @@ function Me(s, t, e, r, n) {
410
410
  }
411
411
  var je = function(s) {
412
412
  U(t, s);
413
- function t(e, r, n, i, o, c) {
414
- var a = s.call(this, e) || this;
415
- return a.onFinalize = o, a.shouldUnsubscribe = c, a._next = r ? function(u) {
413
+ function t(e, r, n, i, o, a) {
414
+ var c = s.call(this, e) || this;
415
+ return c.onFinalize = o, c.shouldUnsubscribe = a, c._next = r ? function(l) {
416
416
  try {
417
- r(u);
417
+ r(l);
418
418
  } catch (h) {
419
419
  e.error(h);
420
420
  }
421
- } : s.prototype._next, a._error = i ? function(u) {
421
+ } : s.prototype._next, c._error = i ? function(l) {
422
422
  try {
423
- i(u);
423
+ i(l);
424
424
  } catch (h) {
425
425
  e.error(h);
426
426
  } finally {
427
427
  this.unsubscribe();
428
428
  }
429
- } : s.prototype._error, a._complete = n ? function() {
429
+ } : s.prototype._error, c._complete = n ? function() {
430
430
  try {
431
431
  n();
432
- } catch (u) {
433
- e.error(u);
432
+ } catch (l) {
433
+ e.error(l);
434
434
  } finally {
435
435
  this.unsubscribe();
436
436
  }
437
- } : s.prototype._complete, a;
437
+ } : s.prototype._complete, c;
438
438
  }
439
439
  return t.prototype.unsubscribe = function() {
440
440
  var e;
@@ -466,15 +466,15 @@ var je = function(s) {
466
466
  if (r._throwIfClosed(), !r.isStopped) {
467
467
  r.currentObservers || (r.currentObservers = Array.from(r.observers));
468
468
  try {
469
- for (var o = Q(r.currentObservers), c = o.next(); !c.done; c = o.next()) {
470
- var a = c.value;
471
- a.next(e);
469
+ for (var o = Q(r.currentObservers), a = o.next(); !a.done; a = o.next()) {
470
+ var c = a.value;
471
+ c.next(e);
472
472
  }
473
- } catch (u) {
474
- n = { error: u };
473
+ } catch (l) {
474
+ n = { error: l };
475
475
  } finally {
476
476
  try {
477
- c && !c.done && (i = o.return) && i.call(o);
477
+ a && !a.done && (i = o.return) && i.call(o);
478
478
  } finally {
479
479
  if (n)
480
480
  throw n.error;
@@ -514,9 +514,9 @@ var je = function(s) {
514
514
  }, t.prototype._subscribe = function(e) {
515
515
  return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
516
516
  }, t.prototype._innerSubscribe = function(e) {
517
- var r = this, n = this, i = n.hasError, o = n.isStopped, c = n.observers;
518
- return i || o ? ve : (this.currentObservers = null, c.push(e), new x(function() {
519
- r.currentObservers = null, D(c, e);
517
+ var r = this, n = this, i = n.hasError, o = n.isStopped, a = n.observers;
518
+ return i || o ? ve : (this.currentObservers = null, a.push(e), new x(function() {
519
+ r.currentObservers = null, D(a, e);
520
520
  }));
521
521
  }, t.prototype._checkFinalizedStatuses = function(e) {
522
522
  var r = this, n = r.hasError, i = r.thrownError, o = r.isStopped;
@@ -696,19 +696,19 @@ function et(s, t, e) {
696
696
  return r ? Ee(function(n, i) {
697
697
  var o;
698
698
  (o = r.subscribe) === null || o === void 0 || o.call(r);
699
- var c = !0;
700
- n.subscribe(Me(i, function(a) {
701
- var u;
702
- (u = r.next) === null || u === void 0 || u.call(r, a), i.next(a);
699
+ var a = !0;
700
+ n.subscribe(Me(i, function(c) {
701
+ var l;
702
+ (l = r.next) === null || l === void 0 || l.call(r, c), i.next(c);
703
703
  }, function() {
704
- var a;
705
- c = !1, (a = r.complete) === null || a === void 0 || a.call(r), i.complete();
706
- }, function(a) {
707
- var u;
708
- c = !1, (u = r.error) === null || u === void 0 || u.call(r, a), i.error(a);
704
+ var c;
705
+ a = !1, (c = r.complete) === null || c === void 0 || c.call(r), i.complete();
706
+ }, function(c) {
707
+ var l;
708
+ a = !1, (l = r.error) === null || l === void 0 || l.call(r, c), i.error(c);
709
709
  }, function() {
710
- var a, u;
711
- c && ((a = r.unsubscribe) === null || a === void 0 || a.call(r)), (u = r.finalize) === null || u === void 0 || u.call(r);
710
+ var c, l;
711
+ a && ((c = r.unsubscribe) === null || c === void 0 || c.call(r)), (l = r.finalize) === null || l === void 0 || l.call(r);
712
712
  }));
713
713
  }) : Ce;
714
714
  }
@@ -718,7 +718,7 @@ class d extends Error {
718
718
  super(`Incorrect context (${t}). Cannot perform the requested operation.`), I(this, "context"), this.context = t;
719
719
  }
720
720
  }
721
- class y extends Error {
721
+ class m extends Error {
722
722
  constructor(t, e, r) {
723
723
  super(`Invalid parameter (${t}). ${r}`), this.param = t, this.value = e, this.reason = r;
724
724
  }
@@ -735,12 +735,12 @@ class st extends Error {
735
735
  super(`Invalid version format: ${t}`);
736
736
  }
737
737
  }
738
- class ue extends Error {
738
+ class le extends Error {
739
739
  constructor(t) {
740
740
  super(`${t} needs to be initialized before it can be used.`);
741
741
  }
742
742
  }
743
- class le extends Error {
743
+ class ue extends Error {
744
744
  constructor(t, e) {
745
745
  let r = `Unsupported Protocol ${Array.isArray(t) ? "versions" : "version"}: (${t}).`;
746
746
  e && (r += ` Minimum version supported is ${e}.`), super(r), this.version = t;
@@ -802,8 +802,8 @@ function J(s, t) {
802
802
  try {
803
803
  for (; (t === void 0 || t-- > 0) && !(n = r.next()).done; )
804
804
  i.push(n.value);
805
- } catch (c) {
806
- o = { error: c };
805
+ } catch (a) {
806
+ o = { error: a };
807
807
  } finally {
808
808
  try {
809
809
  n && !n.done && (e = r.return) && e.call(r);
@@ -853,15 +853,15 @@ var te = function() {
853
853
  if (o)
854
854
  if (this._parentage = null, Array.isArray(o))
855
855
  try {
856
- for (var c = he(o), a = c.next(); !a.done; a = c.next()) {
857
- var u = a.value;
858
- u.remove(this);
856
+ for (var a = he(o), c = a.next(); !c.done; c = a.next()) {
857
+ var l = c.value;
858
+ l.remove(this);
859
859
  }
860
860
  } catch (v) {
861
861
  t = { error: v };
862
862
  } finally {
863
863
  try {
864
- a && !a.done && (e = c.return) && e.call(c);
864
+ c && !c.done && (e = a.return) && e.call(a);
865
865
  } finally {
866
866
  if (t)
867
867
  throw t.error;
@@ -876,11 +876,11 @@ var te = function() {
876
876
  } catch (v) {
877
877
  i = v instanceof j ? v.errors : [v];
878
878
  }
879
- var l = this._finalizers;
880
- if (l) {
879
+ var u = this._finalizers;
880
+ if (u) {
881
881
  this._finalizers = null;
882
882
  try {
883
- for (var b = he(l), p = b.next(); !p.done; p = b.next()) {
883
+ for (var b = he(u), p = b.next(); !p.done; p = b.next()) {
884
884
  var F = p.value;
885
885
  try {
886
886
  pe(F);
@@ -997,11 +997,11 @@ var re = function(s) {
997
997
  this.unsubscribe();
998
998
  }
999
999
  }, t;
1000
- }(te), ut = Function.prototype.bind;
1000
+ }(te), lt = Function.prototype.bind;
1001
1001
  function q(s, t) {
1002
- return ut.call(s, t);
1002
+ return lt.call(s, t);
1003
1003
  }
1004
- var lt = function() {
1004
+ var ut = function() {
1005
1005
  function s(t) {
1006
1006
  this.partialObserver = t;
1007
1007
  }
@@ -1043,16 +1043,16 @@ var lt = function() {
1043
1043
  complete: n ?? void 0
1044
1044
  };
1045
1045
  else {
1046
- var c;
1047
- i && Te.useDeprecatedNextContext ? (c = Object.create(e), c.unsubscribe = function() {
1046
+ var a;
1047
+ i && Te.useDeprecatedNextContext ? (a = Object.create(e), a.unsubscribe = function() {
1048
1048
  return i.unsubscribe();
1049
1049
  }, o = {
1050
- next: e.next && q(e.next, c),
1051
- error: e.error && q(e.error, c),
1052
- complete: e.complete && q(e.complete, c)
1050
+ next: e.next && q(e.next, a),
1051
+ error: e.error && q(e.error, a),
1052
+ complete: e.complete && q(e.complete, a)
1053
1053
  }) : o = e;
1054
1054
  }
1055
- return i.destination = new lt(o), i;
1055
+ return i.destination = new ut(o), i;
1056
1056
  }
1057
1057
  return t;
1058
1058
  }(re);
@@ -1088,10 +1088,10 @@ var gt = function() {
1088
1088
  var e = new s();
1089
1089
  return e.source = this, e.operator = t, e;
1090
1090
  }, s.prototype.subscribe = function(t, e, r) {
1091
- var n = this, i = yt(t) ? t : new K(t, e, r);
1091
+ var n = this, i = mt(t) ? t : new K(t, e, r);
1092
1092
  return at(function() {
1093
- var o = n, c = o.operator, a = o.source;
1094
- i.add(c ? c.call(i, a) : a ? n._subscribe(i) : n._trySubscribe(i));
1093
+ var o = n, a = o.operator, c = o.source;
1094
+ i.add(a ? a.call(i, c) : c ? n._subscribe(i) : n._trySubscribe(i));
1095
1095
  }), i;
1096
1096
  }, s.prototype._trySubscribe = function(t) {
1097
1097
  try {
@@ -1103,11 +1103,11 @@ var gt = function() {
1103
1103
  var r = this;
1104
1104
  return e = ge(e), new e(function(n, i) {
1105
1105
  var o = new K({
1106
- next: function(c) {
1106
+ next: function(a) {
1107
1107
  try {
1108
- t(c);
1109
- } catch (a) {
1110
- i(a), o.unsubscribe();
1108
+ t(a);
1109
+ } catch (c) {
1110
+ i(c), o.unsubscribe();
1111
1111
  }
1112
1112
  },
1113
1113
  error: i,
@@ -1144,42 +1144,42 @@ function ge(s) {
1144
1144
  var t;
1145
1145
  return (t = s ?? Te.Promise) !== null && t !== void 0 ? t : Promise;
1146
1146
  }
1147
- function mt(s) {
1147
+ function yt(s) {
1148
1148
  return s && E(s.next) && E(s.error) && E(s.complete);
1149
1149
  }
1150
- function yt(s) {
1151
- return s && s instanceof re || mt(s) && Ue(s);
1150
+ function mt(s) {
1151
+ return s && s instanceof re || yt(s) && Ue(s);
1152
1152
  }
1153
1153
  function P(s, t, e, r, n) {
1154
1154
  return new vt(s, t, e, r, n);
1155
1155
  }
1156
1156
  var vt = function(s) {
1157
1157
  ee(t, s);
1158
- function t(e, r, n, i, o, c) {
1159
- var a = s.call(this, e) || this;
1160
- return a.onFinalize = o, a.shouldUnsubscribe = c, a._next = r ? function(u) {
1158
+ function t(e, r, n, i, o, a) {
1159
+ var c = s.call(this, e) || this;
1160
+ return c.onFinalize = o, c.shouldUnsubscribe = a, c._next = r ? function(l) {
1161
1161
  try {
1162
- r(u);
1162
+ r(l);
1163
1163
  } catch (h) {
1164
1164
  e.error(h);
1165
1165
  }
1166
- } : s.prototype._next, a._error = i ? function(u) {
1166
+ } : s.prototype._next, c._error = i ? function(l) {
1167
1167
  try {
1168
- i(u);
1168
+ i(l);
1169
1169
  } catch (h) {
1170
1170
  e.error(h);
1171
1171
  } finally {
1172
1172
  this.unsubscribe();
1173
1173
  }
1174
- } : s.prototype._error, a._complete = n ? function() {
1174
+ } : s.prototype._error, c._complete = n ? function() {
1175
1175
  try {
1176
1176
  n();
1177
- } catch (u) {
1178
- e.error(u);
1177
+ } catch (l) {
1178
+ e.error(l);
1179
1179
  } finally {
1180
1180
  this.unsubscribe();
1181
1181
  }
1182
- } : s.prototype._complete, a;
1182
+ } : s.prototype._complete, c;
1183
1183
  }
1184
1184
  return t.prototype.unsubscribe = function() {
1185
1185
  var e;
@@ -1210,7 +1210,7 @@ function w(s) {
1210
1210
  }));
1211
1211
  });
1212
1212
  }
1213
- function m(s, t) {
1213
+ function y(s, t) {
1214
1214
  return R(function(e, r) {
1215
1215
  var n = 0;
1216
1216
  e.subscribe(P(r, function(i) {
@@ -1232,19 +1232,19 @@ function g(s, t, e) {
1232
1232
  return r ? R(function(n, i) {
1233
1233
  var o;
1234
1234
  (o = r.subscribe) === null || o === void 0 || o.call(r);
1235
- var c = !0;
1236
- n.subscribe(P(i, function(a) {
1237
- var u;
1238
- (u = r.next) === null || u === void 0 || u.call(r, a), i.next(a);
1235
+ var a = !0;
1236
+ n.subscribe(P(i, function(c) {
1237
+ var l;
1238
+ (l = r.next) === null || l === void 0 || l.call(r, c), i.next(c);
1239
1239
  }, function() {
1240
- var a;
1241
- c = !1, (a = r.complete) === null || a === void 0 || a.call(r), i.complete();
1242
- }, function(a) {
1243
- var u;
1244
- c = !1, (u = r.error) === null || u === void 0 || u.call(r, a), i.error(a);
1240
+ var c;
1241
+ a = !1, (c = r.complete) === null || c === void 0 || c.call(r), i.complete();
1242
+ }, function(c) {
1243
+ var l;
1244
+ a = !1, (l = r.error) === null || l === void 0 || l.call(r, c), i.error(c);
1245
1245
  }, function() {
1246
- var a, u;
1247
- c && ((a = r.unsubscribe) === null || a === void 0 || a.call(r)), (u = r.finalize) === null || u === void 0 || u.call(r);
1246
+ var c, l;
1247
+ a && ((c = r.unsubscribe) === null || c === void 0 || c.call(r)), (l = r.finalize) === null || l === void 0 || l.call(r);
1248
1248
  }));
1249
1249
  }) : xe;
1250
1250
  }
@@ -1257,18 +1257,18 @@ function Ct(s) {
1257
1257
  }
1258
1258
  throw new st(s);
1259
1259
  }
1260
- function me(s) {
1260
+ function ye(s) {
1261
1261
  const t = Ct(s), [e, r] = t.split("."), [n, i] = [parseInt(e), parseInt(r)];
1262
1262
  return [n, i];
1263
1263
  }
1264
1264
  function Re(s, t) {
1265
- const [e, r] = me(s), [n, i] = me(t);
1265
+ const [e, r] = ye(s), [n, i] = ye(t);
1266
1266
  return e < n ? -1 : e > n ? 1 : r < i ? -1 : r > i ? 1 : 0;
1267
1267
  }
1268
1268
  function Et(s, t) {
1269
1269
  return Re(s, t) >= 0;
1270
1270
  }
1271
- const ye = "2.0";
1271
+ const me = "2.0";
1272
1272
  class Mt {
1273
1273
  /**
1274
1274
  * Create a new instance of the {@link IpcHelper | IPC Protocol Helper}.
@@ -1280,8 +1280,8 @@ class Mt {
1280
1280
  * @param logService - An instance of a logging service or utility
1281
1281
  */
1282
1282
  constructor(t, e) {
1283
- if (I(this, "negotiatedProtocolVersion"), I(this, "currentContext"), I(this, "incomingMessages$"), I(this, "inIframe", !1), I(this, "embeddedResult"), I(this, "iframePort1"), I(this, "iframePort2"), this.supportedVersions = t, this.logService = e, this.incomingMessages$ = new Ie(), this.supportedVersions = t.filter((r) => Et(r, ye)), !this.supportedVersions.length)
1284
- throw new le(t, ye);
1283
+ if (I(this, "negotiatedProtocolVersion"), I(this, "currentContext"), I(this, "incomingMessages$"), I(this, "inIframe", !1), I(this, "embeddedResult"), I(this, "iframePort1"), I(this, "iframePort2"), this.supportedVersions = t, this.logService = e, this.incomingMessages$ = new Ie(), this.supportedVersions = t.filter((r) => Et(r, me)), !this.supportedVersions.length)
1284
+ throw new ue(t, me);
1285
1285
  this.negotiatedProtocolVersion = this.supportedVersions[0], this.embeddedResult = null, this.iframePort2 = null;
1286
1286
  }
1287
1287
  get parent() {
@@ -1303,11 +1303,11 @@ class Mt {
1303
1303
  var t, e, r, n;
1304
1304
  if (this.inIframe) {
1305
1305
  if (!this.iframePort2)
1306
- throw new ue("port2");
1306
+ throw new le("port2");
1307
1307
  return this.iframePort2;
1308
1308
  } else {
1309
1309
  if (!((e = (t = window.Acrobits) == null ? void 0 : t.messageChannel) != null && e.port2))
1310
- throw new ue("port2");
1310
+ throw new le("port2");
1311
1311
  return (n = (r = window.Acrobits) == null ? void 0 : r.messageChannel) == null ? void 0 : n.port2;
1312
1312
  }
1313
1313
  }
@@ -1334,12 +1334,12 @@ class Mt {
1334
1334
  const t = "HELLO", e = this.createMessage(t);
1335
1335
  e.protocolVersions = this.supportedVersions, this.logCreated(t, e);
1336
1336
  const r = this.incomingMessages$.pipe(
1337
- m((n) => n.type === t && n.replyTo === e.id),
1337
+ y((n) => n.type === t && n.replyTo === e.id),
1338
1338
  f((n) => n),
1339
1339
  g(this.logReceived()),
1340
1340
  f((n) => {
1341
1341
  if (!this.supportedVersions.includes(n.protocolVersion))
1342
- throw new le(n.protocolVersion, this.supportedVersions[0]);
1342
+ throw new ue(n.protocolVersion, this.supportedVersions[0]);
1343
1343
  return n.displayName || (n.displayName = n.cloudUsername), n;
1344
1344
  }),
1345
1345
  g((n) => {
@@ -1366,7 +1366,7 @@ class Mt {
1366
1366
  const t = "TOKEN", e = this.createMessage(t);
1367
1367
  this.logCreated(t, e);
1368
1368
  const r = this.incomingMessages$.pipe(
1369
- m((n) => n.type === t && n.replyTo === e.id),
1369
+ y((n) => n.type === t && n.replyTo === e.id),
1370
1370
  f((n) => n),
1371
1371
  g(this.logReceived()),
1372
1372
  w(1)
@@ -1395,11 +1395,11 @@ class Mt {
1395
1395
  displayName: n,
1396
1396
  jwtToken: i,
1397
1397
  serverUrl: o,
1398
- region: c,
1399
- joinMicMuted: a,
1400
- joinWithoutCamera: u
1401
- } = t, h = "JOINING ROOM", l = this.createMessage(h, !1);
1402
- l.roomName = e, l.jwtToken = i, l.serverUrl = o, l.region = c, l.roomInvite = r, l.joinMicMuted = a ?? !1, l.joinWithoutCamera = u ?? !1, l.displayName = n, this.logCreated(h, l), this.port2.postMessage(l), this.logSent(h, l);
1398
+ region: a,
1399
+ joinMicMuted: c,
1400
+ joinWithoutCamera: l
1401
+ } = t, h = "JOINING ROOM", u = this.createMessage(h, !1);
1402
+ u.roomName = e, u.jwtToken = i, u.serverUrl = o, u.region = a, u.roomInvite = r, u.joinMicMuted = c ?? !1, u.joinWithoutCamera = l ?? !1, u.displayName = n, this.logCreated(h, u), this.port2.postMessage(u), this.logSent(h, u);
1403
1403
  }
1404
1404
  /**
1405
1405
  * Sends a {@link LeavingRoomMessage} lifecycle message to the Host app.
@@ -1449,7 +1449,7 @@ class Mt {
1449
1449
  throw new d(this.currentContext);
1450
1450
  const t = "JOIN ROOM";
1451
1451
  return this.incomingMessages$.pipe(
1452
- m((e) => e.type === t && e.target === "client"),
1452
+ y((e) => e.type === t && e.target === "client"),
1453
1453
  f((e) => e),
1454
1454
  g(this.logReceived()),
1455
1455
  f((e) => e)
@@ -1485,7 +1485,7 @@ class Mt {
1485
1485
  throw new d(this.currentContext);
1486
1486
  const t = "LEAVE ROOM";
1487
1487
  return this.incomingMessages$.pipe(
1488
- m((e) => e.type === t && e.target === "client"),
1488
+ y((e) => e.type === t && e.target === "client"),
1489
1489
  f((e) => e),
1490
1490
  g(this.logReceived()),
1491
1491
  f((e) => e)
@@ -1522,7 +1522,7 @@ class Mt {
1522
1522
  throw new d(this.currentContext);
1523
1523
  const t = "CONFIG";
1524
1524
  return this.incomingMessages$.pipe(
1525
- m((e) => e.type === t && e.target === "client"),
1525
+ y((e) => e.type === t && e.target === "client"),
1526
1526
  f((e) => e),
1527
1527
  g(this.logReceived()),
1528
1528
  f((e) => ({
@@ -1546,7 +1546,7 @@ class Mt {
1546
1546
  const e = "SCREENSHARE SOURCE", r = this.createMessage(e);
1547
1547
  r.sourceTypes = t, this.logCreated(e, r);
1548
1548
  const n = this.incomingMessages$.pipe(
1549
- m((i) => i.type === e && i.replyTo === r.id),
1549
+ y((i) => i.type === e && i.replyTo === r.id),
1550
1550
  f((i) => i),
1551
1551
  g(this.logReceived()),
1552
1552
  f((i) => i),
@@ -1560,10 +1560,10 @@ class Mt {
1560
1560
  const n = "LAYOUT CHANGE";
1561
1561
  let i, o;
1562
1562
  if (e && r ? (i = this.createMessage(n, !1, r), i.result = e) : (i = this.createMessage(n), o = this.incomingMessages$.pipe(
1563
- m((c) => c.type === n && c.replyTo === i.id),
1564
- f((c) => c),
1563
+ y((a) => a.type === n && a.replyTo === i.id),
1564
+ f((a) => a),
1565
1565
  g(this.logReceived()),
1566
- f((c) => c),
1566
+ f((a) => a),
1567
1567
  w(1)
1568
1568
  ), this.logService.debug(`Created ${n} Reply handler`)), i.layout = t, this.logCreated(n, i), this.port2.postMessage(i), this.logSent(n, i), o)
1569
1569
  return o;
@@ -1604,7 +1604,7 @@ class Mt {
1604
1604
  throw new d(this.currentContext);
1605
1605
  const t = "LAYOUT CHANGE";
1606
1606
  return this.incomingMessages$.pipe(
1607
- m((e) => e.type === t && e.target === "client" && e.replyTo === null),
1607
+ y((e) => e.type === t && e.target === "client" && e.replyTo === null),
1608
1608
  f((e) => e),
1609
1609
  g(this.logReceived()),
1610
1610
  f((e) => e)
@@ -1617,7 +1617,7 @@ class Mt {
1617
1617
  const e = "OAUTH TOKEN", r = this.createMessage(e);
1618
1618
  r.providerTypes = t, this.logCreated(e, r);
1619
1619
  const n = this.incomingMessages$.pipe(
1620
- m((i) => i.type === e && i.replyTo === r.id),
1620
+ y((i) => i.type === e && i.replyTo === r.id),
1621
1621
  f((i) => i),
1622
1622
  g(this.logReceived()),
1623
1623
  w(1)
@@ -1635,13 +1635,13 @@ class Mt {
1635
1635
  throw new d(this.currentContext);
1636
1636
  if (this.negotiatedProtocolVersion === "2.0") {
1637
1637
  if (e === void 0 || typeof e == "object")
1638
- throw new y(
1638
+ throw new m(
1639
1639
  "streamType",
1640
1640
  e,
1641
1641
  "streamType is missing or invalid"
1642
1642
  );
1643
1643
  if (r === void 0 || typeof r == "object" || typeof r == "number")
1644
- throw new y(
1644
+ throw new m(
1645
1645
  "contactType",
1646
1646
  r,
1647
1647
  "contactType is missing or invalid"
@@ -1654,9 +1654,9 @@ class Mt {
1654
1654
  );
1655
1655
  }
1656
1656
  if (typeof e < "u" && typeof e != "object")
1657
- throw new y("options", e, "options is invalid");
1657
+ throw new m("options", e, "options is invalid");
1658
1658
  if (typeof r < "u" && !Array.isArray(r))
1659
- throw new y(
1659
+ throw new m(
1660
1660
  "currentContacts",
1661
1661
  r,
1662
1662
  "currentContacts is invalid"
@@ -1666,120 +1666,148 @@ class Mt {
1666
1666
  selectContactsV2_0(t, e, r, n) {
1667
1667
  if (!this.isEmbedded())
1668
1668
  throw new d(this.currentContext);
1669
- n && n.length > 0 && (n = n.map((a) => a.type === "cloudUsername" && a.contactUser ? {
1670
- ...a,
1671
- cloudId: a.cloudId || a.contactUser.cloudId,
1672
- networkId: a.networkId || a.contactUser.networkId,
1673
- cloudUsername: a.cloudUsername || a.contactUser.cloudUsername
1674
- } : a));
1669
+ n && n.length > 0 && (n = n.map((c) => c.type === "cloudUsername" && c.contactUser ? {
1670
+ ...c,
1671
+ cloudId: c.cloudId || c.contactUser.cloudId,
1672
+ networkId: c.networkId || c.contactUser.networkId,
1673
+ cloudUsername: c.cloudUsername || c.contactUser.cloudUsername
1674
+ } : c));
1675
1675
  const i = "SELECT CONTACTS", o = this.createMessage(i, !0);
1676
1676
  o.streamId = t, o.streamType = e, o.contactType = r, o.resultTypes = [r], o.currentContacts = n, this.logCreated(i, o);
1677
- const c = this.incomingMessages$.pipe(
1678
- m((a) => a.type === i && a.replyTo === o.id),
1677
+ const a = this.incomingMessages$.pipe(
1678
+ y((c) => c.type === i && c.replyTo === o.id),
1679
1679
  g(this.logReceived()),
1680
- f((a) => {
1681
- const u = a;
1682
- if (u.result === "success") {
1683
- if (u.streamId !== t)
1684
- throw new ae(u.streamId, t);
1685
- e === "direct" && u.contacts.length > 1 && (u.contacts = [u.contacts[0]]);
1680
+ f((c) => {
1681
+ const l = c;
1682
+ if (l.result === "success") {
1683
+ if (l.streamId !== t)
1684
+ throw new ae(l.streamId, t);
1685
+ e === "direct" && l.contacts.length > 1 && (l.contacts = [l.contacts[0]]);
1686
1686
  }
1687
- return u;
1687
+ return l;
1688
1688
  }),
1689
1689
  w(1)
1690
1690
  );
1691
- return this.logService.debug(`Created ${i} Reply handler`), this.port2.postMessage(o), this.logSent(i, o), c;
1691
+ return this.logService.debug(`Created ${i} Reply handler`), this.port2.postMessage(o), this.logSent(i, o), a;
1692
1692
  }
1693
1693
  selectContactsV2_1(t, e, r) {
1694
1694
  if (!this.isEmbedded())
1695
1695
  throw new d(this.currentContext);
1696
1696
  const n = {
1697
1697
  allowMultipleSelection: (e == null ? void 0 : e.allowMultipleSelection) ?? !1,
1698
+ filterToSelectedType: (e == null ? void 0 : e.filterToSelectedType) ?? !1,
1698
1699
  resultTypes: (e == null ? void 0 : e.resultTypes) ?? ["cloudUsername"],
1699
1700
  streamName: e == null ? void 0 : e.streamName
1700
1701
  };
1702
+ if (n.filterToSelectedType) {
1703
+ if (!n.allowMultipleSelection)
1704
+ throw new m(
1705
+ "filterToSelectedType",
1706
+ n.filterToSelectedType,
1707
+ "filterToSelectedType can only be set when allowMultipleSelection is true"
1708
+ );
1709
+ if (n.resultTypes.length === 1 && this.logService.warn(
1710
+ "[IPC] [SelectContacts] filterToSelectedType is redundant when resultTypes contains only one type"
1711
+ ), r && r.length > 0) {
1712
+ const c = r[0].type;
1713
+ if (r.some((l) => l.type !== c))
1714
+ throw new m(
1715
+ "currentContacts",
1716
+ r,
1717
+ "When filterToSelectedType is true, all items in currentContacts must be of the same type"
1718
+ );
1719
+ }
1720
+ }
1701
1721
  if (r && r.length > 0)
1702
- for (const a of r) {
1703
- if (a.contactId === void 0)
1704
- throw new y(
1722
+ for (const c of r) {
1723
+ if (c.contactId === void 0)
1724
+ throw new m(
1705
1725
  "currentContacts",
1706
1726
  r,
1707
1727
  "ContactItem contactId is required since v2.1 on all contacts"
1708
1728
  );
1709
- if (a.type === "cloudUsername") {
1710
- if (!a.contactUser)
1711
- throw new y(
1729
+ if (c.type === "cloudUsername") {
1730
+ if (!c.contactUser)
1731
+ throw new m(
1712
1732
  "currentContacts",
1713
- a,
1733
+ c,
1714
1734
  "CloudUsername contact must include contactUser since v2.1"
1715
1735
  );
1716
- if (!a.contactUser.cloudId || !a.contactUser.networkId || !a.contactUser.cloudUsername)
1717
- throw new y(
1736
+ if (!c.contactUser.cloudId || !c.contactUser.networkId || !c.contactUser.cloudUsername)
1737
+ throw new m(
1718
1738
  "currentContacts",
1719
- a,
1739
+ c,
1720
1740
  "CloudContact must define cloudUsername, cloudId, and networkId since v2.1"
1721
1741
  );
1722
1742
  }
1723
1743
  }
1724
1744
  const i = "SELECT CONTACTS", o = this.createMessage(i, !0);
1725
- o.streamId = t, o.streamName = n.streamName, o.resultTypes = n.resultTypes, o.currentContacts = r, o.allowMultipleSelection = n.allowMultipleSelection, this.logCreated(i, o);
1726
- const c = this.incomingMessages$.pipe(
1727
- m((a) => a.type === i && a.replyTo === o.id),
1745
+ o.streamId = t, o.streamName = n.streamName, o.resultTypes = n.resultTypes, o.currentContacts = r, o.allowMultipleSelection = n.allowMultipleSelection, o.filterToSelectedType = n.filterToSelectedType, this.logCreated(i, o);
1746
+ const a = this.incomingMessages$.pipe(
1747
+ y((c) => c.type === i && c.replyTo === o.id),
1728
1748
  g(this.logReceived()),
1729
- f((a) => {
1730
- const u = a;
1731
- if (u.result === "success") {
1732
- if (u.streamId !== t)
1733
- throw new ae(u.streamId, t);
1734
- const h = u.contacts.length;
1735
- u.contacts = u.contacts.filter(
1736
- (l) => n.resultTypes.includes(l.type)
1737
- ), u.contacts.length !== h && this.logService.debug(
1738
- `[IPC] [SelectContactsReply] Filtered ${h - u.contacts.length} contacts from reply`
1739
- ), !n.allowMultipleSelection && u.contacts.length > 1 && (u.contacts = [u.contacts[0]]);
1740
- for (const l of u.contacts) {
1741
- if (l.type === "cloudUsername") {
1742
- if (!l.contactUser)
1749
+ f((c) => {
1750
+ const l = c;
1751
+ if (l.result === "success") {
1752
+ if (l.streamId !== t)
1753
+ throw new ae(l.streamId, t);
1754
+ const h = l.contacts.length;
1755
+ if (l.contacts = l.contacts.filter(
1756
+ (u) => n.resultTypes.includes(u.type)
1757
+ ), l.contacts.length !== h && this.logService.debug(
1758
+ `[IPC] [SelectContactsReply] Filtered ${h - l.contacts.length} contacts from reply`
1759
+ ), !n.allowMultipleSelection && l.contacts.length > 1 && (l.contacts = [l.contacts[0]]), n.filterToSelectedType && l.contacts.length > 1) {
1760
+ const u = l.contacts[0].type;
1761
+ if (l.contacts.some(
1762
+ (b) => b.type !== u
1763
+ ))
1764
+ throw new Error(
1765
+ `When filterToSelectedType is true, all contacts in the reply must be of the same type. Expected all contacts to be of type '${u}', but received mixed types.`
1766
+ );
1767
+ }
1768
+ for (const u of l.contacts) {
1769
+ if (u.type === "cloudUsername") {
1770
+ if (!u.contactUser)
1743
1771
  throw new Error(
1744
1772
  `CloudUsername contact must include contactUser since v2.1. ContactItem: ${JSON.stringify(
1745
- l
1773
+ u
1746
1774
  )}`
1747
1775
  );
1748
- if (!l.contactUser.cloudId || !l.contactUser.networkId || !l.contactUser.cloudUsername)
1776
+ if (!u.contactUser.cloudId || !u.contactUser.networkId || !u.contactUser.cloudUsername)
1749
1777
  throw new Error(
1750
1778
  `CloudContact must define cloudUsername, cloudId, and networkId since v2.1. ContactItem: ${JSON.stringify(
1751
- l
1779
+ u
1752
1780
  )}`
1753
1781
  );
1754
1782
  }
1755
- this.negotiatedProtocolVersion === "2.2" && (l.type === "number" && l.numbers.length > 1 ? l.numbers = [l.numbers[0]] : l.type === "email" && l.emails.length > 1 && (l.emails = [l.emails[0]]));
1783
+ this.negotiatedProtocolVersion === "2.2" && (u.type === "number" && u.numbers.length > 1 ? u.numbers = [u.numbers[0]] : u.type === "email" && u.emails.length > 1 && (u.emails = [u.emails[0]]));
1756
1784
  }
1757
1785
  }
1758
- return u;
1786
+ return l;
1759
1787
  }),
1760
1788
  w(1)
1761
1789
  );
1762
- return this.logService.debug(`Created ${i} Reply handler`), this.port2.postMessage(o), this.logSent(i, o), c;
1790
+ return this.logService.debug(`Created ${i} Reply handler`), this.port2.postMessage(o), this.logSent(i, o), a;
1763
1791
  }
1764
1792
  matchContacts(t) {
1765
1793
  if (!this.isEmbedded())
1766
1794
  throw new d(this.currentContext);
1767
1795
  if (!Array.isArray(t))
1768
- throw new y("contacts", t, "contacts is not an array");
1796
+ throw new m("contacts", t, "contacts is not an array");
1769
1797
  if (!t.length)
1770
- throw new y("contacts", t, "At least one contact is required");
1798
+ throw new m("contacts", t, "At least one contact is required");
1771
1799
  const e = this.createMessage("MATCH CONTACTS");
1772
1800
  if (this.compareVersion("2.1") >= 0) {
1773
1801
  for (const n of t)
1774
1802
  if (n.type === "cloudUsername") {
1775
1803
  if (!n.contactUser)
1776
- throw new y(
1804
+ throw new m(
1777
1805
  "contacts",
1778
1806
  n,
1779
1807
  "CloudUsername contact must include contactUser"
1780
1808
  );
1781
1809
  if (!n.contactUser.cloudUsername || !n.contactUser.cloudId || !n.contactUser.networkId)
1782
- throw new y(
1810
+ throw new m(
1783
1811
  "contacts",
1784
1812
  n,
1785
1813
  "CloudContact must define cloudUsername, cloudId, and networkId"
@@ -1793,7 +1821,7 @@ class Mt {
1793
1821
  }
1794
1822
  this.logCreated(e.type, e);
1795
1823
  const r = this.incomingMessages$.pipe(
1796
- m((n) => n.type === e.type && n.replyTo === e.id),
1824
+ y((n) => n.type === e.type && n.replyTo === e.id),
1797
1825
  g(this.logReceived()),
1798
1826
  f((n) => {
1799
1827
  const i = n;
@@ -1802,29 +1830,29 @@ class Mt {
1802
1830
  throw new Error(
1803
1831
  "MatchContactsMessageReply should return a Record<string, DetailedContactItem> of contacts when using IPC Protocol v2.1+"
1804
1832
  );
1805
- for (const [o, c] of Object.entries(i.contacts)) {
1806
- if (c == null) {
1833
+ for (const [o, a] of Object.entries(i.contacts)) {
1834
+ if (a == null) {
1807
1835
  this.logService.debug(
1808
1836
  `[IPC] [MatchContactsReply] Received null or undefined contact for ${o}`
1809
1837
  );
1810
1838
  continue;
1811
1839
  }
1812
- if (c.contactId === void 0)
1840
+ if (a.contactId === void 0)
1813
1841
  throw new Error(
1814
1842
  `ContactItem 'contactId' is required since v2.1. ContactItem: ${JSON.stringify(
1815
- c
1843
+ a
1816
1844
  )}`
1817
1845
  );
1818
- if (!c.contactUser && (!c.uri || c.uri.length === 0) && (!c.numbers || c.numbers.length === 0))
1846
+ if (!a.contactUser && (!a.uri || a.uri.length === 0) && (!a.numbers || a.numbers.length === 0))
1819
1847
  throw new Error(
1820
1848
  `DetailedContactItem must define at least one contact method (contactUser, uri, or numbers). ContactItem: ${JSON.stringify(
1821
- c
1849
+ a
1822
1850
  )}`
1823
1851
  );
1824
- if (c.contactUser && (!c.contactUser.cloudId || !c.contactUser.networkId || !c.contactUser.cloudUsername))
1852
+ if (a.contactUser && (!a.contactUser.cloudId || !a.contactUser.networkId || !a.contactUser.cloudUsername))
1825
1853
  throw new Error(
1826
1854
  `When contactUser is defined, cloudId, networkId, and cloudUsername must also be defined. ContactItem: ${JSON.stringify(
1827
- c
1855
+ a
1828
1856
  )}`
1829
1857
  );
1830
1858
  }
@@ -1838,14 +1866,14 @@ class Mt {
1838
1866
  "The number of contacts in the reply does not match the number of contacts in the request"
1839
1867
  );
1840
1868
  for (const o of i.contacts) {
1841
- const c = o;
1842
- if (c.type === "cloudUsername" && !("cloudUsername" in c))
1869
+ const a = o;
1870
+ if (a.type === "cloudUsername" && !("cloudUsername" in a))
1843
1871
  throw new Error(
1844
1872
  `CloudUsernameDetailedContactItem must define cloudUsername. ContactItem: ${JSON.stringify(
1845
1873
  o
1846
1874
  )}`
1847
1875
  );
1848
- if (c.type === "uri" && (!("uri" in c) || !Array.isArray(c.uri)))
1876
+ if (a.type === "uri" && (!("uri" in a) || !Array.isArray(a.uri)))
1849
1877
  throw new Error(
1850
1878
  `UriDetailedContactItem must define uri as an array. ContactItem: ${JSON.stringify(
1851
1879
  o
@@ -1890,7 +1918,7 @@ class Mt {
1890
1918
  throw new d(this.currentContext);
1891
1919
  const t = "PUSH MESSAGE";
1892
1920
  return this.incomingMessages$.pipe(
1893
- m((e) => e.type === t && e.target === "client"),
1921
+ y((e) => e.type === t && e.target === "client"),
1894
1922
  f((e) => e),
1895
1923
  g(this.logReceived())
1896
1924
  );
@@ -1910,7 +1938,7 @@ class Mt {
1910
1938
  const t = "PUSH TOKEN", e = this.createMessage(t);
1911
1939
  this.logCreated(t, e);
1912
1940
  const r = this.incomingMessages$.pipe(
1913
- m((n) => n.type === t && n.replyTo === e.id),
1941
+ y((n) => n.type === t && n.replyTo === e.id),
1914
1942
  g(this.logReceived()),
1915
1943
  f((n) => n),
1916
1944
  w(1)
@@ -1949,7 +1977,7 @@ class Mt {
1949
1977
  throw new d(this.currentContext);
1950
1978
  const t = "PUSH TOKEN";
1951
1979
  return this.incomingMessages$.pipe(
1952
- m(
1980
+ y(
1953
1981
  (e) => e.type === t && e.target === "client" && e.replyTo === null && e.expectReply === !1
1954
1982
  ),
1955
1983
  f((e) => {
@@ -1973,7 +2001,7 @@ class Mt {
1973
2001
  throw new d(this.currentContext);
1974
2002
  const t = "BADGE QUERY";
1975
2003
  return this.incomingMessages$.pipe(
1976
- m((e) => e.type === t && e.target === "client"),
2004
+ y((e) => e.type === t && e.target === "client"),
1977
2005
  f((e) => e),
1978
2006
  g(this.logReceived())
1979
2007
  );
@@ -2031,7 +2059,7 @@ class Mt {
2031
2059
  throw new d(this.currentContext);
2032
2060
  const t = "LIFECYCLE";
2033
2061
  return this.incomingMessages$.pipe(
2034
- m((e) => e.type === t && e.target === "client"),
2062
+ y((e) => e.type === t && e.target === "client"),
2035
2063
  f((e) => e),
2036
2064
  g(this.logReceived())
2037
2065
  );
@@ -2071,7 +2099,7 @@ class Mt {
2071
2099
  throw new d(this.currentContext);
2072
2100
  const t = "REQUEST LOGS";
2073
2101
  return this.incomingMessages$.pipe(
2074
- m((e) => e.type === t && e.target === "client"),
2102
+ y((e) => e.type === t && e.target === "client"),
2075
2103
  f((e) => e),
2076
2104
  g(this.logReceived())
2077
2105
  );
@@ -2089,8 +2117,8 @@ class Mt {
2089
2117
  sendRequestLogsMessageReply(t, e, r, n, i) {
2090
2118
  if (!this.isEmbedded())
2091
2119
  throw new d(this.currentContext);
2092
- const o = "REQUEST LOGS", c = this.createMessage(o, !1, i);
2093
- c.fileId = t, c.fileHash = e, c.fileSize = r, c.format = n, this.logCreated(o, c), this.port2.postMessage(c), this.logSent(o, c);
2120
+ const o = "REQUEST LOGS", a = this.createMessage(o, !1, i);
2121
+ a.fileId = t, a.fileHash = e, a.fileSize = r, a.format = n, this.logCreated(o, a), this.port2.postMessage(a), this.logSent(o, a);
2094
2122
  }
2095
2123
  /**
2096
2124
  * Send a {@link ViewTransitionMessage} to the `Host` app, notifying it of a view transition
@@ -2155,28 +2183,28 @@ class Mt {
2155
2183
  sendFileRequestMessage(t, e, r, n, i) {
2156
2184
  if (!this.isEmbedded())
2157
2185
  throw new d(this.currentContext);
2158
- const o = "FILE REQUEST", c = this.createMessage(o);
2159
- if (c.fileId = t, c.fileHash = e.toLowerCase(), c.intent = r, c.maxChunkSizeInBytes = i, r === "attachment") {
2186
+ const o = "FILE REQUEST", a = this.createMessage(o);
2187
+ if (a.fileId = t, a.fileHash = e.toLowerCase(), a.intent = r, a.maxChunkSizeInBytes = i, r === "attachment") {
2160
2188
  if (!n)
2161
- throw new y(
2189
+ throw new m(
2162
2190
  "streamId",
2163
2191
  n,
2164
2192
  "streamId is required for attachment intent"
2165
2193
  );
2166
- c.streamId = n;
2194
+ a.streamId = n;
2167
2195
  }
2168
- this.logCreated(o, c);
2169
- let a = 0;
2170
- const u = this.incomingMessages$.pipe(
2171
- m(
2172
- (h) => h.type === o && h.replyTo === c.id
2196
+ this.logCreated(o, a);
2197
+ let c = 0;
2198
+ const l = this.incomingMessages$.pipe(
2199
+ y(
2200
+ (h) => h.type === o && h.replyTo === a.id
2173
2201
  ),
2174
2202
  g(this.logReceived()),
2175
- g(() => a++),
2203
+ g(() => c++),
2176
2204
  f((h) => (h.result === "success" && (h.chunkHash = h.chunkHash.toLowerCase(), h.fileHash = h.fileHash.toLowerCase()), h)),
2177
- wt((h) => h.result === "success" && a < h.totalChunks, !0)
2205
+ wt((h) => h.result === "success" && c < h.totalChunks, !0)
2178
2206
  );
2179
- return this.port2.postMessage(c), this.logSent(o, c), u;
2207
+ return this.port2.postMessage(a), this.logSent(o, a), l;
2180
2208
  }
2181
2209
  /**
2182
2210
  * Sends a {@link FileRequestMessageReply} to the Host app, to reply to a
@@ -2223,7 +2251,7 @@ class Mt {
2223
2251
  throw new d(this.currentContext);
2224
2252
  const t = "FILE REQUEST";
2225
2253
  return this.incomingMessages$.pipe(
2226
- m(
2254
+ y(
2227
2255
  (e) => e.type === t && e.target === "client" && e.replyTo === null
2228
2256
  ),
2229
2257
  f((e) => (e.fileHash = e.fileHash.toLowerCase(), e)),
@@ -2255,35 +2283,35 @@ class Mt {
2255
2283
  sendFileSelectionMessage(t = "attachment", e, r, n, i, o) {
2256
2284
  if (!this.isEmbedded())
2257
2285
  throw new d(this.currentContext);
2258
- const c = "FILE SELECTION", a = this.createMessage(c);
2259
- if (a.intent = t, a.maxCount = n, a.maxFileSizeInBytes = i, a.mimeTypes = o, t === "attachment") {
2286
+ const a = "FILE SELECTION", c = this.createMessage(a);
2287
+ if (c.intent = t, c.maxCount = n, c.maxFileSizeInBytes = i, c.mimeTypes = o, t === "attachment") {
2260
2288
  if (!e)
2261
- throw new y(
2289
+ throw new m(
2262
2290
  "streamId",
2263
2291
  e,
2264
2292
  "streamId is required for attachment intent"
2265
2293
  );
2266
2294
  if (!r)
2267
- throw new y(
2295
+ throw new m(
2268
2296
  "correlationId",
2269
2297
  r,
2270
2298
  "correlationId is required for attachment intent"
2271
2299
  );
2272
- a.streamId = e, a.correlationId = r;
2300
+ c.streamId = e, c.correlationId = r;
2273
2301
  }
2274
- this.logCreated(c, a);
2275
- const u = this.incomingMessages$.pipe(
2276
- m(
2277
- (h) => h.type === c && h.replyTo === a.id
2302
+ this.logCreated(a, c);
2303
+ const l = this.incomingMessages$.pipe(
2304
+ y(
2305
+ (h) => h.type === a && h.replyTo === c.id
2278
2306
  ),
2279
2307
  f((h) => {
2280
- var l;
2281
- return h.result === "success" && (h.files = (l = h.files) == null ? void 0 : l.map((b) => (b.original.fileHash = b.original.fileHash.toLowerCase(), b.preview && (b.preview.fileHash = b.preview.fileHash.toLowerCase()), b))), h;
2308
+ var u;
2309
+ return h.result === "success" && (h.files = (u = h.files) == null ? void 0 : u.map((b) => (b.original.fileHash = b.original.fileHash.toLowerCase(), b.preview && (b.preview.fileHash = b.preview.fileHash.toLowerCase()), b))), h;
2282
2310
  }),
2283
2311
  g(this.logReceived()),
2284
2312
  w(1)
2285
2313
  );
2286
- return this.port2.postMessage(a), this.logSent(c, a), u;
2314
+ return this.port2.postMessage(c), this.logSent(a, c), l;
2287
2315
  }
2288
2316
  /**
2289
2317
  * Sends a {@link FileDownloadProgressQueryMessage} to the Host app, to query the progress of a
@@ -2313,11 +2341,11 @@ class Mt {
2313
2341
  );
2314
2342
  i.fileHash = t.toLowerCase(), i.url = e, i.correlationId = r, this.logCreated(n, i);
2315
2343
  const o = this.incomingMessages$.pipe(
2316
- m(
2317
- (c) => c.type === "FILE DOWNLOAD PROGRESS UPDATE" && c.replyTo === i.id
2344
+ y(
2345
+ (a) => a.type === "FILE DOWNLOAD PROGRESS UPDATE" && a.replyTo === i.id
2318
2346
  ),
2319
- g((c) => this.logReceived(c)),
2320
- f((c) => (c.fileHash && (c.fileHash = c.fileHash.toLowerCase()), c)),
2347
+ g((a) => this.logReceived(a)),
2348
+ f((a) => (a.fileHash && (a.fileHash = a.fileHash.toLowerCase()), a)),
2321
2349
  w(1)
2322
2350
  );
2323
2351
  return this.port2.postMessage(i), this.logSent(n, i), o;
@@ -2334,7 +2362,7 @@ class Mt {
2334
2362
  throw new d(this.currentContext);
2335
2363
  const t = "FILE DOWNLOAD PROGRESS UPDATE";
2336
2364
  return this.incomingMessages$.pipe(
2337
- m(
2365
+ y(
2338
2366
  (e) => e.type === t && e.target === "client" && e.replyTo === null
2339
2367
  ),
2340
2368
  f((e) => (e.fileHash && (e.fileHash = e.fileHash.toLowerCase()), e)),
@@ -2364,11 +2392,11 @@ class Mt {
2364
2392
  );
2365
2393
  i.fileHash = t.toLowerCase(), i.fileId = e, i.correlationId = r, this.logCreated(n, i);
2366
2394
  const o = this.incomingMessages$.pipe(
2367
- m(
2368
- (c) => c.type === "FILE UPLOAD PROGRESS UPDATE" && c.replyTo === i.id
2395
+ y(
2396
+ (a) => a.type === "FILE UPLOAD PROGRESS UPDATE" && a.replyTo === i.id
2369
2397
  ),
2370
2398
  g(this.logReceived()),
2371
- f((c) => (c.fileHash && (c.fileHash = c.fileHash.toLowerCase()), c)),
2399
+ f((a) => (a.fileHash && (a.fileHash = a.fileHash.toLowerCase()), a)),
2372
2400
  w(1)
2373
2401
  );
2374
2402
  return this.port2.postMessage(i), this.logSent(n, i), o;
@@ -2389,7 +2417,7 @@ class Mt {
2389
2417
  throw new d(this.currentContext);
2390
2418
  const t = "FILE UPLOAD PROGRESS UPDATE";
2391
2419
  return this.incomingMessages$.pipe(
2392
- m(
2420
+ y(
2393
2421
  (e) => e.type === t && e.target === "client" && e.replyTo === null
2394
2422
  ),
2395
2423
  f((e) => (e.fileHash && (e.fileHash = e.fileHash.toLowerCase()), e)),
@@ -2421,39 +2449,39 @@ class Mt {
2421
2449
  * @returns An observable which emits a {@link FileDownloadMessageReply} instance containing the
2422
2450
  * result of the request. Emits once.
2423
2451
  */
2424
- sendFileDownloadMessage(t, e, r, n, i, o, c, a, u) {
2452
+ sendFileDownloadMessage(t, e, r, n, i, o, a, c, l) {
2425
2453
  if (!this.isEmbedded())
2426
2454
  throw new d(this.currentContext);
2427
- if (a && this.compareVersion("2.1") < 0)
2428
- a.type === "cloudUsername" && a.contactUser && (a = {
2429
- ...a,
2430
- cloudId: a.cloudId || a.contactUser.cloudId,
2431
- networkId: a.networkId || a.contactUser.networkId,
2432
- cloudUsername: a.cloudUsername || a.contactUser.cloudUsername
2455
+ if (c && this.compareVersion("2.1") < 0)
2456
+ c.type === "cloudUsername" && c.contactUser && (c = {
2457
+ ...c,
2458
+ cloudId: c.cloudId || c.contactUser.cloudId,
2459
+ networkId: c.networkId || c.contactUser.networkId,
2460
+ cloudUsername: c.cloudUsername || c.contactUser.cloudUsername
2433
2461
  });
2434
- else if (a && this.compareVersion("2.1") >= 0 && a.type === "cloudUsername") {
2435
- if (!a.contactUser)
2436
- throw new y(
2462
+ else if (c && this.compareVersion("2.1") >= 0 && c.type === "cloudUsername") {
2463
+ if (!c.contactUser)
2464
+ throw new m(
2437
2465
  "sender",
2438
- a,
2466
+ c,
2439
2467
  "CloudUsername contact must include contactUser since v2.1"
2440
2468
  );
2441
- if (!a.contactUser.cloudId || !a.contactUser.networkId || !a.contactUser.cloudUsername)
2442
- throw new y(
2469
+ if (!c.contactUser.cloudId || !c.contactUser.networkId || !c.contactUser.cloudUsername)
2470
+ throw new m(
2443
2471
  "sender",
2444
- a,
2472
+ c,
2445
2473
  "CloudContact must define cloudUsername, cloudId, and networkId since v2.1"
2446
2474
  );
2447
2475
  }
2448
- const h = "FILE DOWNLOAD", l = this.createMessage(h, !0);
2449
- l.url = t, l.key = e, l.fileHash = r.toLowerCase(), l.mimeType = n, l.fileName = i, l.streamId = o, l.correlationId = c, l.sender = a, l.intent = u ?? "download", this.logCreated(h, l);
2476
+ const h = "FILE DOWNLOAD", u = this.createMessage(h, !0);
2477
+ u.url = t, u.key = e, u.fileHash = r.toLowerCase(), u.mimeType = n, u.fileName = i, u.streamId = o, u.correlationId = a, u.sender = c, u.intent = l ?? "download", this.logCreated(h, u);
2450
2478
  const b = this.incomingMessages$.pipe(
2451
- m((p) => p.type === h && p.replyTo === l.id),
2479
+ y((p) => p.type === h && p.replyTo === u.id),
2452
2480
  g(this.logReceived()),
2453
2481
  f((p) => p),
2454
2482
  w(1)
2455
2483
  );
2456
- return this.port2.postMessage(l), this.logSent(h, l), b;
2484
+ return this.port2.postMessage(u), this.logSent(h, u), b;
2457
2485
  }
2458
2486
  /**
2459
2487
  * Sends a {@link CancelFileDownloadMessage} to the Host app, to cancel downloading of a file
@@ -2490,7 +2518,7 @@ class Mt {
2490
2518
  const r = "FILE REMOVE", n = this.createMessage(r, !0);
2491
2519
  n.hash = t.toLowerCase(), n.streamId = e, this.logCreated(r, n);
2492
2520
  const i = this.incomingMessages$.pipe(
2493
- m((o) => o.type === r && o.replyTo === n.id),
2521
+ y((o) => o.type === r && o.replyTo === n.id),
2494
2522
  g(this.logReceived()),
2495
2523
  f((o) => o),
2496
2524
  w(1)
@@ -2558,13 +2586,13 @@ class Mt {
2558
2586
  * @returns An observable which emits a {@link SendMessageMessageReply} instance containing the
2559
2587
  * result of the request. Emits once.
2560
2588
  */
2561
- sendSendMessageMessage(t, e, r, n = "TEXT", i, o, c, a = !0, u) {
2589
+ sendSendMessageMessage(t, e, r, n = "TEXT", i, o, a, c = !0, l) {
2562
2590
  if (!this.isEmbedded())
2563
2591
  throw new d(this.currentContext);
2564
- const h = "SEND MESSAGE", l = this.createMessage(h, !0);
2565
- if (l.streamId = t, l.correlationId = e, l.body = r, l.messageType = n, i && i.length > 0)
2592
+ const h = "SEND MESSAGE", u = this.createMessage(h, !0);
2593
+ if (u.streamId = t, u.correlationId = e, u.body = r, u.messageType = n, i && i.length > 0)
2566
2594
  if (this.compareVersion("2.1") < 0)
2567
- l.mentions = i.map((p) => p.contactUser ? {
2595
+ u.mentions = i.map((p) => p.contactUser ? {
2568
2596
  ...p,
2569
2597
  cloudId: p.cloudId || p.contactUser.cloudId,
2570
2598
  networkId: p.networkId || p.contactUser.networkId,
@@ -2573,30 +2601,30 @@ class Mt {
2573
2601
  else {
2574
2602
  for (const p of i) {
2575
2603
  if (p.type === "cloudUsername" && !p.contactUser)
2576
- throw new y(
2604
+ throw new m(
2577
2605
  "mentions",
2578
2606
  p,
2579
2607
  "CloudUsername mention must include contactUser"
2580
2608
  );
2581
2609
  if (p.contactUser && (!p.contactUser.cloudId || !p.contactUser.networkId || !p.contactUser.cloudUsername))
2582
- throw new y(
2610
+ throw new m(
2583
2611
  "mentions",
2584
2612
  p,
2585
2613
  "CloudContact must define cloudUsername, cloudId, and networkId"
2586
2614
  );
2587
2615
  }
2588
- l.mentions = i;
2616
+ u.mentions = i;
2589
2617
  }
2590
2618
  else
2591
- l.mentions = [];
2592
- l.attachments = (o == null ? void 0 : o.map((p) => p.toLowerCase())) ?? [], l.relatedMessageId = c, l.setCursors = a, l.threadId = u, this.logCreated(h, l);
2619
+ u.mentions = [];
2620
+ u.attachments = (o == null ? void 0 : o.map((p) => p.toLowerCase())) ?? [], u.relatedMessageId = a, u.setCursors = c, u.threadId = l, this.logCreated(h, u);
2593
2621
  const b = this.incomingMessages$.pipe(
2594
- m((p) => p.type === h && p.replyTo === l.id),
2622
+ y((p) => p.type === h && p.replyTo === u.id),
2595
2623
  g(this.logReceived()),
2596
2624
  f((p) => p),
2597
2625
  w(1)
2598
2626
  );
2599
- return this.port2.postMessage(l), this.logSent(h, l), b;
2627
+ return this.port2.postMessage(u), this.logSent(h, u), b;
2600
2628
  }
2601
2629
  /**
2602
2630
  * Sends a {@link CancelSendMessageMessage} to the Host app, to cancel a message that was being
@@ -2645,7 +2673,7 @@ class Mt {
2645
2673
  const r = "SEND MESSAGE STATUS QUERY", n = this.createMessage(r, !0);
2646
2674
  n.correlationId = t, n.streamId = e, this.logCreated(r, n);
2647
2675
  const i = this.incomingMessages$.pipe(
2648
- m(
2676
+ y(
2649
2677
  (o) => o.type === "SEND MESSAGE STATUS UPDATE" && o.replyTo === n.id
2650
2678
  ),
2651
2679
  g(this.logReceived()),
@@ -2666,7 +2694,7 @@ class Mt {
2666
2694
  throw new d(this.currentContext);
2667
2695
  const t = "SEND MESSAGE STATUS UPDATE";
2668
2696
  return this.incomingMessages$.pipe(
2669
- m((e) => e.type === t && e.target === "client" && e.replyTo === null),
2697
+ y((e) => e.type === t && e.target === "client" && e.replyTo === null),
2670
2698
  f((e) => e),
2671
2699
  g(this.logReceived())
2672
2700
  );
@@ -2691,13 +2719,13 @@ class Mt {
2691
2719
  });
2692
2720
  else if (t.type === "cloudUsername") {
2693
2721
  if (!t.contactUser)
2694
- throw new y(
2722
+ throw new m(
2695
2723
  "contact",
2696
2724
  t,
2697
2725
  "CloudUsername contact must include contactUser since v2.1"
2698
2726
  );
2699
2727
  if (!t.contactUser.cloudId || !t.contactUser.networkId || !t.contactUser.cloudUsername)
2700
- throw new y(
2728
+ throw new m(
2701
2729
  "contact",
2702
2730
  t,
2703
2731
  "CloudContact must define cloudUsername, cloudId, and networkId since v2.1"
@@ -2760,7 +2788,7 @@ class Mt {
2760
2788
  throw new d(this.currentContext);
2761
2789
  const t = "BUTTONS";
2762
2790
  return this.incomingMessages$.pipe(
2763
- m((e) => e.type === t && e.target === "client"),
2791
+ y((e) => e.type === t && e.target === "client"),
2764
2792
  f((e) => e),
2765
2793
  g(this.logReceived())
2766
2794
  );
@@ -2961,9 +2989,9 @@ class xt {
2961
2989
  let i;
2962
2990
  if (this.negotiatedVersion === "2.0") {
2963
2991
  if (typeof e != "string")
2964
- throw new y("mode", e, 'mode must be "single" or "multi"');
2992
+ throw new m("mode", e, 'mode must be "single" or "multi"');
2965
2993
  if (n === "number")
2966
- throw new y(
2994
+ throw new m(
2967
2995
  "contactType",
2968
2996
  n,
2969
2997
  'contactType cannot be "number" for version 2.0 of the IPC protocol'
@@ -2976,7 +3004,7 @@ class xt {
2976
3004
  );
2977
3005
  } else {
2978
3006
  if (typeof e != "object")
2979
- throw new y("options", e, "options must be an object");
3007
+ throw new m("options", e, "options must be an object");
2980
3008
  i = this.selectContacts_V2_1(t, e);
2981
3009
  }
2982
3010
  return T(
@@ -2993,7 +3021,7 @@ class xt {
2993
3021
  selectContacts_V2_0(t, e, r, n) {
2994
3022
  if (this.logger.debug("Selecting Contacts: ", ...arguments), e === "multi") {
2995
3023
  if (!r || !Array.isArray(r))
2996
- throw new y(
3024
+ throw new m(
2997
3025
  "currentContacts",
2998
3026
  r,
2999
3027
  "currentContacts is required for group streams"
@@ -3008,19 +3036,35 @@ class xt {
3008
3036
  return n || (n = "cloudUsername"), this.helper.selectContacts(t.toString(), "direct", n);
3009
3037
  }
3010
3038
  selectContacts_V2_1(t, e) {
3011
- if (this.logger.debug("Selecting Contacts: ", e), e.mode === "multi" && (!e.currentContacts || !Array.isArray(e.currentContacts)))
3012
- throw new y(
3039
+ this.logger.debug("Selecting Contacts: ", e);
3040
+ const r = t.toString(), n = e.resultTypes ?? ["cloudUsername"];
3041
+ if (e.mode === "single")
3042
+ return this.helper.selectContacts(r, {
3043
+ allowMultipleSelection: !1,
3044
+ resultTypes: n
3045
+ });
3046
+ if (!e.currentContacts || !Array.isArray(e.currentContacts))
3047
+ throw new m(
3013
3048
  "currentContacts",
3014
3049
  e.currentContacts,
3015
3050
  "currentContacts is required for group streams"
3016
3051
  );
3017
- return this.helper.selectContacts(
3018
- t.toString(),
3052
+ return e.filterToSelectedType ? this.helper.selectContacts(
3053
+ r,
3054
+ {
3055
+ allowMultipleSelection: !0,
3056
+ filterToSelectedType: !0,
3057
+ resultTypes: n
3058
+ },
3059
+ e.currentContacts
3060
+ ) : this.helper.selectContacts(
3061
+ r,
3019
3062
  {
3020
- allowMultipleSelection: e.mode === "multi",
3021
- resultTypes: e.resultTypes ?? ["cloudUsername"]
3063
+ allowMultipleSelection: !0,
3064
+ filterToSelectedType: !1,
3065
+ resultTypes: n
3022
3066
  },
3023
- e.mode === "multi" ? e.currentContacts : void 0
3067
+ e.currentContacts
3024
3068
  );
3025
3069
  }
3026
3070
  /**