@wix/web5-embed 0.1.8 → 0.1.9
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 +7 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +206 -165
- package/dist/index.js.map +1 -1
- package/dist/loader-types.d.ts +6 -0
- package/dist/shared.d.ts +2 -0
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const
|
|
1
|
+
const p = "__web5InputFocusShortcut__", N = 'input, textarea, [contenteditable=""], [contenteditable="true"]', x = '[role="dialog"][aria-modal="true"]';
|
|
2
2
|
function F(e) {
|
|
3
3
|
if (e.hasAttribute("inert")) return !1;
|
|
4
4
|
if (typeof e.checkVisibility == "function")
|
|
@@ -9,54 +9,54 @@ function F(e) {
|
|
|
9
9
|
const t = getComputedStyle(e);
|
|
10
10
|
return !(t.visibility === "hidden" || t.display === "none" || parseFloat(t.opacity) === 0);
|
|
11
11
|
}
|
|
12
|
-
function
|
|
12
|
+
function O(e) {
|
|
13
13
|
const t = e.composedPath();
|
|
14
14
|
for (const n of t)
|
|
15
|
-
if (n instanceof Element && typeof n.matches == "function" && n.matches(
|
|
15
|
+
if (n instanceof Element && typeof n.matches == "function" && n.matches(N))
|
|
16
16
|
return !0;
|
|
17
17
|
return !1;
|
|
18
18
|
}
|
|
19
|
-
function
|
|
19
|
+
function ce() {
|
|
20
20
|
const e = window;
|
|
21
|
-
if (e[
|
|
21
|
+
if (e[p]) return e[p];
|
|
22
22
|
const t = [];
|
|
23
23
|
let n = !1;
|
|
24
|
-
const r = (
|
|
25
|
-
if (
|
|
26
|
-
const c =
|
|
27
|
-
if (!c && !u || c &&
|
|
28
|
-
const
|
|
29
|
-
for (const
|
|
30
|
-
if (F(
|
|
31
|
-
const
|
|
32
|
-
if (!
|
|
33
|
-
|
|
24
|
+
const r = (o) => {
|
|
25
|
+
if (o.defaultPrevented || o.isComposing) return;
|
|
26
|
+
const c = o.key === "/" && !o.metaKey && !o.ctrlKey && !o.altKey && !o.shiftKey, u = (o.metaKey || o.ctrlKey) && !o.altKey && o.key.toLowerCase() === "k";
|
|
27
|
+
if (!c && !u || c && O(o)) return;
|
|
28
|
+
const f = document.querySelectorAll(x);
|
|
29
|
+
for (const w of f)
|
|
30
|
+
if (F(w)) return;
|
|
31
|
+
const l = t.find((w) => w.isVisible());
|
|
32
|
+
if (!l) return;
|
|
33
|
+
o.preventDefault();
|
|
34
34
|
const h = document.activeElement instanceof HTMLElement ? document.activeElement : null;
|
|
35
|
-
|
|
36
|
-
},
|
|
35
|
+
l.focus(h);
|
|
36
|
+
}, i = () => {
|
|
37
37
|
n || (window.addEventListener("keydown", r), n = !0);
|
|
38
38
|
}, s = () => {
|
|
39
39
|
!n || t.length > 0 || (window.removeEventListener("keydown", r), n = !1);
|
|
40
40
|
}, a = {
|
|
41
|
-
register(
|
|
42
|
-
t.includes(
|
|
41
|
+
register(o) {
|
|
42
|
+
t.includes(o) || t.push(o), i();
|
|
43
43
|
},
|
|
44
|
-
unregister(
|
|
45
|
-
const c = t.indexOf(
|
|
44
|
+
unregister(o) {
|
|
45
|
+
const c = t.indexOf(o);
|
|
46
46
|
c >= 0 && t.splice(c, 1), s();
|
|
47
47
|
},
|
|
48
48
|
__teardown() {
|
|
49
49
|
t.length = 0, n && (window.removeEventListener("keydown", r), n = !1);
|
|
50
50
|
}
|
|
51
51
|
};
|
|
52
|
-
return e[
|
|
52
|
+
return e[p] = a, a;
|
|
53
53
|
}
|
|
54
|
-
function
|
|
54
|
+
function ue() {
|
|
55
55
|
const e = window;
|
|
56
|
-
e[
|
|
56
|
+
e[p]?.__teardown(), delete e[p];
|
|
57
57
|
}
|
|
58
|
-
const
|
|
59
|
-
async function
|
|
58
|
+
const P = "https://www.wixapis.com/web50-server/static-versions", _ = "__web5_static_versions";
|
|
59
|
+
async function H(e = P) {
|
|
60
60
|
const t = await fetch(e, {
|
|
61
61
|
method: "GET",
|
|
62
62
|
headers: { Accept: "application/json" },
|
|
@@ -67,7 +67,7 @@ async function O(e = H) {
|
|
|
67
67
|
throw new Error(`[Web5Embed] static-versions returned ${t.status}`);
|
|
68
68
|
return t.json();
|
|
69
69
|
}
|
|
70
|
-
function
|
|
70
|
+
function T(e, t) {
|
|
71
71
|
const n = e.find((r) => r.artifactId === t);
|
|
72
72
|
if (!n)
|
|
73
73
|
throw new Error(
|
|
@@ -75,33 +75,33 @@ function v(e, t) {
|
|
|
75
75
|
);
|
|
76
76
|
return n.version;
|
|
77
77
|
}
|
|
78
|
-
function
|
|
79
|
-
return window[
|
|
78
|
+
function U() {
|
|
79
|
+
return window[_];
|
|
80
80
|
}
|
|
81
|
-
function
|
|
82
|
-
window[
|
|
81
|
+
function R(e) {
|
|
82
|
+
window[_] = e;
|
|
83
83
|
}
|
|
84
|
-
const
|
|
84
|
+
const V = {
|
|
85
85
|
staticVersionsUrl: "https://www.wixapis.com/web50-server/static-versions",
|
|
86
86
|
tokensCdnBase: "https://static.parastorage.com/services/web50-server-ui",
|
|
87
87
|
tokensArtifactId: "com.wixpress.web50-server-ui",
|
|
88
88
|
tokensFileName: "prompt-input-tokens.css",
|
|
89
89
|
fallbackVersion: "1.459.0"
|
|
90
90
|
};
|
|
91
|
-
function
|
|
92
|
-
return { ...
|
|
91
|
+
function A(e) {
|
|
92
|
+
return { ...V, ...e ?? {} };
|
|
93
93
|
}
|
|
94
|
-
function
|
|
95
|
-
const { tokensCdnBase: n, tokensFileName: r } =
|
|
94
|
+
function D(e, t) {
|
|
95
|
+
const { tokensCdnBase: n, tokensFileName: r } = A(t);
|
|
96
96
|
return `${n}/${e}/${r}`;
|
|
97
97
|
}
|
|
98
|
-
async function
|
|
99
|
-
const t =
|
|
98
|
+
async function B(e) {
|
|
99
|
+
const t = A(e);
|
|
100
100
|
try {
|
|
101
|
-
const n =
|
|
102
|
-
if (n) return
|
|
103
|
-
const r = await
|
|
104
|
-
return
|
|
101
|
+
const n = U();
|
|
102
|
+
if (n) return T(n, t.tokensArtifactId);
|
|
103
|
+
const r = await H(t.staticVersionsUrl);
|
|
104
|
+
return R(r), T(r, t.tokensArtifactId);
|
|
105
105
|
} catch (n) {
|
|
106
106
|
return console.warn(
|
|
107
107
|
"[Web5Embed] Failed to resolve prompt token version, using fallback:",
|
|
@@ -109,80 +109,121 @@ async function V(e) {
|
|
|
109
109
|
), t.fallbackVersion;
|
|
110
110
|
}
|
|
111
111
|
}
|
|
112
|
-
async function
|
|
113
|
-
const t = await
|
|
114
|
-
return
|
|
112
|
+
async function $(e) {
|
|
113
|
+
const t = await B(e);
|
|
114
|
+
return D(t, e);
|
|
115
115
|
}
|
|
116
|
-
async function
|
|
116
|
+
async function le(e, t) {
|
|
117
117
|
if (e.querySelector(
|
|
118
118
|
'link[data-web5-prompt-input-tokens="true"]'
|
|
119
119
|
)) return;
|
|
120
120
|
const r = document.createElement("link");
|
|
121
|
-
r.rel = "stylesheet", r.dataset.web5PromptInputTokens = "true", r.href = await
|
|
121
|
+
r.rel = "stylesheet", r.dataset.web5PromptInputTokens = "true", r.href = await $(t), e.prepend(r);
|
|
122
122
|
}
|
|
123
|
-
const
|
|
123
|
+
const de = `
|
|
124
124
|
<svg class="web5-submit-icon" xmlns="http://www.w3.org/2000/svg" viewBox="0 0 16 16" fill="none" aria-hidden="true">
|
|
125
125
|
<path d="M13.0306 7.53114C12.9609 7.60106 12.8781 7.65654 12.787 7.69439C12.6958 7.73224 12.5981 7.75173 12.4993 7.75173C12.4006 7.75173 12.3029 7.73224 12.2117 7.69439C12.1206 7.65654 12.0378 7.60106 11.9681 7.53114L8.74997 4.31301V13.5005C8.74997 13.6994 8.67095 13.8902 8.5303 14.0308C8.38965 14.1715 8.19888 14.2505 7.99997 14.2505C7.80106 14.2505 7.61029 14.1715 7.46964 14.0308C7.32899 13.8902 7.24997 13.6994 7.24997 13.5005V4.31301L4.0306 7.53114C3.8897 7.67203 3.69861 7.75119 3.49935 7.75119C3.30009 7.75119 3.10899 7.67203 2.9681 7.53114C2.8272 7.39024 2.74805 7.19915 2.74805 6.99989C2.74805 6.80063 2.8272 6.60953 2.9681 6.46864L7.4681 1.96864C7.53778 1.89872 7.62057 1.84324 7.71173 1.80539C7.8029 1.76753 7.90064 1.74805 7.99935 1.74805C8.09806 1.74805 8.1958 1.76753 8.28696 1.80539C8.37813 1.84324 8.46092 1.89872 8.5306 1.96864L13.0306 6.46864C13.1005 6.53832 13.156 6.62111 13.1938 6.71227C13.2317 6.80344 13.2512 6.90118 13.2512 6.99989C13.2512 7.0986 13.2317 7.19634 13.1938 7.2875C13.156 7.37867 13.1005 7.46146 13.0306 7.53114Z" fill="currentColor" />
|
|
126
126
|
</svg>
|
|
127
127
|
`;
|
|
128
|
-
function
|
|
128
|
+
function W(e) {
|
|
129
129
|
return `${e}?initialQuestion=`;
|
|
130
130
|
}
|
|
131
|
-
function
|
|
131
|
+
function fe(e) {
|
|
132
132
|
return e.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
133
133
|
}
|
|
134
|
-
const
|
|
135
|
-
|
|
134
|
+
const K = "https://www.wixapis.com/page-enrichment/v1/page-meta-data/chips", S = 5e3, q = "https://www.wixapis.com/wix-assistant-web5/v1/turn", j = "https://www.wixapis.com/web50-turn-agent/v1/visitor/placements", J = "turnEngine", G = "web5_turn_engine";
|
|
135
|
+
function Y() {
|
|
136
|
+
const e = (t) => t === "classic" || t === "agent";
|
|
137
|
+
try {
|
|
138
|
+
const t = new URLSearchParams(window.location.search).get(
|
|
139
|
+
J
|
|
140
|
+
);
|
|
141
|
+
if (e(t)) return t === "agent";
|
|
142
|
+
} catch {
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
return localStorage.getItem(G) === "agent";
|
|
146
|
+
} catch {
|
|
147
|
+
return !1;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
const v = "pdpChips";
|
|
151
|
+
async function we(e, t) {
|
|
136
152
|
if (t.conversation?.web5Id)
|
|
137
|
-
return
|
|
153
|
+
return X({
|
|
138
154
|
...t.conversation,
|
|
139
155
|
timeoutMs: t.timeoutMs,
|
|
140
156
|
fetchImpl: t.fetchImpl
|
|
141
157
|
});
|
|
142
|
-
const n = t.endpoint ??
|
|
158
|
+
const n = t.endpoint ?? K, r = t.timeoutMs ?? S, i = k(t.fetchImpl), s = new AbortController(), a = setTimeout(() => s.abort(), r);
|
|
143
159
|
try {
|
|
144
|
-
const
|
|
160
|
+
const o = await i(
|
|
145
161
|
`${n}?url=${encodeURIComponent(e)}&sessionId=${encodeURIComponent(
|
|
146
162
|
t.sessionId
|
|
147
163
|
)}`,
|
|
148
164
|
{ signal: s.signal }
|
|
149
165
|
);
|
|
150
|
-
if (!
|
|
151
|
-
throw new Error(`HTTP ${
|
|
152
|
-
return (await
|
|
166
|
+
if (!o.ok)
|
|
167
|
+
throw new Error(`HTTP ${o.status}`);
|
|
168
|
+
return (await o.json()).chips?.map((u) => u.label).filter(Boolean) ?? [];
|
|
153
169
|
} finally {
|
|
154
170
|
clearTimeout(a);
|
|
155
171
|
}
|
|
156
172
|
}
|
|
157
|
-
async function
|
|
158
|
-
const t = e.endpoint ??
|
|
173
|
+
async function X(e) {
|
|
174
|
+
const t = Y(), n = e.endpoint ?? (t ? j : q), r = e.timeoutMs ?? S, i = k(e.fetchImpl), s = new AbortController(), a = setTimeout(() => s.abort(), r);
|
|
159
175
|
try {
|
|
160
|
-
const
|
|
176
|
+
const o = e.handle ? { handle: e.handle } : void 0, c = {
|
|
161
177
|
...e.sessionId ? { sessionId: e.sessionId } : {},
|
|
162
178
|
...e.web5Id ? { parentMessageId: e.web5Id } : {},
|
|
163
|
-
placement:
|
|
164
|
-
...
|
|
165
|
-
},
|
|
179
|
+
placement: v,
|
|
180
|
+
...o ? { additionalData: o } : {}
|
|
181
|
+
}, u = {
|
|
182
|
+
placement: v,
|
|
183
|
+
...e.sessionId ? { sessionId: e.sessionId } : {},
|
|
184
|
+
...e.web5Id ? { parentMessageId: e.web5Id } : {},
|
|
185
|
+
...e.handle ? { handle: e.handle } : {}
|
|
186
|
+
}, f = await i(n, {
|
|
166
187
|
method: "POST",
|
|
167
188
|
headers: {
|
|
168
189
|
"Content-Type": "application/json",
|
|
169
190
|
Accept: "text/event-stream"
|
|
170
191
|
},
|
|
171
|
-
body: JSON.stringify(
|
|
172
|
-
signal:
|
|
192
|
+
body: JSON.stringify(t ? u : c),
|
|
193
|
+
signal: s.signal
|
|
173
194
|
});
|
|
174
|
-
if (!
|
|
175
|
-
throw new Error(`HTTP ${
|
|
176
|
-
|
|
177
|
-
|
|
195
|
+
if (!f.ok)
|
|
196
|
+
throw new Error(`HTTP ${f.status}`);
|
|
197
|
+
if (t)
|
|
198
|
+
return I(Q(await f.text()));
|
|
199
|
+
const l = await f.text();
|
|
200
|
+
return I(z(l));
|
|
178
201
|
} finally {
|
|
179
|
-
clearTimeout(
|
|
202
|
+
clearTimeout(a);
|
|
180
203
|
}
|
|
181
204
|
}
|
|
182
|
-
function
|
|
205
|
+
function k(e) {
|
|
183
206
|
return e || (typeof window < "u" ? fetch.bind(window) : fetch);
|
|
184
207
|
}
|
|
185
|
-
function
|
|
208
|
+
function Q(e) {
|
|
209
|
+
for (const t of e.replace(/\r\n?/g, `
|
|
210
|
+
`).split(`
|
|
211
|
+
|
|
212
|
+
`)) {
|
|
213
|
+
const n = t.split(`
|
|
214
|
+
`).filter((r) => r.startsWith("data:")).map((r) => r.slice(5).replace(/^ /, "")).join(`
|
|
215
|
+
`);
|
|
216
|
+
if (n)
|
|
217
|
+
try {
|
|
218
|
+
const r = JSON.parse(n);
|
|
219
|
+
if (r.type === "completed" && typeof r.markdown == "string")
|
|
220
|
+
return r.markdown;
|
|
221
|
+
} catch {
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
return "";
|
|
225
|
+
}
|
|
226
|
+
function z(e) {
|
|
186
227
|
let t = e.trim();
|
|
187
228
|
if (!t) return "";
|
|
188
229
|
t.endsWith(",") && (t = t.slice(0, -1)), t.startsWith("[") || (t = `[${t}`), t.endsWith("]") || (t += "]");
|
|
@@ -190,14 +231,14 @@ function j(e) {
|
|
|
190
231
|
const n = JSON.parse(t);
|
|
191
232
|
if (!Array.isArray(n)) return "";
|
|
192
233
|
const r = n.find(
|
|
193
|
-
(
|
|
234
|
+
(i) => typeof i?.completed?.markdown == "string"
|
|
194
235
|
)?.completed?.markdown;
|
|
195
|
-
return r || n.map((
|
|
236
|
+
return r || n.map((i) => typeof i?.markdown == "string" ? i.markdown : "").join("");
|
|
196
237
|
} catch {
|
|
197
238
|
return "";
|
|
198
239
|
}
|
|
199
240
|
}
|
|
200
|
-
function
|
|
241
|
+
function I(e) {
|
|
201
242
|
const t = e.trim().replace(/^```(?:json)?\s*/i, "").replace(/\s*```$/, "").trim();
|
|
202
243
|
if (!t) return [];
|
|
203
244
|
try {
|
|
@@ -206,7 +247,7 @@ function J(e) {
|
|
|
206
247
|
return [];
|
|
207
248
|
}
|
|
208
249
|
}
|
|
209
|
-
function
|
|
250
|
+
function me(e) {
|
|
210
251
|
if (e instanceof HTMLElement) return e;
|
|
211
252
|
if (typeof e == "string") {
|
|
212
253
|
const r = document.querySelector(e);
|
|
@@ -217,43 +258,43 @@ function ue(e) {
|
|
|
217
258
|
const t = document.currentScript, n = document.createElement("div");
|
|
218
259
|
return t?.parentElement ? t.parentElement.insertBefore(n, t) : document.body.appendChild(n), n;
|
|
219
260
|
}
|
|
220
|
-
function
|
|
261
|
+
function pe(e) {
|
|
221
262
|
return e ? new URLSearchParams(window.location.search).has(e) : !0;
|
|
222
263
|
}
|
|
223
|
-
function
|
|
264
|
+
function he(e, t = []) {
|
|
224
265
|
return !(Array.isArray(e) ? e : e != null ? [e] : t).includes(window.location.pathname);
|
|
225
266
|
}
|
|
226
|
-
function
|
|
267
|
+
function Z(e) {
|
|
227
268
|
if (!e) return {};
|
|
228
269
|
const t = {}, n = e.getAttribute("data-target");
|
|
229
270
|
n && (t.target = n);
|
|
230
271
|
const r = e.getAttribute("data-placeholder");
|
|
231
272
|
r && (t.placeholder = r);
|
|
232
|
-
const
|
|
233
|
-
|
|
273
|
+
const i = e.getAttribute("data-base-url");
|
|
274
|
+
i && (t.baseUrl = i);
|
|
234
275
|
const s = e.getAttribute("data-require-param");
|
|
235
276
|
s && (t.requireParam = s);
|
|
236
277
|
const a = e.getAttribute("data-suggestions");
|
|
237
278
|
if (a)
|
|
238
279
|
try {
|
|
239
|
-
const
|
|
240
|
-
Array.isArray(
|
|
280
|
+
const o = JSON.parse(a);
|
|
281
|
+
Array.isArray(o) && o.length && (t.suggestions = o);
|
|
241
282
|
} catch {
|
|
242
283
|
console.warn("[Web5Embed] Invalid data-suggestions JSON, ignoring.");
|
|
243
284
|
}
|
|
244
285
|
return t;
|
|
245
286
|
}
|
|
246
|
-
function
|
|
247
|
-
const t =
|
|
287
|
+
function ge(e) {
|
|
288
|
+
const t = Z(e);
|
|
248
289
|
if (!e) return t;
|
|
249
290
|
const n = e.getAttribute("data-visibility-mode");
|
|
250
291
|
(n === "always" || n === "after-target") && (t.visibilityMode = n);
|
|
251
292
|
const r = e.getAttribute("data-show-after-target");
|
|
252
293
|
r && (t.showAfterTarget = r);
|
|
253
|
-
const
|
|
254
|
-
return
|
|
294
|
+
const i = e.getAttribute("data-exclude-paths");
|
|
295
|
+
return i && (t.excludePaths = i.includes(",") ? i.split(",").map((s) => s.trim()) : i), t;
|
|
255
296
|
}
|
|
256
|
-
function
|
|
297
|
+
function be(e) {
|
|
257
298
|
if (typeof window > "u") return;
|
|
258
299
|
const t = window.__web5Loader__;
|
|
259
300
|
if (!t) {
|
|
@@ -265,18 +306,18 @@ function we(e) {
|
|
|
265
306
|
const n = async (r) => e.mount(r, e.parseOptions(r.options));
|
|
266
307
|
t.register(e.widgetId, n);
|
|
267
308
|
}
|
|
268
|
-
function
|
|
309
|
+
function ye(e) {
|
|
269
310
|
return (t, n) => {
|
|
270
311
|
const r = n.variant;
|
|
271
312
|
if (!r || r === "default")
|
|
272
313
|
return e.default(t, n);
|
|
273
|
-
const
|
|
274
|
-
return
|
|
314
|
+
const i = e.variants?.[r];
|
|
315
|
+
return i ? i(t, n) : (console.warn(
|
|
275
316
|
`[Web5Embed] unknown variant "${r}" — falling back to default`
|
|
276
317
|
), e.default(t, n));
|
|
277
318
|
};
|
|
278
319
|
}
|
|
279
|
-
function
|
|
320
|
+
function Ee(e) {
|
|
280
321
|
const t = (n) => e?.[n];
|
|
281
322
|
return {
|
|
282
323
|
isEnabled: (n) => {
|
|
@@ -286,21 +327,21 @@ function pe(e) {
|
|
|
286
327
|
get: t
|
|
287
328
|
};
|
|
288
329
|
}
|
|
289
|
-
function
|
|
330
|
+
function Ce(e) {
|
|
290
331
|
const {
|
|
291
332
|
input: t,
|
|
292
333
|
wrapper: n,
|
|
293
334
|
multilineClass: r,
|
|
294
|
-
maxHeightPx:
|
|
335
|
+
maxHeightPx: i,
|
|
295
336
|
multilineThresholdMultiplier: s = 1,
|
|
296
337
|
fallbackLineHeightPx: a = 32
|
|
297
338
|
} = e;
|
|
298
339
|
return {
|
|
299
340
|
sync() {
|
|
300
341
|
if (!n) return;
|
|
301
|
-
const
|
|
342
|
+
const o = window.getComputedStyle(t), c = Number.parseFloat(o.lineHeight) || a;
|
|
302
343
|
t.style.height = "auto";
|
|
303
|
-
const u = t.value.trim().length === 0 ? c : Math.min(Math.max(t.scrollHeight, c),
|
|
344
|
+
const u = t.value.trim().length === 0 ? c : Math.min(Math.max(t.scrollHeight, c), i);
|
|
304
345
|
t.style.height = `${u}px`, n.classList.toggle(
|
|
305
346
|
r,
|
|
306
347
|
u > c * s
|
|
@@ -308,17 +349,17 @@ function he(e) {
|
|
|
308
349
|
}
|
|
309
350
|
};
|
|
310
351
|
}
|
|
311
|
-
const
|
|
312
|
-
function
|
|
313
|
-
const t = e.thresholdPx ??
|
|
352
|
+
const ee = 400;
|
|
353
|
+
function Te(e = {}) {
|
|
354
|
+
const t = e.thresholdPx ?? ee;
|
|
314
355
|
let n = !1;
|
|
315
356
|
function r() {
|
|
316
|
-
const
|
|
317
|
-
return
|
|
357
|
+
const i = document.documentElement, s = window.scrollY || i.scrollTop || 0, a = s + window.innerHeight, o = i.scrollHeight - a;
|
|
358
|
+
return i.scrollHeight > window.innerHeight + t && s > 0 && o <= t;
|
|
318
359
|
}
|
|
319
360
|
return {
|
|
320
|
-
evaluate(
|
|
321
|
-
return !
|
|
361
|
+
evaluate(i) {
|
|
362
|
+
return !i.isCoordinatorVisible() || !r() ? (n = !1, !1) : i.hasFocusInside() || n ? i.isCollapsed() : !0;
|
|
322
363
|
},
|
|
323
364
|
markManuallyExpanded() {
|
|
324
365
|
n = !0;
|
|
@@ -328,19 +369,19 @@ function ge(e = {}) {
|
|
|
328
369
|
}
|
|
329
370
|
};
|
|
330
371
|
}
|
|
331
|
-
function
|
|
372
|
+
function ve(e) {
|
|
332
373
|
if (!e.baseUrl)
|
|
333
374
|
throw new Error(
|
|
334
375
|
"[Web5Embed] createSubmitFlow requires a non-empty baseUrl."
|
|
335
376
|
);
|
|
336
|
-
const t =
|
|
377
|
+
const t = W(e.baseUrl), n = e.windowTarget ?? "_self";
|
|
337
378
|
return {
|
|
338
379
|
open(r) {
|
|
339
380
|
return window.open(t + encodeURIComponent(r), n), !0;
|
|
340
381
|
}
|
|
341
382
|
};
|
|
342
383
|
}
|
|
343
|
-
const
|
|
384
|
+
const te = 100, ne = 0.5, re = 250, oe = 10, ie = 60, se = "--web5-host-bottom-inset";
|
|
344
385
|
function y() {
|
|
345
386
|
if (typeof document > "u" || typeof window > "u")
|
|
346
387
|
return [];
|
|
@@ -350,106 +391,106 @@ function y() {
|
|
|
350
391
|
(n === "fixed" || n === "sticky") && e.push(t);
|
|
351
392
|
}), e;
|
|
352
393
|
}
|
|
353
|
-
function
|
|
394
|
+
function ae(e, t) {
|
|
354
395
|
if (typeof document > "u" || typeof window > "u")
|
|
355
396
|
return 0;
|
|
356
397
|
const n = t ?? y(), r = window.innerWidth / 2;
|
|
357
|
-
let
|
|
398
|
+
let i = 0;
|
|
358
399
|
for (const s of n) {
|
|
359
400
|
if (e != null && (e.contains(s) || s.contains(e)))
|
|
360
401
|
continue;
|
|
361
402
|
const a = window.getComputedStyle(s);
|
|
362
403
|
if (a.position !== "fixed" && a.position !== "sticky" || a.visibility === "hidden" || a.bottom === "auto")
|
|
363
404
|
continue;
|
|
364
|
-
const
|
|
365
|
-
if (!Number.isFinite(
|
|
405
|
+
const o = Number.parseFloat(a.bottom);
|
|
406
|
+
if (!Number.isFinite(o) || o > te)
|
|
366
407
|
continue;
|
|
367
408
|
const c = s.getBoundingClientRect();
|
|
368
409
|
if (c.height <= 0 || c.left > r || c.right < r)
|
|
369
410
|
continue;
|
|
370
411
|
const u = window.innerHeight - c.top;
|
|
371
|
-
u <= 0 || u > window.innerHeight *
|
|
412
|
+
u <= 0 || u > window.innerHeight * ne || (i = Math.max(i, u));
|
|
372
413
|
}
|
|
373
|
-
return Math.round(
|
|
414
|
+
return Math.round(i);
|
|
374
415
|
}
|
|
375
|
-
function
|
|
416
|
+
function Ie(e, t = {}) {
|
|
376
417
|
if (typeof window > "u")
|
|
377
418
|
return () => {
|
|
378
419
|
};
|
|
379
420
|
const n = t.exclude === void 0 ? e : t.exclude;
|
|
380
|
-
let r = y(),
|
|
421
|
+
let r = y(), i = null, s = 0, a = !1, o = 0, c = 0, u = 0, f = 0, l = !1;
|
|
381
422
|
const h = () => {
|
|
382
|
-
const
|
|
383
|
-
return
|
|
384
|
-
},
|
|
385
|
-
if (s = 0,
|
|
423
|
+
const d = ae(n, r);
|
|
424
|
+
return d === i ? !1 : (i = d, e.style.setProperty(se, `${d}px`), !0);
|
|
425
|
+
}, w = () => {
|
|
426
|
+
if (s = 0, l) {
|
|
386
427
|
a = !1;
|
|
387
428
|
return;
|
|
388
429
|
}
|
|
389
|
-
if (
|
|
430
|
+
if (o = h() ? 0 : o + 1, c -= 1, o >= oe || c <= 0) {
|
|
390
431
|
a = !1;
|
|
391
432
|
return;
|
|
392
433
|
}
|
|
393
|
-
s = window.requestAnimationFrame(
|
|
434
|
+
s = window.requestAnimationFrame(w);
|
|
394
435
|
}, g = () => {
|
|
395
|
-
|
|
436
|
+
l || (o = 0, c = ie, !a && (a = !0, s = window.requestAnimationFrame(w)));
|
|
396
437
|
}, E = () => {
|
|
397
|
-
u = 0, !
|
|
398
|
-
},
|
|
399
|
-
if (
|
|
438
|
+
u = 0, !l && (f = Date.now(), r = y(), g());
|
|
439
|
+
}, L = () => {
|
|
440
|
+
if (l || u !== 0)
|
|
400
441
|
return;
|
|
401
|
-
const
|
|
402
|
-
if (
|
|
442
|
+
const d = re - (Date.now() - f);
|
|
443
|
+
if (d <= 0) {
|
|
403
444
|
E();
|
|
404
445
|
return;
|
|
405
446
|
}
|
|
406
|
-
u = window.setTimeout(E,
|
|
407
|
-
},
|
|
408
|
-
g(),
|
|
447
|
+
u = window.setTimeout(E, d);
|
|
448
|
+
}, m = () => {
|
|
449
|
+
g(), L();
|
|
409
450
|
};
|
|
410
|
-
h(), g(), window.addEventListener("resize",
|
|
411
|
-
const
|
|
451
|
+
h(), g(), window.addEventListener("resize", m, { passive: !0 }), window.addEventListener("orientationchange", m, { passive: !0 });
|
|
452
|
+
const M = (d) => n != null && d.every((C) => C.target instanceof Node && n.contains(C.target));
|
|
412
453
|
let b;
|
|
413
|
-
return typeof MutationObserver < "u" && document.body != null && (b = new MutationObserver((
|
|
414
|
-
|
|
454
|
+
return typeof MutationObserver < "u" && document.body != null && (b = new MutationObserver((d) => {
|
|
455
|
+
M(d) || m();
|
|
415
456
|
}), b.observe(document.body, {
|
|
416
457
|
childList: !0,
|
|
417
458
|
subtree: !0,
|
|
418
459
|
attributes: !0
|
|
419
460
|
})), () => {
|
|
420
|
-
|
|
461
|
+
l = !0, a && (window.cancelAnimationFrame(s), a = !1, s = 0), u !== 0 && (window.clearTimeout(u), u = 0), window.removeEventListener("resize", m), window.removeEventListener("orientationchange", m), b?.disconnect();
|
|
421
462
|
};
|
|
422
463
|
}
|
|
423
464
|
export {
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
465
|
+
P as DEFAULT_STATIC_VERSIONS_URL,
|
|
466
|
+
se as HOST_BOTTOM_INSET_VAR,
|
|
467
|
+
ue as __resetFocusShortcutCoordinatorForTests,
|
|
468
|
+
le as attachPromptInputTokensStylesheet,
|
|
469
|
+
W as buildUrl,
|
|
470
|
+
R as cacheVersions,
|
|
471
|
+
Te as createCollapseController,
|
|
472
|
+
Ee as createFeatureToggleReader,
|
|
473
|
+
Ce as createInputHeightSync,
|
|
474
|
+
ve as createSubmitFlow,
|
|
475
|
+
ye as createVariantMount,
|
|
476
|
+
fe as escapeHtml,
|
|
477
|
+
we as fetchChipSuggestions,
|
|
478
|
+
X as fetchContextualChips,
|
|
479
|
+
H as fetchStaticVersions,
|
|
480
|
+
T as findVersion,
|
|
481
|
+
U as getCachedVersions,
|
|
482
|
+
ce as getFocusShortcutCoordinator,
|
|
483
|
+
D as getPromptInputTokensUrl,
|
|
484
|
+
ae as measureHostBottomInset,
|
|
485
|
+
Z as readBaseConfigFromScript,
|
|
486
|
+
ge as readBottomConfigFromScript,
|
|
487
|
+
be as registerWeb5Widget,
|
|
488
|
+
$ as resolvePromptInputTokensUrl,
|
|
489
|
+
B as resolvePromptInputTokensVersion,
|
|
490
|
+
me as resolveTarget,
|
|
491
|
+
de as sendIconSvg,
|
|
492
|
+
pe as shouldInit,
|
|
493
|
+
he as shouldInitForPath,
|
|
494
|
+
Ie as trackHostBottomInset
|
|
454
495
|
};
|
|
455
496
|
//# sourceMappingURL=index.js.map
|