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