@asgard-js/core 0.2.62 → 0.3.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 (50) hide show
  1. package/README.md +95 -20
  2. package/dist/constants/enum.d.ts +7 -0
  3. package/dist/constants/enum.d.ts.map +1 -1
  4. package/dist/index.cjs +4 -4
  5. package/dist/index.cjs.map +1 -1
  6. package/dist/index.d.ts +6 -0
  7. package/dist/index.d.ts.map +1 -1
  8. package/dist/index.js +4 -4
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +1555 -1145
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/lib/channel.d.ts +39 -1
  13. package/dist/lib/channel.d.ts.map +1 -1
  14. package/dist/lib/channel.spec.d.ts +2 -0
  15. package/dist/lib/channel.spec.d.ts.map +1 -0
  16. package/dist/lib/client.d.ts +16 -1
  17. package/dist/lib/client.d.ts.map +1 -1
  18. package/dist/lib/client.spec.d.ts +2 -0
  19. package/dist/lib/client.spec.d.ts.map +1 -0
  20. package/dist/lib/conversation.d.ts +18 -0
  21. package/dist/lib/conversation.d.ts.map +1 -1
  22. package/dist/lib/conversation.spec.d.ts +2 -0
  23. package/dist/lib/conversation.spec.d.ts.map +1 -0
  24. package/dist/lib/create-sse-observable.d.ts +4 -1
  25. package/dist/lib/create-sse-observable.d.ts.map +1 -1
  26. package/dist/lib/derived-stores.d.ts +39 -0
  27. package/dist/lib/derived-stores.d.ts.map +1 -0
  28. package/dist/lib/derived-stores.spec.d.ts +2 -0
  29. package/dist/lib/derived-stores.spec.d.ts.map +1 -0
  30. package/dist/lib/subagent-reducer.d.ts +46 -0
  31. package/dist/lib/subagent-reducer.d.ts.map +1 -0
  32. package/dist/lib/subagent-reducer.spec.d.ts +2 -0
  33. package/dist/lib/subagent-reducer.spec.d.ts.map +1 -0
  34. package/dist/lib/task-reducer.d.ts +23 -0
  35. package/dist/lib/task-reducer.d.ts.map +1 -0
  36. package/dist/lib/task-reducer.spec.d.ts +2 -0
  37. package/dist/lib/task-reducer.spec.d.ts.map +1 -0
  38. package/dist/types/channel.d.ts +73 -1
  39. package/dist/types/channel.d.ts.map +1 -1
  40. package/dist/types/client.d.ts +9 -0
  41. package/dist/types/client.d.ts.map +1 -1
  42. package/dist/types/index.d.ts +2 -0
  43. package/dist/types/index.d.ts.map +1 -1
  44. package/dist/types/sse-response.d.ts +66 -0
  45. package/dist/types/sse-response.d.ts.map +1 -1
  46. package/dist/types/subagent.d.ts +37 -0
  47. package/dist/types/subagent.d.ts.map +1 -0
  48. package/dist/types/task.d.ts +21 -0
  49. package/dist/types/task.d.ts.map +1 -0
  50. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -1,528 +1,528 @@
