@asgard-js/core 0.0.5 → 0.0.6

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,14 +1,14 @@
1
- var Le = Object.defineProperty;
2
- var $e = (t, r, e) => r in t ? Le(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
3
- var m = (t, r, e) => $e(t, typeof r != "symbol" ? r + "" : r, e);
4
- var H = /* @__PURE__ */ ((t) => (t.RESET_CHANNEL = "RESET_CHANNEL", t.NONE = "NONE", t))(H || {}), O = /* @__PURE__ */ ((t) => (t.INIT = "asgard.run.init", t.MESSAGE_START = "asgard.message.start", t.MESSAGE_DELTA = "asgard.message.delta", t.MESSAGE_COMPLETE = "asgard.message.complete", t.DONE = "asgard.run.done", t))(O || {}), Re = /* @__PURE__ */ ((t) => (t.TEXT = "TEXT", t.HINT = "HINT", t.BUTTON = "BUTTON", t.IMAGE = "IMAGE", t.VIDEO = "VIDEO", t.AUDIO = "AUDIO", t.LOCATION = "LOCATION", t.CAROUSEL = "CAROUSEL", t))(Re || {}), q = function(t, r) {
1
+ var je = Object.defineProperty;
2
+ var Le = (t, r, e) => r in t ? je(t, r, { enumerable: !0, configurable: !0, writable: !0, value: e }) : t[r] = e;
3
+ var b = (t, r, e) => Le(t, typeof r != "symbol" ? r + "" : r, e);
4
+ var H = /* @__PURE__ */ ((t) => (t.RESET_CHANNEL = "RESET_CHANNEL", t.NONE = "NONE", t))(H || {}), g = /* @__PURE__ */ ((t) => (t.INIT = "asgard.run.init", t.MESSAGE_START = "asgard.message.start", t.MESSAGE_DELTA = "asgard.message.delta", t.MESSAGE_COMPLETE = "asgard.message.complete", t.DONE = "asgard.run.done", t.ERROR = "asgard.run.error", t))(g || {}), Ue = /* @__PURE__ */ ((t) => (t.TEXT = "TEXT", t.HINT = "HINT", t.BUTTON = "BUTTON", t.IMAGE = "IMAGE", t.VIDEO = "VIDEO", t.AUDIO = "AUDIO", t.LOCATION = "LOCATION", t.CAROUSEL = "CAROUSEL", t))(Ue || {}), q = function(t, r) {
5
5
  return q = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, n) {
6
6
  e.__proto__ = n;
7
7
  } || function(e, n) {
8
8
  for (var i in n) Object.prototype.hasOwnProperty.call(n, i) && (e[i] = n[i]);
9
9
  }, q(t, r);
10
10
  };
11
- function E(t, r) {
11
+ function I(t, r) {
12
12
  if (typeof r != "function" && r !== null)
13
13
  throw new TypeError("Class extends value " + String(r) + " is not a constructor or null");
14
14
  q(t, r);
@@ -17,7 +17,7 @@ function E(t, r) {
17
17
  }
18
18
  t.prototype = r === null ? Object.create(r) : (e.prototype = r.prototype, new e());
19
19
  }
20
- function Ue(t, r, e, n) {
20
+ function $e(t, r, e, n) {
21
21
  function i(o) {
22
22
  return o instanceof e ? o : new e(function(s) {
23
23
  s(o);
@@ -152,8 +152,8 @@ function Ne(t, r, e) {
152
152
  }
153
153
  function c(l, v) {
154
154
  n[l] && (i[l] = function(h) {
155
- return new Promise(function(g, w) {
156
- o.push([l, h, g, w]) > 1 || u(l, h);
155
+ return new Promise(function(w, S) {
156
+ o.push([l, h, w, S]) > 1 || u(l, h);
157
157
  });
158
158
  }, v && (i[l] = v(i[l])));
159
159
  }
@@ -214,13 +214,13 @@ var K = ce(function(t) {
214
214
  `) : "", this.name = "UnsubscriptionError", this.errors = e;
215
215
  };
216
216
  });
217
- function R(t, r) {
217
+ function U(t, r) {
218
218
  if (t) {
219
219
  var e = t.indexOf(r);
220
220
  0 <= e && t.splice(e, 1);
221
221
  }
222
222
  }
223
- var j = function() {
223
+ var R = function() {
224
224
  function t(r) {
225
225
  this.initialTeardown = r, this.closed = !1, this._parentage = null, this._finalizers = null;
226
226
  }
@@ -300,17 +300,17 @@ var j = function() {
300
300
  this._parentage = Array.isArray(e) ? (e.push(r), e) : e ? [e, r] : r;
301
301
  }, t.prototype._removeParent = function(r) {
302
302
  var e = this._parentage;
303
- e === r ? this._parentage = null : Array.isArray(e) && R(e, r);
303
+ e === r ? this._parentage = null : Array.isArray(e) && U(e, r);
304
304
  }, t.prototype.remove = function(r) {
305
305
  var e = this._finalizers;
306
- e && R(e, r), r instanceof t && r._removeParent(this);
306
+ e && U(e, r), r instanceof t && r._removeParent(this);
307
307
  }, t.EMPTY = function() {
308
308
  var r = new t();
309
309
  return r.closed = !0, r;
310
310
  }(), t;
311
- }(), le = j.EMPTY;
311
+ }(), le = R.EMPTY;
312
312
  function fe(t) {
313
- return t instanceof j || t && "closed" in t && y(t.remove) && y(t.add) && y(t.unsubscribe);
313
+ return t instanceof R || t && "closed" in t && y(t.remove) && y(t.add) && y(t.unsubscribe);
314
314
  }
315
315
  function Z(t) {
316
316
  y(t) ? t() : t.unsubscribe();
@@ -335,11 +335,11 @@ function he(t) {
335
335
  }
336
336
  function B() {
337
337
  }
338
- function $(t) {
338
+ function L(t) {
339
339
  t();
340
340
  }
341
341
  var J = function(t) {
342
- E(r, t);
342
+ I(r, t);
343
343
  function r(e) {
344
344
  var n = t.call(this) || this;
345
345
  return n.isStopped = !1, e ? (n.destination = e, fe(e) && e.add(n)) : n.destination = qe, n;
@@ -369,7 +369,7 @@ var J = function(t) {
369
369
  this.unsubscribe();
370
370
  }
371
371
  }, r;
372
- }(j), Ke = function() {
372
+ }(R), Ke = function() {
373
373
  function t(r) {
374
374
  this.partialObserver = r;
375
375
  }
@@ -379,7 +379,7 @@ var J = function(t) {
379
379
  try {
380
380
  e.next(r);
381
381
  } catch (n) {
382
- L(n);
382
+ j(n);
383
383
  }
384
384
  }, t.prototype.error = function(r) {
385
385
  var e = this.partialObserver;
@@ -387,21 +387,21 @@ var J = function(t) {
387
387
  try {
388
388
  e.error(r);
389
389
  } catch (n) {
390
- L(n);
390
+ j(n);
391
391
  }
392
392
  else
393
- L(r);
393
+ j(r);
394
394
  }, t.prototype.complete = function() {
395
395
  var r = this.partialObserver;
396
396
  if (r.complete)
397
397
  try {
398
398
  r.complete();
399
399
  } catch (e) {
400
- L(e);
400
+ j(e);
401
401
  }
402
402
  }, t;
403
403
  }(), Y = function(t) {
404
- E(r, t);
404
+ I(r, t);
405
405
  function r(e, n, i) {
406
406
  var o = t.call(this) || this, s;
407
407
  return y(e) || !e ? s = {
@@ -412,7 +412,7 @@ var J = function(t) {
412
412
  }
413
413
  return r;
414
414
  }(J);
415
- function L(t) {
415
+ function j(t) {
416
416
  he(t);
417
417
  }
418
418
  function He(t) {
@@ -436,7 +436,7 @@ function Be(t) {
436
436
  }, e);
437
437
  };
438
438
  }
439
- var b = function() {
439
+ var m = function() {
440
440
  function t(r) {
441
441
  r && (this._subscribe = r);
442
442
  }
@@ -445,7 +445,7 @@ var b = function() {
445
445
  return e.source = this, e.operator = r, e;
446
446
  }, t.prototype.subscribe = function(r, e, n) {
447
447
  var i = this, o = We(r) ? r : new Y(r, e, n);
448
- return $(function() {
448
+ return L(function() {
449
449
  var s = i, c = s.operator, u = s.source;
450
450
  o.add(c ? c.call(o, u) : u ? i._subscribe(o) : i._trySubscribe(o));
451
451
  }), o;
@@ -522,11 +522,11 @@ function C(t) {
522
522
  throw new TypeError("Unable to lift unknown Observable type");
523
523
  };
524
524
  }
525
- function S(t, r, e, n, i) {
525
+ function E(t, r, e, n, i) {
526
526
  return new Xe(t, r, e, n, i);
527
527
  }
528
528
  var Xe = function(t) {
529
- E(r, t);
529
+ I(r, t);
530
530
  function r(e, n, i, o, s, c) {
531
531
  var u = t.call(this, e) || this;
532
532
  return u.onFinalize = s, u.shouldUnsubscribe = c, u._next = n ? function(a) {
@@ -565,7 +565,7 @@ var Xe = function(t) {
565
565
  t(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
566
566
  };
567
567
  }), z = function(t) {
568
- E(r, t);
568
+ I(r, t);
569
569
  function r() {
570
570
  var e = t.call(this) || this;
571
571
  return e.closed = !1, e.currentObservers = null, e.observers = [], e.isStopped = !1, e.hasError = !1, e.thrownError = null, e;
@@ -578,7 +578,7 @@ var Xe = function(t) {
578
578
  throw new ze();
579
579
  }, r.prototype.next = function(e) {
580
580
  var n = this;
581
- $(function() {
581
+ L(function() {
582
582
  var i, o;
583
583
  if (n._throwIfClosed(), !n.isStopped) {
584
584
  n.currentObservers || (n.currentObservers = Array.from(n.observers));
@@ -600,7 +600,7 @@ var Xe = function(t) {
600
600
  });
601
601
  }, r.prototype.error = function(e) {
602
602
  var n = this;
603
- $(function() {
603
+ L(function() {
604
604
  if (n._throwIfClosed(), !n.isStopped) {
605
605
  n.hasError = n.isStopped = !0, n.thrownError = e;
606
606
  for (var i = n.observers; i.length; )
@@ -609,7 +609,7 @@ var Xe = function(t) {
609
609
  });
610
610
  }, r.prototype.complete = function() {
611
611
  var e = this;
612
- $(function() {
612
+ L(function() {
613
613
  if (e._throwIfClosed(), !e.isStopped) {
614
614
  e.isStopped = !0;
615
615
  for (var n = e.observers; n.length; )
@@ -631,20 +631,20 @@ var Xe = function(t) {
631
631
  return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
632
632
  }, r.prototype._innerSubscribe = function(e) {
633
633
  var n = this, i = this, o = i.hasError, s = i.isStopped, c = i.observers;
634
- return o || s ? le : (this.currentObservers = null, c.push(e), new j(function() {
635
- n.currentObservers = null, R(c, e);
634
+ return o || s ? le : (this.currentObservers = null, c.push(e), new R(function() {
635
+ n.currentObservers = null, U(c, e);
636
636
  }));
637
637
  }, r.prototype._checkFinalizedStatuses = function(e) {
638
638
  var n = this, i = n.hasError, o = n.thrownError, s = n.isStopped;
639
639
  i ? e.error(o) : s && e.complete();
640
640
  }, r.prototype.asObservable = function() {
641
- var e = new b();
641
+ var e = new m();
642
642
  return e.source = this, e;
643
643
  }, r.create = function(e, n) {
644
644
  return new te(e, n);
645
645
  }, r;
646
- }(b), te = function(t) {
647
- E(r, t);
646
+ }(m), te = function(t) {
647
+ I(r, t);
648
648
  function r(e, n) {
649
649
  var i = t.call(this) || this;
650
650
  return i.destination = e, i.source = n, i;
@@ -663,7 +663,7 @@ var Xe = function(t) {
663
663
  return (i = (n = this.source) === null || n === void 0 ? void 0 : n.subscribe(e)) !== null && i !== void 0 ? i : le;
664
664
  }, r;
665
665
  }(z), re = function(t) {
666
- E(r, t);
666
+ I(r, t);
667
667
  function r(e) {
668
668
  var n = t.call(this) || this;
669
669
  return n._value = e, n;
@@ -690,14 +690,14 @@ var Xe = function(t) {
690
690
  return Date.now();
691
691
  }
692
692
  }, Ze = function(t) {
693
- E(r, t);
693
+ I(r, t);
694
694
  function r(e, n) {
695
695
  return t.call(this) || this;
696
696
  }
697
697
  return r.prototype.schedule = function(e, n) {
698
698
  return this;
699
699
  }, r;
700
- }(j), ne = {
700
+ }(R), ne = {
701
701
  setInterval: function(t, r) {
702
702
  for (var e = [], n = 2; n < arguments.length; n++)
703
703
  e[n - 2] = arguments[n];
@@ -708,7 +708,7 @@ var Xe = function(t) {
708
708
  },
709
709
  delegate: void 0
710
710
  }, et = function(t) {
711
- E(r, t);
711
+ I(r, t);
712
712
  function r(e, n) {
713
713
  var i = t.call(this, e, n) || this;
714
714
  return i.scheduler = e, i.work = n, i.pending = !1, i;
@@ -746,7 +746,7 @@ var Xe = function(t) {
746
746
  }, r.prototype.unsubscribe = function() {
747
747
  if (!this.closed) {
748
748
  var e = this, n = e.id, i = e.scheduler, o = i.actions;
749
- this.work = this.state = this.scheduler = null, this.pending = !1, R(o, this), n != null && (this.id = this.recycleAsyncId(i, n, null)), this.delay = null, t.prototype.unsubscribe.call(this);
749
+ this.work = this.state = this.scheduler = null, this.pending = !1, U(o, this), n != null && (this.id = this.recycleAsyncId(i, n, null)), this.delay = null, t.prototype.unsubscribe.call(this);
750
750
  }
751
751
  }, r;
752
752
  }(Ze), ie = function() {
@@ -757,7 +757,7 @@ var Xe = function(t) {
757
757
  return e === void 0 && (e = 0), new this.schedulerActionCtor(this, r).schedule(n, e);
758
758
  }, t.now = Qe.now, t;
759
759
  }(), tt = function(t) {
760
- E(r, t);
760
+ I(r, t);
761
761
  function r(e, n) {
762
762
  n === void 0 && (n = ie.now);
763
763
  var i = t.call(this, e, n) || this;
@@ -781,7 +781,7 @@ var Xe = function(t) {
781
781
  throw i;
782
782
  }
783
783
  }, r;
784
- }(ie), de = new tt(et), rt = de, nt = new b(function(t) {
784
+ }(ie), de = new tt(et), rt = de, nt = new m(function(t) {
785
785
  return t.complete();
786
786
  });
787
787
  function ve(t) {
@@ -849,11 +849,11 @@ function Oe(t) {
849
849
  });
850
850
  });
851
851
  }
852
- function Ae(t) {
852
+ function xe(t) {
853
853
  return y(t == null ? void 0 : t.getReader);
854
854
  }
855
- function x(t) {
856
- if (t instanceof b)
855
+ function A(t) {
856
+ if (t instanceof m)
857
857
  return t;
858
858
  if (t != null) {
859
859
  if (ge(t))
@@ -863,16 +863,16 @@ function x(t) {
863
863
  if (me(t))
864
864
  return ut(t);
865
865
  if (we(t))
866
- return xe(t);
866
+ return Ae(t);
867
867
  if (Ie(t))
868
868
  return ct(t);
869
- if (Ae(t))
869
+ if (xe(t))
870
870
  return lt(t);
871
871
  }
872
872
  throw Se(t);
873
873
  }
874
874
  function st(t) {
875
- return new b(function(r) {
875
+ return new m(function(r) {
876
876
  var e = t[X]();
877
877
  if (y(e.subscribe))
878
878
  return e.subscribe(r);
@@ -880,14 +880,14 @@ function st(t) {
880
880
  });
881
881
  }
882
882
  function at(t) {
883
- return new b(function(r) {
883
+ return new m(function(r) {
884
884
  for (var e = 0; e < t.length && !r.closed; e++)
885
885
  r.next(t[e]);
886
886
  r.complete();
887
887
  });
888
888
  }
889
889
  function ut(t) {
890
- return new b(function(r) {
890
+ return new m(function(r) {
891
891
  t.then(function(e) {
892
892
  r.closed || (r.next(e), r.complete());
893
893
  }, function(e) {
@@ -896,7 +896,7 @@ function ut(t) {
896
896
  });
897
897
  }
898
898
  function ct(t) {
899
- return new b(function(r) {
899
+ return new m(function(r) {
900
900
  var e, n;
901
901
  try {
902
902
  for (var i = P(t), o = i.next(); !o.done; o = i.next()) {
@@ -916,19 +916,19 @@ function ct(t) {
916
916
  r.complete();
917
917
  });
918
918
  }
919
- function xe(t) {
920
- return new b(function(r) {
919
+ function Ae(t) {
920
+ return new m(function(r) {
921
921
  ft(t, r).catch(function(e) {
922
922
  return r.error(e);
923
923
  });
924
924
  });
925
925
  }
926
926
  function lt(t) {
927
- return xe(Oe(t));
927
+ return Ae(Oe(t));
928
928
  }
929
929
  function ft(t, r) {
930
930
  var e, n, i, o;
931
- return Ue(this, void 0, void 0, function() {
931
+ return $e(this, void 0, void 0, function() {
932
932
  var s, c;
933
933
  return ue(this, function(u) {
934
934
  switch (u.label) {
@@ -964,7 +964,7 @@ function ft(t, r) {
964
964
  });
965
965
  });
966
966
  }
967
- function A(t, r, e, n, i) {
967
+ function x(t, r, e, n, i) {
968
968
  n === void 0 && (n = 0), i === void 0 && (i = !1);
969
969
  var o = r.schedule(function() {
970
970
  e(), i ? t.add(this.schedule(null, n)) : this.unsubscribe();
@@ -974,16 +974,16 @@ function A(t, r, e, n, i) {
974
974
  }
975
975
  function _e(t, r) {
976
976
  return r === void 0 && (r = 0), C(function(e, n) {
977
- e.subscribe(S(n, function(i) {
978
- return A(n, t, function() {
977
+ e.subscribe(E(n, function(i) {
978
+ return x(n, t, function() {
979
979
  return n.next(i);
980
980
  }, r);
981
981
  }, function() {
982
- return A(n, t, function() {
982
+ return x(n, t, function() {
983
983
  return n.complete();
984
984
  }, r);
985
985
  }, function(i) {
986
- return A(n, t, function() {
986
+ return x(n, t, function() {
987
987
  return n.error(i);
988
988
  }, r);
989
989
  }));
@@ -997,13 +997,13 @@ function Ce(t, r) {
997
997
  });
998
998
  }
999
999
  function ht(t, r) {
1000
- return x(t).pipe(Ce(r), _e(r));
1000
+ return A(t).pipe(Ce(r), _e(r));
1001
1001
  }
1002
1002
  function dt(t, r) {
1003
- return x(t).pipe(Ce(r), _e(r));
1003
+ return A(t).pipe(Ce(r), _e(r));
1004
1004
  }
1005
1005
  function vt(t, r) {
1006
- return new b(function(e) {
1006
+ return new m(function(e) {
1007
1007
  var n = 0;
1008
1008
  return r.schedule(function() {
1009
1009
  n === t.length ? e.complete() : (e.next(t[n++]), e.closed || this.schedule());
@@ -1011,10 +1011,10 @@ function vt(t, r) {
1011
1011
  });
1012
1012
  }
1013
1013
  function yt(t, r) {
1014
- return new b(function(e) {
1014
+ return new m(function(e) {
1015
1015
  var n;
1016
- return A(e, r, function() {
1017
- n = t[Ee](), A(e, r, function() {
1016
+ return x(e, r, function() {
1017
+ n = t[Ee](), x(e, r, function() {
1018
1018
  var i, o, s;
1019
1019
  try {
1020
1020
  i = n.next(), o = i.value, s = i.done;
@@ -1032,10 +1032,10 @@ function yt(t, r) {
1032
1032
  function Te(t, r) {
1033
1033
  if (!t)
1034
1034
  throw new Error("Iterable cannot be null");
1035
- return new b(function(e) {
1036
- A(e, r, function() {
1035
+ return new m(function(e) {
1036
+ x(e, r, function() {
1037
1037
  var n = t[Symbol.asyncIterator]();
1038
- A(e, r, function() {
1038
+ x(e, r, function() {
1039
1039
  n.next().then(function(i) {
1040
1040
  i.done ? e.complete() : e.next(i.value);
1041
1041
  });
@@ -1058,13 +1058,13 @@ function bt(t, r) {
1058
1058
  return Te(t, r);
1059
1059
  if (Ie(t))
1060
1060
  return yt(t, r);
1061
- if (Ae(t))
1061
+ if (xe(t))
1062
1062
  return pt(t, r);
1063
1063
  }
1064
1064
  throw Se(t);
1065
1065
  }
1066
1066
  function Q(t, r) {
1067
- return r ? bt(t, r) : x(t);
1067
+ return r ? bt(t, r) : A(t);
1068
1068
  }
1069
1069
  function mt() {
1070
1070
  for (var t = [], r = 0; r < arguments.length; r++)
@@ -1078,7 +1078,7 @@ function gt(t) {
1078
1078
  function G(t, r) {
1079
1079
  return C(function(e, n) {
1080
1080
  var i = 0;
1081
- e.subscribe(S(n, function(o) {
1081
+ e.subscribe(E(n, function(o) {
1082
1082
  n.next(t.call(r, o, i++));
1083
1083
  }));
1084
1084
  });
@@ -1092,14 +1092,14 @@ function Et(t) {
1092
1092
  return St(t, r);
1093
1093
  });
1094
1094
  }
1095
- var It = Array.isArray, Ot = Object.getPrototypeOf, At = Object.prototype, xt = Object.keys;
1095
+ var It = Array.isArray, Ot = Object.getPrototypeOf, xt = Object.prototype, At = Object.keys;
1096
1096
  function _t(t) {
1097
1097
  if (t.length === 1) {
1098
1098
  var r = t[0];
1099
1099
  if (It(r))
1100
1100
  return { args: r, keys: null };
1101
1101
  if (Ct(r)) {
1102
- var e = xt(r);
1102
+ var e = At(r);
1103
1103
  return {
1104
1104
  args: e.map(function(n) {
1105
1105
  return r[n];
@@ -1111,7 +1111,7 @@ function _t(t) {
1111
1111
  return { args: t, keys: null };
1112
1112
  }
1113
1113
  function Ct(t) {
1114
- return t && typeof t == "object" && Ot(t) === At;
1114
+ return t && typeof t == "object" && Ot(t) === xt;
1115
1115
  }
1116
1116
  function Tt(t, r) {
1117
1117
  return t.reduce(function(e, n, i) {
@@ -1124,7 +1124,7 @@ function Pt() {
1124
1124
  var e = pe(t), n = it(t), i = _t(t), o = i.args, s = i.keys;
1125
1125
  if (o.length === 0)
1126
1126
  return Q([], e);
1127
- var c = new b(Mt(o, e, s ? function(u) {
1127
+ var c = new m(Mt(o, e, s ? function(u) {
1128
1128
  return Tt(s, u);
1129
1129
  } : N));
1130
1130
  return n ? c.pipe(Et(n)) : c;
@@ -1135,7 +1135,7 @@ function Mt(t, r, e) {
1135
1135
  for (var i = t.length, o = new Array(i), s = i, c = i, u = function(f) {
1136
1136
  oe(r, function() {
1137
1137
  var d = Q(t[f], r), p = !1;
1138
- d.subscribe(S(n, function(l) {
1138
+ d.subscribe(E(n, function(l) {
1139
1139
  o[f] = l, p || (p = !0, c--), c || n.next(e(o.slice()));
1140
1140
  }, function() {
1141
1141
  --s || n.complete();
@@ -1147,7 +1147,7 @@ function Mt(t, r, e) {
1147
1147
  };
1148
1148
  }
1149
1149
  function oe(t, r, e) {
1150
- t ? A(e, t, r) : r();
1150
+ t ? x(e, t, r) : r();
1151
1151
  }
1152
1152
  function kt(t, r, e, n, i, o, s, c) {
1153
1153
  var u = [], a = 0, f = 0, d = !1, p = function() {
@@ -1156,36 +1156,36 @@ function kt(t, r, e, n, i, o, s, c) {
1156
1156
  return a < n ? v(h) : u.push(h);
1157
1157
  }, v = function(h) {
1158
1158
  a++;
1159
- var g = !1;
1160
- x(e(h, f++)).subscribe(S(r, function(w) {
1161
- r.next(w);
1159
+ var w = !1;
1160
+ A(e(h, f++)).subscribe(E(r, function(S) {
1161
+ r.next(S);
1162
1162
  }, function() {
1163
- g = !0;
1163
+ w = !0;
1164
1164
  }, void 0, function() {
1165
- if (g)
1165
+ if (w)
1166
1166
  try {
1167
1167
  a--;
1168
- for (var w = function() {
1168
+ for (var S = function() {
1169
1169
  var _ = u.shift();
1170
1170
  s || v(_);
1171
1171
  }; u.length && a < n; )
1172
- w();
1172
+ S();
1173
1173
  p();
1174
1174
  } catch (_) {
1175
1175
  r.error(_);
1176
1176
  }
1177
1177
  }));
1178
1178
  };
1179
- return t.subscribe(S(r, l, function() {
1179
+ return t.subscribe(E(r, l, function() {
1180
1180
  d = !0, p();
1181
1181
  })), function() {
1182
1182
  };
1183
1183
  }
1184
- function U(t, r, e) {
1185
- return e === void 0 && (e = 1 / 0), y(r) ? U(function(n, i) {
1184
+ function $(t, r, e) {
1185
+ return e === void 0 && (e = 1 / 0), y(r) ? $(function(n, i) {
1186
1186
  return G(function(o, s) {
1187
1187
  return r(n, o, i, s);
1188
- })(x(t(n, i)));
1188
+ })(A(t(n, i)));
1189
1189
  }, e) : (typeof r == "number" && (e = r), C(function(n, i) {
1190
1190
  return kt(n, i, t, e);
1191
1191
  }));
@@ -1193,7 +1193,7 @@ function U(t, r, e) {
1193
1193
  function Pe(t, r, e) {
1194
1194
  t === void 0 && (t = 0), e === void 0 && (e = rt);
1195
1195
  var n = -1;
1196
- return r != null && (ve(r) ? e = r : n = r), new b(function(i) {
1196
+ return r != null && (ve(r) ? e = r : n = r), new m(function(i) {
1197
1197
  var o = gt(t) ? +t - e.now() : t;
1198
1198
  o < 0 && (o = 0);
1199
1199
  var s = 0;
@@ -1202,37 +1202,37 @@ function Pe(t, r, e) {
1202
1202
  }, o);
1203
1203
  });
1204
1204
  }
1205
- function jt(t, r) {
1206
- return y(r) ? U(t, r, 1) : U(t, 1);
1205
+ function Rt(t, r) {
1206
+ return y(r) ? $(t, r, 1) : $(t, 1);
1207
1207
  }
1208
1208
  function Dt(t) {
1209
1209
  return t <= 0 ? function() {
1210
1210
  return nt;
1211
1211
  } : C(function(r, e) {
1212
1212
  var n = 0;
1213
- r.subscribe(S(e, function(i) {
1213
+ r.subscribe(E(e, function(i) {
1214
1214
  ++n <= t && (e.next(i), t <= n && e.complete());
1215
1215
  }));
1216
1216
  });
1217
1217
  }
1218
- function Lt(t) {
1218
+ function jt(t) {
1219
1219
  return G(function() {
1220
1220
  return t;
1221
1221
  });
1222
1222
  }
1223
- function $t(t, r) {
1224
- return U(function(e, n) {
1225
- return x(t(e, n)).pipe(Dt(1), Lt(e));
1223
+ function Lt(t, r) {
1224
+ return $(function(e, n) {
1225
+ return A(t(e, n)).pipe(Dt(1), jt(e));
1226
1226
  });
1227
1227
  }
1228
- function Rt(t, r) {
1228
+ function Ut(t, r) {
1229
1229
  r === void 0 && (r = de);
1230
1230
  var e = Pe(t, r);
1231
- return $t(function() {
1231
+ return Lt(function() {
1232
1232
  return e;
1233
1233
  });
1234
1234
  }
1235
- function Ut(t) {
1235
+ function $t(t) {
1236
1236
  var r;
1237
1237
  r = {
1238
1238
  count: t
@@ -1241,7 +1241,7 @@ function Ut(t) {
1241
1241
  return n <= 0 ? N : C(function(c, u) {
1242
1242
  var a = 0, f, d = function() {
1243
1243
  var p = !1;
1244
- f = c.subscribe(S(u, function(l) {
1244
+ f = c.subscribe(E(u, function(l) {
1245
1245
  s && (a = 0), u.next(l);
1246
1246
  }, void 0, function(l) {
1247
1247
  if (a++ < n) {
@@ -1249,12 +1249,12 @@ function Ut(t) {
1249
1249
  f ? (f.unsubscribe(), f = null, d()) : p = !0;
1250
1250
  };
1251
1251
  if (i != null) {
1252
- var h = typeof i == "number" ? Pe(i) : x(i(l, a)), g = S(u, function() {
1253
- g.unsubscribe(), v();
1252
+ var h = typeof i == "number" ? Pe(i) : A(i(l, a)), w = E(u, function() {
1253
+ w.unsubscribe(), v();
1254
1254
  }, function() {
1255
1255
  u.complete();
1256
1256
  });
1257
- h.subscribe(g);
1257
+ h.subscribe(w);
1258
1258
  } else
1259
1259
  v();
1260
1260
  } else
@@ -1266,7 +1266,7 @@ function Ut(t) {
1266
1266
  }
1267
1267
  function Nt(t) {
1268
1268
  return C(function(r, e) {
1269
- x(t).subscribe(S(e, function() {
1269
+ A(t).subscribe(E(e, function() {
1270
1270
  return e.complete();
1271
1271
  }, B)), !e.closed && r.subscribe(e);
1272
1272
  });
@@ -1362,31 +1362,31 @@ function Bt(t, r) {
1362
1362
  v.abort(), document.hidden || F();
1363
1363
  }
1364
1364
  u || document.addEventListener("visibilitychange", h);
1365
- let g = qt, w = 0;
1365
+ let w = qt, S = 0;
1366
1366
  function _() {
1367
- document.removeEventListener("visibilitychange", h), window.clearTimeout(w), v.abort();
1367
+ document.removeEventListener("visibilitychange", h), window.clearTimeout(S), v.abort();
1368
1368
  }
1369
1369
  e == null || e.addEventListener("abort", () => {
1370
1370
  _(), d();
1371
1371
  });
1372
- const je = a ?? window.fetch, De = i ?? Yt;
1372
+ const Re = a ?? window.fetch, De = i ?? Yt;
1373
1373
  async function F() {
1374
1374
  var V;
1375
1375
  v = new AbortController();
1376
1376
  try {
1377
- const D = await je(t, Object.assign(Object.assign({}, f), { headers: l, signal: v.signal }));
1378
- await De(D), await Gt(D.body, Ft(Vt((I) => {
1379
- I ? l[ae] = I : delete l[ae];
1380
- }, (I) => {
1381
- g = I;
1377
+ const D = await Re(t, Object.assign(Object.assign({}, f), { headers: l, signal: v.signal }));
1378
+ await De(D), await Gt(D.body, Ft(Vt((O) => {
1379
+ O ? l[ae] = O : delete l[ae];
1380
+ }, (O) => {
1381
+ w = O;
1382
1382
  }, o))), s == null || s(), _(), d();
1383
1383
  } catch (D) {
1384
1384
  if (!v.signal.aborted)
1385
1385
  try {
1386
- const I = (V = c == null ? void 0 : c(D)) !== null && V !== void 0 ? V : g;
1387
- window.clearTimeout(w), w = window.setTimeout(F, I);
1388
- } catch (I) {
1389
- _(), p(I);
1386
+ const O = (V = c == null ? void 0 : c(D)) !== null && V !== void 0 ? V : w;
1387
+ window.clearTimeout(S), S = window.setTimeout(F, O);
1388
+ } catch (O) {
1389
+ _(), p(O);
1390
1390
  }
1391
1391
  }
1392
1392
  }
@@ -1400,7 +1400,7 @@ function Yt(t) {
1400
1400
  }
1401
1401
  function Wt(t) {
1402
1402
  const { endpoint: r, apiKey: e, payload: n } = t;
1403
- return new b((i) => {
1403
+ return new m((i) => {
1404
1404
  const o = new AbortController();
1405
1405
  return Bt(r, {
1406
1406
  method: "POST",
@@ -1429,15 +1429,16 @@ function Wt(t) {
1429
1429
  }
1430
1430
  class Xt {
1431
1431
  constructor(r) {
1432
- m(this, "apiKey");
1433
- m(this, "endpoint");
1434
- m(this, "destroy$", new z());
1435
- m(this, "transformSsePayload");
1432
+ b(this, "apiKey");
1433
+ b(this, "endpoint");
1434
+ b(this, "destroy$", new z());
1435
+ b(this, "onExecutionError");
1436
+ b(this, "transformSsePayload");
1436
1437
  if (!r.apiKey)
1437
1438
  throw new Error("apiKey must be required");
1438
1439
  if (!r.endpoint)
1439
1440
  throw new Error("endpoint must be required");
1440
- this.apiKey = r.apiKey, this.endpoint = r.endpoint, this.transformSsePayload = r.transformSsePayload;
1441
+ this.apiKey = r.apiKey, this.endpoint = r.endpoint, this.onExecutionError = r.onExecutionError, this.transformSsePayload = r.transformSsePayload;
1441
1442
  }
1442
1443
  fetchSse(r, e) {
1443
1444
  var n, i;
@@ -1446,13 +1447,20 @@ class Xt {
1446
1447
  endpoint: this.endpoint,
1447
1448
  payload: ((i = this.transformSsePayload) == null ? void 0 : i.call(this, r)) ?? r
1448
1449
  }).pipe(
1449
- jt((o) => mt(o).pipe(Rt((e == null ? void 0 : e.delayTime) ?? 50))),
1450
+ Rt((o) => mt(o).pipe(Ut((e == null ? void 0 : e.delayTime) ?? 50))),
1450
1451
  Nt(this.destroy$),
1451
- Ut(3)
1452
+ $t(3)
1452
1453
  ).subscribe({
1453
1454
  next: (o) => {
1454
- var s;
1455
- (s = e == null ? void 0 : e.onSseMessage) == null || s.call(e, o);
1455
+ var s, c;
1456
+ switch ((s = e == null ? void 0 : e.onSseMessage) == null || s.call(e, o), o.eventType) {
1457
+ case g.ERROR:
1458
+ (c = this.onExecutionError) == null || c.call(
1459
+ this,
1460
+ o.fact.runError
1461
+ );
1462
+ break;
1463
+ }
1456
1464
  },
1457
1465
  error: (o) => {
1458
1466
  var s;
@@ -1470,13 +1478,13 @@ class Xt {
1470
1478
  }
1471
1479
  class Me {
1472
1480
  constructor(r) {
1473
- m(this, "client");
1474
- m(this, "customChannelId");
1475
- m(this, "customMessageId");
1476
- m(this, "isConnecting$");
1477
- m(this, "conversation$");
1478
- m(this, "statesObserver");
1479
- m(this, "statesSubscription");
1481
+ b(this, "client");
1482
+ b(this, "customChannelId");
1483
+ b(this, "customMessageId");
1484
+ b(this, "isConnecting$");
1485
+ b(this, "conversation$");
1486
+ b(this, "statesObserver");
1487
+ b(this, "statesSubscription");
1480
1488
  if (!r.client)
1481
1489
  throw new Error("client must be required");
1482
1490
  if (!r.customChannelId)
@@ -1486,7 +1494,7 @@ class Me {
1486
1494
  static async reset(r, e) {
1487
1495
  const n = new Me(r);
1488
1496
  try {
1489
- return await n.resetChannel(e), n.subscribe(), n;
1497
+ return n.subscribe(), await n.resetChannel(e), n;
1490
1498
  } catch (i) {
1491
1499
  throw n.close(), i;
1492
1500
  }
@@ -1558,8 +1566,8 @@ class Me {
1558
1566
  }
1559
1567
  class ke {
1560
1568
  constructor({ messages: r, showDebugMessage: e }) {
1561
- m(this, "showDebugMessage", !1);
1562
- m(this, "messages", null);
1569
+ b(this, "showDebugMessage", !1);
1570
+ b(this, "messages", null);
1563
1571
  this.messages = r, this.showDebugMessage = e ?? !1;
1564
1572
  }
1565
1573
  create(r) {
@@ -1574,18 +1582,20 @@ class ke {
1574
1582
  }
1575
1583
  onMessage(r) {
1576
1584
  switch (r.eventType) {
1577
- case O.MESSAGE_START:
1585
+ case g.MESSAGE_START:
1578
1586
  return this.onMessageStart(
1579
1587
  r
1580
1588
  );
1581
- case O.MESSAGE_DELTA:
1589
+ case g.MESSAGE_DELTA:
1582
1590
  return this.onMessageDelta(
1583
1591
  r
1584
1592
  );
1585
- case O.MESSAGE_COMPLETE:
1593
+ case g.MESSAGE_COMPLETE:
1586
1594
  return this.onMessageComplete(
1587
1595
  r
1588
1596
  );
1597
+ case g.ERROR:
1598
+ return this.onMessageError(r);
1589
1599
  default:
1590
1600
  return this;
1591
1601
  }
@@ -1594,7 +1604,7 @@ class ke {
1594
1604
  const e = r.fact.messageStart.message, n = new Map(this.messages);
1595
1605
  return e.isDebug && !this.showDebugMessage || n != null && n.has(e.messageId) ? this.create(n) : (n.set(e.messageId, {
1596
1606
  type: "bot",
1597
- eventType: O.MESSAGE_START,
1607
+ eventType: g.MESSAGE_START,
1598
1608
  isTyping: !0,
1599
1609
  typingText: "",
1600
1610
  messageId: e.messageId,
@@ -1604,13 +1614,13 @@ class ke {
1604
1614
  }
1605
1615
  onMessageDelta(r) {
1606
1616
  const e = r.fact.messageDelta.message, n = new Map(this.messages), i = n.get(e.messageId);
1607
- if ((i == null ? void 0 : i.type) === "user") return this;
1608
- if (e.isDebug && !this.showDebugMessage || (i == null ? void 0 : i.eventType) === O.MESSAGE_COMPLETE)
1617
+ if ((i == null ? void 0 : i.type) !== "bot") return this;
1618
+ if (e.isDebug && !this.showDebugMessage || (i == null ? void 0 : i.eventType) === g.MESSAGE_COMPLETE)
1609
1619
  return this.create(n);
1610
1620
  const o = `${(i == null ? void 0 : i.typingText) ?? ""}${e.text}`;
1611
1621
  return n.set(e.messageId, {
1612
1622
  type: "bot",
1613
- eventType: O.MESSAGE_DELTA,
1623
+ eventType: g.MESSAGE_DELTA,
1614
1624
  isTyping: !0,
1615
1625
  typingText: o,
1616
1626
  messageId: e.messageId,
@@ -1622,7 +1632,7 @@ class ke {
1622
1632
  const e = r.fact.messageComplete.message, n = new Map(this.messages);
1623
1633
  return e.isDebug && !this.showDebugMessage ? this.create(n) : (n.set(e.messageId, {
1624
1634
  type: "bot",
1625
- eventType: O.MESSAGE_COMPLETE,
1635
+ eventType: g.MESSAGE_COMPLETE,
1626
1636
  isTyping: !1,
1627
1637
  typingText: null,
1628
1638
  messageId: e.messageId,
@@ -1630,13 +1640,23 @@ class ke {
1630
1640
  time: /* @__PURE__ */ new Date()
1631
1641
  }), this.create(n));
1632
1642
  }
1643
+ onMessageError(r) {
1644
+ const e = crypto.randomUUID(), n = r.fact.runError.error, i = new Map(this.messages);
1645
+ return i.set(e, {
1646
+ type: "error",
1647
+ eventType: g.ERROR,
1648
+ messageId: e,
1649
+ error: n,
1650
+ time: /* @__PURE__ */ new Date()
1651
+ }), this.create(i);
1652
+ }
1633
1653
  }
1634
1654
  export {
1635
1655
  Xt as AsgardServiceClient,
1636
1656
  Me as Channel,
1637
1657
  ke as Conversation,
1638
- O as EventType,
1658
+ g as EventType,
1639
1659
  H as FetchSseAction,
1640
- Re as MessageTemplateType
1660
+ Ue as MessageTemplateType
1641
1661
  };
1642
1662
  //# sourceMappingURL=index.mjs.map