@opencx/widget-core 5.2.0 → 5.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.cjs +5 -5
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +597 -515
- package/dist/index.js.map +1 -1
- package/dist/src/api/api-caller.d.ts +41 -7
- package/dist/src/api/api-caller.d.ts.map +1 -1
- package/dist/src/api/schema.d.ts +52 -0
- package/dist/src/api/schema.d.ts.map +1 -1
- package/dist/src/context/session.ctx.d.ts +2 -1
- package/dist/src/context/session.ctx.d.ts.map +1 -1
- package/dist/src/context/unread.ctx.d.ts +59 -0
- package/dist/src/context/unread.ctx.d.ts.map +1 -0
- package/dist/src/context/widget-agent.d.ts.map +1 -1
- package/dist/src/context/widget.ctx.d.ts +4 -0
- package/dist/src/context/widget.ctx.d.ts.map +1 -1
- package/dist/src/index.d.ts +2 -0
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/translation/ar.d.ts.map +1 -1
- package/dist/src/translation/en.d.ts.map +1 -1
- package/dist/src/translation/index.d.ts +2 -0
- package/dist/src/translation/index.d.ts.map +1 -1
- package/dist/src/types/component-name.d.ts +1 -1
- package/dist/src/types/component-name.d.ts.map +1 -1
- package/dist/src/types/widget-config.d.ts +28 -0
- package/dist/src/types/widget-config.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -1,17 +1,109 @@
|
|
|
1
|
-
import { z as h } from "zod";
|
|
2
|
-
import te from "openapi-fetch";
|
|
3
1
|
import se from "lodash.isequal";
|
|
4
|
-
import {
|
|
5
|
-
|
|
2
|
+
import { z as h } from "zod";
|
|
3
|
+
import oe from "openapi-fetch";
|
|
4
|
+
import { v4 as R } from "uuid";
|
|
5
|
+
const L = "[opencx]", k = {
|
|
6
|
+
warn: (i, ...e) => {
|
|
7
|
+
console.warn(`${L} ${i}`, ...e);
|
|
8
|
+
},
|
|
9
|
+
error: (i, ...e) => {
|
|
10
|
+
console.error(`${L} ${i}`, ...e);
|
|
11
|
+
}
|
|
12
|
+
};
|
|
13
|
+
class S {
|
|
14
|
+
constructor(e) {
|
|
15
|
+
this.subscribers = /* @__PURE__ */ new Set(), this.get = () => this.state, this.set = (t) => {
|
|
16
|
+
se(this.state, t) || (this.state = t, this.notifySubscribers(t));
|
|
17
|
+
}, this.setPartial = (t) => {
|
|
18
|
+
if (t == null) return;
|
|
19
|
+
const o = { ...this.state, ...t };
|
|
20
|
+
this.set(o);
|
|
21
|
+
}, this.reset = () => {
|
|
22
|
+
this.set(this.initialState);
|
|
23
|
+
}, this.notifySubscribers = (t) => {
|
|
24
|
+
Array.from(this.subscribers).forEach((r) => {
|
|
25
|
+
try {
|
|
26
|
+
r(t);
|
|
27
|
+
} catch (_) {
|
|
28
|
+
k.error("state subscriber threw", _);
|
|
29
|
+
}
|
|
30
|
+
});
|
|
31
|
+
}, this.subscribe = (t) => (this.subscribers.add(t), () => {
|
|
32
|
+
this.subscribers.delete(t);
|
|
33
|
+
}), this.state = e, this.initialState = e;
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
const ne = 5e3;
|
|
37
|
+
class ie {
|
|
38
|
+
constructor({
|
|
39
|
+
config: e,
|
|
40
|
+
api: t,
|
|
41
|
+
sessionsState: o,
|
|
42
|
+
setSessions: r
|
|
43
|
+
}) {
|
|
44
|
+
this.state = new S({ unreadSessionIds: [], count: 0 }), this.viewingSessionId = null, this.readsInFlight = /* @__PURE__ */ new Set(), this.retryTimer = null, this.lastNotifiedCount = null, this.subscriptions = [], this.disposed = !1, this.dispose = () => {
|
|
45
|
+
this.disposed = !0, this.subscriptions.forEach((_) => _()), this.subscriptions = [], this.viewingSessionId = null, this.retryTimer && clearTimeout(this.retryTimer), this.retryTimer = null;
|
|
46
|
+
}, this.setViewingSessionId = (_) => {
|
|
47
|
+
this.viewingSessionId = _, this.evaluate(this.sessionsState.get().data);
|
|
48
|
+
}, this.evaluate = (_) => {
|
|
49
|
+
const s = [];
|
|
50
|
+
for (const a of _)
|
|
51
|
+
if (a.unread === !0) {
|
|
52
|
+
if (a.id === this.viewingSessionId) {
|
|
53
|
+
this.markViewedSessionRead(a.id);
|
|
54
|
+
continue;
|
|
55
|
+
}
|
|
56
|
+
s.push(a.id);
|
|
57
|
+
}
|
|
58
|
+
this.state.set({ unreadSessionIds: s, count: s.length }), this.notifyCount(s.length);
|
|
59
|
+
}, this.markViewedSessionRead = (_) => {
|
|
60
|
+
if (this.readsInFlight.has(_)) return;
|
|
61
|
+
this.readsInFlight.add(_);
|
|
62
|
+
let s = !1;
|
|
63
|
+
this.api.markSessionRead({ sessionId: _ }).then(({ data: a }) => {
|
|
64
|
+
if (!a || this.disposed) return;
|
|
65
|
+
const n = this.sessionsState.get().data.find((c) => c.id === a.id);
|
|
66
|
+
n && re(n, a) ? s = !0 : this.setSessions([a]);
|
|
67
|
+
}).catch((a) => {
|
|
68
|
+
k.warn("failed to mark the session read", {
|
|
69
|
+
sessionId: _,
|
|
70
|
+
error: a instanceof Error ? a.message : String(a)
|
|
71
|
+
}), this.scheduleRetry();
|
|
72
|
+
}).finally(() => {
|
|
73
|
+
this.readsInFlight.delete(_), s && !this.disposed && this.evaluate(this.sessionsState.get().data);
|
|
74
|
+
});
|
|
75
|
+
}, this.scheduleRetry = () => {
|
|
76
|
+
this.retryTimer || this.disposed || (this.retryTimer = setTimeout(() => {
|
|
77
|
+
this.retryTimer = null, this.evaluate(this.sessionsState.get().data);
|
|
78
|
+
}, ne));
|
|
79
|
+
}, this.notifyCount = (_) => {
|
|
80
|
+
var s, a;
|
|
81
|
+
if (_ !== this.lastNotifiedCount) {
|
|
82
|
+
this.lastNotifiedCount = _;
|
|
83
|
+
try {
|
|
84
|
+
(a = (s = this.config.hooks) == null ? void 0 : s.onUnreadCountChange) == null || a.call(s, _);
|
|
85
|
+
} catch (n) {
|
|
86
|
+
k.error("onUnreadCountChange hook failed", n);
|
|
87
|
+
}
|
|
88
|
+
}
|
|
89
|
+
}, this.config = e, this.api = t, this.sessionsState = o, this.setSessions = r, this.subscriptions.push(
|
|
90
|
+
o.subscribe(({ data: _ }) => this.evaluate(_))
|
|
91
|
+
);
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
function re(i, e) {
|
|
95
|
+
return new Date(i.updatedAt).getTime() > new Date(e.updatedAt).getTime();
|
|
96
|
+
}
|
|
97
|
+
const Ya = (i) => i.type === "data-keepalive", Xa = (i) => i.type === "data-turn-steered", O = h.object({ const: h.string(), title: h.string().optional() }), _e = h.object({
|
|
6
98
|
type: h.enum(["string", "number", "integer", "boolean", "array"]),
|
|
7
99
|
title: h.string().optional(),
|
|
8
100
|
description: h.string().optional(),
|
|
9
101
|
default: h.union([h.string(), h.number(), h.boolean(), h.array(h.string())]).optional(),
|
|
10
102
|
enum: h.array(h.string()).optional(),
|
|
11
|
-
oneOf: h.array(
|
|
103
|
+
oneOf: h.array(O).optional(),
|
|
12
104
|
items: h.object({
|
|
13
105
|
enum: h.array(h.string()).optional(),
|
|
14
|
-
anyOf: h.array(
|
|
106
|
+
anyOf: h.array(O).optional()
|
|
15
107
|
}).optional(),
|
|
16
108
|
minItems: h.number().int().nonnegative().optional(),
|
|
17
109
|
maxItems: h.number().int().nonnegative().optional(),
|
|
@@ -20,7 +112,7 @@ const Wa = (i) => i.type === "data-keepalive", $a = (i) => i.type === "data-turn
|
|
|
20
112
|
minLength: h.number().optional(),
|
|
21
113
|
maxLength: h.number().optional(),
|
|
22
114
|
format: h.string().optional()
|
|
23
|
-
}),
|
|
115
|
+
}), le = h.array(
|
|
24
116
|
h.object({
|
|
25
117
|
id: h.string(),
|
|
26
118
|
serverId: h.string(),
|
|
@@ -30,12 +122,12 @@ const Wa = (i) => i.type === "data-keepalive", $a = (i) => i.type === "data-turn
|
|
|
30
122
|
form: h.object({
|
|
31
123
|
message: h.string(),
|
|
32
124
|
requestedSchema: h.object({
|
|
33
|
-
properties: h.record(h.string(),
|
|
125
|
+
properties: h.record(h.string(), _e),
|
|
34
126
|
required: h.array(h.string()).optional()
|
|
35
127
|
})
|
|
36
128
|
})
|
|
37
129
|
})
|
|
38
|
-
),
|
|
130
|
+
), ce = h.array(
|
|
39
131
|
h.object({
|
|
40
132
|
key: h.string(),
|
|
41
133
|
serverId: h.string(),
|
|
@@ -43,39 +135,32 @@ const Wa = (i) => i.type === "data-keepalive", $a = (i) => i.type === "data-turn
|
|
|
43
135
|
message: h.string(),
|
|
44
136
|
toolName: h.string()
|
|
45
137
|
})
|
|
46
|
-
),
|
|
47
|
-
warn: (i, ...e) => {
|
|
48
|
-
console.warn(`${O} ${i}`, ...e);
|
|
49
|
-
},
|
|
50
|
-
error: (i, ...e) => {
|
|
51
|
-
console.error(`${O} ${i}`, ...e);
|
|
52
|
-
}
|
|
53
|
-
}, re = (i) => {
|
|
138
|
+
), pe = (i) => {
|
|
54
139
|
k.error("request failed", i.error);
|
|
55
|
-
},
|
|
56
|
-
const e =
|
|
140
|
+
}, de = (i) => {
|
|
141
|
+
const e = oe({
|
|
57
142
|
baseUrl: i.baseUrl
|
|
58
143
|
}), t = {
|
|
59
144
|
onRequest: i.onRequest,
|
|
60
145
|
onResponse: i.onResponse,
|
|
61
|
-
onError: i.onError ||
|
|
146
|
+
onError: i.onError || pe
|
|
62
147
|
};
|
|
63
148
|
return e.use(t), e;
|
|
64
149
|
};
|
|
65
|
-
class
|
|
150
|
+
class ue extends Error {
|
|
66
151
|
constructor() {
|
|
67
152
|
super("This connection request expired. Preparing a new request."), this.name = "ConnectionRequestExpiredError";
|
|
68
153
|
}
|
|
69
154
|
}
|
|
70
|
-
class
|
|
155
|
+
class me extends Error {
|
|
71
156
|
constructor() {
|
|
72
157
|
super("This connection attempt is no longer available."), this.name = "ConnectionAttemptUnavailableError";
|
|
73
158
|
}
|
|
74
159
|
}
|
|
75
|
-
const
|
|
160
|
+
const he = "/backend/widget/v5/chat/stream", ge = "/backend/widget/v5/chat/{sessionId}/stream", F = (i, e, t) => `${i.replace(/\/$/, "")}${t ? e.replace("{sessionId}", encodeURIComponent(t)) : e}`;
|
|
76
161
|
class U {
|
|
77
162
|
constructor({ config: e }) {
|
|
78
|
-
var r,
|
|
163
|
+
var r, _;
|
|
79
164
|
this.userToken = null, this.constructClientOptions = (s) => {
|
|
80
165
|
const a = this.config.apiUrl || "https://api.open.cx", n = {
|
|
81
166
|
"X-Bot-Token": this.config.token,
|
|
@@ -87,11 +172,11 @@ class U {
|
|
|
87
172
|
}, this.createOpenAPIClient = ({
|
|
88
173
|
baseUrl: s,
|
|
89
174
|
headers: a
|
|
90
|
-
}) =>
|
|
175
|
+
}) => de({
|
|
91
176
|
baseUrl: s,
|
|
92
177
|
onRequest: ({ request: n }) => {
|
|
93
|
-
Object.entries(a).forEach(([
|
|
94
|
-
d && n.headers.set(
|
|
178
|
+
Object.entries(a).forEach(([c, d]) => {
|
|
179
|
+
d && n.headers.set(c, d);
|
|
95
180
|
});
|
|
96
181
|
}
|
|
97
182
|
}), this.listApprovalPreferences = async () => {
|
|
@@ -100,32 +185,32 @@ class U {
|
|
|
100
185
|
{ headers: a }
|
|
101
186
|
);
|
|
102
187
|
if (!n.ok) throw new Error("Could not load permissions.");
|
|
103
|
-
return
|
|
188
|
+
return ce.parse(await n.json());
|
|
104
189
|
}, this.revokeApprovalPreference = async (s, a) => {
|
|
105
|
-
const { baseUrl: n, headers:
|
|
190
|
+
const { baseUrl: n, headers: c } = this.getStreamAuthContext();
|
|
106
191
|
if (!(await fetch(
|
|
107
192
|
`${n}/backend/widget/v5/connections/${encodeURIComponent(s)}/approval-preferences/${encodeURIComponent(a)}`,
|
|
108
|
-
{ method: "DELETE", headers:
|
|
193
|
+
{ method: "DELETE", headers: c }
|
|
109
194
|
)).ok) throw new Error("Could not reset permission.");
|
|
110
195
|
}, this.listElicitations = async (s, a) => {
|
|
111
|
-
const { baseUrl: n, headers:
|
|
196
|
+
const { baseUrl: n, headers: c } = this.getStreamAuthContext(), d = await fetch(
|
|
112
197
|
`${n}/backend/widget/v5/connections/elicitation/${encodeURIComponent(s)}`,
|
|
113
|
-
{ headers:
|
|
198
|
+
{ headers: c, signal: a }
|
|
114
199
|
);
|
|
115
200
|
if (!d.ok) throw new Error("Could not load the request.");
|
|
116
|
-
return
|
|
201
|
+
return le.parse(await d.json());
|
|
117
202
|
}, this.answerElicitation = async (s, a, n) => {
|
|
118
|
-
const { baseUrl:
|
|
119
|
-
`${
|
|
203
|
+
const { baseUrl: c, headers: d } = this.getStreamAuthContext(), l = await fetch(
|
|
204
|
+
`${c}/backend/widget/v5/connections/elicitation/${encodeURIComponent(s)}/${encodeURIComponent(a)}`,
|
|
120
205
|
{
|
|
121
206
|
method: "POST",
|
|
122
207
|
headers: { ...d, "Content-Type": "application/json" },
|
|
123
208
|
body: JSON.stringify(n)
|
|
124
209
|
}
|
|
125
210
|
);
|
|
126
|
-
if (!
|
|
211
|
+
if (!l.ok)
|
|
127
212
|
throw new Error(
|
|
128
|
-
|
|
213
|
+
l.status === 400 ? "Check your answers and try again." : "This request has ended. Ask the agent to try again."
|
|
129
214
|
);
|
|
130
215
|
}, this.listConnections = async (s) => {
|
|
131
216
|
const { data: a, error: n } = await this.client.GET(
|
|
@@ -136,7 +221,7 @@ class U {
|
|
|
136
221
|
throw new Error("Could not load connections. Sign in and try again.");
|
|
137
222
|
return a;
|
|
138
223
|
}, this.startConnection = async (s, a, n) => {
|
|
139
|
-
const { data:
|
|
224
|
+
const { data: c, error: d, response: l } = await this.client.POST(
|
|
140
225
|
"/backend/widget/v5/connections/{serverId}/start",
|
|
141
226
|
{
|
|
142
227
|
params: { path: { serverId: s } },
|
|
@@ -144,25 +229,25 @@ class U {
|
|
|
144
229
|
signal: n
|
|
145
230
|
}
|
|
146
231
|
);
|
|
147
|
-
if (
|
|
148
|
-
if (
|
|
232
|
+
if (l.status === 410) throw new ue();
|
|
233
|
+
if (l.status === 404)
|
|
149
234
|
throw new Error("This connection request is no longer available.");
|
|
150
|
-
if (d || !
|
|
235
|
+
if (d || !c)
|
|
151
236
|
throw new Error("Could not start this connection. Please try again.");
|
|
152
|
-
return
|
|
237
|
+
return c;
|
|
153
238
|
}, this.getConnectionAttempt = async (s, a, n) => {
|
|
154
|
-
const { data:
|
|
239
|
+
const { data: c, error: d, response: l } = await this.client.GET(
|
|
155
240
|
"/backend/widget/v5/connections/{serverId}/attempts/{attemptId}",
|
|
156
241
|
{
|
|
157
242
|
params: { path: { serverId: s, attemptId: a } },
|
|
158
243
|
signal: n
|
|
159
244
|
}
|
|
160
245
|
);
|
|
161
|
-
if ([401, 403, 404].includes(
|
|
162
|
-
throw new
|
|
163
|
-
if (d || !
|
|
164
|
-
throw new Error(`Could not check the connection (${
|
|
165
|
-
return
|
|
246
|
+
if ([401, 403, 404].includes(l.status))
|
|
247
|
+
throw new me();
|
|
248
|
+
if (d || !c)
|
|
249
|
+
throw new Error(`Could not check the connection (${l.status}).`);
|
|
250
|
+
return c.status;
|
|
166
251
|
}, this.disconnectConnection = async (s) => {
|
|
167
252
|
const { error: a } = await this.client.DELETE(
|
|
168
253
|
"/backend/widget/v5/connections/{serverId}",
|
|
@@ -177,14 +262,14 @@ class U {
|
|
|
177
262
|
this.client = this.createOpenAPIClient({ baseUrl: a, headers: n });
|
|
178
263
|
}, this.getStreamAuthContext = () => {
|
|
179
264
|
const { baseUrl: s, headers: a } = this.constructClientOptions(this.userToken), n = {};
|
|
180
|
-
for (const [
|
|
181
|
-
typeof d == "string" && (["content-type", "accept"].includes(
|
|
265
|
+
for (const [c, d] of Object.entries(a))
|
|
266
|
+
typeof d == "string" && (["content-type", "accept"].includes(c.toLowerCase()) || (n[c] = d));
|
|
182
267
|
return { baseUrl: s, headers: n };
|
|
183
268
|
}, this.getStreamTransportOptions = () => {
|
|
184
269
|
const { baseUrl: s, headers: a } = this.getStreamAuthContext();
|
|
185
270
|
return {
|
|
186
|
-
api: F(s,
|
|
187
|
-
reconnectApi: (n) => F(s,
|
|
271
|
+
api: F(s, he),
|
|
272
|
+
reconnectApi: (n) => F(s, ge, n),
|
|
188
273
|
headers: a
|
|
189
274
|
};
|
|
190
275
|
}, this.stopStream = async (s) => {
|
|
@@ -203,7 +288,7 @@ class U {
|
|
|
203
288
|
} catch {
|
|
204
289
|
}
|
|
205
290
|
}, this.getAgentTurnMessages = async (s, a) => {
|
|
206
|
-
const { data: n, response:
|
|
291
|
+
const { data: n, response: c } = await this.client.GET(
|
|
207
292
|
"/backend/widget/v5/chat/{sessionId}/messages",
|
|
208
293
|
{
|
|
209
294
|
params: {
|
|
@@ -218,7 +303,7 @@ class U {
|
|
|
218
303
|
return n ? {
|
|
219
304
|
...n,
|
|
220
305
|
handled_connection_request_ids: n.handled_connection_request_ids ?? []
|
|
221
|
-
} : (k.warn("agent turn messages fetch failed",
|
|
306
|
+
} : (k.warn("agent turn messages fetch failed", c.status), null);
|
|
222
307
|
}, this.createDictationSession = async ({
|
|
223
308
|
language: s
|
|
224
309
|
}) => {
|
|
@@ -251,7 +336,16 @@ class U {
|
|
|
251
336
|
}) => await this.client.GET("/backend/widget/v2/poll/{sessionId}", {
|
|
252
337
|
params: { path: { sessionId: s } },
|
|
253
338
|
signal: a
|
|
254
|
-
}), this.
|
|
339
|
+
}), this.markSessionRead = async ({
|
|
340
|
+
sessionId: s,
|
|
341
|
+
abortSignal: a
|
|
342
|
+
}) => await this.client.POST(
|
|
343
|
+
"/backend/widget/v2/session/{sessionId}/read",
|
|
344
|
+
{
|
|
345
|
+
params: { path: { sessionId: s } },
|
|
346
|
+
signal: a
|
|
347
|
+
}
|
|
348
|
+
), this.getSessions = async ({
|
|
255
349
|
cursor: s,
|
|
256
350
|
filters: a,
|
|
257
351
|
abortSignal: n
|
|
@@ -267,10 +361,10 @@ class U {
|
|
|
267
361
|
file: s,
|
|
268
362
|
abortSignal: a,
|
|
269
363
|
onProgress: n
|
|
270
|
-
}) => new Promise((
|
|
364
|
+
}) => new Promise((c, d) => {
|
|
271
365
|
var f;
|
|
272
|
-
const
|
|
273
|
-
|
|
366
|
+
const l = new FormData();
|
|
367
|
+
l.append("file", s);
|
|
274
368
|
const p = new XMLHttpRequest();
|
|
275
369
|
if (a && (a.addEventListener("abort", () => {
|
|
276
370
|
p.abort(), d(new DOMException("Aborted", "AbortError"));
|
|
@@ -287,7 +381,7 @@ class U {
|
|
|
287
381
|
if (p.status >= 200 && p.status < 300)
|
|
288
382
|
try {
|
|
289
383
|
const v = JSON.parse(p.responseText);
|
|
290
|
-
|
|
384
|
+
c(v);
|
|
291
385
|
} catch (v) {
|
|
292
386
|
d(new Error(`Failed to parse response: ${v}`));
|
|
293
387
|
}
|
|
@@ -299,7 +393,7 @@ class U {
|
|
|
299
393
|
d(new Error("Upload timed out"));
|
|
300
394
|
});
|
|
301
395
|
const { baseUrl: u } = this.constructClientOptions(this.userToken), g = `${u}/backend/widget/v2/upload`;
|
|
302
|
-
p.open("POST", g), p.setRequestHeader("X-Bot-Token", this.config.token), this.userToken ?? ((f = this.config.user) == null ? void 0 : f.token) ? p.setRequestHeader("Authorization", `Bearer ${this.userToken}`) : k.error("user token not set"), p.send(
|
|
396
|
+
p.open("POST", g), p.setRequestHeader("X-Bot-Token", this.config.token), this.userToken ?? ((f = this.config.user) == null ? void 0 : f.token) ? p.setRequestHeader("Authorization", `Bearer ${this.userToken}`) : k.error("user token not set"), p.send(l);
|
|
303
397
|
}), this.vote = async (s) => await this.client.POST("/backend/widget/v2/chat/vote", { body: s }), this.resolveSession = async (s, a) => await this.client.POST("/backend/widget/v2/session/resolve", {
|
|
304
398
|
body: s,
|
|
305
399
|
signal: a
|
|
@@ -307,38 +401,15 @@ class U {
|
|
|
307
401
|
body: s
|
|
308
402
|
}), this.submitCsat = async (s) => await this.client.POST("/backend/widget/v2/submit-csat", { body: s }), this.config = e, this.userToken = ((r = e.user) == null ? void 0 : r.token) || null;
|
|
309
403
|
const { baseUrl: t, headers: o } = this.constructClientOptions(
|
|
310
|
-
(
|
|
404
|
+
(_ = e.user) == null ? void 0 : _.token
|
|
311
405
|
);
|
|
312
406
|
this.client = this.createOpenAPIClient({ baseUrl: t, headers: o });
|
|
313
407
|
}
|
|
314
408
|
}
|
|
315
|
-
function
|
|
409
|
+
function ke(i, e) {
|
|
316
410
|
k.error(`missing case for ${i} in ${e}`);
|
|
317
411
|
}
|
|
318
|
-
class
|
|
319
|
-
constructor(e) {
|
|
320
|
-
this.subscribers = /* @__PURE__ */ new Set(), this.get = () => this.state, this.set = (t) => {
|
|
321
|
-
se(this.state, t) || (this.state = t, this.notifySubscribers(t));
|
|
322
|
-
}, this.setPartial = (t) => {
|
|
323
|
-
if (t == null) return;
|
|
324
|
-
const o = { ...this.state, ...t };
|
|
325
|
-
this.set(o);
|
|
326
|
-
}, this.reset = () => {
|
|
327
|
-
this.set(this.initialState);
|
|
328
|
-
}, this.notifySubscribers = (t) => {
|
|
329
|
-
Array.from(this.subscribers).forEach((r) => {
|
|
330
|
-
try {
|
|
331
|
-
r(t);
|
|
332
|
-
} catch (c) {
|
|
333
|
-
k.error("state subscriber threw", c);
|
|
334
|
-
}
|
|
335
|
-
});
|
|
336
|
-
}, this.subscribe = (t) => (this.subscribers.add(t), () => {
|
|
337
|
-
this.subscribers.delete(t);
|
|
338
|
-
}), this.state = e, this.initialState = e;
|
|
339
|
-
}
|
|
340
|
-
}
|
|
341
|
-
class Z {
|
|
412
|
+
class W {
|
|
342
413
|
constructor() {
|
|
343
414
|
this.state = new S({
|
|
344
415
|
isPolling: !1,
|
|
@@ -352,10 +423,10 @@ class Z {
|
|
|
352
423
|
this.abortController = new AbortController(), this.state.setPartial({ isPolling: !0 });
|
|
353
424
|
try {
|
|
354
425
|
await e(this.abortController.signal);
|
|
355
|
-
} catch (
|
|
426
|
+
} catch (_) {
|
|
356
427
|
if (this.abortController.signal.aborted)
|
|
357
428
|
return;
|
|
358
|
-
k.error("failed to poll",
|
|
429
|
+
k.error("failed to poll", _), this.state.setPartial({ isError: !0 });
|
|
359
430
|
} finally {
|
|
360
431
|
this.state.setPartial({ isPolling: !1 });
|
|
361
432
|
}
|
|
@@ -367,7 +438,7 @@ class Z {
|
|
|
367
438
|
};
|
|
368
439
|
}
|
|
369
440
|
}
|
|
370
|
-
function
|
|
441
|
+
function $(i) {
|
|
371
442
|
try {
|
|
372
443
|
const e = i();
|
|
373
444
|
return e instanceof Promise ? e.then((t) => ({ data: t })).catch((t) => ({ error: t })) : { data: e };
|
|
@@ -375,15 +446,15 @@ function W(i) {
|
|
|
375
446
|
return { error: e };
|
|
376
447
|
}
|
|
377
448
|
}
|
|
378
|
-
class
|
|
449
|
+
class be {
|
|
379
450
|
constructor({
|
|
380
451
|
api: e,
|
|
381
452
|
config: t,
|
|
382
453
|
sessionCtx: o,
|
|
383
454
|
messageCtx: r,
|
|
384
|
-
sessionPollingIntervalSeconds:
|
|
455
|
+
sessionPollingIntervalSeconds: _
|
|
385
456
|
}) {
|
|
386
|
-
this.poller = new
|
|
457
|
+
this.poller = new W(), this.fetchSessionAndFullHistoryAbortController = new AbortController(), this.reconcileAbortController = new AbortController(), this.subscriptions = [], this.reconcilingSessionId = null, this.registerPolling = () => {
|
|
387
458
|
this.subscriptions.push(
|
|
388
459
|
this.sessionCtx.sessionState.subscribe(({ session: s }) => {
|
|
389
460
|
s != null && s.id ? this.poller.startPolling(async (a) => {
|
|
@@ -431,32 +502,32 @@ class me {
|
|
|
431
502
|
}) => {
|
|
432
503
|
const n = this.messageCtx.state.get().messages.length === 0;
|
|
433
504
|
n && this.messageCtx.state.setPartial({ isInitialFetchLoading: !0 });
|
|
434
|
-
const { data:
|
|
505
|
+
const { data: c } = await this.api.pollSessionAndHistory({
|
|
435
506
|
sessionId: s,
|
|
436
507
|
abortSignal: a
|
|
437
508
|
});
|
|
438
|
-
if (
|
|
439
|
-
this.reconcileOptionPicks(
|
|
440
|
-
const d = this.messageCtx.state.get().messages,
|
|
509
|
+
if (c != null && c.session && (this.sessionCtx.sessionState.setPartial({ session: c.session }), this.sessionCtx.setSessions([c.session])), c != null && c.history && c.history.length > 0) {
|
|
510
|
+
this.reconcileOptionPicks(c.history);
|
|
511
|
+
const d = this.messageCtx.state.get().messages, l = c.history.map(this.mapHistoryToMessage).filter((p) => p !== null).filter(
|
|
441
512
|
(p) => !d.some((u) => u.id === p.id)
|
|
442
513
|
);
|
|
443
|
-
if (
|
|
514
|
+
if (l.length > 0)
|
|
444
515
|
if (this.messageCtx.state.setPartial({
|
|
445
|
-
messages: [...d, ...
|
|
516
|
+
messages: [...d, ...l]
|
|
446
517
|
}), n)
|
|
447
518
|
this.messageCtx.markAsDispatchedToOnMessageReceivedHook(
|
|
448
|
-
|
|
519
|
+
l.map((p) => p.id)
|
|
449
520
|
);
|
|
450
521
|
else
|
|
451
|
-
for (const p of
|
|
522
|
+
for (const p of l)
|
|
452
523
|
this.messageCtx.dispatchToOnMessageReceivedHook(p);
|
|
453
524
|
}
|
|
454
525
|
this.messageCtx.state.get().isInitialFetchLoading && this.messageCtx.state.setPartial({ isInitialFetchLoading: !1 });
|
|
455
526
|
}, this.reconcileOptionPicks = (s) => {
|
|
456
527
|
var a;
|
|
457
528
|
for (const n of s) {
|
|
458
|
-
const
|
|
459
|
-
|
|
529
|
+
const c = (a = n.messageOptions) == null ? void 0 : a.pickedOptionId;
|
|
530
|
+
c && this.messageCtx.setMessageOptionPick(n.publicId, c);
|
|
460
531
|
}
|
|
461
532
|
}, this.mapHistoryToMessage = (s) => {
|
|
462
533
|
var n;
|
|
@@ -495,7 +566,7 @@ class me {
|
|
|
495
566
|
...s.messageOptions ? { messageOptions: s.messageOptions } : {}
|
|
496
567
|
};
|
|
497
568
|
if (s.sender.kind === "ai") {
|
|
498
|
-
const
|
|
569
|
+
const c = s.actionCalls && s.actionCalls.length > 0 ? s.actionCalls[s.actionCalls.length - 1] : void 0;
|
|
499
570
|
return {
|
|
500
571
|
...a,
|
|
501
572
|
type: "AI",
|
|
@@ -510,27 +581,27 @@ class me {
|
|
|
510
581
|
},
|
|
511
582
|
data: {
|
|
512
583
|
message: s.content.text || "",
|
|
513
|
-
action:
|
|
514
|
-
name:
|
|
515
|
-
data: this.extractActionResult(
|
|
584
|
+
action: c ? {
|
|
585
|
+
name: c.actionName,
|
|
586
|
+
data: this.extractActionResult(c)
|
|
516
587
|
} : void 0
|
|
517
588
|
},
|
|
518
589
|
...this.constructReplyTo(s)
|
|
519
590
|
};
|
|
520
591
|
}
|
|
521
592
|
if (s.sender.kind === "system") {
|
|
522
|
-
const
|
|
523
|
-
return
|
|
593
|
+
const c = this.constructSystemMessage(s);
|
|
594
|
+
return c === null ? null : { ...c };
|
|
524
595
|
}
|
|
525
596
|
return null;
|
|
526
597
|
}, this.constructReplyTo = (s) => {
|
|
527
598
|
if (!s.replyTo) return {};
|
|
528
|
-
const { publicId: a, text: n, sender:
|
|
599
|
+
const { publicId: a, text: n, sender: c } = s.replyTo;
|
|
529
600
|
return {
|
|
530
601
|
replyTo: {
|
|
531
602
|
id: a,
|
|
532
603
|
text: n,
|
|
533
|
-
sender:
|
|
604
|
+
sender: c
|
|
534
605
|
}
|
|
535
606
|
};
|
|
536
607
|
}, this.constructSystemMessage = (s) => {
|
|
@@ -571,7 +642,7 @@ class me {
|
|
|
571
642
|
case "none":
|
|
572
643
|
return null;
|
|
573
644
|
default:
|
|
574
|
-
return
|
|
645
|
+
return ke(
|
|
575
646
|
s.systemMessagePayload,
|
|
576
647
|
this.constructSystemMessage.name
|
|
577
648
|
), null;
|
|
@@ -580,14 +651,14 @@ class me {
|
|
|
580
651
|
const a = s.result;
|
|
581
652
|
if (a === null || typeof a != "object") return a;
|
|
582
653
|
if ("responseBodyText" in a && typeof a.responseBodyText == "string") {
|
|
583
|
-
const n = a.responseBodyText,
|
|
584
|
-
if (
|
|
654
|
+
const n = a.responseBodyText, c = $(() => JSON.parse(n)).data;
|
|
655
|
+
if (c) return c;
|
|
585
656
|
}
|
|
586
657
|
return s.result;
|
|
587
|
-
}, this.api = e, this.config = t, this.sessionCtx = o, this.messageCtx = r, this.sessionPollingIntervalSeconds =
|
|
658
|
+
}, this.api = e, this.config = t, this.sessionCtx = o, this.messageCtx = r, this.sessionPollingIntervalSeconds = _, this.registerPolling();
|
|
588
659
|
}
|
|
589
660
|
}
|
|
590
|
-
class
|
|
661
|
+
class ve {
|
|
591
662
|
constructor({
|
|
592
663
|
config: e,
|
|
593
664
|
api: t,
|
|
@@ -595,19 +666,19 @@ class he {
|
|
|
595
666
|
}) {
|
|
596
667
|
var r;
|
|
597
668
|
this.shouldCollectData = () => {
|
|
598
|
-
var
|
|
599
|
-
return !!(!((
|
|
669
|
+
var _;
|
|
670
|
+
return !!(!((_ = this.state.get().contact) != null && _.token) && this.config.collectUserData);
|
|
600
671
|
}, this.autoCreateUnverifiedUserIfNotExists = async () => {
|
|
601
|
-
var
|
|
602
|
-
if (!((
|
|
672
|
+
var _, s, a, n, c, d, l, p, u, m, g, b, f, v;
|
|
673
|
+
if (!((_ = this.config.user) != null && _.token)) {
|
|
603
674
|
if (this.config.collectUserData && !((a = (s = this.config.user) == null ? void 0 : s.data) != null && a.email)) {
|
|
604
675
|
if ((n = this.config.extraDataCollectionFields) != null && n.length)
|
|
605
676
|
return;
|
|
606
|
-
const y = await ((
|
|
677
|
+
const y = await ((c = this.storageCtx) == null ? void 0 : c.getContactToken());
|
|
607
678
|
y && await this.setUnverifiedContact(y);
|
|
608
679
|
return;
|
|
609
680
|
}
|
|
610
|
-
if (!((
|
|
681
|
+
if (!((l = (d = this.config.user) == null ? void 0 : d.data) != null && l.email)) {
|
|
611
682
|
const y = await ((p = this.storageCtx) == null ? void 0 : p.getContactToken());
|
|
612
683
|
if (y) {
|
|
613
684
|
await this.setUnverifiedContact(y);
|
|
@@ -620,14 +691,14 @@ class he {
|
|
|
620
691
|
non_verified_custom_data: (v = (f = this.config.user) == null ? void 0 : f.data) == null ? void 0 : v.customData
|
|
621
692
|
});
|
|
622
693
|
}
|
|
623
|
-
}, this.createUnverifiedContact = async (
|
|
694
|
+
}, this.createUnverifiedContact = async (_, s) => {
|
|
624
695
|
this.state.setPartial({ extraCollectedData: s });
|
|
625
696
|
try {
|
|
626
697
|
this.state.setPartial({
|
|
627
698
|
isCreatingUnverifiedContact: !0,
|
|
628
699
|
isErrorCreatingUnverifiedContact: !1
|
|
629
700
|
});
|
|
630
|
-
const { data: a } = await this.api.createUnverifiedContact(
|
|
701
|
+
const { data: a } = await this.api.createUnverifiedContact(_);
|
|
631
702
|
a != null && a.token ? await this.setUnverifiedContact(a.token) : this.state.setPartial({ isErrorCreatingUnverifiedContact: !0 });
|
|
632
703
|
} catch (a) {
|
|
633
704
|
this.state.setPartial({ isErrorCreatingUnverifiedContact: !0 }), k.error("failed to create an unverified contact", {
|
|
@@ -637,8 +708,8 @@ class he {
|
|
|
637
708
|
this.state.setPartial({ isCreatingUnverifiedContact: !1 });
|
|
638
709
|
}
|
|
639
710
|
}, this.recoverFromStaleToken = async () => {
|
|
640
|
-
var
|
|
641
|
-
if ((
|
|
711
|
+
var _, s, a, n, c, d, l, p, u, m;
|
|
712
|
+
if ((_ = this.config.user) != null && _.token) return !1;
|
|
642
713
|
this.api.setAuthToken(""), this.state.setPartial({ contact: null });
|
|
643
714
|
try {
|
|
644
715
|
await ((s = this.storageCtx) == null ? void 0 : s.clearContactToken()), await ((a = this.storageCtx) == null ? void 0 : a.clearActiveSessionId());
|
|
@@ -648,14 +719,14 @@ class he {
|
|
|
648
719
|
});
|
|
649
720
|
}
|
|
650
721
|
return await this.createUnverifiedContact({
|
|
651
|
-
email: (
|
|
652
|
-
non_verified_name: (
|
|
722
|
+
email: (c = (n = this.config.user) == null ? void 0 : n.data) == null ? void 0 : c.email,
|
|
723
|
+
non_verified_name: (l = (d = this.config.user) == null ? void 0 : d.data) == null ? void 0 : l.name,
|
|
653
724
|
non_verified_custom_data: (u = (p = this.config.user) == null ? void 0 : p.data) == null ? void 0 : u.customData
|
|
654
725
|
}), !!((m = this.state.get().contact) != null && m.token);
|
|
655
|
-
}, this.setUnverifiedContact = async (
|
|
656
|
-
var n,
|
|
657
|
-
const s = await ((n = this.storageCtx) == null ? void 0 : n.getExternalContactId()), a = ((
|
|
658
|
-
this.api.setAuthToken(
|
|
726
|
+
}, this.setUnverifiedContact = async (_) => {
|
|
727
|
+
var n, c, d, l;
|
|
728
|
+
const s = await ((n = this.storageCtx) == null ? void 0 : n.getExternalContactId()), a = ((c = this.config.user) == null ? void 0 : c.externalId) || s || R();
|
|
729
|
+
this.api.setAuthToken(_), await ((d = this.storageCtx) == null ? void 0 : d.setContactToken(_)), await ((l = this.storageCtx) == null ? void 0 : l.setExternalContactId(a)), this.state.setPartial({ contact: { token: _, externalId: a } });
|
|
659
730
|
}, this.config = e, this.storageCtx = o, this.api = t, this.state = new S({
|
|
660
731
|
contact: (r = e.user) != null && r.token ? {
|
|
661
732
|
token: e.user.token,
|
|
@@ -668,13 +739,13 @@ class he {
|
|
|
668
739
|
}), this.autoCreateUnverifiedUserIfNotExists();
|
|
669
740
|
}
|
|
670
741
|
}
|
|
671
|
-
class
|
|
742
|
+
class fe {
|
|
672
743
|
constructor(e) {
|
|
673
744
|
this.api = e, this.state = new S([]), this.controllers = /* @__PURE__ */ new Map(), this.appendFiles = (t) => {
|
|
674
745
|
const o = t.map(
|
|
675
746
|
(r) => ({
|
|
676
747
|
file: r,
|
|
677
|
-
id:
|
|
748
|
+
id: R(),
|
|
678
749
|
status: "pending",
|
|
679
750
|
progress: 0
|
|
680
751
|
})
|
|
@@ -718,18 +789,18 @@ class ge {
|
|
|
718
789
|
}
|
|
719
790
|
}
|
|
720
791
|
function q() {
|
|
721
|
-
return
|
|
792
|
+
return R();
|
|
722
793
|
}
|
|
723
|
-
class
|
|
794
|
+
class ye {
|
|
724
795
|
constructor({
|
|
725
796
|
api: e,
|
|
726
797
|
sessionCtx: t,
|
|
727
798
|
messageCtx: o
|
|
728
799
|
}) {
|
|
729
800
|
this.submitCsat = async (r) => {
|
|
730
|
-
var
|
|
731
|
-
const
|
|
732
|
-
if (!
|
|
801
|
+
var c;
|
|
802
|
+
const _ = (c = this.sessionCtx.sessionState.get().session) == null ? void 0 : c.id;
|
|
803
|
+
if (!_)
|
|
733
804
|
return { data: null, error: "No session id found" };
|
|
734
805
|
const s = q();
|
|
735
806
|
this.messageCtx.state.setPartial({
|
|
@@ -752,13 +823,13 @@ class ke {
|
|
|
752
823
|
const { data: a, error: n } = await this.api.submitCsat({
|
|
753
824
|
...r,
|
|
754
825
|
system_message_uuid: s,
|
|
755
|
-
session_id:
|
|
826
|
+
session_id: _
|
|
756
827
|
});
|
|
757
828
|
return { data: a, error: n };
|
|
758
829
|
}, this.api = e, this.sessionCtx = t, this.messageCtx = o;
|
|
759
830
|
}
|
|
760
831
|
}
|
|
761
|
-
const
|
|
832
|
+
const we = [
|
|
762
833
|
{
|
|
763
834
|
action: "newparagraph",
|
|
764
835
|
phrases: {
|
|
@@ -833,7 +904,7 @@ const be = [
|
|
|
833
904
|
it: ["invia messaggio"]
|
|
834
905
|
}
|
|
835
906
|
}
|
|
836
|
-
],
|
|
907
|
+
], je = [
|
|
837
908
|
"en",
|
|
838
909
|
"es",
|
|
839
910
|
"fr",
|
|
@@ -841,18 +912,18 @@ const be = [
|
|
|
841
912
|
"pt",
|
|
842
913
|
"it"
|
|
843
914
|
];
|
|
844
|
-
function
|
|
845
|
-
return
|
|
915
|
+
function Se(i) {
|
|
916
|
+
return je.includes(i);
|
|
846
917
|
}
|
|
847
|
-
function
|
|
918
|
+
function ze(i) {
|
|
848
919
|
return i.replace(/[.*+?^${}()|[\]\\]/g, "\\$&");
|
|
849
920
|
}
|
|
850
|
-
function
|
|
851
|
-
const e =
|
|
921
|
+
function Ce(i) {
|
|
922
|
+
const e = we.flatMap(
|
|
852
923
|
(r) => i.flatMap(
|
|
853
|
-
(
|
|
924
|
+
(_) => r.phrases[_].map((s) => ({ phrase: s, action: r.action }))
|
|
854
925
|
)
|
|
855
|
-
), t = e.map((r) =>
|
|
926
|
+
), t = e.map((r) => ze(r.phrase)).sort((r, _) => _.length - r.length).join("|"), o = String.raw`(?<=^\s{0,3}|[.!?\n]\s{0,3})`;
|
|
856
927
|
return {
|
|
857
928
|
regex: new RegExp(
|
|
858
929
|
`${o}(${t})` + String.raw`([.,!?;:])(?=\s|$)`,
|
|
@@ -870,18 +941,18 @@ function we(i) {
|
|
|
870
941
|
}
|
|
871
942
|
const B = /* @__PURE__ */ new Map();
|
|
872
943
|
function M(i) {
|
|
873
|
-
const e = i &&
|
|
944
|
+
const e = i && Se(i) && i !== "en" ? i : null, t = e ?? "en";
|
|
874
945
|
let o = B.get(t);
|
|
875
|
-
return o || (o =
|
|
946
|
+
return o || (o = Ce(e ? ["en", e] : ["en"]), B.set(t, o)), o;
|
|
876
947
|
}
|
|
877
|
-
function
|
|
948
|
+
function xe(i) {
|
|
878
949
|
const e = i.replace(/\s+$/, "");
|
|
879
950
|
if (!e) return "";
|
|
880
951
|
const t = e.replace(/[.!?]+$/, "");
|
|
881
952
|
let o = -1;
|
|
882
953
|
for (let r = t.length - 1; r >= 0; r--) {
|
|
883
|
-
const
|
|
884
|
-
if (
|
|
954
|
+
const _ = t[r];
|
|
955
|
+
if (_ === "." || _ === "!" || _ === "?" || _ === `
|
|
885
956
|
`) {
|
|
886
957
|
o = r + 1;
|
|
887
958
|
break;
|
|
@@ -890,17 +961,17 @@ function je(i) {
|
|
|
890
961
|
return o === -1 ? "" : `${t.slice(0, o)} `.replace(/\n $/, `
|
|
891
962
|
`);
|
|
892
963
|
}
|
|
893
|
-
const
|
|
964
|
+
const qe = new RegExp(
|
|
894
965
|
String.raw`(^- |\n(?:- )?)(\p{Ll})`,
|
|
895
966
|
"gu"
|
|
896
967
|
);
|
|
897
|
-
function
|
|
968
|
+
function Ee(i) {
|
|
898
969
|
return i.replace(
|
|
899
|
-
|
|
970
|
+
qe,
|
|
900
971
|
(e, t, o) => t + o.toUpperCase()
|
|
901
972
|
);
|
|
902
973
|
}
|
|
903
|
-
function
|
|
974
|
+
function Ae(i) {
|
|
904
975
|
return i.length <= 3 && /^\s*$/.test(i) ? !0 : /[.!?\n]\s{0,3}$/.test(i.slice(-6));
|
|
905
976
|
}
|
|
906
977
|
class E {
|
|
@@ -910,12 +981,12 @@ class E {
|
|
|
910
981
|
* result never depends on delta chunking.
|
|
911
982
|
*/
|
|
912
983
|
static process(e, t) {
|
|
913
|
-
const o = M(t == null ? void 0 : t.language), r = t != null && t.final ? "" : E.commandPrefixTail(e, t == null ? void 0 : t.language),
|
|
914
|
-
let a = "", n = null,
|
|
915
|
-
for (const
|
|
916
|
-
const [, p = ""] =
|
|
984
|
+
const o = M(t == null ? void 0 : t.language), r = t != null && t.final ? "" : E.commandPrefixTail(e, t == null ? void 0 : t.language), _ = e.slice(0, e.length - r.length), s = t != null && t.final ? o.finalRegex : o.regex;
|
|
985
|
+
let a = "", n = null, c = 0;
|
|
986
|
+
for (const l of Array.from(_.matchAll(s))) {
|
|
987
|
+
const [, p = ""] = l, u = o.phraseToAction.get(p.toLowerCase());
|
|
917
988
|
if (u)
|
|
918
|
-
if (a +=
|
|
989
|
+
if (a += _.slice(c, l.index), c = l.index + l[0].length, u === "newline") a = `${a.replace(/[ \t]+$/, "")}
|
|
919
990
|
`;
|
|
920
991
|
else if (u === "newparagraph")
|
|
921
992
|
a = `${a.replace(/[ \t]+$/, "")}
|
|
@@ -926,13 +997,13 @@ class E {
|
|
|
926
997
|
a = m === "" || m.endsWith(`
|
|
927
998
|
`) ? `${m}- ` : `${m}
|
|
928
999
|
- `;
|
|
929
|
-
} else if (u === "scratch") a =
|
|
1000
|
+
} else if (u === "scratch") a = xe(a);
|
|
930
1001
|
else {
|
|
931
1002
|
n = u === "send" ? "send" : "stop";
|
|
932
1003
|
break;
|
|
933
1004
|
}
|
|
934
1005
|
}
|
|
935
|
-
return n === null && (a +=
|
|
1006
|
+
return n === null && (a += _.slice(c)), { text: Ee(
|
|
936
1007
|
a.replace(/^\s+/, "").replace(/[ \t]+\n/g, `
|
|
937
1008
|
`).replace(/\n[ \t]+/g, `
|
|
938
1009
|
`).replace(/(^|\n)- +/g, "$1- ").replace(/ {2,}/g, " ").replace(/\n{3,}/g, `
|
|
@@ -951,13 +1022,13 @@ class E {
|
|
|
951
1022
|
*/
|
|
952
1023
|
static commandPrefixTail(e, t) {
|
|
953
1024
|
const o = M(t), r = Math.min(e.length, o.longestPhrase + 2);
|
|
954
|
-
for (let
|
|
955
|
-
const s = e.length -
|
|
956
|
-
if (!
|
|
1025
|
+
for (let _ = r; _ > 0; _--) {
|
|
1026
|
+
const s = e.length - _;
|
|
1027
|
+
if (!Ae(e.slice(0, s))) continue;
|
|
957
1028
|
const a = e.slice(s).toLowerCase(), n = a.replace(/^\s+/, "");
|
|
958
1029
|
if (n) {
|
|
959
|
-
for (const
|
|
960
|
-
if (
|
|
1030
|
+
for (const c of Array.from(o.phraseToAction.keys()))
|
|
1031
|
+
if (c.startsWith(n))
|
|
961
1032
|
return e.slice(s + (a.length - n.length));
|
|
962
1033
|
}
|
|
963
1034
|
}
|
|
@@ -973,7 +1044,7 @@ class E {
|
|
|
973
1044
|
return o ? M(t).phraseToAction.has(o) : !1;
|
|
974
1045
|
}
|
|
975
1046
|
}
|
|
976
|
-
const
|
|
1047
|
+
const Pe = 55, Te = 90;
|
|
977
1048
|
class V {
|
|
978
1049
|
/**
|
|
979
1050
|
* Next paced step toward `processed`: normally one word per tick so text
|
|
@@ -987,7 +1058,7 @@ class V {
|
|
|
987
1058
|
}) {
|
|
988
1059
|
if (t.length <= e.length) return t;
|
|
989
1060
|
const o = t.length - e.length;
|
|
990
|
-
if (o >
|
|
1061
|
+
if (o > Te)
|
|
991
1062
|
return t.slice(0, e.length + Math.ceil(o / 3));
|
|
992
1063
|
let r = e.length;
|
|
993
1064
|
for (; r < t.length && /\s/.test(t.charAt(r)); ) r++;
|
|
@@ -1003,8 +1074,8 @@ class V {
|
|
|
1003
1074
|
return o && /^[a-z]{2,3}$/.test(o) ? o : void 0;
|
|
1004
1075
|
}
|
|
1005
1076
|
}
|
|
1006
|
-
const
|
|
1007
|
-
class
|
|
1077
|
+
const Ie = 2e4;
|
|
1078
|
+
class Me {
|
|
1008
1079
|
constructor() {
|
|
1009
1080
|
this.cached = null, this.inflight = null;
|
|
1010
1081
|
}
|
|
@@ -1012,7 +1083,7 @@ class Ae {
|
|
|
1012
1083
|
get() {
|
|
1013
1084
|
if (!this.cached) return null;
|
|
1014
1085
|
const e = Date.parse(this.cached.expiresAt);
|
|
1015
|
-
return Number.isNaN(e) || e - Date.now() <
|
|
1086
|
+
return Number.isNaN(e) || e - Date.now() < Ie ? (this.cached = null, null) : this.cached;
|
|
1016
1087
|
}
|
|
1017
1088
|
/**
|
|
1018
1089
|
* Resolve a mint, deduping concurrent requests (hover-prewarm racing a
|
|
@@ -1032,7 +1103,7 @@ class Ae {
|
|
|
1032
1103
|
function H(i) {
|
|
1033
1104
|
return typeof i == "object" && i !== null && !Array.isArray(i);
|
|
1034
1105
|
}
|
|
1035
|
-
function
|
|
1106
|
+
function De(i) {
|
|
1036
1107
|
if (!H(i) || typeof i.type != "string") return null;
|
|
1037
1108
|
const e = H(i.error) ? i.error : null;
|
|
1038
1109
|
return {
|
|
@@ -1041,30 +1112,30 @@ function Pe(i) {
|
|
|
1041
1112
|
errorMessage: e && typeof e.message == "string" ? e.message : void 0
|
|
1042
1113
|
};
|
|
1043
1114
|
}
|
|
1044
|
-
const
|
|
1115
|
+
const Re = "https://api.openai.com/v1/realtime/calls", Ne = 600 * 1e3, Ke = 15e3, Le = 5e3;
|
|
1045
1116
|
class T extends Error {
|
|
1046
1117
|
}
|
|
1047
|
-
class
|
|
1118
|
+
class Oe {
|
|
1048
1119
|
constructor({
|
|
1049
1120
|
mintToken: e,
|
|
1050
1121
|
onDelta: t,
|
|
1051
1122
|
onState: o,
|
|
1052
1123
|
onError: r,
|
|
1053
|
-
onLevel:
|
|
1124
|
+
onLevel: _
|
|
1054
1125
|
}) {
|
|
1055
|
-
this.state = "idle", this.pc = null, this.dc = null, this.stream = null, this.audioContext = null, this.levelRaf = 0, this.timers = [], this.loggedParseFailure = !1, this.mintToken = e, this.onDelta = t, this.onState = o, this.onError = r, this.onLevel =
|
|
1126
|
+
this.state = "idle", this.pc = null, this.dc = null, this.stream = null, this.audioContext = null, this.levelRaf = 0, this.timers = [], this.loggedParseFailure = !1, this.mintToken = e, this.onDelta = t, this.onState = o, this.onError = r, this.onLevel = _;
|
|
1056
1127
|
}
|
|
1057
1128
|
async start() {
|
|
1058
1129
|
if (this.state === "idle") {
|
|
1059
1130
|
this.setState("connecting"), this.timers.push(
|
|
1060
1131
|
setTimeout(() => {
|
|
1061
1132
|
this.state === "connecting" && this.fail("unavailable");
|
|
1062
|
-
},
|
|
1063
|
-
), this.timers.push(setTimeout(() => this.stop(),
|
|
1133
|
+
}, Ke)
|
|
1134
|
+
), this.timers.push(setTimeout(() => this.stop(), Ne));
|
|
1064
1135
|
try {
|
|
1065
1136
|
const e = this.requestMicrophone();
|
|
1066
1137
|
e.then((d) => {
|
|
1067
|
-
this.isTornDown() || this.stream && this.stream !== d ? d.getTracks().forEach((
|
|
1138
|
+
this.isTornDown() || this.stream && this.stream !== d ? d.getTracks().forEach((l) => l.stop()) : this.stream = d;
|
|
1068
1139
|
}).catch(() => {
|
|
1069
1140
|
});
|
|
1070
1141
|
const [t, o] = await Promise.all([e, this.mintToken()]);
|
|
@@ -1075,9 +1146,9 @@ class Ne {
|
|
|
1075
1146
|
this.stream = t, this.startLevelMeter(t);
|
|
1076
1147
|
const r = new RTCPeerConnection();
|
|
1077
1148
|
this.pc = r;
|
|
1078
|
-
const [
|
|
1079
|
-
if (!
|
|
1080
|
-
r.addTrack(
|
|
1149
|
+
const [_] = t.getAudioTracks();
|
|
1150
|
+
if (!_) throw new T("No audio track");
|
|
1151
|
+
r.addTrack(_, t);
|
|
1081
1152
|
const s = r.createDataChannel("oai-events");
|
|
1082
1153
|
this.dc = s, s.addEventListener(
|
|
1083
1154
|
"message",
|
|
@@ -1092,12 +1163,12 @@ class Ne {
|
|
|
1092
1163
|
r.connectionState === "disconnected" && this.timers.push(
|
|
1093
1164
|
setTimeout(() => {
|
|
1094
1165
|
this.pc === r && r.connectionState !== "connected" && this.fail("unavailable");
|
|
1095
|
-
},
|
|
1166
|
+
}, Le)
|
|
1096
1167
|
);
|
|
1097
1168
|
});
|
|
1098
1169
|
const a = await r.createOffer();
|
|
1099
1170
|
if (this.isTornDown() || (await r.setLocalDescription(a), this.isTornDown())) return;
|
|
1100
|
-
const n = await fetch(
|
|
1171
|
+
const n = await fetch(Re, {
|
|
1101
1172
|
method: "POST",
|
|
1102
1173
|
headers: {
|
|
1103
1174
|
Authorization: `Bearer ${o.token}`,
|
|
@@ -1107,9 +1178,9 @@ class Ne {
|
|
|
1107
1178
|
});
|
|
1108
1179
|
if (!n.ok)
|
|
1109
1180
|
throw new Error(`Realtime handshake failed (${n.status})`);
|
|
1110
|
-
const
|
|
1181
|
+
const c = await n.text();
|
|
1111
1182
|
if (this.isTornDown()) return;
|
|
1112
|
-
await r.setRemoteDescription({ type: "answer", sdp:
|
|
1183
|
+
await r.setRemoteDescription({ type: "answer", sdp: c });
|
|
1113
1184
|
} catch (e) {
|
|
1114
1185
|
e instanceof T ? this.fail("microphone") : (k.error("dictation session failed to start", {
|
|
1115
1186
|
_e: e instanceof Error ? e.message : String(e)
|
|
@@ -1149,15 +1220,15 @@ class Ne {
|
|
|
1149
1220
|
}));
|
|
1150
1221
|
return;
|
|
1151
1222
|
}
|
|
1152
|
-
const o =
|
|
1223
|
+
const o = De(t);
|
|
1153
1224
|
if (!o) return;
|
|
1154
|
-
const { type: r, delta:
|
|
1225
|
+
const { type: r, delta: _ } = o;
|
|
1155
1226
|
if (r === "session.created" || r === "transcription_session.created") {
|
|
1156
1227
|
this.setState("listening");
|
|
1157
1228
|
return;
|
|
1158
1229
|
}
|
|
1159
|
-
if (r === "conversation.item.input_audio_transcription.delta" &&
|
|
1160
|
-
this.state === "connecting" && this.setState("listening"), this.onDelta(
|
|
1230
|
+
if (r === "conversation.item.input_audio_transcription.delta" && _) {
|
|
1231
|
+
this.state === "connecting" && this.setState("listening"), this.onDelta(_);
|
|
1161
1232
|
return;
|
|
1162
1233
|
}
|
|
1163
1234
|
r === "error" && (k.error("dictation server event error", {
|
|
@@ -1171,16 +1242,16 @@ class Ne {
|
|
|
1171
1242
|
this.audioContext = t;
|
|
1172
1243
|
const o = t.createMediaStreamSource(e), r = t.createAnalyser();
|
|
1173
1244
|
r.fftSize = 512, o.connect(r);
|
|
1174
|
-
const
|
|
1175
|
-
var
|
|
1176
|
-
r.getByteTimeDomainData(
|
|
1245
|
+
const _ = new Uint8Array(r.frequencyBinCount), s = () => {
|
|
1246
|
+
var c;
|
|
1247
|
+
r.getByteTimeDomainData(_);
|
|
1177
1248
|
let a = 0;
|
|
1178
|
-
for (let d = 0; d <
|
|
1179
|
-
const
|
|
1180
|
-
a +=
|
|
1249
|
+
for (let d = 0; d < _.length; d++) {
|
|
1250
|
+
const l = ((_[d] ?? 128) - 128) / 128;
|
|
1251
|
+
a += l * l;
|
|
1181
1252
|
}
|
|
1182
|
-
const n = Math.sqrt(a /
|
|
1183
|
-
(
|
|
1253
|
+
const n = Math.sqrt(a / _.length);
|
|
1254
|
+
(c = this.onLevel) == null || c.call(this, Math.min(1, n * 4)), this.levelRaf = requestAnimationFrame(s);
|
|
1184
1255
|
};
|
|
1185
1256
|
this.levelRaf = requestAnimationFrame(s);
|
|
1186
1257
|
} catch (t) {
|
|
@@ -1197,9 +1268,9 @@ class Ne {
|
|
|
1197
1268
|
}
|
|
1198
1269
|
teardown() {
|
|
1199
1270
|
var e, t, o, r;
|
|
1200
|
-
this.timers.forEach((
|
|
1271
|
+
this.timers.forEach((_) => clearTimeout(_)), this.timers = [], this.levelRaf && cancelAnimationFrame(this.levelRaf), this.levelRaf = 0, (e = this.dc) == null || e.close(), this.dc = null, (t = this.pc) == null || t.close(), this.pc = null, (o = this.stream) == null || o.getTracks().forEach((_) => _.stop()), this.stream = null, (r = this.audioContext) == null || r.close().catch((_) => {
|
|
1201
1272
|
k.error("failed to close dictation audio context", {
|
|
1202
|
-
_e: String(
|
|
1273
|
+
_e: String(_)
|
|
1203
1274
|
});
|
|
1204
1275
|
}), this.audioContext = null;
|
|
1205
1276
|
}
|
|
@@ -1207,10 +1278,10 @@ class Ne {
|
|
|
1207
1278
|
this.state !== e && (this.state = e, this.onState(e));
|
|
1208
1279
|
}
|
|
1209
1280
|
}
|
|
1210
|
-
const
|
|
1211
|
-
class
|
|
1281
|
+
const Fe = 1300, Ue = { status: "idle", error: null };
|
|
1282
|
+
class Be {
|
|
1212
1283
|
constructor({ api: e, config: t }) {
|
|
1213
|
-
this.state = new S(
|
|
1284
|
+
this.state = new S(Ue), this.levelRef = { current: 0 }, this.mintCache = new Me(), this.session = null, this.target = null, this.prefix = "", this.raw = "", this.processed = "", this.displayed = "", this.dripTimer = null, this.silenceTimer = null, this.isActive = () => this.session !== null, this.prewarm = () => {
|
|
1214
1285
|
this.mintToken().catch((o) => {
|
|
1215
1286
|
this.mintCache.clear(), k.error("dictation token prewarm failed", {
|
|
1216
1287
|
_e: o instanceof Error ? o.message : String(o)
|
|
@@ -1220,24 +1291,24 @@ class Le {
|
|
|
1220
1291
|
this.session && this.teardown(), this.target = o, this.language = V.languageHint(
|
|
1221
1292
|
this.config.language ?? navigator.language
|
|
1222
1293
|
), this.prefix = o.getValue(), this.raw = "", this.processed = "", this.displayed = "";
|
|
1223
|
-
const r = new
|
|
1294
|
+
const r = new Oe({
|
|
1224
1295
|
mintToken: this.mintToken,
|
|
1225
|
-
onLevel: (
|
|
1226
|
-
this.levelRef.current =
|
|
1296
|
+
onLevel: (_) => {
|
|
1297
|
+
this.levelRef.current = _;
|
|
1227
1298
|
},
|
|
1228
|
-
onState: (
|
|
1229
|
-
r === this.session && (
|
|
1299
|
+
onState: (_) => {
|
|
1300
|
+
r === this.session && (_ === "connecting" && this.state.set({ status: "connecting", error: null }), _ === "listening" && this.state.set({ status: "listening", error: null }), _ === "stopped" && this.teardown());
|
|
1230
1301
|
},
|
|
1231
|
-
onError: (
|
|
1232
|
-
r === this.session && (this.mintCache.clear(), this.teardown({ error:
|
|
1302
|
+
onError: (_) => {
|
|
1303
|
+
r === this.session && (this.mintCache.clear(), this.teardown({ error: _, executeFinalCommand: !1 }));
|
|
1233
1304
|
},
|
|
1234
|
-
onDelta: (
|
|
1305
|
+
onDelta: (_) => {
|
|
1235
1306
|
if (r !== this.session || !this.target) return;
|
|
1236
1307
|
if (!this.isConsistent()) {
|
|
1237
1308
|
this.teardown();
|
|
1238
1309
|
return;
|
|
1239
1310
|
}
|
|
1240
|
-
this.raw +=
|
|
1311
|
+
this.raw += _;
|
|
1241
1312
|
const s = this.ingest();
|
|
1242
1313
|
if (s === "stop") {
|
|
1243
1314
|
this.teardown();
|
|
@@ -1255,7 +1326,7 @@ class Le {
|
|
|
1255
1326
|
this.raw = `${this.raw}.`;
|
|
1256
1327
|
const a = this.ingest();
|
|
1257
1328
|
a === "stop" ? this.teardown() : a === "send" && this.teardown({ send: !0 });
|
|
1258
|
-
},
|
|
1329
|
+
}, Fe));
|
|
1259
1330
|
}
|
|
1260
1331
|
});
|
|
1261
1332
|
this.session = r, this.state.set({ status: "connecting", error: null }), this.dripTimer = setInterval(() => {
|
|
@@ -1271,7 +1342,7 @@ class Le {
|
|
|
1271
1342
|
})
|
|
1272
1343
|
);
|
|
1273
1344
|
}
|
|
1274
|
-
},
|
|
1345
|
+
}, Pe), r.start();
|
|
1275
1346
|
}, this.stop = (o) => {
|
|
1276
1347
|
this.session && this.teardown(o);
|
|
1277
1348
|
}, this.mintToken = async () => this.mintCache.resolve(
|
|
@@ -1298,7 +1369,7 @@ class Le {
|
|
|
1298
1369
|
this.silenceTimer && clearTimeout(this.silenceTimer), this.silenceTimer = null;
|
|
1299
1370
|
}
|
|
1300
1371
|
teardown(e) {
|
|
1301
|
-
var
|
|
1372
|
+
var _;
|
|
1302
1373
|
const t = this.session, o = this.target;
|
|
1303
1374
|
this.dripTimer && clearInterval(this.dripTimer), this.dripTimer = null, this.stopSilenceTimer();
|
|
1304
1375
|
let r = (e == null ? void 0 : e.send) ?? !1;
|
|
@@ -1306,10 +1377,10 @@ class Le {
|
|
|
1306
1377
|
const s = this.ingest({ final: !0 });
|
|
1307
1378
|
(e == null ? void 0 : e.executeFinalCommand) !== !1 && s === "send" && (r = !0), this.processed !== this.displayed && this.applyDisplayed(this.processed);
|
|
1308
1379
|
}
|
|
1309
|
-
this.session = null, this.target = null, t == null || t.stop(), this.levelRef.current = 0, this.state.set({ status: "idle", error: (e == null ? void 0 : e.error) ?? null }), r && ((
|
|
1380
|
+
this.session = null, this.target = null, t == null || t.stop(), this.levelRef.current = 0, this.state.set({ status: "idle", error: (e == null ? void 0 : e.error) ?? null }), r && ((_ = o == null ? void 0 : o.onSend) == null || _.call(o));
|
|
1310
1381
|
}
|
|
1311
1382
|
}
|
|
1312
|
-
const
|
|
1383
|
+
const Ve = {
|
|
1313
1384
|
write_a_message_placeholder: "اكتب رسالة...",
|
|
1314
1385
|
your_issue_has_been_resolved: "تم حل مشكلتك!",
|
|
1315
1386
|
new_conversation: "محادثة جديدة",
|
|
@@ -1346,6 +1417,7 @@ const Oe = {
|
|
|
1346
1417
|
companion_active_chats: "{count} جلسات نشطة",
|
|
1347
1418
|
companion_other_sessions: "الجلسات المفتوحة الأخرى: {count}",
|
|
1348
1419
|
companion_working_chats: "{count} قيد العمل",
|
|
1420
|
+
unread_sessions: "{count} غير مقروءة",
|
|
1349
1421
|
companion_history: "سجل المحادثات",
|
|
1350
1422
|
companion_expand_chat: "توسيع المحادثة",
|
|
1351
1423
|
companion_sidebar_dock_label: "الإرساء",
|
|
@@ -1418,7 +1490,7 @@ const Oe = {
|
|
|
1418
1490
|
zoom_out: "تصغير",
|
|
1419
1491
|
reset_zoom: "إعادة تعيين التكبير",
|
|
1420
1492
|
support_chat_aria_label: "دردشة الدعم"
|
|
1421
|
-
},
|
|
1493
|
+
}, He = {
|
|
1422
1494
|
write_a_message_placeholder: "একটি বার্তা লিখুন...",
|
|
1423
1495
|
your_issue_has_been_resolved: "আপনার সমস্যা সমাধান হয়েছে!",
|
|
1424
1496
|
new_conversation: "নতুন কথোপকথন",
|
|
@@ -1515,7 +1587,7 @@ const Oe = {
|
|
|
1515
1587
|
zoom_out: "ছোট করুন",
|
|
1516
1588
|
reset_zoom: "জুম রিসেট করুন",
|
|
1517
1589
|
support_chat_aria_label: "সাপোর্ট চ্যাট"
|
|
1518
|
-
},
|
|
1590
|
+
}, Ge = {
|
|
1519
1591
|
write_a_message_placeholder: "Напишете съобщение...",
|
|
1520
1592
|
your_issue_has_been_resolved: "Вашият проблем е разрешен!",
|
|
1521
1593
|
new_conversation: "Нов разговор",
|
|
@@ -1612,7 +1684,7 @@ const Oe = {
|
|
|
1612
1684
|
zoom_out: "Намаляване",
|
|
1613
1685
|
reset_zoom: "Нулиране на мащаба",
|
|
1614
1686
|
support_chat_aria_label: "Чат за поддръжка"
|
|
1615
|
-
},
|
|
1687
|
+
}, Ze = {
|
|
1616
1688
|
write_a_message_placeholder: "Napište zprávu...",
|
|
1617
1689
|
your_issue_has_been_resolved: "Váš problém byl vyřešen!",
|
|
1618
1690
|
new_conversation: "Nová konverzace",
|
|
@@ -1709,7 +1781,7 @@ const Oe = {
|
|
|
1709
1781
|
zoom_out: "Oddálit",
|
|
1710
1782
|
reset_zoom: "Obnovit přiblížení",
|
|
1711
1783
|
support_chat_aria_label: "Chat podpory"
|
|
1712
|
-
},
|
|
1784
|
+
}, We = {
|
|
1713
1785
|
write_a_message_placeholder: "Skriv en besked...",
|
|
1714
1786
|
your_issue_has_been_resolved: "Dit problem er løst!",
|
|
1715
1787
|
new_conversation: "Ny samtale",
|
|
@@ -1806,7 +1878,7 @@ const Oe = {
|
|
|
1806
1878
|
zoom_out: "Zoom ud",
|
|
1807
1879
|
reset_zoom: "Nulstil zoom",
|
|
1808
1880
|
support_chat_aria_label: "Supportchat"
|
|
1809
|
-
},
|
|
1881
|
+
}, $e = {
|
|
1810
1882
|
write_a_message_placeholder: "Γράψτε ένα μήνυμα...",
|
|
1811
1883
|
your_issue_has_been_resolved: "Το πρόβλημά σας επιλύθηκε!",
|
|
1812
1884
|
new_conversation: "Νέα συνομιλία",
|
|
@@ -1903,7 +1975,7 @@ const Oe = {
|
|
|
1903
1975
|
zoom_out: "Σμίκρυνση",
|
|
1904
1976
|
reset_zoom: "Επαναφορά ζουμ",
|
|
1905
1977
|
support_chat_aria_label: "Συνομιλία υποστήριξης"
|
|
1906
|
-
},
|
|
1978
|
+
}, Je = {
|
|
1907
1979
|
write_a_message_placeholder: "Nachricht schreiben...",
|
|
1908
1980
|
your_issue_has_been_resolved: "Ihr Problem wurde gelöst!",
|
|
1909
1981
|
new_conversation: "Neue Konversation",
|
|
@@ -2000,7 +2072,7 @@ const Oe = {
|
|
|
2000
2072
|
zoom_out: "Verkleinern",
|
|
2001
2073
|
reset_zoom: "Zoom zurücksetzen",
|
|
2002
2074
|
support_chat_aria_label: "Support-Chat"
|
|
2003
|
-
},
|
|
2075
|
+
}, J = {
|
|
2004
2076
|
write_a_message_placeholder: "Write a message...",
|
|
2005
2077
|
your_issue_has_been_resolved: "Your issue has been resolved!",
|
|
2006
2078
|
new_conversation: "New conversation",
|
|
@@ -2037,6 +2109,7 @@ const Oe = {
|
|
|
2037
2109
|
companion_active_chats: "{count} active sessions",
|
|
2038
2110
|
companion_other_sessions: "Other open sessions: {count}",
|
|
2039
2111
|
companion_working_chats: "{count} working",
|
|
2112
|
+
unread_sessions: "{count} unread",
|
|
2040
2113
|
companion_history: "Conversation history",
|
|
2041
2114
|
companion_expand_chat: "Expand chat",
|
|
2042
2115
|
companion_sidebar_dock_label: "Dock",
|
|
@@ -2109,7 +2182,7 @@ const Oe = {
|
|
|
2109
2182
|
zoom_out: "Zoom out",
|
|
2110
2183
|
reset_zoom: "Reset zoom",
|
|
2111
2184
|
support_chat_aria_label: "Support chat"
|
|
2112
|
-
},
|
|
2185
|
+
}, Ye = {
|
|
2113
2186
|
write_a_message_placeholder: "Escribe un mensaje...",
|
|
2114
2187
|
your_issue_has_been_resolved: "¡Tu problema fue resuelto!",
|
|
2115
2188
|
new_conversation: "Nueva conversación",
|
|
@@ -2206,7 +2279,7 @@ const Oe = {
|
|
|
2206
2279
|
zoom_out: "Alejar",
|
|
2207
2280
|
reset_zoom: "Restablecer zoom",
|
|
2208
2281
|
support_chat_aria_label: "Chat de soporte"
|
|
2209
|
-
},
|
|
2282
|
+
}, Xe = {
|
|
2210
2283
|
write_a_message_placeholder: "Magsulat ng mensahe...",
|
|
2211
2284
|
your_issue_has_been_resolved: "Nalutas na ang iyong isyu!",
|
|
2212
2285
|
new_conversation: "Bagong usapan",
|
|
@@ -2303,7 +2376,7 @@ const Oe = {
|
|
|
2303
2376
|
zoom_out: "Paliitin",
|
|
2304
2377
|
reset_zoom: "I-reset ang zoom",
|
|
2305
2378
|
support_chat_aria_label: "Chat ng suporta"
|
|
2306
|
-
},
|
|
2379
|
+
}, Qe = {
|
|
2307
2380
|
write_a_message_placeholder: "Kirjoita viesti...",
|
|
2308
2381
|
your_issue_has_been_resolved: "Ongelmasi on ratkaistu!",
|
|
2309
2382
|
new_conversation: "Uusi keskustelu",
|
|
@@ -2400,7 +2473,7 @@ const Oe = {
|
|
|
2400
2473
|
zoom_out: "Loitonna",
|
|
2401
2474
|
reset_zoom: "Palauta zoomaus",
|
|
2402
2475
|
support_chat_aria_label: "Tukichat"
|
|
2403
|
-
},
|
|
2476
|
+
}, ea = {
|
|
2404
2477
|
write_a_message_placeholder: "Écrivez un message...",
|
|
2405
2478
|
your_issue_has_been_resolved: "Votre problème a été résolu !",
|
|
2406
2479
|
new_conversation: "Nouvelle conversation",
|
|
@@ -2497,7 +2570,7 @@ const Oe = {
|
|
|
2497
2570
|
zoom_out: "Zoom arrière",
|
|
2498
2571
|
reset_zoom: "Réinitialiser le zoom",
|
|
2499
2572
|
support_chat_aria_label: "Chat de support"
|
|
2500
|
-
},
|
|
2573
|
+
}, aa = {
|
|
2501
2574
|
write_a_message_placeholder: "एक संदेश लिखें...",
|
|
2502
2575
|
your_issue_has_been_resolved: "आपकी समस्या हल हो गई है!",
|
|
2503
2576
|
new_conversation: "नई बातचीत",
|
|
@@ -2594,7 +2667,7 @@ const Oe = {
|
|
|
2594
2667
|
zoom_out: "ज़ूम आउट",
|
|
2595
2668
|
reset_zoom: "ज़ूम रीसेट करें",
|
|
2596
2669
|
support_chat_aria_label: "सहायता चैट"
|
|
2597
|
-
},
|
|
2670
|
+
}, ta = {
|
|
2598
2671
|
write_a_message_placeholder: "Scrivi un messaggio...",
|
|
2599
2672
|
your_issue_has_been_resolved: "Il tuo problema è stato risolto!",
|
|
2600
2673
|
new_conversation: "Nuova conversazione",
|
|
@@ -2691,7 +2764,7 @@ const Oe = {
|
|
|
2691
2764
|
zoom_out: "Riduci",
|
|
2692
2765
|
reset_zoom: "Reimposta zoom",
|
|
2693
2766
|
support_chat_aria_label: "Chat di supporto"
|
|
2694
|
-
},
|
|
2767
|
+
}, sa = {
|
|
2695
2768
|
write_a_message_placeholder: "メッセージを入力...",
|
|
2696
2769
|
your_issue_has_been_resolved: "問題が解決しました!",
|
|
2697
2770
|
new_conversation: "新しい会話",
|
|
@@ -2788,7 +2861,7 @@ const Oe = {
|
|
|
2788
2861
|
zoom_out: "縮小",
|
|
2789
2862
|
reset_zoom: "ズームをリセット",
|
|
2790
2863
|
support_chat_aria_label: "サポートチャット"
|
|
2791
|
-
},
|
|
2864
|
+
}, oa = {
|
|
2792
2865
|
write_a_message_placeholder: "메시지를 입력하세요...",
|
|
2793
2866
|
your_issue_has_been_resolved: "문제가 해결되었습니다!",
|
|
2794
2867
|
new_conversation: "새 대화",
|
|
@@ -2885,7 +2958,7 @@ const Oe = {
|
|
|
2885
2958
|
zoom_out: "축소",
|
|
2886
2959
|
reset_zoom: "확대/축소 초기화",
|
|
2887
2960
|
support_chat_aria_label: "고객 지원 채팅"
|
|
2888
|
-
},
|
|
2961
|
+
}, na = {
|
|
2889
2962
|
write_a_message_placeholder: "Schrijf een bericht...",
|
|
2890
2963
|
your_issue_has_been_resolved: "Uw probleem is opgelost!",
|
|
2891
2964
|
new_conversation: "Nieuw gesprek",
|
|
@@ -2982,7 +3055,7 @@ const Oe = {
|
|
|
2982
3055
|
zoom_out: "Uitzoomen",
|
|
2983
3056
|
reset_zoom: "Zoom herstellen",
|
|
2984
3057
|
support_chat_aria_label: "Supportchat"
|
|
2985
|
-
},
|
|
3058
|
+
}, ia = {
|
|
2986
3059
|
write_a_message_placeholder: "Skriv en melding...",
|
|
2987
3060
|
your_issue_has_been_resolved: "Problemet ditt er løst!",
|
|
2988
3061
|
new_conversation: "Ny samtale",
|
|
@@ -3079,7 +3152,7 @@ const Oe = {
|
|
|
3079
3152
|
zoom_out: "Zoom ut",
|
|
3080
3153
|
reset_zoom: "Tilbakestill zoom",
|
|
3081
3154
|
support_chat_aria_label: "Support-chat"
|
|
3082
|
-
},
|
|
3155
|
+
}, ra = {
|
|
3083
3156
|
write_a_message_placeholder: "Napisz wiadomość...",
|
|
3084
3157
|
your_issue_has_been_resolved: "Twój problem został rozwiązany!",
|
|
3085
3158
|
new_conversation: "Nowa rozmowa",
|
|
@@ -3176,7 +3249,7 @@ const Oe = {
|
|
|
3176
3249
|
zoom_out: "Pomniejsz",
|
|
3177
3250
|
reset_zoom: "Resetuj powiększenie",
|
|
3178
3251
|
support_chat_aria_label: "Czat pomocy"
|
|
3179
|
-
},
|
|
3252
|
+
}, _a = {
|
|
3180
3253
|
write_a_message_placeholder: "Escreva uma mensagem...",
|
|
3181
3254
|
your_issue_has_been_resolved: "Seu problema foi resolvido!",
|
|
3182
3255
|
new_conversation: "Nova conversa",
|
|
@@ -3273,7 +3346,7 @@ const Oe = {
|
|
|
3273
3346
|
zoom_out: "Reduzir",
|
|
3274
3347
|
reset_zoom: "Redefinir zoom",
|
|
3275
3348
|
support_chat_aria_label: "Chat de suporte"
|
|
3276
|
-
},
|
|
3349
|
+
}, la = {
|
|
3277
3350
|
write_a_message_placeholder: "Scrie un mesaj...",
|
|
3278
3351
|
your_issue_has_been_resolved: "Problema ta a fost rezolvată!",
|
|
3279
3352
|
new_conversation: "Conversație nouă",
|
|
@@ -3370,7 +3443,7 @@ const Oe = {
|
|
|
3370
3443
|
zoom_out: "Micșorează",
|
|
3371
3444
|
reset_zoom: "Resetează zoomul",
|
|
3372
3445
|
support_chat_aria_label: "Chat de asistență"
|
|
3373
|
-
},
|
|
3446
|
+
}, ca = {
|
|
3374
3447
|
write_a_message_placeholder: "Skriv ett meddelande...",
|
|
3375
3448
|
your_issue_has_been_resolved: "Ditt problem har lösts!",
|
|
3376
3449
|
new_conversation: "Ny konversation",
|
|
@@ -3467,7 +3540,7 @@ const Oe = {
|
|
|
3467
3540
|
zoom_out: "Zooma ut",
|
|
3468
3541
|
reset_zoom: "Återställ zoom",
|
|
3469
3542
|
support_chat_aria_label: "Supportchatt"
|
|
3470
|
-
},
|
|
3543
|
+
}, pa = {
|
|
3471
3544
|
write_a_message_placeholder: "Напишите сообщение...",
|
|
3472
3545
|
your_issue_has_been_resolved: "Ваша проблема решена!",
|
|
3473
3546
|
new_conversation: "Новый разговор",
|
|
@@ -3564,7 +3637,7 @@ const Oe = {
|
|
|
3564
3637
|
zoom_out: "Уменьшить",
|
|
3565
3638
|
reset_zoom: "Сбросить масштаб",
|
|
3566
3639
|
support_chat_aria_label: "Чат поддержки"
|
|
3567
|
-
},
|
|
3640
|
+
}, da = {
|
|
3568
3641
|
write_a_message_placeholder: "เขียนข้อความ...",
|
|
3569
3642
|
your_issue_has_been_resolved: "ปัญหาของคุณได้รับการแก้ไขแล้ว!",
|
|
3570
3643
|
new_conversation: "การสนทนาใหม่",
|
|
@@ -3661,7 +3734,7 @@ const Oe = {
|
|
|
3661
3734
|
zoom_out: "ย่อ",
|
|
3662
3735
|
reset_zoom: "รีเซ็ตการซูม",
|
|
3663
3736
|
support_chat_aria_label: "แชทฝ่ายสนับสนุน"
|
|
3664
|
-
},
|
|
3737
|
+
}, ua = {
|
|
3665
3738
|
write_a_message_placeholder: "Bir mesaj yazın...",
|
|
3666
3739
|
your_issue_has_been_resolved: "Sorununuz çözüldü!",
|
|
3667
3740
|
new_conversation: "Yeni konuşma",
|
|
@@ -3758,7 +3831,7 @@ const Oe = {
|
|
|
3758
3831
|
zoom_out: "Uzaklaştır",
|
|
3759
3832
|
reset_zoom: "Yakınlaştırmayı sıfırla",
|
|
3760
3833
|
support_chat_aria_label: "Destek sohbeti"
|
|
3761
|
-
},
|
|
3834
|
+
}, ma = {
|
|
3762
3835
|
write_a_message_placeholder: "پیغام لکھیں...",
|
|
3763
3836
|
your_issue_has_been_resolved: "آپ کا مسئلہ حل ہو گیا ہے!",
|
|
3764
3837
|
new_conversation: "نئی گفتگو",
|
|
@@ -3855,7 +3928,7 @@ const Oe = {
|
|
|
3855
3928
|
zoom_out: "زوم آؤٹ",
|
|
3856
3929
|
reset_zoom: "زوم دوبارہ ترتیب دیں",
|
|
3857
3930
|
support_chat_aria_label: "سپورٹ چیٹ"
|
|
3858
|
-
},
|
|
3931
|
+
}, ha = {
|
|
3859
3932
|
write_a_message_placeholder: "Viết tin nhắn...",
|
|
3860
3933
|
your_issue_has_been_resolved: "Vấn đề của bạn đã được giải quyết!",
|
|
3861
3934
|
new_conversation: "Cuộc trò chuyện mới",
|
|
@@ -3952,7 +4025,7 @@ const Oe = {
|
|
|
3952
4025
|
zoom_out: "Thu nhỏ",
|
|
3953
4026
|
reset_zoom: "Đặt lại thu phóng",
|
|
3954
4027
|
support_chat_aria_label: "Trò chuyện hỗ trợ"
|
|
3955
|
-
},
|
|
4028
|
+
}, ga = {
|
|
3956
4029
|
write_a_message_placeholder: "写一条消息...",
|
|
3957
4030
|
your_issue_has_been_resolved: "您的问题已解决!",
|
|
3958
4031
|
new_conversation: "新对话",
|
|
@@ -4049,7 +4122,7 @@ const Oe = {
|
|
|
4049
4122
|
zoom_out: "缩小",
|
|
4050
4123
|
reset_zoom: "重置缩放",
|
|
4051
4124
|
support_chat_aria_label: "支持对话"
|
|
4052
|
-
},
|
|
4125
|
+
}, ka = {
|
|
4053
4126
|
write_a_message_placeholder: "Napišite poruku...",
|
|
4054
4127
|
your_issue_has_been_resolved: "Vaš problem je riješen!",
|
|
4055
4128
|
new_conversation: "Novi razgovor",
|
|
@@ -4146,7 +4219,7 @@ const Oe = {
|
|
|
4146
4219
|
zoom_out: "Udalji",
|
|
4147
4220
|
reset_zoom: "Poništi zumiranje",
|
|
4148
4221
|
support_chat_aria_label: "Chat za podršku"
|
|
4149
|
-
},
|
|
4222
|
+
}, ba = {
|
|
4150
4223
|
write_a_message_placeholder: "Kirjuta sõnum...",
|
|
4151
4224
|
your_issue_has_been_resolved: "Teie probleem on lahendatud!",
|
|
4152
4225
|
new_conversation: "Uus vestlus",
|
|
@@ -4243,7 +4316,7 @@ const Oe = {
|
|
|
4243
4316
|
zoom_out: "Vähenda",
|
|
4244
4317
|
reset_zoom: "Lähtesta suurendus",
|
|
4245
4318
|
support_chat_aria_label: "Tugivestlus"
|
|
4246
|
-
},
|
|
4319
|
+
}, va = {
|
|
4247
4320
|
write_a_message_placeholder: "Írjon üzenetet...",
|
|
4248
4321
|
your_issue_has_been_resolved: "A problémája megoldódott!",
|
|
4249
4322
|
new_conversation: "Új beszélgetés",
|
|
@@ -4340,7 +4413,7 @@ const Oe = {
|
|
|
4340
4413
|
zoom_out: "Kicsinyítés",
|
|
4341
4414
|
reset_zoom: "Nagyítás visszaállítása",
|
|
4342
4415
|
support_chat_aria_label: "Ügyfélszolgálati chat"
|
|
4343
|
-
},
|
|
4416
|
+
}, fa = {
|
|
4344
4417
|
write_a_message_placeholder: "Skrifaðu skilaboð...",
|
|
4345
4418
|
your_issue_has_been_resolved: "Málið þitt hefur verið leyst!",
|
|
4346
4419
|
new_conversation: "Nýtt samtal",
|
|
@@ -4437,7 +4510,7 @@ const Oe = {
|
|
|
4437
4510
|
zoom_out: "Minnka aðdrátt",
|
|
4438
4511
|
reset_zoom: "Endurstilla aðdrátt",
|
|
4439
4512
|
support_chat_aria_label: "Þjónustuspjall"
|
|
4440
|
-
},
|
|
4513
|
+
}, ya = {
|
|
4441
4514
|
write_a_message_placeholder: "Rakstiet ziņojumu...",
|
|
4442
4515
|
your_issue_has_been_resolved: "Jūsu problēma ir atrisināta!",
|
|
4443
4516
|
new_conversation: "Jauna saruna",
|
|
@@ -4534,7 +4607,7 @@ const Oe = {
|
|
|
4534
4607
|
zoom_out: "Attālināt",
|
|
4535
4608
|
reset_zoom: "Atiestatīt tālummaiņu",
|
|
4536
4609
|
support_chat_aria_label: "Atbalsta tērzēšana"
|
|
4537
|
-
},
|
|
4610
|
+
}, wa = {
|
|
4538
4611
|
write_a_message_placeholder: "Parašykite žinutę...",
|
|
4539
4612
|
your_issue_has_been_resolved: "Jūsų problema išspręsta!",
|
|
4540
4613
|
new_conversation: "Naujas pokalbis",
|
|
@@ -4631,7 +4704,7 @@ const Oe = {
|
|
|
4631
4704
|
zoom_out: "Nutolinti",
|
|
4632
4705
|
reset_zoom: "Atstatyti mastelį",
|
|
4633
4706
|
support_chat_aria_label: "Pagalbos pokalbis"
|
|
4634
|
-
},
|
|
4707
|
+
}, ja = {
|
|
4635
4708
|
write_a_message_placeholder: "Schreift eng Noriicht...",
|
|
4636
4709
|
your_issue_has_been_resolved: "Äert Problem gouf geléist!",
|
|
4637
4710
|
new_conversation: "Nei Konversatioun",
|
|
@@ -4728,7 +4801,7 @@ const Oe = {
|
|
|
4728
4801
|
zoom_out: "Erauszoomen",
|
|
4729
4802
|
reset_zoom: "Zoom zrécksetzen",
|
|
4730
4803
|
support_chat_aria_label: "Support-Chat"
|
|
4731
|
-
},
|
|
4804
|
+
}, Sa = {
|
|
4732
4805
|
write_a_message_placeholder: "Ikteb messaġġ...",
|
|
4733
4806
|
your_issue_has_been_resolved: "Il-problema tiegħek ġiet riżolta!",
|
|
4734
4807
|
new_conversation: "Konversazzjoni ġdida",
|
|
@@ -4825,7 +4898,7 @@ const Oe = {
|
|
|
4825
4898
|
zoom_out: "Ċekken",
|
|
4826
4899
|
reset_zoom: "Irrisettja ż-zoom",
|
|
4827
4900
|
support_chat_aria_label: "Chat ta’ appoġġ"
|
|
4828
|
-
},
|
|
4901
|
+
}, za = {
|
|
4829
4902
|
write_a_message_placeholder: "Skriv en melding...",
|
|
4830
4903
|
your_issue_has_been_resolved: "Saken din er løst!",
|
|
4831
4904
|
new_conversation: "Ny samtale",
|
|
@@ -4922,7 +4995,7 @@ const Oe = {
|
|
|
4922
4995
|
zoom_out: "Zoom ut",
|
|
4923
4996
|
reset_zoom: "Tilbakestill zoom",
|
|
4924
4997
|
support_chat_aria_label: "Support-chat"
|
|
4925
|
-
},
|
|
4998
|
+
}, Ca = {
|
|
4926
4999
|
write_a_message_placeholder: "Napíšte správu...",
|
|
4927
5000
|
your_issue_has_been_resolved: "Váš problém bol vyriešený!",
|
|
4928
5001
|
new_conversation: "Nová konverzácia",
|
|
@@ -5019,82 +5092,82 @@ const Oe = {
|
|
|
5019
5092
|
zoom_out: "Oddialiť",
|
|
5020
5093
|
reset_zoom: "Obnoviť priblíženie",
|
|
5021
5094
|
support_chat_aria_label: "Chat podpory"
|
|
5022
|
-
},
|
|
5023
|
-
ar:
|
|
5024
|
-
bn:
|
|
5025
|
-
bg:
|
|
5026
|
-
cs:
|
|
5027
|
-
da:
|
|
5028
|
-
de:
|
|
5029
|
-
el:
|
|
5030
|
-
en:
|
|
5031
|
-
es:
|
|
5032
|
-
et:
|
|
5033
|
-
fi:
|
|
5034
|
-
fil:
|
|
5035
|
-
fr:
|
|
5036
|
-
hi:
|
|
5037
|
-
hr:
|
|
5038
|
-
hu:
|
|
5039
|
-
is:
|
|
5040
|
-
it:
|
|
5041
|
-
ja:
|
|
5042
|
-
ko:
|
|
5043
|
-
lb:
|
|
5044
|
-
lt:
|
|
5045
|
-
lv:
|
|
5046
|
-
mt:
|
|
5047
|
-
nb:
|
|
5048
|
-
nl:
|
|
5049
|
-
no:
|
|
5050
|
-
pl:
|
|
5051
|
-
pt:
|
|
5052
|
-
ro:
|
|
5053
|
-
ru:
|
|
5054
|
-
sk:
|
|
5055
|
-
sv:
|
|
5056
|
-
th:
|
|
5057
|
-
tr:
|
|
5058
|
-
ur:
|
|
5059
|
-
vi:
|
|
5060
|
-
"zh-cn":
|
|
5061
|
-
},
|
|
5062
|
-
function
|
|
5063
|
-
return
|
|
5095
|
+
}, Y = {
|
|
5096
|
+
ar: Ve,
|
|
5097
|
+
bn: He,
|
|
5098
|
+
bg: Ge,
|
|
5099
|
+
cs: Ze,
|
|
5100
|
+
da: We,
|
|
5101
|
+
de: Je,
|
|
5102
|
+
el: $e,
|
|
5103
|
+
en: J,
|
|
5104
|
+
es: Ye,
|
|
5105
|
+
et: ba,
|
|
5106
|
+
fi: Qe,
|
|
5107
|
+
fil: Xe,
|
|
5108
|
+
fr: ea,
|
|
5109
|
+
hi: aa,
|
|
5110
|
+
hr: ka,
|
|
5111
|
+
hu: va,
|
|
5112
|
+
is: fa,
|
|
5113
|
+
it: ta,
|
|
5114
|
+
ja: sa,
|
|
5115
|
+
ko: oa,
|
|
5116
|
+
lb: ja,
|
|
5117
|
+
lt: wa,
|
|
5118
|
+
lv: ya,
|
|
5119
|
+
mt: Sa,
|
|
5120
|
+
nb: za,
|
|
5121
|
+
nl: na,
|
|
5122
|
+
no: ia,
|
|
5123
|
+
pl: ra,
|
|
5124
|
+
pt: _a,
|
|
5125
|
+
ro: la,
|
|
5126
|
+
ru: pa,
|
|
5127
|
+
sk: Ca,
|
|
5128
|
+
sv: ca,
|
|
5129
|
+
th: da,
|
|
5130
|
+
tr: ua,
|
|
5131
|
+
ur: ma,
|
|
5132
|
+
vi: ha,
|
|
5133
|
+
"zh-cn": ga
|
|
5134
|
+
}, xa = Object.keys(Y);
|
|
5135
|
+
function qa(i) {
|
|
5136
|
+
return xa.includes(i);
|
|
5064
5137
|
}
|
|
5065
|
-
const
|
|
5066
|
-
function
|
|
5067
|
-
return
|
|
5138
|
+
const Ea = /* @__PURE__ */ new Set(["ar", "ur"]);
|
|
5139
|
+
function Qa(i) {
|
|
5140
|
+
return Ea.has(i);
|
|
5068
5141
|
}
|
|
5069
|
-
function
|
|
5070
|
-
return
|
|
5142
|
+
function Aa(i) {
|
|
5143
|
+
return qa(i) ? i : "en";
|
|
5071
5144
|
}
|
|
5072
|
-
function
|
|
5073
|
-
var
|
|
5074
|
-
const r = ((
|
|
5145
|
+
function Pa(i, e, t, o) {
|
|
5146
|
+
var _;
|
|
5147
|
+
const r = ((_ = t == null ? void 0 : t[e]) == null ? void 0 : _[i]) || Y[e][i] || J[i] || i;
|
|
5075
5148
|
return o ? r.replace(
|
|
5076
5149
|
/\{(\w+)\}/g,
|
|
5077
5150
|
(s, a) => a in o ? String(o[a]) : s
|
|
5078
5151
|
) : r;
|
|
5079
5152
|
}
|
|
5080
|
-
function
|
|
5081
|
-
return
|
|
5153
|
+
function Ta(i, e, t) {
|
|
5154
|
+
return Pa(
|
|
5082
5155
|
e,
|
|
5083
|
-
|
|
5156
|
+
Aa(i.language),
|
|
5084
5157
|
i.translationOverrides,
|
|
5085
5158
|
t
|
|
5086
5159
|
);
|
|
5087
5160
|
}
|
|
5088
|
-
class
|
|
5161
|
+
class Ia {
|
|
5089
5162
|
constructor({
|
|
5090
5163
|
config: e,
|
|
5091
5164
|
api: t,
|
|
5092
5165
|
contactCtx: o,
|
|
5093
5166
|
storageCtx: r,
|
|
5094
|
-
sessionsPollingIntervalSeconds:
|
|
5167
|
+
sessionsPollingIntervalSeconds: _,
|
|
5095
5168
|
sharedSessions: s
|
|
5096
5169
|
}) {
|
|
5097
|
-
this.sessionsRefresher = new
|
|
5170
|
+
this.sessionsRefresher = new W(), this.persistedSessionId = null, this.sessionAbortController = new AbortController(), this.sessionState = new S({
|
|
5098
5171
|
session: null,
|
|
5099
5172
|
isCreatingSession: !1,
|
|
5100
5173
|
isResolvingSession: !1
|
|
@@ -5122,11 +5195,11 @@ class Ea {
|
|
|
5122
5195
|
}, this.persistSession = ({ session: a }) => {
|
|
5123
5196
|
const n = this.storageCtx;
|
|
5124
5197
|
if (!n) return;
|
|
5125
|
-
const
|
|
5126
|
-
if (
|
|
5127
|
-
this.persistedSessionId =
|
|
5198
|
+
const c = a != null && a.isOpened ? a.id : null;
|
|
5199
|
+
if (c === this.persistedSessionId || !c && this.persistedSessionId === null) return;
|
|
5200
|
+
this.persistedSessionId = c, (c ? n.setActiveSessionId(c) : n.clearActiveSessionId()).catch((l) => {
|
|
5128
5201
|
k.warn("failed to persist the active session", {
|
|
5129
|
-
error:
|
|
5202
|
+
error: l instanceof Error ? l.message : String(l)
|
|
5130
5203
|
});
|
|
5131
5204
|
});
|
|
5132
5205
|
}, this.getLastActiveSessionId = async () => {
|
|
@@ -5151,8 +5224,8 @@ class Ea {
|
|
|
5151
5224
|
this.sessionsState.get().didStartInitialFetch === !1 && this.sessionsState.setPartial({ didStartInitialFetch: !0 }), await this.refreshSessions(), this.sessionsState.get().isInitialFetchLoading === !0 && this.sessionsState.setPartial({ isInitialFetchLoading: !1 });
|
|
5152
5225
|
}, this.sessionsPollingIntervalSeconds * 1e3);
|
|
5153
5226
|
}, this.dispose = ({ clearActiveSession: a = !1 } = {}) => {
|
|
5154
|
-
var n,
|
|
5155
|
-
if (this.sessionsRefresher.reset(), this.sessionAbortController.abort(), (n = this.stopPersistingSession) == null || n.call(this), this.stopPersistingSession = void 0, (
|
|
5227
|
+
var n, c;
|
|
5228
|
+
if (this.sessionsRefresher.reset(), this.sessionAbortController.abort(), (n = this.stopPersistingSession) == null || n.call(this), this.stopPersistingSession = void 0, (c = this.stopWaitingForContact) == null || c.call(this), this.stopWaitingForContact = void 0, this.sessionState.reset(), a && this.storageCtx)
|
|
5156
5229
|
return this.persistedSessionId = null, this.storageCtx.clearActiveSessionId().catch((d) => {
|
|
5157
5230
|
k.warn("failed to clear the replaced session", {
|
|
5158
5231
|
error: d instanceof Error ? d.message : String(d)
|
|
@@ -5161,8 +5234,8 @@ class Ea {
|
|
|
5161
5234
|
}, this.getParsedCustomData = () => Object.fromEntries(
|
|
5162
5235
|
Object.entries(this.config.sessionCustomData || {}).map(
|
|
5163
5236
|
([a, n]) => {
|
|
5164
|
-
var
|
|
5165
|
-
return typeof n == "string" ? [a, n] : typeof n == "boolean" ? [a, n] : typeof n == "number" ? [a, n] : [a, ((
|
|
5237
|
+
var c;
|
|
5238
|
+
return typeof n == "string" ? [a, n] : typeof n == "boolean" ? [a, n] : typeof n == "number" ? [a, n] : [a, ((c = $(() => JSON.stringify(n))) == null ? void 0 : c.data) || ""];
|
|
5166
5239
|
}
|
|
5167
5240
|
)
|
|
5168
5241
|
), this.createSession = async () => {
|
|
@@ -5174,8 +5247,8 @@ class Ea {
|
|
|
5174
5247
|
if (n.session) return n.session;
|
|
5175
5248
|
if (n.status === 401 && await this.contactCtx.recoverFromStaleToken()) {
|
|
5176
5249
|
if (a.aborted) return null;
|
|
5177
|
-
const
|
|
5178
|
-
return a.aborted ? null :
|
|
5250
|
+
const c = await this.requestSession(a);
|
|
5251
|
+
return a.aborted ? null : c.session ? c.session : (k.error("failed to create session", c.error), null);
|
|
5179
5252
|
}
|
|
5180
5253
|
return k.error("failed to create session", n.error), null;
|
|
5181
5254
|
} catch (n) {
|
|
@@ -5185,21 +5258,21 @@ class Ea {
|
|
|
5185
5258
|
}
|
|
5186
5259
|
}, this.requestSession = async (a) => {
|
|
5187
5260
|
var u, m, g;
|
|
5188
|
-
const n = (u = this.contactCtx.state.get().contact) == null ? void 0 : u.externalId,
|
|
5261
|
+
const n = (u = this.contactCtx.state.get().contact) == null ? void 0 : u.externalId, c = {
|
|
5189
5262
|
...this.getParsedCustomData(),
|
|
5190
5263
|
...n ? { external_id: n } : {}
|
|
5191
5264
|
}, {
|
|
5192
5265
|
data: d,
|
|
5193
|
-
error:
|
|
5266
|
+
error: l,
|
|
5194
5267
|
response: p
|
|
5195
5268
|
} = await this.api.createSession(
|
|
5196
5269
|
{
|
|
5197
|
-
customData: Object.keys(
|
|
5270
|
+
customData: Object.keys(c).length > 0 ? c : void 0
|
|
5198
5271
|
},
|
|
5199
5272
|
a
|
|
5200
5273
|
);
|
|
5201
5274
|
if (a.aborted || !d)
|
|
5202
|
-
return { session: null, status: p == null ? void 0 : p.status, error:
|
|
5275
|
+
return { session: null, status: p == null ? void 0 : p.status, error: l };
|
|
5203
5276
|
this.sessionState.setPartial({ session: d });
|
|
5204
5277
|
try {
|
|
5205
5278
|
(g = (m = this.config.hooks) == null ? void 0 : m.onSessionCreated) == null || g.call(m, { session: d });
|
|
@@ -5213,18 +5286,18 @@ class Ea {
|
|
|
5213
5286
|
cursor: this.sessionsState.get().cursor
|
|
5214
5287
|
});
|
|
5215
5288
|
if (a) {
|
|
5216
|
-
const
|
|
5217
|
-
(d,
|
|
5289
|
+
const c = [...this.sessionsState.get().data, ...a.items].filter(
|
|
5290
|
+
(d, l, p) => l === p.findIndex((u) => d.id === u.id)
|
|
5218
5291
|
);
|
|
5219
5292
|
this.sessionsState.setPartial({
|
|
5220
|
-
data:
|
|
5293
|
+
data: c,
|
|
5221
5294
|
cursor: a.next || void 0,
|
|
5222
5295
|
isLastPage: a.next === null
|
|
5223
5296
|
});
|
|
5224
5297
|
}
|
|
5225
5298
|
}, this.getSessions = async ({ cursor: a }) => {
|
|
5226
|
-
var
|
|
5227
|
-
if (!((
|
|
5299
|
+
var c, d;
|
|
5300
|
+
if (!((c = this.contactCtx.state.get().contact) != null && c.token)) return { data: null };
|
|
5228
5301
|
const n = (d = this.contactCtx.state.get().contact) == null ? void 0 : d.externalId;
|
|
5229
5302
|
return await this.api.getSessions({
|
|
5230
5303
|
cursor: a,
|
|
@@ -5234,7 +5307,7 @@ class Ea {
|
|
|
5234
5307
|
});
|
|
5235
5308
|
}, this.setSessions = (a) => {
|
|
5236
5309
|
const n = [...a, ...this.sessionsState.get().data].filter(
|
|
5237
|
-
(
|
|
5310
|
+
(c, d, l) => d === l.findIndex((p) => c.id === p.id)
|
|
5238
5311
|
);
|
|
5239
5312
|
this.sessionsState.setPartial({ data: n });
|
|
5240
5313
|
}, this.refreshSessions = async () => {
|
|
@@ -5245,31 +5318,31 @@ class Ea {
|
|
|
5245
5318
|
if (!a || !a.isOpened)
|
|
5246
5319
|
return { success: !1, error: "Session is not opened" };
|
|
5247
5320
|
this.sessionState.setPartial({ isResolvingSession: !0 });
|
|
5248
|
-
const { signal: n } = this.sessionAbortController,
|
|
5321
|
+
const { signal: n } = this.sessionAbortController, c = await this.api.resolveSession({ session_id: a.id }, n).catch((p) => {
|
|
5249
5322
|
if (n.aborted) return null;
|
|
5250
5323
|
throw p;
|
|
5251
5324
|
});
|
|
5252
|
-
if (!
|
|
5325
|
+
if (!c || n.aborted)
|
|
5253
5326
|
return { success: !1, error: "Session was reset" };
|
|
5254
|
-
const { data: d, error:
|
|
5255
|
-
return d ? (this.sessionState.setPartial({ session: d, isResolvingSession: !1 }), { success: !0, data: d }) : (this.sessionState.setPartial({ isResolvingSession: !1 }), { success: !1, error:
|
|
5327
|
+
const { data: d, error: l } = c;
|
|
5328
|
+
return d ? (this.sessionState.setPartial({ session: d, isResolvingSession: !1 }), { success: !0, data: d }) : (this.sessionState.setPartial({ isResolvingSession: !1 }), { success: !1, error: l });
|
|
5256
5329
|
}, this.createStateCheckpoint = async (a) => {
|
|
5257
5330
|
var d;
|
|
5258
5331
|
const n = (d = this.sessionState.get().session) == null ? void 0 : d.id;
|
|
5259
5332
|
if (!n) return;
|
|
5260
|
-
const { data:
|
|
5333
|
+
const { data: c } = await this.api.createStateCheckpoint({
|
|
5261
5334
|
session_id: n,
|
|
5262
5335
|
payload: a
|
|
5263
5336
|
});
|
|
5264
|
-
return
|
|
5265
|
-
}, this.config = e, this.api = t, this.contactCtx = o, this.storageCtx = r, this.sessionsPollingIntervalSeconds =
|
|
5337
|
+
return c != null && c.success ? { success: !0 } : { success: !1 };
|
|
5338
|
+
}, this.config = e, this.api = t, this.contactCtx = o, this.storageCtx = r, this.sessionsPollingIntervalSeconds = _, s ? this.sessionsState = s : this.registerSessionsRefresherWrapper(), this.registerActiveSessionPersistence();
|
|
5266
5339
|
}
|
|
5267
5340
|
}
|
|
5268
|
-
const
|
|
5269
|
-
const o =
|
|
5270
|
-
...
|
|
5341
|
+
const Ma = (i, e, { sendsPageContext: t }) => {
|
|
5342
|
+
const o = Na(i), r = t && e.mentions && e.mentions.length > 0 ? { mentions: e.mentions.map(Da) } : void 0, _ = t && (e.clientContext || r) ? { ...o, ...e.clientContext, ...r } : o, s = e.connectionRequestId ? {
|
|
5343
|
+
..._,
|
|
5271
5344
|
opencx__connection_request_id: e.connectionRequestId
|
|
5272
|
-
} :
|
|
5345
|
+
} : _, a = e.withPageEntity === !1 && s && "entity" in s ? Ra(s, "entity") : s;
|
|
5273
5346
|
return {
|
|
5274
5347
|
clientContext: e.background ? { ...a, opencx__background: !0 } : a,
|
|
5275
5348
|
custom_data: {
|
|
@@ -5277,15 +5350,15 @@ const Aa = (i, e, { sendsPageContext: t }) => {
|
|
|
5277
5350
|
...e.customData || {}
|
|
5278
5351
|
}
|
|
5279
5352
|
};
|
|
5280
|
-
},
|
|
5353
|
+
}, Da = ({ type: i, id: e, title: t, meta: o }) => ({
|
|
5281
5354
|
type: i,
|
|
5282
5355
|
id: e,
|
|
5283
5356
|
title: t,
|
|
5284
5357
|
...o ? { meta: o } : {}
|
|
5285
|
-
}),
|
|
5358
|
+
}), Ra = (i, e) => {
|
|
5286
5359
|
const { [e]: t, ...o } = i;
|
|
5287
5360
|
return Object.keys(o).length > 0 ? o : void 0;
|
|
5288
|
-
},
|
|
5361
|
+
}, Na = (i) => {
|
|
5289
5362
|
if (typeof i.context != "function") return i.context;
|
|
5290
5363
|
try {
|
|
5291
5364
|
return i.context();
|
|
@@ -5293,23 +5366,23 @@ const Aa = (i, e, { sendsPageContext: t }) => {
|
|
|
5293
5366
|
k.error("context getter threw; sending without context", e);
|
|
5294
5367
|
return;
|
|
5295
5368
|
}
|
|
5296
|
-
},
|
|
5369
|
+
}, Ka = (i) => {
|
|
5297
5370
|
const e = i.features, t = {
|
|
5298
5371
|
page_context: (e == null ? void 0 : e.pageContext) === !0,
|
|
5299
5372
|
client_tools: (e == null ? void 0 : e.pageContext) === !0 && (e == null ? void 0 : e.clientTools) === !0,
|
|
5300
5373
|
page_actions: (e == null ? void 0 : e.pageContext) === !0 && (e == null ? void 0 : e.clientTools) === !0 && (e == null ? void 0 : e.pageActions) === !0
|
|
5301
5374
|
};
|
|
5302
5375
|
return e && (e.preamble !== void 0 && (t.preamble = e.preamble), e.inlineUi !== void 0 && (t.inline_ui = e.inlineUi)), t;
|
|
5303
|
-
},
|
|
5376
|
+
}, La = ({
|
|
5304
5377
|
config: i,
|
|
5305
5378
|
input: e,
|
|
5306
5379
|
uuid: t,
|
|
5307
5380
|
sessionId: o,
|
|
5308
5381
|
content: r,
|
|
5309
|
-
initialMessages:
|
|
5382
|
+
initialMessages: _,
|
|
5310
5383
|
sendsPageContext: s
|
|
5311
5384
|
}) => {
|
|
5312
|
-
var a, n,
|
|
5385
|
+
var a, n, c, d;
|
|
5313
5386
|
return {
|
|
5314
5387
|
uuid: t,
|
|
5315
5388
|
bot_token: i.token,
|
|
@@ -5319,14 +5392,14 @@ const Aa = (i, e, { sendsPageContext: t }) => {
|
|
|
5319
5392
|
session_id: o,
|
|
5320
5393
|
content: r,
|
|
5321
5394
|
attachments: e.attachments,
|
|
5322
|
-
...
|
|
5395
|
+
...Ma(i, e, { sendsPageContext: s }),
|
|
5323
5396
|
language: i.language,
|
|
5324
|
-
features:
|
|
5397
|
+
features: Ka(i),
|
|
5325
5398
|
presentation: i.presentation,
|
|
5326
5399
|
capabilities: {
|
|
5327
5400
|
connections: ((a = i.capabilities) == null ? void 0 : a.connections) === !0,
|
|
5328
5401
|
structured_questions: (n = i.capabilities) == null ? void 0 : n.structuredQuestions,
|
|
5329
|
-
rich_replies: (
|
|
5402
|
+
rich_replies: (c = i.capabilities) == null ? void 0 : c.richReplies,
|
|
5330
5403
|
page_effects: (d = i.capabilities) == null ? void 0 : d.pageEffects
|
|
5331
5404
|
},
|
|
5332
5405
|
exit_mode_prompt: e.exitModePrompt,
|
|
@@ -5334,7 +5407,7 @@ const Aa = (i, e, { sendsPageContext: t }) => {
|
|
|
5334
5407
|
message_id: e.optionReply.messageId,
|
|
5335
5408
|
option_id: e.optionReply.optionId
|
|
5336
5409
|
} : void 0,
|
|
5337
|
-
initial_messages:
|
|
5410
|
+
initial_messages: _.length > 0 ? _.map((l) => ({ uuid: l.id, content: l.data.message })) : void 0
|
|
5338
5411
|
};
|
|
5339
5412
|
}, x = class x {
|
|
5340
5413
|
constructor({
|
|
@@ -5342,11 +5415,11 @@ const Aa = (i, e, { sendsPageContext: t }) => {
|
|
|
5342
5415
|
api: t,
|
|
5343
5416
|
sessionCtx: o,
|
|
5344
5417
|
contactCtx: r,
|
|
5345
|
-
streaming:
|
|
5418
|
+
streaming: _,
|
|
5346
5419
|
sendsPageContext: s,
|
|
5347
5420
|
getClientCapabilities: a,
|
|
5348
5421
|
getRequestConfig: n,
|
|
5349
|
-
isStreaming:
|
|
5422
|
+
isStreaming: c,
|
|
5350
5423
|
getSendsPageContext: d
|
|
5351
5424
|
}) {
|
|
5352
5425
|
this.state = new S({
|
|
@@ -5360,29 +5433,29 @@ const Aa = (i, e, { sendsPageContext: t }) => {
|
|
|
5360
5433
|
text: "",
|
|
5361
5434
|
mentions: []
|
|
5362
5435
|
}), this.agentHandlers = null, this.bufferedAgentSends = [], this.sendMessageAbortController = new AbortController(), this.conversationGeneration = 0, this.captureConversation = () => {
|
|
5363
|
-
const
|
|
5364
|
-
return () =>
|
|
5436
|
+
const l = this.conversationGeneration;
|
|
5437
|
+
return () => l === this.conversationGeneration;
|
|
5365
5438
|
}, this.messageIdsDispatchedToOnMessageReceivedHook = /* @__PURE__ */ new Set(), this.sentTextHistory = [], this.reset = () => {
|
|
5366
5439
|
this.conversationGeneration++, this.sendMessageAbortController.abort("Resetting chat"), this.bufferedAgentSends = [], this.state.reset(), this.messageIdsDispatchedToOnMessageReceivedHook.clear(), this.sentTextHistory = [], this.draftState.reset();
|
|
5367
|
-
}, this.rememberSentText = (
|
|
5368
|
-
const p =
|
|
5440
|
+
}, this.rememberSentText = (l) => {
|
|
5441
|
+
const p = l.trim();
|
|
5369
5442
|
!p || this.sentTextHistory.at(-1) === p || (this.sentTextHistory.push(p), this.sentTextHistory.length > x.SENT_TEXT_HISTORY_MAX && this.sentTextHistory.shift());
|
|
5370
|
-
}, this.getSentTextHistory = () => this.sentTextHistory, this.registerAgentHandlers = (
|
|
5371
|
-
this.agentHandlers =
|
|
5443
|
+
}, this.getSentTextHistory = () => this.sentTextHistory, this.registerAgentHandlers = (l) => {
|
|
5444
|
+
this.agentHandlers = l;
|
|
5372
5445
|
const p = this.bufferedAgentSends;
|
|
5373
5446
|
this.bufferedAgentSends = [], p.forEach((u) => {
|
|
5374
|
-
x.dispatchToEngine(
|
|
5447
|
+
x.dispatchToEngine(l, u);
|
|
5375
5448
|
});
|
|
5376
|
-
}, this.unregisterAgentHandlers = (
|
|
5377
|
-
this.agentHandlers ===
|
|
5378
|
-
}, this.dispatchToOnMessageReceivedHook = (
|
|
5449
|
+
}, this.unregisterAgentHandlers = (l) => {
|
|
5450
|
+
this.agentHandlers === l && (this.agentHandlers = null);
|
|
5451
|
+
}, this.dispatchToOnMessageReceivedHook = (l) => {
|
|
5379
5452
|
var u, m;
|
|
5380
|
-
if (
|
|
5453
|
+
if (l.type === "USER" || this.messageIdsDispatchedToOnMessageReceivedHook.has(l.id))
|
|
5381
5454
|
return;
|
|
5382
5455
|
const p = this.sessionCtx.sessionState.get().session;
|
|
5383
|
-
p && (this.messageIdsDispatchedToOnMessageReceivedHook.add(
|
|
5384
|
-
}, this.markAsDispatchedToOnMessageReceivedHook = (
|
|
5385
|
-
|
|
5456
|
+
p && (this.messageIdsDispatchedToOnMessageReceivedHook.add(l.id), (m = (u = this.config.hooks) == null ? void 0 : u.onMessageReceived) == null || m.call(u, { message: l, session: p }));
|
|
5457
|
+
}, this.markAsDispatchedToOnMessageReceivedHook = (l) => {
|
|
5458
|
+
l.forEach(
|
|
5386
5459
|
(p) => this.messageIdsDispatchedToOnMessageReceivedHook.add(p)
|
|
5387
5460
|
);
|
|
5388
5461
|
}, this.buildPersistentInitialMessages = () => {
|
|
@@ -5398,29 +5471,29 @@ const Aa = (i, e, { sendsPageContext: t }) => {
|
|
|
5398
5471
|
})
|
|
5399
5472
|
) : [];
|
|
5400
5473
|
}, this.ensureSessionId = async () => {
|
|
5401
|
-
var
|
|
5402
|
-
if (!((
|
|
5474
|
+
var l, p;
|
|
5475
|
+
if (!((l = this.sessionCtx.sessionState.get().session) != null && l.id)) {
|
|
5403
5476
|
if (!await this.sessionCtx.createSession()) return null;
|
|
5404
5477
|
this.sessionCtx.refreshSessions();
|
|
5405
5478
|
}
|
|
5406
5479
|
return ((p = this.sessionCtx.sessionState.get().session) == null ? void 0 : p.id) ?? null;
|
|
5407
|
-
}, this.rollbackOptimisticMessages = (
|
|
5408
|
-
if (
|
|
5409
|
-
const p = new Set(
|
|
5480
|
+
}, this.rollbackOptimisticMessages = (l) => {
|
|
5481
|
+
if (l.length === 0) return;
|
|
5482
|
+
const p = new Set(l), u = this.state.get().messages, m = u.filter((g) => !p.has(g.id));
|
|
5410
5483
|
m.length !== u.length && this.state.setPartial({ messages: m });
|
|
5411
|
-
}, this.notifySendAccepted = (
|
|
5484
|
+
}, this.notifySendAccepted = (l) => {
|
|
5412
5485
|
var p;
|
|
5413
|
-
|
|
5414
|
-
|
|
5415
|
-
|
|
5486
|
+
l.optionReply && this.setMessageOptionPick(
|
|
5487
|
+
l.optionReply.messageId,
|
|
5488
|
+
l.optionReply.optionId
|
|
5416
5489
|
);
|
|
5417
5490
|
try {
|
|
5418
|
-
(p =
|
|
5491
|
+
(p = l.onAccepted) == null || p.call(l);
|
|
5419
5492
|
} catch (u) {
|
|
5420
5493
|
k.error("send acceptance callback failed", u);
|
|
5421
5494
|
}
|
|
5422
|
-
}, this.stageUserTurn = async (
|
|
5423
|
-
const u = this.captureConversation(), m = this.buildUserMessage(
|
|
5495
|
+
}, this.stageUserTurn = async (l, { pending: p }) => {
|
|
5496
|
+
const u = this.captureConversation(), m = this.buildUserMessage(l);
|
|
5424
5497
|
if (!m) return null;
|
|
5425
5498
|
const g = p ? { ...m, pending: !0 } : m, b = this.buildPersistentInitialMessages(), f = [
|
|
5426
5499
|
...b.map((y) => y.id),
|
|
@@ -5441,30 +5514,30 @@ const Aa = (i, e, { sendsPageContext: t }) => {
|
|
|
5441
5514
|
throw this.rollbackOptimisticMessages(f), y;
|
|
5442
5515
|
}
|
|
5443
5516
|
return u() ? v ? { sessionId: v, userMessage: g, initialMessages: b } : (this.rollbackOptimisticMessages(f), null) : null;
|
|
5444
|
-
}, this.buildQueuedUserMessage = (
|
|
5517
|
+
}, this.buildQueuedUserMessage = (l) => {
|
|
5445
5518
|
var m;
|
|
5446
|
-
const p = this.buildUserMessage(
|
|
5519
|
+
const p = this.buildUserMessage(l);
|
|
5447
5520
|
if (!p) return null;
|
|
5448
5521
|
const u = (m = this.sessionCtx.sessionState.get().session) == null ? void 0 : m.id;
|
|
5449
5522
|
return u ? { sessionId: u, userMessage: { ...p, pending: !0 } } : null;
|
|
5450
|
-
}, this.buildUserMessage = (
|
|
5523
|
+
}, this.buildUserMessage = (l) => {
|
|
5451
5524
|
var p;
|
|
5452
|
-
return !
|
|
5525
|
+
return !l.content.trim() && (!l.attachments || l.attachments.length === 0) ? (k.warn("cannot send an empty message of no content or attachments"), null) : {
|
|
5453
5526
|
...this.toUserMessage(
|
|
5454
|
-
|
|
5455
|
-
|
|
5456
|
-
this.sendsPageContext ? x.markedElementNames(
|
|
5457
|
-
this.sendsPageContext && ((p =
|
|
5527
|
+
l.content.trim(),
|
|
5528
|
+
l.attachments || void 0,
|
|
5529
|
+
this.sendsPageContext ? x.markedElementNames(l.clientContext) : void 0,
|
|
5530
|
+
this.sendsPageContext && ((p = l.mentions) != null && p.length) ? l.mentions : void 0
|
|
5458
5531
|
),
|
|
5459
|
-
...
|
|
5532
|
+
...l.background ? { background: !0 } : {}
|
|
5460
5533
|
};
|
|
5461
|
-
}, this.appendUserMessageIfAbsent = (
|
|
5462
|
-
if (
|
|
5534
|
+
}, this.appendUserMessageIfAbsent = (l) => {
|
|
5535
|
+
if (l.background) return;
|
|
5463
5536
|
const p = this.state.get().messages;
|
|
5464
|
-
p.some((u) => u.id ===
|
|
5465
|
-
}, this.markUserMessageDelivered = (
|
|
5537
|
+
p.some((u) => u.id === l.id) || this.state.setPartial({ messages: [...p, l] });
|
|
5538
|
+
}, this.markUserMessageDelivered = (l) => {
|
|
5466
5539
|
const p = this.state.get().messages, u = p.findIndex(
|
|
5467
|
-
(b) => b.id ===
|
|
5540
|
+
(b) => b.id === l && b.type === "USER" && b.pending
|
|
5468
5541
|
);
|
|
5469
5542
|
if (u === -1) return;
|
|
5470
5543
|
const m = p[u];
|
|
@@ -5473,33 +5546,33 @@ const Aa = (i, e, { sendsPageContext: t }) => {
|
|
|
5473
5546
|
g[u] = { ...m, pending: !1 }, this.state.setPartial({
|
|
5474
5547
|
messages: g
|
|
5475
5548
|
});
|
|
5476
|
-
}, this.setMessageOptionPick = (
|
|
5477
|
-
const u = this.state.get().messages, m = u.findIndex((f) => f.id ===
|
|
5549
|
+
}, this.setMessageOptionPick = (l, p) => {
|
|
5550
|
+
const u = this.state.get().messages, m = u.findIndex((f) => f.id === l), g = u[m];
|
|
5478
5551
|
if (!g || g.type !== "AGENT" || !g.messageOptions || g.messageOptions.pickedOptionId === p) return;
|
|
5479
5552
|
const b = [...u];
|
|
5480
5553
|
b[m] = {
|
|
5481
5554
|
...g,
|
|
5482
5555
|
messageOptions: { ...g.messageOptions, pickedOptionId: p }
|
|
5483
5556
|
}, this.state.setPartial({ messages: b });
|
|
5484
|
-
}, this.releaseFailedOptionPick = (
|
|
5557
|
+
}, this.releaseFailedOptionPick = (l) => {
|
|
5485
5558
|
var g;
|
|
5486
|
-
if (!
|
|
5487
|
-
const { messageId: p, optionId: u } =
|
|
5559
|
+
if (!l.optionReply) return;
|
|
5560
|
+
const { messageId: p, optionId: u } = l.optionReply, m = this.state.get().messages.find((b) => b.id === p);
|
|
5488
5561
|
(m == null ? void 0 : m.type) !== "AGENT" || ((g = m.messageOptions) == null ? void 0 : g.pickedOptionId) !== u || this.setMessageOptionPick(p, null);
|
|
5489
|
-
}, this.sendMessage = async (
|
|
5562
|
+
}, this.sendMessage = async (l) => {
|
|
5490
5563
|
var u, m, g, b, f;
|
|
5491
5564
|
if (this.streaming) {
|
|
5492
5565
|
if (!this.agentHandlers) {
|
|
5493
|
-
this.bufferedAgentSends.push(
|
|
5566
|
+
this.bufferedAgentSends.push(l);
|
|
5494
5567
|
return;
|
|
5495
5568
|
}
|
|
5496
|
-
await this.agentHandlers.send(
|
|
5569
|
+
await this.agentHandlers.send(l);
|
|
5497
5570
|
return;
|
|
5498
5571
|
}
|
|
5499
5572
|
let p;
|
|
5500
5573
|
try {
|
|
5501
|
-
const v = this.sessionCtx.sessionState.get().session, z = (v == null ? void 0 : v.assignee.kind) === "ai",
|
|
5502
|
-
if (this.blocksSendWhileAwaitingReply && (
|
|
5574
|
+
const v = this.sessionCtx.sessionState.get().session, z = (v == null ? void 0 : v.assignee.kind) === "ai", Q = this.state.get().isSendingMessageToAI, A = this.state.get().messages.at(-1);
|
|
5575
|
+
if (this.blocksSendWhileAwaitingReply && (Q || // If last message is from user, then bot response did not arrive yet
|
|
5503
5576
|
z && (A == null ? void 0 : A.type) === "USER" && A.id !== this.state.get().settledAgentUserMessageId)) {
|
|
5504
5577
|
k.warn("cannot send messages while awaiting AI response");
|
|
5505
5578
|
return;
|
|
@@ -5509,21 +5582,21 @@ const Aa = (i, e, { sendsPageContext: t }) => {
|
|
|
5509
5582
|
isSendingMessage: !0,
|
|
5510
5583
|
isSendingMessageToAI: !!z || !v
|
|
5511
5584
|
});
|
|
5512
|
-
const
|
|
5513
|
-
if (!
|
|
5514
|
-
const { sessionId:
|
|
5515
|
-
this.notifySendAccepted(
|
|
5585
|
+
const N = await this.stageUserTurn(l, { pending: !1 });
|
|
5586
|
+
if (!N) return;
|
|
5587
|
+
const { sessionId: ee, userMessage: K, initialMessages: ae } = N;
|
|
5588
|
+
this.notifySendAccepted(l);
|
|
5516
5589
|
const { data: w } = await this.api.sendMessage(
|
|
5517
|
-
|
|
5590
|
+
La({
|
|
5518
5591
|
config: {
|
|
5519
5592
|
...this.getRequestConfig(),
|
|
5520
5593
|
capabilities: this.getClientCapabilities()
|
|
5521
5594
|
},
|
|
5522
|
-
input:
|
|
5595
|
+
input: l,
|
|
5523
5596
|
uuid: K.id,
|
|
5524
|
-
sessionId:
|
|
5597
|
+
sessionId: ee,
|
|
5525
5598
|
content: K.content,
|
|
5526
|
-
initialMessages:
|
|
5599
|
+
initialMessages: ae,
|
|
5527
5600
|
sendsPageContext: this.sendsPageContext
|
|
5528
5601
|
}),
|
|
5529
5602
|
p.signal
|
|
@@ -5533,7 +5606,7 @@ const Aa = (i, e, { sendsPageContext: t }) => {
|
|
|
5533
5606
|
if (C) {
|
|
5534
5607
|
const P = this.state.get().messages;
|
|
5535
5608
|
if (!!P.some(
|
|
5536
|
-
(
|
|
5609
|
+
(te) => te.id === C.id
|
|
5537
5610
|
)) {
|
|
5538
5611
|
this.state.setPartial({
|
|
5539
5612
|
lastAIResMightSolveUserIssue: ((u = w.autopilotResponse) == null ? void 0 : u.mightSolveUserIssue) || ((m = w.uiResponse) == null ? void 0 : m.mightSolveUserIssue)
|
|
@@ -5547,29 +5620,29 @@ const Aa = (i, e, { sendsPageContext: t }) => {
|
|
|
5547
5620
|
}
|
|
5548
5621
|
w.session && this.sessionCtx.sessionState.setPartial({ session: w.session });
|
|
5549
5622
|
} else {
|
|
5550
|
-
this.releaseFailedOptionPick(
|
|
5623
|
+
this.releaseFailedOptionPick(l);
|
|
5551
5624
|
const C = this.toBotErrorMessage(
|
|
5552
|
-
((f = w == null ? void 0 : w.error) == null ? void 0 : f.message) ||
|
|
5625
|
+
((f = w == null ? void 0 : w.error) == null ? void 0 : f.message) || Ta(this.config, "turn_failed_message")
|
|
5553
5626
|
), P = this.state.get().messages;
|
|
5554
5627
|
this.state.setPartial({
|
|
5555
5628
|
messages: [...P, C]
|
|
5556
5629
|
});
|
|
5557
5630
|
}
|
|
5558
5631
|
} catch (v) {
|
|
5559
|
-
p != null && p.signal.aborted || (this.releaseFailedOptionPick(
|
|
5632
|
+
p != null && p.signal.aborted || (this.releaseFailedOptionPick(l), k.error("failed to send message", v));
|
|
5560
5633
|
} finally {
|
|
5561
5634
|
p != null && p.signal.aborted || this.state.setPartial({
|
|
5562
5635
|
isSendingMessage: !1,
|
|
5563
5636
|
isSendingMessageToAI: !1
|
|
5564
5637
|
});
|
|
5565
5638
|
}
|
|
5566
|
-
}, this.toUserMessage = (
|
|
5639
|
+
}, this.toUserMessage = (l, p, u, m) => {
|
|
5567
5640
|
const g = (() => {
|
|
5568
5641
|
const f = this.contactCtx.state.get().extraCollectedData;
|
|
5569
5642
|
return this.state.get().messages.length === 0 && f && Object.keys(f).length > 0 ? `${Object.entries(f).filter(([y, z]) => !!z).map(([y, z]) => `${y}: ${z}`).join(`
|
|
5570
5643
|
`)}
|
|
5571
5644
|
|
|
5572
|
-
${
|
|
5645
|
+
${l}` : l;
|
|
5573
5646
|
})(), b = (/* @__PURE__ */ new Date()).toISOString();
|
|
5574
5647
|
return {
|
|
5575
5648
|
id: q(),
|
|
@@ -5581,11 +5654,11 @@ ${_}` : _;
|
|
|
5581
5654
|
mentions: m,
|
|
5582
5655
|
timestamp: b
|
|
5583
5656
|
};
|
|
5584
|
-
}, this.toBotMessage = (
|
|
5657
|
+
}, this.toBotMessage = (l) => {
|
|
5585
5658
|
var p;
|
|
5586
|
-
return
|
|
5659
|
+
return l.success && l.autopilotResponse ? {
|
|
5587
5660
|
type: "AI",
|
|
5588
|
-
id:
|
|
5661
|
+
id: l.autopilotResponse.id || q(),
|
|
5589
5662
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5590
5663
|
component: "bot_message",
|
|
5591
5664
|
agent: this.config.bot ? {
|
|
@@ -5597,24 +5670,24 @@ ${_}` : _;
|
|
|
5597
5670
|
id: null
|
|
5598
5671
|
} : void 0,
|
|
5599
5672
|
data: {
|
|
5600
|
-
message:
|
|
5601
|
-
action: (p =
|
|
5602
|
-
name:
|
|
5603
|
-
data:
|
|
5673
|
+
message: l.autopilotResponse.value.content,
|
|
5674
|
+
action: (p = l.uiResponse) != null && p.value.name ? {
|
|
5675
|
+
name: l.uiResponse.value.name,
|
|
5676
|
+
data: l.uiResponse.value.request_response
|
|
5604
5677
|
} : void 0
|
|
5605
5678
|
}
|
|
5606
5679
|
} : null;
|
|
5607
|
-
}, this.toBotErrorMessage = (
|
|
5680
|
+
}, this.toBotErrorMessage = (l) => ({
|
|
5608
5681
|
type: "AI",
|
|
5609
5682
|
id: q(),
|
|
5610
5683
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
5611
5684
|
component: "bot_message",
|
|
5612
5685
|
data: {
|
|
5613
|
-
message:
|
|
5686
|
+
message: l,
|
|
5614
5687
|
variant: "error",
|
|
5615
5688
|
action: void 0
|
|
5616
5689
|
}
|
|
5617
|
-
}), this.config = e, this.getClientCapabilities = a ?? (() => this.getRequestConfig().capabilities), this.api = t, this.sessionCtx = o, this.contactCtx = r, this.isStreaming =
|
|
5690
|
+
}), this.config = e, this.getClientCapabilities = a ?? (() => this.getRequestConfig().capabilities), this.api = t, this.sessionCtx = o, this.contactCtx = r, this.isStreaming = c ?? (() => _), this.getRequestConfig = n ?? (() => this.config), this.getSendsPageContext = d ?? (() => s);
|
|
5618
5691
|
}
|
|
5619
5692
|
/**
|
|
5620
5693
|
* Current transport choice. The org or this embed may request polling
|
|
@@ -5652,14 +5725,14 @@ ${_}` : _;
|
|
|
5652
5725
|
if (!Array.isArray(t)) return;
|
|
5653
5726
|
const o = t.flatMap((r) => {
|
|
5654
5727
|
if (typeof r != "object" || r === null) return [];
|
|
5655
|
-
const
|
|
5728
|
+
const _ = r.elements, s = Array.isArray(_) ? _[0] : void 0, a = typeof s == "object" && s !== null && "name" in s ? s.name : void 0;
|
|
5656
5729
|
if (typeof a != "string" || a.length === 0) return [];
|
|
5657
|
-
const n = r.note,
|
|
5730
|
+
const n = r.note, c = r.snapshotUrl;
|
|
5658
5731
|
return [
|
|
5659
5732
|
{
|
|
5660
5733
|
name: a,
|
|
5661
5734
|
...typeof n == "string" && n.length > 0 ? { note: n } : {},
|
|
5662
|
-
...typeof
|
|
5735
|
+
...typeof c == "string" && c.length > 0 ? { snapshotUrl: c } : {},
|
|
5663
5736
|
mark: r
|
|
5664
5737
|
}
|
|
5665
5738
|
];
|
|
@@ -5676,7 +5749,7 @@ ${_}` : _;
|
|
|
5676
5749
|
};
|
|
5677
5750
|
x.SENT_TEXT_HISTORY_MAX = 50;
|
|
5678
5751
|
let D = x;
|
|
5679
|
-
class
|
|
5752
|
+
class Oa {
|
|
5680
5753
|
constructor(e) {
|
|
5681
5754
|
var t, o;
|
|
5682
5755
|
this.widget = e, this.subscriptions = [], this.disposed = !1, this.restorableSessionId = null, this.didReadStoredSession = !1, this.readStoredSession = () => {
|
|
@@ -5692,9 +5765,9 @@ class Na {
|
|
|
5692
5765
|
}, this.registerRoutingListener = () => {
|
|
5693
5766
|
this.subscriptions.push(
|
|
5694
5767
|
this.contactCtx.state.subscribe(({ contact: r }) => {
|
|
5695
|
-
var
|
|
5768
|
+
var _;
|
|
5696
5769
|
r != null && r.token && this.state.get().screen === "welcome" && this.state.setPartial({
|
|
5697
|
-
screen: (
|
|
5770
|
+
screen: (_ = this.config.router) != null && _.chatScreenOnly ? "chat" : "sessions"
|
|
5698
5771
|
});
|
|
5699
5772
|
})
|
|
5700
5773
|
), this.subscriptions.push(
|
|
@@ -5702,16 +5775,16 @@ class Na {
|
|
|
5702
5775
|
);
|
|
5703
5776
|
}, this.routeFromSessions = ({
|
|
5704
5777
|
isInitialFetchLoading: r,
|
|
5705
|
-
data:
|
|
5778
|
+
data: _
|
|
5706
5779
|
}) => {
|
|
5707
|
-
var s, a, n,
|
|
5780
|
+
var s, a, n, c, d;
|
|
5708
5781
|
if (!(this.disposed || !this.didReadStoredSession)) {
|
|
5709
5782
|
if (this.restorableSessionId && !((s = this.sessionCtx.sessionState.get().session) != null && s.id)) {
|
|
5710
|
-
const
|
|
5783
|
+
const l = _.find(
|
|
5711
5784
|
(p) => p.id === this.restorableSessionId && p.isOpened
|
|
5712
5785
|
);
|
|
5713
|
-
if (
|
|
5714
|
-
this.restorableSessionId = null, this.toChatScreen(
|
|
5786
|
+
if (l) {
|
|
5787
|
+
this.restorableSessionId = null, this.toChatScreen(l.id);
|
|
5715
5788
|
return;
|
|
5716
5789
|
}
|
|
5717
5790
|
if (r) return;
|
|
@@ -5720,10 +5793,10 @@ class Na {
|
|
|
5720
5793
|
if ((a = this.config.router) != null && a.chatScreenOnly && // Do not route to a chat if we are currently inside one already
|
|
5721
5794
|
// This also applies to newly created sessions; the new session will be in `sessionState` before it is refreshed and included in `sessionsState`
|
|
5722
5795
|
!((n = this.sessionCtx.sessionState.get().session) != null && n.id)) {
|
|
5723
|
-
const
|
|
5724
|
-
return
|
|
5796
|
+
const l = (c = _.find((p) => p.isOpened)) == null ? void 0 : c.id;
|
|
5797
|
+
return l ? this.toChatScreen(l) : void 0;
|
|
5725
5798
|
}
|
|
5726
|
-
|
|
5799
|
+
_.length || ((d = this.config.router) == null ? void 0 : d.goToChatIfNoSessions) !== !1 && !r && this.state.get().screen !== "chat" && this.toChatScreen();
|
|
5727
5800
|
}
|
|
5728
5801
|
}, this.dispose = () => {
|
|
5729
5802
|
this.disposed = !0, this.subscriptions.forEach((r) => r()), this.subscriptions = [], this.navigateConversation = void 0;
|
|
@@ -5733,18 +5806,18 @@ class Na {
|
|
|
5733
5806
|
var s, a;
|
|
5734
5807
|
if (this.navigateConversation) return this.navigateConversation(r);
|
|
5735
5808
|
this.resetChat();
|
|
5736
|
-
let
|
|
5809
|
+
let _;
|
|
5737
5810
|
if (r) {
|
|
5738
|
-
if (
|
|
5739
|
-
this.sessionCtx.sessionState.setPartial({ session:
|
|
5811
|
+
if (_ = this.sessionCtx.sessionsState.get().data.find((n) => n.id === r), !_) return;
|
|
5812
|
+
this.sessionCtx.sessionState.setPartial({ session: _ });
|
|
5740
5813
|
}
|
|
5741
|
-
return this.state.setPartial({ screen: "chat" }), (a = (s = this.config.hooks) == null ? void 0 : s.onNavigateToChat) == null || a.call(s, { session:
|
|
5814
|
+
return this.state.setPartial({ screen: "chat" }), (a = (s = this.config.hooks) == null ? void 0 : s.onNavigateToChat) == null || a.call(s, { session: _ }), this.widget;
|
|
5742
5815
|
}, this.config = e.config, this.contactCtx = e.contactCtx, this.sessionCtx = e.sessionCtx, this.resetChat = e.resetChat, this.state = new S({
|
|
5743
5816
|
screen: this.contactCtx.shouldCollectData() ? "welcome" : (t = this.config.router) != null && t.chatScreenOnly ? "chat" : "sessions"
|
|
5744
5817
|
}), this.shouldRestoreLastSession = ((o = this.config.router) == null ? void 0 : o.restoreLastSession) ?? !1, this.readStoredSession(), this.registerRoutingListener();
|
|
5745
5818
|
}
|
|
5746
5819
|
}
|
|
5747
|
-
class
|
|
5820
|
+
class Fa {
|
|
5748
5821
|
constructor({
|
|
5749
5822
|
storage: e,
|
|
5750
5823
|
config: t
|
|
@@ -5767,8 +5840,8 @@ class Ra {
|
|
|
5767
5840
|
}, this.getExternalContactId = async () => this.storage.get(this.KEYS.externalContactId(this.config.token)), this.companionKey = (o) => this.KEYS.companionPreference(this.config.token, o), this.getFiniteNumber = async (o) => {
|
|
5768
5841
|
const r = await this.storage.get(o);
|
|
5769
5842
|
if (r === null) return null;
|
|
5770
|
-
const
|
|
5771
|
-
return Number.isFinite(
|
|
5843
|
+
const _ = Number(r);
|
|
5844
|
+
return Number.isFinite(_) ? _ : null;
|
|
5772
5845
|
}, this.getCompanionPillOffsetX = async () => this.getFiniteNumber(this.companionKey("pill-offset-x")), this.setCompanionPillOffsetX = async (o) => {
|
|
5773
5846
|
Number.isFinite(o) && await this.storage.set(this.companionKey("pill-offset-x"), String(o));
|
|
5774
5847
|
}, this.getCompanionSidebarWidth = async () => this.getFiniteNumber(this.companionKey("sidebar-width")), this.setCompanionSidebarWidth = async (o) => {
|
|
@@ -5791,7 +5864,7 @@ class Ra {
|
|
|
5791
5864
|
}, this.storage = e, this.config = t;
|
|
5792
5865
|
}
|
|
5793
5866
|
}
|
|
5794
|
-
function
|
|
5867
|
+
function Ua({
|
|
5795
5868
|
org: i,
|
|
5796
5869
|
agent: e
|
|
5797
5870
|
}) {
|
|
@@ -5820,20 +5893,23 @@ function Ka({
|
|
|
5820
5893
|
}
|
|
5821
5894
|
};
|
|
5822
5895
|
}
|
|
5823
|
-
function
|
|
5896
|
+
function G(i, e) {
|
|
5824
5897
|
return i && e !== !1;
|
|
5825
5898
|
}
|
|
5826
|
-
function
|
|
5899
|
+
function Ba(i, e) {
|
|
5827
5900
|
const t = e.features;
|
|
5828
5901
|
return {
|
|
5829
|
-
dictation:
|
|
5830
|
-
attachments:
|
|
5902
|
+
dictation: G(i.features.dictation, t == null ? void 0 : t.dictation),
|
|
5903
|
+
attachments: G(
|
|
5904
|
+
i.features.attachments,
|
|
5905
|
+
t == null ? void 0 : t.attachments
|
|
5906
|
+
),
|
|
5831
5907
|
pageContext: i.features.pageContext && (t == null ? void 0 : t.pageContext) === !0,
|
|
5832
5908
|
clientTools: i.features.clientTools && i.features.pageContext && (t == null ? void 0 : t.pageContext) === !0 && (t == null ? void 0 : t.clientTools) === !0,
|
|
5833
5909
|
pageActions: i.features.pageActions && i.features.clientTools && i.features.pageContext && (t == null ? void 0 : t.pageContext) === !0 && (t == null ? void 0 : t.clientTools) === !0 && (t == null ? void 0 : t.pageActions) === !0
|
|
5834
5910
|
};
|
|
5835
5911
|
}
|
|
5836
|
-
class
|
|
5912
|
+
class Va extends Error {
|
|
5837
5913
|
constructor(e, t, o) {
|
|
5838
5914
|
super(t), this.name = "WidgetInitializationError", this.code = e, this.details = o;
|
|
5839
5915
|
}
|
|
@@ -5844,13 +5920,13 @@ const j = class j {
|
|
|
5844
5920
|
storage: t,
|
|
5845
5921
|
getClientCapabilities: o,
|
|
5846
5922
|
getRequestConfig: r,
|
|
5847
|
-
modes:
|
|
5923
|
+
modes: _,
|
|
5848
5924
|
org: s,
|
|
5849
5925
|
agent: a,
|
|
5850
5926
|
parent: n
|
|
5851
5927
|
}) {
|
|
5852
5928
|
if (this.modes = [], this.disposed = !1, this.createConversation = () => {
|
|
5853
|
-
const
|
|
5929
|
+
const c = new j({
|
|
5854
5930
|
config: {
|
|
5855
5931
|
...this.config,
|
|
5856
5932
|
router: {
|
|
@@ -5867,25 +5943,25 @@ const j = class j {
|
|
|
5867
5943
|
getRequestConfig: this.getRequestConfig,
|
|
5868
5944
|
getClientCapabilities: this.getClientCapabilities
|
|
5869
5945
|
});
|
|
5870
|
-
return
|
|
5946
|
+
return c.routerCtx.state.setPartial({
|
|
5871
5947
|
screen: this.contactCtx.shouldCollectData() ? "welcome" : "chat"
|
|
5872
|
-
}),
|
|
5873
|
-
}, this.releaseConversation = () => this.dispose(), this.dispose = ({ clearActiveSession:
|
|
5948
|
+
}), c;
|
|
5949
|
+
}, this.releaseConversation = () => this.dispose(), this.dispose = ({ clearActiveSession: c = !1 } = {}) => {
|
|
5874
5950
|
if (this.disposed) return;
|
|
5875
|
-
this.disposed = !0, this.routerCtx.dispose(), this.activeSessionPollingCtx.dispose();
|
|
5876
|
-
const d = this.sessionCtx.dispose({ clearActiveSession:
|
|
5951
|
+
this.disposed = !0, this.routerCtx.dispose(), this.activeSessionPollingCtx.dispose(), this.ownsUnreadCtx && this.unreadCtx.dispose();
|
|
5952
|
+
const d = this.sessionCtx.dispose({ clearActiveSession: c });
|
|
5877
5953
|
return this.messageCtx.reset(), this.uploadCtx.reset(), this.dictationCtx.stop({ executeFinalCommand: !1 }), d;
|
|
5878
5954
|
}, this.resetChat = () => {
|
|
5879
5955
|
this.sessionCtx.reset(), this.messageCtx.reset(), this.uploadCtx.reset();
|
|
5880
|
-
}, this.reconcileAfterStream = (
|
|
5956
|
+
}, this.reconcileAfterStream = (c) => this.activeSessionPollingCtx.reconcileAfterStream(c), !j.pollingIntervalsSeconds)
|
|
5881
5957
|
throw Error(
|
|
5882
5958
|
"Widget polling values are not defined, did you call WidgetCtx.initialize()"
|
|
5883
5959
|
);
|
|
5884
|
-
this.config = e, this.getRequestConfig = r ?? (() => this.config), this.getClientCapabilities = o, this.org = s, this.agent = a, this.api = (n == null ? void 0 : n.api) ?? new U({ config: e }), this.storageCtx = (n == null ? void 0 : n.storageCtx) ?? (t ? new
|
|
5960
|
+
this.config = e, this.getRequestConfig = r ?? (() => this.config), this.getClientCapabilities = o, this.org = s, this.agent = a, this.api = (n == null ? void 0 : n.api) ?? new U({ config: e }), this.storageCtx = (n == null ? void 0 : n.storageCtx) ?? (t ? new Fa({ storage: t, config: e }) : void 0), this.modes = _, this.contactCtx = (n == null ? void 0 : n.contactCtx) ?? new ve({
|
|
5885
5961
|
api: this.api,
|
|
5886
5962
|
config: this.config,
|
|
5887
5963
|
storageCtx: this.storageCtx
|
|
5888
|
-
}), this.sessionCtx = new
|
|
5964
|
+
}), this.sessionCtx = new Ia({
|
|
5889
5965
|
config: this.config,
|
|
5890
5966
|
api: this.api,
|
|
5891
5967
|
contactCtx: this.contactCtx,
|
|
@@ -5893,6 +5969,11 @@ const j = class j {
|
|
|
5893
5969
|
storageCtx: n ? void 0 : this.storageCtx,
|
|
5894
5970
|
sharedSessions: n == null ? void 0 : n.sessionCtx.sessionsState,
|
|
5895
5971
|
sessionsPollingIntervalSeconds: j.pollingIntervalsSeconds.sessions
|
|
5972
|
+
}), this.ownsUnreadCtx = !n, this.unreadCtx = (n == null ? void 0 : n.unreadCtx) ?? new ie({
|
|
5973
|
+
config: this.config,
|
|
5974
|
+
api: this.api,
|
|
5975
|
+
sessionsState: this.sessionCtx.sessionsState,
|
|
5976
|
+
setSessions: this.sessionCtx.setSessions
|
|
5896
5977
|
}), this.messageCtx = new D({
|
|
5897
5978
|
config: this.config,
|
|
5898
5979
|
api: this.api,
|
|
@@ -5906,20 +5987,20 @@ const j = class j {
|
|
|
5906
5987
|
getSendsPageContext: () => this.features.pageContext,
|
|
5907
5988
|
getClientCapabilities: o,
|
|
5908
5989
|
getRequestConfig: r
|
|
5909
|
-
}), this.uploadCtx = new
|
|
5990
|
+
}), this.uploadCtx = new fe(this.api), this.csatCtx = new ye({
|
|
5910
5991
|
api: this.api,
|
|
5911
5992
|
sessionCtx: this.sessionCtx,
|
|
5912
5993
|
messageCtx: this.messageCtx
|
|
5913
|
-
}), this.dictationCtx = new
|
|
5994
|
+
}), this.dictationCtx = new Be({
|
|
5914
5995
|
api: this.api,
|
|
5915
5996
|
config: this.config
|
|
5916
|
-
}), this.activeSessionPollingCtx = new
|
|
5997
|
+
}), this.activeSessionPollingCtx = new be({
|
|
5917
5998
|
api: this.api,
|
|
5918
5999
|
config: this.config,
|
|
5919
6000
|
sessionCtx: this.sessionCtx,
|
|
5920
6001
|
messageCtx: this.messageCtx,
|
|
5921
6002
|
sessionPollingIntervalSeconds: j.pollingIntervalsSeconds.session
|
|
5922
|
-
}), this.routerCtx = new
|
|
6003
|
+
}), this.routerCtx = new Oa(this);
|
|
5923
6004
|
}
|
|
5924
6005
|
get streaming() {
|
|
5925
6006
|
var e, t;
|
|
@@ -5930,7 +6011,7 @@ const j = class j {
|
|
|
5930
6011
|
* answers the UI asks for, resolved against the current options.
|
|
5931
6012
|
*/
|
|
5932
6013
|
get features() {
|
|
5933
|
-
return
|
|
6014
|
+
return Ba(this.agent, this.getRequestConfig());
|
|
5934
6015
|
}
|
|
5935
6016
|
};
|
|
5936
6017
|
j.pollingIntervalsSeconds = null, j.initialize = async ({
|
|
@@ -5940,40 +6021,40 @@ j.pollingIntervalsSeconds = null, j.initialize = async ({
|
|
|
5940
6021
|
getRequestConfig: r
|
|
5941
6022
|
}) => {
|
|
5942
6023
|
var s, a;
|
|
5943
|
-
const
|
|
6024
|
+
const _ = await new U({
|
|
5944
6025
|
config: e
|
|
5945
6026
|
}).getExternalWidgetConfig();
|
|
5946
|
-
if (!
|
|
5947
|
-
throw k.error("widget config fetch failed",
|
|
6027
|
+
if (!_.data)
|
|
6028
|
+
throw k.error("widget config fetch failed", _.error), new Va(
|
|
5948
6029
|
"config-fetch-failed",
|
|
5949
6030
|
"Failed to fetch widget config",
|
|
5950
|
-
|
|
6031
|
+
_.error
|
|
5951
6032
|
);
|
|
5952
6033
|
return j.pollingIntervalsSeconds = {
|
|
5953
|
-
session: ((s =
|
|
5954
|
-
sessions: ((a =
|
|
6034
|
+
session: ((s = _.data) == null ? void 0 : s.sessionPollingIntervalSeconds) || 10,
|
|
6035
|
+
sessions: ((a = _.data) == null ? void 0 : a.sessionsPollingIntervalSeconds) || 60
|
|
5955
6036
|
}, new j({
|
|
5956
6037
|
config: e,
|
|
5957
6038
|
storage: t,
|
|
5958
6039
|
getClientCapabilities: o,
|
|
5959
6040
|
getRequestConfig: r,
|
|
5960
|
-
modes:
|
|
6041
|
+
modes: _.data.modes || [],
|
|
5961
6042
|
org: {
|
|
5962
|
-
id:
|
|
5963
|
-
name:
|
|
6043
|
+
id: _.data.org.id,
|
|
6044
|
+
name: _.data.org.name
|
|
5964
6045
|
},
|
|
5965
|
-
agent:
|
|
6046
|
+
agent: Ua(_.data)
|
|
5966
6047
|
});
|
|
5967
6048
|
};
|
|
5968
|
-
let
|
|
5969
|
-
function
|
|
6049
|
+
let Z = j;
|
|
6050
|
+
function et(i, e) {
|
|
5970
6051
|
return i ? {
|
|
5971
6052
|
streaming: i.streaming && (e == null ? void 0 : e.streaming) !== !1,
|
|
5972
6053
|
toolActivity: i.toolActivity === "hidden" || (e == null ? void 0 : e.toolActivity) === "hidden" ? "hidden" : i.toolActivity === "status" || (e == null ? void 0 : e.toolActivity) === "status" ? "status" : "details",
|
|
5973
6054
|
reasoning: i.reasoning && (e == null ? void 0 : e.reasoning) !== !1
|
|
5974
6055
|
} : e;
|
|
5975
6056
|
}
|
|
5976
|
-
class
|
|
6057
|
+
class at {
|
|
5977
6058
|
constructor({ attack: e, release: t }) {
|
|
5978
6059
|
this.value = 0, this.attack = e, this.release = t;
|
|
5979
6060
|
}
|
|
@@ -5988,52 +6069,53 @@ const I = [
|
|
|
5988
6069
|
"compact",
|
|
5989
6070
|
"sidebar",
|
|
5990
6071
|
"fullscreen"
|
|
5991
|
-
],
|
|
6072
|
+
], Ha = new Set(
|
|
5992
6073
|
I
|
|
5993
6074
|
);
|
|
5994
|
-
function
|
|
5995
|
-
return
|
|
6075
|
+
function X(i) {
|
|
6076
|
+
return Ha.has(i);
|
|
5996
6077
|
}
|
|
5997
|
-
function
|
|
6078
|
+
function tt(i) {
|
|
5998
6079
|
if (!Array.isArray(i)) return I;
|
|
5999
6080
|
const e = [], t = /* @__PURE__ */ new Set();
|
|
6000
6081
|
for (const o of i)
|
|
6001
|
-
!
|
|
6082
|
+
!X(o) || t.has(o) || (t.add(o), e.push(o));
|
|
6002
6083
|
return e.length > 0 ? e : I;
|
|
6003
6084
|
}
|
|
6004
|
-
function
|
|
6005
|
-
return
|
|
6085
|
+
function st(i, e) {
|
|
6086
|
+
return X(i) && e.includes(i) ? i : e[0] ?? I[0];
|
|
6006
6087
|
}
|
|
6007
|
-
function
|
|
6088
|
+
function ot(i, e) {
|
|
6008
6089
|
return i === "left" || i === "right" ? i : e === "rtl" ? "left" : "right";
|
|
6009
6090
|
}
|
|
6010
|
-
function
|
|
6091
|
+
function nt(i) {
|
|
6011
6092
|
return i === "docked" ? "docked" : "floating";
|
|
6012
6093
|
}
|
|
6013
6094
|
export {
|
|
6014
|
-
|
|
6015
|
-
|
|
6016
|
-
|
|
6095
|
+
me as ConnectionAttemptUnavailableError,
|
|
6096
|
+
ue as ConnectionRequestExpiredError,
|
|
6097
|
+
at as DictationLevelSmoother,
|
|
6017
6098
|
S as PrimitiveState,
|
|
6018
|
-
|
|
6019
|
-
|
|
6020
|
-
|
|
6099
|
+
ie as UnreadCtx,
|
|
6100
|
+
Z as WidgetCtx,
|
|
6101
|
+
Va as WidgetInitializationError,
|
|
6102
|
+
La as buildSendMessageBody,
|
|
6021
6103
|
q as genUuid,
|
|
6022
|
-
|
|
6023
|
-
|
|
6024
|
-
|
|
6104
|
+
Pa as getTranslation,
|
|
6105
|
+
Ya as isAgentStreamKeepalive,
|
|
6106
|
+
ke as isExhaustive,
|
|
6025
6107
|
H as isRecord,
|
|
6026
|
-
|
|
6027
|
-
|
|
6028
|
-
|
|
6108
|
+
Qa as isRtlLanguage,
|
|
6109
|
+
qa as isSupportedLanguage,
|
|
6110
|
+
Xa as isTurnSteeredPart,
|
|
6029
6111
|
k as log,
|
|
6030
|
-
|
|
6031
|
-
|
|
6032
|
-
|
|
6033
|
-
|
|
6034
|
-
|
|
6035
|
-
|
|
6036
|
-
|
|
6037
|
-
|
|
6112
|
+
tt as normalizeCompanionLayouts,
|
|
6113
|
+
et as resolveClientPresentation,
|
|
6114
|
+
st as resolveCompanionDefaultLayout,
|
|
6115
|
+
Na as resolveConfigContext,
|
|
6116
|
+
Aa as resolveLanguage,
|
|
6117
|
+
nt as resolveSidebarMode,
|
|
6118
|
+
ot as resolveSidebarSide,
|
|
6119
|
+
Ta as translate
|
|
6038
6120
|
};
|
|
6039
6121
|
//# sourceMappingURL=index.js.map
|