1
- class de extends Error {
1
+ class te extends Error {
2
2
  status;
3
3
  statusText;
4
4
  body;
5
- constructor(e, t, r) {
6
- super(`HTTP ${e}: ${t}`), this.name = "HttpError", this.status = e, this.statusText = t, this.body = r;
5
+ constructor(t, e, r) {
6
+ super(`HTTP ${t}: ${e}`), this.name = "HttpError", this.status = t, this.statusText = e, this.body = r;
7
7
  }
8
8
  }
9
- function on(n) {
10
- return n instanceof de;
9
+ function En(n) {
10
+ return n instanceof te;
11
11
  }
12
- var k = /* @__PURE__ */ ((n) => (n.RESET_CHANNEL = "RESET_CHANNEL", n.NONE = "NONE", n.RESPONSE_TOOL_CALL_CONSENT = "RESPONSE_TOOL_CALL_CONSENT", n))(k || {}), d = /* @__PURE__ */ ((n) => (n.INIT = "asgard.run.init", n.PROCESS = "asgard.process", n.PROCESS_START = "asgard.process.start", n.PROCESS_COMPLETE = "asgard.process.complete", n.MESSAGE = "asgard.message", n.MESSAGE_START = "asgard.message.start", n.MESSAGE_DELTA = "asgard.message.delta", n.MESSAGE_COMPLETE = "asgard.message.complete", n.TOOL_CALL = "asgard.tool_call", n.TOOL_CALL_START = "asgard.tool_call.start", n.TOOL_CALL_COMPLETE = "asgard.tool_call.complete", n.TOOL_CALL_CONSENT = "asgard.tool_call.consent", n.DONE = "asgard.run.done", n.ERROR = "asgard.run.error", n))(d || {}), je = /* @__PURE__ */ ((n) => (n.ALLOW_ONCE = "ALLOW_ONCE", n.ALLOW_ALWAYS = "ALLOW_ALWAYS", n.DENY_ONCE = "DENY_ONCE", n))(je || {}), He = /* @__PURE__ */ ((n) => (n.TEXT = "TEXT", n.HINT = "HINT", n.BUTTON = "BUTTON", n.IMAGE = "IMAGE", n.VIDEO = "VIDEO", n.AUDIO = "AUDIO", n.LOCATION = "LOCATION", n.CAROUSEL = "CAROUSEL", n.CHART = "CHART", n.TABLE = "TABLE", n.ATTACHMENT = "ATTACHMENT", n))(He || {}), q = function(n, e) {
13
- return q = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(t, r) {
14
- t.__proto__ = r;
15
- } || function(t, r) {
16
- for (var o in r) Object.prototype.hasOwnProperty.call(r, o) && (t[o] = r[o]);
17
- }, q(n, e);
12
+ var H = /* @__PURE__ */ ((n) => (n.RESET_CHANNEL = "RESET_CHANNEL", n.NONE = "NONE", n.RESPONSE_TOOL_CALL_CONSENT = "RESPONSE_TOOL_CALL_CONSENT", n))(H || {}), d = /* @__PURE__ */ ((n) => (n.INIT = "asgard.run.init", n.PROCESS = "asgard.process", n.PROCESS_START = "asgard.process.start", n.PROCESS_COMPLETE = "asgard.process.complete", n.MESSAGE = "asgard.message", n.MESSAGE_START = "asgard.message.start", n.MESSAGE_DELTA = "asgard.message.delta", n.MESSAGE_COMPLETE = "asgard.message.complete", n.MESSAGE_USER = "asgard.message.user", n.MESSAGE_THINKING_START = "asgard.message.thinking.start", n.MESSAGE_THINKING_DELTA = "asgard.message.thinking.delta", n.MESSAGE_THINKING_COMPLETE = "asgard.message.thinking.complete", n.TOOL_CALL = "asgard.tool_call", n.TOOL_CALL_START = "asgard.tool_call.start", n.TOOL_CALL_COMPLETE = "asgard.tool_call.complete", n.TOOL_CALL_CONSENT = "asgard.tool_call.consent", n.SUBAGENT_START = "asgard.subagent.start", n.SUBAGENT_COMPLETE = "asgard.subagent.complete", n.CHANNEL_TITLE_UPDATE = "asgard.channel.title.update", n.DONE = "asgard.run.done", n.ERROR = "asgard.run.error", n))(d || {}), Ke = /* @__PURE__ */ ((n) => (n.ALLOW_ONCE = "ALLOW_ONCE", n.ALLOW_ALWAYS = "ALLOW_ALWAYS", n.DENY_ONCE = "DENY_ONCE", n))(Ke || {}), Fe = /* @__PURE__ */ ((n) => (n.TEXT = "TEXT", n.HINT = "HINT", n.BUTTON = "BUTTON", n.IMAGE = "IMAGE", n.VIDEO = "VIDEO", n.AUDIO = "AUDIO", n.LOCATION = "LOCATION", n.CAROUSEL = "CAROUSEL", n.CHART = "CHART", n.TABLE = "TABLE", n.ATTACHMENT = "ATTACHMENT", n))(Fe || {}), z = function(n, t) {
13
+ return z = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(e, r) {
14
+ e.__proto__ = r;
15
+ } || function(e, r) {
16
+ for (var s in r) Object.prototype.hasOwnProperty.call(r, s) && (e[s] = r[s]);
17
+ }, z(n, t);
18
18
  };
19
- function I(n, e) {
20
- if (typeof e != "function" && e !== null)
21
- throw new TypeError("Class extends value " + String(e) + " is not a constructor or null");
22
- q(n, e);
23
- function t() {
19
+ function w(n, t) {
20
+ if (typeof t != "function" && t !== null)
21
+ throw new TypeError("Class extends value " + String(t) + " is not a constructor or null");
22
+ z(n, t);
23
+ function e() {
24
24
  this.constructor = n;
25
25
  }
26
- n.prototype = e === null ? Object.create(e) : (t.prototype = e.prototype, new t());
26
+ n.prototype = t === null ? Object.create(t) : (e.prototype = t.prototype, new e());
27
27
  }
28
- function Fe(n, e, t, r) {
29
- function o(i) {
30
- return i instanceof t ? i : new t(function(s) {
31
- s(i);
28
+ function Be(n, t, e, r) {
29
+ function s(o) {
30
+ return o instanceof e ? o : new e(function(i) {
31
+ i(o);
32
32
  });
33
33
  }
34
- return new (t || (t = Promise))(function(i, s) {
35
- function a(f) {
34
+ return new (e || (e = Promise))(function(o, i) {
35
+ function a(h) {
36
36
  try {
37
- u(r.next(f));
38
- } catch (p) {
39
- s(p);
37
+ c(r.next(h));
38
+ } catch (g) {
39
+ i(g);
40
40
  }
41
41
  }
42
- function c(f) {
42
+ function u(h) {
43
43
  try {
44
- u(r.throw(f));
45
- } catch (p) {
46
- s(p);
44
+ c(r.throw(h));
45
+ } catch (g) {
46
+ i(g);
47
47
  }
48
48
  }
49
- function u(f) {
50
- f.done ? i(f.value) : o(f.value).then(a, c);
49
+ function c(h) {
50
+ h.done ? o(h.value) : s(h.value).then(a, u);
51
51
  }
52
- u((r = r.apply(n, e || [])).next());
52
+ c((r = r.apply(n, t || [])).next());
53
53
  });
54
54
  }
55
- function he(n, e) {
56
- var t = { label: 0, sent: function() {
57
- if (i[0] & 1) throw i[1];
58
- return i[1];
59
- }, trys: [], ops: [] }, r, o, i, s = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
60
- return s.next = a(0), s.throw = a(1), s.return = a(2), typeof Symbol == "function" && (s[Symbol.iterator] = function() {
55
+ function ve(n, t) {
56
+ var e = { label: 0, sent: function() {
57
+ if (o[0] & 1) throw o[1];
58
+ return o[1];
59
+ }, trys: [], ops: [] }, r, s, o, i = Object.create((typeof Iterator == "function" ? Iterator : Object).prototype);
60
+ return i.next = a(0), i.throw = a(1), i.return = a(2), typeof Symbol == "function" && (i[Symbol.iterator] = function() {
61
61
  return this;
62
- }), s;
63
- function a(u) {
64
- return function(f) {
65
- return c([u, f]);
62
+ }), i;
63
+ function a(c) {
64
+ return function(h) {
65
+ return u([c, h]);
66
66
  };
67
67
  }
68
- function c(u) {
68
+ function u(c) {
69
69
  if (r) throw new TypeError("Generator is already executing.");
70
- for (; s && (s = 0, u[0] && (t = 0)), t; ) try {
71
- if (r = 1, o && (i = u[0] & 2 ? o.return : u[0] ? o.throw || ((i = o.return) && i.call(o), 0) : o.next) && !(i = i.call(o, u[1])).done) return i;
72
- switch (o = 0, i && (u = [u[0] & 2, i.value]), u[0]) {
70
+ for (; i && (i = 0, c[0] && (e = 0)), e; ) try {
71
+ if (r = 1, s && (o = c[0] & 2 ? s.return : c[0] ? s.throw || ((o = s.return) && o.call(s), 0) : s.next) && !(o = o.call(s, c[1])).done) return o;
72
+ switch (s = 0, o && (c = [c[0] & 2, o.value]), c[0]) {
73
73
  case 0:
74
74
  case 1:
75
- i = u;
75
+ o = c;
76
76
  break;
77
77
  case 4:
78
- return t.label++, { value: u[1], done: !1 };
78
+ return e.label++, { value: c[1], done: !1 };
79
79
  case 5:
80
- t.label++, o = u[1], u = [0];
80
+ e.label++, s = c[1], c = [0];
81
81
  continue;
82
82
  case 7:
83
- u = t.ops.pop(), t.trys.pop();
83
+ c = e.ops.pop(), e.trys.pop();
84
84
  continue;
85
85
  default:
86
- if (i = t.trys, !(i = i.length > 0 && i[i.length - 1]) && (u[0] === 6 || u[0] === 2)) {
87
- t = 0;
86
+ if (o = e.trys, !(o = o.length > 0 && o[o.length - 1]) && (c[0] === 6 || c[0] === 2)) {
87
+ e = 0;
88
88
  continue;
89
89
  }
90
- if (u[0] === 3 && (!i || u[1] > i[0] && u[1] < i[3])) {
91
- t.label = u[1];
90
+ if (c[0] === 3 && (!o || c[1] > o[0] && c[1] < o[3])) {
91
+ e.label = c[1];
92
92
  break;
93
93
  }
94
- if (u[0] === 6 && t.label < i[1]) {
95
- t.label = i[1], i = u;
94
+ if (c[0] === 6 && e.label < o[1]) {
95
+ e.label = o[1], o = c;
96
96
  break;
97
97
  }
98
- if (i && t.label < i[2]) {
99
- t.label = i[2], t.ops.push(u);
98
+ if (o && e.label < o[2]) {
99
+ e.label = o[2], e.ops.push(c);
100
100
  break;
101
101
  }
102
- i[2] && t.ops.pop(), t.trys.pop();
102
+ o[2] && e.ops.pop(), e.trys.pop();
103
103
  continue;
104
104
  }
105
- u = e.call(n, t);
106
- } catch (f) {
107
- u = [6, f], o = 0;
105
+ c = t.call(n, e);
106
+ } catch (h) {
107
+ c = [6, h], s = 0;
108
108
  } finally {
109
- r = i = 0;
109
+ r = o = 0;
110
110
  }
111
- if (u[0] & 5) throw u[1];
112
- return { value: u[0] ? u[1] : void 0, done: !0 };
111
+ if (c[0] & 5) throw c[1];
112
+ return { value: c[0] ? c[1] : void 0, done: !0 };
113
113
  }
114
114
  }
115
- function P(n) {
116
- var e = typeof Symbol == "function" && Symbol.iterator, t = e && n[e], r = 0;
117
- if (t) return t.call(n);
115
+ function k(n) {
116
+ var t = typeof Symbol == "function" && Symbol.iterator, e = t && n[t], r = 0;
117
+ if (e) return e.call(n);
118
118
  if (n && typeof n.length == "number") return {
119
119
  next: function() {
120
120
  return n && r >= n.length && (n = void 0), { value: n && n[r++], done: !n };
121
121
  }
122
122
  };
123
- throw new TypeError(e ? "Object is not iterable." : "Symbol.iterator is not defined.");
123
+ throw new TypeError(t ? "Object is not iterable." : "Symbol.iterator is not defined.");
124
124
  }
125
- function M(n, e) {
126
- var t = typeof Symbol == "function" && n[Symbol.iterator];
127
- if (!t) return n;
128
- var r = t.call(n), o, i = [], s;
125
+ function R(n, t) {
126
+ var e = typeof Symbol == "function" && n[Symbol.iterator];
127
+ if (!e) return n;
128
+ var r = e.call(n), s, o = [], i;
129
129
  try {
130
- for (; (e === void 0 || e-- > 0) && !(o = r.next()).done; ) i.push(o.value);
130
+ for (; (t === void 0 || t-- > 0) && !(s = r.next()).done; ) o.push(s.value);
131
131
  } catch (a) {
132
- s = { error: a };
132
+ i = { error: a };
133
133
  } finally {
134
134
  try {
135
- o && !o.done && (t = r.return) && t.call(r);
135
+ s && !s.done && (e = r.return) && e.call(r);
136
136
  } finally {
137
- if (s) throw s.error;
137
+ if (i) throw i.error;
138
138
  }
139
139
  }
140
- return i;
140
+ return o;
141
141
  }
142
- function R(n, e, t) {
143
- if (t || arguments.length === 2) for (var r = 0, o = e.length, i; r < o; r++)
144
- (i || !(r in e)) && (i || (i = Array.prototype.slice.call(e, 0, r)), i[r] = e[r]);
145
- return n.concat(i || Array.prototype.slice.call(e));
142
+ function $(n, t, e) {
143
+ if (e || arguments.length === 2) for (var r = 0, s = t.length, o; r < s; r++)
144
+ (o || !(r in t)) && (o || (o = Array.prototype.slice.call(t, 0, r)), o[r] = t[r]);
145
+ return n.concat(o || Array.prototype.slice.call(t));
146
146
  }
147
- function x(n) {
148
- return this instanceof x ? (this.v = n, this) : new x(n);
147
+ function L(n) {
148
+ return this instanceof L ? (this.v = n, this) : new L(n);
149
149
  }
150
- function Ge(n, e, t) {
150
+ function qe(n, t, e) {
151
151
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
152
- var r = t.apply(n, e || []), o, i = [];
153
- return o = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), a("next"), a("throw"), a("return", s), o[Symbol.asyncIterator] = function() {
152
+ var r = e.apply(n, t || []), s, o = [];
153
+ return s = Object.create((typeof AsyncIterator == "function" ? AsyncIterator : Object).prototype), a("next"), a("throw"), a("return", i), s[Symbol.asyncIterator] = function() {
154
154
  return this;
155
- }, o;
156
- function s(l) {
157
- return function(y) {
158
- return Promise.resolve(y).then(l, p);
155
+ }, s;
156
+ function i(l) {
157
+ return function(f) {
158
+ return Promise.resolve(f).then(l, g);
159
159
  };
160
160
  }
161
- function a(l, y) {
162
- r[l] && (o[l] = function(v) {
163
- return new Promise(function(w, E) {
164
- i.push([l, v, w, E]) > 1 || c(l, v);
161
+ function a(l, f) {
162
+ r[l] && (s[l] = function(p) {
163
+ return new Promise(function(A, I) {
164
+ o.push([l, p, A, I]) > 1 || u(l, p);
165
165
  });
166
- }, y && (o[l] = y(o[l])));
166
+ }, f && (s[l] = f(s[l])));
167
167
  }
168
- function c(l, y) {
168
+ function u(l, f) {
169
169
  try {
170
- u(r[l](y));
171
- } catch (v) {
172
- h(i[0][3], v);
170
+ c(r[l](f));
171
+ } catch (p) {
172
+ v(o[0][3], p);
173
173
  }
174
174
  }
175
- function u(l) {
176
- l.value instanceof x ? Promise.resolve(l.value.v).then(f, p) : h(i[0][2], l);
175
+ function c(l) {
176
+ l.value instanceof L ? Promise.resolve(l.value.v).then(h, g) : v(o[0][2], l);
177
177
  }
178
- function f(l) {
179
- c("next", l);
178
+ function h(l) {
179
+ u("next", l);
180
180
  }
181
- function p(l) {
182
- c("throw", l);
181
+ function g(l) {
182
+ u("throw", l);
183
183
  }
184
- function h(l, y) {
185
- l(y), i.shift(), i.length && c(i[0][0], i[0][1]);
184
+ function v(l, f) {
185
+ l(f), o.shift(), o.length && u(o[0][0], o[0][1]);
186
186
  }
187
187
  }
188
- function Ke(n) {
188
+ function Ve(n) {
189
189
  if (!Symbol.asyncIterator) throw new TypeError("Symbol.asyncIterator is not defined.");
190
- var e = n[Symbol.asyncIterator], t;
191
- return e ? e.call(n) : (n = typeof P == "function" ? P(n) : n[Symbol.iterator](), t = {}, r("next"), r("throw"), r("return"), t[Symbol.asyncIterator] = function() {
190
+ var t = n[Symbol.asyncIterator], e;
191
+ return t ? t.call(n) : (n = typeof k == "function" ? k(n) : n[Symbol.iterator](), e = {}, r("next"), r("throw"), r("return"), e[Symbol.asyncIterator] = function() {
192
192
  return this;
193
- }, t);
194
- function r(i) {
195
- t[i] = n[i] && function(s) {
196
- return new Promise(function(a, c) {
197
- s = n[i](s), o(a, c, s.done, s.value);
193
+ }, e);
194
+ function r(o) {
195
+ e[o] = n[o] && function(i) {
196
+ return new Promise(function(a, u) {
197
+ i = n[o](i), s(a, u, i.done, i.value);
198
198
  });
199
199
  };
200
200
  }
201
- function o(i, s, a, c) {
202
- Promise.resolve(c).then(function(u) {
203
- i({ value: u, done: a });
204
- }, s);
201
+ function s(o, i, a, u) {
202
+ Promise.resolve(u).then(function(c) {
203
+ o({ value: c, done: a });
204
+ }, i);
205
205
  }
206
206
  }
207
207
  function m(n) {
208
208
  return typeof n == "function";
209
209
  }
210
- function pe(n) {
211
- var e = function(r) {
210
+ function ye(n) {
211
+ var t = function(r) {
212
212
  Error.call(r), r.stack = new Error().stack;
213
- }, t = n(e);
214
- return t.prototype = Object.create(Error.prototype), t.prototype.constructor = t, t;
213
+ }, e = n(t);
214
+ return e.prototype = Object.create(Error.prototype), e.prototype.constructor = e, e;
215
215
  }
216
- var B = pe(function(n) {
217
- return function(t) {
218
- n(this), this.message = t ? t.length + ` errors occurred during unsubscription:
219
- ` + t.map(function(r, o) {
220
- return o + 1 + ") " + r.toString();
216
+ var W = ye(function(n) {
217
+ return function(e) {
218
+ n(this), this.message = e ? e.length + ` errors occurred during unsubscription:
219
+ ` + e.map(function(r, s) {
220
+ return s + 1 + ") " + r.toString();
221
221
  }).join(`
222
- `) : "", this.name = "UnsubscriptionError", this.errors = t;
222
+ `) : "", this.name = "UnsubscriptionError", this.errors = e;
223
223
  };
224
224
  });
225
- function j(n, e) {
225
+ function F(n, t) {
226
226
  if (n) {
227
- var t = n.indexOf(e);
228
- 0 <= t && n.splice(t, 1);
227
+ var e = n.indexOf(t);
228
+ 0 <= e && n.splice(e, 1);
229
229
  }
230
230
  }
231
- var N = (function() {
232
- function n(e) {
233
- this.initialTeardown = e, this.closed = !1, this._parentage = null, this._finalizers = null;
231
+ var U = (function() {
232
+ function n(t) {
233
+ this.initialTeardown = t, this.closed = !1, this._parentage = null, this._finalizers = null;
234
234
  }
235
235
  return n.prototype.unsubscribe = function() {
236
- var e, t, r, o, i;
236
+ var t, e, r, s, o;
237
237
  if (!this.closed) {
238
238
  this.closed = !0;
239
- var s = this._parentage;
240
- if (s)
241
- if (this._parentage = null, Array.isArray(s))
239
+ var i = this._parentage;
240
+ if (i)
241
+ if (this._parentage = null, Array.isArray(i))
242
242
  try {
243
- for (var a = P(s), c = a.next(); !c.done; c = a.next()) {
244
- var u = c.value;
245
- u.remove(this);
243
+ for (var a = k(i), u = a.next(); !u.done; u = a.next()) {
244
+ var c = u.value;
245
+ c.remove(this);
246
246
  }
247
- } catch (v) {
248
- e = { error: v };
247
+ } catch (p) {
248
+ t = { error: p };
249
249
  } finally {
250
250
  try {
251
- c && !c.done && (t = a.return) && t.call(a);
251
+ u && !u.done && (e = a.return) && e.call(a);
252
252
  } finally {
253
- if (e) throw e.error;
253
+ if (t) throw t.error;
254
254
  }
255
255
  }
256
256
  else
257
- s.remove(this);
258
- var f = this.initialTeardown;
259
- if (m(f))
257
+ i.remove(this);
258
+ var h = this.initialTeardown;
259
+ if (m(h))
260
260
  try {
261
- f();
262
- } catch (v) {
263
- i = v instanceof B ? v.errors : [v];
261
+ h();
262
+ } catch (p) {
263
+ o = p instanceof W ? p.errors : [p];
264
264
  }
265
- var p = this._finalizers;
266
- if (p) {
265
+ var g = this._finalizers;
266
+ if (g) {
267
267
  this._finalizers = null;
268
268
  try {
269
- for (var h = P(p), l = h.next(); !l.done; l = h.next()) {
270
- var y = l.value;
269
+ for (var v = k(g), l = v.next(); !l.done; l = v.next()) {
270
+ var f = l.value;
271
271
  try {
272
- ne(y);
273
- } catch (v) {
274
- i = i ?? [], v instanceof B ? i = R(R([], M(i)), M(v.errors)) : i.push(v);
272
+ ie(f);
273
+ } catch (p) {
274
+ o = o ?? [], p instanceof W ? o = $($([], R(o)), R(p.errors)) : o.push(p);
275
275
  }
276
276
  }
277
- } catch (v) {
278
- r = { error: v };
277
+ } catch (p) {
278
+ r = { error: p };
279
279
  } finally {
280
280
  try {
281
- l && !l.done && (o = h.return) && o.call(h);
281
+ l && !l.done && (s = v.return) && s.call(v);
282
282
  } finally {
283
283
  if (r) throw r.error;
284
284
  }
285
285
  }
286
286
  }
287
- if (i)
288
- throw new B(i);
287
+ if (o)
288
+ throw new W(o);
289
289
  }
290
- }, n.prototype.add = function(e) {
291
- var t;
292
- if (e && e !== this)
290
+ }, n.prototype.add = function(t) {
291
+ var e;
292
+ if (t && t !== this)
293
293
  if (this.closed)
294
- ne(e);
294
+ ie(t);
295
295
  else {
296
- if (e instanceof n) {
297
- if (e.closed || e._hasParent(this))
296
+ if (t instanceof n) {
297
+ if (t.closed || t._hasParent(this))
298
298
  return;
299
- e._addParent(this);
299
+ t._addParent(this);
300
300
  }
301
- (this._finalizers = (t = this._finalizers) !== null && t !== void 0 ? t : []).push(e);
301
+ (this._finalizers = (e = this._finalizers) !== null && e !== void 0 ? e : []).push(t);
302
302
  }
303
- }, n.prototype._hasParent = function(e) {
304
- var t = this._parentage;
305
- return t === e || Array.isArray(t) && t.includes(e);
306
- }, n.prototype._addParent = function(e) {
307
- var t = this._parentage;
308
- this._parentage = Array.isArray(t) ? (t.push(e), t) : t ? [t, e] : e;
309
- }, n.prototype._removeParent = function(e) {
310
- var t = this._parentage;
311
- t === e ? this._parentage = null : Array.isArray(t) && j(t, e);
312
- }, n.prototype.remove = function(e) {
313
- var t = this._finalizers;
314
- t && j(t, e), e instanceof n && e._removeParent(this);
303
+ }, n.prototype._hasParent = function(t) {
304
+ var e = this._parentage;
305
+ return e === t || Array.isArray(e) && e.includes(t);
306
+ }, n.prototype._addParent = function(t) {
307
+ var e = this._parentage;
308
+ this._parentage = Array.isArray(e) ? (e.push(t), e) : e ? [e, t] : t;
309
+ }, n.prototype._removeParent = function(t) {
310
+ var e = this._parentage;
311
+ e === t ? this._parentage = null : Array.isArray(e) && F(e, t);
312
+ }, n.prototype.remove = function(t) {
313
+ var e = this._finalizers;
314
+ e && F(e, t), t instanceof n && t._removeParent(this);
315
315
  }, n.EMPTY = (function() {
316
- var e = new n();
317
- return e.closed = !0, e;
316
+ var t = new n();
317
+ return t.closed = !0, t;
318
318
  })(), n;
319
- })(), ve = N.EMPTY;
320
- function ye(n) {
321
- return n instanceof N || n && "closed" in n && m(n.remove) && m(n.add) && m(n.unsubscribe);
319
+ })(), be = U.EMPTY;
320
+ function Se(n) {
321
+ return n instanceof U || n && "closed" in n && m(n.remove) && m(n.add) && m(n.unsubscribe);
322
322
  }
323
- function ne(n) {
323
+ function ie(n) {
324
324
  m(n) ? n() : n.unsubscribe();
325
325
  }
326
- var Ve = {
326
+ var Ye = {
327
327
  Promise: void 0
328
- }, Be = {
329
- setTimeout: function(n, e) {
330
- for (var t = [], r = 2; r < arguments.length; r++)
331
- t[r - 2] = arguments[r];
332
- return setTimeout.apply(void 0, R([n, e], M(t)));
328
+ }, We = {
329
+ setTimeout: function(n, t) {
330
+ for (var e = [], r = 2; r < arguments.length; r++)
331
+ e[r - 2] = arguments[r];
332
+ return setTimeout.apply(void 0, $([n, t], R(e)));
333
333
  },
334
334
  clearTimeout: function(n) {
335
335
  return clearTimeout(n);
336
336
  },
337
337
  delegate: void 0
338
338
  };
339
- function me(n) {
340
- Be.setTimeout(function() {
339
+ function Ie(n) {
340
+ We.setTimeout(function() {
341
341
  throw n;
342
342
  });
343
343
  }
344
- function W() {
344
+ function J() {
345
345
  }
346
- function D(n) {
346
+ function G(n) {
347
347
  n();
348
348
  }
349
- var Q = (function(n) {
350
- I(e, n);
351
- function e(t) {
349
+ var ne = (function(n) {
350
+ w(t, n);
351
+ function t(e) {
352
352
  var r = n.call(this) || this;
353
- return r.isStopped = !1, t ? (r.destination = t, ye(t) && t.add(r)) : r.destination = We, r;
354
- }
355
- return e.create = function(t, r, o) {
356
- return new X(t, r, o);
357
- }, e.prototype.next = function(t) {
358
- this.isStopped || this._next(t);
359
- }, e.prototype.error = function(t) {
360
- this.isStopped || (this.isStopped = !0, this._error(t));
361
- }, e.prototype.complete = function() {
353
+ return r.isStopped = !1, e ? (r.destination = e, Se(e) && e.add(r)) : r.destination = Je, r;
354
+ }
355
+ return t.create = function(e, r, s) {
356
+ return new Q(e, r, s);
357
+ }, t.prototype.next = function(e) {
358
+ this.isStopped || this._next(e);
359
+ }, t.prototype.error = function(e) {
360
+ this.isStopped || (this.isStopped = !0, this._error(e));
361
+ }, t.prototype.complete = function() {
362
362
  this.isStopped || (this.isStopped = !0, this._complete());
363
- }, e.prototype.unsubscribe = function() {
363
+ }, t.prototype.unsubscribe = function() {
364
364
  this.closed || (this.isStopped = !0, n.prototype.unsubscribe.call(this), this.destination = null);
365
- }, e.prototype._next = function(t) {
366
- this.destination.next(t);
367
- }, e.prototype._error = function(t) {
365
+ }, t.prototype._next = function(e) {
366
+ this.destination.next(e);
367
+ }, t.prototype._error = function(e) {
368
368
  try {
369
- this.destination.error(t);
369
+ this.destination.error(e);
370
370
  } finally {
371
371
  this.unsubscribe();
372
372
  }
373
- }, e.prototype._complete = function() {
373
+ }, t.prototype._complete = function() {
374
374
  try {
375
375
  this.destination.complete();
376
376
  } finally {
377
377
  this.unsubscribe();
378
378
  }
379
- }, e;
380
- })(N), Ye = (function() {
381
- function n(e) {
382
- this.partialObserver = e;
379
+ }, t;
380
+ })(U), Xe = (function() {
381
+ function n(t) {
382
+ this.partialObserver = t;
383
383
  }
384
- return n.prototype.next = function(e) {
385
- var t = this.partialObserver;
386
- if (t.next)
384
+ return n.prototype.next = function(t) {
385
+ var e = this.partialObserver;
386
+ if (e.next)
387
387
  try {
388
- t.next(e);
388
+ e.next(t);
389
389
  } catch (r) {
390
- $(r);
390
+ D(r);
391
391
  }
392
- }, n.prototype.error = function(e) {
393
- var t = this.partialObserver;
394
- if (t.error)
392
+ }, n.prototype.error = function(t) {
393
+ var e = this.partialObserver;
394
+ if (e.error)
395
395
  try {
396
- t.error(e);
396
+ e.error(t);
397
397
  } catch (r) {
398
- $(r);
398
+ D(r);
399
399
  }
400
400
  else
401
- $(e);
401
+ D(t);
402
402
  }, n.prototype.complete = function() {
403
- var e = this.partialObserver;
404
- if (e.complete)
403
+ var t = this.partialObserver;
404
+ if (t.complete)
405
405
  try {
406
- e.complete();
407
- } catch (t) {
408
- $(t);
406
+ t.complete();
407
+ } catch (e) {
408
+ D(e);
409
409
  }
410
410
  }, n;
411
- })(), X = (function(n) {
412
- I(e, n);
413
- function e(t, r, o) {
414
- var i = n.call(this) || this, s;
415
- return m(t) || !t ? s = {
416
- next: t ?? void 0,
411
+ })(), Q = (function(n) {
412
+ w(t, n);
413
+ function t(e, r, s) {
414
+ var o = n.call(this) || this, i;
415
+ return m(e) || !e ? i = {
416
+ next: e ?? void 0,
417
417
  error: r ?? void 0,
418
- complete: o ?? void 0
419
- } : s = t, i.destination = new Ye(s), i;
418
+ complete: s ?? void 0
419
+ } : i = e, o.destination = new Xe(i), o;
420
420
  }
421
- return e;
422
- })(Q);
423
- function $(n) {
424
- me(n);
421
+ return t;
422
+ })(ne);
423
+ function D(n) {
424
+ Ie(n);
425
425
  }
426
- function qe(n) {
426
+ function ze(n) {
427
427
  throw n;
428
428
  }
429
- var We = {
429
+ var Je = {
430
430
  closed: !0,
431
- next: W,
432
- error: qe,
433
- complete: W
434
- }, Z = (function() {
431
+ next: J,
432
+ error: ze,
433
+ complete: J
434
+ }, re = (function() {
435
435
  return typeof Symbol == "function" && Symbol.observable || "@@observable";
436
436
  })();
437
- function F(n) {
437
+ function q(n) {
438
438
  return n;
439
439
  }
440
- function Xe(n) {
441
- return n.length === 0 ? F : n.length === 1 ? n[0] : function(t) {
442
- return n.reduce(function(r, o) {
443
- return o(r);
444
- }, t);
440
+ function Qe(n) {
441
+ return n.length === 0 ? q : n.length === 1 ? n[0] : function(e) {
442
+ return n.reduce(function(r, s) {
443
+ return s(r);
444
+ }, e);
445
445
  };
446
446
  }
447
- var g = (function() {
448
- function n(e) {
449
- e && (this._subscribe = e);
447
+ var S = (function() {
448
+ function n(t) {
449
+ t && (this._subscribe = t);
450
450
  }
451
- return n.prototype.lift = function(e) {
452
- var t = new n();
453
- return t.source = this, t.operator = e, t;
454
- }, n.prototype.subscribe = function(e, t, r) {
455
- var o = this, i = Je(e) ? e : new X(e, t, r);
456
- return D(function() {
457
- var s = o, a = s.operator, c = s.source;
458
- i.add(a ? a.call(i, c) : c ? o._subscribe(i) : o._trySubscribe(i));
459
- }), i;
460
- }, n.prototype._trySubscribe = function(e) {
451
+ return n.prototype.lift = function(t) {
452
+ var e = new n();
453
+ return e.source = this, e.operator = t, e;
454
+ }, n.prototype.subscribe = function(t, e, r) {
455
+ var s = this, o = et(t) ? t : new Q(t, e, r);
456
+ return G(function() {
457
+ var i = s, a = i.operator, u = i.source;
458
+ o.add(a ? a.call(o, u) : u ? s._subscribe(o) : s._trySubscribe(o));
459
+ }), o;
460
+ }, n.prototype._trySubscribe = function(t) {
461
461
  try {
462
- return this._subscribe(e);
463
- } catch (t) {
464
- e.error(t);
462
+ return this._subscribe(t);
463
+ } catch (e) {
464
+ t.error(e);
465
465
  }
466
- }, n.prototype.forEach = function(e, t) {
466
+ }, n.prototype.forEach = function(t, e) {
467
467
  var r = this;
468
- return t = re(t), new t(function(o, i) {
469
- var s = new X({
468
+ return e = ae(e), new e(function(s, o) {
469
+ var i = new Q({
470
470
  next: function(a) {
471
471
  try {
472
- e(a);
473
- } catch (c) {
474
- i(c), s.unsubscribe();
472
+ t(a);
473
+ } catch (u) {
474
+ o(u), i.unsubscribe();
475
475
  }
476
476
  },
477
- error: i,
478
- complete: o
477
+ error: o,
478
+ complete: s
479
479
  });
480
- r.subscribe(s);
480
+ r.subscribe(i);
481
481
  });
482
- }, n.prototype._subscribe = function(e) {
483
- var t;
484
- return (t = this.source) === null || t === void 0 ? void 0 : t.subscribe(e);
485
- }, n.prototype[Z] = function() {
482
+ }, n.prototype._subscribe = function(t) {
483
+ var e;
484
+ return (e = this.source) === null || e === void 0 ? void 0 : e.subscribe(t);
485
+ }, n.prototype[re] = function() {
486
486
  return this;
487
487
  }, n.prototype.pipe = function() {
488
- for (var e = [], t = 0; t < arguments.length; t++)
489
- e[t] = arguments[t];
490
- return Xe(e)(this);
491
- }, n.prototype.toPromise = function(e) {
492
- var t = this;
493
- return e = re(e), new e(function(r, o) {
494
- var i;
495
- t.subscribe(function(s) {
496
- return i = s;
497
- }, function(s) {
498
- return o(s);
488
+ for (var t = [], e = 0; e < arguments.length; e++)
489
+ t[e] = arguments[e];
490
+ return Qe(t)(this);
491
+ }, n.prototype.toPromise = function(t) {
492
+ var e = this;
493
+ return t = ae(t), new t(function(r, s) {
494
+ var o;
495
+ e.subscribe(function(i) {
496
+ return o = i;
497
+ }, function(i) {
498
+ return s(i);
499
499
  }, function() {
500
- return r(i);
500
+ return r(o);
501
501
  });
502
502
  });
503
- }, n.create = function(e) {
504
- return new n(e);
503
+ }, n.create = function(t) {
504
+ return new n(t);
505
505
  }, n;
506
506
  })();
507
- function re(n) {
508
- var e;
509
- return (e = n ?? Ve.Promise) !== null && e !== void 0 ? e : Promise;
507
+ function ae(n) {
508
+ var t;
509
+ return (t = n ?? Ye.Promise) !== null && t !== void 0 ? t : Promise;
510
510
  }
511
- function ze(n) {
511
+ function Ze(n) {
512
512
  return n && m(n.next) && m(n.error) && m(n.complete);
513
513
  }
514
- function Je(n) {
515
- return n && n instanceof Q || ze(n) && ye(n);
514
+ function et(n) {
515
+ return n && n instanceof ne || Ze(n) && Se(n);
516
516
  }
517
- function Qe(n) {
517
+ function tt(n) {
518
518
  return m(n?.lift);
519
519
  }
520
- function L(n) {
521
- return function(e) {
522
- if (Qe(e))
523
- return e.lift(function(t) {
520
+ function M(n) {
521
+ return function(t) {
522
+ if (tt(t))
523
+ return t.lift(function(e) {
524
524
  try {
525
- return n(t, this);
525
+ return n(e, this);
526
526
  } catch (r) {
527
527
  this.error(r);
528
528
  }
@@ -530,820 +530,800 @@ function L(n) {
530
530
  throw new TypeError("Unable to lift unknown Observable type");
531
531
  };
532
532
  }
533
- function O(n, e, t, r, o) {
534
- return new Ze(n, e, t, r, o);
533
+ function O(n, t, e, r, s) {
534
+ return new nt(n, t, e, r, s);
535
535
  }
536
- var Ze = (function(n) {
537
- I(e, n);
538
- function e(t, r, o, i, s, a) {
539
- var c = n.call(this, t) || this;
540
- return c.onFinalize = s, c.shouldUnsubscribe = a, c._next = r ? function(u) {
536
+ var nt = (function(n) {
537
+ w(t, n);
538
+ function t(e, r, s, o, i, a) {
539
+ var u = n.call(this, e) || this;
540
+ return u.onFinalize = i, u.shouldUnsubscribe = a, u._next = r ? function(c) {
541
541
  try {
542
- r(u);
543
- } catch (f) {
544
- t.error(f);
542
+ r(c);
543
+ } catch (h) {
544
+ e.error(h);
545
545
  }
546
- } : n.prototype._next, c._error = i ? function(u) {
546
+ } : n.prototype._next, u._error = o ? function(c) {
547
547
  try {
548
- i(u);
549
- } catch (f) {
550
- t.error(f);
548
+ o(c);
549
+ } catch (h) {
550
+ e.error(h);
551
551
  } finally {
552
552
  this.unsubscribe();
553
553
  }
554
- } : n.prototype._error, c._complete = o ? function() {
554
+ } : n.prototype._error, u._complete = s ? function() {
555
555
  try {
556
- o();
557
- } catch (u) {
558
- t.error(u);
556
+ s();
557
+ } catch (c) {
558
+ e.error(c);
559
559
  } finally {
560
560
  this.unsubscribe();
561
561
  }
562
- } : n.prototype._complete, c;
562
+ } : n.prototype._complete, u;
563
563
  }
564
- return e.prototype.unsubscribe = function() {
565
- var t;
564
+ return t.prototype.unsubscribe = function() {
565
+ var e;
566
566
  if (!this.shouldUnsubscribe || this.shouldUnsubscribe()) {
567
567
  var r = this.closed;
568
- n.prototype.unsubscribe.call(this), !r && ((t = this.onFinalize) === null || t === void 0 || t.call(this));
568
+ n.prototype.unsubscribe.call(this), !r && ((e = this.onFinalize) === null || e === void 0 || e.call(this));
569
569
  }
570
- }, e;
571
- })(Q), et = pe(function(n) {
570
+ }, t;
571
+ })(ne), rt = ye(function(n) {
572
572
  return function() {
573
573
  n(this), this.name = "ObjectUnsubscribedError", this.message = "object unsubscribed";
574
574
  };
575
- }), ee = (function(n) {
576
- I(e, n);
577
- function e() {
578
- var t = n.call(this) || this;
579
- return t.closed = !1, t.currentObservers = null, t.observers = [], t.isStopped = !1, t.hasError = !1, t.thrownError = null, t;
575
+ }), se = (function(n) {
576
+ w(t, n);
577
+ function t() {
578
+ var e = n.call(this) || this;
579
+ return e.closed = !1, e.currentObservers = null, e.observers = [], e.isStopped = !1, e.hasError = !1, e.thrownError = null, e;
580
580
  }
581
- return e.prototype.lift = function(t) {
582
- var r = new oe(this, this);
583
- return r.operator = t, r;
584
- }, e.prototype._throwIfClosed = function() {
581
+ return t.prototype.lift = function(e) {
582
+ var r = new ce(this, this);
583
+ return r.operator = e, r;
584
+ }, t.prototype._throwIfClosed = function() {
585
585
  if (this.closed)
586
- throw new et();
587
- }, e.prototype.next = function(t) {
586
+ throw new rt();
587
+ }, t.prototype.next = function(e) {
588
588
  var r = this;
589
- D(function() {
590
- var o, i;
589
+ G(function() {
590
+ var s, o;
591
591
  if (r._throwIfClosed(), !r.isStopped) {
592
592
  r.currentObservers || (r.currentObservers = Array.from(r.observers));
593
593
  try {
594
- for (var s = P(r.currentObservers), a = s.next(); !a.done; a = s.next()) {
595
- var c = a.value;
596
- c.next(t);
594
+ for (var i = k(r.currentObservers), a = i.next(); !a.done; a = i.next()) {
595
+ var u = a.value;
596
+ u.next(e);
597
597
  }
598
- } catch (u) {
599
- o = { error: u };
598
+ } catch (c) {
599
+ s = { error: c };
600
600
  } finally {
601
601
  try {
602
- a && !a.done && (i = s.return) && i.call(s);
602
+ a && !a.done && (o = i.return) && o.call(i);
603
603
  } finally {
604
- if (o) throw o.error;
604
+ if (s) throw s.error;
605
605
  }
606
606
  }
607
607
  }
608
608
  });
609
- }, e.prototype.error = function(t) {
609
+ }, t.prototype.error = function(e) {
610
610
  var r = this;
611
- D(function() {
611
+ G(function() {
612
612
  if (r._throwIfClosed(), !r.isStopped) {
613
- r.hasError = r.isStopped = !0, r.thrownError = t;
614
- for (var o = r.observers; o.length; )
615
- o.shift().error(t);
613
+ r.hasError = r.isStopped = !0, r.thrownError = e;
614
+ for (var s = r.observers; s.length; )
615
+ s.shift().error(e);
616
616
  }
617
617
  });
618
- }, e.prototype.complete = function() {
619
- var t = this;
620
- D(function() {
621
- if (t._throwIfClosed(), !t.isStopped) {
622
- t.isStopped = !0;
623
- for (var r = t.observers; r.length; )
618
+ }, t.prototype.complete = function() {
619
+ var e = this;
620
+ G(function() {
621
+ if (e._throwIfClosed(), !e.isStopped) {
622
+ e.isStopped = !0;
623
+ for (var r = e.observers; r.length; )
624
624
  r.shift().complete();
625
625
  }
626
626
  });
627
- }, e.prototype.unsubscribe = function() {
627
+ }, t.prototype.unsubscribe = function() {
628
628
  this.isStopped = this.closed = !0, this.observers = this.currentObservers = null;
629
- }, Object.defineProperty(e.prototype, "observed", {
629
+ }, Object.defineProperty(t.prototype, "observed", {
630
630
  get: function() {
631
- var t;
632
- return ((t = this.observers) === null || t === void 0 ? void 0 : t.length) > 0;
631
+ var e;
632
+ return ((e = this.observers) === null || e === void 0 ? void 0 : e.length) > 0;
633
633
  },
634
634
  enumerable: !1,
635
635
  configurable: !0
636
- }), e.prototype._trySubscribe = function(t) {
637
- return this._throwIfClosed(), n.prototype._trySubscribe.call(this, t);
638
- }, e.prototype._subscribe = function(t) {
639
- return this._throwIfClosed(), this._checkFinalizedStatuses(t), this._innerSubscribe(t);
640
- }, e.prototype._innerSubscribe = function(t) {
641
- var r = this, o = this, i = o.hasError, s = o.isStopped, a = o.observers;
642
- return i || s ? ve : (this.currentObservers = null, a.push(t), new N(function() {
643
- r.currentObservers = null, j(a, t);
636
+ }), t.prototype._trySubscribe = function(e) {
637
+ return this._throwIfClosed(), n.prototype._trySubscribe.call(this, e);
638
+ }, t.prototype._subscribe = function(e) {
639
+ return this._throwIfClosed(), this._checkFinalizedStatuses(e), this._innerSubscribe(e);
640
+ }, t.prototype._innerSubscribe = function(e) {
641
+ var r = this, s = this, o = s.hasError, i = s.isStopped, a = s.observers;
642
+ return o || i ? be : (this.currentObservers = null, a.push(e), new U(function() {
643
+ r.currentObservers = null, F(a, e);
644
644
  }));
645
- }, e.prototype._checkFinalizedStatuses = function(t) {
646
- var r = this, o = r.hasError, i = r.thrownError, s = r.isStopped;
647
- o ? t.error(i) : s && t.complete();
648
- }, e.prototype.asObservable = function() {
649
- var t = new g();
650
- return t.source = this, t;
651
- }, e.create = function(t, r) {
652
- return new oe(t, r);
653
- }, e;
654
- })(g), oe = (function(n) {
655
- I(e, n);
656
- function e(t, r) {
657
- var o = n.call(this) || this;
658
- return o.destination = t, o.source = r, o;
659
- }
660
- return e.prototype.next = function(t) {
661
- var r, o;
662
- (o = (r = this.destination) === null || r === void 0 ? void 0 : r.next) === null || o === void 0 || o.call(r, t);
663
- }, e.prototype.error = function(t) {
664
- var r, o;
665
- (o = (r = this.destination) === null || r === void 0 ? void 0 : r.error) === null || o === void 0 || o.call(r, t);
666
- }, e.prototype.complete = function() {
667
- var t, r;
668
- (r = (t = this.destination) === null || t === void 0 ? void 0 : t.complete) === null || r === void 0 || r.call(t);
669
- }, e.prototype._subscribe = function(t) {
670
- var r, o;
671
- return (o = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(t)) !== null && o !== void 0 ? o : ve;
672
- }, e;
673
- })(ee), ie = (function(n) {
674
- I(e, n);
675
- function e(t) {
645
+ }, t.prototype._checkFinalizedStatuses = function(e) {
646
+ var r = this, s = r.hasError, o = r.thrownError, i = r.isStopped;
647
+ s ? e.error(o) : i && e.complete();
648
+ }, t.prototype.asObservable = function() {
649
+ var e = new S();
650
+ return e.source = this, e;
651
+ }, t.create = function(e, r) {
652
+ return new ce(e, r);
653
+ }, t;
654
+ })(S), ce = (function(n) {
655
+ w(t, n);
656
+ function t(e, r) {
657
+ var s = n.call(this) || this;
658
+ return s.destination = e, s.source = r, s;
659
+ }
660
+ return t.prototype.next = function(e) {
661
+ var r, s;
662
+ (s = (r = this.destination) === null || r === void 0 ? void 0 : r.next) === null || s === void 0 || s.call(r, e);
663
+ }, t.prototype.error = function(e) {
664
+ var r, s;
665
+ (s = (r = this.destination) === null || r === void 0 ? void 0 : r.error) === null || s === void 0 || s.call(r, e);
666
+ }, t.prototype.complete = function() {
667
+ var e, r;
668
+ (r = (e = this.destination) === null || e === void 0 ? void 0 : e.complete) === null || r === void 0 || r.call(e);
669
+ }, t.prototype._subscribe = function(e) {
670
+ var r, s;
671
+ return (s = (r = this.source) === null || r === void 0 ? void 0 : r.subscribe(e)) !== null && s !== void 0 ? s : be;
672
+ }, t;
673
+ })(se), N = (function(n) {
674
+ w(t, n);
675
+ function t(e) {
676
676
  var r = n.call(this) || this;
677
- return r._value = t, r;
677
+ return r._value = e, r;
678
678
  }
679
- return Object.defineProperty(e.prototype, "value", {
679
+ return Object.defineProperty(t.prototype, "value", {
680
680
  get: function() {
681
681
  return this.getValue();
682
682
  },
683
683
  enumerable: !1,
684
684
  configurable: !0
685
- }), e.prototype._subscribe = function(t) {
686
- var r = n.prototype._subscribe.call(this, t);
687
- return !r.closed && t.next(this._value), r;
688
- }, e.prototype.getValue = function() {
689
- var t = this, r = t.hasError, o = t.thrownError, i = t._value;
685
+ }), t.prototype._subscribe = function(e) {
686
+ var r = n.prototype._subscribe.call(this, e);
687
+ return !r.closed && e.next(this._value), r;
688
+ }, t.prototype.getValue = function() {
689
+ var e = this, r = e.hasError, s = e.thrownError, o = e._value;
690
690
  if (r)
691
- throw o;
692
- return this._throwIfClosed(), i;
693
- }, e.prototype.next = function(t) {
694
- n.prototype.next.call(this, this._value = t);
695
- }, e;
696
- })(ee), tt = {
691
+ throw s;
692
+ return this._throwIfClosed(), o;
693
+ }, t.prototype.next = function(e) {
694
+ n.prototype.next.call(this, this._value = e);
695
+ }, t;
696
+ })(se), st = {
697
697
  now: function() {
698
698
  return Date.now();
699
699
  }
700
- }, nt = (function(n) {
701
- I(e, n);
702
- function e(t, r) {
700
+ }, ot = (function(n) {
701
+ w(t, n);
702
+ function t(e, r) {
703
703
  return n.call(this) || this;
704
704
  }
705
- return e.prototype.schedule = function(t, r) {
705
+ return t.prototype.schedule = function(e, r) {
706
706
  return this;
707
- }, e;
708
- })(N), se = {
709
- setInterval: function(n, e) {
710
- for (var t = [], r = 2; r < arguments.length; r++)
711
- t[r - 2] = arguments[r];
712
- return setInterval.apply(void 0, R([n, e], M(t)));
707
+ }, t;
708
+ })(U), ue = {
709
+ setInterval: function(n, t) {
710
+ for (var e = [], r = 2; r < arguments.length; r++)
711
+ e[r - 2] = arguments[r];
712
+ return setInterval.apply(void 0, $([n, t], R(e)));
713
713
  },
714
714
  clearInterval: function(n) {
715
715
  return clearInterval(n);
716
716
  },
717
717
  delegate: void 0
718
- }, rt = (function(n) {
719
- I(e, n);
720
- function e(t, r) {
721
- var o = n.call(this, t, r) || this;
722
- return o.scheduler = t, o.work = r, o.pending = !1, o;
723
- }
724
- return e.prototype.schedule = function(t, r) {
725
- var o;
718
+ }, it = (function(n) {
719
+ w(t, n);
720
+ function t(e, r) {
721
+ var s = n.call(this, e, r) || this;
722
+ return s.scheduler = e, s.work = r, s.pending = !1, s;
723
+ }
724
+ return t.prototype.schedule = function(e, r) {
725
+ var s;
726
726
  if (r === void 0 && (r = 0), this.closed)
727
727
  return this;
728
- this.state = t;
729
- var i = this.id, s = this.scheduler;
730
- return i != null && (this.id = this.recycleAsyncId(s, i, r)), this.pending = !0, this.delay = r, this.id = (o = this.id) !== null && o !== void 0 ? o : this.requestAsyncId(s, this.id, r), this;
731
- }, e.prototype.requestAsyncId = function(t, r, o) {
732
- return o === void 0 && (o = 0), se.setInterval(t.flush.bind(t, this), o);
733
- }, e.prototype.recycleAsyncId = function(t, r, o) {
734
- if (o === void 0 && (o = 0), o != null && this.delay === o && this.pending === !1)
728
+ this.state = e;
729
+ var o = this.id, i = this.scheduler;
730
+ return o != null && (this.id = this.recycleAsyncId(i, o, r)), this.pending = !0, this.delay = r, this.id = (s = this.id) !== null && s !== void 0 ? s : this.requestAsyncId(i, this.id, r), this;
731
+ }, t.prototype.requestAsyncId = function(e, r, s) {
732
+ return s === void 0 && (s = 0), ue.setInterval(e.flush.bind(e, this), s);
733
+ }, t.prototype.recycleAsyncId = function(e, r, s) {
734
+ if (s === void 0 && (s = 0), s != null && this.delay === s && this.pending === !1)
735
735
  return r;
736
- r != null && se.clearInterval(r);
737
- }, e.prototype.execute = function(t, r) {
736
+ r != null && ue.clearInterval(r);
737
+ }, t.prototype.execute = function(e, r) {
738
738
  if (this.closed)
739
739
  return new Error("executing a cancelled action");
740
740
  this.pending = !1;
741
- var o = this._execute(t, r);
742
- if (o)
743
- return o;
741
+ var s = this._execute(e, r);
742
+ if (s)
743
+ return s;
744
744
  this.pending === !1 && this.id != null && (this.id = this.recycleAsyncId(this.scheduler, this.id, null));
745
- }, e.prototype._execute = function(t, r) {
746
- var o = !1, i;
745
+ }, t.prototype._execute = function(e, r) {
746
+ var s = !1, o;
747
747
  try {
748
- this.work(t);
749
- } catch (s) {
750
- o = !0, i = s || new Error("Scheduled action threw falsy error");
748
+ this.work(e);
749
+ } catch (i) {
750
+ s = !0, o = i || new Error("Scheduled action threw falsy error");
751
751
  }
752
- if (o)
753
- return this.unsubscribe(), i;
754
- }, e.prototype.unsubscribe = function() {
752
+ if (s)
753
+ return this.unsubscribe(), o;
754
+ }, t.prototype.unsubscribe = function() {
755
755
  if (!this.closed) {
756
- var t = this, r = t.id, o = t.scheduler, i = o.actions;
757
- this.work = this.state = this.scheduler = null, this.pending = !1, j(i, this), r != null && (this.id = this.recycleAsyncId(o, r, null)), this.delay = null, n.prototype.unsubscribe.call(this);
756
+ var e = this, r = e.id, s = e.scheduler, o = s.actions;
757
+ this.work = this.state = this.scheduler = null, this.pending = !1, F(o, this), r != null && (this.id = this.recycleAsyncId(s, r, null)), this.delay = null, n.prototype.unsubscribe.call(this);
758
758
  }
759
- }, e;
760
- })(nt), ae = (function() {
761
- function n(e, t) {
762
- t === void 0 && (t = n.now), this.schedulerActionCtor = e, this.now = t;
763
- }
764
- return n.prototype.schedule = function(e, t, r) {
765
- return t === void 0 && (t = 0), new this.schedulerActionCtor(this, e).schedule(r, t);
766
- }, n.now = tt.now, n;
767
- })(), ot = (function(n) {
768
- I(e, n);
769
- function e(t, r) {
770
- r === void 0 && (r = ae.now);
771
- var o = n.call(this, t, r) || this;
772
- return o.actions = [], o._active = !1, o;
773
- }
774
- return e.prototype.flush = function(t) {
759
+ }, t;
760
+ })(ot), le = (function() {
761
+ function n(t, e) {
762
+ e === void 0 && (e = n.now), this.schedulerActionCtor = t, this.now = e;
763
+ }
764
+ return n.prototype.schedule = function(t, e, r) {
765
+ return e === void 0 && (e = 0), new this.schedulerActionCtor(this, t).schedule(r, e);
766
+ }, n.now = st.now, n;
767
+ })(), at = (function(n) {
768
+ w(t, n);
769
+ function t(e, r) {
770
+ r === void 0 && (r = le.now);
771
+ var s = n.call(this, e, r) || this;
772
+ return s.actions = [], s._active = !1, s;
773
+ }
774
+ return t.prototype.flush = function(e) {
775
775
  var r = this.actions;
776
776
  if (this._active) {
777
- r.push(t);
777
+ r.push(e);
778
778
  return;
779
779
  }
780
- var o;
780
+ var s;
781
781
  this._active = !0;
782
782
  do
783
- if (o = t.execute(t.state, t.delay))
783
+ if (s = e.execute(e.state, e.delay))
784
784
  break;
785
- while (t = r.shift());
786
- if (this._active = !1, o) {
787
- for (; t = r.shift(); )
788
- t.unsubscribe();
789
- throw o;
785
+ while (e = r.shift());
786
+ if (this._active = !1, s) {
787
+ for (; e = r.shift(); )
788
+ e.unsubscribe();
789
+ throw s;
790
790
  }
791
- }, e;
792
- })(ae), be = new ot(rt), it = be, st = new g(function(n) {
791
+ }, t;
792
+ })(le), Ee = new at(it), ct = Ee, ut = new S(function(n) {
793
793
  return n.complete();
794
794
  });
795
- function ge(n) {
795
+ function we(n) {
796
796
  return n && m(n.schedule);
797
797
  }
798
- function Se(n) {
798
+ function Te(n) {
799
799
  return n[n.length - 1];
800
800
  }
801
- function at(n) {
802
- return m(Se(n)) ? n.pop() : void 0;
801
+ function lt(n) {
802
+ return m(Te(n)) ? n.pop() : void 0;
803
803
  }
804
- function we(n) {
805
- return ge(Se(n)) ? n.pop() : void 0;
804
+ function Ce(n) {
805
+ return we(Te(n)) ? n.pop() : void 0;
806
806
  }
807
- var Ee = (function(n) {
807
+ var Oe = (function(n) {
808
808
  return n && typeof n.length == "number" && typeof n != "function";
809
809
  });
810
- function Oe(n) {
810
+ function Ae(n) {
811
811
  return m(n?.then);
812
812
  }
813
- function Ie(n) {
814
- return m(n[Z]);
813
+ function _e(n) {
814
+ return m(n[re]);
815
815
  }
816
- function Ce(n) {
816
+ function Me(n) {
817
817
  return Symbol.asyncIterator && m(n?.[Symbol.asyncIterator]);
818
818
  }
819
- function Ae(n) {
819
+ function xe(n) {
820
820
  return new TypeError("You provided " + (n !== null && typeof n == "object" ? "an invalid object" : "'" + n + "'") + " where a stream was expected. You can provide an Observable, Promise, ReadableStream, Array, AsyncIterable, or Iterable.");
821
821
  }
822
- function ct() {
822
+ function dt() {
823
823
  return typeof Symbol != "function" || !Symbol.iterator ? "@@iterator" : Symbol.iterator;
824
824
  }
825
- var Te = ct();
826
- function _e(n) {
827
- return m(n?.[Te]);
825
+ var Le = dt();
826
+ function ke(n) {
827
+ return m(n?.[Le]);
828
828
  }
829
- function Le(n) {
830
- return Ge(this, arguments, function() {
831
- var t, r, o, i;
832
- return he(this, function(s) {
833
- switch (s.label) {
829
+ function Pe(n) {
830
+ return qe(this, arguments, function() {
831
+ var e, r, s, o;
832
+ return ve(this, function(i) {
833
+ switch (i.label) {
834
834
  case 0:
835
- t = n.getReader(), s.label = 1;
835
+ e = n.getReader(), i.label = 1;
836
836
  case 1:
837
- s.trys.push([1, , 9, 10]), s.label = 2;
837
+ i.trys.push([1, , 9, 10]), i.label = 2;
838
838
  case 2:
839
- return [4, x(t.read())];
839
+ return [4, L(e.read())];
840
840
  case 3:
841
- return r = s.sent(), o = r.value, i = r.done, i ? [4, x(void 0)] : [3, 5];
841
+ return r = i.sent(), s = r.value, o = r.done, o ? [4, L(void 0)] : [3, 5];
842
842
  case 4:
843
- return [2, s.sent()];
843
+ return [2, i.sent()];
844
844
  case 5:
845
- return [4, x(o)];
845
+ return [4, L(s)];
846
846
  case 6:
847
- return [4, s.sent()];
847
+ return [4, i.sent()];
848
848
  case 7:
849
- return s.sent(), [3, 2];
849
+ return i.sent(), [3, 2];
850
850
  case 8:
851
851
  return [3, 10];
852
852
  case 9:
853
- return t.releaseLock(), [7];
853
+ return e.releaseLock(), [7];
854
854
  case 10:
855
855
  return [2];
856
856
  }
857
857
  });
858
858
  });
859
859
  }
860
- function xe(n) {
860
+ function Ue(n) {
861
861
  return m(n?.getReader);
862
862
  }
863
- function T(n) {
864
- if (n instanceof g)
863
+ function x(n) {
864
+ if (n instanceof S)
865
865
  return n;
866
866
  if (n != null) {
867
- if (Ie(n))
868
- return ut(n);
869
- if (Ee(n))
870
- return lt(n);
871
- if (Oe(n))
872
- return ft(n);
873
- if (Ce(n))
874
- return Pe(n);
875
867
  if (_e(n))
876
- return dt(n);
877
- if (xe(n))
878
868
  return ht(n);
869
+ if (Oe(n))
870
+ return ft(n);
871
+ if (Ae(n))
872
+ return pt(n);
873
+ if (Me(n))
874
+ return Ne(n);
875
+ if (ke(n))
876
+ return gt(n);
877
+ if (Ue(n))
878
+ return mt(n);
879
879
  }
880
- throw Ae(n);
880
+ throw xe(n);
881
881
  }
882
- function ut(n) {
883
- return new g(function(e) {
884
- var t = n[Z]();
885
- if (m(t.subscribe))
886
- return t.subscribe(e);
882
+ function ht(n) {
883
+ return new S(function(t) {
884
+ var e = n[re]();
885
+ if (m(e.subscribe))
886
+ return e.subscribe(t);
887
887
  throw new TypeError("Provided object does not correctly implement Symbol.observable");
888
888
  });
889
889
  }
890
- function lt(n) {
891
- return new g(function(e) {
892
- for (var t = 0; t < n.length && !e.closed; t++)
893
- e.next(n[t]);
894
- e.complete();
890
+ function ft(n) {
891
+ return new S(function(t) {
892
+ for (var e = 0; e < n.length && !t.closed; e++)
893
+ t.next(n[e]);
894
+ t.complete();
895
895
  });
896
896
  }
897
- function ft(n) {
898
- return new g(function(e) {
899
- n.then(function(t) {
900
- e.closed || (e.next(t), e.complete());
901
- }, function(t) {
902
- return e.error(t);
903
- }).then(null, me);
897
+ function pt(n) {
898
+ return new S(function(t) {
899
+ n.then(function(e) {
900
+ t.closed || (t.next(e), t.complete());
901
+ }, function(e) {
902
+ return t.error(e);
903
+ }).then(null, Ie);
904
904
  });
905
905
  }
906
- function dt(n) {
907
- return new g(function(e) {
908
- var t, r;
906
+ function gt(n) {
907
+ return new S(function(t) {
908
+ var e, r;
909
909
  try {
910
- for (var o = P(n), i = o.next(); !i.done; i = o.next()) {
911
- var s = i.value;
912
- if (e.next(s), e.closed)
910
+ for (var s = k(n), o = s.next(); !o.done; o = s.next()) {
911
+ var i = o.value;
912
+ if (t.next(i), t.closed)
913
913
  return;
914
914
  }
915
915
  } catch (a) {
916
- t = { error: a };
916
+ e = { error: a };
917
917
  } finally {
918
918
  try {
919
- i && !i.done && (r = o.return) && r.call(o);
919
+ o && !o.done && (r = s.return) && r.call(s);
920
920
  } finally {
921
- if (t) throw t.error;
921
+ if (e) throw e.error;
922
922
  }
923
923
  }
924
- e.complete();
924
+ t.complete();
925
925
  });
926
926
  }
927
- function Pe(n) {
928
- return new g(function(e) {
929
- pt(n, e).catch(function(t) {
930
- return e.error(t);
927
+ function Ne(n) {
928
+ return new S(function(t) {
929
+ vt(n, t).catch(function(e) {
930
+ return t.error(e);
931
931
  });
932
932
  });
933
933
  }
934
- function ht(n) {
935
- return Pe(Le(n));
936
- }
937
- function pt(n, e) {
938
- var t, r, o, i;
939
- return Fe(this, void 0, void 0, function() {
940
- var s, a;
941
- return he(this, function(c) {
942
- switch (c.label) {
934
+ function mt(n) {
935
+ return Ne(Pe(n));
936
+ }
937
+ function vt(n, t) {
938
+ var e, r, s, o;
939
+ return Be(this, void 0, void 0, function() {
940
+ var i, a;
941
+ return ve(this, function(u) {
942
+ switch (u.label) {
943
943
  case 0:
944
- c.trys.push([0, 5, 6, 11]), t = Ke(n), c.label = 1;
944
+ u.trys.push([0, 5, 6, 11]), e = Ve(n), u.label = 1;
945
945
  case 1:
946
- return [4, t.next()];
946
+ return [4, e.next()];
947
947
  case 2:
948
- if (r = c.sent(), !!r.done) return [3, 4];
949
- if (s = r.value, e.next(s), e.closed)
948
+ if (r = u.sent(), !!r.done) return [3, 4];
949
+ if (i = r.value, t.next(i), t.closed)
950
950
  return [2];
951
- c.label = 3;
951
+ u.label = 3;
952
952
  case 3:
953
953
  return [3, 1];
954
954
  case 4:
955
955
  return [3, 11];
956
956
  case 5:
957
- return a = c.sent(), o = { error: a }, [3, 11];
957
+ return a = u.sent(), s = { error: a }, [3, 11];
958
958
  case 6:
959
- return c.trys.push([6, , 9, 10]), r && !r.done && (i = t.return) ? [4, i.call(t)] : [3, 8];
959
+ return u.trys.push([6, , 9, 10]), r && !r.done && (o = e.return) ? [4, o.call(e)] : [3, 8];
960
960
  case 7:
961
- c.sent(), c.label = 8;
961
+ u.sent(), u.label = 8;
962
962
  case 8:
963
963
  return [3, 10];
964
964
  case 9:
965
- if (o) throw o.error;
965
+ if (s) throw s.error;
966
966
  return [7];
967
967
  case 10:
968
968
  return [7];
969
969
  case 11:
970
- return e.complete(), [2];
970
+ return t.complete(), [2];
971
971
  }
972
972
  });
973
973
  });
974
974
  }
975
- function A(n, e, t, r, o) {
976
- r === void 0 && (r = 0), o === void 0 && (o = !1);
977
- var i = e.schedule(function() {
978
- t(), o ? n.add(this.schedule(null, r)) : this.unsubscribe();
975
+ function C(n, t, e, r, s) {
976
+ r === void 0 && (r = 0), s === void 0 && (s = !1);
977
+ var o = t.schedule(function() {
978
+ e(), s ? n.add(this.schedule(null, r)) : this.unsubscribe();
979
979
  }, r);
980
- if (n.add(i), !o)
981
- return i;
982
- }
983
- function Me(n, e) {
984
- return e === void 0 && (e = 0), L(function(t, r) {
985
- t.subscribe(O(r, function(o) {
986
- return A(r, n, function() {
987
- return r.next(o);
988
- }, e);
980
+ if (n.add(o), !s)
981
+ return o;
982
+ }
983
+ function Re(n, t) {
984
+ return t === void 0 && (t = 0), M(function(e, r) {
985
+ e.subscribe(O(r, function(s) {
986
+ return C(r, n, function() {
987
+ return r.next(s);
988
+ }, t);
989
989
  }, function() {
990
- return A(r, n, function() {
990
+ return C(r, n, function() {
991
991
  return r.complete();
992
- }, e);
993
- }, function(o) {
994
- return A(r, n, function() {
995
- return r.error(o);
996
- }, e);
992
+ }, t);
993
+ }, function(s) {
994
+ return C(r, n, function() {
995
+ return r.error(s);
996
+ }, t);
997
997
  }));
998
998
  });
999
999
  }
1000
- function Re(n, e) {
1001
- return e === void 0 && (e = 0), L(function(t, r) {
1000
+ function $e(n, t) {
1001
+ return t === void 0 && (t = 0), M(function(e, r) {
1002
1002
  r.add(n.schedule(function() {
1003
- return t.subscribe(r);
1004
- }, e));
1003
+ return e.subscribe(r);
1004
+ }, t));
1005
1005
  });
1006
1006
  }
1007
- function vt(n, e) {
1008
- return T(n).pipe(Re(e), Me(e));
1007
+ function yt(n, t) {
1008
+ return x(n).pipe($e(t), Re(t));
1009
1009
  }
1010
- function yt(n, e) {
1011
- return T(n).pipe(Re(e), Me(e));
1010
+ function bt(n, t) {
1011
+ return x(n).pipe($e(t), Re(t));
1012
1012
  }
1013
- function mt(n, e) {
1014
- return new g(function(t) {
1013
+ function St(n, t) {
1014
+ return new S(function(e) {
1015
1015
  var r = 0;
1016
- return e.schedule(function() {
1017
- r === n.length ? t.complete() : (t.next(n[r++]), t.closed || this.schedule());
1016
+ return t.schedule(function() {
1017
+ r === n.length ? e.complete() : (e.next(n[r++]), e.closed || this.schedule());
1018
1018
  });
1019
1019
  });
1020
1020
  }
1021
- function bt(n, e) {
1022
- return new g(function(t) {
1021
+ function It(n, t) {
1022
+ return new S(function(e) {
1023
1023
  var r;
1024
- return A(t, e, function() {
1025
- r = n[Te](), A(t, e, function() {
1026
- var o, i, s;
1024
+ return C(e, t, function() {
1025
+ r = n[Le](), C(e, t, function() {
1026
+ var s, o, i;
1027
1027
  try {
1028
- o = r.next(), i = o.value, s = o.done;
1028
+ s = r.next(), o = s.value, i = s.done;
1029
1029
  } catch (a) {
1030
- t.error(a);
1030
+ e.error(a);
1031
1031
  return;
1032
1032
  }
1033
- s ? t.complete() : t.next(i);
1033
+ i ? e.complete() : e.next(o);
1034
1034
  }, 0, !0);
1035
1035
  }), function() {
1036
1036
  return m(r?.return) && r.return();
1037
1037
  };
1038
1038
  });
1039
1039
  }
1040
- function Ne(n, e) {
1040
+ function je(n, t) {
1041
1041
  if (!n)
1042
1042
  throw new Error("Iterable cannot be null");
1043
- return new g(function(t) {
1044
- A(t, e, function() {
1043
+ return new S(function(e) {
1044
+ C(e, t, function() {
1045
1045
  var r = n[Symbol.asyncIterator]();
1046
- A(t, e, function() {
1047
- r.next().then(function(o) {
1048
- o.done ? t.complete() : t.next(o.value);
1046
+ C(e, t, function() {
1047
+ r.next().then(function(s) {
1048
+ s.done ? e.complete() : e.next(s.value);
1049
1049
  });
1050
1050
  }, 0, !0);
1051
1051
  });
1052
1052
  });
1053
1053
  }
1054
- function gt(n, e) {
1055
- return Ne(Le(n), e);
1054
+ function Et(n, t) {
1055
+ return je(Pe(n), t);
1056
1056
  }
1057
- function St(n, e) {
1057
+ function wt(n, t) {
1058
1058
  if (n != null) {
1059
- if (Ie(n))
1060
- return vt(n, e);
1061
- if (Ee(n))
1062
- return mt(n, e);
1063
- if (Oe(n))
1064
- return yt(n, e);
1065
- if (Ce(n))
1066
- return Ne(n, e);
1067
1059
  if (_e(n))
1068
- return bt(n, e);
1069
- if (xe(n))
1070
- return gt(n, e);
1071
- }
1072
- throw Ae(n);
1073
- }
1074
- function te(n, e) {
1075
- return e ? St(n, e) : T(n);
1076
- }
1077
- function wt() {
1078
- for (var n = [], e = 0; e < arguments.length; e++)
1079
- n[e] = arguments[e];
1080
- var t = we(n);
1081
- return te(n, t);
1060
+ return yt(n, t);
1061
+ if (Oe(n))
1062
+ return St(n, t);
1063
+ if (Ae(n))
1064
+ return bt(n, t);
1065
+ if (Me(n))
1066
+ return je(n, t);
1067
+ if (ke(n))
1068
+ return It(n, t);
1069
+ if (Ue(n))
1070
+ return Et(n, t);
1071
+ }
1072
+ throw xe(n);
1073
+ }
1074
+ function oe(n, t) {
1075
+ return t ? wt(n, t) : x(n);
1076
+ }
1077
+ function Tt() {
1078
+ for (var n = [], t = 0; t < arguments.length; t++)
1079
+ n[t] = arguments[t];
1080
+ var e = Ce(n);
1081
+ return oe(n, e);
1082
1082
  }
1083
- function Et(n) {
1083
+ function Ct(n) {
1084
1084
  return n instanceof Date && !isNaN(n);
1085
1085
  }
1086
- function G(n, e) {
1087
- return L(function(t, r) {
1088
- var o = 0;
1089
- t.subscribe(O(r, function(i) {
1090
- r.next(n.call(e, i, o++));
1086
+ function P(n, t) {
1087
+ return M(function(e, r) {
1088
+ var s = 0;
1089
+ e.subscribe(O(r, function(o) {
1090
+ r.next(n.call(t, o, s++));
1091
1091
  }));
1092
1092
  });
1093
1093
  }
1094
1094
  var Ot = Array.isArray;
1095
- function It(n, e) {
1096
- return Ot(e) ? n.apply(void 0, R([], M(e))) : n(e);
1095
+ function At(n, t) {
1096
+ return Ot(t) ? n.apply(void 0, $([], R(t))) : n(t);
1097
1097
  }
1098
- function Ct(n) {
1099
- return G(function(e) {
1100
- return It(n, e);
1098
+ function _t(n) {
1099
+ return P(function(t) {
1100
+ return At(n, t);
1101
1101
  });
1102
1102
  }
1103
- var At = Array.isArray, Tt = Object.getPrototypeOf, _t = Object.prototype, Lt = Object.keys;
1104
- function xt(n) {
1103
+ var Mt = Array.isArray, xt = Object.getPrototypeOf, Lt = Object.prototype, kt = Object.keys;
1104
+ function Pt(n) {
1105
1105
  if (n.length === 1) {
1106
- var e = n[0];
1107
- if (At(e))
1108
- return { args: e, keys: null };
1109
- if (Pt(e)) {
1110
- var t = Lt(e);
1106
+ var t = n[0];
1107
+ if (Mt(t))
1108
+ return { args: t, keys: null };
1109
+ if (Ut(t)) {
1110
+ var e = kt(t);
1111
1111
  return {
1112
- args: t.map(function(r) {
1113
- return e[r];
1112
+ args: e.map(function(r) {
1113
+ return t[r];
1114
1114
  }),
1115
- keys: t
1115
+ keys: e
1116
1116
  };
1117
1117
  }
1118
1118
  }
1119
1119
  return { args: n, keys: null };
1120
1120
  }
1121
- function Pt(n) {
1122
- return n && typeof n == "object" && Tt(n) === _t;
1121
+ function Ut(n) {
1122
+ return n && typeof n == "object" && xt(n) === Lt;
1123
1123
  }
1124
- function Mt(n, e) {
1125
- return n.reduce(function(t, r, o) {
1126
- return t[r] = e[o], t;
1124
+ function Nt(n, t) {
1125
+ return n.reduce(function(e, r, s) {
1126
+ return e[r] = t[s], e;
1127
1127
  }, {});
1128
1128
  }
1129
1129
  function Rt() {
1130
- for (var n = [], e = 0; e < arguments.length; e++)
1131
- n[e] = arguments[e];
1132
- var t = we(n), r = at(n), o = xt(n), i = o.args, s = o.keys;
1133
- if (i.length === 0)
1134
- return te([], t);
1135
- var a = new g(Nt(i, t, s ? function(c) {
1136
- return Mt(s, c);
1137
- } : F));
1138
- return r ? a.pipe(Ct(r)) : a;
1139
- }
1140
- function Nt(n, e, t) {
1141
- return t === void 0 && (t = F), function(r) {
1142
- ce(e, function() {
1143
- for (var o = n.length, i = new Array(o), s = o, a = o, c = function(f) {
1144
- ce(e, function() {
1145
- var p = te(n[f], e), h = !1;
1146
- p.subscribe(O(r, function(l) {
1147
- i[f] = l, h || (h = !0, a--), a || r.next(t(i.slice()));
1130
+ for (var n = [], t = 0; t < arguments.length; t++)
1131
+ n[t] = arguments[t];
1132
+ var e = Ce(n), r = lt(n), s = Pt(n), o = s.args, i = s.keys;
1133
+ if (o.length === 0)
1134
+ return oe([], e);
1135
+ var a = new S($t(o, e, i ? function(u) {
1136
+ return Nt(i, u);
1137
+ } : q));
1138
+ return r ? a.pipe(_t(r)) : a;
1139
+ }
1140
+ function $t(n, t, e) {
1141
+ return e === void 0 && (e = q), function(r) {
1142
+ de(t, function() {
1143
+ for (var s = n.length, o = new Array(s), i = s, a = s, u = function(h) {
1144
+ de(t, function() {
1145
+ var g = oe(n[h], t), v = !1;
1146
+ g.subscribe(O(r, function(l) {
1147
+ o[h] = l, v || (v = !0, a--), a || r.next(e(o.slice()));
1148
1148
  }, function() {
1149
- --s || r.complete();
1149
+ --i || r.complete();
1150
1150
  }));
1151
1151
  }, r);
1152
- }, u = 0; u < o; u++)
1153
- c(u);
1152
+ }, c = 0; c < s; c++)
1153
+ u(c);
1154
1154
  }, r);
1155
1155
  };
1156
1156
  }
1157
- function ce(n, e, t) {
1158
- n ? A(t, n, e) : e();
1159
- }
1160
- function Ut(n, e, t, r, o, i, s, a) {
1161
- var c = [], u = 0, f = 0, p = !1, h = function() {
1162
- p && !c.length && !u && e.complete();
1163
- }, l = function(v) {
1164
- return u < r ? y(v) : c.push(v);
1165
- }, y = function(v) {
1166
- u++;
1167
- var w = !1;
1168
- T(t(v, f++)).subscribe(O(e, function(E) {
1169
- e.next(E);
1157
+ function de(n, t, e) {
1158
+ n ? C(e, n, t) : t();
1159
+ }
1160
+ function jt(n, t, e, r, s, o, i, a) {
1161
+ var u = [], c = 0, h = 0, g = !1, v = function() {
1162
+ g && !u.length && !c && t.complete();
1163
+ }, l = function(p) {
1164
+ return c < r ? f(p) : u.push(p);
1165
+ }, f = function(p) {
1166
+ c++;
1167
+ var A = !1;
1168
+ x(e(p, h++)).subscribe(O(t, function(I) {
1169
+ t.next(I);
1170
1170
  }, function() {
1171
- w = !0;
1171
+ A = !0;
1172
1172
  }, void 0, function() {
1173
- if (w)
1173
+ if (A)
1174
1174
  try {
1175
- u--;
1176
- for (var E = function() {
1177
- var _ = c.shift();
1178
- s || y(_);
1179
- }; c.length && u < r; )
1180
- E();
1181
- h();
1175
+ c--;
1176
+ for (var I = function() {
1177
+ var _ = u.shift();
1178
+ i || f(_);
1179
+ }; u.length && c < r; )
1180
+ I();
1181
+ v();
1182
1182
  } catch (_) {
1183
- e.error(_);
1183
+ t.error(_);
1184
1184
  }
1185
1185
  }));
1186
1186
  };
1187
- return n.subscribe(O(e, l, function() {
1188
- p = !0, h();
1187
+ return n.subscribe(O(t, l, function() {
1188
+ g = !0, v();
1189
1189
  })), function() {
1190
1190
  };
1191
1191
  }
1192
- function H(n, e, t) {
1193
- return t === void 0 && (t = 1 / 0), m(e) ? H(function(r, o) {
1194
- return G(function(i, s) {
1195
- return e(r, i, o, s);
1196
- })(T(n(r, o)));
1197
- }, t) : (typeof e == "number" && (t = e), L(function(r, o) {
1198
- return Ut(r, o, n, t);
1192
+ function B(n, t, e) {
1193
+ return e === void 0 && (e = 1 / 0), m(t) ? B(function(r, s) {
1194
+ return P(function(o, i) {
1195
+ return t(r, o, s, i);
1196
+ })(x(n(r, s)));
1197
+ }, e) : (typeof t == "number" && (e = t), M(function(r, s) {
1198
+ return jt(r, s, n, e);
1199
1199
  }));
1200
1200
  }
1201
- function Ue(n, e, t) {
1202
- n === void 0 && (n = 0), t === void 0 && (t = it);
1201
+ function Dt(n, t, e) {
1202
+ n === void 0 && (n = 0), e === void 0 && (e = ct);
1203
1203
  var r = -1;
1204
- return e != null && (ge(e) ? t = e : r = e), new g(function(o) {
1205
- var i = Et(n) ? +n - t.now() : n;
1206
- i < 0 && (i = 0);
1207
- var s = 0;
1208
- return t.schedule(function() {
1209
- o.closed || (o.next(s++), 0 <= r ? this.schedule(void 0, r) : o.complete());
1210
- }, i);
1204
+ return t != null && (we(t) ? e = t : r = t), new S(function(s) {
1205
+ var o = Ct(n) ? +n - e.now() : n;
1206
+ o < 0 && (o = 0);
1207
+ var i = 0;
1208
+ return e.schedule(function() {
1209
+ s.closed || (s.next(i++), 0 <= r ? this.schedule(void 0, r) : s.complete());
1210
+ }, o);
1211
1211
  });
1212
1212
  }
1213
- function $t(n, e) {
1214
- return m(e) ? H(n, e, 1) : H(n, 1);
1213
+ function Ht(n, t) {
1214
+ return m(t) ? B(n, t, 1) : B(n, 1);
1215
1215
  }
1216
- function kt(n) {
1216
+ function Gt(n) {
1217
1217
  return n <= 0 ? function() {
1218
- return st;
1219
- } : L(function(e, t) {
1218
+ return ut;
1219
+ } : M(function(t, e) {
1220
1220
  var r = 0;
1221
- e.subscribe(O(t, function(o) {
1222
- ++r <= n && (t.next(o), n <= r && t.complete());
1221
+ t.subscribe(O(e, function(s) {
1222
+ ++r <= n && (e.next(s), n <= r && e.complete());
1223
1223
  }));
1224
1224
  });
1225
1225
  }
1226
- function Dt(n) {
1227
- return G(function() {
1226
+ function Kt(n) {
1227
+ return P(function() {
1228
1228
  return n;
1229
1229
  });
1230
1230
  }
1231
- function jt(n, e) {
1232
- return H(function(t, r) {
1233
- return T(n(t, r)).pipe(kt(1), Dt(t));
1231
+ function Ft(n, t) {
1232
+ return B(function(e, r) {
1233
+ return x(n(e, r)).pipe(Gt(1), Kt(e));
1234
1234
  });
1235
1235
  }
1236
- function Ht(n, e) {
1237
- e === void 0 && (e = be);
1238
- var t = Ue(n, e);
1239
- return jt(function() {
1240
- return t;
1236
+ function Bt(n, t) {
1237
+ t === void 0 && (t = Ee);
1238
+ var e = Dt(n, t);
1239
+ return Ft(function() {
1240
+ return e;
1241
1241
  });
1242
1242
  }
1243
- function Ft(n) {
1244
- var e;
1245
- e = {
1246
- count: n
1247
- };
1248
- var t = e.count, r = t === void 0 ? 1 / 0 : t, o = e.delay, i = e.resetOnSuccess, s = i === void 0 ? !1 : i;
1249
- return r <= 0 ? F : L(function(a, c) {
1250
- var u = 0, f, p = function() {
1251
- var h = !1;
1252
- f = a.subscribe(O(c, function(l) {
1253
- s && (u = 0), c.next(l);
1254
- }, void 0, function(l) {
1255
- if (u++ < r) {
1256
- var y = function() {
1257
- f ? (f.unsubscribe(), f = null, p()) : h = !0;
1258
- };
1259
- if (o != null) {
1260
- var v = typeof o == "number" ? Ue(o) : T(o(l, u)), w = O(c, function() {
1261
- w.unsubscribe(), y();
1262
- }, function() {
1263
- c.complete();
1264
- });
1265
- v.subscribe(w);
1266
- } else
1267
- y();
1268
- } else
1269
- c.error(l);
1270
- })), h && (f.unsubscribe(), f = null, p());
1271
- };
1272
- p();
1243
+ function Z(n, t) {
1244
+ return t === void 0 && (t = q), n = n ?? qt, M(function(e, r) {
1245
+ var s, o = !0;
1246
+ e.subscribe(O(r, function(i) {
1247
+ var a = t(i);
1248
+ (o || !n(s, a)) && (o = !1, s = a, r.next(i));
1249
+ }));
1273
1250
  });
1274
1251
  }
1275
- function Gt(n) {
1276
- return L(function(e, t) {
1277
- T(n).subscribe(O(t, function() {
1278
- return t.complete();
1279
- }, W)), !t.closed && e.subscribe(t);
1252
+ function qt(n, t) {
1253
+ return n === t;
1254
+ }
1255
+ function Vt(n) {
1256
+ return M(function(t, e) {
1257
+ x(n).subscribe(O(e, function() {
1258
+ return e.complete();
1259
+ }, J)), !e.closed && t.subscribe(e);
1280
1260
  });
1281
1261
  }
1282
- async function Kt(n, e) {
1283
- const t = n.getReader();
1262
+ async function Yt(n, t) {
1263
+ const e = n.getReader();
1284
1264
  let r;
1285
- for (; !(r = await t.read()).done; )
1286
- e(r.value);
1287
- }
1288
- function Vt(n) {
1289
- let e, t, r, o = !1;
1290
- return function(s) {
1291
- e === void 0 ? (e = s, t = 0, r = -1) : e = Yt(e, s);
1292
- const a = e.length;
1293
- let c = 0;
1294
- for (; t < a; ) {
1295
- o && (e[t] === 10 && (c = ++t), o = !1);
1296
- let u = -1;
1297
- for (; t < a && u === -1; ++t)
1298
- switch (e[t]) {
1265
+ for (; !(r = await e.read()).done; )
1266
+ t(r.value);
1267
+ }
1268
+ function Wt(n) {
1269
+ let t, e, r, s = !1;
1270
+ return function(i) {
1271
+ t === void 0 ? (t = i, e = 0, r = -1) : t = zt(t, i);
1272
+ const a = t.length;
1273
+ let u = 0;
1274
+ for (; e < a; ) {
1275
+ s && (t[e] === 10 && (u = ++e), s = !1);
1276
+ let c = -1;
1277
+ for (; e < a && c === -1; ++e)
1278
+ switch (t[e]) {
1299
1279
  case 58:
1300
- r === -1 && (r = t - c);
1280
+ r === -1 && (r = e - u);
1301
1281
  break;
1302
1282
  case 13:
1303
- o = !0;
1283
+ s = !0;
1304
1284
  case 10:
1305
- u = t;
1285
+ c = e;
1306
1286
  break;
1307
1287
  }
1308
- if (u === -1)
1288
+ if (c === -1)
1309
1289
  break;
1310
- n(e.subarray(c, u), r), c = t, r = -1;
1290
+ n(t.subarray(u, c), r), u = e, r = -1;
1311
1291
  }
1312
- c === a ? e = void 0 : c !== 0 && (e = e.subarray(c), t -= c);
1292
+ u === a ? t = void 0 : u !== 0 && (t = t.subarray(u), e -= u);
1313
1293
  };
1314
1294
  }
1315
- function Bt(n, e, t) {
1316
- let r = ue();
1317
- const o = new TextDecoder();
1318
- return function(s, a) {
1319
- if (s.length === 0)
1320
- t?.(r), r = ue();
1295
+ function Xt(n, t, e) {
1296
+ let r = he();
1297
+ const s = new TextDecoder();
1298
+ return function(i, a) {
1299
+ if (i.length === 0)
1300
+ e?.(r), r = he();
1321
1301
  else if (a > 0) {
1322
- const c = o.decode(s.subarray(0, a)), u = a + (s[a + 1] === 32 ? 2 : 1), f = o.decode(s.subarray(u));
1323
- switch (c) {
1302
+ const u = s.decode(i.subarray(0, a)), c = a + (i[a + 1] === 32 ? 2 : 1), h = s.decode(i.subarray(c));
1303
+ switch (u) {
1324
1304
  case "data":
1325
1305
  r.data = r.data ? r.data + `
1326
- ` + f : f;
1306
+ ` + h : h;
1327
1307
  break;
1328
1308
  case "event":
1329
- r.event = f;
1309
+ r.event = h;
1330
1310
  break;
1331
1311
  case "id":
1332
- n(r.id = f);
1312
+ n(r.id = h);
1333
1313
  break;
1334
1314
  case "retry":
1335
- const p = parseInt(f, 10);
1336
- isNaN(p) || e(r.retry = p);
1315
+ const g = parseInt(h, 10);
1316
+ isNaN(g) || t(r.retry = g);
1337
1317
  break;
1338
1318
  }
1339
1319
  }
1340
1320
  };
1341
1321
  }
1342
- function Yt(n, e) {
1343
- const t = new Uint8Array(n.length + e.length);
1344
- return t.set(n), t.set(e, n.length), t;
1322
+ function zt(n, t) {
1323
+ const e = new Uint8Array(n.length + t.length);
1324
+ return e.set(n), e.set(t, n.length), e;
1345
1325
  }
1346
- function ue() {
1326
+ function he() {
1347
1327
  return {
1348
1328
  data: "",
1349
1329
  event: "",
@@ -1351,216 +1331,274 @@ function ue() {
1351
1331
  retry: void 0
1352
1332
  };
1353
1333
  }
1354
- var qt = function(n, e) {
1355
- var t = {};
1356
- for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && e.indexOf(r) < 0 && (t[r] = n[r]);
1334
+ var Jt = function(n, t) {
1335
+ var e = {};
1336
+ for (var r in n) Object.prototype.hasOwnProperty.call(n, r) && t.indexOf(r) < 0 && (e[r] = n[r]);
1357
1337
  if (n != null && typeof Object.getOwnPropertySymbols == "function")
1358
- for (var o = 0, r = Object.getOwnPropertySymbols(n); o < r.length; o++)
1359
- e.indexOf(r[o]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[o]) && (t[r[o]] = n[r[o]]);
1360
- return t;
1338
+ for (var s = 0, r = Object.getOwnPropertySymbols(n); s < r.length; s++)
1339
+ t.indexOf(r[s]) < 0 && Object.prototype.propertyIsEnumerable.call(n, r[s]) && (e[r[s]] = n[r[s]]);
1340
+ return e;
1361
1341
  };
1362
- const z = "text/event-stream", Wt = 1e3, le = "last-event-id";
1363
- function Xt(n, e) {
1364
- var { signal: t, headers: r, onopen: o, onmessage: i, onclose: s, onerror: a, openWhenHidden: c, fetch: u } = e, f = qt(e, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
1365
- return new Promise((p, h) => {
1342
+ const ee = "text/event-stream", Qt = 1e3, fe = "last-event-id";
1343
+ function Zt(n, t) {
1344
+ var { signal: e, headers: r, onopen: s, onmessage: o, onclose: i, onerror: a, openWhenHidden: u, fetch: c } = t, h = Jt(t, ["signal", "headers", "onopen", "onmessage", "onclose", "onerror", "openWhenHidden", "fetch"]);
1345
+ return new Promise((g, v) => {
1366
1346
  const l = Object.assign({}, r);
1367
- l.accept || (l.accept = z);
1368
- let y;
1369
- function v() {
1370
- y.abort(), document.hidden || K();
1347
+ l.accept || (l.accept = ee);
1348
+ let f;
1349
+ function p() {
1350
+ f.abort(), document.hidden || V();
1371
1351
  }
1372
- c || document.addEventListener("visibilitychange", v);
1373
- let w = Wt, E = 0;
1352
+ u || document.addEventListener("visibilitychange", p);
1353
+ let A = Qt, I = 0;
1374
1354
  function _() {
1375
- document.removeEventListener("visibilitychange", v), window.clearTimeout(E), y.abort();
1355
+ document.removeEventListener("visibilitychange", p), window.clearTimeout(I), f.abort();
1376
1356
  }
1377
- t?.addEventListener("abort", () => {
1378
- _(), p();
1357
+ e?.addEventListener("abort", () => {
1358
+ _(), g();
1379
1359
  });
1380
- const ke = u ?? window.fetch, De = o ?? zt;
1381
- async function K() {
1382
- var V;
1383
- y = new AbortController();
1360
+ const He = c ?? window.fetch, Ge = s ?? en;
1361
+ async function V() {
1362
+ var Y;
1363
+ f = new AbortController();
1384
1364
  try {
1385
- const U = await ke(n, Object.assign(Object.assign({}, f), { headers: l, signal: y.signal }));
1386
- await De(U), await Kt(U.body, Vt(Bt((C) => {
1387
- C ? l[le] = C : delete l[le];
1388
- }, (C) => {
1389
- w = C;
1390
- }, i))), s?.(), _(), p();
1391
- } catch (U) {
1392
- if (!y.signal.aborted)
1365
+ const j = await He(n, Object.assign(Object.assign({}, h), { headers: l, signal: f.signal }));
1366
+ await Ge(j), await Yt(j.body, Wt(Xt((T) => {
1367
+ T ? l[fe] = T : delete l[fe];
1368
+ }, (T) => {
1369
+ A = T;
1370
+ }, o))), i?.(), _(), g();
1371
+ } catch (j) {
1372
+ if (!f.signal.aborted)
1393
1373
  try {
1394
- const C = (V = a?.(U)) !== null && V !== void 0 ? V : w;
1395
- window.clearTimeout(E), E = window.setTimeout(K, C);
1396
- } catch (C) {
1397
- _(), h(C);
1374
+ const T = (Y = a?.(j)) !== null && Y !== void 0 ? Y : A;
1375
+ window.clearTimeout(I), I = window.setTimeout(V, T);
1376
+ } catch (T) {
1377
+ _(), v(T);
1398
1378
  }
1399
1379
  }
1400
1380
  }
1401
- K();
1381
+ V();
1402
1382
  });
1403
1383
  }
1404
- function zt(n) {
1405
- const e = n.headers.get("content-type");
1406
- if (!e?.startsWith(z))
1407
- throw new Error(`Expected content-type to be ${z}, Actual: ${e}`);
1408
- }
1409
- function Jt(n) {
1410
- const { endpoint: e, apiKey: t, payload: r, debugMode: o, customHeaders: i } = n;
1411
- return new g((s) => {
1412
- const a = new AbortController();
1413
- let c;
1414
- const u = {
1384
+ function en(n) {
1385
+ const t = n.headers.get("content-type");
1386
+ if (!t?.startsWith(ee))
1387
+ throw new Error(`Expected content-type to be ${ee}, Actual: ${t}`);
1388
+ }
1389
+ function pe(n) {
1390
+ const { endpoint: t, apiKey: e, payload: r, debugMode: s, customHeaders: o } = n, i = n.method ?? "POST";
1391
+ return new S((a) => {
1392
+ const u = new AbortController();
1393
+ let c, h = !1;
1394
+ const g = {
1415
1395
  "Content-Type": "application/json",
1416
- ...i
1396
+ ...o
1417
1397
  };
1418
- t && (u["X-API-KEY"] = t);
1419
- const f = new URLSearchParams();
1420
- o && f.set("is_debug", "true");
1421
- const p = new URL(e);
1422
- return f.toString() && (p.search = f.toString()), Xt(p.toString(), {
1423
- method: "POST",
1424
- headers: u,
1425
- body: r ? JSON.stringify(r) : void 0,
1426
- signal: a.signal,
1398
+ e && (g["X-API-KEY"] = e);
1399
+ const v = new URL(t);
1400
+ return s && v.searchParams.set("is_debug", "true"), Zt(v.toString(), {
1401
+ method: i,
1402
+ headers: g,
1403
+ body: i === "POST" && r ? JSON.stringify(r) : void 0,
1404
+ signal: u.signal,
1427
1405
  /**
1428
1406
  * Allow SSE to work when the page is hidden.
1429
1407
  * https://github.com/Azure/fetch-event-source/issues/17#issuecomment-1525904929
1430
1408
  */
1431
1409
  openWhenHidden: !0,
1432
- onopen: async (h) => {
1433
- if (h.ok)
1434
- c = h.headers.get("X-Trace-Id") ?? void 0;
1410
+ onopen: async (l) => {
1411
+ if (l.ok)
1412
+ c = l.headers.get("X-Trace-Id") ?? void 0;
1435
1413
  else {
1436
- let l;
1414
+ let f;
1437
1415
  try {
1438
- l = await h.json();
1416
+ f = await l.json();
1439
1417
  } catch {
1440
1418
  try {
1441
- l = await h.text();
1419
+ f = await l.text();
1442
1420
  } catch {
1443
- l = null;
1421
+ f = null;
1444
1422
  }
1445
1423
  }
1446
- s.error(new de(h.status, h.statusText, l)), a.abort();
1424
+ a.error(new te(l.status, l.statusText, f)), u.abort();
1447
1425
  }
1448
1426
  },
1449
- onmessage: (h) => {
1450
- const l = JSON.parse(h.data);
1451
- c ? l.traceId = c : l.requestId && (l.traceId = l.requestId, c || (c = l.requestId)), s.next(l);
1427
+ onmessage: (l) => {
1428
+ l.id && (h = !0);
1429
+ const f = JSON.parse(l.data);
1430
+ c ? f.traceId = c : f.requestId && (f.traceId = f.requestId, c || (c = f.requestId)), a.next(f);
1452
1431
  },
1453
1432
  onclose: () => {
1454
- s.complete();
1433
+ a.complete();
1455
1434
  },
1456
- onerror: (h) => {
1457
- throw s.error(h), a.abort(), h;
1435
+ onerror: (l) => {
1436
+ if (!h)
1437
+ throw a.error(l), u.abort(), l;
1458
1438
  }
1459
1439
  }), () => {
1460
- a.abort();
1440
+ u.abort();
1461
1441
  };
1462
1442
  });
1463
1443
  }
1464
- class Qt {
1444
+ class tn {
1465
1445
  listeners = {};
1466
- on(e, t) {
1446
+ on(t, e) {
1467
1447
  this.listeners = Object.assign({}, this.listeners, {
1468
- [e]: (this.listeners[e] ?? []).concat(t)
1448
+ [t]: (this.listeners[t] ?? []).concat(e)
1469
1449
  });
1470
1450
  }
1471
- off(e, t) {
1472
- this.listeners[e] && (this.listeners = Object.assign({}, this.listeners, {
1473
- [e]: (this.listeners[e] ?? []).filter((r) => r !== t)
1451
+ off(t, e) {
1452
+ this.listeners[t] && (this.listeners = Object.assign({}, this.listeners, {
1453
+ [t]: (this.listeners[t] ?? []).filter((r) => r !== e)
1474
1454
  }));
1475
1455
  }
1476
- remove(e) {
1477
- delete this.listeners[e];
1456
+ remove(t) {
1457
+ delete this.listeners[t];
1478
1458
  }
1479
- emit(e, ...t) {
1480
- this.listeners[e] && this.listeners[e].forEach((r) => r(...t));
1459
+ emit(t, ...e) {
1460
+ this.listeners[t] && this.listeners[t].forEach((r) => r(...e));
1481
1461
  }
1482
1462
  }
1483
- class sn {
1463
+ class wn {
1484
1464
  apiKey;
1485
1465
  endpoint;
1486
1466
  botProviderEndpoint;
1487
1467
  debugMode;
1488
- destroy$ = new ee();
1468
+ destroy$ = new se();
1489
1469
  closed = !1;
1490
1470
  detached = !1;
1491
1471
  detachTimer;
1492
1472
  inFlight = 0;
1493
- sseEmitter = new Qt();
1473
+ sseEmitter = new tn();
1494
1474
  transformSsePayload;
1495
1475
  customHeaders;
1496
- constructor(e) {
1497
- if (!e.endpoint && !e.botProviderEndpoint)
1476
+ constructor(t) {
1477
+ if (!t.endpoint && !t.botProviderEndpoint)
1498
1478
  throw new Error("Either endpoint or botProviderEndpoint must be provided");
1499
- if (this.apiKey = e.apiKey, this.debugMode = e.debugMode, this.transformSsePayload = e.transformSsePayload, this.botProviderEndpoint = e.botProviderEndpoint, this.customHeaders = {
1500
- ...e.customHeaders,
1501
- ...e.userIdentityHint ? { "X-ASGARD-USER-IDENTITY-HINT": e.userIdentityHint } : {}
1502
- }, !e.endpoint && e.botProviderEndpoint) {
1503
- const t = e.botProviderEndpoint.replace(/\/+$/, "");
1504
- this.endpoint = `${t}/message/sse`;
1505
- } else e.endpoint && (this.endpoint = e.endpoint, this.debugMode && console.warn(
1479
+ if (this.apiKey = t.apiKey, this.debugMode = t.debugMode, this.transformSsePayload = t.transformSsePayload, this.botProviderEndpoint = t.botProviderEndpoint, this.customHeaders = {
1480
+ ...t.customHeaders,
1481
+ ...t.userIdentityHint ? { "X-ASGARD-USER-IDENTITY-HINT": t.userIdentityHint } : {}
1482
+ }, !t.endpoint && t.botProviderEndpoint) {
1483
+ const e = t.botProviderEndpoint.replace(/\/+$/, "");
1484
+ this.endpoint = `${e}/message/sse`;
1485
+ } else t.endpoint && (this.endpoint = t.endpoint, this.debugMode && console.warn(
1506
1486
  '[AsgardServiceClient] The "endpoint" option is deprecated and will be removed in the next major version. Please use "botProviderEndpoint" instead. The SSE endpoint will be automatically derived as "${botProviderEndpoint}/message/sse".'
1507
1487
  ));
1508
1488
  }
1509
- on(e, t) {
1510
- this.sseEmitter.remove(e), this.sseEmitter.on(e, t);
1489
+ on(t, e) {
1490
+ this.sseEmitter.remove(t), this.sseEmitter.on(t, e);
1511
1491
  }
1512
- handleEvent(e) {
1513
- switch (e.eventType) {
1492
+ handleEvent(t) {
1493
+ switch (t.eventType) {
1514
1494
  case d.INIT:
1515
- this.sseEmitter.emit(d.INIT, e);
1495
+ this.sseEmitter.emit(d.INIT, t);
1516
1496
  break;
1517
1497
  case d.PROCESS_START:
1518
1498
  case d.PROCESS_COMPLETE:
1519
- this.sseEmitter.emit(d.PROCESS, e);
1499
+ this.sseEmitter.emit(d.PROCESS, t);
1520
1500
  break;
1521
1501
  case d.MESSAGE_START:
1522
1502
  case d.MESSAGE_DELTA:
1523
1503
  case d.MESSAGE_COMPLETE:
1524
- this.sseEmitter.emit(d.MESSAGE, e);
1504
+ this.sseEmitter.emit(d.MESSAGE, t);
1525
1505
  break;
1526
1506
  case d.TOOL_CALL_START:
1527
1507
  case d.TOOL_CALL_COMPLETE:
1528
- this.sseEmitter.emit(d.TOOL_CALL, e);
1508
+ this.sseEmitter.emit(d.TOOL_CALL, t);
1529
1509
  break;
1530
1510
  case d.TOOL_CALL_CONSENT:
1531
1511
  this.sseEmitter.emit(
1532
1512
  d.TOOL_CALL_CONSENT,
1533
- e
1513
+ t
1534
1514
  );
1535
1515
  break;
1536
1516
  case d.DONE:
1537
- this.sseEmitter.emit(d.DONE, e);
1517
+ this.sseEmitter.emit(d.DONE, t);
1538
1518
  break;
1539
1519
  case d.ERROR:
1540
- this.sseEmitter.emit(d.ERROR, e);
1520
+ this.sseEmitter.emit(d.ERROR, t);
1541
1521
  break;
1542
1522
  }
1543
1523
  }
1544
- fetchSse(e, t) {
1545
- t?.onSseStart?.(), this.inFlight += 1, Jt({
1546
- apiKey: this.apiKey,
1547
- endpoint: this.endpoint,
1548
- debugMode: this.debugMode,
1549
- payload: this.transformSsePayload?.(e) ?? e,
1550
- customHeaders: this.customHeaders
1551
- }).pipe(
1552
- $t((r) => wt(r).pipe(Ht(t?.delayTime ?? 50))),
1553
- Gt(this.destroy$),
1554
- Ft(3)
1524
+ fetchSse(t, e) {
1525
+ e?.onSseStart?.(), this.inFlight += 1, this.runSse(
1526
+ pe({
1527
+ apiKey: this.apiKey,
1528
+ endpoint: this.endpoint,
1529
+ debugMode: this.debugMode,
1530
+ payload: this.transformSsePayload?.(t) ?? t,
1531
+ customHeaders: this.customHeaders
1532
+ }),
1533
+ e
1534
+ );
1535
+ }
1536
+ /**
1537
+ * Cold-start transcript rejoin (F-014): a `GET /message/sse?custom_channel_id=…` with an empty
1538
+ * `Last-Event-ID` replays the collapsed history (`message.user` + self-sufficient `*.complete`),
1539
+ * assembled through the same reducer. Reuses the F-002 native Last-Event-ID transport (no re-POST).
1540
+ */
1541
+ rejoinSse(t, e) {
1542
+ e?.onSseStart?.(), this.inFlight += 1;
1543
+ const r = new URL(this.endpoint);
1544
+ r.searchParams.set("custom_channel_id", t), this.runSse(
1545
+ pe({
1546
+ apiKey: this.apiKey,
1547
+ endpoint: r.toString(),
1548
+ debugMode: this.debugMode,
1549
+ method: "GET",
1550
+ customHeaders: this.customHeaders
1551
+ }),
1552
+ e
1553
+ );
1554
+ }
1555
+ deriveChannelMetadataEndpoint() {
1556
+ const t = this.getBaseEndpoint();
1557
+ return t ? `${t}/channel/metadata` : null;
1558
+ }
1559
+ /**
1560
+ * Join-init existence + restore gate (F-015): `GET {base}/channel/metadata?custom_channel_id=…`.
1561
+ * `200` → parsed {@link ChannelMetadata}; `404` → `null` (channel does not exist); any other non-OK
1562
+ * status or network error throws. The caller must never treat an indeterminate result (throw) as
1563
+ * "not exists" — that would let a mount-time reset wipe an existing channel's history.
1564
+ */
1565
+ async channelMetadata(t) {
1566
+ const e = this.deriveChannelMetadataEndpoint();
1567
+ if (!e)
1568
+ throw new Error("Unable to derive channel metadata endpoint. Please provide botProviderEndpoint in config.");
1569
+ const r = new URL(e);
1570
+ r.searchParams.set("custom_channel_id", t);
1571
+ const s = { ...this.customHeaders };
1572
+ this.apiKey && (s["X-API-KEY"] = this.apiKey);
1573
+ const o = await fetch(r.toString(), { method: "GET", headers: s });
1574
+ if (o.status === 404)
1575
+ return null;
1576
+ if (!o.ok)
1577
+ throw new te(o.status, o.statusText, await o.text().catch(() => {
1578
+ }));
1579
+ const i = await o.json(), a = i.data ?? i;
1580
+ return {
1581
+ title: a.title ?? null,
1582
+ runState: a.runState ?? "IDLE",
1583
+ lastActivityAt: a.lastActivityAt
1584
+ };
1585
+ }
1586
+ runSse(t, e) {
1587
+ t.pipe(
1588
+ // No RxJS-level retry: re-subscribing would re-POST and the backend would re-dispatch a duplicate
1589
+ // run. Mid-stream resume is the library's job (native Last-Event-ID reconnect in
1590
+ // create-sse-observable); a no-cursor failure surfaces via `error` below.
1591
+ Ht((r) => Tt(r).pipe(Bt(e?.delayTime ?? 50))),
1592
+ Vt(this.destroy$)
1555
1593
  ).subscribe({
1556
1594
  next: (r) => {
1557
- this.detached || (t?.onSseMessage?.(r), this.handleEvent(r));
1595
+ this.detached || (e?.onSseMessage?.(r), this.handleEvent(r));
1558
1596
  },
1559
1597
  error: (r) => {
1560
- this.detached || t?.onSseError?.(r), this.onRunSettled();
1598
+ this.detached || e?.onSseError?.(r), this.onRunSettled();
1561
1599
  },
1562
1600
  complete: () => {
1563
- this.detached || t?.onSseCompleted?.(), this.onRunSettled();
1601
+ this.detached || e?.onSseCompleted?.(), this.onRunSettled();
1564
1602
  }
1565
1603
  });
1566
1604
  }
@@ -1578,13 +1616,13 @@ class sn {
1578
1616
  * - A run gets stuck (stream stays open, no `run.done`/error) → the safety
1579
1617
  * timeout force-closes it so the orphaned connection cannot leak.
1580
1618
  */
1581
- detach(e) {
1619
+ detach(t) {
1582
1620
  if (!(this.detached || this.closed)) {
1583
1621
  if (this.detached = !0, this.inFlight === 0) {
1584
1622
  this.close();
1585
1623
  return;
1586
1624
  }
1587
- this.detachTimer = setTimeout(() => this.close(), e.timeoutMs);
1625
+ this.detachTimer = setTimeout(() => this.close(), t.timeoutMs);
1588
1626
  }
1589
1627
  }
1590
1628
  onRunSettled() {
@@ -1597,51 +1635,51 @@ class sn {
1597
1635
  * 上傳檔案到 Blob API
1598
1636
  * 根據 API 文件:/ns/{namespace}/bot-provider/{bot_provider_name}/blob
1599
1637
  */
1600
- async uploadFile(e, t) {
1638
+ async uploadFile(t, e) {
1601
1639
  const r = this.deriveBlobEndpoint();
1602
1640
  if (!r)
1603
1641
  throw new Error("Unable to derive blob endpoint. Please provide botProviderEndpoint in config.");
1604
- const o = new FormData();
1605
- o.append("file", e), o.append("customChannelId", t);
1606
- const i = {
1642
+ const s = new FormData();
1643
+ s.append("file", t), s.append("customChannelId", e);
1644
+ const o = {
1607
1645
  ...this.customHeaders
1608
1646
  };
1609
- this.apiKey && (i["X-API-KEY"] = this.apiKey);
1647
+ this.apiKey && (o["X-API-KEY"] = this.apiKey);
1610
1648
  try {
1611
- const s = await fetch(r, {
1649
+ const i = await fetch(r, {
1612
1650
  method: "POST",
1613
- headers: i,
1614
- body: o
1651
+ headers: o,
1652
+ body: s
1615
1653
  });
1616
- if (!s.ok)
1617
- throw new Error(`Upload failed: ${s.status} ${s.statusText}`);
1618
- const a = await s.json();
1654
+ if (!i.ok)
1655
+ throw new Error(`Upload failed: ${i.status} ${i.statusText}`);
1656
+ const a = await i.json();
1619
1657
  return this.debugMode && console.log("[AsgardServiceClient] File upload response:", a), a;
1620
- } catch (s) {
1621
- throw console.error("[AsgardServiceClient] File upload error:", s), s;
1658
+ } catch (i) {
1659
+ throw console.error("[AsgardServiceClient] File upload error:", i), i;
1622
1660
  }
1623
1661
  }
1624
1662
  /**
1625
1663
  * 下載 channel sandbox 工作目錄裡的檔案(cwd:// URI action)。
1626
1664
  * 呼叫 Edge Server GET <base>/cwd/download?custom_channel_id=xxx&relative_path=xxx 取回 binary。
1627
1665
  */
1628
- async downloadCwdFile(e, t) {
1666
+ async downloadCwdFile(t, e) {
1629
1667
  const r = this.getBaseEndpoint();
1630
1668
  if (!r)
1631
1669
  throw new Error("Unable to derive cwd download endpoint. Please provide botProviderEndpoint in config.");
1632
- const o = `custom_channel_id=${encodeURIComponent(t)}&relative_path=${encodeURIComponent(e)}`, i = `${r}/cwd/download?${o}`, s = {
1670
+ const s = `custom_channel_id=${encodeURIComponent(e)}&relative_path=${encodeURIComponent(t)}`, o = `${r}/cwd/download?${s}`, i = {
1633
1671
  ...this.customHeaders
1634
1672
  };
1635
- this.apiKey && (s["X-API-KEY"] = this.apiKey);
1673
+ this.apiKey && (i["X-API-KEY"] = this.apiKey);
1636
1674
  try {
1637
- const a = await fetch(i, {
1675
+ const a = await fetch(o, {
1638
1676
  method: "GET",
1639
- headers: s
1677
+ headers: i
1640
1678
  });
1641
1679
  if (!a.ok)
1642
1680
  throw new Error(`CWD download failed: ${a.status} ${a.statusText}`);
1643
- const c = await a.blob(), u = e.split("/").pop() || "download";
1644
- return this.debugMode && console.log("[AsgardServiceClient] CWD download response:", { filename: u, size: c.size }), { blob: c, filename: u };
1681
+ const u = await a.blob(), c = t.split("/").pop() || "download";
1682
+ return this.debugMode && console.log("[AsgardServiceClient] CWD download response:", { filename: c, size: u.size }), { blob: u, filename: c };
1645
1683
  } catch (a) {
1646
1684
  throw console.error("[AsgardServiceClient] CWD download error:", a), a;
1647
1685
  }
@@ -1650,309 +1688,681 @@ class sn {
1650
1688
  * 從 botProviderEndpoint 衍生 Blob API endpoint
1651
1689
  */
1652
1690
  deriveBlobEndpoint() {
1653
- const e = this.getBaseEndpoint();
1654
- return e ? `${e}/blob` : null;
1691
+ const t = this.getBaseEndpoint();
1692
+ return t ? `${t}/blob` : null;
1655
1693
  }
1656
1694
  /**
1657
1695
  * 衍生 bot provider 的 base endpoint(不含子路徑)。
1658
1696
  * 優先用 botProviderEndpoint;若只有 deprecated 的 endpoint 則反推(移除 /message/sse)。已去除尾部斜線。
1659
1697
  */
1660
1698
  getBaseEndpoint() {
1661
- let e = this.botProviderEndpoint;
1662
- return !e && this.endpoint && (e = this.endpoint.replace("/message/sse", "")), e ? e.replace(/\/+$/, "") : null;
1699
+ let t = this.botProviderEndpoint;
1700
+ return !t && this.endpoint && (t = this.endpoint.replace("/message/sse", "")), t ? t.replace(/\/+$/, "") : null;
1663
1701
  }
1664
1702
  }
1665
- const b = [];
1703
+ const y = [];
1666
1704
  for (let n = 0; n < 256; ++n)
1667
- b.push((n + 256).toString(16).slice(1));
1668
- function Zt(n, e = 0) {
1669
- return (b[n[e + 0]] + b[n[e + 1]] + b[n[e + 2]] + b[n[e + 3]] + "-" + b[n[e + 4]] + b[n[e + 5]] + "-" + b[n[e + 6]] + b[n[e + 7]] + "-" + b[n[e + 8]] + b[n[e + 9]] + "-" + b[n[e + 10]] + b[n[e + 11]] + b[n[e + 12]] + b[n[e + 13]] + b[n[e + 14]] + b[n[e + 15]]).toLowerCase();
1670
- }
1671
- let Y;
1672
- const en = new Uint8Array(16);
1673
- function tn() {
1674
- if (!Y) {
1705
+ y.push((n + 256).toString(16).slice(1));
1706
+ function nn(n, t = 0) {
1707
+ return (y[n[t + 0]] + y[n[t + 1]] + y[n[t + 2]] + y[n[t + 3]] + "-" + y[n[t + 4]] + y[n[t + 5]] + "-" + y[n[t + 6]] + y[n[t + 7]] + "-" + y[n[t + 8]] + y[n[t + 9]] + "-" + y[n[t + 10]] + y[n[t + 11]] + y[n[t + 12]] + y[n[t + 13]] + y[n[t + 14]] + y[n[t + 15]]).toLowerCase();
1708
+ }
1709
+ let X;
1710
+ const rn = new Uint8Array(16);
1711
+ function sn() {
1712
+ if (!X) {
1675
1713
  if (typeof crypto > "u" || !crypto.getRandomValues)
1676
1714
  throw new Error("crypto.getRandomValues() not supported. See https://github.com/uuidjs/uuid#getrandomvalues-not-supported");
1677
- Y = crypto.getRandomValues.bind(crypto);
1715
+ X = crypto.getRandomValues.bind(crypto);
1678
1716
  }
1679
- return Y(en);
1717
+ return X(rn);
1680
1718
  }
1681
- const nn = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), fe = { randomUUID: nn };
1682
- function rn(n, e, t) {
1719
+ const on = typeof crypto < "u" && crypto.randomUUID && crypto.randomUUID.bind(crypto), ge = { randomUUID: on };
1720
+ function an(n, t, e) {
1683
1721
  n = n || {};
1684
- const r = n.random ?? n.rng?.() ?? tn();
1722
+ const r = n.random ?? n.rng?.() ?? sn();
1685
1723
  if (r.length < 16)
1686
1724
  throw new Error("Random bytes length must be >= 16");
1687
- return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, Zt(r);
1725
+ return r[6] = r[6] & 15 | 64, r[8] = r[8] & 63 | 128, nn(r);
1688
1726
  }
1689
- function $e(n, e, t) {
1690
- return fe.randomUUID && !n ? fe.randomUUID() : rn(n);
1727
+ function De(n, t, e) {
1728
+ return ge.randomUUID && !n ? ge.randomUUID() : an(n);
1691
1729
  }
1692
- class S {
1730
+ class b {
1693
1731
  messages = null;
1694
1732
  pendingConsent = null;
1695
- constructor({ messages: e, pendingConsent: t = null }) {
1696
- this.messages = e, this.pendingConsent = t ?? null;
1733
+ constructor({ messages: t, pendingConsent: e = null }) {
1734
+ this.messages = t, this.pendingConsent = e ?? null;
1697
1735
  }
1698
- pushMessage(e) {
1699
- const t = new Map(this.messages);
1700
- return t.set(e.messageId, e), new S({ messages: t, pendingConsent: this.pendingConsent });
1736
+ pushMessage(t) {
1737
+ const e = new Map(this.messages);
1738
+ return e.set(t.messageId, t), new b({ messages: e, pendingConsent: this.pendingConsent });
1701
1739
  }
1702
1740
  clearPendingConsent() {
1703
- return this.pendingConsent ? new S({ messages: this.messages, pendingConsent: null }) : this;
1741
+ return this.pendingConsent ? new b({ messages: this.messages, pendingConsent: null }) : this;
1704
1742
  }
1705
- onMessage(e) {
1706
- switch (e.eventType) {
1743
+ onMessage(t) {
1744
+ switch (t.eventType) {
1707
1745
  case d.MESSAGE_START:
1708
- return this.onMessageStart(e);
1746
+ return this.onMessageStart(t);
1709
1747
  case d.MESSAGE_DELTA:
1710
- return this.onMessageDelta(e);
1748
+ return this.onMessageDelta(t);
1711
1749
  case d.MESSAGE_COMPLETE:
1712
- return this.onMessageComplete(e);
1750
+ return this.onMessageComplete(t);
1751
+ case d.MESSAGE_USER:
1752
+ return this.onMessageUser(t);
1753
+ case d.MESSAGE_THINKING_START:
1754
+ return this.onThinkingStart(t);
1755
+ case d.MESSAGE_THINKING_DELTA:
1756
+ return this.onThinkingDelta(t);
1757
+ case d.MESSAGE_THINKING_COMPLETE:
1758
+ return this.onThinkingComplete(t);
1713
1759
  case d.TOOL_CALL_START:
1714
- return this.onToolCallStart(e);
1760
+ return this.onToolCallStart(t);
1715
1761
  case d.TOOL_CALL_COMPLETE:
1716
- return this.onToolCallComplete(e);
1762
+ return this.onToolCallComplete(t);
1717
1763
  case d.TOOL_CALL_CONSENT:
1718
- return this.onToolCallConsent(e);
1764
+ return this.onToolCallConsent(t);
1765
+ case d.SUBAGENT_START:
1766
+ return this.onSubagentStart(t);
1767
+ case d.SUBAGENT_COMPLETE:
1768
+ return this.onSubagentComplete(t);
1719
1769
  case d.ERROR:
1720
- return this.onMessageError(e);
1770
+ return this.onMessageError(t);
1721
1771
  default:
1722
1772
  return this;
1723
1773
  }
1724
1774
  }
1725
- onMessageStart(e) {
1726
- const t = e.fact.messageStart.message, r = new Map(this.messages);
1727
- return r.set(t.messageId, {
1775
+ /**
1776
+ * A message is terminal once `complete` has materialized it (a bot message with `isTyping === false`).
1777
+ * Terminal messages must never regress to typing/streaming — late `start`/`delta` frames from replay
1778
+ * or out-of-order delivery are ignored (F-011 / UC-018).
1779
+ */
1780
+ isTerminalBot(t) {
1781
+ return t?.type === "bot" && !t.isTyping;
1782
+ }
1783
+ /**
1784
+ * A thinking block is terminal once `thinking.complete` has settled it (`isThinking === false`).
1785
+ * Like the bot terminal guard (F-011), it must never regress to the streaming state — late
1786
+ * `thinking.start` / `thinking.delta` frames from replay or out-of-order delivery are ignored.
1787
+ */
1788
+ isTerminalThinking(t) {
1789
+ return t?.type === "thinking" && !t.isThinking;
1790
+ }
1791
+ onMessageStart(t) {
1792
+ const e = t.fact.messageStart.message;
1793
+ if (this.isTerminalBot(this.messages?.get(e.messageId))) return this;
1794
+ const r = new Map(this.messages);
1795
+ return r.set(e.messageId, {
1728
1796
  type: "bot",
1729
1797
  eventType: d.MESSAGE_START,
1730
1798
  isTyping: !0,
1731
1799
  typingText: "",
1732
- messageId: t.messageId,
1733
- message: t,
1800
+ messageId: e.messageId,
1801
+ message: e,
1734
1802
  time: /* @__PURE__ */ new Date(),
1735
- traceId: e.traceId,
1803
+ traceId: t.traceId,
1736
1804
  raw: ""
1737
- }), new S({ messages: r, pendingConsent: this.pendingConsent });
1805
+ }), new b({ messages: r, pendingConsent: this.pendingConsent });
1738
1806
  }
1739
- onMessageDelta(e) {
1740
- const t = e.fact.messageDelta.message, r = new Map(this.messages), o = r.get(t.messageId);
1741
- if (o?.type !== "bot") return this;
1742
- const i = `${o?.typingText ?? ""}${t.text}`;
1743
- return r.set(t.messageId, {
1807
+ onMessageDelta(t) {
1808
+ const e = t.fact.messageDelta.message, r = this.messages?.get(e.messageId);
1809
+ if (this.isTerminalBot(r)) return this;
1810
+ const s = r?.type === "bot" ? r : void 0, o = new Map(this.messages);
1811
+ return o.set(e.messageId, {
1744
1812
  type: "bot",
1745
1813
  eventType: d.MESSAGE_DELTA,
1746
1814
  isTyping: !0,
1747
- typingText: i,
1748
- messageId: t.messageId,
1749
- message: t,
1815
+ typingText: `${s?.typingText ?? ""}${e.text}`,
1816
+ messageId: e.messageId,
1817
+ message: e,
1750
1818
  time: /* @__PURE__ */ new Date(),
1751
- traceId: e.traceId ?? o.traceId,
1752
- raw: o.raw
1753
- }), new S({ messages: r, pendingConsent: this.pendingConsent });
1819
+ traceId: t.traceId ?? s?.traceId,
1820
+ raw: s?.raw ?? ""
1821
+ }), new b({ messages: o, pendingConsent: this.pendingConsent });
1754
1822
  }
1755
- onMessageComplete(e) {
1756
- const t = e.fact.messageComplete.message, r = new Map(this.messages), o = r.get(t.messageId);
1757
- return r.set(t.messageId, {
1823
+ onMessageComplete(t) {
1824
+ const e = t.fact.messageComplete.message, r = new Map(this.messages), s = r.get(e.messageId);
1825
+ return r.set(e.messageId, {
1758
1826
  type: "bot",
1759
1827
  eventType: d.MESSAGE_COMPLETE,
1760
1828
  isTyping: !1,
1761
1829
  typingText: null,
1762
- messageId: t.messageId,
1763
- message: t,
1830
+ messageId: e.messageId,
1831
+ message: e,
1832
+ time: /* @__PURE__ */ new Date(),
1833
+ traceId: t.traceId ?? (s?.type === "bot" ? s.traceId : void 0),
1834
+ raw: JSON.stringify(t)
1835
+ }), new b({ messages: r, pendingConsent: this.pendingConsent });
1836
+ }
1837
+ onThinkingStart(t) {
1838
+ const e = t.fact.messageThinkingStart.message;
1839
+ if (this.isTerminalThinking(this.messages?.get(e.messageId))) return this;
1840
+ const r = new Map(this.messages), s = {
1841
+ type: "thinking",
1842
+ messageId: e.messageId,
1843
+ text: e.text,
1844
+ isThinking: !0,
1845
+ time: /* @__PURE__ */ new Date(),
1846
+ traceId: t.traceId
1847
+ };
1848
+ return r.set(e.messageId, s), new b({ messages: r, pendingConsent: this.pendingConsent });
1849
+ }
1850
+ onThinkingDelta(t) {
1851
+ const e = t.fact.messageThinkingDelta.message, r = this.messages?.get(e.messageId);
1852
+ if (this.isTerminalThinking(r)) return this;
1853
+ const s = r?.type === "thinking" ? r : void 0, o = new Map(this.messages), i = {
1854
+ type: "thinking",
1855
+ messageId: e.messageId,
1856
+ text: `${s?.text ?? ""}${e.text}`,
1857
+ isThinking: !0,
1858
+ time: s?.time ?? /* @__PURE__ */ new Date(),
1859
+ traceId: t.traceId ?? s?.traceId
1860
+ };
1861
+ return o.set(e.messageId, i), new b({ messages: o, pendingConsent: this.pendingConsent });
1862
+ }
1863
+ onThinkingComplete(t) {
1864
+ const e = t.fact.messageThinkingComplete.message, r = this.messages?.get(e.messageId), s = r?.type === "thinking" ? r : void 0, o = new Map(this.messages), i = {
1865
+ type: "thinking",
1866
+ messageId: e.messageId,
1867
+ // Self-sufficient (F-011): the complete frame carries the full reasoning, so a complete-only
1868
+ // replay (no start/delta) still renders the whole text.
1869
+ text: e.text,
1870
+ isThinking: !1,
1871
+ time: s?.time ?? /* @__PURE__ */ new Date(),
1872
+ traceId: t.traceId ?? s?.traceId
1873
+ };
1874
+ return o.set(e.messageId, i), new b({ messages: o, pendingConsent: this.pendingConsent });
1875
+ }
1876
+ onMessageUser(t) {
1877
+ const e = t.fact.messageUser;
1878
+ if ((this.messages?.get(e.messageId) ?? (e.customMessageId ? this.messages?.get(e.customMessageId) : void 0))?.type === "user") return this;
1879
+ const s = new Map(this.messages), o = {
1880
+ type: "user",
1881
+ messageId: e.messageId,
1882
+ text: e.text,
1883
+ blobIds: e.blobIds,
1884
+ customMessageId: e.customMessageId,
1885
+ identityHint: e.identityHint,
1764
1886
  time: /* @__PURE__ */ new Date(),
1765
- traceId: e.traceId ?? (o?.type === "bot" ? o.traceId : void 0),
1766
- raw: JSON.stringify(e)
1767
- }), new S({ messages: r, pendingConsent: this.pendingConsent });
1887
+ traceId: t.traceId
1888
+ };
1889
+ return s.set(e.messageId, o), new b({ messages: s, pendingConsent: this.pendingConsent });
1768
1890
  }
1769
- onMessageError(e) {
1770
- const t = $e(), r = e.fact.runError.error, o = new Map(this.messages);
1771
- return o.set(t, {
1891
+ onMessageError(t) {
1892
+ const e = De(), r = t.fact.runError.error, s = new Map(this.messages);
1893
+ return s.set(e, {
1772
1894
  type: "error",
1773
1895
  eventType: d.ERROR,
1774
- messageId: t,
1896
+ messageId: e,
1775
1897
  error: r,
1776
1898
  time: /* @__PURE__ */ new Date(),
1777
- traceId: e.traceId
1778
- }), new S({ messages: o, pendingConsent: this.pendingConsent });
1899
+ traceId: t.traceId
1900
+ }), new b({ messages: s, pendingConsent: this.pendingConsent });
1779
1901
  }
1780
- onToolCallStart(e) {
1781
- const t = e.fact.toolCallStart, r = new Map(this.messages), o = `${t.processId}-${t.callSeq}`, i = {
1902
+ onToolCallStart(t) {
1903
+ const e = t.fact.toolCallStart, r = new Map(this.messages), s = `${e.processId}-${e.callSeq}`, o = {
1782
1904
  type: "tool-call",
1783
1905
  eventType: d.TOOL_CALL_START,
1784
- messageId: o,
1785
- processId: t.processId,
1786
- callSeq: t.callSeq,
1787
- toolName: t.toolCall.toolName,
1788
- reason: t.toolCall.reason,
1789
- toolsetName: t.toolCall.toolsetName,
1790
- parameter: t.toolCall.parameter,
1906
+ messageId: s,
1907
+ processId: e.processId,
1908
+ callSeq: e.callSeq,
1909
+ toolName: e.toolCall.toolName,
1910
+ reason: e.toolCall.reason,
1911
+ toolsetName: e.toolCall.toolsetName,
1912
+ parameter: e.toolCall.parameter,
1913
+ toolUseId: e.toolUseId,
1914
+ parentToolUseId: e.parentToolUseId,
1791
1915
  isComplete: !1,
1792
1916
  time: /* @__PURE__ */ new Date(),
1793
- traceId: e.traceId
1917
+ traceId: t.traceId
1794
1918
  };
1795
- return r.set(o, i), new S({ messages: r, pendingConsent: this.pendingConsent });
1919
+ return r.set(s, o), new b({ messages: r, pendingConsent: this.pendingConsent });
1796
1920
  }
1797
- onToolCallComplete(e) {
1798
- const t = e.fact.toolCallComplete, r = new Map(this.messages), o = `${t.processId}-${t.callSeq}`, i = r.get(o);
1799
- if (i?.type === "tool-call") {
1800
- const s = {
1801
- ...i,
1921
+ onToolCallComplete(t) {
1922
+ const e = t.fact.toolCallComplete, r = new Map(this.messages), s = `${e.processId}-${e.callSeq}`, o = r.get(s);
1923
+ if (o?.type === "tool-call") {
1924
+ const i = {
1925
+ ...o,
1802
1926
  eventType: d.TOOL_CALL_COMPLETE,
1803
- result: t.toolCallResult,
1927
+ result: e.toolCallResult,
1928
+ isError: e.isError,
1929
+ sidecar: e.toolUseResultSidecar,
1804
1930
  isComplete: !0,
1805
- traceId: e.traceId ?? i.traceId
1931
+ traceId: t.traceId ?? o.traceId
1806
1932
  };
1807
- r.set(o, s);
1933
+ r.set(s, i);
1808
1934
  }
1809
- return new S({ messages: r, pendingConsent: this.pendingConsent });
1935
+ return new b({ messages: r, pendingConsent: this.pendingConsent });
1936
+ }
1937
+ onToolCallConsent(t) {
1938
+ const e = t.fact.toolCallConsent;
1939
+ return new b({ messages: this.messages, pendingConsent: e });
1940
+ }
1941
+ onSubagentStart(t) {
1942
+ const e = t.fact.subagentStart, r = new Map(this.messages), s = `subagent:${e.parentToolUseId}:start`, o = {
1943
+ type: "subagent",
1944
+ messageId: s,
1945
+ kind: "start",
1946
+ parentToolUseId: e.parentToolUseId,
1947
+ agentId: e.agentId,
1948
+ subagentType: e.subagentType,
1949
+ description: e.description,
1950
+ time: /* @__PURE__ */ new Date(),
1951
+ traceId: t.traceId
1952
+ };
1953
+ return r.set(s, o), new b({ messages: r, pendingConsent: this.pendingConsent });
1954
+ }
1955
+ onSubagentComplete(t) {
1956
+ const e = t.fact.subagentComplete, r = new Map(this.messages), s = `subagent:${e.parentToolUseId}:complete`, o = {
1957
+ type: "subagent",
1958
+ messageId: s,
1959
+ kind: "complete",
1960
+ parentToolUseId: e.parentToolUseId,
1961
+ agentId: e.agentId,
1962
+ subagentType: e.subagentType,
1963
+ status: e.status,
1964
+ summary: e.summary,
1965
+ time: /* @__PURE__ */ new Date(),
1966
+ traceId: t.traceId
1967
+ };
1968
+ return r.set(s, o), new b({ messages: r, pendingConsent: this.pendingConsent });
1810
1969
  }
1811
- onToolCallConsent(e) {
1812
- const t = e.fact.toolCallConsent;
1813
- return new S({ messages: this.messages, pendingConsent: t });
1970
+ }
1971
+ const cn = /* @__PURE__ */ new Set(["TaskCreate", "TaskUpdate"]);
1972
+ function un(n) {
1973
+ return n.toolsetName === "" && cn.has(n.toolName);
1974
+ }
1975
+ function me(n) {
1976
+ return typeof n == "object" && n !== null ? n : void 0;
1977
+ }
1978
+ function E(n) {
1979
+ return typeof n == "string" ? n : void 0;
1980
+ }
1981
+ function ln(n) {
1982
+ const t = [], e = /* @__PURE__ */ new Map();
1983
+ for (const r of n) {
1984
+ const s = r.parameter ?? {}, o = r.sidecar ?? {};
1985
+ if (r.toolName === "TaskCreate") {
1986
+ const i = me(o.task), a = E(i?.id);
1987
+ if (!a) continue;
1988
+ e.has(a) || t.push(a), e.set(a, {
1989
+ id: a,
1990
+ subject: E(s.subject) || E(i?.subject) || "",
1991
+ activeForm: E(s.activeForm),
1992
+ description: E(s.description),
1993
+ status: e.get(a)?.status ?? "pending"
1994
+ // initial status = pending (keep existing on repeat)
1995
+ });
1996
+ } else if (r.toolName === "TaskUpdate") {
1997
+ const i = me(o.statusChange), a = E(s.taskId) || E(o.taskId), u = E(i?.to) || E(s.status);
1998
+ if (!a || !u) continue;
1999
+ const c = e.get(a);
2000
+ c && e.set(a, { ...c, status: u });
2001
+ }
1814
2002
  }
2003
+ return t.map((r) => e.get(r));
1815
2004
  }
1816
- class J {
2005
+ function dn(n) {
2006
+ return n.toolsetName === "" && n.toolName === "Agent";
2007
+ }
2008
+ function hn(n) {
2009
+ return !!n;
2010
+ }
2011
+ function fn(n) {
2012
+ const t = [], e = /* @__PURE__ */ new Map(), r = /* @__PURE__ */ new Map(), s = (o) => (e.has(o) || (t.push(o), e.set(o, { status: "running" }), r.set(o, /* @__PURE__ */ new Map())), e.get(o));
2013
+ for (const o of n)
2014
+ switch (o.kind) {
2015
+ case "agentStart": {
2016
+ const i = s(o.toolUseId);
2017
+ o.description && !i.description && (i.description = o.description);
2018
+ break;
2019
+ }
2020
+ case "subagentStart": {
2021
+ const i = s(o.parentToolUseId);
2022
+ i.agentId = o.agentId ?? i.agentId, i.subagentType = o.subagentType ?? i.subagentType, i.description = o.description ?? i.description;
2023
+ break;
2024
+ }
2025
+ case "toolStart": {
2026
+ s(o.parentToolUseId), r.get(o.parentToolUseId).set(o.toolUseId, {
2027
+ toolsetName: o.toolsetName,
2028
+ toolName: o.toolName,
2029
+ parameter: o.parameter ?? {},
2030
+ reason: o.reason,
2031
+ status: "running"
2032
+ });
2033
+ break;
2034
+ }
2035
+ case "toolComplete": {
2036
+ const i = r.get(o.parentToolUseId)?.get(o.toolUseId);
2037
+ i && (i.status = o.isError ? "error" : "completed");
2038
+ break;
2039
+ }
2040
+ case "subagentComplete": {
2041
+ const i = s(o.parentToolUseId);
2042
+ i.status = o.status, i.summary = o.summary;
2043
+ break;
2044
+ }
2045
+ }
2046
+ return t.map((o) => ({
2047
+ parentToolUseId: o,
2048
+ ...e.get(o),
2049
+ tools: Array.from(r.get(o).values())
2050
+ }));
2051
+ }
2052
+ function pn(n) {
2053
+ return typeof n == "string" ? n : void 0;
2054
+ }
2055
+ function gn(n) {
2056
+ const t = [];
2057
+ for (const e of n) {
2058
+ if (e.type === "tool-call" && dn(e)) {
2059
+ t.push({
2060
+ kind: "agentStart",
2061
+ toolUseId: e.toolUseId ?? e.messageId,
2062
+ description: pn(e.parameter.description)
2063
+ });
2064
+ continue;
2065
+ }
2066
+ if (e.type === "tool-call" && hn(e.parentToolUseId)) {
2067
+ const r = e.toolUseId ?? e.messageId;
2068
+ t.push({
2069
+ kind: "toolStart",
2070
+ parentToolUseId: e.parentToolUseId,
2071
+ toolUseId: r,
2072
+ toolsetName: e.toolsetName,
2073
+ toolName: e.toolName,
2074
+ parameter: e.parameter,
2075
+ reason: e.reason
2076
+ }), e.isComplete && t.push({
2077
+ kind: "toolComplete",
2078
+ parentToolUseId: e.parentToolUseId,
2079
+ toolUseId: r,
2080
+ isError: e.isError
2081
+ });
2082
+ continue;
2083
+ }
2084
+ if (e.type === "subagent" && e.kind === "start") {
2085
+ t.push({
2086
+ kind: "subagentStart",
2087
+ parentToolUseId: e.parentToolUseId,
2088
+ agentId: e.agentId,
2089
+ subagentType: e.subagentType,
2090
+ description: e.description
2091
+ });
2092
+ continue;
2093
+ }
2094
+ e.type === "subagent" && e.kind === "complete" && e.status && t.push({
2095
+ kind: "subagentComplete",
2096
+ parentToolUseId: e.parentToolUseId,
2097
+ status: e.status,
2098
+ summary: e.summary
2099
+ });
2100
+ }
2101
+ return t;
2102
+ }
2103
+ function mn(n) {
2104
+ const t = Array.from(n.messages?.values() ?? []).filter(
2105
+ (e) => e.type === "tool-call" && e.isComplete && un(e)
2106
+ );
2107
+ return ln(t);
2108
+ }
2109
+ function vn(n) {
2110
+ return fn(gn(Array.from(n.messages?.values() ?? [])));
2111
+ }
2112
+ function yn(n, t) {
2113
+ return n === t ? !0 : n.length !== t.length ? !1 : n.every((e, r) => {
2114
+ const s = t[r];
2115
+ return e.id === s.id && e.status === s.status && e.subject === s.subject && e.activeForm === s.activeForm && e.description === s.description;
2116
+ });
2117
+ }
2118
+ function bn(n, t) {
2119
+ return n.length !== t.length ? !1 : n.every((e, r) => {
2120
+ const s = t[r];
2121
+ return e.toolName === s.toolName && e.toolsetName === s.toolsetName && e.status === s.status && e.reason === s.reason;
2122
+ });
2123
+ }
2124
+ function Sn(n, t) {
2125
+ return n === t ? !0 : n.length !== t.length ? !1 : n.every((e, r) => {
2126
+ const s = t[r];
2127
+ return e.parentToolUseId === s.parentToolUseId && e.status === s.status && e.subagentType === s.subagentType && e.description === s.description && e.summary === s.summary && bn(e.tools, s.tools);
2128
+ });
2129
+ }
2130
+ function In(n) {
2131
+ const t = new N([]), e = new N([]), r = new U();
2132
+ return r.add(n.pipe(P(mn), Z(yn)).subscribe(t)), r.add(
2133
+ n.pipe(P(vn), Z(Sn)).subscribe(e)
2134
+ ), {
2135
+ tasks$: t.asObservable(),
2136
+ subagents$: e.asObservable(),
2137
+ getTasks: () => t.value,
2138
+ getSubagents: () => e.value,
2139
+ teardown: () => r.unsubscribe()
2140
+ };
2141
+ }
2142
+ class K {
1817
2143
  client;
1818
2144
  customChannelId;
1819
2145
  customMessageId;
1820
2146
  isConnecting$;
1821
2147
  conversation$;
2148
+ channelTitleSubject;
2149
+ derivedStores;
1822
2150
  statesObserver;
1823
2151
  statesSubscription;
2152
+ /** Reactive Task Check List store (F-013): emits only when the list changes; replays the snapshot. */
2153
+ tasks$;
2154
+ /** Reactive Subagent list store (F-013): emits only when the list changes; replays the snapshot. */
2155
+ subagents$;
2156
+ /** Reactive channel title store (F-016): seeded from metadata, updated by `title.update`; replay-safe. */
2157
+ channelTitle$;
1824
2158
  currentUserMessageId;
1825
2159
  // The most-recently-sent user message id. Unlike currentUserMessageId (which
1826
2160
  // is cleared once a traceId is attached), this is kept across the SSE
1827
2161
  // lifecycle so RESPONSE_TOOL_CALL_CONSENT — fired after run.done — can echo
1828
2162
  // back the message id the bot is waiting on.
1829
2163
  lastSentMessageId;
1830
- constructor(e) {
1831
- if (!e.client)
2164
+ constructor(t) {
2165
+ if (!t.client)
1832
2166
  throw new Error("client must be required");
1833
- if (!e.customChannelId)
2167
+ if (!t.customChannelId)
1834
2168
  throw new Error("customChannelId must be required");
1835
- this.client = e.client, this.customChannelId = e.customChannelId, this.customMessageId = e.customMessageId, this.isConnecting$ = new ie(!1), this.conversation$ = new ie(e.conversation), this.statesObserver = e.statesObserver;
2169
+ this.client = t.client, this.customChannelId = t.customChannelId, this.customMessageId = t.customMessageId, this.isConnecting$ = new N(!1), this.conversation$ = new N(t.conversation), this.channelTitleSubject = new N(t.channelTitle ?? null), this.derivedStores = In(this.conversation$), this.tasks$ = this.derivedStores.tasks$, this.subagents$ = this.derivedStores.subagents$, this.channelTitle$ = this.channelTitleSubject.pipe(Z()), this.statesObserver = t.statesObserver;
2170
+ }
2171
+ /** Current Task Check List snapshot (F-013) — for framework-agnostic `getSnapshot()` bridging. */
2172
+ getTasks() {
2173
+ return this.derivedStores.getTasks();
2174
+ }
2175
+ /** Current Subagent list snapshot (F-013) — for framework-agnostic `getSnapshot()` bridging. */
2176
+ getSubagents() {
2177
+ return this.derivedStores.getSubagents();
2178
+ }
2179
+ /** Current channel title snapshot (F-016) — for framework-agnostic `getSnapshot()` bridging. */
2180
+ getChannelTitle() {
2181
+ return this.channelTitleSubject.value;
2182
+ }
2183
+ /** Seed / override the channel title (F-016) — used by the join-restore metadata seed (F-015). */
2184
+ setChannelTitle(t) {
2185
+ this.channelTitleSubject.next(t);
1836
2186
  }
1837
- static create(e) {
1838
- const t = new J(e);
1839
- return t.subscribe(), t;
2187
+ static create(t) {
2188
+ const e = new K(t);
2189
+ return e.subscribe(), e;
1840
2190
  }
1841
- static async reset(e, t, r, o) {
1842
- const i = new J(e);
2191
+ static async reset(t, e, r, s) {
2192
+ const o = new K(t);
1843
2193
  try {
1844
- return i.subscribe(), o?.(i), await i.resetChannel(t, r), i;
1845
- } catch (s) {
1846
- throw i.close(), s;
2194
+ return o.subscribe(), s?.(o), await o.resetChannel(e, r), o;
2195
+ } catch (i) {
2196
+ throw o.close(), i;
2197
+ }
2198
+ }
2199
+ /**
2200
+ * Join an **existing** channel without resetting it (F-015). Seeds the title from `config.channelTitle`
2201
+ * (the `GET /channel/metadata` value) at construction, then replays the server transcript via GET
2202
+ * `rejoinSse` and holds `isConnecting` until the run reaches a terminal. Never sends `RESET_CHANNEL`,
2203
+ * so the channel's history / session / title are preserved — this is the fix for the mount-time
2204
+ * "join an existing channel and wipe its history" data-loss bug.
2205
+ */
2206
+ static async restore(t, e, r) {
2207
+ const s = new K(t);
2208
+ try {
2209
+ return s.subscribe(), r?.(s), await s.rejoinChannel(e), s;
2210
+ } catch (o) {
2211
+ throw s.close(), o;
1847
2212
  }
1848
2213
  }
1849
2214
  subscribe() {
1850
- this.statesSubscription = Rt([this.isConnecting$, this.conversation$]).pipe(
1851
- G(([e, t]) => ({
1852
- isConnecting: e,
1853
- conversation: t
2215
+ this.statesSubscription = Rt([
2216
+ this.isConnecting$,
2217
+ this.conversation$,
2218
+ this.derivedStores.tasks$,
2219
+ this.derivedStores.subagents$,
2220
+ this.channelTitle$
2221
+ ]).pipe(
2222
+ P(([t, e, r, s, o]) => ({
2223
+ isConnecting: t,
2224
+ conversation: e,
2225
+ tasks: r,
2226
+ subagents: s,
2227
+ channelTitle: o
1854
2228
  }))
1855
2229
  ).subscribe(this.statesObserver);
1856
2230
  }
1857
2231
  /**
1858
2232
  * Resolves payload by executing it if it's a function, otherwise returns as-is.
1859
2233
  */
1860
- resolvePayload(e) {
1861
- if (typeof e == "function")
2234
+ resolvePayload(t) {
2235
+ if (typeof t == "function")
1862
2236
  try {
1863
- return e();
1864
- } catch (t) {
2237
+ return t();
2238
+ } catch (e) {
1865
2239
  throw new Error(
1866
- `Failed to resolve payload function: ${t instanceof Error ? t.message : String(t)}`
2240
+ `Failed to resolve payload function: ${e instanceof Error ? e.message : String(e)}`
1867
2241
  );
1868
2242
  }
1869
- return e;
2243
+ return t;
1870
2244
  }
1871
- fetchSse(e, t) {
1872
- return new Promise((r, o) => {
1873
- this.isConnecting$.next(!0), this.client.fetchSse(e, {
1874
- onSseStart: t?.onSseStart,
1875
- onSseMessage: (i) => {
1876
- if (t?.onSseMessage?.(i), this.currentUserMessageId && i.traceId) {
1877
- const s = new Map(this.conversation$.value.messages), a = s.get(this.currentUserMessageId);
1878
- a && a.type === "user" && (s.set(this.currentUserMessageId, {
1879
- ...a,
1880
- traceId: i.traceId
1881
- }), this.conversation$.next(new S({ messages: s }))), this.currentUserMessageId = void 0;
1882
- }
1883
- this.conversation$.next(this.conversation$.value.onMessage(i));
1884
- },
1885
- onSseError: (i) => {
1886
- t?.onSseError?.(i), this.isConnecting$.next(!1), this.currentUserMessageId = void 0, o(i);
1887
- },
1888
- onSseCompleted: () => {
1889
- t?.onSseCompleted?.(), this.isConnecting$.next(!1), this.currentUserMessageId = void 0, r();
2245
+ /**
2246
+ * The SSE run handlers shared by every run kind (POST send/reset and GET rejoin): fold each frame
2247
+ * through the conversation reducer, keep the title store in sync, attach the traceId to the pending
2248
+ * user bubble, and settle the run promise (releasing `isConnecting`) on completion / error.
2249
+ */
2250
+ buildRunHandlers(t, e, r) {
2251
+ return {
2252
+ onSseStart: t?.onSseStart,
2253
+ onSseMessage: (s) => {
2254
+ if (t?.onSseMessage?.(s), s.eventType === d.CHANNEL_TITLE_UPDATE && this.channelTitleSubject.next(
2255
+ s.fact.channelTitleUpdate.title
2256
+ ), this.currentUserMessageId && s.traceId) {
2257
+ const o = new Map(this.conversation$.value.messages), i = o.get(this.currentUserMessageId);
2258
+ i && i.type === "user" && (o.set(this.currentUserMessageId, {
2259
+ ...i,
2260
+ traceId: s.traceId
2261
+ }), this.conversation$.next(new b({ messages: o }))), this.currentUserMessageId = void 0;
1890
2262
  }
1891
- });
2263
+ this.conversation$.next(this.conversation$.value.onMessage(s));
2264
+ },
2265
+ onSseError: (s) => {
2266
+ t?.onSseError?.(s), this.isConnecting$.next(!1), this.currentUserMessageId = void 0, r(s);
2267
+ },
2268
+ onSseCompleted: () => {
2269
+ t?.onSseCompleted?.(), this.isConnecting$.next(!1), this.currentUserMessageId = void 0, e();
2270
+ }
2271
+ };
2272
+ }
2273
+ fetchSse(t, e) {
2274
+ return new Promise((r, s) => {
2275
+ this.isConnecting$.next(!0), this.client.fetchSse(t, this.buildRunHandlers(e, r, s));
2276
+ });
2277
+ }
2278
+ /**
2279
+ * Join-restore transport (F-015): replay the server transcript via GET `rejoinSse` (F-014) and, if a
2280
+ * run is still live, keep listening until its terminal — holding `isConnecting` the whole time so the
2281
+ * input stays gated (F-003). A client without GET-replay support settles immediately (nothing to
2282
+ * restore), so the input is released rather than stuck.
2283
+ */
2284
+ rejoinChannel(t) {
2285
+ return new Promise((e, r) => {
2286
+ if (!this.client.rejoinSse) {
2287
+ e();
2288
+ return;
2289
+ }
2290
+ this.isConnecting$.next(!0), this.client.rejoinSse(this.customChannelId, this.buildRunHandlers(t, e, r));
1892
2291
  });
1893
2292
  }
1894
- resetChannel(e, t) {
2293
+ resetChannel(t, e) {
1895
2294
  return this.fetchSse(
1896
2295
  {
1897
- action: k.RESET_CHANNEL,
2296
+ action: H.RESET_CHANNEL,
1898
2297
  customChannelId: this.customChannelId,
1899
2298
  customMessageId: this.customMessageId,
1900
- text: e?.text || "",
1901
- payload: this.resolvePayload(e?.payload)
2299
+ text: t?.text || "",
2300
+ payload: this.resolvePayload(t?.payload)
1902
2301
  },
1903
- t
2302
+ e
1904
2303
  );
1905
2304
  }
1906
- sendMessage(e, t) {
1907
- const r = e.text.trim(), o = e.customMessageId ?? $e();
1908
- return this.currentUserMessageId = o, this.lastSentMessageId = o, this.conversation$.next(
2305
+ sendMessage(t, e) {
2306
+ const r = t.text.trim(), s = t.customMessageId ?? De();
2307
+ return this.currentUserMessageId = s, this.lastSentMessageId = s, this.conversation$.next(
1909
2308
  this.conversation$.value.pushMessage({
1910
2309
  type: "user",
1911
- messageId: o,
2310
+ messageId: s,
1912
2311
  text: r,
1913
- blobIds: e.blobIds,
1914
- filePreviewUrls: e.filePreviewUrls,
1915
- documentNames: e.documentNames,
2312
+ blobIds: t.blobIds,
2313
+ filePreviewUrls: t.filePreviewUrls,
2314
+ documentNames: t.documentNames,
1916
2315
  time: /* @__PURE__ */ new Date()
1917
2316
  })
1918
2317
  ), this.fetchSse(
1919
2318
  {
1920
- action: k.NONE,
2319
+ action: H.NONE,
1921
2320
  customChannelId: this.customChannelId,
1922
- customMessageId: o,
1923
- payload: this.resolvePayload(e?.payload),
2321
+ customMessageId: s,
2322
+ payload: this.resolvePayload(t?.payload),
1924
2323
  text: r,
1925
- blobIds: e?.blobIds
2324
+ blobIds: t?.blobIds
1926
2325
  },
1927
- t
2326
+ e
1928
2327
  );
1929
2328
  }
1930
- replyToolCallConsents(e, t, r) {
2329
+ replyToolCallConsents(t, e, r) {
1931
2330
  return this.conversation$.next(this.conversation$.value.clearPendingConsent()), this.fetchSse(
1932
2331
  {
1933
- action: k.RESPONSE_TOOL_CALL_CONSENT,
2332
+ action: H.RESPONSE_TOOL_CALL_CONSENT,
1934
2333
  customChannelId: this.customChannelId,
1935
2334
  customMessageId: this.lastSentMessageId ?? this.customMessageId,
1936
2335
  payload: this.resolvePayload(r),
1937
2336
  text: "",
1938
- toolCallConsents: e
2337
+ toolCallConsents: t
1939
2338
  },
1940
- t
2339
+ e
1941
2340
  );
1942
2341
  }
1943
2342
  close() {
1944
- this.isConnecting$.complete(), this.conversation$.complete(), this.statesSubscription?.unsubscribe();
2343
+ this.isConnecting$.complete(), this.conversation$.complete(), this.channelTitleSubject.complete(), this.derivedStores.teardown(), this.statesSubscription?.unsubscribe();
1945
2344
  }
1946
2345
  }
1947
2346
  export {
1948
- sn as AsgardServiceClient,
1949
- J as Channel,
1950
- S as Conversation,
2347
+ wn as AsgardServiceClient,
2348
+ K as Channel,
2349
+ b as Conversation,
1951
2350
  d as EventType,
1952
- k as FetchSseAction,
1953
- de as HttpError,
1954
- He as MessageTemplateType,
1955
- je as ToolCallConsentResult,
1956
- on as isHttpError
2351
+ H as FetchSseAction,
2352
+ te as HttpError,
2353
+ Fe as MessageTemplateType,
2354
+ Ke as ToolCallConsentResult,
2355
+ gn as conversationToSubagentEvents,
2356
+ In as createDerivedStores,
2357
+ vn as deriveSubagents,
2358
+ mn as deriveTasks,
2359
+ dn as isAgentTool,
2360
+ En as isHttpError,
2361
+ hn as isSubagentChildTool,
2362
+ un as isTaskTool,
2363
+ fn as reduceSubagents,
2364
+ ln as reduceTaskEvents,
2365
+ Sn as subagentsEqual,
2366
+ yn as tasksEqual
1957
2367
  };
1958
2368
  //# sourceMappingURL=index.mjs.map