cobrowse-agent-ui 1.4.2 → 1.6.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/README.md +6 -8
- package/dist/cobrowse-agent-ui.css +1 -1
- package/dist/cobrowse-agent-ui.d.ts +140 -6
- package/dist/cobrowse-agent-ui.js +436 -173
- package/dist/cobrowse-agent-ui.js.map +1 -1
- package/dist/index-fBWDR3rY.js +1337 -0
- package/dist/index-fBWDR3rY.js.map +1 -0
- package/dist/integrations.d.ts +22 -6
- package/dist/integrations.js +116 -80
- package/dist/integrations.js.map +1 -1
- package/dist/session/demo-session.html +111 -0
- package/package.json +5 -4
- package/dist/index-CvPSmCSB.js +0 -839
- package/dist/index-CvPSmCSB.js.map +0 -1
|
@@ -1,194 +1,457 @@
|
|
|
1
|
-
var
|
|
2
|
-
var
|
|
3
|
-
var
|
|
4
|
-
var
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
1
|
+
var ve = Object.defineProperty, Ee = Object.defineProperties;
|
|
2
|
+
var Re = Object.getOwnPropertyDescriptors;
|
|
3
|
+
var M = Object.getOwnPropertySymbols;
|
|
4
|
+
var X = Object.prototype.hasOwnProperty, K = Object.prototype.propertyIsEnumerable;
|
|
5
|
+
var G = (e, n, t) => n in e ? ve(e, n, { enumerable: !0, configurable: !0, writable: !0, value: t }) : e[n] = t, $ = (e, n) => {
|
|
6
|
+
for (var t in n || (n = {}))
|
|
7
|
+
X.call(n, t) && G(e, t, n[t]);
|
|
8
|
+
if (M)
|
|
9
|
+
for (var t of M(n))
|
|
10
|
+
K.call(n, t) && G(e, t, n[t]);
|
|
11
|
+
return e;
|
|
12
|
+
}, H = (e, n) => Ee(e, Re(n));
|
|
13
|
+
var U = (e, n) => {
|
|
14
|
+
var t = {};
|
|
15
|
+
for (var o in e)
|
|
16
|
+
X.call(e, o) && n.indexOf(o) < 0 && (t[o] = e[o]);
|
|
17
|
+
if (e != null && M)
|
|
18
|
+
for (var o of M(e))
|
|
19
|
+
n.indexOf(o) < 0 && K.call(e, o) && (t[o] = e[o]);
|
|
10
20
|
return t;
|
|
11
21
|
};
|
|
12
|
-
var
|
|
13
|
-
var
|
|
22
|
+
var k = (e, n, t) => new Promise((o, s) => {
|
|
23
|
+
var r = (a) => {
|
|
14
24
|
try {
|
|
15
|
-
|
|
16
|
-
} catch (
|
|
17
|
-
|
|
25
|
+
f(t.next(a));
|
|
26
|
+
} catch (i) {
|
|
27
|
+
s(i);
|
|
18
28
|
}
|
|
19
|
-
},
|
|
29
|
+
}, c = (a) => {
|
|
20
30
|
try {
|
|
21
|
-
|
|
22
|
-
} catch (
|
|
23
|
-
|
|
31
|
+
f(t.throw(a));
|
|
32
|
+
} catch (i) {
|
|
33
|
+
s(i);
|
|
24
34
|
}
|
|
25
|
-
},
|
|
26
|
-
|
|
35
|
+
}, f = (a) => a.done ? o(a.value) : Promise.resolve(a.value).then(r, c);
|
|
36
|
+
f((t = t.apply(e, n)).next());
|
|
27
37
|
});
|
|
28
|
-
import {
|
|
29
|
-
import
|
|
30
|
-
import
|
|
31
|
-
import {
|
|
32
|
-
import
|
|
33
|
-
import {
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
}
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
},
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
},
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
(s = c.current[e]) == null || s.focus();
|
|
64
|
-
}, [E]), K = m((r) => A(null, null, function* () {
|
|
65
|
-
h(!0);
|
|
66
|
-
try {
|
|
67
|
-
(yield f == null ? void 0 : f(r)) ? (D(x), c.current[0] && setTimeout(() => {
|
|
68
|
-
var s;
|
|
69
|
-
return (s = c.current[0]) == null ? void 0 : s.focus();
|
|
70
|
-
}, 0)) : setTimeout(() => {
|
|
71
|
-
var s;
|
|
72
|
-
return (s = c.current[l - 1]) == null ? void 0 : s.focus();
|
|
73
|
-
}, 0);
|
|
74
|
-
} catch (e) {
|
|
75
|
-
throw c.current[l - 1] && setTimeout(() => {
|
|
76
|
-
var s;
|
|
77
|
-
return (s = c.current[l - 1]) == null ? void 0 : s.focus();
|
|
78
|
-
}, 0), e;
|
|
79
|
-
} finally {
|
|
80
|
-
h(!1);
|
|
38
|
+
import { i as W, u as T, B as re, L as ce, C as be, D as pe, P as Se, R as we, S as $e, a as xe } from "./index-fBWDR3rY.js";
|
|
39
|
+
import { jsxs as D, jsx as C } from "react/jsx-runtime";
|
|
40
|
+
import * as v from "react";
|
|
41
|
+
import { createContext as ae, use as ie, useState as I, useEffect as x, useRef as S, useCallback as R, useMemo as ye } from "react";
|
|
42
|
+
import j from "clsx";
|
|
43
|
+
import { RemoteContext as Le } from "cobrowse-agent-sdk";
|
|
44
|
+
import "react-i18next";
|
|
45
|
+
const Q = ({ resolvedLanguage: e, language: n }) => e != null ? e : n, ke = (e) => {
|
|
46
|
+
const n = (o) => {
|
|
47
|
+
!o || Q(W) === o || W.changeLanguage(o);
|
|
48
|
+
}, t = (o) => {
|
|
49
|
+
n(o);
|
|
50
|
+
};
|
|
51
|
+
return n(Q(e)), e.on("languageChanged", t), () => {
|
|
52
|
+
e.off("languageChanged", t);
|
|
53
|
+
};
|
|
54
|
+
}, Pe = (e) => /* @__PURE__ */ v.createElement("svg", $({ xmlns: "http://www.w3.org/2000/svg", viewBox: "0 0 24 24", fill: "none", stroke: "currentColor", strokeWidth: 2, strokeLinecap: "round", strokeLinejoin: "round", width: 14, height: 14, "aria-hidden": "true" }, e), /* @__PURE__ */ v.createElement("path", { d: "M15 3h6v6" }), /* @__PURE__ */ v.createElement("path", { d: "M10 14 21 3" }), /* @__PURE__ */ v.createElement("path", { d: "M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6" })), Be = "ExternalLink-module__root__7-WiY focus-module__focusRing__rvgPB", Oe = {
|
|
55
|
+
root: Be
|
|
56
|
+
}, Ne = ({ href: e, children: n }) => /* @__PURE__ */ D("a", { className: Oe.root, href: e, target: "_blank", rel: "noopener noreferrer", children: [
|
|
57
|
+
n,
|
|
58
|
+
/* @__PURE__ */ C(Pe, {})
|
|
59
|
+
] }), Me = "UserIcon-module__root__-NL30", Ue = {
|
|
60
|
+
root: Me
|
|
61
|
+
}, Te = ({ user: e, className: n }) => {
|
|
62
|
+
const t = () => !(e != null && e.name) || e.picture ? "" : e.name.trim().split(/\s+/).map((o) => o.toUpperCase().charAt(0)).join("").slice(0, 2);
|
|
63
|
+
return e ? /* @__PURE__ */ C(
|
|
64
|
+
"div",
|
|
65
|
+
{
|
|
66
|
+
className: j(Ue.root, n),
|
|
67
|
+
title: e.name,
|
|
68
|
+
style: {
|
|
69
|
+
backgroundImage: e.picture ? `url(${e.picture || ""})` : void 0,
|
|
70
|
+
backgroundColor: e.colour
|
|
71
|
+
},
|
|
72
|
+
children: /* @__PURE__ */ C("span", { children: t() })
|
|
81
73
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
}, [
|
|
87
|
-
const
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
74
|
+
) : null;
|
|
75
|
+
}, De = (e) => /* @__PURE__ */ v.createElement("svg", $({ width: 24, height: 24, viewBox: "0 0 24 24", fill: "none", xmlns: "http://www.w3.org/2000/svg" }, e), /* @__PURE__ */ v.createElement("g", { clipPath: "url(#clip0_60797_8824)" }, /* @__PURE__ */ v.createElement("path", { fillRule: "evenodd", clipRule: "evenodd", d: "M20.9964 12.5895C21.1528 12.4331 21.2406 12.2211 21.2406 12C21.2406 11.7872 21.1593 11.5829 21.0138 11.4285C18.518 9.23023 15.3059 8.01707 11.9793 8.01707C8.65261 8.01707 5.44055 9.23023 2.94474 11.4285C2.7993 11.5829 2.71797 11.7872 2.71797 12C2.71797 12.2211 2.8058 12.4331 2.96214 12.5895L5.07653 14.7039L8.20945 13.3612L7.76772 11.5943C7.6415 11.0894 7.92363 10.5721 8.41645 10.4048C10.7269 9.62055 13.2316 9.62055 15.5421 10.4048C16.0349 10.5721 16.3171 11.0894 16.1908 11.5943L15.7491 13.3612L18.882 14.7039L20.9964 12.5895ZM23.2406 12C23.2406 12.7515 22.942 13.4723 22.4106 14.0037L19.8175 16.5968C19.5284 16.8859 19.0923 16.9699 18.7165 16.8088L14.1785 14.864C13.7274 14.6707 13.4832 14.1785 13.6023 13.7023L14.0159 12.0478C12.6758 11.7395 11.2828 11.7395 9.94266 12.0478L10.3563 13.7023C10.4753 14.1785 10.2312 14.6707 9.78006 14.864L5.24208 16.8088C4.86624 16.9699 4.43019 16.8859 4.14106 16.5968L1.54792 14.0037C1.01651 13.4723 0.717975 12.7515 0.717976 12C0.717975 11.2485 1.01651 10.5277 1.54792 9.99633C1.56223 9.98202 1.57697 9.96815 1.59212 9.95474C4.45744 7.41772 8.1522 6.01707 11.9793 6.01707C15.8064 6.01707 19.5011 7.41772 22.3664 9.95474C22.3816 9.96815 22.3963 9.98202 22.4106 9.99633C22.942 10.5277 23.2406 11.2485 23.2406 12Z", fill: "currentColor" })), /* @__PURE__ */ v.createElement("defs", null, /* @__PURE__ */ v.createElement("clipPath", { id: "clip0_60797_8824" }, /* @__PURE__ */ v.createElement("rect", { width: 24, height: 24, fill: "white" })))), Ie = "CancelButton-module__root__CbF-w", je = {
|
|
76
|
+
root: Ie
|
|
77
|
+
}, le = (s) => {
|
|
78
|
+
var r = s, { type: e = "button", className: n, children: t } = r, o = U(r, ["type", "className", "children"]);
|
|
79
|
+
const { t: c } = T();
|
|
80
|
+
return /* @__PURE__ */ C(
|
|
81
|
+
re,
|
|
82
|
+
H($({
|
|
83
|
+
type: e,
|
|
84
|
+
"aria-label": c("Cancel"),
|
|
85
|
+
className: j(je.root, n)
|
|
86
|
+
}, o), {
|
|
87
|
+
children: t != null ? t : /* @__PURE__ */ C(De, {})
|
|
88
|
+
})
|
|
89
|
+
);
|
|
90
|
+
}, Ae = "BlockingError-module__root__myw6b", Fe = "BlockingError-module__heading__FzjhY", He = "BlockingError-module__message__7jJ2T", q = {
|
|
91
|
+
root: Ae,
|
|
92
|
+
heading: Fe,
|
|
93
|
+
message: He
|
|
94
|
+
}, qe = ({ heading: e, message: n, children: t }) => {
|
|
95
|
+
const { t: o } = T();
|
|
96
|
+
return /* @__PURE__ */ D("div", { className: q.root, children: [
|
|
97
|
+
/* @__PURE__ */ C("p", { className: q.heading, children: e != null ? e : o("Sorry, something went wrong.") }),
|
|
98
|
+
n && /* @__PURE__ */ C("p", { className: q.message, children: n }),
|
|
99
|
+
t
|
|
100
|
+
] });
|
|
101
|
+
}, de = ae(null), We = ({ cobrowse: e, children: n }) => /* @__PURE__ */ C(de.Provider, { value: e, children: n }), ue = () => ie(de), Y = () => {
|
|
102
|
+
const e = ue();
|
|
103
|
+
if (!e)
|
|
104
|
+
throw new Error("CobrowseProvider is required to use this component.");
|
|
105
|
+
return e;
|
|
106
|
+
}, fe = ae(null);
|
|
107
|
+
function A(e) {
|
|
108
|
+
const n = ie(fe), t = ue(), [o, s] = I(null);
|
|
109
|
+
return x(() => {
|
|
110
|
+
if (e === void 0 || !e || !t)
|
|
95
111
|
return;
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
112
|
+
let r = !1, c = null;
|
|
113
|
+
return k(null, null, function* () {
|
|
114
|
+
if (c = yield t.attachContext(e), r) {
|
|
115
|
+
c.destroy(), c = null;
|
|
116
|
+
return;
|
|
117
|
+
}
|
|
118
|
+
s(c);
|
|
119
|
+
}), () => {
|
|
120
|
+
r = !0, s(null), c && (c.destroy(), c = null);
|
|
121
|
+
};
|
|
122
|
+
}, [t, e]), e === void 0 ? n : !e || !t ? null : o;
|
|
123
|
+
}
|
|
124
|
+
const E = (e) => {
|
|
125
|
+
const n = S(e);
|
|
126
|
+
return x(() => {
|
|
127
|
+
n.current = e;
|
|
128
|
+
}, [e]), R((...t) => {
|
|
129
|
+
var o;
|
|
130
|
+
return (o = n.current) == null ? void 0 : o.call(n, ...t);
|
|
131
|
+
}, []);
|
|
132
|
+
}, me = (a) => {
|
|
133
|
+
var i = a, {
|
|
134
|
+
src: e,
|
|
135
|
+
onError: n,
|
|
136
|
+
title: t = "Frame",
|
|
137
|
+
width: o = "100%",
|
|
138
|
+
height: s = "100%",
|
|
139
|
+
style: r,
|
|
140
|
+
children: c
|
|
141
|
+
} = i, f = U(i, [
|
|
142
|
+
"src",
|
|
143
|
+
"onError",
|
|
144
|
+
"title",
|
|
145
|
+
"width",
|
|
146
|
+
"height",
|
|
147
|
+
"style",
|
|
148
|
+
"children"
|
|
149
|
+
]);
|
|
150
|
+
const [u, _] = I(null), m = E(n), d = A(u), b = R((g) => {
|
|
151
|
+
_(g);
|
|
152
|
+
}, []);
|
|
153
|
+
return x(() => {
|
|
154
|
+
if (!d)
|
|
99
155
|
return;
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
}
|
|
106
|
-
}, [
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
156
|
+
const g = (w) => {
|
|
157
|
+
m(w);
|
|
158
|
+
};
|
|
159
|
+
return d.on("error", g), () => {
|
|
160
|
+
d.off("error", g);
|
|
161
|
+
};
|
|
162
|
+
}, [d, m]), /* @__PURE__ */ D(fe.Provider, { value: d, children: [
|
|
163
|
+
/* @__PURE__ */ C(
|
|
164
|
+
"iframe",
|
|
165
|
+
$({
|
|
166
|
+
ref: b,
|
|
167
|
+
title: t,
|
|
168
|
+
width: o,
|
|
169
|
+
height: s,
|
|
170
|
+
src: e,
|
|
171
|
+
style: $({ border: 0 }, r)
|
|
172
|
+
}, f)
|
|
173
|
+
),
|
|
174
|
+
c
|
|
175
|
+
] });
|
|
176
|
+
}, ee = (e) => e instanceof Le, Ye = (e, n) => n in e, ne = (e) => e ? new Proxy(e, {
|
|
177
|
+
get: (n, t) => Ye(n, t) ? n[t] : void 0
|
|
178
|
+
}) : null, Ce = (e) => {
|
|
179
|
+
const n = e && ee(e) ? e : null, t = e && !ee(e) ? e : null, [o, s] = I(t);
|
|
180
|
+
return x(() => {
|
|
181
|
+
if (!n)
|
|
182
|
+
return;
|
|
183
|
+
const r = (c) => {
|
|
184
|
+
s(ne(c));
|
|
185
|
+
};
|
|
186
|
+
return n.on("session.loaded", r), n.on("session.updated", r), () => {
|
|
187
|
+
n.off("session.loaded", r), n.off("session.updated", r), s(null);
|
|
188
|
+
};
|
|
189
|
+
}, [n]), x(() => {
|
|
190
|
+
if (!t)
|
|
191
|
+
return;
|
|
192
|
+
const r = () => {
|
|
193
|
+
s(ne(t));
|
|
194
|
+
};
|
|
195
|
+
return t.on("updated", r), t.on("ended", r), () => {
|
|
196
|
+
t.off("updated", r), t.off("ended", r), s(null);
|
|
197
|
+
};
|
|
198
|
+
}, [t]), o != null ? o : t;
|
|
199
|
+
}, Je = "Overlay-module__root__qqUZs", Ve = "Overlay-module__content__5FwWj", te = {
|
|
200
|
+
root: Je,
|
|
201
|
+
content: Ve
|
|
202
|
+
}, Ze = ({ state: e, children: n }) => {
|
|
203
|
+
const t = A(), o = Ce(t), s = o == null ? void 0 : o.state;
|
|
204
|
+
return (e === "loading" ? s === void 0 : s === e) ? /* @__PURE__ */ C("div", { className: te.root, children: /* @__PURE__ */ C("div", { className: te.content, children: n }) }) : null;
|
|
205
|
+
}, ze = ({
|
|
206
|
+
id: e,
|
|
207
|
+
endAction: n,
|
|
208
|
+
popout: t,
|
|
209
|
+
agentTools: o,
|
|
210
|
+
deviceControls: s,
|
|
211
|
+
sessionDetails: r,
|
|
212
|
+
messages: c
|
|
213
|
+
}) => {
|
|
214
|
+
const f = Y(), { i18n: { language: a } } = T();
|
|
215
|
+
return ye(() => {
|
|
216
|
+
const i = Object.entries({
|
|
217
|
+
end_action: n,
|
|
218
|
+
popout: t,
|
|
219
|
+
agent_tools: o,
|
|
220
|
+
device_controls: s,
|
|
221
|
+
session_details: r,
|
|
222
|
+
messages: c,
|
|
223
|
+
token_source: "postMessage",
|
|
224
|
+
lng: a
|
|
225
|
+
}).flatMap(([_, m]) => m === void 0 ? [] : [[_, m]]), u = new URLSearchParams(i);
|
|
226
|
+
return `${f.api}/session/${encodeURIComponent(e)}?${u.toString()}`;
|
|
227
|
+
}, [
|
|
228
|
+
f.api,
|
|
229
|
+
e,
|
|
230
|
+
n,
|
|
231
|
+
t,
|
|
232
|
+
o,
|
|
233
|
+
s,
|
|
234
|
+
r,
|
|
235
|
+
c,
|
|
236
|
+
a
|
|
237
|
+
]);
|
|
238
|
+
}, Ge = "SessionEmbed-module__root__Y9AHn", Xe = {
|
|
239
|
+
root: Ge
|
|
240
|
+
}, Ke = ({ onLoaded: e, onUpdated: n, onActivated: t, onEnded: o }) => {
|
|
241
|
+
const s = A(), r = E(e), c = E(n), f = E(t), a = E(o), i = S(!1), u = S(!1);
|
|
242
|
+
return x(() => {
|
|
243
|
+
if (!s) {
|
|
244
|
+
i.current = !1, u.current = !1;
|
|
111
245
|
return;
|
|
112
246
|
}
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
247
|
+
const _ = (d) => {
|
|
248
|
+
i.current = d.isActive(), u.current = !1, r(d);
|
|
249
|
+
}, m = (d) => {
|
|
250
|
+
c(d), d.isActive() && !i.current && (i.current = !0, f(d)), d.isEnded() && !u.current && (u.current = !0, a(d));
|
|
251
|
+
};
|
|
252
|
+
return s.on("session.loaded", _), s.on("session.updated", m), () => {
|
|
253
|
+
s.off("session.loaded", _), s.off("session.updated", m), i.current = !1, u.current = !1;
|
|
254
|
+
};
|
|
255
|
+
}, [f, a, r, c, s]), null;
|
|
256
|
+
}, Qe = (g) => {
|
|
257
|
+
var w = g, {
|
|
258
|
+
id: e,
|
|
259
|
+
endAction: n,
|
|
260
|
+
popout: t,
|
|
261
|
+
agentTools: o,
|
|
262
|
+
deviceControls: s,
|
|
263
|
+
sessionDetails: r,
|
|
264
|
+
messages: c,
|
|
265
|
+
onError: f,
|
|
266
|
+
onLoaded: a,
|
|
267
|
+
onUpdated: i,
|
|
268
|
+
onActivated: u,
|
|
269
|
+
onEnded: _,
|
|
270
|
+
className: m,
|
|
271
|
+
children: d
|
|
272
|
+
} = w, b = U(w, [
|
|
273
|
+
"id",
|
|
274
|
+
"endAction",
|
|
275
|
+
"popout",
|
|
276
|
+
"agentTools",
|
|
277
|
+
"deviceControls",
|
|
278
|
+
"sessionDetails",
|
|
279
|
+
"messages",
|
|
280
|
+
"onError",
|
|
281
|
+
"onLoaded",
|
|
282
|
+
"onUpdated",
|
|
283
|
+
"onActivated",
|
|
284
|
+
"onEnded",
|
|
285
|
+
"className",
|
|
286
|
+
"children"
|
|
287
|
+
]);
|
|
288
|
+
const B = ze({
|
|
289
|
+
id: e,
|
|
290
|
+
endAction: n,
|
|
291
|
+
popout: t,
|
|
292
|
+
agentTools: o,
|
|
293
|
+
deviceControls: s,
|
|
294
|
+
sessionDetails: r,
|
|
295
|
+
messages: c
|
|
296
|
+
});
|
|
297
|
+
return /* @__PURE__ */ C("div", { className: Xe.root, children: /* @__PURE__ */ D(
|
|
298
|
+
me,
|
|
299
|
+
H($({
|
|
300
|
+
src: B,
|
|
301
|
+
className: m,
|
|
302
|
+
onError: f
|
|
303
|
+
}, b), {
|
|
125
304
|
children: [
|
|
126
|
-
|
|
127
|
-
|
|
305
|
+
/* @__PURE__ */ C(
|
|
306
|
+
Ke,
|
|
128
307
|
{
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
308
|
+
onLoaded: a,
|
|
309
|
+
onUpdated: i,
|
|
310
|
+
onActivated: u,
|
|
311
|
+
onEnded: _
|
|
132
312
|
}
|
|
133
313
|
),
|
|
134
|
-
|
|
135
|
-
E.map((r, e) => /* @__PURE__ */ _(
|
|
136
|
-
"input",
|
|
137
|
-
{
|
|
138
|
-
inputMode: "numeric",
|
|
139
|
-
className: $(I.input, n),
|
|
140
|
-
disabled: a,
|
|
141
|
-
onKeyDown: H,
|
|
142
|
-
onKeyUp: O,
|
|
143
|
-
onChange: Y,
|
|
144
|
-
onPaste: F,
|
|
145
|
-
value: r,
|
|
146
|
-
"data-digit": e,
|
|
147
|
-
ref: (s) => {
|
|
148
|
-
c.current[e] = s;
|
|
149
|
-
},
|
|
150
|
-
autoFocus: d && e === 0,
|
|
151
|
-
"aria-label": p("Digit {{digit}}", { digit: e + 1 })
|
|
152
|
-
},
|
|
153
|
-
e
|
|
154
|
-
)),
|
|
155
|
-
k
|
|
156
|
-
] })
|
|
314
|
+
d
|
|
157
315
|
]
|
|
316
|
+
})
|
|
317
|
+
) });
|
|
318
|
+
}, en = Object.assign(Qe, {
|
|
319
|
+
Overlay: Ze
|
|
320
|
+
}), F = 5, _e = 4e3, nn = "push_error", tn = "push_attempt_limit_reached", on = "device_not_found", sn = "session_not_found", oe = "session_error", se = (e) => e instanceof Error ? e.name === "AbortError" : !1, rn = ({
|
|
321
|
+
deviceId: e,
|
|
322
|
+
onConnectAttempt: n,
|
|
323
|
+
onConnected: t,
|
|
324
|
+
onCancelled: o,
|
|
325
|
+
onEnded: s,
|
|
326
|
+
onError: r,
|
|
327
|
+
maxPushAttempts: c = F,
|
|
328
|
+
pushRetryMs: f = _e
|
|
329
|
+
}) => {
|
|
330
|
+
const a = Y(), i = S(null), u = S(null), _ = S(!1), m = S(!1), d = S(0), b = E(n), g = E(t), w = E(o), B = E(s), y = E(r), L = R(() => {
|
|
331
|
+
clearTimeout(d.current);
|
|
332
|
+
}, []), J = R((l) => {
|
|
333
|
+
!["pending", "ended"].includes(l.state) && !_.current && (L(), g(l), _.current = !0);
|
|
334
|
+
}, [g, L]), V = R((l) => {
|
|
335
|
+
var h;
|
|
336
|
+
m.current || (B(l), m.current = !0, (h = u.current) == null || h.end());
|
|
337
|
+
}, [B]), P = R((l) => {
|
|
338
|
+
se(l) || (l instanceof Error ? y({ id: nn, message: l.message }) : y(l));
|
|
339
|
+
}, [y]), Z = R(function l(h = 1, p) {
|
|
340
|
+
return k(this, null, function* () {
|
|
341
|
+
if (b(h), h >= c) {
|
|
342
|
+
P({ id: tn, message: "Push attempt limit reached." });
|
|
343
|
+
return;
|
|
344
|
+
}
|
|
345
|
+
if (!i.current) {
|
|
346
|
+
P({ id: on, message: "Device not found." });
|
|
347
|
+
return;
|
|
348
|
+
}
|
|
349
|
+
if (!u.current) {
|
|
350
|
+
P({ id: sn, message: "Session not found." });
|
|
351
|
+
return;
|
|
352
|
+
}
|
|
353
|
+
try {
|
|
354
|
+
yield i.current.notify({ session: u.current, attempt: h }, void 0, { signal: p.signal });
|
|
355
|
+
} catch (O) {
|
|
356
|
+
P(O);
|
|
357
|
+
}
|
|
358
|
+
d.current = setTimeout(() => {
|
|
359
|
+
l(h + 1, p);
|
|
360
|
+
}, f);
|
|
361
|
+
});
|
|
362
|
+
}, [c, b, f, P]), z = R((l) => k(null, null, function* () {
|
|
363
|
+
const { signal: h } = l;
|
|
364
|
+
try {
|
|
365
|
+
i.current = null, u.current = null, _.current = !1, m.current = !1;
|
|
366
|
+
const [p, O] = yield Promise.all([
|
|
367
|
+
a.regions.closest(void 0, { signal: h }),
|
|
368
|
+
a.devices.get(e, void 0, { signal: h })
|
|
369
|
+
]);
|
|
370
|
+
i.current = O;
|
|
371
|
+
const N = yield a.sessions.create({
|
|
372
|
+
custom_data: O.custom_data,
|
|
373
|
+
region: p.id,
|
|
374
|
+
agent: "me"
|
|
375
|
+
}, void 0, { signal: h });
|
|
376
|
+
u.current = N, N.on("updated", J), N.on("ended", V), yield N.subscribe();
|
|
377
|
+
} catch (p) {
|
|
378
|
+
if (se(p))
|
|
379
|
+
return;
|
|
380
|
+
p instanceof Error ? y({ id: oe, message: p.message }) : y({ id: oe, message: "The session could not be created." });
|
|
158
381
|
}
|
|
159
|
-
)
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
382
|
+
}), [a, e, V, J, y]), ge = R(() => k(null, null, function* () {
|
|
383
|
+
L();
|
|
384
|
+
const l = u.current;
|
|
385
|
+
l && (yield l.end(), w(l));
|
|
386
|
+
}), [w, L]);
|
|
387
|
+
return x(() => {
|
|
388
|
+
const l = new AbortController();
|
|
389
|
+
return k(null, null, function* () {
|
|
390
|
+
yield z(l), !l.signal.aborted && (yield Z(1, l));
|
|
391
|
+
}), () => {
|
|
392
|
+
l.abort(), L();
|
|
393
|
+
};
|
|
394
|
+
}, [z, Z, L]), { cancel: ge };
|
|
395
|
+
}, cn = "ConnectDevice-module__root__JnmG1", an = "ConnectDevice-module__statusMessage__JWNqk", he = {
|
|
396
|
+
root: cn,
|
|
397
|
+
statusMessage: an
|
|
398
|
+
}, ln = ({ attempt: e, maxPushAttempts: n = F, className: t }) => {
|
|
399
|
+
const { t: o } = T();
|
|
400
|
+
let s = o("Contacting device");
|
|
401
|
+
return e >= n ? s = o("Device not responding") : e >= n - 1 ? s = o("Trying once more") : e > 2 && (s = o("Retrying connection")), /* @__PURE__ */ C("div", { className: j(he.statusMessage, t), children: s });
|
|
402
|
+
}, dn = ({ attempt: e, maxPushAttempts: n = F }) => e >= n ? null : /* @__PURE__ */ C(ce, {}), un = ({
|
|
403
|
+
deviceId: e,
|
|
404
|
+
onConnectAttempt: n,
|
|
405
|
+
onConnected: t,
|
|
406
|
+
onCancelled: o,
|
|
407
|
+
onEnded: s,
|
|
408
|
+
onError: r,
|
|
409
|
+
maxPushAttempts: c = F,
|
|
410
|
+
pushRetryMs: f = _e,
|
|
411
|
+
className: a,
|
|
412
|
+
children: i
|
|
413
|
+
}) => {
|
|
414
|
+
const [u, _] = I(1), m = (g) => {
|
|
415
|
+
_(g), n == null || n(g);
|
|
416
|
+
}, { cancel: d } = rn({
|
|
417
|
+
deviceId: e,
|
|
418
|
+
onConnectAttempt: m,
|
|
419
|
+
onConnected: t,
|
|
420
|
+
onCancelled: o,
|
|
421
|
+
onEnded: s,
|
|
422
|
+
onError: r,
|
|
423
|
+
maxPushAttempts: c,
|
|
424
|
+
pushRetryMs: f
|
|
425
|
+
}), b = () => {
|
|
426
|
+
d();
|
|
427
|
+
};
|
|
428
|
+
return /* @__PURE__ */ C("div", { className: j(he.root, a), children: i(u, b) });
|
|
429
|
+
}, fn = Object.assign(un, {
|
|
430
|
+
StatusMessage: ln,
|
|
431
|
+
Loader: dn,
|
|
432
|
+
CancelButton: le
|
|
433
|
+
}), Rn = be, bn = re, pn = Ne, Sn = Se, wn = pe, $n = $e, xn = xe, yn = Te, Ln = we, kn = le, Pn = qe, Bn = ce, On = me, Nn = en, Mn = fn, Un = We, Tn = Y, Dn = A, In = Ce, jn = ke, An = W;
|
|
182
434
|
export {
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
435
|
+
Pn as BlockingError,
|
|
436
|
+
bn as Button,
|
|
437
|
+
kn as CancelButton,
|
|
438
|
+
Un as CobrowseProvider,
|
|
439
|
+
Rn as CodeEntry,
|
|
440
|
+
Mn as ConnectDevice,
|
|
441
|
+
wn as Device,
|
|
442
|
+
pn as ExternalLink,
|
|
443
|
+
On as Frame,
|
|
444
|
+
Bn as Loader,
|
|
445
|
+
Sn as PlatformIcon,
|
|
446
|
+
Ln as RefreshButton,
|
|
447
|
+
$n as Session,
|
|
448
|
+
Nn as SessionEmbed,
|
|
449
|
+
xn as SmartConnectButton,
|
|
450
|
+
yn as UserIcon,
|
|
451
|
+
jn as bindI18n,
|
|
452
|
+
An as i18n,
|
|
453
|
+
Tn as useCobrowse,
|
|
454
|
+
Dn as useRemoteContext,
|
|
455
|
+
In as useSession
|
|
193
456
|
};
|
|
194
457
|
//# sourceMappingURL=cobrowse-agent-ui.js.map
|