@opencx/widget 3.0.83 → 3.0.85
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/designs.cjs +21 -21
- package/dist/designs.cjs.map +1 -1
- package/dist/designs.js +3051 -3118
- package/dist/designs.js.map +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.js +1 -1
- package/dist/react.cjs +1 -1
- package/dist/react.js +2 -2
- package/dist/src/designs/react/components/lib/MotionDiv.d.ts +1 -0
- package/dist/src/designs/translation/translation.types.d.ts +1 -1
- package/dist/src/headless/core/context/router.ctx.d.ts +6 -5
- package/dist/src/headless/core/index.d.ts +1 -1
- package/dist/src/headless/core/types/widget-config.d.ts +18 -1
- package/dist/src/headless/react/hooks/useSessions.d.ts +31 -0
- package/dist/src/headless/react/hooks/useWidgetRouter.d.ts +1 -1
- package/dist/{useWidgetTrigger-ClIdKwZT.cjs → useWidgetTrigger-Be2RN31V.cjs} +4 -4
- package/dist/useWidgetTrigger-Be2RN31V.cjs.map +1 -0
- package/dist/{useWidgetTrigger-CiXxBOLI.js → useWidgetTrigger-D94qDfz7.js} +354 -348
- package/dist/useWidgetTrigger-D94qDfz7.js.map +1 -0
- package/dist/{widget.ctx-r2Nzp00O.js → widget.ctx-0z1bMkkT.js} +246 -236
- package/dist/{widget.ctx-r2Nzp00O.js.map → widget.ctx-0z1bMkkT.js.map} +1 -1
- package/dist/widget.ctx-BOpwwK5L.cjs +5 -0
- package/dist/{widget.ctx-CoJrM0OY.cjs.map → widget.ctx-BOpwwK5L.cjs.map} +1 -1
- package/dist-embed/script.js +82 -102
- package/dist-embed/script.js.map +1 -1
- package/package.json +1 -1
- package/dist/useWidgetTrigger-CiXxBOLI.js.map +0 -1
- package/dist/useWidgetTrigger-ClIdKwZT.cjs.map +0 -1
- package/dist/widget.ctx-CoJrM0OY.cjs +0 -5
|
@@ -6,45 +6,45 @@ const F = (d) => {
|
|
|
6
6
|
}, _ = (d) => {
|
|
7
7
|
const n = M({
|
|
8
8
|
baseUrl: d.baseUrl
|
|
9
|
-
}),
|
|
9
|
+
}), a = {
|
|
10
10
|
onRequest: d.onRequest,
|
|
11
11
|
onResponse: d.onResponse,
|
|
12
12
|
onError: d.onError || F
|
|
13
13
|
};
|
|
14
|
-
return n.use(
|
|
14
|
+
return n.use(a), n;
|
|
15
15
|
};
|
|
16
16
|
class T {
|
|
17
17
|
constructor({ config: n }) {
|
|
18
|
-
var
|
|
18
|
+
var o, e;
|
|
19
19
|
this.userToken = null, this.constructClientOptions = (t) => {
|
|
20
|
-
const
|
|
20
|
+
const s = this.config.apiUrl || "https://api.open.cx", i = {
|
|
21
21
|
"X-Bot-Token": this.config.token,
|
|
22
22
|
"Content-Type": "application/json",
|
|
23
23
|
Accept: "application/json",
|
|
24
24
|
Authorization: t ? `Bearer ${t}` : void 0
|
|
25
25
|
};
|
|
26
|
-
return { baseUrl:
|
|
26
|
+
return { baseUrl: s, headers: i };
|
|
27
27
|
}, this.createOpenAPIClient = ({
|
|
28
28
|
baseUrl: t,
|
|
29
|
-
headers:
|
|
29
|
+
headers: s
|
|
30
30
|
}) => _({
|
|
31
31
|
baseUrl: t,
|
|
32
|
-
onRequest: ({ request:
|
|
33
|
-
Object.entries(
|
|
34
|
-
r &&
|
|
32
|
+
onRequest: ({ request: i }) => {
|
|
33
|
+
Object.entries(s).forEach(([c, r]) => {
|
|
34
|
+
r && i.headers.set(c, r);
|
|
35
35
|
});
|
|
36
36
|
}
|
|
37
37
|
}), this.setAuthToken = (t) => {
|
|
38
38
|
this.userToken = t;
|
|
39
|
-
const { baseUrl:
|
|
40
|
-
this.client = this.createOpenAPIClient({ baseUrl:
|
|
39
|
+
const { baseUrl: s, headers: i } = this.constructClientOptions(t);
|
|
40
|
+
this.client = this.createOpenAPIClient({ baseUrl: s, headers: i });
|
|
41
41
|
}, this.getExternalWidgetConfig = async () => await this.client.GET("/backend/widget/v2/config", {
|
|
42
42
|
params: { header: { "X-Bot-Token": this.config.token } }
|
|
43
43
|
}), this.widgetPrelude = async () => await this.client.GET("/backend/widget/v2/prelude", {
|
|
44
44
|
params: { header: { "X-Bot-Token": this.config.token } }
|
|
45
|
-
}), this.sendMessage = async (t,
|
|
45
|
+
}), this.sendMessage = async (t, s) => await this.client.POST("/backend/widget/v2/chat/send", {
|
|
46
46
|
body: t,
|
|
47
|
-
signal:
|
|
47
|
+
signal: s
|
|
48
48
|
}), this.createUnverifiedContact = async (t) => await this.client.POST(
|
|
49
49
|
"/backend/widget/v2/contact/create-unverified",
|
|
50
50
|
{
|
|
@@ -55,88 +55,88 @@ class T {
|
|
|
55
55
|
body: t
|
|
56
56
|
}), this.pollSessionAndHistory = async ({
|
|
57
57
|
sessionId: t,
|
|
58
|
-
lastMessageTimestamp:
|
|
59
|
-
abortSignal:
|
|
58
|
+
lastMessageTimestamp: s,
|
|
59
|
+
abortSignal: i
|
|
60
60
|
}) => {
|
|
61
|
-
const
|
|
61
|
+
const c = s ? { lastMessageTimestamp: s } : void 0;
|
|
62
62
|
return await this.client.GET("/backend/widget/v2/poll/{sessionId}", {
|
|
63
|
-
params: { path: { sessionId: t }, query:
|
|
64
|
-
signal:
|
|
63
|
+
params: { path: { sessionId: t }, query: c },
|
|
64
|
+
signal: i
|
|
65
65
|
});
|
|
66
66
|
}, this.getSessions = async ({
|
|
67
67
|
cursor: t,
|
|
68
|
-
filters:
|
|
69
|
-
abortSignal:
|
|
68
|
+
filters: s,
|
|
69
|
+
abortSignal: i
|
|
70
70
|
}) => await this.client.GET("/backend/widget/v2/sessions", {
|
|
71
|
-
params: { query: { cursor: t, filters: JSON.stringify(
|
|
72
|
-
signal:
|
|
71
|
+
params: { query: { cursor: t, filters: JSON.stringify(s) } },
|
|
72
|
+
signal: i
|
|
73
73
|
}), this.uploadFile = async ({
|
|
74
74
|
file: t,
|
|
75
|
-
abortSignal:
|
|
76
|
-
onProgress:
|
|
77
|
-
}) => new Promise((
|
|
75
|
+
abortSignal: s,
|
|
76
|
+
onProgress: i
|
|
77
|
+
}) => new Promise((c, r) => {
|
|
78
78
|
var v;
|
|
79
|
-
const
|
|
80
|
-
|
|
81
|
-
const
|
|
82
|
-
if (
|
|
83
|
-
|
|
84
|
-
}),
|
|
79
|
+
const h = new FormData();
|
|
80
|
+
h.append("file", t);
|
|
81
|
+
const l = new XMLHttpRequest();
|
|
82
|
+
if (s && (s.addEventListener("abort", () => {
|
|
83
|
+
l.abort(), r(new DOMException("Aborted", "AbortError"));
|
|
84
|
+
}), s.aborted)) {
|
|
85
85
|
r(new DOMException("Aborted", "AbortError"));
|
|
86
86
|
return;
|
|
87
87
|
}
|
|
88
|
-
|
|
89
|
-
if (u.lengthComputable &&
|
|
90
|
-
const
|
|
91
|
-
|
|
88
|
+
l.upload.addEventListener("progress", (u) => {
|
|
89
|
+
if (u.lengthComputable && i) {
|
|
90
|
+
const S = Math.round(u.loaded / u.total * 100);
|
|
91
|
+
i(S);
|
|
92
92
|
}
|
|
93
|
-
}),
|
|
94
|
-
if (
|
|
93
|
+
}), l.addEventListener("load", () => {
|
|
94
|
+
if (l.status >= 200 && l.status < 300)
|
|
95
95
|
try {
|
|
96
|
-
const u = JSON.parse(
|
|
97
|
-
|
|
96
|
+
const u = JSON.parse(l.responseText);
|
|
97
|
+
c(u);
|
|
98
98
|
} catch (u) {
|
|
99
99
|
r(new Error(`Failed to parse response: ${u}`));
|
|
100
100
|
}
|
|
101
101
|
else
|
|
102
|
-
r(new Error(`Upload failed with status: ${
|
|
103
|
-
}),
|
|
102
|
+
r(new Error(`Upload failed with status: ${l.status}`));
|
|
103
|
+
}), l.addEventListener("error", () => {
|
|
104
104
|
r(new Error("Network error occurred"));
|
|
105
|
-
}),
|
|
105
|
+
}), l.addEventListener("timeout", () => {
|
|
106
106
|
r(new Error("Upload timed out"));
|
|
107
107
|
});
|
|
108
|
-
const { baseUrl:
|
|
109
|
-
|
|
110
|
-
}), this.vote = async (t) => await this.client.POST("/backend/widget/v2/chat/vote", { body: t }), this.resolveSession = async (t,
|
|
108
|
+
const { baseUrl: f } = this.constructClientOptions(this.userToken), p = `${f}/backend/widget/v2/upload`;
|
|
109
|
+
l.open("POST", p), l.setRequestHeader("X-Bot-Token", this.config.token), this.userToken ?? ((v = this.config.user) == null ? void 0 : v.token) ? l.setRequestHeader("Authorization", `Bearer ${this.userToken}`) : console.error("User token not set"), l.send(h);
|
|
110
|
+
}), this.vote = async (t) => await this.client.POST("/backend/widget/v2/chat/vote", { body: t }), this.resolveSession = async (t, s) => await this.client.POST("/backend/widget/v2/session/resolve", {
|
|
111
111
|
body: t,
|
|
112
|
-
signal:
|
|
113
|
-
}), this.config = n, this.userToken = ((
|
|
114
|
-
const { baseUrl:
|
|
115
|
-
(
|
|
112
|
+
signal: s
|
|
113
|
+
}), this.config = n, this.userToken = ((o = n.user) == null ? void 0 : o.token) || null;
|
|
114
|
+
const { baseUrl: a, headers: g } = this.constructClientOptions(
|
|
115
|
+
(e = n.user) == null ? void 0 : e.token
|
|
116
116
|
);
|
|
117
|
-
this.client = this.createOpenAPIClient({ baseUrl:
|
|
117
|
+
this.client = this.createOpenAPIClient({ baseUrl: a, headers: g });
|
|
118
118
|
}
|
|
119
119
|
}
|
|
120
120
|
class P {
|
|
121
121
|
constructor(n) {
|
|
122
|
-
this.subscribers = /* @__PURE__ */ new Set(), this.get = () => this.state, this.set = (
|
|
123
|
-
O(this.state,
|
|
124
|
-
}, this.setPartial = (
|
|
125
|
-
if (
|
|
126
|
-
const
|
|
127
|
-
this.set(
|
|
122
|
+
this.subscribers = /* @__PURE__ */ new Set(), this.get = () => this.state, this.set = (a) => {
|
|
123
|
+
O(this.state, a) || (this.state = a, this.notifySubscribers(a));
|
|
124
|
+
}, this.setPartial = (a) => {
|
|
125
|
+
if (a == null) return;
|
|
126
|
+
const g = { ...this.state, ...a };
|
|
127
|
+
this.set(g);
|
|
128
128
|
}, this.reset = () => {
|
|
129
129
|
this.set(this.initialState);
|
|
130
|
-
}, this.notifySubscribers = (
|
|
131
|
-
Array.from(this.subscribers).forEach((
|
|
130
|
+
}, this.notifySubscribers = (a) => {
|
|
131
|
+
Array.from(this.subscribers).forEach((o) => {
|
|
132
132
|
try {
|
|
133
|
-
a
|
|
134
|
-
} catch (
|
|
135
|
-
console.error(
|
|
133
|
+
o(a);
|
|
134
|
+
} catch (e) {
|
|
135
|
+
console.error(e);
|
|
136
136
|
}
|
|
137
137
|
});
|
|
138
|
-
}, this.subscribe = (
|
|
139
|
-
this.subscribers.delete(
|
|
138
|
+
}, this.subscribe = (a) => (this.subscribers.add(a), () => {
|
|
139
|
+
this.subscribers.delete(a);
|
|
140
140
|
}), this.state = n, this.initialState = n;
|
|
141
141
|
}
|
|
142
142
|
}
|
|
@@ -148,23 +148,23 @@ class A {
|
|
|
148
148
|
}), this.abortController = new AbortController(), this.reset = () => {
|
|
149
149
|
var n;
|
|
150
150
|
this.abortController.abort("Resetting poller"), (n = this.stopPolling) == null || n.call(this), this.stopPolling = null;
|
|
151
|
-
}, this.stopPolling = null, this.startPolling = (n,
|
|
151
|
+
}, this.stopPolling = null, this.startPolling = (n, a) => {
|
|
152
152
|
if (this.stopPolling) return;
|
|
153
|
-
const
|
|
153
|
+
const g = [], o = async () => {
|
|
154
154
|
this.abortController = new AbortController(), this.state.setPartial({ isPolling: !0 });
|
|
155
155
|
try {
|
|
156
156
|
await n(this.abortController.signal);
|
|
157
|
-
} catch (
|
|
157
|
+
} catch (e) {
|
|
158
158
|
if (this.abortController.signal.aborted)
|
|
159
159
|
return;
|
|
160
|
-
console.error("Failed to poll:",
|
|
160
|
+
console.error("Failed to poll:", e), this.state.setPartial({ isError: !0 });
|
|
161
161
|
} finally {
|
|
162
162
|
this.state.setPartial({ isPolling: !1 });
|
|
163
163
|
}
|
|
164
|
-
this.abortController.signal.aborted ? console.log("Poller aborted, not scheduling anymore") :
|
|
164
|
+
this.abortController.signal.aborted ? console.log("Poller aborted, not scheduling anymore") : g.push(setTimeout(o, a));
|
|
165
165
|
};
|
|
166
|
-
|
|
167
|
-
|
|
166
|
+
o(), this.stopPolling = () => {
|
|
167
|
+
g.forEach(clearTimeout), this.state.reset();
|
|
168
168
|
};
|
|
169
169
|
};
|
|
170
170
|
}
|
|
@@ -172,7 +172,7 @@ class A {
|
|
|
172
172
|
function D(d) {
|
|
173
173
|
try {
|
|
174
174
|
const n = d();
|
|
175
|
-
return n instanceof Promise ? n.then((
|
|
175
|
+
return n instanceof Promise ? n.then((a) => ({ data: a })).catch((a) => ({ error: a })) : { data: n };
|
|
176
176
|
} catch (n) {
|
|
177
177
|
return { error: n };
|
|
178
178
|
}
|
|
@@ -180,51 +180,51 @@ function D(d) {
|
|
|
180
180
|
class L {
|
|
181
181
|
constructor({
|
|
182
182
|
api: n,
|
|
183
|
-
config:
|
|
184
|
-
sessionCtx:
|
|
185
|
-
messageCtx:
|
|
186
|
-
sessionPollingIntervalSeconds:
|
|
183
|
+
config: a,
|
|
184
|
+
sessionCtx: g,
|
|
185
|
+
messageCtx: o,
|
|
186
|
+
sessionPollingIntervalSeconds: e
|
|
187
187
|
}) {
|
|
188
188
|
this.poller = new A(), this.registerPolling = () => {
|
|
189
189
|
this.sessionCtx.sessionState.subscribe(({ session: t }) => {
|
|
190
|
-
t != null && t.id ? this.poller.startPolling(async (
|
|
191
|
-
this.hackAndSlash(t.id,
|
|
190
|
+
t != null && t.id ? this.poller.startPolling(async (s) => {
|
|
191
|
+
this.hackAndSlash(t.id, s);
|
|
192
192
|
}, this.sessionPollingIntervalSeconds * 1e3) : this.poller.reset();
|
|
193
193
|
});
|
|
194
|
-
}, this.hackAndSlash = async (t,
|
|
195
|
-
var
|
|
194
|
+
}, this.hackAndSlash = async (t, s) => {
|
|
195
|
+
var h;
|
|
196
196
|
this.messageCtx.state.get().messages.length === 0 && this.messageCtx.state.setPartial({ isInitialFetchLoading: !0 });
|
|
197
|
-
const
|
|
197
|
+
const i = this.messageCtx.state.get().messages, c = i.length > 0 ? (h = i[i.length - 1]) == null ? void 0 : h.timestamp : void 0, { data: r } = await this.api.pollSessionAndHistory({
|
|
198
198
|
sessionId: t,
|
|
199
|
-
abortSignal:
|
|
200
|
-
lastMessageTimestamp:
|
|
199
|
+
abortSignal: s,
|
|
200
|
+
lastMessageTimestamp: c
|
|
201
201
|
});
|
|
202
202
|
if (r != null && r.session && (this.sessionCtx.sessionState.setPartial({ session: r.session }), this.sessionCtx.setSessions([r.session])), r != null && r.history && r.history.length > 0) {
|
|
203
|
-
const
|
|
204
|
-
(x) => !
|
|
203
|
+
const l = this.messageCtx.state.get().messages, f = r.history.map(this.mapHistoryToMessage).filter(
|
|
204
|
+
(x) => !l.some((p) => p.id === x.id)
|
|
205
205
|
);
|
|
206
206
|
this.messageCtx.state.setPartial({
|
|
207
|
-
messages: [...
|
|
207
|
+
messages: [...l, ...f]
|
|
208
208
|
});
|
|
209
209
|
}
|
|
210
210
|
this.messageCtx.state.get().isInitialFetchLoading && this.messageCtx.state.setPartial({ isInitialFetchLoading: !1 });
|
|
211
211
|
}, this.mapHistoryToMessage = (t) => {
|
|
212
|
-
var
|
|
213
|
-
const
|
|
212
|
+
var c, r;
|
|
213
|
+
const s = {
|
|
214
214
|
id: t.publicId,
|
|
215
215
|
timestamp: t.sentAt || "",
|
|
216
216
|
attachments: t.attachments || void 0
|
|
217
217
|
};
|
|
218
218
|
if (t.sender.kind === "user")
|
|
219
219
|
return {
|
|
220
|
-
...
|
|
220
|
+
...s,
|
|
221
221
|
type: "FROM_USER",
|
|
222
222
|
content: t.content.text || "",
|
|
223
223
|
deliveredAt: t.sentAt || ""
|
|
224
224
|
};
|
|
225
225
|
if (t.sender.kind === "agent")
|
|
226
226
|
return {
|
|
227
|
-
...
|
|
227
|
+
...s,
|
|
228
228
|
type: "FROM_AGENT",
|
|
229
229
|
component: "agent_message",
|
|
230
230
|
data: {
|
|
@@ -237,87 +237,87 @@ class L {
|
|
|
237
237
|
isAi: !1
|
|
238
238
|
}
|
|
239
239
|
};
|
|
240
|
-
const
|
|
240
|
+
const i = t.actionCalls && t.actionCalls.length > 0 ? t.actionCalls[t.actionCalls.length - 1] : void 0;
|
|
241
241
|
return {
|
|
242
|
-
...
|
|
242
|
+
...s,
|
|
243
243
|
type: "FROM_BOT",
|
|
244
244
|
component: "bot_message",
|
|
245
245
|
agent: {
|
|
246
246
|
id: null,
|
|
247
|
-
name: ((
|
|
247
|
+
name: ((c = this.config.bot) == null ? void 0 : c.name) || "",
|
|
248
248
|
isAi: !0,
|
|
249
249
|
avatar: ((r = this.config.bot) == null ? void 0 : r.avatar) || ""
|
|
250
250
|
},
|
|
251
251
|
data: {
|
|
252
252
|
message: t.content.text || "",
|
|
253
|
-
action:
|
|
254
|
-
name:
|
|
255
|
-
data: this.extractActionResult(
|
|
253
|
+
action: i ? {
|
|
254
|
+
name: i.actionName,
|
|
255
|
+
data: this.extractActionResult(i)
|
|
256
256
|
} : void 0
|
|
257
257
|
}
|
|
258
258
|
};
|
|
259
259
|
}, this.extractActionResult = (t) => {
|
|
260
|
-
const
|
|
261
|
-
if (
|
|
262
|
-
if ("responseBodyText" in
|
|
263
|
-
const
|
|
264
|
-
if (
|
|
260
|
+
const s = t.result;
|
|
261
|
+
if (s === null || typeof s != "object") return s;
|
|
262
|
+
if ("responseBodyText" in s && typeof s.responseBodyText == "string") {
|
|
263
|
+
const i = s.responseBodyText, c = D(() => JSON.parse(i)).data;
|
|
264
|
+
if (c) return c;
|
|
265
265
|
}
|
|
266
266
|
return t.result;
|
|
267
|
-
}, this.api = n, this.config =
|
|
267
|
+
}, this.api = n, this.config = a, this.sessionCtx = g, this.messageCtx = o, this.sessionPollingIntervalSeconds = e, this.registerPolling();
|
|
268
268
|
}
|
|
269
269
|
}
|
|
270
270
|
class B {
|
|
271
271
|
constructor({
|
|
272
272
|
config: n,
|
|
273
|
-
api:
|
|
274
|
-
storageCtx:
|
|
273
|
+
api: a,
|
|
274
|
+
storageCtx: g
|
|
275
275
|
}) {
|
|
276
|
-
var
|
|
276
|
+
var o;
|
|
277
277
|
this.shouldCollectData = () => {
|
|
278
|
-
var
|
|
279
|
-
return !!(!((
|
|
278
|
+
var e;
|
|
279
|
+
return !!(!((e = this.state.get().contact) != null && e.token) && this.config.collectUserData);
|
|
280
280
|
}, this.autoCreateUnverifiedUserIfNotExists = async () => {
|
|
281
|
-
var
|
|
282
|
-
if (!((
|
|
283
|
-
if (this.config.collectUserData && !((
|
|
284
|
-
if ((
|
|
281
|
+
var e, t, s, i, c, r, h, l, f, x, p, b, v, u;
|
|
282
|
+
if (!((e = this.config.user) != null && e.token)) {
|
|
283
|
+
if (this.config.collectUserData && !((s = (t = this.config.user) == null ? void 0 : t.data) != null && s.email)) {
|
|
284
|
+
if ((i = this.config.extraDataCollectionFields) != null && i.length)
|
|
285
285
|
return;
|
|
286
|
-
const
|
|
287
|
-
|
|
286
|
+
const S = await ((c = this.storageCtx) == null ? void 0 : c.getContactToken());
|
|
287
|
+
S && await this.setUnverifiedContact(S);
|
|
288
288
|
return;
|
|
289
289
|
}
|
|
290
|
-
if (!((
|
|
291
|
-
const
|
|
292
|
-
if (
|
|
293
|
-
await this.setUnverifiedContact(
|
|
290
|
+
if (!((h = (r = this.config.user) == null ? void 0 : r.data) != null && h.email)) {
|
|
291
|
+
const S = await ((l = this.storageCtx) == null ? void 0 : l.getContactToken());
|
|
292
|
+
if (S) {
|
|
293
|
+
await this.setUnverifiedContact(S);
|
|
294
294
|
return;
|
|
295
295
|
}
|
|
296
296
|
}
|
|
297
297
|
await this.createUnverifiedContact({
|
|
298
|
-
email: (x = (
|
|
298
|
+
email: (x = (f = this.config.user) == null ? void 0 : f.data) == null ? void 0 : x.email,
|
|
299
299
|
non_verified_name: ((b = (p = this.config.user) == null ? void 0 : p.data) == null ? void 0 : b.name) || "Anonymous",
|
|
300
300
|
non_verified_custom_data: (u = (v = this.config.user) == null ? void 0 : v.data) == null ? void 0 : u.customData
|
|
301
301
|
});
|
|
302
302
|
}
|
|
303
|
-
}, this.createUnverifiedContact = async (
|
|
303
|
+
}, this.createUnverifiedContact = async (e, t) => {
|
|
304
304
|
this.state.setPartial({ extraCollectedData: t });
|
|
305
305
|
try {
|
|
306
306
|
this.state.setPartial({
|
|
307
307
|
isCreatingUnverifiedContact: !0,
|
|
308
308
|
isErrorCreatingUnverifiedContact: !1
|
|
309
309
|
});
|
|
310
|
-
const { data:
|
|
311
|
-
|
|
310
|
+
const { data: s } = await this.api.createUnverifiedContact(e);
|
|
311
|
+
s != null && s.token ? await this.setUnverifiedContact(s.token) : this.state.setPartial({ isErrorCreatingUnverifiedContact: !0 });
|
|
312
312
|
} finally {
|
|
313
313
|
this.state.setPartial({ isCreatingUnverifiedContact: !1 });
|
|
314
314
|
}
|
|
315
|
-
}, this.setUnverifiedContact = async (
|
|
316
|
-
var
|
|
317
|
-
const t = await ((
|
|
318
|
-
this.api.setAuthToken(
|
|
319
|
-
}, this.config = n, this.storageCtx =
|
|
320
|
-
contact: (
|
|
315
|
+
}, this.setUnverifiedContact = async (e) => {
|
|
316
|
+
var i, c, r, h;
|
|
317
|
+
const t = await ((i = this.storageCtx) == null ? void 0 : i.getExternalContactId()), s = ((c = this.config.user) == null ? void 0 : c.externalId) || t || E();
|
|
318
|
+
this.api.setAuthToken(e), await ((r = this.storageCtx) == null ? void 0 : r.setContactToken(e)), await ((h = this.storageCtx) == null ? void 0 : h.setExternalContactId(s)), this.state.setPartial({ contact: { token: e, externalId: s } });
|
|
319
|
+
}, this.config = n, this.storageCtx = g, this.api = a, this.state = new P({
|
|
320
|
+
contact: (o = n.user) != null && o.token ? {
|
|
321
321
|
token: n.user.token,
|
|
322
322
|
// Set optional externalId from config... not local storage
|
|
323
323
|
externalId: n.user.externalId
|
|
@@ -334,8 +334,8 @@ function y() {
|
|
|
334
334
|
class q {
|
|
335
335
|
constructor({
|
|
336
336
|
api: n,
|
|
337
|
-
contactCtx:
|
|
338
|
-
sessionsPollingIntervalSeconds:
|
|
337
|
+
contactCtx: a,
|
|
338
|
+
sessionsPollingIntervalSeconds: g
|
|
339
339
|
}) {
|
|
340
340
|
this.sessionsRefresher = new A(), this.sessionState = new P({
|
|
341
341
|
session: null,
|
|
@@ -352,73 +352,73 @@ class q {
|
|
|
352
352
|
}), this.reset = async () => {
|
|
353
353
|
this.sessionState.reset();
|
|
354
354
|
}, this.registerSessionsRefresherWrapper = () => {
|
|
355
|
-
var
|
|
355
|
+
var o;
|
|
356
356
|
// If the widget config was initially provided with a contact token, no state change would be triggered, so we just fetch
|
|
357
|
-
(
|
|
358
|
-
|
|
357
|
+
(o = this.contactCtx.state.get().contact) != null && o.token && !this.sessionsState.get().didStartInitialFetch ? this.registerSessionsRefresher() : this.contactCtx.state.subscribe(({ contact: e }) => {
|
|
358
|
+
e != null && e.token && !this.sessionsState.get().didStartInitialFetch && this.registerSessionsRefresher();
|
|
359
359
|
});
|
|
360
360
|
}, this.registerSessionsRefresher = () => {
|
|
361
361
|
this.sessionsRefresher.startPolling(async () => {
|
|
362
362
|
this.sessionsState.get().didStartInitialFetch === !1 && this.sessionsState.setPartial({ didStartInitialFetch: !0 }), await this.refreshSessions(), this.sessionsState.get().isInitialFetchLoading === !0 && this.sessionsState.setPartial({ isInitialFetchLoading: !1 });
|
|
363
363
|
}, this.sessionsPollingIntervalSeconds * 1e3);
|
|
364
364
|
}, this.createSession = async () => {
|
|
365
|
-
var
|
|
365
|
+
var s;
|
|
366
366
|
this.sessionState.setPartial({ session: null, isCreatingSession: !0 });
|
|
367
|
-
const
|
|
368
|
-
customData:
|
|
369
|
-
external_id:
|
|
367
|
+
const o = (s = this.contactCtx.state.get().contact) == null ? void 0 : s.externalId, { data: e, error: t } = await this.api.createSession({
|
|
368
|
+
customData: o ? {
|
|
369
|
+
external_id: o
|
|
370
370
|
} : void 0
|
|
371
371
|
});
|
|
372
|
-
return
|
|
372
|
+
return e ? (this.sessionState.setPartial({ session: e, isCreatingSession: !1 }), e) : (console.error("Failed to create session:", t), null);
|
|
373
373
|
}, this.loadMoreSessions = async () => {
|
|
374
374
|
if (this.sessionsState.get().isLastPage) return;
|
|
375
|
-
const { data:
|
|
375
|
+
const { data: o } = await this.getSessions({
|
|
376
376
|
cursor: this.sessionsState.get().cursor
|
|
377
377
|
});
|
|
378
|
-
if (
|
|
379
|
-
const t = [...this.sessionsState.get().data, ...
|
|
380
|
-
(
|
|
378
|
+
if (o) {
|
|
379
|
+
const t = [...this.sessionsState.get().data, ...o.items].filter(
|
|
380
|
+
(s, i, c) => i === c.findIndex((r) => s.id === r.id)
|
|
381
381
|
);
|
|
382
382
|
this.sessionsState.setPartial({
|
|
383
383
|
data: t,
|
|
384
|
-
cursor:
|
|
385
|
-
isLastPage:
|
|
384
|
+
cursor: o.next || void 0,
|
|
385
|
+
isLastPage: o.next === null
|
|
386
386
|
});
|
|
387
387
|
}
|
|
388
|
-
}, this.getSessions = async ({ cursor:
|
|
389
|
-
var t,
|
|
388
|
+
}, this.getSessions = async ({ cursor: o }) => {
|
|
389
|
+
var t, s;
|
|
390
390
|
if (!((t = this.contactCtx.state.get().contact) != null && t.token)) return { data: null };
|
|
391
|
-
const
|
|
391
|
+
const e = (s = this.contactCtx.state.get().contact) == null ? void 0 : s.externalId;
|
|
392
392
|
return await this.api.getSessions({
|
|
393
|
-
cursor:
|
|
394
|
-
filters:
|
|
395
|
-
external_id:
|
|
393
|
+
cursor: o,
|
|
394
|
+
filters: e ? {
|
|
395
|
+
external_id: e
|
|
396
396
|
} : {}
|
|
397
397
|
});
|
|
398
|
-
}, this.setSessions = (
|
|
399
|
-
const
|
|
400
|
-
(t,
|
|
398
|
+
}, this.setSessions = (o) => {
|
|
399
|
+
const e = [...o, ...this.sessionsState.get().data].filter(
|
|
400
|
+
(t, s, i) => s === i.findIndex((c) => t.id === c.id)
|
|
401
401
|
);
|
|
402
|
-
this.sessionsState.setPartial({ data:
|
|
402
|
+
this.sessionsState.setPartial({ data: e });
|
|
403
403
|
}, this.refreshSessions = async () => {
|
|
404
|
-
const { data:
|
|
405
|
-
|
|
404
|
+
const { data: o } = await this.getSessions({ cursor: void 0 });
|
|
405
|
+
o && this.setSessions(o.items);
|
|
406
406
|
}, this.resolveSession = async () => {
|
|
407
|
-
const
|
|
408
|
-
if (!
|
|
409
|
-
const { data:
|
|
410
|
-
session_id:
|
|
407
|
+
const o = this.sessionState.get().session;
|
|
408
|
+
if (!o || !o.isOpened) return;
|
|
409
|
+
const { data: e } = await this.api.resolveSession({
|
|
410
|
+
session_id: o.id
|
|
411
411
|
});
|
|
412
|
-
|
|
413
|
-
}, this.api = n, this.contactCtx =
|
|
412
|
+
e && this.sessionState.setPartial({ session: e });
|
|
413
|
+
}, this.api = n, this.contactCtx = a, this.sessionsPollingIntervalSeconds = g, this.registerSessionsRefresherWrapper();
|
|
414
414
|
}
|
|
415
415
|
}
|
|
416
416
|
class $ {
|
|
417
417
|
constructor({
|
|
418
418
|
config: n,
|
|
419
|
-
api:
|
|
420
|
-
sessionCtx:
|
|
421
|
-
contactCtx:
|
|
419
|
+
api: a,
|
|
420
|
+
sessionCtx: g,
|
|
421
|
+
contactCtx: o
|
|
422
422
|
}) {
|
|
423
423
|
this.state = new P({
|
|
424
424
|
messages: [],
|
|
@@ -427,15 +427,15 @@ class $ {
|
|
|
427
427
|
isInitialFetchLoading: !1
|
|
428
428
|
}), this.sendMessageAbortController = new AbortController(), this.reset = () => {
|
|
429
429
|
this.sendMessageAbortController.abort("Resetting chat"), this.state.reset();
|
|
430
|
-
}, this.sendMessage = async (
|
|
431
|
-
var r,
|
|
432
|
-
if (!
|
|
430
|
+
}, this.sendMessage = async (e) => {
|
|
431
|
+
var r, h, l, f, x, p, b, v;
|
|
432
|
+
if (!e.content.trim() && (!e.attachments || e.attachments.length === 0)) {
|
|
433
433
|
console.warn("Cannot send an empty message of no content or attachments");
|
|
434
434
|
return;
|
|
435
435
|
}
|
|
436
|
-
const t = this.state.get().isSendingMessage,
|
|
437
|
-
if (
|
|
438
|
-
|
|
436
|
+
const t = this.state.get().isSendingMessage, s = ((r = this.sessionCtx.sessionState.get().session) == null ? void 0 : r.assignee.kind) === "ai", i = this.state.get().messages, c = i.length > 0 ? i[i.length - 1] : void 0;
|
|
437
|
+
if (s && t || // If last message is from user, then bot response did not arrive yet
|
|
438
|
+
s && (c == null ? void 0 : c.type) === "FROM_USER") {
|
|
439
439
|
console.warn("Cannot send messages while awaiting AI response");
|
|
440
440
|
return;
|
|
441
441
|
}
|
|
@@ -443,21 +443,21 @@ class $ {
|
|
|
443
443
|
try {
|
|
444
444
|
this.state.setPartial({ isSendingMessage: !0 });
|
|
445
445
|
const u = this.toUserMessage(
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
),
|
|
446
|
+
e.content.trim(),
|
|
447
|
+
e.attachments || void 0
|
|
448
|
+
), S = this.state.get().messages;
|
|
449
449
|
if (this.state.setPartial({
|
|
450
|
-
messages: [...
|
|
451
|
-
}), !((
|
|
450
|
+
messages: [...S, u]
|
|
451
|
+
}), !((h = this.sessionCtx.sessionState.get().session) != null && h.id)) {
|
|
452
452
|
if (!await this.sessionCtx.createSession()) {
|
|
453
453
|
console.error("Failed to create session");
|
|
454
454
|
return;
|
|
455
455
|
}
|
|
456
456
|
this.sessionCtx.refreshSessions();
|
|
457
457
|
}
|
|
458
|
-
const k = (
|
|
458
|
+
const k = (l = this.sessionCtx.sessionState.get().session) == null ? void 0 : l.id;
|
|
459
459
|
if (!k) return;
|
|
460
|
-
const { data:
|
|
460
|
+
const { data: C } = await this.api.sendMessage(
|
|
461
461
|
{
|
|
462
462
|
uuid: u.id,
|
|
463
463
|
bot_token: this.config.token,
|
|
@@ -466,36 +466,36 @@ class $ {
|
|
|
466
466
|
body_properties: this.config.bodyProperties,
|
|
467
467
|
session_id: k,
|
|
468
468
|
content: u.content,
|
|
469
|
-
attachments:
|
|
469
|
+
attachments: e.attachments,
|
|
470
470
|
clientContext: this.config.context,
|
|
471
471
|
custom_data: {
|
|
472
472
|
...this.config.messageCustomData || {},
|
|
473
|
-
...
|
|
473
|
+
...e.customData || {}
|
|
474
474
|
},
|
|
475
475
|
language: this.config.language
|
|
476
476
|
},
|
|
477
477
|
this.sendMessageAbortController.signal
|
|
478
478
|
);
|
|
479
|
-
if (
|
|
480
|
-
const w = this.toBotMessage(
|
|
479
|
+
if (C != null && C.success) {
|
|
480
|
+
const w = this.toBotMessage(C);
|
|
481
481
|
if (w) {
|
|
482
482
|
const I = this.state.get().messages;
|
|
483
483
|
if (!!I.some(
|
|
484
484
|
(R) => R.id === w.id
|
|
485
485
|
)) {
|
|
486
486
|
this.state.setPartial({
|
|
487
|
-
lastAIResMightSolveUserIssue: ((
|
|
487
|
+
lastAIResMightSolveUserIssue: ((f = C.autopilotResponse) == null ? void 0 : f.mightSolveUserIssue) || ((x = C.uiResponse) == null ? void 0 : x.mightSolveUserIssue)
|
|
488
488
|
});
|
|
489
489
|
return;
|
|
490
490
|
}
|
|
491
491
|
this.state.setPartial({
|
|
492
492
|
messages: [...I, w],
|
|
493
|
-
lastAIResMightSolveUserIssue: ((p =
|
|
493
|
+
lastAIResMightSolveUserIssue: ((p = C.autopilotResponse) == null ? void 0 : p.mightSolveUserIssue) || ((b = C.uiResponse) == null ? void 0 : b.mightSolveUserIssue)
|
|
494
494
|
});
|
|
495
495
|
}
|
|
496
496
|
} else {
|
|
497
497
|
const w = this.toBotErrorMessage(
|
|
498
|
-
((v =
|
|
498
|
+
((v = C == null ? void 0 : C.error) == null ? void 0 : v.message) || "Unknown error occurred"
|
|
499
499
|
), I = this.state.get().messages;
|
|
500
500
|
this.state.setPartial({
|
|
501
501
|
messages: [...I, w]
|
|
@@ -506,27 +506,27 @@ class $ {
|
|
|
506
506
|
} finally {
|
|
507
507
|
this.state.setPartial({ isSendingMessage: !1 });
|
|
508
508
|
}
|
|
509
|
-
}, this.toUserMessage = (
|
|
510
|
-
const
|
|
511
|
-
const
|
|
512
|
-
return this.state.get().messages.length === 0 &&
|
|
509
|
+
}, this.toUserMessage = (e, t) => {
|
|
510
|
+
const s = (() => {
|
|
511
|
+
const i = this.contactCtx.state.get().extraCollectedData;
|
|
512
|
+
return this.state.get().messages.length === 0 && i && Object.keys(i).length > 0 ? `${Object.entries(i).filter(([r, h]) => !!h).map(([r, h]) => `${r}: ${h}`).join(`
|
|
513
513
|
`)}
|
|
514
514
|
|
|
515
|
-
${
|
|
515
|
+
${e}` : e;
|
|
516
516
|
})();
|
|
517
517
|
return {
|
|
518
518
|
id: y(),
|
|
519
519
|
type: "FROM_USER",
|
|
520
|
-
content:
|
|
520
|
+
content: s,
|
|
521
521
|
deliveredAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
522
522
|
attachments: t,
|
|
523
523
|
timestamp: (/* @__PURE__ */ new Date()).toISOString()
|
|
524
524
|
};
|
|
525
|
-
}, this.toBotMessage = (
|
|
525
|
+
}, this.toBotMessage = (e) => {
|
|
526
526
|
var t;
|
|
527
|
-
return
|
|
527
|
+
return e.success && e.autopilotResponse ? {
|
|
528
528
|
type: "FROM_BOT",
|
|
529
|
-
id:
|
|
529
|
+
id: e.autopilotResponse.id || y(),
|
|
530
530
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
531
531
|
component: "bot_message",
|
|
532
532
|
agent: this.config.bot ? {
|
|
@@ -536,54 +536,64 @@ ${s}` : s;
|
|
|
536
536
|
id: null
|
|
537
537
|
} : void 0,
|
|
538
538
|
data: {
|
|
539
|
-
message:
|
|
540
|
-
action: (t =
|
|
541
|
-
name:
|
|
542
|
-
data:
|
|
539
|
+
message: e.autopilotResponse.value.content,
|
|
540
|
+
action: (t = e.uiResponse) != null && t.value.name ? {
|
|
541
|
+
name: e.uiResponse.value.name,
|
|
542
|
+
data: e.uiResponse.value.request_response
|
|
543
543
|
} : void 0
|
|
544
544
|
}
|
|
545
545
|
} : null;
|
|
546
|
-
}, this.toBotErrorMessage = (
|
|
546
|
+
}, this.toBotErrorMessage = (e) => ({
|
|
547
547
|
type: "FROM_BOT",
|
|
548
548
|
id: y(),
|
|
549
549
|
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
550
550
|
component: "TEXT",
|
|
551
551
|
data: {
|
|
552
|
-
message:
|
|
552
|
+
message: e,
|
|
553
553
|
variant: "error",
|
|
554
554
|
action: void 0
|
|
555
555
|
}
|
|
556
|
-
}), this.config = n, this.api =
|
|
556
|
+
}), this.config = n, this.api = a, this.sessionCtx = g, this.contactCtx = o;
|
|
557
557
|
}
|
|
558
558
|
}
|
|
559
559
|
class N {
|
|
560
560
|
constructor({
|
|
561
561
|
config: n,
|
|
562
|
-
contactCtx:
|
|
563
|
-
sessionCtx:
|
|
564
|
-
resetChat:
|
|
562
|
+
contactCtx: a,
|
|
563
|
+
sessionCtx: g,
|
|
564
|
+
resetChat: o
|
|
565
565
|
}) {
|
|
566
|
+
var e;
|
|
566
567
|
this.registerRoutingListener = () => {
|
|
567
|
-
this.contactCtx.state.subscribe(({ contact:
|
|
568
|
-
|
|
568
|
+
this.contactCtx.state.subscribe(({ contact: t }) => {
|
|
569
|
+
var s;
|
|
570
|
+
t != null && t.token && this.state.get().screen === "welcome" && this.state.setPartial({
|
|
571
|
+
screen: (s = this.config.router) != null && s.chatScreenOnly ? "chat" : "sessions"
|
|
572
|
+
});
|
|
569
573
|
}), this.sessionCtx.sessionsState.subscribe(
|
|
570
|
-
({ isInitialFetchLoading:
|
|
571
|
-
var
|
|
572
|
-
|
|
574
|
+
({ isInitialFetchLoading: t, data: s }) => {
|
|
575
|
+
var i, c, r, h;
|
|
576
|
+
if ((i = this.config.router) != null && i.chatScreenOnly && // Do not route to a chat if we are currently inside one already
|
|
577
|
+
// This also applies to newly created sessions; the new session will be in `sessionState` before it is refreshed and included in `sessionsState`
|
|
578
|
+
!((c = this.sessionCtx.sessionState.get().session) != null && c.id)) {
|
|
579
|
+
const l = (r = s.find((f) => f.isOpened)) == null ? void 0 : r.id;
|
|
580
|
+
return l ? this.toChatScreen(l) : void 0;
|
|
581
|
+
}
|
|
582
|
+
s.length || ((h = this.config.router) == null ? void 0 : h.goToChatIfNoSessions) !== !1 && !t && this.state.get().screen !== "chat" && this.toChatScreen();
|
|
573
583
|
}
|
|
574
584
|
);
|
|
575
585
|
}, this.toSessionsScreen = () => {
|
|
576
586
|
this.resetChat(), this.state.setPartial({ screen: "sessions" });
|
|
577
|
-
}, this.toChatScreen = (
|
|
578
|
-
if (this.resetChat(),
|
|
579
|
-
const
|
|
580
|
-
if (!
|
|
581
|
-
this.sessionCtx.sessionState.setPartial({ session:
|
|
587
|
+
}, this.toChatScreen = (t) => {
|
|
588
|
+
if (this.resetChat(), t) {
|
|
589
|
+
const s = this.sessionCtx.sessionsState.get().data.find((i) => i.id === t);
|
|
590
|
+
if (!s) return;
|
|
591
|
+
this.sessionCtx.sessionState.setPartial({ session: s });
|
|
582
592
|
}
|
|
583
593
|
this.state.setPartial({ screen: "chat" });
|
|
584
|
-
}, this.state = new P({
|
|
585
|
-
screen:
|
|
586
|
-
}), this.
|
|
594
|
+
}, this.config = n, this.contactCtx = a, this.sessionCtx = g, this.resetChat = o, this.state = new P({
|
|
595
|
+
screen: this.contactCtx.shouldCollectData() ? "welcome" : (e = this.config.router) != null && e.chatScreenOnly ? "chat" : "sessions"
|
|
596
|
+
}), this.registerRoutingListener();
|
|
587
597
|
}
|
|
588
598
|
}
|
|
589
599
|
class H {
|
|
@@ -591,32 +601,32 @@ class H {
|
|
|
591
601
|
this.KEYS = {
|
|
592
602
|
contactToken: "opencx__widget__contactToken",
|
|
593
603
|
externalContactId: "opencx__widget__externalContactId"
|
|
594
|
-
}, this.setContactToken = async (
|
|
595
|
-
await this.storage.set(this.KEYS.contactToken,
|
|
596
|
-
}, this.getContactToken = async () => this.storage.get(this.KEYS.contactToken), this.setExternalContactId = async (
|
|
597
|
-
await this.storage.set(this.KEYS.externalContactId,
|
|
604
|
+
}, this.setContactToken = async (a) => {
|
|
605
|
+
await this.storage.set(this.KEYS.contactToken, a);
|
|
606
|
+
}, this.getContactToken = async () => this.storage.get(this.KEYS.contactToken), this.setExternalContactId = async (a) => {
|
|
607
|
+
await this.storage.set(this.KEYS.externalContactId, a);
|
|
598
608
|
}, this.getExternalContactId = async () => this.storage.get(this.KEYS.externalContactId), this.storage = n;
|
|
599
609
|
}
|
|
600
610
|
}
|
|
601
|
-
const
|
|
611
|
+
const m = class m {
|
|
602
612
|
constructor({
|
|
603
613
|
config: n,
|
|
604
|
-
storage:
|
|
614
|
+
storage: a
|
|
605
615
|
}) {
|
|
606
616
|
if (this.resetChat = () => {
|
|
607
617
|
this.sessionCtx.reset(), this.messageCtx.reset();
|
|
608
|
-
}, !
|
|
618
|
+
}, !m.pollingIntervalsSeconds)
|
|
609
619
|
throw Error(
|
|
610
620
|
"Widget polling values are not defined, did you call WidgetCtx.initialize()"
|
|
611
621
|
);
|
|
612
|
-
this.config = n, this.api = new T({ config: n }), this.storageCtx =
|
|
622
|
+
this.config = n, this.api = new T({ config: n }), this.storageCtx = a ? new H({ storage: a }) : void 0, this.contactCtx = new B({
|
|
613
623
|
api: this.api,
|
|
614
624
|
config: this.config,
|
|
615
625
|
storageCtx: this.storageCtx
|
|
616
626
|
}), this.sessionCtx = new q({
|
|
617
627
|
api: this.api,
|
|
618
628
|
contactCtx: this.contactCtx,
|
|
619
|
-
sessionsPollingIntervalSeconds:
|
|
629
|
+
sessionsPollingIntervalSeconds: m.pollingIntervalsSeconds.sessions
|
|
620
630
|
}), this.messageCtx = new $({
|
|
621
631
|
config: this.config,
|
|
622
632
|
api: this.api,
|
|
@@ -627,7 +637,7 @@ const S = class S {
|
|
|
627
637
|
config: this.config,
|
|
628
638
|
sessionCtx: this.sessionCtx,
|
|
629
639
|
messageCtx: this.messageCtx,
|
|
630
|
-
sessionPollingIntervalSeconds:
|
|
640
|
+
sessionPollingIntervalSeconds: m.pollingIntervalsSeconds.session
|
|
631
641
|
}), this.routerCtx = new N({
|
|
632
642
|
config: this.config,
|
|
633
643
|
contactCtx: this.contactCtx,
|
|
@@ -636,25 +646,25 @@ const S = class S {
|
|
|
636
646
|
});
|
|
637
647
|
}
|
|
638
648
|
};
|
|
639
|
-
|
|
649
|
+
m.pollingIntervalsSeconds = null, m.initialize = async ({
|
|
640
650
|
config: n,
|
|
641
|
-
storage:
|
|
651
|
+
storage: a
|
|
642
652
|
}) => {
|
|
643
|
-
var
|
|
644
|
-
const
|
|
653
|
+
var o, e;
|
|
654
|
+
const g = await new T({
|
|
645
655
|
config: n
|
|
646
656
|
}).getExternalWidgetConfig();
|
|
647
|
-
return
|
|
648
|
-
session: ((
|
|
649
|
-
sessions: ((
|
|
650
|
-
}, new
|
|
657
|
+
return m.pollingIntervalsSeconds = {
|
|
658
|
+
session: ((o = g.data) == null ? void 0 : o.sessionPollingIntervalSeconds) || 10,
|
|
659
|
+
sessions: ((e = g.data) == null ? void 0 : e.sessionsPollingIntervalSeconds) || 60
|
|
660
|
+
}, new m({
|
|
651
661
|
config: n,
|
|
652
|
-
storage:
|
|
662
|
+
storage: a
|
|
653
663
|
});
|
|
654
664
|
};
|
|
655
|
-
let U =
|
|
665
|
+
let U = m;
|
|
656
666
|
export {
|
|
657
667
|
P,
|
|
658
668
|
U as W
|
|
659
669
|
};
|
|
660
|
-
//# sourceMappingURL=widget.ctx-
|
|
670
|
+
//# sourceMappingURL=widget.ctx-0z1bMkkT.js.map
|