@acrobits/ipc-sdk 0.10.0 → 0.11.2-alpha.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.
Files changed (36) hide show
  1. package/docs/assets/main.js +4 -4
  2. package/docs/assets/navigation.js +1 -1
  3. package/docs/assets/search.js +1 -1
  4. package/docs/assets/style.css +7 -5
  5. package/docs/classes/IPCManager.html +94 -69
  6. package/docs/enums/IPCEvents.html +10 -8
  7. package/docs/index.html +2 -2
  8. package/docs/interfaces/DetailedContactURI.html +6 -6
  9. package/docs/interfaces/ILogger.html +7 -7
  10. package/docs/modules.html +17 -17
  11. package/docs/types/BaseContactItem.html +10 -0
  12. package/docs/types/CloudUsernameContactItem.html +6 -0
  13. package/docs/types/ContactItem.html +2 -2
  14. package/docs/types/ContactLabel.html +2 -2
  15. package/docs/types/ContactType.html +2 -2
  16. package/docs/types/ContactURI.html +2 -2
  17. package/docs/types/DetailedContactItem.html +16 -0
  18. package/docs/types/HostType.html +2 -2
  19. package/docs/types/IPCContext.html +2 -2
  20. package/docs/types/IpcProtocolVersion.html +2 -2
  21. package/docs/types/UnsubscribeCallback.html +2 -2
  22. package/docs/types/UriContactItem.html +3 -0
  23. package/lib/index.d.ts +254 -33
  24. package/lib/ipc-sdk.js +944 -538
  25. package/lib/ipc-sdk.js.map +1 -1
  26. package/lib/ipc-sdk.umd.cjs +3 -3
  27. package/lib/ipc-sdk.umd.cjs.map +1 -1
  28. package/lib/tsdoc-metadata.json +1 -1
  29. package/package.json +3 -3
  30. package/docs/assets/icons.js +0 -15
  31. package/docs/assets/icons.svg +0 -1
  32. package/docs/hierarchy.html +0 -1
  33. package/docs/interfaces/BaseContactItem.html +0 -8
  34. package/docs/interfaces/CloudUsernameContactItem.html +0 -10
  35. package/docs/interfaces/DetailedContactItem.html +0 -17
  36. package/docs/interfaces/UriContactItem.html +0 -10
package/lib/ipc-sdk.js CHANGED
@@ -1,52 +1,59 @@
1
- var Pe = Object.defineProperty;
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 M = (n, t, e) => _e(n, typeof t != "symbol" ? t + "" : t, e);
4
- var w = /* @__PURE__ */ ((n) => (n.BadgeQuery = "BADGE QUERY", n.Lifecycle = "LIFECYCLE", n.PushToken = "PUSH TOKEN", n))(w || {}), q = function(n, t) {
5
- return q = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
1
+ var Ae = Object.defineProperty;
2
+ var Pe = (n, t, e) => t in n ? Ae(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e;
3
+ var M = (n, t, e) => (Pe(n, typeof t != "symbol" ? t + "" : t, e), e);
4
+ var C = /* @__PURE__ */ ((n) => (n.BadgeQuery = "BADGE QUERY", n.Lifecycle = "LIFECYCLE", n.PushToken = "PUSH TOKEN", n.RequestLogs = "REQUEST LOGS", n))(C || {}), B = function(n, t) {
5
+ return B = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
6
6
  e.__proto__ = r;
7
7
  } || function(e, r) {
8
- for (var s in r) Object.prototype.hasOwnProperty.call(r, s) && (e[s] = r[s]);
9
- }, q(n, t);
8
+ for (var s in r)
9
+ Object.prototype.hasOwnProperty.call(r, s) && (e[s] = r[s]);
10
+ }, B(n, t);
10
11
  };
