@levo-so/site-runtime 0.3.1 → 0.3.8
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/CollectionField-C-6a1ud4.js +270 -0
- package/{CollectionInput-B1qV4QEH.js → CollectionInput-BJ__qcbk.js} +40 -40
- package/DateTimeWidget-hFjcn3o6.js +255 -0
- package/Dialog-dT7y641z.js +130 -0
- package/KBChatWidget-ClHFDgJ5.js +1026 -0
- package/LevoProvider-Bsjkcwc8.js +20 -0
- package/PhoneWidget-BmBO-kvA.js +99 -0
- package/{Popover-q5dL7y0W.js → Popover-3N88sRp4.js} +20 -20
- package/{PopupRenderer-Bncp54gB-DuCULkBK.js → PopupBody-DZVwDLkg-Cfy3lWGs.js} +201 -910
- package/PopupRenderer-BjW1jg70-W2y-PEPH.js +387 -0
- package/{RichTextWidget-D-mGlES0.js → RichTextWidget-DkKHEq4j.js} +142 -141
- package/ThemeProvider-DutrjSTF.js +116 -0
- package/{Tooltip-BIgrpetu.js → Tooltip-CQB0LyxK.js} +20 -20
- package/VerifyButton-BUT70lgz.js +192 -0
- package/{theme.cssm-2YTdd8Yh.js → createThemeExtension-4AUn51iJ.js} +2 -2
- package/dist-CRDgdAkQ.js +3631 -0
- package/dist-DPmVG7VB.js +79 -0
- package/index.d.ts +575 -3
- package/index.js +1217 -722
- package/inlineBaseTheme-BB9e6h5f.js +9 -0
- package/inlineCollectionTheme-CWcMCUti.js +19 -0
- package/{kbChat-AUJxjURc.js → kbChat-C00LVlxP.js} +53 -48
- package/{nodeAlignment-Cn6xNtOP.js → nodeAlignment-BnJljFlw.js} +13 -13
- package/package.json +9 -9
- package/pillChrome-BAu5AfCT.js +30 -0
- package/popupState-JmpeKzgM-qhNTV79U.js +229 -0
- package/popups.js +1 -1
- package/react-CV3jf2mc.js +74 -0
- package/rteTheme.cssm-xg0gJ28J.js +4 -0
- package/styles.css +1 -1
- package/theme.cssm-DUzmx76l.js +4 -0
- package/{inlineCollectionTheme-D2w17LHX.js → themeVars.cssm-ByhhC2Jm.js} +18 -33
- package/usePopupRedirect-BThP_YPW-COUseDik.js +80 -0
- package/CollectionField-CzS-34zx.js +0 -270
- package/DateTimeWidget-C1jHOtz7.js +0 -255
- package/Dialog-CzVhHLEY.js +0 -145
- package/KBChatWidget-D7F9LRwI.js +0 -1078
- package/PhoneWidget-_nw97rkI.js +0 -99
- package/ThemeProvider-BQmIB5tr.js +0 -116
- package/VerifyButton-BkP98H17.js +0 -191
- package/dist-CJknSbJK.js +0 -80
- package/dist-DBbiX2ST.js +0 -3556
- package/inlineBaseTheme-DS-AfUHi.js +0 -9
- package/pillChrome-AhXOWXIb.js +0 -20
- /package/{es-iCqKQf1c.js → es-CztjLuNy.js} +0 -0
|
@@ -0,0 +1,1026 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
import { _ as e, a as t, c as n, f as r, g as i, h as a, i as o, l as s, m as c, n as l, o as u, r as d, s as f, t as p, u as m, v as h } from "./pillChrome-BAu5AfCT.js";
|
|
3
|
+
import { Fragment as g, jsx as _, jsxs as v } from "react/jsx-runtime";
|
|
4
|
+
import { Children as y, createContext as b, isValidElement as x, useCallback as S, useContext as C, useEffect as w, useLayoutEffect as T, useRef as E, useState as D } from "react";
|
|
5
|
+
import { ArrowUp as O, Check as k, ChevronDown as ee, Copy as A, MessageSquarePlus as j, Mic as te, RefreshCw as M, Sparkles as ne, Square as N, X as P } from "lucide-react";
|
|
6
|
+
import { ActionBarPrimitive as F, AssistantRuntimeProvider as I, ComposerPrimitive as L, MessagePrimitive as R, ThreadPrimitive as z, WebSpeechDictationAdapter as re, useAui as B, useAuiState as V } from "@assistant-ui/react";
|
|
7
|
+
import { AssistantChatTransport as ie, useChatRuntime as ae } from "@assistant-ui/react-ai-sdk";
|
|
8
|
+
import { MarkdownTextPrimitive as oe } from "@assistant-ui/react-markdown";
|
|
9
|
+
import se from "remark-gfm";
|
|
10
|
+
//#region ../../libraries/ai-chat/src/FollowUpChips.tsx
|
|
11
|
+
var H = ({ chips: e, onSelect: t, size: n = "comfortable", className: r, chipClassName: i }) => {
|
|
12
|
+
if (e.length === 0) return null;
|
|
13
|
+
let a = [
|
|
14
|
+
"rounded-full border border-zinc-200 bg-white text-zinc-700",
|
|
15
|
+
"transition-all duration-150 hover:border-zinc-300 hover:bg-zinc-50 hover:text-zinc-900 active:scale-95",
|
|
16
|
+
n === "compact" ? "px-2.5 py-1 text-[11px] leading-none" : "px-3.5 py-1.5 text-xs"
|
|
17
|
+
].join(" ");
|
|
18
|
+
return /* @__PURE__ */ _("div", {
|
|
19
|
+
className: ["flex flex-wrap gap-1.5", r].filter(Boolean).join(" "),
|
|
20
|
+
children: e.map((e, n) => /* @__PURE__ */ _("button", {
|
|
21
|
+
type: "button",
|
|
22
|
+
onClick: () => t(e),
|
|
23
|
+
className: ["ai-chat-chip", i ?? a].join(" "),
|
|
24
|
+
style: { animationDelay: `${n * 60}ms` },
|
|
25
|
+
children: e
|
|
26
|
+
}, `${n}-${e}`))
|
|
27
|
+
});
|
|
28
|
+
}, ce = ({ api: e, headers: t, credentials: n, getBody: r, getHeaders: i, onSendStart: a }) => new ie({
|
|
29
|
+
api: e,
|
|
30
|
+
headers: t,
|
|
31
|
+
credentials: n,
|
|
32
|
+
prepareSendMessagesRequest: async (e) => (a?.(), {
|
|
33
|
+
body: r(e),
|
|
34
|
+
headers: {
|
|
35
|
+
...t,
|
|
36
|
+
...i?.(e)
|
|
37
|
+
}
|
|
38
|
+
})
|
|
39
|
+
}), le = (e) => {
|
|
40
|
+
let t = E(null), n = E(null);
|
|
41
|
+
return n.current !== (e ?? null) && (n.current = e ?? null, t.current = null), {
|
|
42
|
+
conversationIdRef: t,
|
|
43
|
+
handleFinish: S(({ message: e }) => {
|
|
44
|
+
let n = e.metadata;
|
|
45
|
+
if (!n || typeof n != "object") return;
|
|
46
|
+
let r = n.conversation_id;
|
|
47
|
+
if (typeof r != "string") return;
|
|
48
|
+
let i = r.trim();
|
|
49
|
+
i.length !== 0 && t.current !== i && (t.current = i);
|
|
50
|
+
}, []),
|
|
51
|
+
reset: S(() => {
|
|
52
|
+
t.current = null;
|
|
53
|
+
}, [])
|
|
54
|
+
};
|
|
55
|
+
}, ue = (e = []) => {
|
|
56
|
+
let [t, n] = D(e);
|
|
57
|
+
return {
|
|
58
|
+
followUps: t,
|
|
59
|
+
setFollowUps: n,
|
|
60
|
+
clearOnSend: S(() => n([]), []),
|
|
61
|
+
handleData: S((e) => {
|
|
62
|
+
if (e.type !== "data-follow_ups") return !1;
|
|
63
|
+
let t = e.data?.suggestions;
|
|
64
|
+
return Array.isArray(t) ? (n(t.filter((e) => typeof e == "string")), !0) : !1;
|
|
65
|
+
}, [])
|
|
66
|
+
};
|
|
67
|
+
}, de = (e) => e instanceof Error && e.message.includes("intelligence.site_agent.NO_ACTIVE_AGENT"), U = b({ agentUnavailable: !1 }), fe = () => C(U), pe = (...e) => e.filter(Boolean).join(" "), me = "inline-flex items-center justify-center gap-1.5 transition-all duration-200", he = "rounded-full border border-zinc-200 bg-white/95 px-3 py-1.5 font-medium text-xs text-zinc-500 shadow-lg backdrop-blur-sm hover:text-zinc-900", ge = ({ onClick: e, isRunning: t = !1, iconOnly: n = !1, className: r = he }) => /* @__PURE__ */ v("button", {
|
|
68
|
+
type: "button",
|
|
69
|
+
"aria-label": "Scroll to bottom",
|
|
70
|
+
onClick: e,
|
|
71
|
+
className: pe(me, r),
|
|
72
|
+
children: [/* @__PURE__ */ _(ee, { className: "h-3 w-3" }), !n && (t ? "New messages" : "Scroll to bottom")]
|
|
73
|
+
}), _e = ({ endpoint: e, headers: t, fallback: n, enabled: r = !0 }) => {
|
|
74
|
+
let [i, a] = D(null), o = t ? JSON.stringify(t) : "", s = E(t);
|
|
75
|
+
s.current = t;
|
|
76
|
+
let c = E(n);
|
|
77
|
+
return c.current = n, w(() => {
|
|
78
|
+
if (!r || !e) {
|
|
79
|
+
a([...c.current]);
|
|
80
|
+
return;
|
|
81
|
+
}
|
|
82
|
+
let t = new AbortController();
|
|
83
|
+
return fetch(e, {
|
|
84
|
+
method: "GET",
|
|
85
|
+
headers: s.current,
|
|
86
|
+
credentials: "include",
|
|
87
|
+
signal: t.signal
|
|
88
|
+
}).then(async (e) => {
|
|
89
|
+
if (!e.ok) {
|
|
90
|
+
let t = await e.text().catch(() => "");
|
|
91
|
+
throw Error(`Suggestions request failed: ${e.status} ${t.slice(0, 200)}`);
|
|
92
|
+
}
|
|
93
|
+
let t = (await e.json())?.suggestions;
|
|
94
|
+
if (!Array.isArray(t) || !t.every((e) => typeof e == "string")) throw Error("Suggestions response shape invalid");
|
|
95
|
+
return t;
|
|
96
|
+
}).then((e) => {
|
|
97
|
+
t.signal.aborted || a(e.length > 0 ? e : [...c.current]);
|
|
98
|
+
}).catch((e) => {
|
|
99
|
+
t.signal.aborted || e instanceof Error && e.name === "AbortError" || a([...c.current]);
|
|
100
|
+
}), () => t.abort();
|
|
101
|
+
}, [
|
|
102
|
+
e,
|
|
103
|
+
r,
|
|
104
|
+
o
|
|
105
|
+
]), i;
|
|
106
|
+
}, ve = 36, ye = 80, be = ({ viewportRef: e, isRunning: t, onRunStart: n, anchorOnRunStart: r = !0, atBottomThreshold: i }) => {
|
|
107
|
+
let a = E(!1), [o, s] = D(!0), c = E(n);
|
|
108
|
+
c.current = n;
|
|
109
|
+
let l = E(i);
|
|
110
|
+
return l.current = i, w(() => {
|
|
111
|
+
let n = a.current;
|
|
112
|
+
if (a.current = t, !t || n || (c.current?.(), !r)) return;
|
|
113
|
+
let i = null, o = null;
|
|
114
|
+
return i = requestAnimationFrame(() => {
|
|
115
|
+
o = requestAnimationFrame(() => {
|
|
116
|
+
let t = e.current;
|
|
117
|
+
if (!t) return;
|
|
118
|
+
let n = Math.max(0, t.scrollHeight - t.clientHeight - ve);
|
|
119
|
+
n > t.clientHeight * .3 && t.scrollTo({
|
|
120
|
+
top: n,
|
|
121
|
+
behavior: "smooth"
|
|
122
|
+
});
|
|
123
|
+
});
|
|
124
|
+
}), () => {
|
|
125
|
+
i !== null && cancelAnimationFrame(i), o !== null && cancelAnimationFrame(o);
|
|
126
|
+
};
|
|
127
|
+
}, [
|
|
128
|
+
t,
|
|
129
|
+
e,
|
|
130
|
+
r
|
|
131
|
+
]), w(() => {
|
|
132
|
+
let t = e.current;
|
|
133
|
+
if (!t) return;
|
|
134
|
+
let n = () => {
|
|
135
|
+
let e = l.current?.(t.clientHeight) ?? ye;
|
|
136
|
+
s(t.scrollHeight - t.scrollTop - t.clientHeight < e);
|
|
137
|
+
};
|
|
138
|
+
t.addEventListener("scroll", n, { passive: !0 });
|
|
139
|
+
let r = new ResizeObserver(n);
|
|
140
|
+
for (let e of t.children) r.observe(e);
|
|
141
|
+
return () => {
|
|
142
|
+
t.removeEventListener("scroll", n), r.disconnect();
|
|
143
|
+
};
|
|
144
|
+
}, [e]), {
|
|
145
|
+
isAtBottom: o,
|
|
146
|
+
scrollToBottom: () => {
|
|
147
|
+
let t = e.current;
|
|
148
|
+
t && t.scrollTo({
|
|
149
|
+
top: t.scrollHeight,
|
|
150
|
+
behavior: "smooth"
|
|
151
|
+
});
|
|
152
|
+
}
|
|
153
|
+
};
|
|
154
|
+
}, W = (...e) => e.filter(Boolean).join(" "), G = ({ onStop: e }) => /* @__PURE__ */ _("button", {
|
|
155
|
+
type: "button",
|
|
156
|
+
onClick: e,
|
|
157
|
+
"aria-label": "Stop generating",
|
|
158
|
+
className: "flex h-9 w-9 items-center justify-center rounded-md shadow-md transition-all duration-150 hover:scale-110 active:scale-95",
|
|
159
|
+
style: {
|
|
160
|
+
backgroundColor: "var(--color-brand, #0a0a0a)",
|
|
161
|
+
color: "var(--color-brand-foreground, #fff)"
|
|
162
|
+
},
|
|
163
|
+
children: /* @__PURE__ */ _(N, { className: "h-3.5 w-3.5 fill-current" })
|
|
164
|
+
}), K = () => /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _(L.If, {
|
|
165
|
+
dictation: !1,
|
|
166
|
+
children: /* @__PURE__ */ _(L.Dictate, {
|
|
167
|
+
className: "flex h-8 w-8 items-center justify-center rounded-md text-zinc-500 transition-colors hover:bg-zinc-100 hover:text-zinc-900",
|
|
168
|
+
children: /* @__PURE__ */ _(te, { className: "h-4 w-4" })
|
|
169
|
+
})
|
|
170
|
+
}), /* @__PURE__ */ _(L.If, {
|
|
171
|
+
dictation: !0,
|
|
172
|
+
children: /* @__PURE__ */ _(L.StopDictation, {
|
|
173
|
+
className: "flex h-8 w-8 animate-pulse items-center justify-center rounded-md bg-red-500/15 text-red-500 transition-colors hover:bg-red-500/25",
|
|
174
|
+
children: /* @__PURE__ */ _(N, { className: "h-3 w-3 fill-current" })
|
|
175
|
+
})
|
|
176
|
+
})] }), xe = () => /* @__PURE__ */ _(L.Send, {
|
|
177
|
+
"aria-label": "Send message",
|
|
178
|
+
className: "flex h-9 w-9 items-center justify-center rounded-md shadow-md transition-all duration-300 hover:scale-110 active:scale-95 disabled:cursor-not-allowed disabled:opacity-40 disabled:shadow-none disabled:hover:scale-100",
|
|
179
|
+
style: {
|
|
180
|
+
backgroundColor: "var(--color-brand, #0a0a0a)",
|
|
181
|
+
color: "var(--color-brand-foreground, #fff)"
|
|
182
|
+
},
|
|
183
|
+
children: /* @__PURE__ */ _(O, { className: "h-5 w-5 stroke-[2.5px]" })
|
|
184
|
+
}), Se = ({ variant: e, isRunning: t, onStop: n }) => {
|
|
185
|
+
let r = (e) => {
|
|
186
|
+
e.nativeEvent.isComposing || t && e.key === "Enter" && !e.shiftKey && e.preventDefault();
|
|
187
|
+
};
|
|
188
|
+
return e === "expanded" ? /* @__PURE__ */ v("div", {
|
|
189
|
+
className: "rounded-lg border border-zinc-200 bg-white shadow-sm transition-colors focus-within:border-[var(--color-brand,#a1a1aa)]",
|
|
190
|
+
children: [/* @__PURE__ */ _(L.Input, {
|
|
191
|
+
"data-ai-chat-composer": "",
|
|
192
|
+
className: W("ai-chat-textarea w-full resize-none overflow-y-auto bg-transparent px-6 pt-4 text-base text-zinc-900 leading-relaxed placeholder:text-zinc-500 focus:outline-none", "max-h-[160px]"),
|
|
193
|
+
placeholder: "Ask anything about this site…",
|
|
194
|
+
rows: 1,
|
|
195
|
+
submitMode: "enter",
|
|
196
|
+
autoComplete: "off",
|
|
197
|
+
autoCorrect: "off",
|
|
198
|
+
autoCapitalize: "none",
|
|
199
|
+
inputMode: "text",
|
|
200
|
+
onInput: (e) => i(e.currentTarget),
|
|
201
|
+
onKeyDown: r
|
|
202
|
+
}), /* @__PURE__ */ v("div", {
|
|
203
|
+
className: "flex items-center justify-between px-3 pt-1 pb-2",
|
|
204
|
+
children: [/* @__PURE__ */ _(K, {}), t ? /* @__PURE__ */ _(G, { onStop: n }) : /* @__PURE__ */ _(xe, {})]
|
|
205
|
+
})]
|
|
206
|
+
}) : /* @__PURE__ */ v("div", {
|
|
207
|
+
className: "flex items-end gap-2 rounded-lg border border-zinc-200 bg-white p-2 shadow-sm transition-colors focus-within:border-[var(--color-brand,#a1a1aa)]",
|
|
208
|
+
children: [
|
|
209
|
+
/* @__PURE__ */ _(L.Input, {
|
|
210
|
+
"data-ai-chat-composer": "",
|
|
211
|
+
className: W("ai-chat-textarea min-w-0 flex-1 resize-none overflow-y-auto bg-transparent px-2 py-1.5 text-base text-zinc-900 leading-relaxed placeholder:text-zinc-500 focus:outline-none", "max-h-[120px]"),
|
|
212
|
+
placeholder: "Ask a follow-up…",
|
|
213
|
+
rows: 1,
|
|
214
|
+
submitMode: "enter",
|
|
215
|
+
autoComplete: "off",
|
|
216
|
+
autoCorrect: "off",
|
|
217
|
+
autoCapitalize: "none",
|
|
218
|
+
inputMode: "text",
|
|
219
|
+
onInput: (e) => i(e.currentTarget),
|
|
220
|
+
onKeyDown: r
|
|
221
|
+
}),
|
|
222
|
+
/* @__PURE__ */ _(K, {}),
|
|
223
|
+
t ? /* @__PURE__ */ _(G, { onStop: n }) : /* @__PURE__ */ _(xe, {})
|
|
224
|
+
]
|
|
225
|
+
});
|
|
226
|
+
}, Ce = "rounded-2xl border border-zinc-200 bg-zinc-100 px-3.5 py-2.5", we = "ai-chat-textarea w-full resize-none bg-transparent text-base text-zinc-900 leading-relaxed placeholder:text-zinc-500 focus:outline-none", Te = "rounded-md px-2 py-1 text-xs text-zinc-500 transition-colors hover:bg-zinc-100", Ee = "rounded-md px-2 py-1 text-xs transition-opacity hover:opacity-80", De = ({ autoGrowMax: e, boxClassName: t = Ce, inputClassName: n = we, cancelClassName: r = Te, sendClassName: a = Ee, sendStyle: o }) => /* @__PURE__ */ _(R.Root, {
|
|
227
|
+
className: "mb-4 pr-2 pl-0",
|
|
228
|
+
children: /* @__PURE__ */ v(L.Root, { children: [/* @__PURE__ */ _("div", {
|
|
229
|
+
className: t,
|
|
230
|
+
children: /* @__PURE__ */ _(L.Input, {
|
|
231
|
+
className: n,
|
|
232
|
+
rows: 1,
|
|
233
|
+
onInput: (t) => i(t.currentTarget, e)
|
|
234
|
+
})
|
|
235
|
+
}), /* @__PURE__ */ v("div", {
|
|
236
|
+
className: "mt-2 flex justify-end gap-1.5",
|
|
237
|
+
children: [/* @__PURE__ */ _(L.Cancel, {
|
|
238
|
+
className: r,
|
|
239
|
+
children: "Cancel"
|
|
240
|
+
}), /* @__PURE__ */ _(L.Send, {
|
|
241
|
+
className: a,
|
|
242
|
+
style: o,
|
|
243
|
+
children: "Save"
|
|
244
|
+
})]
|
|
245
|
+
})] })
|
|
246
|
+
}), Oe = ({ idleClassName: e = "text-zinc-500 hover:text-zinc-900", copiedClassName: t = "text-emerald-500", errorClassName: n = "text-rose-500", className: r = "rounded p-1.5 transition-colors", iconClassName: i = "h-3 w-3" }) => {
|
|
247
|
+
let [a, o] = D("idle"), s = V((e) => e.message);
|
|
248
|
+
w(() => {
|
|
249
|
+
if (a === "idle") return;
|
|
250
|
+
let e = setTimeout(() => o("idle"), 1500);
|
|
251
|
+
return () => clearTimeout(e);
|
|
252
|
+
}, [a]);
|
|
253
|
+
let c = async () => {
|
|
254
|
+
let e = s.content.filter((e) => e.type === "text").map((e) => e.text).join("");
|
|
255
|
+
try {
|
|
256
|
+
await navigator.clipboard.writeText(e), o("copied");
|
|
257
|
+
} catch {
|
|
258
|
+
o("error");
|
|
259
|
+
}
|
|
260
|
+
}, l = a === "copied" ? t ?? e : a === "error" ? n ?? e : e, u = a === "copied" ? "Copied" : a === "error" ? "Copy failed" : "Copy message", d = a === "copied" ? k : a === "error" ? P : A;
|
|
261
|
+
return /* @__PURE__ */ _("button", {
|
|
262
|
+
type: "button",
|
|
263
|
+
"aria-label": u,
|
|
264
|
+
onClick: c,
|
|
265
|
+
className: [r, l].filter(Boolean).join(" "),
|
|
266
|
+
children: /* @__PURE__ */ _(d, { className: i })
|
|
267
|
+
});
|
|
268
|
+
}, ke = ({ children: e }) => {
|
|
269
|
+
let [t, n] = D(!1), r = "plaintext", i = "";
|
|
270
|
+
return y.forEach(e, (e) => {
|
|
271
|
+
if (x(e)) {
|
|
272
|
+
let t = e.props, n = /language-(\w+)/.exec(t.className ?? "");
|
|
273
|
+
n && (r = n[1] ?? r), typeof t.children == "string" && (i = t.children.trim());
|
|
274
|
+
}
|
|
275
|
+
}), /* @__PURE__ */ v("div", {
|
|
276
|
+
className: "ai-chat-code not-prose my-4 overflow-hidden rounded-xl border",
|
|
277
|
+
children: [/* @__PURE__ */ v("div", {
|
|
278
|
+
className: "ai-chat-code__header flex items-center justify-between px-4 py-2",
|
|
279
|
+
children: [/* @__PURE__ */ _("span", {
|
|
280
|
+
className: "ai-chat-code__label font-mono text-[10px] uppercase tracking-widest",
|
|
281
|
+
children: r
|
|
282
|
+
}), /* @__PURE__ */ _("button", {
|
|
283
|
+
type: "button",
|
|
284
|
+
onClick: () => navigator.clipboard.writeText(i).then(() => {
|
|
285
|
+
n(!0), setTimeout(() => n(!1), 2e3);
|
|
286
|
+
}).catch(() => {}),
|
|
287
|
+
className: "ai-chat-code__copy flex items-center gap-1.5 rounded px-2 py-0.5 text-[10px] transition-colors",
|
|
288
|
+
children: t ? /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _(k, { className: "h-3 w-3 text-emerald-500" }), /* @__PURE__ */ _("span", { children: "Copied!" })] }) : /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _(A, { className: "h-3 w-3" }), /* @__PURE__ */ _("span", { children: "Copy" })] })
|
|
289
|
+
})]
|
|
290
|
+
}), /* @__PURE__ */ _("pre", {
|
|
291
|
+
className: "ai-chat-code__pre overflow-x-auto px-4 py-4 font-mono text-sm leading-relaxed",
|
|
292
|
+
children: e
|
|
293
|
+
})]
|
|
294
|
+
});
|
|
295
|
+
}, Ae = (e) => /* @__PURE__ */ _("a", {
|
|
296
|
+
...e,
|
|
297
|
+
target: "_blank",
|
|
298
|
+
rel: "noopener noreferrer"
|
|
299
|
+
}), je = ({ className: e, ...t }) => /* @__PURE__ */ _("div", {
|
|
300
|
+
className: "w-full max-w-full overflow-x-auto",
|
|
301
|
+
children: /* @__PURE__ */ _("table", {
|
|
302
|
+
...t,
|
|
303
|
+
className: ["w-max min-w-full [&_td]:max-w-[20rem] [&_th]:max-w-[20rem]", e].filter(Boolean).join(" ")
|
|
304
|
+
})
|
|
305
|
+
}), Me = () => /* @__PURE__ */ _(oe, {
|
|
306
|
+
remarkPlugins: [se],
|
|
307
|
+
components: {
|
|
308
|
+
pre: ke,
|
|
309
|
+
a: Ae,
|
|
310
|
+
table: je
|
|
311
|
+
}
|
|
312
|
+
}), Ne = [
|
|
313
|
+
"Thinking",
|
|
314
|
+
"Pondering",
|
|
315
|
+
"Drafting",
|
|
316
|
+
"Reasoning",
|
|
317
|
+
"Composing",
|
|
318
|
+
"Cogitating",
|
|
319
|
+
"Synthesizing",
|
|
320
|
+
"Weighing words",
|
|
321
|
+
"Brewing",
|
|
322
|
+
"Sketching",
|
|
323
|
+
"Untangling",
|
|
324
|
+
"Threading the needle",
|
|
325
|
+
"Lining up ideas"
|
|
326
|
+
], Pe = (e) => {
|
|
327
|
+
let t = Math.floor(e / 60), n = e % 60;
|
|
328
|
+
return t > 0 ? `${t}m ${n.toString().padStart(2, "0")}s` : `${n}s`;
|
|
329
|
+
}, Fe = ({ phrases: e = Ne, textClassName: t = "ai-thinking-text", timerClassName: n = "text-xs text-zinc-500/70 tabular-nums", longRunningClassName: r = "ml-1.5 text-zinc-500/45", longRunningHint: i = "· hang tight" }) => {
|
|
330
|
+
let [a, o] = D(() => e.length > 0 ? Math.floor(Math.random() * e.length) : 0), [s, c] = D(0);
|
|
331
|
+
w(() => {
|
|
332
|
+
let t = e.length > 0 ? setInterval(() => {
|
|
333
|
+
o((t) => (t + 1) % e.length);
|
|
334
|
+
}, 2800) : null, n = setInterval(() => {
|
|
335
|
+
c((e) => e + 1);
|
|
336
|
+
}, 1e3);
|
|
337
|
+
return () => {
|
|
338
|
+
t !== null && clearInterval(t), clearInterval(n);
|
|
339
|
+
};
|
|
340
|
+
}, [e.length]);
|
|
341
|
+
let l = e[a] ?? "Thinking", u = s >= 3, d = s >= 30;
|
|
342
|
+
return /* @__PURE__ */ v("div", {
|
|
343
|
+
className: "flex items-center gap-3 py-1",
|
|
344
|
+
children: [
|
|
345
|
+
/* @__PURE__ */ v("div", {
|
|
346
|
+
className: "ai-dust",
|
|
347
|
+
children: [
|
|
348
|
+
/* @__PURE__ */ _("span", { style: {
|
|
349
|
+
left: "4px",
|
|
350
|
+
"--delay": ".3s"
|
|
351
|
+
} }),
|
|
352
|
+
/* @__PURE__ */ _("span", { style: {
|
|
353
|
+
left: "12px",
|
|
354
|
+
"--delay": "0s"
|
|
355
|
+
} }),
|
|
356
|
+
/* @__PURE__ */ _("span", { style: {
|
|
357
|
+
left: "20px",
|
|
358
|
+
"--delay": ".6s"
|
|
359
|
+
} })
|
|
360
|
+
]
|
|
361
|
+
}),
|
|
362
|
+
/* @__PURE__ */ v("span", {
|
|
363
|
+
className: `${t} font-semibold text-sm transition-opacity duration-500`,
|
|
364
|
+
children: [l, "…"]
|
|
365
|
+
}),
|
|
366
|
+
u && /* @__PURE__ */ v("span", {
|
|
367
|
+
className: n,
|
|
368
|
+
children: [Pe(s), d && /* @__PURE__ */ _("span", {
|
|
369
|
+
className: r,
|
|
370
|
+
children: i
|
|
371
|
+
})]
|
|
372
|
+
})
|
|
373
|
+
]
|
|
374
|
+
});
|
|
375
|
+
}, Ie = () => null, Le = "max-w-none text-sm text-zinc-900 leading-relaxed [&>*:first-child]:mt-0 [&>*:last-child]:mb-0 [&_a:hover]:text-sky-700 [&_a]:break-words [&_a]:font-medium [&_a]:text-sky-600 [&_a]:underline [&_a]:underline-offset-2 [&_li]:text-sm [&_ol]:my-2 [&_ol]:list-decimal [&_ol]:pl-5 [&_p]:my-2 [&_p]:text-sm [&_strong]:font-semibold [&_ul]:my-2 [&_ul]:list-disc [&_ul]:pl-5", Re = "group pr-4 pb-6", ze = "mt-2 flex items-center gap-2 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100", Be = "text-xs text-zinc-500/60", Ve = "rounded p-1.5 text-zinc-500 transition-colors hover:text-zinc-900", He = ({ tools: e = Ie, Parts: t, thinkingIndicator: n = /* @__PURE__ */ _(Fe, {}), rootClassName: r = Re, contentClassName: i = Le, metaClassName: a = ze, wrapContent: o, metaSlot: s, copyIdleClassName: c, copyCopiedClassName: l, reloadClassName: u = Ve, timeClassName: d = Be, timeFormatOptions: f, readOnly: p = !1, belowContent: m }) => {
|
|
376
|
+
let g = V((e) => e.message), y = t ?? R.Content, b = g.status?.type === "running", x = /* @__PURE__ */ _("div", {
|
|
377
|
+
className: i,
|
|
378
|
+
children: /* @__PURE__ */ _(y, { components: {
|
|
379
|
+
Text: Me,
|
|
380
|
+
tools: { Fallback: e }
|
|
381
|
+
} })
|
|
382
|
+
});
|
|
383
|
+
return /* @__PURE__ */ _(R.Root, {
|
|
384
|
+
className: r,
|
|
385
|
+
children: /* @__PURE__ */ v("div", {
|
|
386
|
+
className: "flex min-w-0 flex-col",
|
|
387
|
+
children: [
|
|
388
|
+
o ? o(x) : x,
|
|
389
|
+
b && /* @__PURE__ */ _("div", {
|
|
390
|
+
className: "mt-1",
|
|
391
|
+
children: n
|
|
392
|
+
}),
|
|
393
|
+
!b && m && /* @__PURE__ */ _("div", {
|
|
394
|
+
className: "mt-2",
|
|
395
|
+
children: m
|
|
396
|
+
}),
|
|
397
|
+
!b && /* @__PURE__ */ v("div", {
|
|
398
|
+
className: a,
|
|
399
|
+
children: [
|
|
400
|
+
/* @__PURE__ */ _("span", {
|
|
401
|
+
className: d,
|
|
402
|
+
children: h(g.createdAt, f)
|
|
403
|
+
}),
|
|
404
|
+
s,
|
|
405
|
+
/* @__PURE__ */ v(F.Root, {
|
|
406
|
+
className: "flex items-center gap-0.5",
|
|
407
|
+
children: [/* @__PURE__ */ _(Oe, {
|
|
408
|
+
idleClassName: c,
|
|
409
|
+
copiedClassName: l
|
|
410
|
+
}), !p && /* @__PURE__ */ _(F.Reload, {
|
|
411
|
+
className: u,
|
|
412
|
+
children: /* @__PURE__ */ _(M, { className: "h-3 w-3" })
|
|
413
|
+
})]
|
|
414
|
+
})
|
|
415
|
+
]
|
|
416
|
+
})
|
|
417
|
+
]
|
|
418
|
+
})
|
|
419
|
+
});
|
|
420
|
+
}, Ue = "group flex flex-col items-end pb-4 pl-12", We = "rounded-2xl border border-zinc-200 bg-zinc-100 px-3.5 py-2.5 text-sm text-zinc-900 leading-relaxed", Ge = "mt-1 flex items-center gap-2 opacity-0 transition-opacity group-focus-within:opacity-100 group-hover:opacity-100", Ke = "text-xs text-zinc-500/60", qe = "rounded px-2 py-1 font-medium text-xs text-zinc-500 transition-colors hover:text-zinc-900", Je = ({ attachmentsSlot: e, rootClassName: t = Ue, bubbleClassName: n = We, contentSlot: r, metaClassName: i = Ge, timeClassName: a = Ke, editClassName: o = qe, copyIdleClassName: s, copyCopiedClassName: c, timeFormatOptions: l, readOnly: u = !1 }) => {
|
|
421
|
+
let d = V((e) => e.message);
|
|
422
|
+
return /* @__PURE__ */ v(R.Root, {
|
|
423
|
+
className: t,
|
|
424
|
+
"data-user-message": "true",
|
|
425
|
+
children: [
|
|
426
|
+
e,
|
|
427
|
+
/* @__PURE__ */ _("div", {
|
|
428
|
+
className: n,
|
|
429
|
+
children: r ?? /* @__PURE__ */ _(R.Content, {})
|
|
430
|
+
}),
|
|
431
|
+
/* @__PURE__ */ v("div", {
|
|
432
|
+
className: i,
|
|
433
|
+
children: [/* @__PURE__ */ _("span", {
|
|
434
|
+
className: a,
|
|
435
|
+
children: h(d.createdAt, l)
|
|
436
|
+
}), /* @__PURE__ */ v(F.Root, {
|
|
437
|
+
className: "flex items-center gap-0.5",
|
|
438
|
+
children: [/* @__PURE__ */ _(Oe, {
|
|
439
|
+
idleClassName: s,
|
|
440
|
+
copiedClassName: c
|
|
441
|
+
}), !u && /* @__PURE__ */ _(F.Edit, {
|
|
442
|
+
className: o,
|
|
443
|
+
children: "Edit"
|
|
444
|
+
})]
|
|
445
|
+
})]
|
|
446
|
+
})
|
|
447
|
+
]
|
|
448
|
+
});
|
|
449
|
+
}, Ye = () => /* @__PURE__ */ _(De, { sendStyle: {
|
|
450
|
+
backgroundColor: "var(--color-brand, #0a0a0a)",
|
|
451
|
+
color: "var(--color-brand-foreground, #fff)"
|
|
452
|
+
} }), Xe = [
|
|
453
|
+
"What do you offer?",
|
|
454
|
+
"How much does it cost?",
|
|
455
|
+
"Why should I choose you?",
|
|
456
|
+
"How do I get in touch?"
|
|
457
|
+
], Ze = [
|
|
458
|
+
"w-3/4",
|
|
459
|
+
"w-4/5",
|
|
460
|
+
"w-2/3",
|
|
461
|
+
"w-3/5"
|
|
462
|
+
], Qe = ({ workspaceId: t, siteName: n, siteLogo: r, apiBaseUrl: i, authHeaders: a, agentId: o, followUps: s, hideComposer: c = !1 }) => {
|
|
463
|
+
let l = B(), u = V((e) => e.thread.isRunning), { agentUnavailable: d } = fe(), f = E(null), { isAtBottom: p, scrollToBottom: m } = be({
|
|
464
|
+
viewportRef: f,
|
|
465
|
+
isRunning: u
|
|
466
|
+
}), h = _e({
|
|
467
|
+
endpoint: t ? `${i}/suggestions${o ? `?agent_id=${encodeURIComponent(o)}` : ""}` : void 0,
|
|
468
|
+
headers: t ? {
|
|
469
|
+
...a,
|
|
470
|
+
"Levo-Workspace": t
|
|
471
|
+
} : void 0,
|
|
472
|
+
fallback: Xe
|
|
473
|
+
}), g = S((t) => {
|
|
474
|
+
e(l.thread.composer(), t);
|
|
475
|
+
}, [l]), y = S(() => l.thread.cancelRun(), [l]), b = E(u);
|
|
476
|
+
return w(() => {
|
|
477
|
+
b.current = u;
|
|
478
|
+
}, [u]), w(() => {
|
|
479
|
+
let e = (e) => {
|
|
480
|
+
e.key !== "Escape" || e.isComposing || !b.current || (e.preventDefault(), e.stopImmediatePropagation(), l.thread.cancelRun());
|
|
481
|
+
};
|
|
482
|
+
return window.addEventListener("keydown", e, !0), () => window.removeEventListener("keydown", e, !0);
|
|
483
|
+
}, [l]), /* @__PURE__ */ v(z.Root, {
|
|
484
|
+
className: "relative flex flex-1 flex-col overflow-hidden",
|
|
485
|
+
children: [
|
|
486
|
+
/* @__PURE__ */ _(z.If, {
|
|
487
|
+
empty: !0,
|
|
488
|
+
children: /* @__PURE__ */ _("div", {
|
|
489
|
+
className: "pointer-events-none absolute inset-0 z-0 overflow-hidden",
|
|
490
|
+
children: /* @__PURE__ */ _("div", {
|
|
491
|
+
className: "absolute inset-0",
|
|
492
|
+
style: { background: ["radial-gradient(at 12% 18%, color-mix(in oklch, var(--color-brand, #4691e8) 12%, transparent) 0px, transparent 55%)", "radial-gradient(at 88% 82%, color-mix(in oklch, var(--color-brand-secondary, #db646d) 8%, transparent) 0px, transparent 55%)"].join(", ") }
|
|
493
|
+
})
|
|
494
|
+
})
|
|
495
|
+
}),
|
|
496
|
+
d && /* @__PURE__ */ _("div", {
|
|
497
|
+
role: "alert",
|
|
498
|
+
className: "relative z-20 shrink-0 border-amber-200 border-b bg-amber-50 px-4 py-2.5 text-amber-800 text-xs",
|
|
499
|
+
children: "This conversation is no longer available. Please refresh the page to start a new chat."
|
|
500
|
+
}),
|
|
501
|
+
/* @__PURE__ */ v(z.Viewport, {
|
|
502
|
+
ref: f,
|
|
503
|
+
turnAnchor: "top",
|
|
504
|
+
className: "relative z-10 flex-1 overflow-y-auto",
|
|
505
|
+
autoScroll: !1,
|
|
506
|
+
scrollToBottomOnRunStart: !1,
|
|
507
|
+
scrollToBottomOnInitialize: !1,
|
|
508
|
+
scrollToBottomOnThreadSwitch: !1,
|
|
509
|
+
children: [/* @__PURE__ */ _(z.Empty, { children: /* @__PURE__ */ v("div", {
|
|
510
|
+
className: "flex min-h-full flex-col items-center justify-center px-6 py-6",
|
|
511
|
+
children: [/* @__PURE__ */ v("div", {
|
|
512
|
+
className: "mb-5 flex flex-col items-center gap-2 text-center",
|
|
513
|
+
children: [
|
|
514
|
+
r ? /* @__PURE__ */ _("img", {
|
|
515
|
+
src: r,
|
|
516
|
+
alt: n ?? "Site logo",
|
|
517
|
+
className: "mb-1 h-12 w-auto max-w-[180px] object-contain"
|
|
518
|
+
}) : /* @__PURE__ */ _("span", {
|
|
519
|
+
className: "font-semibold text-lg text-zinc-900 tracking-tight",
|
|
520
|
+
children: n ?? "This site"
|
|
521
|
+
}),
|
|
522
|
+
/* @__PURE__ */ _("p", {
|
|
523
|
+
className: "mt-1 text-2xl text-zinc-900 tracking-tight",
|
|
524
|
+
style: {
|
|
525
|
+
fontFamily: "var(--font-heading, inherit)",
|
|
526
|
+
fontWeight: 600
|
|
527
|
+
},
|
|
528
|
+
children: "Ask anything"
|
|
529
|
+
}),
|
|
530
|
+
/* @__PURE__ */ _("p", {
|
|
531
|
+
className: "text-sm text-zinc-500",
|
|
532
|
+
style: { fontFamily: "var(--font-heading, inherit)" },
|
|
533
|
+
children: "Get instant answers about products, pricing, and how to get started."
|
|
534
|
+
})
|
|
535
|
+
]
|
|
536
|
+
}), /* @__PURE__ */ _("div", {
|
|
537
|
+
className: "flex w-full max-w-md flex-col gap-2",
|
|
538
|
+
children: h === null ? Ze.map((e, t) => /* @__PURE__ */ _("div", {
|
|
539
|
+
className: "flex h-[42px] items-center rounded-xl border border-zinc-200 bg-white px-4",
|
|
540
|
+
children: /* @__PURE__ */ _("span", { className: `block h-3 animate-pulse rounded bg-zinc-200 ${e}` })
|
|
541
|
+
}, `skeleton-${t}`)) : h.map((e, t) => /* @__PURE__ */ _("button", {
|
|
542
|
+
type: "button",
|
|
543
|
+
onClick: () => g(e),
|
|
544
|
+
className: "ai-chat-suggestion rounded-xl border border-zinc-200 bg-white px-4 py-2.5 text-left text-sm text-zinc-700 transition-[border-color,background-color,transform] duration-150 hover:border-zinc-300 hover:bg-zinc-50 active:scale-[0.98]",
|
|
545
|
+
style: { animationDelay: `${t * 40}ms` },
|
|
546
|
+
children: e
|
|
547
|
+
}, e))
|
|
548
|
+
})]
|
|
549
|
+
}) }), /* @__PURE__ */ _(z.If, {
|
|
550
|
+
empty: !1,
|
|
551
|
+
children: /* @__PURE__ */ _("div", {
|
|
552
|
+
className: "ai-chat-kb-messages mx-auto max-w-3xl px-6 py-6 pt-8",
|
|
553
|
+
children: /* @__PURE__ */ _(z.Messages, { components: {
|
|
554
|
+
UserMessage: Je,
|
|
555
|
+
AssistantMessage: He,
|
|
556
|
+
EditComposer: Ye
|
|
557
|
+
} })
|
|
558
|
+
})
|
|
559
|
+
})]
|
|
560
|
+
}),
|
|
561
|
+
!c && /* @__PURE__ */ _("div", {
|
|
562
|
+
className: "relative z-10 shrink-0 border-zinc-200 border-t bg-white/95 backdrop-blur-sm",
|
|
563
|
+
children: /* @__PURE__ */ v("div", {
|
|
564
|
+
className: "relative mx-auto max-w-3xl px-4 pt-3 pb-3",
|
|
565
|
+
children: [
|
|
566
|
+
!p && /* @__PURE__ */ _("div", {
|
|
567
|
+
className: "pointer-events-none absolute inset-x-0 -top-9 z-20 flex justify-center",
|
|
568
|
+
children: /* @__PURE__ */ _(ge, {
|
|
569
|
+
onClick: m,
|
|
570
|
+
isRunning: u,
|
|
571
|
+
className: "pointer-events-auto rounded-full border border-zinc-200 bg-white/95 px-3 py-1.5 font-medium text-xs text-zinc-500 shadow-lg backdrop-blur-sm hover:text-zinc-900"
|
|
572
|
+
})
|
|
573
|
+
}),
|
|
574
|
+
s.length > 0 && !u && /* @__PURE__ */ _("div", {
|
|
575
|
+
className: "mb-2",
|
|
576
|
+
children: /* @__PURE__ */ _(H, {
|
|
577
|
+
chips: s,
|
|
578
|
+
onSelect: g,
|
|
579
|
+
size: "compact"
|
|
580
|
+
})
|
|
581
|
+
}),
|
|
582
|
+
/* @__PURE__ */ v(L.Root, { children: [
|
|
583
|
+
/* @__PURE__ */ _(z.If, {
|
|
584
|
+
empty: !0,
|
|
585
|
+
children: /* @__PURE__ */ _(Se, {
|
|
586
|
+
variant: "expanded",
|
|
587
|
+
isRunning: u,
|
|
588
|
+
onStop: y
|
|
589
|
+
})
|
|
590
|
+
}),
|
|
591
|
+
/* @__PURE__ */ _(z.If, {
|
|
592
|
+
empty: !1,
|
|
593
|
+
children: /* @__PURE__ */ _(Se, {
|
|
594
|
+
variant: "compact",
|
|
595
|
+
isRunning: u,
|
|
596
|
+
onStop: y
|
|
597
|
+
})
|
|
598
|
+
}),
|
|
599
|
+
/* @__PURE__ */ _(L.If, {
|
|
600
|
+
dictation: !0,
|
|
601
|
+
children: /* @__PURE__ */ v("div", {
|
|
602
|
+
className: "mt-2 flex items-center justify-center gap-2",
|
|
603
|
+
children: [/* @__PURE__ */ _("span", { className: "h-1.5 w-1.5 animate-pulse rounded-full bg-red-500" }), /* @__PURE__ */ _("span", {
|
|
604
|
+
className: "font-medium text-red-500 text-xs tracking-wide",
|
|
605
|
+
children: "Listening… speak now"
|
|
606
|
+
})]
|
|
607
|
+
})
|
|
608
|
+
})
|
|
609
|
+
] }),
|
|
610
|
+
/* @__PURE__ */ _(z.If, {
|
|
611
|
+
empty: !1,
|
|
612
|
+
children: /* @__PURE__ */ _("p", {
|
|
613
|
+
className: "mt-2 text-center text-[10px] text-zinc-500/70",
|
|
614
|
+
children: "Answers can be inaccurate. Verify before relying on them."
|
|
615
|
+
})
|
|
616
|
+
})
|
|
617
|
+
]
|
|
618
|
+
})
|
|
619
|
+
})
|
|
620
|
+
]
|
|
621
|
+
});
|
|
622
|
+
}, q = 4096, $e = 400, et = 300, tt = 2e3, nt = (e) => document.querySelector(e)?.content?.trim() || void 0, J = (e) => {
|
|
623
|
+
for (let t of e) {
|
|
624
|
+
let e = nt(t);
|
|
625
|
+
if (e) return e;
|
|
626
|
+
}
|
|
627
|
+
}, rt = (e, t) => e.length > t ? `${e.slice(0, t - 1).trimEnd()}…` : e, Y = (e) => JSON.stringify(e).length, it = () => {
|
|
628
|
+
if (typeof window > "u" || typeof document > "u") return;
|
|
629
|
+
let e = {}, t = window.location?.href;
|
|
630
|
+
t && (e.url = t);
|
|
631
|
+
let n = document.title?.trim() || J(["meta[property=\"og:title\"]", "meta[name=\"twitter:title\"]"]);
|
|
632
|
+
n && (e.page_title = rt(n, et));
|
|
633
|
+
let r = J([
|
|
634
|
+
"meta[name=\"description\"]",
|
|
635
|
+
"meta[property=\"og:description\"]",
|
|
636
|
+
"meta[name=\"twitter:description\"]"
|
|
637
|
+
]);
|
|
638
|
+
r && (e.description = rt(r, $e));
|
|
639
|
+
let i = document.referrer?.trim();
|
|
640
|
+
if (i && (e.referrer = i), Object.keys(e).length !== 0) return e.description && Y(e) > q && delete e.description, e.referrer && Y(e) > q && delete e.referrer, e.url && Y(e) > q && (e.url = e.url.slice(0, tt)), e;
|
|
641
|
+
}, at = ({ workspaceId: e, siteName: t, siteLogo: n, agentId: r, apiBaseUrl: i, authHeaders: a, children: o }) => {
|
|
642
|
+
let s = E(e);
|
|
643
|
+
s.current = e;
|
|
644
|
+
let c = E(r);
|
|
645
|
+
c.current = r;
|
|
646
|
+
let { followUps: l, clearOnSend: u, handleData: d } = ue(), [f, p] = D(!1), { conversationIdRef: m, handleFinish: h, reset: g } = le(e), v = ae({
|
|
647
|
+
joinStrategy: "none",
|
|
648
|
+
transport: ce({
|
|
649
|
+
api: `${i}/stream`,
|
|
650
|
+
credentials: "include",
|
|
651
|
+
headers: a,
|
|
652
|
+
onSendStart: () => {
|
|
653
|
+
u(), p(!1);
|
|
654
|
+
},
|
|
655
|
+
getHeaders: () => {
|
|
656
|
+
let e = {};
|
|
657
|
+
return s.current && (e["Levo-Workspace"] = s.current), e;
|
|
658
|
+
},
|
|
659
|
+
getBody: (e) => {
|
|
660
|
+
let t = {
|
|
661
|
+
messages: e.messages,
|
|
662
|
+
workspace_id: s.current
|
|
663
|
+
};
|
|
664
|
+
m.current && (t.conversation_id = m.current), c.current && (t.agent_id = c.current);
|
|
665
|
+
let n = it();
|
|
666
|
+
return n && (t.context = n), t;
|
|
667
|
+
}
|
|
668
|
+
}),
|
|
669
|
+
adapters: { dictation: new re({ interimResults: !1 }) },
|
|
670
|
+
onData: d,
|
|
671
|
+
onFinish: h,
|
|
672
|
+
onError: (e) => {
|
|
673
|
+
de(e) ? p(!0) : console.warn("[levo-kb-chat] stream error:", e);
|
|
674
|
+
}
|
|
675
|
+
}), y = S(() => {
|
|
676
|
+
v.threads.switchToNewThread().catch((e) => {
|
|
677
|
+
console.warn("[levo-kb-chat] switchToNewThread failed:", e);
|
|
678
|
+
}), g(), u(), p(!1);
|
|
679
|
+
}, [
|
|
680
|
+
v,
|
|
681
|
+
g,
|
|
682
|
+
u
|
|
683
|
+
]);
|
|
684
|
+
return /* @__PURE__ */ _(I, {
|
|
685
|
+
runtime: v,
|
|
686
|
+
children: /* @__PURE__ */ _(U.Provider, {
|
|
687
|
+
value: { agentUnavailable: f },
|
|
688
|
+
children: o ? o({
|
|
689
|
+
followUps: l,
|
|
690
|
+
onResetChat: y
|
|
691
|
+
}) : /* @__PURE__ */ _(Qe, {
|
|
692
|
+
workspaceId: e,
|
|
693
|
+
siteName: t,
|
|
694
|
+
siteLogo: n,
|
|
695
|
+
apiBaseUrl: i,
|
|
696
|
+
authHeaders: a,
|
|
697
|
+
agentId: r,
|
|
698
|
+
followUps: l
|
|
699
|
+
})
|
|
700
|
+
})
|
|
701
|
+
});
|
|
702
|
+
}, ot = (e, t, n) => {
|
|
703
|
+
w(() => {
|
|
704
|
+
if (!e) return;
|
|
705
|
+
let r = (e) => {
|
|
706
|
+
if (e.key !== "Escape" || e.isComposing) return;
|
|
707
|
+
let r = t.current;
|
|
708
|
+
if (r?.isRunning) {
|
|
709
|
+
r.cancelRun();
|
|
710
|
+
return;
|
|
711
|
+
}
|
|
712
|
+
n();
|
|
713
|
+
};
|
|
714
|
+
return window.addEventListener("keydown", r, !0), () => window.removeEventListener("keydown", r, !0);
|
|
715
|
+
}, [
|
|
716
|
+
e,
|
|
717
|
+
t,
|
|
718
|
+
n
|
|
719
|
+
]);
|
|
720
|
+
}, X = "(max-width: 639px)", Z = () => {
|
|
721
|
+
let [e, t] = D(() => typeof window < "u" && window.matchMedia(X).matches);
|
|
722
|
+
return w(() => {
|
|
723
|
+
let e = window.matchMedia(X), n = () => t(e.matches);
|
|
724
|
+
return n(), e.addEventListener("change", n), () => e.removeEventListener("change", n);
|
|
725
|
+
}, []), e;
|
|
726
|
+
}, st = (e, t) => {
|
|
727
|
+
w(() => {
|
|
728
|
+
let n = t.current, r = window.visualViewport;
|
|
729
|
+
if (!e || !n || !r || !window.matchMedia(X).matches) return;
|
|
730
|
+
let i = () => {
|
|
731
|
+
n.style.setProperty("--ai-vv-top", `${r.offsetTop}px`), n.style.setProperty("--ai-vv-height", `${r.height}px`);
|
|
732
|
+
};
|
|
733
|
+
return i(), r.addEventListener("resize", i), r.addEventListener("scroll", i), () => {
|
|
734
|
+
r.removeEventListener("resize", i), r.removeEventListener("scroll", i), n.style.removeProperty("--ai-vv-top"), n.style.removeProperty("--ai-vv-height");
|
|
735
|
+
};
|
|
736
|
+
}, [e, t]);
|
|
737
|
+
}, ct = (e, t, n) => {
|
|
738
|
+
w(() => {
|
|
739
|
+
if (!e) return;
|
|
740
|
+
let r = (e) => {
|
|
741
|
+
let r = e.composedPath();
|
|
742
|
+
t.current && !r.includes(t.current) && n();
|
|
743
|
+
};
|
|
744
|
+
return document.addEventListener("mousedown", r), () => document.removeEventListener("mousedown", r);
|
|
745
|
+
}, [
|
|
746
|
+
e,
|
|
747
|
+
t,
|
|
748
|
+
n
|
|
749
|
+
]);
|
|
750
|
+
}, Q = (...e) => e.filter(Boolean).join(" "), lt = ({ open: e, onToggle: i, askLabel: a, panelId: h, initialDraft: y }) => {
|
|
751
|
+
let b = B(), x = Z(), S = V((e) => e.thread.isRunning), C = V((e) => e.thread.messages.length > 0), k = V((e) => e.composer.text), ee = k.trim().length > 0, [A, j] = D(!1);
|
|
752
|
+
w(() => {
|
|
753
|
+
y && b.thread.composer().setText(y);
|
|
754
|
+
}, []);
|
|
755
|
+
let M = E(null), P = E(null), F = E(!1);
|
|
756
|
+
T(() => {
|
|
757
|
+
let e = M.current;
|
|
758
|
+
!e || document.activeElement === e || (F.current = !0, e.focus({ preventScroll: !0 }));
|
|
759
|
+
}, []), T(() => {
|
|
760
|
+
let t = M.current, n = P.current;
|
|
761
|
+
if (!(!t || !n)) {
|
|
762
|
+
if (!e) {
|
|
763
|
+
t.style.height = "", j(!1);
|
|
764
|
+
return;
|
|
765
|
+
}
|
|
766
|
+
j(c(n, t));
|
|
767
|
+
}
|
|
768
|
+
}, [k, e]);
|
|
769
|
+
let I = E(e);
|
|
770
|
+
w(() => {
|
|
771
|
+
let t = I.current;
|
|
772
|
+
I.current = e;
|
|
773
|
+
let n = M.current;
|
|
774
|
+
e || !t || !n || document.activeElement === n && n.blur();
|
|
775
|
+
}, [e]);
|
|
776
|
+
let R = E(S);
|
|
777
|
+
w(() => {
|
|
778
|
+
let e = !R.current && S;
|
|
779
|
+
R.current = S, x && e && M.current?.blur();
|
|
780
|
+
}, [S, x]);
|
|
781
|
+
let z = C ? "Continue conversation" : a;
|
|
782
|
+
return /* @__PURE__ */ _("div", {
|
|
783
|
+
className: Q(l, e ? f : n),
|
|
784
|
+
children: /* @__PURE__ */ v("div", {
|
|
785
|
+
ref: P,
|
|
786
|
+
className: Q(m, A && "ai-chat-pill-surface--stacked"),
|
|
787
|
+
children: [
|
|
788
|
+
/* @__PURE__ */ _("button", {
|
|
789
|
+
type: "button",
|
|
790
|
+
onClick: i,
|
|
791
|
+
"aria-label": e ? "Collapse AI chat" : "Expand AI chat",
|
|
792
|
+
"aria-expanded": e,
|
|
793
|
+
"aria-controls": h,
|
|
794
|
+
className: s,
|
|
795
|
+
children: /* @__PURE__ */ _(ne, { className: "h-5 w-5" })
|
|
796
|
+
}),
|
|
797
|
+
/* @__PURE__ */ v("div", {
|
|
798
|
+
className: d,
|
|
799
|
+
children: [/* @__PURE__ */ _(L.Input, {
|
|
800
|
+
ref: M,
|
|
801
|
+
"data-ai-chat-composer": "",
|
|
802
|
+
placeholder: e ? "Ask anything…" : "",
|
|
803
|
+
onFocus: () => {
|
|
804
|
+
if (F.current) {
|
|
805
|
+
F.current = !1;
|
|
806
|
+
return;
|
|
807
|
+
}
|
|
808
|
+
e || i();
|
|
809
|
+
},
|
|
810
|
+
onKeyDown: (e) => {
|
|
811
|
+
e.nativeEvent.isComposing || e.key !== "Enter" || e.shiftKey || (e.preventDefault(), !S && ee && b.thread.composer().send());
|
|
812
|
+
},
|
|
813
|
+
rows: 1,
|
|
814
|
+
submitMode: "enter",
|
|
815
|
+
unstable_focusOnRunStart: !x,
|
|
816
|
+
unstable_focusOnScrollToBottom: !x,
|
|
817
|
+
unstable_focusOnThreadSwitched: !x,
|
|
818
|
+
autoComplete: "off",
|
|
819
|
+
autoCorrect: "off",
|
|
820
|
+
autoCapitalize: "none",
|
|
821
|
+
inputMode: "text",
|
|
822
|
+
className: Q(r, "transition-opacity duration-200", !e && "opacity-0")
|
|
823
|
+
}), /* @__PURE__ */ _("span", {
|
|
824
|
+
className: Q(o, "transition-opacity duration-150", e && "opacity-0"),
|
|
825
|
+
"aria-hidden": !0,
|
|
826
|
+
children: z
|
|
827
|
+
})]
|
|
828
|
+
}),
|
|
829
|
+
/* @__PURE__ */ v("div", {
|
|
830
|
+
className: p,
|
|
831
|
+
children: [e && /* @__PURE__ */ v(g, { children: [/* @__PURE__ */ _(L.If, {
|
|
832
|
+
dictation: !1,
|
|
833
|
+
children: /* @__PURE__ */ _(L.Dictate, {
|
|
834
|
+
"aria-label": "Start dictation",
|
|
835
|
+
className: "ai-chat-icon-btn flex h-11 w-11 flex-shrink-0 items-center justify-center rounded-full transition-colors active:scale-95",
|
|
836
|
+
children: /* @__PURE__ */ _(te, { className: "h-5 w-5" })
|
|
837
|
+
})
|
|
838
|
+
}), /* @__PURE__ */ _(L.If, {
|
|
839
|
+
dictation: !0,
|
|
840
|
+
children: /* @__PURE__ */ _(L.StopDictation, {
|
|
841
|
+
"aria-label": "Stop dictation",
|
|
842
|
+
className: "flex h-11 w-11 flex-shrink-0 animate-pulse items-center justify-center rounded-full bg-red-500/15 text-red-500 transition-colors hover:bg-red-500/25",
|
|
843
|
+
children: /* @__PURE__ */ _(N, { className: "h-4 w-4 fill-current" })
|
|
844
|
+
})
|
|
845
|
+
})] }), e ? S ? /* @__PURE__ */ _("button", {
|
|
846
|
+
type: "button",
|
|
847
|
+
onClick: () => b.thread.cancelRun(),
|
|
848
|
+
"aria-label": "Stop generating",
|
|
849
|
+
className: t,
|
|
850
|
+
style: u,
|
|
851
|
+
children: /* @__PURE__ */ _(N, { className: "h-4 w-4 fill-current" })
|
|
852
|
+
}) : /* @__PURE__ */ _(L.Send, {
|
|
853
|
+
"aria-label": "Send message",
|
|
854
|
+
className: Q(t, "disabled:cursor-not-allowed disabled:opacity-40 disabled:shadow-none disabled:hover:scale-100"),
|
|
855
|
+
style: u,
|
|
856
|
+
children: /* @__PURE__ */ _(O, { className: "h-5 w-5 stroke-[2.5px]" })
|
|
857
|
+
}) : /* @__PURE__ */ _("button", {
|
|
858
|
+
type: "button",
|
|
859
|
+
onClick: i,
|
|
860
|
+
"aria-label": "Open AI chat",
|
|
861
|
+
className: t,
|
|
862
|
+
style: u,
|
|
863
|
+
children: /* @__PURE__ */ _(O, { className: "h-5 w-5 stroke-[2.5px]" })
|
|
864
|
+
})]
|
|
865
|
+
})
|
|
866
|
+
]
|
|
867
|
+
})
|
|
868
|
+
});
|
|
869
|
+
}, ut = "linear-gradient(to right, color-mix(in oklch, var(--ai-chat-thinking-1, oklch(0.65 0.15 253.81)) 40%, transparent), color-mix(in oklch, var(--ai-chat-thinking-2, oklch(0.65 0.15 17.5826)) 40%, transparent))", $ = (...e) => e.filter(Boolean).join(" "), dt = ({ workspaceId: e, siteName: t, siteLogo: n, siteIcon: r, siteSlug: i, agentId: o, apiBaseUrl: s, authHeaders: c, initialOpen: l, initialDraft: u, showBranding: d = !0 }) => {
|
|
870
|
+
let [f, p] = D(!1);
|
|
871
|
+
w(() => {
|
|
872
|
+
if (!l) return;
|
|
873
|
+
let e = requestAnimationFrame(() => p(!0));
|
|
874
|
+
return () => cancelAnimationFrame(e);
|
|
875
|
+
}, [l]);
|
|
876
|
+
let m = `kb-chat-panel-${e ?? "default"}`, h = E(null), g = E(null), v = S(() => p(!1), []);
|
|
877
|
+
ot(f, g, v), ct(f, h, v), st(f, h);
|
|
878
|
+
let y = a(t);
|
|
879
|
+
return /* @__PURE__ */ _("div", {
|
|
880
|
+
ref: h,
|
|
881
|
+
className: $("ai-chat-launcher pointer-events-none fixed bottom-5 left-1/2 z-[60] flex -translate-x-1/2 flex-col", "ai-chat-kb-wrap", f ? "w-[min(34rem,calc(100vw-1.5rem))]" : "ai-chat-kb-wrap-closed w-[19.5rem]"),
|
|
882
|
+
children: /* @__PURE__ */ _(at, {
|
|
883
|
+
workspaceId: e,
|
|
884
|
+
siteName: t,
|
|
885
|
+
siteLogo: n,
|
|
886
|
+
agentId: o,
|
|
887
|
+
apiBaseUrl: s,
|
|
888
|
+
authHeaders: c,
|
|
889
|
+
children: ({ followUps: a, onResetChat: l }) => /* @__PURE__ */ _(pt, {
|
|
890
|
+
open: f,
|
|
891
|
+
onToggle: () => p((e) => !e),
|
|
892
|
+
threadStateRef: g,
|
|
893
|
+
onResetChat: l,
|
|
894
|
+
askLabel: y,
|
|
895
|
+
panelId: m,
|
|
896
|
+
siteName: t,
|
|
897
|
+
siteIcon: r,
|
|
898
|
+
siteSlug: i,
|
|
899
|
+
initialDraft: u,
|
|
900
|
+
showBranding: d,
|
|
901
|
+
followUps: a,
|
|
902
|
+
thread: /* @__PURE__ */ _(Qe, {
|
|
903
|
+
workspaceId: e,
|
|
904
|
+
siteName: t,
|
|
905
|
+
siteLogo: n,
|
|
906
|
+
agentId: o,
|
|
907
|
+
apiBaseUrl: s,
|
|
908
|
+
authHeaders: c,
|
|
909
|
+
followUps: a,
|
|
910
|
+
hideComposer: !0
|
|
911
|
+
})
|
|
912
|
+
})
|
|
913
|
+
})
|
|
914
|
+
});
|
|
915
|
+
}, ft = [
|
|
916
|
+
"rounded-full border border-zinc-200 bg-white text-zinc-700",
|
|
917
|
+
"px-3 py-1 text-[13px] leading-snug",
|
|
918
|
+
"transition-[border-color,background-color,color,transform] duration-150 hover:border-zinc-300 hover:bg-zinc-50 hover:text-zinc-900 active:scale-95"
|
|
919
|
+
].join(" "), pt = ({ open: t, onToggle: n, threadStateRef: r, onResetChat: i, askLabel: a, panelId: o, siteName: s, siteIcon: c, siteSlug: l, initialDraft: u, showBranding: d, followUps: f, thread: p }) => {
|
|
920
|
+
let m = B(), h = V((e) => e.thread.isRunning), y = V((e) => e.thread.messages.length > 0), b = Z() ? f.slice(0, 2) : f;
|
|
921
|
+
w(() => (r.current = {
|
|
922
|
+
isRunning: h,
|
|
923
|
+
cancelRun: () => m.thread.cancelRun()
|
|
924
|
+
}, () => {
|
|
925
|
+
r.current = null;
|
|
926
|
+
}), [
|
|
927
|
+
h,
|
|
928
|
+
m,
|
|
929
|
+
r
|
|
930
|
+
]);
|
|
931
|
+
let x = S((t) => {
|
|
932
|
+
e(m.thread.composer(), t);
|
|
933
|
+
}, [m]), C = s ?? "Ask AI", T = `https://levo.so/?utm_source=${encodeURIComponent(l || "website")}&utm_term=Powered%20By%20levo.so&utm_campaign=site_agent&utm_medium=organic_site_agent`;
|
|
934
|
+
return /* @__PURE__ */ v(g, { children: [
|
|
935
|
+
/* @__PURE__ */ _("div", {
|
|
936
|
+
"aria-hidden": !0,
|
|
937
|
+
className: $("absolute inset-0", t ? "pointer-events-auto" : "pointer-events-none"),
|
|
938
|
+
style: { filter: "drop-shadow(0 16px 32px rgba(0,0,0,0.16)) drop-shadow(0 2px 8px rgba(0,0,0,0.08))" },
|
|
939
|
+
children: /* @__PURE__ */ _("div", {
|
|
940
|
+
className: $("ai-chat-kb-surface h-full w-full p-[2px]", !t && "ai-chat-kb-surface-closed"),
|
|
941
|
+
style: { background: ut },
|
|
942
|
+
children: /* @__PURE__ */ _("div", { className: "h-full w-full rounded-t-[26px] rounded-b-[40px] bg-white" })
|
|
943
|
+
})
|
|
944
|
+
}),
|
|
945
|
+
/* @__PURE__ */ v("section", {
|
|
946
|
+
id: o,
|
|
947
|
+
"aria-label": "AI chat",
|
|
948
|
+
inert: !t,
|
|
949
|
+
className: $("relative z-10 flex min-h-0 flex-col", "ai-chat-kb-content", t ? "pointer-events-auto" : "ai-chat-kb-content-closed pointer-events-none"),
|
|
950
|
+
children: [
|
|
951
|
+
/* @__PURE__ */ v("header", {
|
|
952
|
+
className: "flex h-14 w-full shrink-0 items-center justify-between gap-2 px-4",
|
|
953
|
+
children: [/* @__PURE__ */ v("div", {
|
|
954
|
+
className: "flex min-w-0 items-center gap-2",
|
|
955
|
+
children: [c ? /* @__PURE__ */ _("img", {
|
|
956
|
+
src: c,
|
|
957
|
+
alt: "",
|
|
958
|
+
className: "h-6 w-6 shrink-0 rounded-sm object-contain"
|
|
959
|
+
}) : null, /* @__PURE__ */ _("span", {
|
|
960
|
+
className: "truncate font-semibold text-sm text-zinc-900",
|
|
961
|
+
children: C
|
|
962
|
+
})]
|
|
963
|
+
}), /* @__PURE__ */ v("div", {
|
|
964
|
+
className: "flex flex-shrink-0 items-center gap-1",
|
|
965
|
+
children: [y && /* @__PURE__ */ _("button", {
|
|
966
|
+
type: "button",
|
|
967
|
+
onClick: i,
|
|
968
|
+
"aria-label": "Start new chat",
|
|
969
|
+
title: "Start new chat",
|
|
970
|
+
className: "ai-chat-icon-btn flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full transition-[background-color,color,transform] duration-150 active:scale-95",
|
|
971
|
+
children: /* @__PURE__ */ _(j, { className: "h-4 w-4" })
|
|
972
|
+
}), /* @__PURE__ */ _("button", {
|
|
973
|
+
type: "button",
|
|
974
|
+
onClick: n,
|
|
975
|
+
"aria-label": "Close AI chat",
|
|
976
|
+
className: "ai-chat-icon-btn flex h-8 w-8 flex-shrink-0 items-center justify-center rounded-full transition-[background-color,color,transform] duration-150 active:scale-95",
|
|
977
|
+
children: /* @__PURE__ */ _(P, { className: "h-4 w-4" })
|
|
978
|
+
})]
|
|
979
|
+
})]
|
|
980
|
+
}),
|
|
981
|
+
/* @__PURE__ */ _("div", { className: "mx-4 h-px shrink-0 bg-zinc-100" }),
|
|
982
|
+
/* @__PURE__ */ _("div", {
|
|
983
|
+
className: "ai-chat-kb-thread flex max-h-[min(60vh,32rem)] min-h-0 flex-col overflow-hidden",
|
|
984
|
+
children: p
|
|
985
|
+
}),
|
|
986
|
+
b.length > 0 && !h && /* @__PURE__ */ _("div", {
|
|
987
|
+
className: "shrink-0 px-4 pt-1 pb-2",
|
|
988
|
+
children: /* @__PURE__ */ _(H, {
|
|
989
|
+
chips: b,
|
|
990
|
+
onSelect: x,
|
|
991
|
+
chipClassName: ft
|
|
992
|
+
})
|
|
993
|
+
})
|
|
994
|
+
]
|
|
995
|
+
}),
|
|
996
|
+
/* @__PURE__ */ _("div", {
|
|
997
|
+
className: "ai-chat-kb-pillbox pointer-events-auto relative z-20 mx-3 mt-1",
|
|
998
|
+
children: /* @__PURE__ */ _(lt, {
|
|
999
|
+
open: t,
|
|
1000
|
+
onToggle: n,
|
|
1001
|
+
askLabel: a,
|
|
1002
|
+
panelId: o,
|
|
1003
|
+
initialDraft: u
|
|
1004
|
+
})
|
|
1005
|
+
}),
|
|
1006
|
+
d && /* @__PURE__ */ _("div", {
|
|
1007
|
+
className: $("pointer-events-none relative z-20 grid shrink-0 transition-[grid-template-rows] duration-[450ms] ease-[cubic-bezier(0.32,0.72,0,1)]", t ? "grid-rows-[1fr]" : "grid-rows-[0fr]"),
|
|
1008
|
+
children: /* @__PURE__ */ _("div", {
|
|
1009
|
+
className: "overflow-hidden",
|
|
1010
|
+
children: /* @__PURE__ */ v("p", {
|
|
1011
|
+
className: "pt-2 text-center text-[11px] text-zinc-400",
|
|
1012
|
+
children: ["Powered by ", /* @__PURE__ */ _("a", {
|
|
1013
|
+
href: T,
|
|
1014
|
+
target: "_blank",
|
|
1015
|
+
rel: "noopener noreferrer",
|
|
1016
|
+
className: "pointer-events-auto font-medium text-zinc-500 underline-offset-2 transition-colors hover:text-zinc-700 hover:underline",
|
|
1017
|
+
children: "levo.so"
|
|
1018
|
+
})]
|
|
1019
|
+
})
|
|
1020
|
+
})
|
|
1021
|
+
}),
|
|
1022
|
+
/* @__PURE__ */ _("div", { className: "h-3" })
|
|
1023
|
+
] });
|
|
1024
|
+
};
|
|
1025
|
+
//#endregion
|
|
1026
|
+
export { dt as KBChatWidget };
|