11
- function x(n, t) {
12
+ function U(n, t) {
12
13
  if (typeof t != "function" && t !== null)
13
14
  throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
14
- q(n, t);
15
+ B(n, t);
15
16
  function e() {
16
17
  this.constructor = n;
17
18
  }
18
19
  n.prototype = t === null ? Object.create(t) : (e.prototype = t.prototype, new e());
19
20
  }
20
- function G(n) {
21
+ function Q(n) {
21
22
  var t = typeof Symbol == "function" && Symbol.iterator, e = t && n[t], r = 0;
22
- if (e) return e.call(n);
23
- if (n && typeof n.length == "number") return {
24
- next: function() {
25
- return n && r >= n.length && (n = void 0), { value: n && n[r++], done: !n };
26
- }
27
- };
23
+ if (e)
24
+ return e.call(n);
25
+ if (n && typeof n.length == "number")
26
+ return {
27
+ next: function() {
28
+ return n && r >= n.length && (n = void 0), { value: n && n[r++], done: !n };
29
+ }
30
+ };
28
31
  throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
29
32
  }
30
33
  function $(n, t) {
31
34
  var e = typeof Symbol == "function" && n[Symbol.iterator];
32
- if (!e) return n;
35
+ if (!e)
36
+ return n;
33
37
  var r = e.call(n), s, i = [], o;
34
38
  try {
35
- for (; (t === void 0 || t-- > 0) && !(s = r.next()).done; ) i.push(s.value);
36
- } catch (a) {
37
- o = { error: a };
39
+ for (; (t === void 0 || t-- > 0) && !(s = r.next()).done; )
40
+ i.push(s.value);
41
+ } catch (c) {
42
+ o = { error: c };
38
43
  } finally {
39
44
  try {
40
45
  s && !s.done && (e = r.return) && e.call(r);
41
46
  } finally {
42
- if (o) throw o.error;
47
+ if (o)
48
+ throw o.error;
43
49
  }
44
50
  }
45
51
  return i;
46
52
  }
47
- function D(n, t, e) {
48
- if (e || arguments.length === 2) for (var r = 0, s = t.length, i; r < s; r++)
49
- (i || !(r in t)) && (i || (i = Array.prototype.slice.call(t, 0, r)), i[r] = t[r]);
53
+ function k(n, t, e) {
54
+ if (e || arguments.length === 2)
55
+ for (var r = 0, s = t.length, i; r < s; r++)
56
+ (i || !(r in t)) && (i || (i = Array.prototype.slice.call(t, 0, r)), i[r] = t[r]);
50
57
  return n.concat(i || Array.prototype.slice.call(t));
51
58
  }
52
59
  function S(n) {
@@ -58,7 +65,7 @@ function X(n) {
58
65
  }, e = n(t);
59
66
  return e.prototype = Object.create(Error.prototype), e.prototype.constructor = e, e;
60
67
  }
61
- var k = X(function(n) {
68
+ var V = X(function(n) {
62
69
  return function(e) {
63
70
  n(this), this.message = e ? e.length + ` errors occurred during unsubscription:
64
71
  ` + e.map(function(r, s) {
@@ -67,13 +74,13 @@ var k = X(function(n) {
67
74
  `) : "", this.name = "UnsubscriptionError", this.errors = e;
68
75
  };
69
76
  });
70
- function F(n, t) {
77
+ function D(n, t) {
71
78
  if (n) {
72
79
  var e = n.indexOf(t);
73
80
  0 <= e && n.splice(e, 1);
74
81
  }
75
82
  }
76
- var R = function() {
83
+ var x = function() {
77
84
  function n(t) {
78
85
  this.initialTeardown = t, this.closed = !1, this._parentage = null, this._finalizers = null;
79
86
  }
@@ -85,58 +92,60 @@ var R = function() {
85
92
  if (o)
86
93
  if (this._parentage = null, Array.isArray(o))
87
94
  try {
88
- for (var a = G(o), c = a.next(); !c.done; c = a.next()) {
89
- var u = c.value;
95
+ for (var c = Q(o), a = c.next(); !a.done; a = c.next()) {
96
+ var u = a.value;
90
97
  u.remove(this);
91
98
  }
92
- } catch (y) {
93
- t = { error: y };
99
+ } catch (v) {
100
+ t = { error: v };
94
101
  } finally {
95
102
  try {
96
- c && !c.done && (e = a.return) && e.call(a);
103
+ a && !a.done && (e = c.return) && e.call(c);
97
104
  } finally {
98
- if (t) throw t.error;
105
+ if (t)
106
+ throw t.error;
99
107
  }
100
108
  }
101
109
  else
102
110
  o.remove(this);
103
- var l = this.initialTeardown;
104
- if (S(l))
111
+ var h = this.initialTeardown;
112
+ if (S(h))
105
113
  try {
106
- l();
107
- } catch (y) {
108
- i = y instanceof k ? y.errors : [y];
114
+ h();
115
+ } catch (v) {
116
+ i = v instanceof V ? v.errors : [v];
109
117
  }
110
- var h = this._finalizers;
111
- if (h) {
118
+ var l = this._finalizers;
119
+ if (l) {
112
120
  this._finalizers = null;
113
121
  try {
114
- for (var b = G(h), v = b.next(); !v.done; v = b.next()) {
115
- var N = v.value;
122
+ for (var b = Q(l), p = b.next(); !p.done; p = b.next()) {
123
+ var F = p.value;
116
124
  try {
117
- se(N);
118
- } catch (y) {
119
- i = i ?? [], y instanceof k ? i = D(D([], $(i)), $(y.errors)) : i.push(y);
125
+ ne(F);
126
+ } catch (v) {
127
+ i = i ?? [], v instanceof V ? i = k(k([], $(i)), $(v.errors)) : i.push(v);
120
128
  }
121
129
  }
122
- } catch (y) {
123
- r = { error: y };
130
+ } catch (v) {
131
+ r = { error: v };
124
132
  } finally {
125
133
  try {
126
- v && !v.done && (s = b.return) && s.call(b);
134
+ p && !p.done && (s = b.return) && s.call(b);
127
135
  } finally {
128
- if (r) throw r.error;
136
+ if (r)
137
+ throw r.error;
129
138
  }
130
139
  }
131
140
  }
132
141
  if (i)
133
- throw new k(i);
142
+ throw new V(i);
134
143
  }
135
144
  }, n.prototype.add = function(t) {
136
145
  var e;
137
146
  if (t && t !== this)
138
147
  if (this.closed)
139
- se(t);
148
+ ne(t);
140
149
  else {
141
150
  if (t instanceof n) {
142
151
  if (t.closed || t._hasParent(this))
@@ -153,19 +162,19 @@ var R = function() {
153
162
  this._parentage = Array.isArray(e) ? (e.push(t), e) : e ? [e, t] : t;
154
163
  }, n.prototype._removeParent = function(t) {
155
164
  var e = this._parentage;
156
- e === t ? this._parentage = null : Array.isArray(e) && F(e, t);
165
+ e === t ? this._parentage = null : Array.isArray(e) && D(e, t);
157
166
  }, n.prototype.remove = function(t) {
158
167
  var e = this._finalizers;
159
- e && F(e, t), t instanceof n && t._removeParent(this);
168
+ e && D(e, t), t instanceof n && t._removeParent(this);
160
169
  }, n.EMPTY = function() {
161
170
  var t = new n();
162
171
  return t.closed = !0, t;
163
172
  }(), n;
164
- }(), be = R.EMPTY;
165
- function me(n) {
166
- return n instanceof R || n && "closed" in n && S(n.remove) && S(n.add) && S(n.unsubscribe);
173
+ }(), ve = x.EMPTY;
174
+ function be(n) {
175
+ return n instanceof x || n && "closed" in n && S(n.remove) && S(n.add) && S(n.unsubscribe);
167
176
  }
168
- function se(n) {
177
+ function ne(n) {
169
178
  S(n) ? n() : n.unsubscribe();
170
179
  }
171
180
  var we = {
@@ -174,36 +183,36 @@ var we = {
174
183
  Promise: void 0,
175
184
  useDeprecatedSynchronousErrorHandling: !1,
176
185
  useDeprecatedNextContext: !1
177
- }, Se = {
186
+ }, Ce = {
178
187
  setTimeout: function(n, t) {
179
188
  for (var e = [], r = 2; r < arguments.length; r++)
180
189
  e[r - 2] = arguments[r];
181
- return setTimeout.apply(void 0, D([n, t], $(e)));
190
+ return setTimeout.apply(void 0, k([n, t], $(e)));
182
191
  },
183
192
  clearTimeout: function(n) {
184
- var t = Se.delegate;
193
+ var t = Ce.delegate;
185
194
  return ((t == null ? void 0 : t.clearTimeout) || clearTimeout)(n);
186
195
  },
187
196
  delegate: void 0
188
197
  };
189
- function Ae(n) {
190
- Se.setTimeout(function() {
198
+ function _e(n) {
199
+ Ce.setTimeout(function() {
191
200
  throw n;
192
201
  });
193
202
  }
194
- function ie() {
203
+ function se() {
195
204
  }
196
- function U(n) {
205
+ function O(n) {
197
206
  n();
198
207
  }
199
208
  var Z = function(n) {
200
- x(t, n);
209
+ U(t, n);
201
210
  function t(e) {
202
211
  var r = n.call(this) || this;
203
- return r.isStopped = !1, e ? (r.destination = e, me(e) && e.add(r)) : r.destination = $e, r;
212
+ return r.isStopped = !1, e ? (r.destination = e, be(e) && e.add(r)) : r.destination = ke, r;
204
213
  }
205
214
  return t.create = function(e, r, s) {
206
- return new H(e, r, s);
215
+ return new N(e, r, s);
207
216
  }, t.prototype.next = function(e) {
208
217
  this.isStopped || this._next(e);
209
218
  }, t.prototype.error = function(e) {
@@ -227,11 +236,11 @@ var Z = function(n) {
227
236
  this.unsubscribe();
228
237
  }
229
238
  }, t;
230
- }(R), Oe = Function.prototype.bind;
231
- function V(n, t) {
232
- return Oe.call(n, t);
239
+ }(x), Le = Function.prototype.bind;
240
+ function H(n, t) {
241
+ return Le.call(n, t);
233
242
  }
234
- var Le = function() {
243
+ var Oe = function() {
235
244
  function n(t) {
236
245
  this.partialObserver = t;
237
246
  }
@@ -241,7 +250,7 @@ var Le = function() {
241
250
  try {
242
251
  e.next(t);
243
252
  } catch (r) {
244
- A(r);
253
+ P(r);
245
254
  }
246
255
  }, n.prototype.error = function(t) {
247
256
  var e = this.partialObserver;
@@ -249,21 +258,21 @@ var Le = function() {
249
258
  try {
250
259
  e.error(t);
251
260
  } catch (r) {
252
- A(r);
261
+ P(r);
253
262
  }
254
263
  else
255
- A(t);
264
+ P(t);
256
265
  }, n.prototype.complete = function() {
257
266
  var t = this.partialObserver;
258
267
  if (t.complete)
259
268
  try {
260
269
  t.complete();
261
270
  } catch (e) {
262
- A(e);
271
+ P(e);
263
272
  }
264
273
  }, n;
265
- }(), H = function(n) {
266
- x(t, n);
274
+ }(), N = function(n) {
275
+ U(t, n);
267
276
  function t(e, r, s) {
268
277
  var i = n.call(this) || this, o;
269
278
  if (S(e) || !e)
@@ -273,44 +282,44 @@ var Le = function() {
273
282
  complete: s ?? void 0
274
283
  };
275
284
  else {
276
- var a;
277
- i && we.useDeprecatedNextContext ? (a = Object.create(e), a.unsubscribe = function() {
285
+ var c;
286
+ i && we.useDeprecatedNextContext ? (c = Object.create(e), c.unsubscribe = function() {
278
287
  return i.unsubscribe();
279
288
  }, o = {
280
- next: e.next && V(e.next, a),
281
- error: e.error && V(e.error, a),
282
- complete: e.complete && V(e.complete, a)
289
+ next: e.next && H(e.next, c),
290
+ error: e.error && H(e.error, c),
291
+ complete: e.complete && H(e.complete, c)
283
292
  }) : o = e;
284
293
  }
285
- return i.destination = new Le(o), i;
294
+ return i.destination = new Oe(o), i;
286
295
  }
287
296
  return t;
288
297
  }(Z);
289
- function A(n) {
290
- Ae(n);
298
+ function P(n) {
299
+ _e(n);
291
300
  }
292
- function Ue(n) {
301
+ function $e(n) {
293
302
  throw n;
294
303
  }
295
- var $e = {
304
+ var ke = {
296
305
  closed: !0,
297
- next: ie,
298
- error: Ue,
299
- complete: ie
306
+ next: se,
307
+ error: $e,
308
+ complete: se
300
309
  }, De = function() {
301
310
  return typeof Symbol == "function" && Symbol.observable || "@@observable";
302
311
  }();
303
- function Ee(n) {
312
+ function Se(n) {
304
313
  return n;
305
314
  }
306
- function Fe(n) {
307
- return n.length === 0 ? Ee : n.length === 1 ? n[0] : function(e) {
315
+ function Ne(n) {
316
+ return n.length === 0 ? Se : n.length === 1 ? n[0] : function(e) {
308
317
  return n.reduce(function(r, s) {
309
318
  return s(r);
310
319
  }, e);
311
320
  };
312
321
  }
313
- var B = function() {
322
+ var G = function() {
314
323
  function n(t) {
315
324
  t && (this._subscribe = t);
316
325
  }
@@ -318,10 +327,10 @@ var B = function() {
318
327
  var e = new n();
319
328
  return e.source = this, e.operator = t, e;
320
329
  }, n.prototype.subscribe = function(t, e, r) {
321
- var s = this, i = Ne(t) ? t : new H(t, e, r);
322
- return U(function() {
323
- var o = s, a = o.operator, c = o.source;
324
- i.add(a ? a.call(i, c) : c ? s._subscribe(i) : s._trySubscribe(i));
330
+ var s = this, i = Ve(t) ? t : new N(t, e, r);
331
+ return O(function() {
332
+ var o = s, c = o.operator, a = o.source;
333
+ i.add(c ? c.call(i, a) : a ? s._subscribe(i) : s._trySubscribe(i));
325
334
  }), i;
326
335
  }, n.prototype._trySubscribe = function(t) {
327
336
  try {
@@ -331,13 +340,13 @@ var B = function() {
331
340
  }
332
341
  }, n.prototype.forEach = function(t, e) {
333
342
  var r = this;
334
- return e = oe(e), new e(function(s, i) {
335
- var o = new H({
336
- next: function(a) {
343
+ return e = ie(e), new e(function(s, i) {
344
+ var o = new N({
345
+ next: function(c) {
337
346
  try {
338
- t(a);
339
- } catch (c) {
340
- i(c), o.unsubscribe();
347
+ t(c);
348
+ } catch (a) {
349
+ i(a), o.unsubscribe();
341
350
  }
342
351
  },
343
352
  error: i,
@@ -353,10 +362,10 @@ var B = function() {
353
362
  }, n.prototype.pipe = function() {
354
363
  for (var t = [], e = 0; e < arguments.length; e++)
355
364
  t[e] = arguments[e];
356
- return Fe(t)(this);
365
+ return Ne(t)(this);
357
366
  }, n.prototype.toPromise = function(t) {
358
367
  var e = this;
359
- return t = oe(t), new t(function(r, s) {
368
+ return t = ie(t), new t(function(r, s) {
360
369
  var i;
361
370
  e.subscribe(function(o) {
362
371
  return i = o;
@@ -370,22 +379,22 @@ var B = function() {
370
379
  return new n(t);
371
380
  }, n;
372
381
  }();
373
- function oe(n) {
382
+ function ie(n) {
374
383
  var t;
375
384
  return (t = n ?? we.Promise) !== null && t !== void 0 ? t : Promise;
376
385
  }
377
- function He(n) {
386
+ function Fe(n) {
378
387
  return n && S(n.next) && S(n.error) && S(n.complete);
379
388
  }
380
- function Ne(n) {
381
- return n && n instanceof Z || He(n) && me(n);
389
+ function Ve(n) {
390
+ return n && n instanceof Z || Fe(n) && be(n);
382
391
  }
383
- function ke(n) {
392
+ function He(n) {
384
393
  return S(n == null ? void 0 : n.lift);
385
394
  }
386
- function Me(n) {
395
+ function Ee(n) {
387
396
  return function(t) {
388
- if (ke(t))
397
+ if (He(t))
389
398
  return t.lift(function(e) {
390
399
  try {
391
400
  return n(e, this);
@@ -396,28 +405,28 @@ function Me(n) {
396
405
  throw new TypeError("Unable to lift unknown Observable type");
397
406
  };
398
407
  }
399
- function Ce(n, t, e, r, s) {
400
- return new Ve(n, t, e, r, s);
408
+ function Me(n, t, e, r, s) {
409
+ return new je(n, t, e, r, s);
401
410
  }
402
- var Ve = function(n) {
403
- x(t, n);
404
- function t(e, r, s, i, o, a) {
405
- var c = n.call(this, e) || this;
406
- return c.onFinalize = o, c.shouldUnsubscribe = a, c._next = r ? function(u) {
411
+ var je = function(n) {
412
+ U(t, n);
413
+ function t(e, r, s, i, o, c) {
414
+ var a = n.call(this, e) || this;
415
+ return a.onFinalize = o, a.shouldUnsubscribe = c, a._next = r ? function(u) {
407
416
  try {
408
417
  r(u);
409
- } catch (l) {
410
- e.error(l);
418
+ } catch (h) {
419
+ e.error(h);
411
420
  }
412
- } : n.prototype._next, c._error = i ? function(u) {
421
+ } : n.prototype._next, a._error = i ? function(u) {
413
422
  try {
414
423
  i(u);
415
- } catch (l) {
416
- e.error(l);
424
+ } catch (h) {
425
+ e.error(h);
417
426
  } finally {
418
427
  this.unsubscribe();
419
428
  }
420
- } : n.prototype._error, c._complete = s ? function() {
429
+ } : n.prototype._error, a._complete = s ? function() {
421
430
  try {
422
431
  s();
423
432
  } catch (u) {
@@ -425,7 +434,7 @@ var Ve = function(n) {
425
434
  } finally {
426
435
  this.unsubscribe();
427
436
  }
428
- } : n.prototype._complete, c;
437
+ } : n.prototype._complete, a;
429
438
  }
430
439
  return t.prototype.unsubscribe = function() {
431
440
  var e;
@@ -434,47 +443,48 @@ var Ve = function(n) {
434
443
  n.prototype.unsubscribe.call(this), !r && ((e = this.onFinalize) === null || e === void 0 || e.call(this));
435
444
  }
436
445
  }, t;
437
- }(Z), je = X(function(n) {
446
+ }(Z), qe = X(function(n) {
438
447
  return function() {
439
448
  n(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
440
449
  };
441
- }), xe = function(n) {
442
- x(t, n);
450
+ }), Ie = function(n) {
451
+ U(t, n);
443
452
  function t() {
444
453
  var e = n.call(this) || this;
445
454
  return e.closed = !1, e.currentObservers = null, e.observers = [], e.isStopped = !1, e.hasError = !1, e.thrownError = null, e;
446
455
  }
447
456
  return t.prototype.lift = function(e) {
448
- var r = new ae(this, this);
457
+ var r = new oe(this, this);
449
458
  return r.operator = e, r;
450
459
  }, t.prototype._throwIfClosed = function() {
451
460
  if (this.closed)
452
- throw new je();
461
+ throw new qe();
453
462
  }, t.prototype.next = function(e) {
454
463
  var r = this;
455
- U(function() {
464
+ O(function() {
456
465
  var s, i;
457
466
  if (r._throwIfClosed(), !r.isStopped) {
458
467
  r.currentObservers || (r.currentObservers = Array.from(r.observers));
459
468
  try {
460
- for (var o = G(r.currentObservers), a = o.next(); !a.done; a = o.next()) {
461
- var c = a.value;
462
- c.next(e);
469
+ for (var o = Q(r.currentObservers), c = o.next(); !c.done; c = o.next()) {
470
+ var a = c.value;
471
+ a.next(e);
463
472
  }
464
473
  } catch (u) {
465
474
  s = { error: u };
466
475
  } finally {
467
476
  try {
468
- a && !a.done && (i = o.return) && i.call(o);
477
+ c && !c.done && (i = o.return) && i.call(o);
469
478
  } finally {
470
- if (s) throw s.error;
479
+ if (s)
480
+ throw s.error;
471
481
  }
472
482
  }
473
483
  }
474
484
  });
475
485
  }, t.prototype.error = function(e) {
476
486
  var r = this;
477
- U(function() {
487
+ O(function() {
478
488
  if (r._throwIfClosed(), !r.isStopped) {
479
489
  r.hasError = r.isStopped = !0, r.thrownError = e;
480
490
  for (var s = r.observers; s.length; )
@@ -483,7 +493,7 @@ var Ve = function(n) {
483
493
  });
484
494
  }, t.prototype.complete = function() {
485
495
  var e = this;
486
- U(function() {
496
+ O(function() {
487
497
  if (e._throwIfClosed(), !e.isStopped) {
488
498
  e.isStopped = !0;
489
499
  for (var r = e.observers; r.length; )
@@ -504,21 +514,21 @@ var Ve = function(n) {
504
514
  }, t.prototype._subscribe = function(e) {
505
515
  return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
506
516
  }, t.prototype._innerSubscribe = function(e) {
507
- var r = this, s = this, i = s.hasError, o = s.isStopped, a = s.observers;
508
- return i || o ? be : (this.currentObservers = null, a.push(e), new R(function() {
509
- r.currentObservers = null, F(a, e);
517
+ var r = this, s = this, i = s.hasError, o = s.isStopped, c = s.observers;
518
+ return i || o ? ve : (this.currentObservers = null, c.push(e), new x(function() {
519
+ r.currentObservers = null, D(c, e);
510
520
  }));
511
521
  }, t.prototype._checkFinalizedStatuses = function(e) {
512
522
  var r = this, s = r.hasError, i = r.thrownError, o = r.isStopped;
513
523
  s ? e.error(i) : o && e.complete();
514
524
  }, t.prototype.asObservable = function() {
515
- var e = new B();
525
+ var e = new G();
516
526
  return e.source = this, e;
517
527
  }, t.create = function(e, r) {
518
- return new ae(e, r);
528
+ return new oe(e, r);
519
529
  }, t;
520
- }(B), ae = function(n) {
521
- x(t, n);
530
+ }(G), oe = function(n) {
531
+ U(t, n);
522
532
  function t(e, r) {
523
533
  var s = n.call(this) || this;
524
534
  return s.destination = e, s.source = r, s;
@@ -534,26 +544,26 @@ var Ve = function(n) {
534
544
  (r = (e = this.destination) === null || e === void 0 ? void 0 : e.complete) === null || r === void 0 || r.call(e);
535
545
  }, t.prototype._subscribe = function(e) {
536
546
  var r, s;
537
- return (s = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(e)) !== null && s !== void 0 ? s : be;
547
+ return (s = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(e)) !== null && s !== void 0 ? s : ve;
538
548
  }, t;
539
- }(xe), Qe = {
549
+ }(Ie), Be = {
540
550
  now: function() {
541
551
  return Date.now();
542
552
  },
543
553
  delegate: void 0
544
- }, qe = function(n) {
545
- x(t, n);
554
+ }, Qe = function(n) {
555
+ U(t, n);
546
556
  function t(e, r) {
547
557
  return n.call(this) || this;
548
558
  }
549
559
  return t.prototype.schedule = function(e, r) {
550
560
  return this;
551
561
  }, t;
552
- }(R), Y = {
562
+ }(x), Y = {
553
563
  setInterval: function(n, t) {
554
564
  for (var e = [], r = 2; r < arguments.length; r++)
555
565
  e[r - 2] = arguments[r];
556
- return setInterval.apply(void 0, D([n, t], $(e)));
566
+ return setInterval.apply(void 0, k([n, t], $(e)));
557
567
  },
558
568
  clearInterval: function(n) {
559
569
  var t = Y.delegate;
@@ -561,7 +571,7 @@ var Ve = function(n) {
561
571
  },
562
572
  delegate: void 0
563
573
  }, Ge = function(n) {
564
- x(t, n);
574
+ U(t, n);
565
575
  function t(e, r) {
566
576
  var s = n.call(this, e, r) || this;
567
577
  return s.scheduler = e, s.work = r, s.pending = !1, s;
@@ -599,18 +609,18 @@ var Ve = function(n) {
599
609
  }, t.prototype.unsubscribe = function() {
600
610
  if (!this.closed) {
601
611
  var e = this, r = e.id, s = e.scheduler, i = s.actions;
602
- this.work = this.state = this.scheduler = null, this.pending = !1, F(i, this), r != null && (this.id = this.recycleAsyncId(s, r, null)), this.delay = null, n.prototype.unsubscribe.call(this);
612
+ this.work = this.state = this.scheduler = null, this.pending = !1, D(i, this), r != null && (this.id = this.recycleAsyncId(s, r, null)), this.delay = null, n.prototype.unsubscribe.call(this);
603
613
  }
604
614
  }, t;
605
- }(qe), ce = function() {
615
+ }(Qe), ce = function() {
606
616
  function n(t, e) {
607
617
  e === void 0 && (e = n.now), this.schedulerActionCtor = t, this.now = e;
608
618
  }
609
619
  return n.prototype.schedule = function(t, e, r) {
610
620
  return e === void 0 && (e = 0), new this.schedulerActionCtor(this, t).schedule(r, e);
611
- }, n.now = Qe.now, n;
612
- }(), Be = function(n) {
613
- x(t, n);
621
+ }, n.now = Be.now, n;
622
+ }(), Ye = function(n) {
623
+ U(t, n);
614
624
  function t(e, r) {
615
625
  r === void 0 && (r = ce.now);
616
626
  var s = n.call(this, e, r) || this;
@@ -634,7 +644,11 @@ var Ve = function(n) {
634
644
  throw s;
635
645
  }
636
646
  }, t;
637
- }(ce), Ye = new Be(Ge), ze = Ye, We = X(function(n) {
647
+ }(ce), ze = new Ye(Ge), Je = ze;
648
+ function We(n) {
649
+ return n && S(n.schedule);
650
+ }
651
+ var Ke = X(function(n) {
638
652
  return function() {
639
653
  n(this), this.name = "EmptyError", this.message = "no elements in sequence";
640
654
  };
@@ -642,79 +656,81 @@ var Ve = function(n) {
642
656
  function T(n, t) {
643
657
  var e = typeof t == "object";
644
658
  return new Promise(function(r, s) {
645
- var i = new H({
659
+ var i = new N({
646
660
  next: function(o) {
647
661
  r(o), i.unsubscribe();
648
662
  },
649
663
  error: s,
650
664
  complete: function() {
651
- e ? r(t.defaultValue) : s(new We());
665
+ e ? r(t.defaultValue) : s(new Ke());
652
666
  }
653
667
  });
654
668
  n.subscribe(i);
655
669
  });
656
670
  }
657
- function Ke(n) {
671
+ function Xe(n) {
658
672
  return n instanceof Date && !isNaN(n);
659
673
  }
660
- function O(n, t) {
661
- return Me(function(e, r) {
674
+ function _(n, t) {
675
+ return Ee(function(e, r) {
662
676
  var s = 0;
663
- e.subscribe(Ce(r, function(i) {
677
+ e.subscribe(Me(r, function(i) {
664
678
  r.next(n.call(t, i, s++));
665
679
  }));
666
680
  });
667
681
  }
668
- function Je(n, t, e) {
669
- return e === void 0 && (e = ze), new B(function(r) {
670
- var s = Ke(n) ? +n - e.now() : n;
671
- s < 0 && (s = 0);
672
- var i = 0;
682
+ function Ze(n, t, e) {
683
+ n === void 0 && (n = 0), e === void 0 && (e = Je);
684
+ var r = -1;
685
+ return t != null && (We(t) ? e = t : r = t), new G(function(s) {
686
+ var i = Xe(n) ? +n - e.now() : n;
687
+ i < 0 && (i = 0);
688
+ var o = 0;
673
689
  return e.schedule(function() {
674
- r.closed || (r.next(i++), r.complete());
675
- }, s);
690
+ s.closed || (s.next(o++), 0 <= r ? this.schedule(void 0, r) : s.complete());
691
+ }, i);
676
692
  });
677
693
  }
678
- function Xe(n, t, e) {
694
+ function et(n, t, e) {
679
695
  var r = S(n) || t || e ? { next: n, error: t, complete: e } : n;
680
- return r ? Me(function(s, i) {
696
+ return r ? Ee(function(s, i) {
681
697
  var o;
682
698
  (o = r.subscribe) === null || o === void 0 || o.call(r);
683
- var a = !0;
684
- s.subscribe(Ce(i, function(c) {
699
+ var c = !0;
700
+ s.subscribe(Me(i, function(a) {
685
701
  var u;
686
- (u = r.next) === null || u === void 0 || u.call(r, c), i.next(c);
702
+ (u = r.next) === null || u === void 0 || u.call(r, a), i.next(a);
687
703
  }, function() {
688
- var c;
689
- a = !1, (c = r.complete) === null || c === void 0 || c.call(r), i.complete();
690
- }, function(c) {
704
+ var a;
705
+ c = !1, (a = r.complete) === null || a === void 0 || a.call(r), i.complete();
706
+ }, function(a) {
691
707
  var u;
692
- a = !1, (u = r.error) === null || u === void 0 || u.call(r, c), i.error(c);
708
+ c = !1, (u = r.error) === null || u === void 0 || u.call(r, a), i.error(a);
693
709
  }, function() {
694
- var c, u;
695
- a && ((c = r.unsubscribe) === null || c === void 0 || c.call(r)), (u = r.finalize) === null || u === void 0 || u.call(r);
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);
696
712
  }));
697
- }) : Ee;
713
+ }) : Se;
698
714
  }
699
- 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);
715
+ var tt = Object.defineProperty, rt = (n, t, e) => t in n ? tt(n, t, { enumerable: !0, configurable: !0, writable: !0, value: e }) : n[t] = e, I = (n, t, e) => (rt(n, typeof t != "symbol" ? t + "" : t, e), e);
700
716
  class d extends Error {
701
717
  constructor(t) {
702
- super(`Incorrect context (${t}). Cannot perform the requested operation.`), C(this, "context"), this.context = t;
718
+ super(`Incorrect context (${t}). Cannot perform the requested operation.`), I(this, "context"), this.context = t;
703
719
  }
704
720
  }
705
- class I extends Error {
721
+ class y extends Error {
706
722
  constructor(t, e, r) {
707
723
  super(`Invalid parameter (${t}). ${r}`), this.param = t, this.value = e, this.reason = r;
708
724
  }
709
725
  }
710
- class tt extends Error {
726
+ class ae extends Error {
711
727
  constructor(t, e) {
712
728
  super(
713
729
  `'streamId' value of "${t}" is different from what we expected ("${e}")`
714
730
  ), this.streamId = t, this.expectedStreamId = e;
715
731
  }
716
732
  }
717
- class rt extends Error {
733
+ class nt extends Error {
718
734
  constructor(t) {
719
735
  super(`Invalid version format: ${t}`);
720
736
  }
@@ -733,12 +749,12 @@ class le extends Error {
733
749
  function E(n) {
734
750
  return typeof n == "function";
735
751
  }
736
- function nt(n) {
752
+ function st(n) {
737
753
  return E(n == null ? void 0 : n.lift);
738
754
  }
739
- function P(n) {
755
+ function R(n) {
740
756
  return function(t) {
741
- if (nt(t))
757
+ if (st(t))
742
758
  return t.lift(function(e) {
743
759
  try {
744
760
  return n(e, this);
@@ -753,7 +769,8 @@ var z = function(n, t) {
753
769
  return z = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
754
770
  e.__proto__ = r;
755
771
  } || function(e, r) {
756
- for (var s in r) Object.prototype.hasOwnProperty.call(r, s) && (e[s] = r[s]);
772
+ for (var s in r)
773
+ Object.prototype.hasOwnProperty.call(r, s) && (e[s] = r[s]);
757
774
  }, z(n, t);
758
775
  };
759
776
  function ee(n, t) {
@@ -767,43 +784,49 @@ function ee(n, t) {
767
784
  }
768
785
  function he(n) {
769
786
  var t = typeof Symbol == "function" && Symbol.iterator, e = t && n[t], r = 0;
770
- if (e) return e.call(n);
771
- if (n && typeof n.length == "number") return {
772
- next: function() {
773
- return n && r >= n.length && (n = void 0), { value: n && n[r++], done: !n };
774
- }
775
- };
787
+ if (e)
788
+ return e.call(n);
789
+ if (n && typeof n.length == "number")
790
+ return {
791
+ next: function() {
792
+ return n && r >= n.length && (n = void 0), { value: n && n[r++], done: !n };
793
+ }
794
+ };
776
795
  throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
777
796
  }
778
- function W(n, t) {
797
+ function J(n, t) {
779
798
  var e = typeof Symbol == "function" && n[Symbol.iterator];
780
- if (!e) return n;
799
+ if (!e)
800
+ return n;
781
801
  var r = e.call(n), s, i = [], o;
782
802
  try {
783
- for (; (t === void 0 || t-- > 0) && !(s = r.next()).done; ) i.push(s.value);
784
- } catch (a) {
785
- o = { error: a };
803
+ for (; (t === void 0 || t-- > 0) && !(s = r.next()).done; )
804
+ i.push(s.value);
805
+ } catch (c) {
806
+ o = { error: c };
786
807
  } finally {
787
808
  try {
788
809
  s && !s.done && (e = r.return) && e.call(r);
789
810
  } finally {
790
- if (o) throw o.error;
811
+ if (o)
812
+ throw o.error;
791
813
  }
792
814
  }
793
815
  return i;
794
816
  }
795
- function K(n, t, e) {
796
- if (arguments.length === 2) for (var r = 0, s = t.length, i; r < s; r++)
797
- (i || !(r in t)) && (i || (i = Array.prototype.slice.call(t, 0, r)), i[r] = t[r]);
817
+ function W(n, t, e) {
818
+ if (e || arguments.length === 2)
819
+ for (var r = 0, s = t.length, i; r < s; r++)
820
+ (i || !(r in t)) && (i || (i = Array.prototype.slice.call(t, 0, r)), i[r] = t[r]);
798
821
  return n.concat(i || Array.prototype.slice.call(t));
799
822
  }
800
- function st(n) {
823
+ function it(n) {
801
824
  var t = function(r) {
802
825
  Error.call(r), r.stack = new Error().stack;
803
826
  }, e = n(t);
804
827
  return e.prototype = Object.create(Error.prototype), e.prototype.constructor = e, e;
805
828
  }
806
- var j = st(function(n) {
829
+ var j = it(function(n) {
807
830
  return function(t) {
808
831
  n(this), this.message = t ? t.length + ` errors occurred during unsubscription:
809
832
  ` + t.map(function(e, r) {
@@ -830,47 +853,49 @@ var te = function() {
830
853
  if (o)
831
854
  if (this._parentage = null, Array.isArray(o))
832
855
  try {
833
- for (var a = he(o), c = a.next(); !c.done; c = a.next()) {
834
- var u = c.value;
856
+ for (var c = he(o), a = c.next(); !a.done; a = c.next()) {
857
+ var u = a.value;
835
858
  u.remove(this);
836
859
  }
837
- } catch (y) {
838
- t = { error: y };
860
+ } catch (v) {
861
+ t = { error: v };
839
862
  } finally {
840
863
  try {
841
- c && !c.done && (e = a.return) && e.call(a);
864
+ a && !a.done && (e = c.return) && e.call(c);
842
865
  } finally {
843
- if (t) throw t.error;
866
+ if (t)
867
+ throw t.error;
844
868
  }
845
869
  }
846
870
  else
847
871
  o.remove(this);
848
- var l = this.initialTeardown;
849
- if (E(l))
872
+ var h = this.initialTeardown;
873
+ if (E(h))
850
874
  try {
851
- l();
852
- } catch (y) {
853
- i = y instanceof j ? y.errors : [y];
875
+ h();
876
+ } catch (v) {
877
+ i = v instanceof j ? v.errors : [v];
854
878
  }
855
- var h = this._finalizers;
856
- if (h) {
879
+ var l = this._finalizers;
880
+ if (l) {
857
881
  this._finalizers = null;
858
882
  try {
859
- for (var b = he(h), v = b.next(); !v.done; v = b.next()) {
860
- var N = v.value;
883
+ for (var b = he(l), p = b.next(); !p.done; p = b.next()) {
884
+ var F = p.value;
861
885
  try {
862
- pe(N);
863
- } catch (y) {
864
- i = i ?? [], y instanceof j ? i = K(K([], W(i)), W(y.errors)) : i.push(y);
886
+ pe(F);
887
+ } catch (v) {
888
+ i = i ?? [], v instanceof j ? i = W(W([], J(i)), J(v.errors)) : i.push(v);
865
889
  }
866
890
  }
867
- } catch (y) {
868
- r = { error: y };
891
+ } catch (v) {
892
+ r = { error: v };
869
893
  } finally {
870
894
  try {
871
- v && !v.done && (s = b.return) && s.call(b);
895
+ p && !p.done && (s = b.return) && s.call(b);
872
896
  } finally {
873
- if (r) throw r.error;
897
+ if (r)
898
+ throw r.error;
874
899
  }
875
900
  }
876
901
  }
@@ -908,7 +933,7 @@ var te = function() {
908
933
  }(), n;
909
934
  }();
910
935
  te.EMPTY;
911
- function Ie(n) {
936
+ function Ue(n) {
912
937
  return n instanceof te || n && "closed" in n && E(n.remove) && E(n.add) && E(n.unsubscribe);
913
938
  }
914
939
  function pe(n) {
@@ -920,19 +945,19 @@ var Te = {
920
945
  Promise: void 0,
921
946
  useDeprecatedSynchronousErrorHandling: !1,
922
947
  useDeprecatedNextContext: !1
923
- }, it = {
948
+ }, ot = {
924
949
  setTimeout: function(n, t) {
925
950
  for (var e = [], r = 2; r < arguments.length; r++)
926
951
  e[r - 2] = arguments[r];
927
- return setTimeout.apply(void 0, K([n, t], W(e)));
952
+ return setTimeout.apply(void 0, W([n, t], J(e)));
928
953
  },
929
954
  clearTimeout: function(n) {
930
955
  return clearTimeout(n);
931
956
  },
932
957
  delegate: void 0
933
958
  };
934
- function ot(n) {
935
- it.setTimeout(function() {
959
+ function ct(n) {
960
+ ot.setTimeout(function() {
936
961
  throw n;
937
962
  });
938
963
  }
@@ -945,10 +970,10 @@ var re = function(n) {
945
970
  ee(t, n);
946
971
  function t(e) {
947
972
  var r = n.call(this) || this;
948
- return r.isStopped = !1, e ? (r.destination = e, Ie(e) && e.add(r)) : r.destination = ht, r;
973
+ return r.isStopped = !1, e ? (r.destination = e, Ue(e) && e.add(r)) : r.destination = dt, r;
949
974
  }
950
975
  return t.create = function(e, r, s) {
951
- return new J(e, r, s);
976
+ return new K(e, r, s);
952
977
  }, t.prototype.next = function(e) {
953
978
  this.isStopped || this._next(e);
954
979
  }, t.prototype.error = function(e) {
@@ -972,11 +997,11 @@ var re = function(n) {
972
997
  this.unsubscribe();
973
998
  }
974
999
  }, t;
975
- }(te), ct = Function.prototype.bind;
976
- function Q(n, t) {
977
- return ct.call(n, t);
1000
+ }(te), ut = Function.prototype.bind;
1001
+ function q(n, t) {
1002
+ return ut.call(n, t);
978
1003
  }
979
- var ut = function() {
1004
+ var lt = function() {
980
1005
  function n(t) {
981
1006
  this.partialObserver = t;
982
1007
  }
@@ -1007,7 +1032,7 @@ var ut = function() {
1007
1032
  L(e);
1008
1033
  }
1009
1034
  }, n;
1010
- }(), J = function(n) {
1035
+ }(), K = function(n) {
1011
1036
  ee(t, n);
1012
1037
  function t(e, r, s) {
1013
1038
  var i = n.call(this) || this, o;
@@ -1018,44 +1043,44 @@ var ut = function() {
1018
1043
  complete: s ?? void 0
1019
1044
  };
1020
1045
  else {
1021
- var a;
1022
- i && Te.useDeprecatedNextContext ? (a = Object.create(e), a.unsubscribe = function() {
1046
+ var c;
1047
+ i && Te.useDeprecatedNextContext ? (c = Object.create(e), c.unsubscribe = function() {
1023
1048
  return i.unsubscribe();
1024
1049
  }, o = {
1025
- next: e.next && Q(e.next, a),
1026
- error: e.error && Q(e.error, a),
1027
- complete: e.complete && Q(e.complete, a)
1050
+ next: e.next && q(e.next, c),
1051
+ error: e.error && q(e.error, c),
1052
+ complete: e.complete && q(e.complete, c)
1028
1053
  }) : o = e;
1029
1054
  }
1030
- return i.destination = new ut(o), i;
1055
+ return i.destination = new lt(o), i;
1031
1056
  }
1032
1057
  return t;
1033
1058
  }(re);
1034
1059
  function L(n) {
1035
- ot(n);
1060
+ ct(n);
1036
1061
  }
1037
- function lt(n) {
1062
+ function ht(n) {
1038
1063
  throw n;
1039
1064
  }
1040
- var ht = {
1065
+ var dt = {
1041
1066
  closed: !0,
1042
1067
  next: fe,
1043
- error: lt,
1068
+ error: ht,
1044
1069
  complete: fe
1045
- }, dt = function() {
1070
+ }, pt = function() {
1046
1071
  return typeof Symbol == "function" && Symbol.observable || "@@observable";
1047
1072
  }();
1048
- function Re(n) {
1073
+ function xe(n) {
1049
1074
  return n;
1050
1075
  }
1051
- function pt(n) {
1052
- return n.length === 0 ? Re : n.length === 1 ? n[0] : function(t) {
1076
+ function ft(n) {
1077
+ return n.length === 0 ? xe : n.length === 1 ? n[0] : function(t) {
1053
1078
  return n.reduce(function(e, r) {
1054
1079
  return r(e);
1055
1080
  }, t);
1056
1081
  };
1057
1082
  }
1058
- var ft = function() {
1083
+ var gt = function() {
1059
1084
  function n(t) {
1060
1085
  t && (this._subscribe = t);
1061
1086
  }
@@ -1063,10 +1088,10 @@ var ft = function() {
1063
1088
  var e = new n();
1064
1089
  return e.source = this, e.operator = t, e;
1065
1090
  }, n.prototype.subscribe = function(t, e, r) {
1066
- var s = this, i = vt(t) ? t : new J(t, e, r);
1091
+ var s = this, i = yt(t) ? t : new K(t, e, r);
1067
1092
  return at(function() {
1068
- var o = s, a = o.operator, c = o.source;
1069
- i.add(a ? a.call(i, c) : c ? s._subscribe(i) : s._trySubscribe(i));
1093
+ var o = s, c = o.operator, a = o.source;
1094
+ i.add(c ? c.call(i, a) : a ? s._subscribe(i) : s._trySubscribe(i));
1070
1095
  }), i;
1071
1096
  }, n.prototype._trySubscribe = function(t) {
1072
1097
  try {
@@ -1077,12 +1102,12 @@ var ft = function() {
1077
1102
  }, n.prototype.forEach = function(t, e) {
1078
1103
  var r = this;
1079
1104
  return e = ge(e), new e(function(s, i) {
1080
- var o = new J({
1081
- next: function(a) {
1105
+ var o = new K({
1106
+ next: function(c) {
1082
1107
  try {
1083
- t(a);
1084
- } catch (c) {
1085
- i(c), o.unsubscribe();
1108
+ t(c);
1109
+ } catch (a) {
1110
+ i(a), o.unsubscribe();
1086
1111
  }
1087
1112
  },
1088
1113
  error: i,
@@ -1093,12 +1118,12 @@ var ft = function() {
1093
1118
  }, n.prototype._subscribe = function(t) {
1094
1119
  var e;
1095
1120
  return (e = this.source) === null || e === void 0 ? void 0 : e.subscribe(t);
1096
- }, n.prototype[dt] = function() {
1121
+ }, n.prototype[pt] = function() {
1097
1122
  return this;
1098
1123
  }, n.prototype.pipe = function() {
1099
1124
  for (var t = [], e = 0; e < arguments.length; e++)
1100
1125
  t[e] = arguments[e];
1101
- return pt(t)(this);
1126
+ return ft(t)(this);
1102
1127
  }, n.prototype.toPromise = function(t) {
1103
1128
  var e = this;
1104
1129
  return t = ge(t), new t(function(r, s) {
@@ -1119,34 +1144,34 @@ function ge(n) {
1119
1144
  var t;
1120
1145
  return (t = n ?? Te.Promise) !== null && t !== void 0 ? t : Promise;
1121
1146
  }
1122
- function gt(n) {
1147
+ function mt(n) {
1123
1148
  return n && E(n.next) && E(n.error) && E(n.complete);
1124
1149
  }
1125
- function vt(n) {
1126
- return n && n instanceof re || gt(n) && Ie(n);
1150
+ function yt(n) {
1151
+ return n && n instanceof re || mt(n) && Ue(n);
1127
1152
  }
1128
- function _(n, t, e, r, s) {
1129
- return new yt(n, t, e, r, s);
1153
+ function A(n, t, e, r, s) {
1154
+ return new vt(n, t, e, r, s);
1130
1155
  }
1131
- var yt = function(n) {
1156
+ var vt = function(n) {
1132
1157
  ee(t, n);
1133
- function t(e, r, s, i, o, a) {
1134
- var c = n.call(this, e) || this;
1135
- return c.onFinalize = o, c.shouldUnsubscribe = a, c._next = r ? function(u) {
1158
+ function t(e, r, s, i, o, c) {
1159
+ var a = n.call(this, e) || this;
1160
+ return a.onFinalize = o, a.shouldUnsubscribe = c, a._next = r ? function(u) {
1136
1161
  try {
1137
1162
  r(u);
1138
- } catch (l) {
1139
- e.error(l);
1163
+ } catch (h) {
1164
+ e.error(h);
1140
1165
  }
1141
- } : n.prototype._next, c._error = i ? function(u) {
1166
+ } : n.prototype._next, a._error = i ? function(u) {
1142
1167
  try {
1143
1168
  i(u);
1144
- } catch (l) {
1145
- e.error(l);
1169
+ } catch (h) {
1170
+ e.error(h);
1146
1171
  } finally {
1147
1172
  this.unsubscribe();
1148
1173
  }
1149
- } : n.prototype._error, c._complete = s ? function() {
1174
+ } : n.prototype._error, a._complete = s ? function() {
1150
1175
  try {
1151
1176
  s();
1152
1177
  } catch (u) {
@@ -1154,7 +1179,7 @@ var yt = function(n) {
1154
1179
  } finally {
1155
1180
  this.unsubscribe();
1156
1181
  }
1157
- } : n.prototype._complete, c;
1182
+ } : n.prototype._complete, a;
1158
1183
  }
1159
1184
  return t.prototype.unsubscribe = function() {
1160
1185
  var e;
@@ -1164,90 +1189,87 @@ var yt = function(n) {
1164
1189
  }
1165
1190
  }, t;
1166
1191
  }(re);
1167
- function p(n, t) {
1168
- return P(function(e, r) {
1192
+ function f(n, t) {
1193
+ return R(function(e, r) {
1169
1194
  var s = 0;
1170
- e.subscribe(_(r, function(i) {
1195
+ e.subscribe(A(r, function(i) {
1171
1196
  r.next(n.call(t, i, s++));
1172
1197
  }));
1173
1198
  });
1174
1199
  }
1175
- var bt = new ft(function(n) {
1200
+ var bt = new gt(function(n) {
1176
1201
  return n.complete();
1177
1202
  });
1178
- function m(n) {
1203
+ function w(n) {
1179
1204
  return n <= 0 ? function() {
1180
1205
  return bt;
1181
- } : P(function(t, e) {
1206
+ } : R(function(t, e) {
1182
1207
  var r = 0;
1183
- t.subscribe(_(e, function(s) {
1208
+ t.subscribe(A(e, function(s) {
1184
1209
  ++r <= n && (e.next(s), n <= r && e.complete());
1185
1210
  }));
1186
1211
  });
1187
1212
  }
1188
- function g(n, t) {
1189
- return P(function(e, r) {
1213
+ function m(n, t) {
1214
+ return R(function(e, r) {
1190
1215
  var s = 0;
1191
- e.subscribe(_(r, function(i) {
1216
+ e.subscribe(A(r, function(i) {
1192
1217
  return n.call(t, i, s++) && r.next(i);
1193
1218
  }));
1194
1219
  });
1195
1220
  }
1196
- function mt(n, t) {
1197
- return P(function(e, r) {
1221
+ function wt(n, t) {
1222
+ return t === void 0 && (t = !1), R(function(e, r) {
1198
1223
  var s = 0;
1199
- e.subscribe(_(r, function(i) {
1224
+ e.subscribe(A(r, function(i) {
1200
1225
  var o = n(i, s++);
1201
1226
  (o || t) && r.next(i), !o && r.complete();
1202
1227
  }));
1203
1228
  });
1204
1229
  }
1205
- function f(n, t, e) {
1230
+ function g(n, t, e) {
1206
1231
  var r = E(n) || t || e ? { next: n, error: t, complete: e } : n;
1207
- return r ? P(function(s, i) {
1232
+ return r ? R(function(s, i) {
1208
1233
  var o;
1209
1234
  (o = r.subscribe) === null || o === void 0 || o.call(r);
1210
- var a = !0;
1211
- s.subscribe(_(i, function(c) {
1235
+ var c = !0;
1236
+ s.subscribe(A(i, function(a) {
1212
1237
  var u;
1213
- (u = r.next) === null || u === void 0 || u.call(r, c), i.next(c);
1238
+ (u = r.next) === null || u === void 0 || u.call(r, a), i.next(a);
1214
1239
  }, function() {
1215
- var c;
1216
- a = !1, (c = r.complete) === null || c === void 0 || c.call(r), i.complete();
1217
- }, function(c) {
1240
+ var a;
1241
+ c = !1, (a = r.complete) === null || a === void 0 || a.call(r), i.complete();
1242
+ }, function(a) {
1218
1243
  var u;
1219
- a = !1, (u = r.error) === null || u === void 0 || u.call(r, c), i.error(c);
1244
+ c = !1, (u = r.error) === null || u === void 0 || u.call(r, a), i.error(a);
1220
1245
  }, function() {
1221
- var c, u;
1222
- a && ((c = r.unsubscribe) === null || c === void 0 || c.call(r)), (u = r.finalize) === null || u === void 0 || u.call(r);
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);
1223
1248
  }));
1224
- }) : Re;
1249
+ }) : xe;
1225
1250
  }
1226
- const wt = /^(\d+)\.(\d+)$/;
1251
+ const Ct = /^(\d+)\.(\d+)$/;
1227
1252
  function St(n) {
1228
1253
  if (typeof n == "string") {
1229
- const t = n.match(wt);
1254
+ const t = n.match(Ct);
1230
1255
  if (t)
1231
1256
  return `${t[1]}.${t[2]}`;
1232
1257
  }
1233
- throw new rt(n);
1258
+ throw new nt(n);
1234
1259
  }
1235
- function ve(n) {
1260
+ function me(n) {
1236
1261
  const t = St(n), [e, r] = t.split("."), [s, i] = [parseInt(e), parseInt(r)];
1237
1262
  return [s, i];
1238
1263
  }
1239
- function ne(n, t) {
1240
- const [e, r] = ve(n), [s, i] = ve(t);
1264
+ function Re(n, t) {
1265
+ const [e, r] = me(n), [s, i] = me(t);
1241
1266
  return e < s ? -1 : e > s ? 1 : r < i ? -1 : r > i ? 1 : 0;
1242
1267
  }
1243
1268
  function Et(n, t) {
1244
- return ne(n, t) === 1;
1245
- }
1246
- function Mt(n, t) {
1247
- return ne(n, t) >= 0;
1269
+ return Re(n, t) >= 0;
1248
1270
  }
1249
1271
  const ye = "2.0";
1250
- class Ct {
1272
+ class Mt {
1251
1273
  /**
1252
1274
  * Create a new instance of the {@link IpcHelper | IPC Protocol Helper}.
1253
1275
  *
@@ -1258,7 +1280,7 @@ class Ct {
1258
1280
  * @param logService - An instance of a logging service or utility
1259
1281
  */
1260
1282
  constructor(t, e) {
1261
- 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)
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)
1262
1284
  throw new le(t, ye);
1263
1285
  this.negotiatedProtocolVersion = this.supportedVersions[0], this.embeddedResult = null, this.iframePort2 = null;
1264
1286
  }
@@ -1295,9 +1317,9 @@ class Ct {
1295
1317
  * @returns Observable with the {@link AppContext} the app is running under. Emits once.
1296
1318
  */
1297
1319
  determineContext() {
1298
- return Je(1e3).pipe(
1299
- p(() => (this.isEmbedded() ? this.currentContext = "user" : this.currentContext = "guest", this.currentContext)),
1300
- m(1)
1320
+ return Ze(1e3).pipe(
1321
+ f(() => (this.isEmbedded() ? this.currentContext = "user" : this.currentContext = "guest", this.currentContext)),
1322
+ w(1)
1301
1323
  );
1302
1324
  }
1303
1325
  /**
@@ -1312,20 +1334,20 @@ class Ct {
1312
1334
  const t = "HELLO", e = this.createMessage(t);
1313
1335
  e.protocolVersions = this.supportedVersions, this.logCreated(t, e);
1314
1336
  const r = this.incomingMessages$.pipe(
1315
- g((s) => s.type === t && s.replyTo === e.id),
1316
- p((s) => s),
1317
- f(this.logReceived()),
1318
- p((s) => {
1319
- if (this.supportedVersions.some((i) => Et(i, s.protocolVersion)))
1337
+ m((s) => s.type === t && s.replyTo === e.id),
1338
+ f((s) => s),
1339
+ g(this.logReceived()),
1340
+ f((s) => {
1341
+ if (!this.supportedVersions.includes(s.protocolVersion))
1320
1342
  throw new le(s.protocolVersion, this.supportedVersions[0]);
1321
1343
  return s.displayName || (s.displayName = s.cloudUsername), s;
1322
1344
  }),
1323
- f((s) => {
1345
+ g((s) => {
1324
1346
  this.negotiatedProtocolVersion = s.protocolVersion, this.logService.info(
1325
1347
  `[IPC] Negotiated IPC Protocol Version: ${this.negotiatedProtocolVersion}`
1326
1348
  );
1327
1349
  }),
1328
- m(1)
1350
+ w(1)
1329
1351
  );
1330
1352
  return this.logService.debug(`Created ${t} Reply handler`), this.inIframe ? this.createIframeChannel().then(() => this.finishIpcSetup(e)) : this.finishIpcSetup(e), r;
1331
1353
  }
@@ -1342,10 +1364,10 @@ class Ct {
1342
1364
  const t = "TOKEN", e = this.createMessage(t);
1343
1365
  this.logCreated(t, e);
1344
1366
  const r = this.incomingMessages$.pipe(
1345
- g((s) => s.type === t && s.replyTo === e.id),
1346
- p((s) => s),
1347
- f(this.logReceived()),
1348
- m(1)
1367
+ m((s) => s.type === t && s.replyTo === e.id),
1368
+ f((s) => s),
1369
+ g(this.logReceived()),
1370
+ w(1)
1349
1371
  );
1350
1372
  return this.logService.debug(`Created ${t} Reply handler`), this.port2.postMessage(e), this.logSent(t, e), r;
1351
1373
  }
@@ -1371,11 +1393,11 @@ class Ct {
1371
1393
  displayName: s,
1372
1394
  jwtToken: i,
1373
1395
  serverUrl: o,
1374
- region: a,
1375
- joinMicMuted: c,
1396
+ region: c,
1397
+ joinMicMuted: a,
1376
1398
  joinWithoutCamera: u
1377
- } = t, l = "JOINING ROOM", h = this.createMessage(l, !1);
1378
- 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);
1399
+ } = t, h = "JOINING ROOM", l = this.createMessage(h, !1);
1400
+ 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 = s, this.logCreated(h, l), this.port2.postMessage(l), this.logSent(h, l);
1379
1401
  }
1380
1402
  /**
1381
1403
  * Sends a {@link LeavingRoomMessage} lifecycle message to the Host app.
@@ -1425,10 +1447,10 @@ class Ct {
1425
1447
  throw new d(this.currentContext);
1426
1448
  const t = "JOIN ROOM";
1427
1449
  return this.incomingMessages$.pipe(
1428
- g((e) => e.type === t && e.target === "client"),
1429
- p((e) => e),
1430
- f(this.logReceived()),
1431
- p((e) => e)
1450
+ m((e) => e.type === t && e.target === "client"),
1451
+ f((e) => e),
1452
+ g(this.logReceived()),
1453
+ f((e) => e)
1432
1454
  );
1433
1455
  }
1434
1456
  /**
@@ -1461,10 +1483,10 @@ class Ct {
1461
1483
  throw new d(this.currentContext);
1462
1484
  const t = "LEAVE ROOM";
1463
1485
  return this.incomingMessages$.pipe(
1464
- g((e) => e.type === t && e.target === "client"),
1465
- p((e) => e),
1466
- f(this.logReceived()),
1467
- p((e) => e)
1486
+ m((e) => e.type === t && e.target === "client"),
1487
+ f((e) => e),
1488
+ g(this.logReceived()),
1489
+ f((e) => e)
1468
1490
  );
1469
1491
  }
1470
1492
  /**
@@ -1498,10 +1520,10 @@ class Ct {
1498
1520
  throw new d(this.currentContext);
1499
1521
  const t = "CONFIG";
1500
1522
  return this.incomingMessages$.pipe(
1501
- g((e) => e.type === t && e.target === "client"),
1502
- p((e) => e),
1503
- f(this.logReceived()),
1504
- p((e) => ({
1523
+ m((e) => e.type === t && e.target === "client"),
1524
+ f((e) => e),
1525
+ g(this.logReceived()),
1526
+ f((e) => ({
1505
1527
  preferredCameraType: e.preferredCameraType,
1506
1528
  preferredMicType: e.preferredMicType,
1507
1529
  preferredOutputType: e.preferredOutputType,
@@ -1521,11 +1543,11 @@ class Ct {
1521
1543
  const e = "SCREENSHARE SOURCE", r = this.createMessage(e);
1522
1544
  r.sourceTypes = t, this.logCreated(e, r);
1523
1545
  const s = this.incomingMessages$.pipe(
1524
- g((i) => i.type === e && i.replyTo === r.id),
1525
- p((i) => i),
1526
- f(this.logReceived()),
1527
- p((i) => i),
1528
- m(1)
1546
+ m((i) => i.type === e && i.replyTo === r.id),
1547
+ f((i) => i),
1548
+ g(this.logReceived()),
1549
+ f((i) => i),
1550
+ w(1)
1529
1551
  );
1530
1552
  return this.logService.debug(`Created ${e} Reply handler`), this.port2.postMessage(r), this.logSent(e, r), s;
1531
1553
  }
@@ -1535,11 +1557,11 @@ class Ct {
1535
1557
  const s = "LAYOUT CHANGE";
1536
1558
  let i, o;
1537
1559
  if (e && r ? (i = this.createMessage(s, !1, r), i.result = e) : (i = this.createMessage(s), o = this.incomingMessages$.pipe(
1538
- g((a) => a.type === s && a.replyTo === i.id),
1539
- p((a) => a),
1540
- f(this.logReceived()),
1541
- p((a) => a),
1542
- m(1)
1560
+ m((c) => c.type === s && c.replyTo === i.id),
1561
+ f((c) => c),
1562
+ g(this.logReceived()),
1563
+ f((c) => c),
1564
+ w(1)
1543
1565
  ), this.logService.debug(`Created ${s} Reply handler`)), i.layout = t, this.logCreated(s, i), this.port2.postMessage(i), this.logSent(s, i), o)
1544
1566
  return o;
1545
1567
  }
@@ -1579,10 +1601,10 @@ class Ct {
1579
1601
  throw new d(this.currentContext);
1580
1602
  const t = "LAYOUT CHANGE";
1581
1603
  return this.incomingMessages$.pipe(
1582
- g((e) => e.type === t && e.target === "client" && e.replyTo === null),
1583
- p((e) => e),
1584
- f(this.logReceived()),
1585
- p((e) => e)
1604
+ m((e) => e.type === t && e.target === "client" && e.replyTo === null),
1605
+ f((e) => e),
1606
+ g(this.logReceived()),
1607
+ f((e) => e)
1586
1608
  );
1587
1609
  }
1588
1610
  requestOAuthToken(t) {
@@ -1592,10 +1614,10 @@ class Ct {
1592
1614
  const e = "OAUTH TOKEN", r = this.createMessage(e);
1593
1615
  r.providerTypes = t, this.logCreated(e, r);
1594
1616
  const s = this.incomingMessages$.pipe(
1595
- g((i) => i.type === e && i.replyTo === r.id),
1596
- p((i) => i),
1597
- f(this.logReceived()),
1598
- m(1)
1617
+ m((i) => i.type === e && i.replyTo === r.id),
1618
+ f((i) => i),
1619
+ g(this.logReceived()),
1620
+ w(1)
1599
1621
  );
1600
1622
  return this.logService.debug(`Created ${e} Reply handler`), this.port2.postMessage(r), this.logSent(e, r), s;
1601
1623
  }
@@ -1608,59 +1630,228 @@ class Ct {
1608
1630
  selectContacts(t, e, r, s) {
1609
1631
  if (!this.isEmbedded())
1610
1632
  throw new d(this.currentContext);
1611
- if (e === "group" && s === void 0)
1612
- throw new I(
1613
- "currentContacts",
1614
- s,
1615
- "currentContacts is required for group streams"
1633
+ if (this.negotiatedProtocolVersion === "2.0") {
1634
+ if (e === void 0 || typeof e == "object")
1635
+ throw new y(
1636
+ "streamType",
1637
+ e,
1638
+ "streamType is missing or invalid"
1639
+ );
1640
+ if (r === void 0 || typeof r == "object" || typeof r == "number")
1641
+ throw new y(
1642
+ "contactType",
1643
+ r,
1644
+ "contactType is missing or invalid"
1645
+ );
1646
+ return this.selectContactsV2_0(
1647
+ t,
1648
+ e,
1649
+ r,
1650
+ s
1616
1651
  );
1617
- if (e === "direct" && s !== void 0)
1618
- throw new I(
1652
+ }
1653
+ if (typeof e < "u" && typeof e != "object")
1654
+ throw new y("options", e, "options is invalid");
1655
+ if (typeof r < "u" && !Array.isArray(r))
1656
+ throw new y(
1619
1657
  "currentContacts",
1620
- s,
1621
- "currentContacts should not be passed for direct streams"
1658
+ r,
1659
+ "currentContacts is invalid"
1622
1660
  );
1661
+ return this.selectContactsV2_1(t, e, r);
1662
+ }
1663
+ selectContactsV2_0(t, e, r, s) {
1664
+ if (!this.isEmbedded())
1665
+ throw new d(this.currentContext);
1666
+ s && s.length > 0 && (s = s.map((a) => a.type === "cloudUsername" && a.contactUser ? {
1667
+ ...a,
1668
+ cloudId: a.cloudId || a.contactUser.cloudId,
1669
+ networkId: a.networkId || a.contactUser.networkId,
1670
+ cloudUsername: a.cloudUsername || a.contactUser.cloudUsername
1671
+ } : a));
1623
1672
  const i = "SELECT CONTACTS", o = this.createMessage(i, !0);
1624
- o.streamType = e, o.streamId = t, o.contactType = r, o.currentContacts = s, this.logCreated(i, o);
1625
- const a = this.incomingMessages$.pipe(
1626
- g((c) => c.type === i && c.replyTo === o.id),
1627
- f(this.logReceived()),
1628
- // validate if `streamId` is the same as we sent
1629
- p((c) => {
1630
- const u = c;
1673
+ o.streamId = t, o.streamType = e, o.contactType = r, o.resultTypes = [r], o.currentContacts = s, this.logCreated(i, o);
1674
+ const c = this.incomingMessages$.pipe(
1675
+ m((a) => a.type === i && a.replyTo === o.id),
1676
+ g(this.logReceived()),
1677
+ f((a) => {
1678
+ const u = a;
1631
1679
  if (u.result === "success") {
1632
1680
  if (u.streamId !== t)
1633
- throw new tt(u.streamId, t);
1681
+ throw new ae(u.streamId, t);
1634
1682
  e === "direct" && u.contacts.length > 1 && (u.contacts = [u.contacts[0]]);
1635
1683
  }
1636
1684
  return u;
1637
1685
  }),
1638
- m(1)
1686
+ w(1)
1639
1687
  );
1640
- return this.logService.debug(`Created ${i} Reply handler`), this.port2.postMessage(o), this.logSent(i, o), a;
1688
+ return this.logService.debug(`Created ${i} Reply handler`), this.port2.postMessage(o), this.logSent(i, o), c;
1689
+ }
1690
+ selectContactsV2_1(t, e, r) {
1691
+ if (!this.isEmbedded())
1692
+ throw new d(this.currentContext);
1693
+ const s = {
1694
+ allowMultipleSelection: (e == null ? void 0 : e.allowMultipleSelection) ?? !1,
1695
+ resultTypes: (e == null ? void 0 : e.resultTypes) ?? ["cloudUsername"]
1696
+ };
1697
+ if (r && r.length > 0)
1698
+ for (const a of r) {
1699
+ if (a.contactId === void 0)
1700
+ throw new y(
1701
+ "currentContacts",
1702
+ r,
1703
+ "ContactItem contactId is required since v2.1 on all contacts"
1704
+ );
1705
+ if (a.type === "cloudUsername") {
1706
+ if (!a.contactUser)
1707
+ throw new y(
1708
+ "currentContacts",
1709
+ a,
1710
+ "CloudUsername contact must include contactUser since v2.1"
1711
+ );
1712
+ if (!a.contactUser.cloudId || !a.contactUser.networkId || !a.contactUser.cloudUsername)
1713
+ throw new y(
1714
+ "currentContacts",
1715
+ a,
1716
+ "CloudContact must define cloudUsername, cloudId, and networkId since v2.1"
1717
+ );
1718
+ }
1719
+ }
1720
+ const i = "SELECT CONTACTS", o = this.createMessage(i, !0);
1721
+ o.streamId = t, o.resultTypes = s.resultTypes, o.currentContacts = r, o.allowMultipleSelection = s.allowMultipleSelection, this.logCreated(i, o);
1722
+ const c = this.incomingMessages$.pipe(
1723
+ m((a) => a.type === i && a.replyTo === o.id),
1724
+ g(this.logReceived()),
1725
+ f((a) => {
1726
+ const u = a;
1727
+ if (u.result === "success") {
1728
+ if (u.streamId !== t)
1729
+ throw new ae(u.streamId, t);
1730
+ const h = u.contacts.length;
1731
+ u.contacts = u.contacts.filter(
1732
+ (l) => s.resultTypes.includes(l.type)
1733
+ ), u.contacts.length !== h && this.logService.debug(
1734
+ `[IPC] [SelectContactsReply] Filtered ${h - u.contacts.length} contacts from reply`
1735
+ ), !s.allowMultipleSelection && u.contacts.length > 1 && (u.contacts = [u.contacts[0]]);
1736
+ for (const l of u.contacts)
1737
+ if (l.type === "cloudUsername") {
1738
+ if (!l.contactUser)
1739
+ throw new Error(
1740
+ `CloudUsername contact must include contactUser since v2.1. ContactItem: ${JSON.stringify(
1741
+ l
1742
+ )}`
1743
+ );
1744
+ if (!l.contactUser.cloudId || !l.contactUser.networkId || !l.contactUser.cloudUsername)
1745
+ throw new Error(
1746
+ `CloudContact must define cloudUsername, cloudId, and networkId since v2.1. ContactItem: ${JSON.stringify(
1747
+ l
1748
+ )}`
1749
+ );
1750
+ }
1751
+ }
1752
+ return u;
1753
+ }),
1754
+ w(1)
1755
+ );
1756
+ return this.logService.debug(`Created ${i} Reply handler`), this.port2.postMessage(o), this.logSent(i, o), c;
1641
1757
  }
1642
- /**
1643
- * Request detailed contact information for the given Cloud usernames.
1644
- *
1645
- * @param contacts - Cloud usernames for which we need detailed contact information
1646
- *
1647
- * @returns Observable with a {@link MatchContactsMessageReply} instance containing the requested
1648
- * {@link ContactItem} information. Emits once.
1649
- */
1650
1758
  matchContacts(t) {
1651
1759
  if (!this.isEmbedded())
1652
1760
  throw new d(this.currentContext);
1761
+ if (!Array.isArray(t))
1762
+ throw new y("contacts", t, "contacts is not an array");
1653
1763
  if (!t.length)
1654
- throw new I("contacts", t, "At least one contact is required");
1655
- const e = "MATCH CONTACTS", r = this.createMessage(e);
1656
- r.contacts = [...t], this.logCreated(e, r);
1657
- const s = this.incomingMessages$.pipe(
1658
- g((i) => i.type === e && i.replyTo === r.id),
1659
- f(this.logReceived()),
1660
- p((i) => i),
1661
- m(1)
1764
+ throw new y("contacts", t, "At least one contact is required");
1765
+ const e = this.createMessage("MATCH CONTACTS");
1766
+ if (this.compareVersion("2.1") >= 0) {
1767
+ for (const s of t)
1768
+ if (s.type === "cloudUsername") {
1769
+ if (!s.contactUser)
1770
+ throw new y(
1771
+ "contacts",
1772
+ s,
1773
+ "CloudUsername contact must include contactUser"
1774
+ );
1775
+ if (!s.contactUser.cloudUsername || !s.contactUser.cloudId || !s.contactUser.networkId)
1776
+ throw new y(
1777
+ "contacts",
1778
+ s,
1779
+ "CloudContact must define cloudUsername, cloudId, and networkId"
1780
+ );
1781
+ }
1782
+ e.contacts = [...t];
1783
+ } else {
1784
+ for (const s of t)
1785
+ s.type === "cloudUsername" && s.contactUser && (s.cloudId = s.contactUser.cloudId, s.networkId = s.contactUser.networkId, s.cloudUsername = s.contactUser.cloudUsername);
1786
+ e.contacts = [...t];
1787
+ }
1788
+ this.logCreated(e.type, e);
1789
+ const r = this.incomingMessages$.pipe(
1790
+ m((s) => s.type === e.type && s.replyTo === e.id),
1791
+ g(this.logReceived()),
1792
+ f((s) => {
1793
+ const i = s;
1794
+ if (this.compareVersion("2.1") >= 0) {
1795
+ if (Array.isArray(i.contacts))
1796
+ throw new Error(
1797
+ "MatchContactsMessageReply should return a Record<string, DetailedContactItem> of contacts when using IPC Protocol v2.1+"
1798
+ );
1799
+ for (const [o, c] of Object.entries(i.contacts)) {
1800
+ if (c == null) {
1801
+ this.logService.debug(
1802
+ `[IPC] [MatchContactsReply] Received null or undefined contact for ${o}`
1803
+ );
1804
+ continue;
1805
+ }
1806
+ if (c.contactId === void 0)
1807
+ throw new Error(
1808
+ `ContactItem 'contactId' is required since v2.1. ContactItem: ${JSON.stringify(
1809
+ c
1810
+ )}`
1811
+ );
1812
+ if (!c.contactUser && (!c.uri || c.uri.length === 0) && (!c.numbers || c.numbers.length === 0))
1813
+ throw new Error(
1814
+ `DetailedContactItem must define at least one contact method (contactUser, uri, or numbers). ContactItem: ${JSON.stringify(
1815
+ c
1816
+ )}`
1817
+ );
1818
+ if (c.contactUser && (!c.contactUser.cloudId || !c.contactUser.networkId || !c.contactUser.cloudUsername))
1819
+ throw new Error(
1820
+ `When contactUser is defined, cloudId, networkId, and cloudUsername must also be defined. ContactItem: ${JSON.stringify(
1821
+ c
1822
+ )}`
1823
+ );
1824
+ }
1825
+ } else {
1826
+ if (!Array.isArray(i.contacts))
1827
+ throw new Error(
1828
+ "MatchContactsMessageReply should return an array of contacts when using IPC Protocol v2.0"
1829
+ );
1830
+ if (i.contacts.length !== e.contacts.length)
1831
+ throw new Error(
1832
+ "The number of contacts in the reply does not match the number of contacts in the request"
1833
+ );
1834
+ for (const o of i.contacts) {
1835
+ const c = o;
1836
+ if (c.type === "cloudUsername" && !("cloudUsername" in c))
1837
+ throw new Error(
1838
+ `CloudUsernameDetailedContactItem must define cloudUsername. ContactItem: ${JSON.stringify(
1839
+ o
1840
+ )}`
1841
+ );
1842
+ if (c.type === "uri" && (!("uri" in c) || !Array.isArray(c.uri)))
1843
+ throw new Error(
1844
+ `UriDetailedContactItem must define uri as an array. ContactItem: ${JSON.stringify(
1845
+ o
1846
+ )}`
1847
+ );
1848
+ }
1849
+ }
1850
+ return i;
1851
+ }),
1852
+ w(1)
1662
1853
  );
1663
- return this.logService.debug(`Created ${e} Reply handler`), this.port2.postMessage(r), this.logSent(e, r), s;
1854
+ return this.logService.debug(`Created ${e.type} Reply handler`), this.port2.postMessage(e), this.logSent(e.type, e), r;
1664
1855
  }
1665
1856
  /**
1666
1857
  * Setup listener for {@link PushMessageMessage}, which can be sent by a Host app to forward an
@@ -1693,9 +1884,9 @@ class Ct {
1693
1884
  throw new d(this.currentContext);
1694
1885
  const t = "PUSH MESSAGE";
1695
1886
  return this.incomingMessages$.pipe(
1696
- g((e) => e.type === t && e.target === "client"),
1697
- p((e) => e),
1698
- f(this.logReceived())
1887
+ m((e) => e.type === t && e.target === "client"),
1888
+ f((e) => e),
1889
+ g(this.logReceived())
1699
1890
  );
1700
1891
  }
1701
1892
  /**
@@ -1713,10 +1904,10 @@ class Ct {
1713
1904
  const t = "PUSH TOKEN", e = this.createMessage(t);
1714
1905
  this.logCreated(t, e);
1715
1906
  const r = this.incomingMessages$.pipe(
1716
- g((s) => s.type === t && s.replyTo === e.id),
1717
- f(this.logReceived()),
1718
- p((s) => s),
1719
- m(1)
1907
+ m((s) => s.type === t && s.replyTo === e.id),
1908
+ g(this.logReceived()),
1909
+ f((s) => s),
1910
+ w(1)
1720
1911
  );
1721
1912
  return this.logService.debug(`Created ${t} Reply handler`), this.port2.postMessage(e), this.logSent(t, e), r;
1722
1913
  }
@@ -1752,16 +1943,16 @@ class Ct {
1752
1943
  throw new d(this.currentContext);
1753
1944
  const t = "PUSH TOKEN";
1754
1945
  return this.incomingMessages$.pipe(
1755
- g(
1946
+ m(
1756
1947
  (e) => e.type === t && e.target === "client" && e.replyTo === null && e.expectReply === !1
1757
1948
  ),
1758
- p((e) => {
1949
+ f((e) => {
1759
1950
  if (e.pushToken && e.selector && e.appId)
1760
1951
  return e;
1761
1952
  throw new Error("PushTokenMessage is missing required PushTokenPayload fields");
1762
1953
  }),
1763
- f((e) => e.pushToken),
1764
- f(this.logReceived())
1954
+ g((e) => e.pushToken),
1955
+ g(this.logReceived())
1765
1956
  );
1766
1957
  }
1767
1958
  /**
@@ -1776,9 +1967,9 @@ class Ct {
1776
1967
  throw new d(this.currentContext);
1777
1968
  const t = "BADGE QUERY";
1778
1969
  return this.incomingMessages$.pipe(
1779
- g((e) => e.type === t && e.target === "client"),
1780
- p((e) => e),
1781
- f(this.logReceived())
1970
+ m((e) => e.type === t && e.target === "client"),
1971
+ f((e) => e),
1972
+ g(this.logReceived())
1782
1973
  );
1783
1974
  }
1784
1975
  /**
@@ -1834,9 +2025,9 @@ class Ct {
1834
2025
  throw new d(this.currentContext);
1835
2026
  const t = "LIFECYCLE";
1836
2027
  return this.incomingMessages$.pipe(
1837
- g((e) => e.type === t && e.target === "client"),
1838
- p((e) => e),
1839
- f(this.logReceived())
2028
+ m((e) => e.type === t && e.target === "client"),
2029
+ f((e) => e),
2030
+ g(this.logReceived())
1840
2031
  );
1841
2032
  }
1842
2033
  /**
@@ -1874,9 +2065,9 @@ class Ct {
1874
2065
  throw new d(this.currentContext);
1875
2066
  const t = "REQUEST LOGS";
1876
2067
  return this.incomingMessages$.pipe(
1877
- g((e) => e.type === t && e.target === "client"),
1878
- p((e) => e),
1879
- f(this.logReceived())
2068
+ m((e) => e.type === t && e.target === "client"),
2069
+ f((e) => e),
2070
+ g(this.logReceived())
1880
2071
  );
1881
2072
  }
1882
2073
  /**
@@ -1892,8 +2083,8 @@ class Ct {
1892
2083
  sendRequestLogsMessageReply(t, e, r, s, i) {
1893
2084
  if (!this.isEmbedded())
1894
2085
  throw new d(this.currentContext);
1895
- const o = "REQUEST LOGS", a = this.createMessage(o, !1, i);
1896
- a.fileId = t, a.fileHash = e, a.fileSize = r, a.format = s, this.logCreated(o, a), this.port2.postMessage(a), this.logSent(o, a);
2086
+ const o = "REQUEST LOGS", c = this.createMessage(o, !1, i);
2087
+ c.fileId = t, c.fileHash = e, c.fileSize = r, c.format = s, this.logCreated(o, c), this.port2.postMessage(c), this.logSent(o, c);
1897
2088
  }
1898
2089
  /**
1899
2090
  * Send a {@link ViewTransitionMessage} to the `Host` app, notifying it of a view transition
@@ -1958,28 +2149,28 @@ class Ct {
1958
2149
  sendFileRequestMessage(t, e, r, s, i) {
1959
2150
  if (!this.isEmbedded())
1960
2151
  throw new d(this.currentContext);
1961
- const o = "FILE REQUEST", a = this.createMessage(o);
1962
- if (a.fileId = t, a.fileHash = e.toLowerCase(), a.intent = r, a.maxChunkSizeInBytes = i, r === "attachment") {
2152
+ const o = "FILE REQUEST", c = this.createMessage(o);
2153
+ if (c.fileId = t, c.fileHash = e.toLowerCase(), c.intent = r, c.maxChunkSizeInBytes = i, r === "attachment") {
1963
2154
  if (!s)
1964
- throw new I(
2155
+ throw new y(
1965
2156
  "streamId",
1966
2157
  s,
1967
2158
  "streamId is required for attachment intent"
1968
2159
  );
1969
- a.streamId = s;
2160
+ c.streamId = s;
1970
2161
  }
1971
- this.logCreated(o, a);
1972
- let c = 0;
2162
+ this.logCreated(o, c);
2163
+ let a = 0;
1973
2164
  const u = this.incomingMessages$.pipe(
1974
- g(
1975
- (l) => l.type === o && l.replyTo === a.id
2165
+ m(
2166
+ (h) => h.type === o && h.replyTo === c.id
1976
2167
  ),
1977
- f(this.logReceived()),
1978
- f(() => c++),
1979
- p((l) => (l.result === "success" && (l.chunkHash = l.chunkHash.toLowerCase(), l.fileHash = l.fileHash.toLowerCase()), l)),
1980
- mt((l) => l.result === "success" && c < l.totalChunks, !0)
2168
+ g(this.logReceived()),
2169
+ g(() => a++),
2170
+ f((h) => (h.result === "success" && (h.chunkHash = h.chunkHash.toLowerCase(), h.fileHash = h.fileHash.toLowerCase()), h)),
2171
+ wt((h) => h.result === "success" && a < h.totalChunks, !0)
1981
2172
  );
1982
- return this.port2.postMessage(a), this.logSent(o, a), u;
2173
+ return this.port2.postMessage(c), this.logSent(o, c), u;
1983
2174
  }
1984
2175
  /**
1985
2176
  * Sends a {@link FileRequestMessageReply} to the Host app, to reply to a
@@ -2026,11 +2217,11 @@ class Ct {
2026
2217
  throw new d(this.currentContext);
2027
2218
  const t = "FILE REQUEST";
2028
2219
  return this.incomingMessages$.pipe(
2029
- g(
2220
+ m(
2030
2221
  (e) => e.type === t && e.target === "client" && e.replyTo === null
2031
2222
  ),
2032
- p((e) => (e.fileHash = e.fileHash.toLowerCase(), e)),
2033
- f(this.logReceived())
2223
+ f((e) => (e.fileHash = e.fileHash.toLowerCase(), e)),
2224
+ g(this.logReceived())
2034
2225
  );
2035
2226
  }
2036
2227
  /**
@@ -2058,35 +2249,35 @@ class Ct {
2058
2249
  sendFileSelectionMessage(t = "attachment", e, r, s, i, o) {
2059
2250
  if (!this.isEmbedded())
2060
2251
  throw new d(this.currentContext);
2061
- const a = "FILE SELECTION", c = this.createMessage(a);
2062
- if (c.intent = t, c.maxCount = s, c.maxFileSizeInBytes = i, c.mimeTypes = o, t === "attachment") {
2252
+ const c = "FILE SELECTION", a = this.createMessage(c);
2253
+ if (a.intent = t, a.maxCount = s, a.maxFileSizeInBytes = i, a.mimeTypes = o, t === "attachment") {
2063
2254
  if (!e)
2064
- throw new I(
2255
+ throw new y(
2065
2256
  "streamId",
2066
2257
  e,
2067
2258
  "streamId is required for attachment intent"
2068
2259
  );
2069
2260
  if (!r)
2070
- throw new I(
2261
+ throw new y(
2071
2262
  "correlationId",
2072
2263
  r,
2073
2264
  "correlationId is required for attachment intent"
2074
2265
  );
2075
- c.streamId = e, c.correlationId = r;
2266
+ a.streamId = e, a.correlationId = r;
2076
2267
  }
2077
- this.logCreated(a, c);
2268
+ this.logCreated(c, a);
2078
2269
  const u = this.incomingMessages$.pipe(
2079
- g(
2080
- (l) => l.type === a && l.replyTo === c.id
2270
+ m(
2271
+ (h) => h.type === c && h.replyTo === a.id
2081
2272
  ),
2082
- p((l) => {
2083
- var h;
2084
- 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;
2273
+ f((h) => {
2274
+ var l;
2275
+ 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;
2085
2276
  }),
2086
- f(this.logReceived()),
2087
- m(1)
2277
+ g(this.logReceived()),
2278
+ w(1)
2088
2279
  );
2089
- return this.port2.postMessage(c), this.logSent(a, c), u;
2280
+ return this.port2.postMessage(a), this.logSent(c, a), u;
2090
2281
  }
2091
2282
  /**
2092
2283
  * Sends a {@link FileDownloadProgressQueryMessage} to the Host app, to query the progress of a
@@ -2116,12 +2307,12 @@ class Ct {
2116
2307
  );
2117
2308
  i.fileHash = t.toLowerCase(), i.url = e, i.correlationId = r, this.logCreated(s, i);
2118
2309
  const o = this.incomingMessages$.pipe(
2119
- g(
2120
- (a) => a.type === "FILE DOWNLOAD PROGRESS UPDATE" && a.replyTo === i.id
2310
+ m(
2311
+ (c) => c.type === "FILE DOWNLOAD PROGRESS UPDATE" && c.replyTo === i.id
2121
2312
  ),
2122
- f((a) => this.logReceived(a)),
2123
- p((a) => (a.fileHash && (a.fileHash = a.fileHash.toLowerCase()), a)),
2124
- m(1)
2313
+ g((c) => this.logReceived(c)),
2314
+ f((c) => (c.fileHash && (c.fileHash = c.fileHash.toLowerCase()), c)),
2315
+ w(1)
2125
2316
  );
2126
2317
  return this.port2.postMessage(i), this.logSent(s, i), o;
2127
2318
  }
@@ -2137,11 +2328,11 @@ class Ct {
2137
2328
  throw new d(this.currentContext);
2138
2329
  const t = "FILE DOWNLOAD PROGRESS UPDATE";
2139
2330
  return this.incomingMessages$.pipe(
2140
- g(
2331
+ m(
2141
2332
  (e) => e.type === t && e.target === "client" && e.replyTo === null
2142
2333
  ),
2143
- p((e) => (e.fileHash && (e.fileHash = e.fileHash.toLowerCase()), e)),
2144
- f(this.logReceived())
2334
+ f((e) => (e.fileHash && (e.fileHash = e.fileHash.toLowerCase()), e)),
2335
+ g(this.logReceived())
2145
2336
  );
2146
2337
  }
2147
2338
  /**
@@ -2167,12 +2358,12 @@ class Ct {
2167
2358
  );
2168
2359
  i.fileHash = t.toLowerCase(), i.fileId = e, i.correlationId = r, this.logCreated(s, i);
2169
2360
  const o = this.incomingMessages$.pipe(
2170
- g(
2171
- (a) => a.type === "FILE UPLOAD PROGRESS UPDATE" && a.replyTo === i.id
2361
+ m(
2362
+ (c) => c.type === "FILE UPLOAD PROGRESS UPDATE" && c.replyTo === i.id
2172
2363
  ),
2173
- f(this.logReceived()),
2174
- p((a) => (a.fileHash && (a.fileHash = a.fileHash.toLowerCase()), a)),
2175
- m(1)
2364
+ g(this.logReceived()),
2365
+ f((c) => (c.fileHash && (c.fileHash = c.fileHash.toLowerCase()), c)),
2366
+ w(1)
2176
2367
  );
2177
2368
  return this.port2.postMessage(i), this.logSent(s, i), o;
2178
2369
  }
@@ -2192,11 +2383,11 @@ class Ct {
2192
2383
  throw new d(this.currentContext);
2193
2384
  const t = "FILE UPLOAD PROGRESS UPDATE";
2194
2385
  return this.incomingMessages$.pipe(
2195
- g(
2386
+ m(
2196
2387
  (e) => e.type === t && e.target === "client" && e.replyTo === null
2197
2388
  ),
2198
- p((e) => (e.fileHash && (e.fileHash = e.fileHash.toLowerCase()), e)),
2199
- f(this.logReceived())
2389
+ f((e) => (e.fileHash && (e.fileHash = e.fileHash.toLowerCase()), e)),
2390
+ g(this.logReceived())
2200
2391
  );
2201
2392
  }
2202
2393
  /**
@@ -2224,18 +2415,39 @@ class Ct {
2224
2415
  * @returns An observable which emits a {@link FileDownloadMessageReply} instance containing the
2225
2416
  * result of the request. Emits once.
2226
2417
  */
2227
- sendFileDownloadMessage(t, e, r, s, i, o, a, c, u) {
2418
+ sendFileDownloadMessage(t, e, r, s, i, o, c, a, u) {
2228
2419
  if (!this.isEmbedded())
2229
2420
  throw new d(this.currentContext);
2230
- const l = "FILE DOWNLOAD", h = this.createMessage(l, !0);
2231
- 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);
2421
+ if (a && this.compareVersion("2.1") < 0)
2422
+ a.type === "cloudUsername" && a.contactUser && (a = {
2423
+ ...a,
2424
+ cloudId: a.cloudId || a.contactUser.cloudId,
2425
+ networkId: a.networkId || a.contactUser.networkId,
2426
+ cloudUsername: a.cloudUsername || a.contactUser.cloudUsername
2427
+ });
2428
+ else if (a && this.compareVersion("2.1") >= 0 && a.type === "cloudUsername") {
2429
+ if (!a.contactUser)
2430
+ throw new y(
2431
+ "sender",
2432
+ a,
2433
+ "CloudUsername contact must include contactUser since v2.1"
2434
+ );
2435
+ if (!a.contactUser.cloudId || !a.contactUser.networkId || !a.contactUser.cloudUsername)
2436
+ throw new y(
2437
+ "sender",
2438
+ a,
2439
+ "CloudContact must define cloudUsername, cloudId, and networkId since v2.1"
2440
+ );
2441
+ }
2442
+ const h = "FILE DOWNLOAD", l = this.createMessage(h, !0);
2443
+ l.url = t, l.key = e, l.fileHash = r.toLowerCase(), l.mimeType = s, l.fileName = i, l.streamId = o, l.correlationId = c, l.sender = a, l.intent = u ?? "download", this.logCreated(h, l);
2232
2444
  const b = this.incomingMessages$.pipe(
2233
- g((v) => v.type === l && v.replyTo === h.id),
2234
- f(this.logReceived()),
2235
- p((v) => v),
2236
- m(1)
2445
+ m((p) => p.type === h && p.replyTo === l.id),
2446
+ g(this.logReceived()),
2447
+ f((p) => p),
2448
+ w(1)
2237
2449
  );
2238
- return this.port2.postMessage(h), this.logSent(l, h), b;
2450
+ return this.port2.postMessage(l), this.logSent(h, l), b;
2239
2451
  }
2240
2452
  /**
2241
2453
  * Sends a {@link CancelFileDownloadMessage} to the Host app, to cancel downloading of a file
@@ -2272,10 +2484,10 @@ class Ct {
2272
2484
  const r = "FILE REMOVE", s = this.createMessage(r, !0);
2273
2485
  s.hash = t.toLowerCase(), s.streamId = e, this.logCreated(r, s);
2274
2486
  const i = this.incomingMessages$.pipe(
2275
- g((o) => o.type === r && o.replyTo === s.id),
2276
- f(this.logReceived()),
2277
- p((o) => o),
2278
- m(1)
2487
+ m((o) => o.type === r && o.replyTo === s.id),
2488
+ g(this.logReceived()),
2489
+ f((o) => o),
2490
+ w(1)
2279
2491
  );
2280
2492
  return this.port2.postMessage(s), this.logSent(r, s), i;
2281
2493
  }
@@ -2340,18 +2552,45 @@ class Ct {
2340
2552
  * @returns An observable which emits a {@link SendMessageMessageReply} instance containing the
2341
2553
  * result of the request. Emits once.
2342
2554
  */
2343
- sendSendMessageMessage(t, e, r, s = "TEXT", i, o, a, c = !0, u) {
2555
+ sendSendMessageMessage(t, e, r, s = "TEXT", i, o, c, a = !0, u) {
2344
2556
  if (!this.isEmbedded())
2345
2557
  throw new d(this.currentContext);
2346
- const l = "SEND MESSAGE", h = this.createMessage(l, !0);
2347
- 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);
2558
+ const h = "SEND MESSAGE", l = this.createMessage(h, !0);
2559
+ if (l.streamId = t, l.correlationId = e, l.body = r, l.messageType = s, i && i.length > 0)
2560
+ if (this.compareVersion("2.1") < 0)
2561
+ l.mentions = i.map((p) => p.contactUser ? {
2562
+ ...p,
2563
+ cloudId: p.cloudId || p.contactUser.cloudId,
2564
+ networkId: p.networkId || p.contactUser.networkId,
2565
+ cloudUsername: p.cloudUsername || p.contactUser.cloudUsername
2566
+ } : p);
2567
+ else {
2568
+ for (const p of i) {
2569
+ if (p.type === "cloudUsername" && !p.contactUser)
2570
+ throw new y(
2571
+ "mentions",
2572
+ p,
2573
+ "CloudUsername mention must include contactUser"
2574
+ );
2575
+ if (p.contactUser && (!p.contactUser.cloudId || !p.contactUser.networkId || !p.contactUser.cloudUsername))
2576
+ throw new y(
2577
+ "mentions",
2578
+ p,
2579
+ "CloudContact must define cloudUsername, cloudId, and networkId"
2580
+ );
2581
+ }
2582
+ l.mentions = i;
2583
+ }
2584
+ else
2585
+ l.mentions = [];
2586
+ l.attachments = (o == null ? void 0 : o.map((p) => p.toLowerCase())) ?? [], l.relatedMessageId = c, l.setCursors = a, l.threadId = u, this.logCreated(h, l);
2348
2587
  const b = this.incomingMessages$.pipe(
2349
- g((v) => v.type === l && v.replyTo === h.id),
2350
- f(this.logReceived()),
2351
- p((v) => v),
2352
- m(1)
2588
+ m((p) => p.type === h && p.replyTo === l.id),
2589
+ g(this.logReceived()),
2590
+ f((p) => p),
2591
+ w(1)
2353
2592
  );
2354
- return this.port2.postMessage(h), this.logSent(l, h), b;
2593
+ return this.port2.postMessage(l), this.logSent(h, l), b;
2355
2594
  }
2356
2595
  /**
2357
2596
  * Sends a {@link CancelSendMessageMessage} to the Host app, to cancel a message that was being
@@ -2400,12 +2639,12 @@ class Ct {
2400
2639
  const r = "SEND MESSAGE STATUS QUERY", s = this.createMessage(r, !0);
2401
2640
  s.correlationId = t, s.streamId = e, this.logCreated(r, s);
2402
2641
  const i = this.incomingMessages$.pipe(
2403
- g(
2642
+ m(
2404
2643
  (o) => o.type === "SEND MESSAGE STATUS UPDATE" && o.replyTo === s.id
2405
2644
  ),
2406
- f(this.logReceived()),
2407
- p((o) => o),
2408
- m(1)
2645
+ g(this.logReceived()),
2646
+ f((o) => o),
2647
+ w(1)
2409
2648
  );
2410
2649
  return this.port2.postMessage(s), this.logSent(r, s), i;
2411
2650
  }
@@ -2421,23 +2660,105 @@ class Ct {
2421
2660
  throw new d(this.currentContext);
2422
2661
  const t = "SEND MESSAGE STATUS UPDATE";
2423
2662
  return this.incomingMessages$.pipe(
2424
- g((e) => e.type === t && e.target === "client" && e.replyTo === null),
2425
- p((e) => e),
2426
- f(this.logReceived())
2663
+ m((e) => e.type === t && e.target === "client" && e.replyTo === null),
2664
+ f((e) => e),
2665
+ g(this.logReceived())
2427
2666
  );
2428
2667
  }
2429
2668
  /**
2430
- * Sends a {@link SipCallMessage} to the Host app to initiate a SIP call between the current user
2431
- * and the callee.
2669
+ * Send a SIP call message to the Host app.
2670
+ *
2671
+ * @remarks
2672
+ * This message is used to initiate a SIP call to the specified contact.
2432
2673
  *
2433
2674
  * @param contact - The {@link ContactItem} for the callee.
2434
2675
  */
2435
2676
  sendSipCallMessage(t) {
2436
2677
  if (!this.isEmbedded())
2437
2678
  throw new d(this.currentContext);
2679
+ if (this.compareVersion("2.1") < 0)
2680
+ t.type === "cloudUsername" && t.contactUser && (t = {
2681
+ ...t,
2682
+ cloudId: t.cloudId || t.contactUser.cloudId,
2683
+ networkId: t.networkId || t.contactUser.networkId,
2684
+ cloudUsername: t.cloudUsername || t.contactUser.cloudUsername
2685
+ });
2686
+ else if (t.type === "cloudUsername") {
2687
+ if (!t.contactUser)
2688
+ throw new y(
2689
+ "contact",
2690
+ t,
2691
+ "CloudUsername contact must include contactUser since v2.1"
2692
+ );
2693
+ if (!t.contactUser.cloudId || !t.contactUser.networkId || !t.contactUser.cloudUsername)
2694
+ throw new y(
2695
+ "contact",
2696
+ t,
2697
+ "CloudContact must define cloudUsername, cloudId, and networkId since v2.1"
2698
+ );
2699
+ }
2438
2700
  const e = "SIP CALL", r = this.createMessage(e, !1);
2439
2701
  r.contact = t, this.logCreated(e, r), this.port2.postMessage(r), this.logSent(e, r);
2440
2702
  }
2703
+ sendCustomFunctionMessage(t, e) {
2704
+ if (!this.isEmbedded())
2705
+ throw new d(this.currentContext);
2706
+ const r = "CUSTOM FUNCTION", s = this.createMessage(r, !1);
2707
+ s.customFunctionId = t, s.context = e, this.logCreated(r, s), this.port2.postMessage(s), this.logSent(r, s);
2708
+ }
2709
+ /**
2710
+ * Sends a {@link SubscribeButtonsMessage} to the Host app to subscribe to button updates for
2711
+ * specific locations.
2712
+ *
2713
+ * @remarks
2714
+ * The host will respond with BUTTONS messages containing the current button configurations
2715
+ * for the subscribed locations.
2716
+ *
2717
+ * @param subscribe - Subscription configuration for different button locations
2718
+ *
2719
+ * @returns This method returns void.
2720
+ */
2721
+ sendSubscribeButtonsMessage(t) {
2722
+ if (!this.isEmbedded())
2723
+ throw new d(this.currentContext);
2724
+ const e = "SUBSCRIBE BUTTONS", r = this.createMessage(e, !1);
2725
+ r.subscribe = t, this.logCreated(e, r), this.port2.postMessage(r), this.logSent(e, r);
2726
+ }
2727
+ /**
2728
+ * Setup listener for {@link ButtonsMessage}, which can be sent by a Host app to provide button
2729
+ * configurations for subscribed locations.
2730
+ *
2731
+ * @remarks
2732
+ * This message is sent in response to a SUBSCRIBE BUTTONS message or when button configurations
2733
+ * change for subscribed locations.
2734
+ *
2735
+ * @example
2736
+ * Here is an example of how a listener can be setup:
2737
+ *
2738
+ * ```ts
2739
+ * const ipcHelper = new IpcHelper(['2.2'], console);
2740
+ *
2741
+ * const buttonsSubscription = ipcHelper.onButtonsMessage().subscribe((msg) => {
2742
+ * // your logic for handling the button configurations goes here
2743
+ * });
2744
+ *
2745
+ * // don't forget to unsubscribe when you're cleaning up
2746
+ * buttonsSubscription.unsubscribe();
2747
+ * ```
2748
+ *
2749
+ * @returns An Observable that emits whenever {@link ButtonsMessage} is received so it can be
2750
+ * subscribed to indefinitely.
2751
+ */
2752
+ onButtonsMessage() {
2753
+ if (!this.isEmbedded())
2754
+ throw new d(this.currentContext);
2755
+ const t = "BUTTONS";
2756
+ return this.incomingMessages$.pipe(
2757
+ m((e) => e.type === t && e.target === "client"),
2758
+ f((e) => e),
2759
+ g(this.logReceived())
2760
+ );
2761
+ }
2441
2762
  /**
2442
2763
  * Checks if the client app is either embedded in an iframe or in a native webview.
2443
2764
  *
@@ -2475,7 +2796,7 @@ class Ct {
2475
2796
  * version.
2476
2797
  */
2477
2798
  compareVersion(t) {
2478
- return ne(this.negotiatedProtocolVersion, t);
2799
+ return Re(this.negotiatedProtocolVersion, t);
2479
2800
  }
2480
2801
  logReceived(t) {
2481
2802
  const e = (r) => this.logService.debug(
@@ -2483,7 +2804,7 @@ class Ct {
2483
2804
  r
2484
2805
  );
2485
2806
  if (t) {
2486
- xt(t) && (t = { ...t, data: "..." }), e(t);
2807
+ It(t) && (t = { ...t, data: "..." }), e(t);
2487
2808
  return;
2488
2809
  } else
2489
2810
  return e;
@@ -2527,11 +2848,11 @@ class Ct {
2527
2848
  return s.join("");
2528
2849
  }
2529
2850
  }
2530
- function xt(n) {
2851
+ function It(n) {
2531
2852
  return n.type === "FILE REQUEST" && n.replyTo !== null;
2532
2853
  }
2533
- const It = ["2.0"];
2534
- class Rt {
2854
+ const Ut = ["2.0", "2.1"];
2855
+ class xt {
2535
2856
  /**
2536
2857
  * A class that manages the IPC communication between the `Client` and the `Host`.
2537
2858
  *
@@ -2562,7 +2883,7 @@ class Rt {
2562
2883
  M(this, "logger");
2563
2884
  M(this, "helper");
2564
2885
  M(this, "listeners");
2565
- this.logger = t ?? console, this.helper = new Ct(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());
2886
+ this.logger = t ?? console, this.helper = new Mt(Ut, this.logger), this.listeners = /* @__PURE__ */ new Map(), this.listeners.set(C.BadgeQuery, /* @__PURE__ */ new Set()), this.listeners.set(C.Lifecycle, /* @__PURE__ */ new Set()), this.listeners.set(C.PushToken, /* @__PURE__ */ new Set()), this.listeners.set(C.RequestLogs, /* @__PURE__ */ new Set());
2566
2887
  }
2567
2888
  /**
2568
2889
  * Returns whether the app is running inside a native WebView (`host` context) or as a
@@ -2600,25 +2921,31 @@ class Rt {
2600
2921
  initiateConnection() {
2601
2922
  return T(
2602
2923
  this.helper.openBridge().pipe(
2603
- Xe((t) => {
2924
+ et((t) => {
2604
2925
  this.helper.onBadgeQueryMessage().subscribe((e) => {
2605
2926
  var r;
2606
2927
  this.logger.debug("Received Badge Query: ", e);
2607
- for (const s of ((r = this.listeners.get(w.BadgeQuery)) == null ? void 0 : r.values()) ?? [])
2928
+ for (const s of ((r = this.listeners.get(C.BadgeQuery)) == null ? void 0 : r.values()) ?? [])
2608
2929
  s();
2609
2930
  }), this.helper.onLifecycleMessage().subscribe((e) => {
2610
2931
  var r;
2611
2932
  this.logger.debug("Received Lifecycle Event: ", e);
2612
- for (const s of ((r = this.listeners.get(w.Lifecycle)) == null ? void 0 : r.values()) ?? [])
2933
+ for (const s of ((r = this.listeners.get(C.Lifecycle)) == null ? void 0 : r.values()) ?? [])
2613
2934
  s(e.eventName, e.payload);
2614
2935
  }), this.helper.onPushTokenMessage().subscribe((e) => {
2615
2936
  var r;
2616
2937
  this.logger.debug("Received Push Token: ", e);
2617
- for (const s of ((r = this.listeners.get(w.PushToken)) == null ? void 0 : r.values()) ?? [])
2938
+ for (const s of ((r = this.listeners.get(C.PushToken)) == null ? void 0 : r.values()) ?? [])
2618
2939
  s(e.pushToken, e.appId, e.selector);
2940
+ }), this.helper.onRequestLogsMessage().subscribe((e) => {
2941
+ var r;
2942
+ if (this.logger.debug("Received Request Logs Message: ", e), e.responseType === "file")
2943
+ throw this.logger.error("File response type not supported"), new Error("File response type not supported");
2944
+ for (const s of ((r = this.listeners.get(C.RequestLogs)) == null ? void 0 : r.values()) ?? [])
2945
+ s(e.skipCompression);
2619
2946
  }), this.cloudId = t.cloudId, this.cloudUsername = t.cloudUsername, this.displayName = t.displayName, this.host = t.host;
2620
2947
  }),
2621
- O(() => {
2948
+ _(() => {
2622
2949
  })
2623
2950
  )
2624
2951
  );
@@ -2626,30 +2953,68 @@ class Rt {
2626
2953
  selectContacts(t, e, r, s) {
2627
2954
  this.logger.debug("Selecting Contacts: ", ...arguments);
2628
2955
  let i;
2629
- if (e === "multi") {
2956
+ if (this.negotiatedVersion === "2.0") {
2957
+ if (typeof e != "string")
2958
+ throw new y("mode", e, 'mode must be "single" or "multi"');
2959
+ if (s === "number")
2960
+ throw new y(
2961
+ "contactType",
2962
+ s,
2963
+ 'contactType cannot be "number" for version 2.0 of the IPC protocol'
2964
+ );
2965
+ i = this.selectContacts_V2_0(
2966
+ t,
2967
+ e ?? "single",
2968
+ e === "multi" ? r : void 0,
2969
+ e === "multi" ? s : r
2970
+ );
2971
+ } else {
2972
+ if (typeof e != "object")
2973
+ throw new y("options", e, "options must be an object");
2974
+ i = this.selectContacts_V2_1(t, e);
2975
+ }
2976
+ return T(
2977
+ i.pipe(
2978
+ _((o) => o.result === "error" ? {
2979
+ result: "error",
2980
+ errorMessage: o.errorMessage
2981
+ } : o.result === "cancelled" ? {
2982
+ result: "cancelled"
2983
+ } : o.contacts)
2984
+ )
2985
+ );
2986
+ }
2987
+ selectContacts_V2_0(t, e, r, s) {
2988
+ if (this.logger.debug("Selecting Contacts: ", ...arguments), e === "multi") {
2630
2989
  if (!r || !Array.isArray(r))
2631
- throw new I(
2990
+ throw new y(
2632
2991
  "currentContacts",
2633
2992
  r,
2634
2993
  "currentContacts is required for group streams"
2635
2994
  );
2636
- s || (s = "cloudUsername"), i = this.helper.selectContacts(
2995
+ return s || (s = "cloudUsername"), this.helper.selectContacts(
2637
2996
  t.toString(),
2638
2997
  "group",
2639
2998
  s,
2640
2999
  r
2641
3000
  );
2642
3001
  } else
2643
- r ? s = r : s = "cloudUsername", i = this.helper.selectContacts(t.toString(), "direct", s);
2644
- return T(
2645
- i.pipe(
2646
- O((o) => o.result === "error" ? {
2647
- result: "error",
2648
- errorMessage: o.errorMessage
2649
- } : o.result === "cancelled" ? {
2650
- result: "cancelled"
2651
- } : o.contacts)
2652
- )
3002
+ return s || (s = "cloudUsername"), this.helper.selectContacts(t.toString(), "direct", s);
3003
+ }
3004
+ selectContacts_V2_1(t, e) {
3005
+ if (this.logger.debug("Selecting Contacts: ", e), e.mode === "multi" && (!e.currentContacts || !Array.isArray(e.currentContacts)))
3006
+ throw new y(
3007
+ "currentContacts",
3008
+ e.currentContacts,
3009
+ "currentContacts is required for group streams"
3010
+ );
3011
+ return this.helper.selectContacts(
3012
+ t.toString(),
3013
+ {
3014
+ allowMultipleSelection: e.mode === "multi",
3015
+ resultTypes: e.resultTypes ?? ["cloudUsername"]
3016
+ },
3017
+ e.mode === "multi" ? e.currentContacts : void 0
2653
3018
  );
2654
3019
  }
2655
3020
  /**
@@ -2662,7 +3027,7 @@ class Rt {
2662
3027
  * Host's contact list.
2663
3028
  */
2664
3029
  matchContacts(t) {
2665
- return this.logger.debug("Match Contacts: ", t), T(this.helper.matchContacts(t).pipe(O((e) => e.contacts)));
3030
+ return this.logger.debug("Match Contacts: ", t), T(this.helper.matchContacts(t).pipe(_((e) => e.contacts)));
2666
3031
  }
2667
3032
  /**
2668
3033
  * Requests the `Host` app to provide the Push Token for the current device.
@@ -2670,7 +3035,7 @@ class Rt {
2670
3035
  * @returns A promise with the Push Token as `string`.
2671
3036
  */
2672
3037
  requestPushToken() {
2673
- return this.logger.debug("Requesting Push Token"), T(this.helper.requestPushToken().pipe(O((t) => t.pushToken)));
3038
+ return this.logger.debug("Requesting Push Token"), T(this.helper.requestPushToken().pipe(_((t) => t.pushToken)));
2674
3039
  }
2675
3040
  /**
2676
3041
  * Sends the current badge count to the `Host` app.
@@ -2697,6 +3062,25 @@ class Rt {
2697
3062
  * @remarks
2698
3063
  * Any additional data to be posted alongside the URL is included with the `data` parameter.
2699
3064
  *
3065
+ * @example
3066
+ *
3067
+ * ```ts
3068
+ * // import the IPCManager
3069
+ * import { IPCManager } from '@acrobits/ipc-sdk';
3070
+ *
3071
+ * // create an instance of IPCManager
3072
+ * const manager = new IPCManager();
3073
+ *
3074
+ * // open the URL with additional data
3075
+ * const url = 'https://example.com';
3076
+ * const data = {
3077
+ * name: 'John Doe',
3078
+ * age: 30
3079
+ * };
3080
+ *
3081
+ * manager.openUrl(url, data);
3082
+ * ```
3083
+ *
2700
3084
  * @param url - URL to open in the external browser
2701
3085
  * @param data - _Optional_. Any additional data to be sent along with the URL
2702
3086
  */
@@ -2720,9 +3104,9 @@ class Rt {
2720
3104
  */
2721
3105
  onBadgeQueryRequest(t) {
2722
3106
  var e;
2723
- return this.logger.debug("Registering for Badge Query"), (e = this.listeners.get(w.BadgeQuery)) == null || e.add(t), () => {
3107
+ return this.logger.debug("Registering for Badge Query"), (e = this.listeners.get(C.BadgeQuery)) == null || e.add(t), () => {
2724
3108
  var r;
2725
- return (r = this.listeners.get(w.BadgeQuery)) == null ? void 0 : r.delete(t);
3109
+ return (r = this.listeners.get(C.BadgeQuery)) == null ? void 0 : r.delete(t);
2726
3110
  };
2727
3111
  }
2728
3112
  /**
@@ -2739,9 +3123,9 @@ class Rt {
2739
3123
  */
2740
3124
  onLifecycleEvent(t) {
2741
3125
  var e;
2742
- return this.logger.debug("Registering for Lifecycle Event"), (e = this.listeners.get(w.Lifecycle)) == null || e.add(t), () => {
3126
+ return this.logger.debug("Registering for Lifecycle Event"), (e = this.listeners.get(C.Lifecycle)) == null || e.add(t), () => {
2743
3127
  var r;
2744
- return (r = this.listeners.get(w.Lifecycle)) == null ? void 0 : r.delete(t);
3128
+ return (r = this.listeners.get(C.Lifecycle)) == null ? void 0 : r.delete(t);
2745
3129
  };
2746
3130
  }
2747
3131
  /**
@@ -2757,9 +3141,31 @@ class Rt {
2757
3141
  */
2758
3142
  onPushToken(t) {
2759
3143
  var e;
2760
- return this.logger.debug("Registering for Push Token"), (e = this.listeners.get(w.PushToken)) == null || e.add(t), () => {
3144
+ return this.logger.debug("Registering for Push Token"), (e = this.listeners.get(C.PushToken)) == null || e.add(t), () => {
3145
+ var r;
3146
+ return (r = this.listeners.get(C.PushToken)) == null ? void 0 : r.delete(t);
3147
+ };
3148
+ }
3149
+ /**
3150
+ * Registers a callback to be invoked when a {@link IPCEvents.RequestLogs} event is received.
3151
+ *
3152
+ * @remarks
3153
+ * The Host app can request logs from the Client app by sending a RequestLogs event. The callback
3154
+ * will receive a skipCompression parameter indicating whether the logs should be compressed or not.
3155
+ *
3156
+ * When skipCompression is true, the logs should be sent uncompressed. When false or undefined,
3157
+ * the logs should be compressed before sending.
3158
+ *
3159
+ * @param callback - A callback function to be invoked when a {@link IPCEvents.RequestLogs} event
3160
+ * is received. The callback receives an optional skipCompression parameter.
3161
+ *
3162
+ * @returns An unsubscribe callback to remove the listener.
3163
+ */
3164
+ onRequestLogsMessage(t) {
3165
+ var e;
3166
+ return this.logger.debug("Registering for Request Logs Message"), (e = this.listeners.get(C.RequestLogs)) == null || e.add(t), () => {
2761
3167
  var r;
2762
- return (r = this.listeners.get(w.PushToken)) == null ? void 0 : r.delete(t);
3168
+ return (r = this.listeners.get(C.RequestLogs)) == null ? void 0 : r.delete(t);
2763
3169
  };
2764
3170
  }
2765
3171
  evaluateContext(t) {
@@ -2770,6 +3176,6 @@ class Rt {
2770
3176
  }
2771
3177
  }
2772
3178
  export {
2773
- w as IPCEvents,
2774
- Rt as IPCManager
3179
+ C as IPCEvents,
3180
+ xt as IPCManager
2775
3181
  };