@convai/web-widget 0.1.4 → 0.2.0-beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +55 -11
- package/chunks/lightbox-Dxfdw3VU.js +683 -0
- package/index.d.ts +26 -0
- package/index.js +4 -0
- package/package.json +53 -2
- package/react.d.ts +23 -0
- package/react.js +3551 -0
- package/runtime.js +12588 -18085
- package/types.d.ts +62 -0
- package/ui/react/components/ConvaiWidget.d.ts +86 -0
- package/ui/react/components/index.d.ts +1 -0
- package/ui/react/components/rtc-widget/components/AudioSettingsPanel.d.ts +9 -0
- package/ui/react/components/rtc-widget/components/AudioVisualizer.d.ts +35 -0
- package/ui/react/components/rtc-widget/components/ConviMessage.d.ts +13 -0
- package/ui/react/components/rtc-widget/components/FloatingVideo.d.ts +8 -0
- package/ui/react/components/rtc-widget/components/MarkdownRenderer.d.ts +31 -0
- package/ui/react/components/rtc-widget/components/MessageBubble.d.ts +9 -0
- package/ui/react/components/rtc-widget/components/MessageList.d.ts +14 -0
- package/ui/react/components/rtc-widget/components/SiteCard.d.ts +15 -0
- package/ui/react/components/rtc-widget/components/UserMessage.d.ts +9 -0
- package/ui/react/components/rtc-widget/components/conviComponents/ConviButton.d.ts +6 -0
- package/ui/react/components/rtc-widget/components/conviComponents/ConviFooter.d.ts +24 -0
- package/ui/react/components/rtc-widget/components/conviComponents/ConviHeader.d.ts +16 -0
- package/ui/react/components/rtc-widget/components/conviComponents/SettingsTray.d.ts +12 -0
- package/ui/react/components/rtc-widget/components/conviComponents/VoiceModeOverlay.d.ts +14 -0
- package/ui/react/components/rtc-widget/components/conviComponents/index.d.ts +5 -0
- package/ui/react/components/rtc-widget/components/index.d.ts +8 -0
- package/ui/react/components/rtc-widget/index.d.ts +5 -0
- package/ui/react/components/rtc-widget/styles/framerConfig.d.ts +115 -0
- package/ui/react/components/rtc-widget/styles/icons.d.ts +27 -0
- package/ui/react/components/rtc-widget/styles/index.d.ts +5 -0
- package/ui/react/components/rtc-widget/styles/styledComponents.d.ts +53 -0
- package/ui/react/components/rtc-widget/styles/theme.d.ts +187 -0
- package/ui/react/components/rtc-widget/types/index.d.ts +59 -0
- package/ui/react/hooks/useCharacterInfo.d.ts +18 -0
- package/ui/react/hooks/useLocalCameraTrack.d.ts +21 -0
- package/ui/react/icons.d.ts +37 -0
- package/ui/shared/lightbox.d.ts +15 -0
- package/ui/shared/linkStyles.d.ts +64 -0
- package/ui/shared/logger.d.ts +30 -0
- package/ui/vanilla/ConvaiWidget.d.ts +46 -0
- package/ui/vanilla/WidgetEventSubscriptions.d.ts +14 -0
- package/ui/vanilla/icons.d.ts +34 -0
- package/ui/vanilla/styles.d.ts +168 -0
- package/ui/vanilla/types.d.ts +170 -0
- package/vanilla.d.ts +21 -0
- package/vanilla.js +2512 -0
package/react.js
ADDED
|
@@ -0,0 +1,3551 @@
|
|
|
1
|
+
import { jsxs, jsx, Fragment } from "react/jsx-runtime";
|
|
2
|
+
import React, { useState, useEffect, useRef, useCallback, useMemo } from "react";
|
|
3
|
+
import { motion, AnimatePresence } from "framer-motion";
|
|
4
|
+
import { useLocalParticipant, useRoomContext, RoomContext, VideoTrack } from "@livekit/components-react";
|
|
5
|
+
import { RoomContext as RoomContext2, RoomAudioRenderer } from "@livekit/components-react";
|
|
6
|
+
import { FALLBACK_CHARACTER_NAME, fetchCharacterInfo, resolveLinkPreviewCached, isCardWorthy, faviconFor, siteNameFor, parseInlineMarkdown, linkKindForUrl, contactLabel, hoverTitle, compactUrl, documentBadge, fileNameOf, isMixedContent, describeUrl } from "@convai/web-sdk/core";
|
|
7
|
+
import { AudioRenderer } from "@convai/web-sdk/vanilla";
|
|
8
|
+
import { freshPublicationGrantOptions } from "@convai/web-sdk/embed";
|
|
9
|
+
import styled from "styled-components";
|
|
10
|
+
import { p as presentationStyles, M as MAX_CARDS_PER_MESSAGE, i as injectKeyframes, P as PREVIEW_TIMEOUT_MS, g as glyph, o as openLightbox } from "./chunks/lightbox-Dxfdw3VU.js";
|
|
11
|
+
import { Track } from "livekit-client";
|
|
12
|
+
function renderTree(tree) {
|
|
13
|
+
return tree.map(
|
|
14
|
+
(node, i) => React.createElement(node.tag, { key: i, ...node.attr }, renderTree(node.child))
|
|
15
|
+
);
|
|
16
|
+
}
|
|
17
|
+
function IconBase({
|
|
18
|
+
data,
|
|
19
|
+
size,
|
|
20
|
+
title,
|
|
21
|
+
...svgProps
|
|
22
|
+
}) {
|
|
23
|
+
const computedSize = size || "1em";
|
|
24
|
+
return React.createElement(
|
|
25
|
+
"svg",
|
|
26
|
+
{
|
|
27
|
+
stroke: "currentColor",
|
|
28
|
+
fill: "currentColor",
|
|
29
|
+
strokeWidth: "0",
|
|
30
|
+
...data.attr,
|
|
31
|
+
...svgProps,
|
|
32
|
+
className: svgProps.className,
|
|
33
|
+
style: { color: svgProps.color, ...svgProps.style },
|
|
34
|
+
height: computedSize,
|
|
35
|
+
width: computedSize,
|
|
36
|
+
xmlns: "http://www.w3.org/2000/svg"
|
|
37
|
+
},
|
|
38
|
+
title && React.createElement("title", null, title),
|
|
39
|
+
renderTree(data.child)
|
|
40
|
+
);
|
|
41
|
+
}
|
|
42
|
+
function icon(data) {
|
|
43
|
+
return (props) => IconBase({ ...props, data });
|
|
44
|
+
}
|
|
45
|
+
const FaUser = icon({ "tag": "svg", "attr": { "viewBox": "0 0 448 512" }, "child": [{ "tag": "path", "attr": { "d": "M224 256c70.7 0 128-57.3 128-128S294.7 0 224 0 96 57.3 96 128s57.3 128 128 128zm89.6 32h-16.7c-22.2 10.2-46.9 16-72.9 16s-50.6-5.8-72.9-16h-16.7C60.2 288 0 348.2 0 422.4V464c0 26.5 21.5 48 48 48h352c26.5 0 48-21.5 48-48v-41.6c0-74.2-60.2-134.4-134.4-134.4z" }, "child": [] }] });
|
|
46
|
+
const FiMoreVertical = icon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "circle", "attr": { "cx": "12", "cy": "12", "r": "1" }, "child": [] }, { "tag": "circle", "attr": { "cx": "12", "cy": "5", "r": "1" }, "child": [] }, { "tag": "circle", "attr": { "cx": "12", "cy": "19", "r": "1" }, "child": [] }] });
|
|
47
|
+
const FiSend = icon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "line", "attr": { "x1": "22", "y1": "2", "x2": "11", "y2": "13" }, "child": [] }, { "tag": "polygon", "attr": { "points": "22 2 15 22 11 13 2 9 22 2" }, "child": [] }] });
|
|
48
|
+
const FiPhoneOff = icon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24", "fill": "none", "stroke": "currentColor", "strokeWidth": "2", "strokeLinecap": "round", "strokeLinejoin": "round" }, "child": [{ "tag": "path", "attr": { "d": "M10.68 13.31a16 16 0 0 0 3.41 2.6l1.27-1.27a2 2 0 0 1 2.11-.45 12.84 12.84 0 0 0 2.81.7 2 2 0 0 1 1.72 2v3a2 2 0 0 1-2.18 2 19.79 19.79 0 0 1-8.63-3.07 19.42 19.42 0 0 1-3.33-2.67m-2.67-3.34a19.79 19.79 0 0 1-3.07-8.63A2 2 0 0 1 4.11 2h3a2 2 0 0 1 2 1.72 12.84 12.84 0 0 0 .7 2.81 2 2 0 0 1-.45 2.11L8.09 9.91" }, "child": [] }, { "tag": "line", "attr": { "x1": "23", "y1": "1", "x2": "1", "y2": "23" }, "child": [] }] });
|
|
49
|
+
const IoClose = icon({ "tag": "svg", "attr": { "viewBox": "0 0 512 512" }, "child": [{ "tag": "path", "attr": { "d": "m289.94 256 95-95A24 24 0 0 0 351 127l-95 95-95-95a24 24 0 0 0-34 34l95 95-95 95a24 24 0 1 0 34 34l95-95 95 95a24 24 0 0 0 34-34z" }, "child": [] }] });
|
|
50
|
+
const IoVideocam = icon({ "tag": "svg", "attr": { "viewBox": "0 0 512 512" }, "child": [{ "tag": "path", "attr": { "d": "M464 384.39a32 32 0 0 1-13-2.77 15.77 15.77 0 0 1-2.71-1.54l-82.71-58.22A32 32 0 0 1 352 295.7v-79.4a32 32 0 0 1 13.58-26.16l82.71-58.22a15.77 15.77 0 0 1 2.71-1.54 32 32 0 0 1 45 29.24v192.76a32 32 0 0 1-32 32zM268 400H84a68.07 68.07 0 0 1-68-68V180a68.07 68.07 0 0 1 68-68h184.48A67.6 67.6 0 0 1 336 179.52V332a68.07 68.07 0 0 1-68 68z" }, "child": [] }] });
|
|
51
|
+
const IoVideocamOff = icon({ "tag": "svg", "attr": { "viewBox": "0 0 512 512" }, "child": [{ "tag": "path", "attr": { "d": "M336 179.52A67.52 67.52 0 0 0 268.48 112h-79.2a4 4 0 0 0-2.82 6.83l142.71 142.71a4 4 0 0 0 6.83-2.82zM16 180v152a68 68 0 0 0 68 68h184a67.66 67.66 0 0 0 42.84-15.24 4 4 0 0 0 .33-6L54.41 122a4 4 0 0 0-4.87-.62A68 68 0 0 0 16 180zm448 204.39a32 32 0 0 1-13-2.77 15.77 15.77 0 0 1-2.71-1.54l-82.71-58.22A32 32 0 0 1 352 295.7v-79.4a32 32 0 0 1 13.58-26.16l82.71-58.22a15.77 15.77 0 0 1 2.71-1.54 32 32 0 0 1 45 29.24v192.76a32 32 0 0 1-32 32z" }, "child": [] }, { "tag": "path", "attr": { "fill": "none", "strokeLinecap": "round", "strokeMiterlimit": "10", "strokeWidth": "32", "d": "M416 416 80 80" }, "child": [] }] });
|
|
52
|
+
const IoVolumeMute = icon({ "tag": "svg", "attr": { "viewBox": "0 0 512 512" }, "child": [{ "tag": "path", "attr": { "fill": "none", "strokeLinecap": "round", "strokeMiterlimit": "10", "strokeWidth": "32", "d": "M416 432 64 80" }, "child": [] }, { "tag": "path", "attr": { "d": "M243.33 98.86a23.89 23.89 0 0 0-25.55 1.82l-.66.51-28.52 23.35a8 8 0 0 0-.59 11.85l54.33 54.33a8 8 0 0 0 13.66-5.66v-64.49a24.51 24.51 0 0 0-12.67-21.71zm8 236.43L96.69 180.69A16 16 0 0 0 85.38 176H56a24 24 0 0 0-24 24v112a24 24 0 0 0 24 24h69.76l92 75.31a23.9 23.9 0 0 0 25.87 1.69A24.51 24.51 0 0 0 256 391.45v-44.86a16 16 0 0 0-4.67-11.3zM352 256c0-24.56-5.81-47.87-17.75-71.27a16 16 0 1 0-28.5 14.55C315.34 218.06 320 236.62 320 256q0 4-.31 8.13a8 8 0 0 0 2.32 6.25l14.36 14.36a8 8 0 0 0 13.55-4.31A146 146 0 0 0 352 256zm64 0c0-51.18-13.08-83.89-34.18-120.06a16 16 0 0 0-27.64 16.12C373.07 184.44 384 211.83 384 256c0 23.83-3.29 42.88-9.37 60.65a8 8 0 0 0 1.9 8.26L389 337.4a8 8 0 0 0 13.13-2.79C411 311.76 416 287.26 416 256z" }, "child": [] }, { "tag": "path", "attr": { "d": "M480 256c0-74.25-20.19-121.11-50.51-168.61a16 16 0 1 0-27 17.22C429.82 147.38 448 189.5 448 256c0 46.19-8.43 80.27-22.43 110.53a8 8 0 0 0 1.59 9l11.92 11.92a8 8 0 0 0 12.92-2.16C471.6 344.9 480 305 480 256z" }, "child": [] }] });
|
|
53
|
+
const IoVolumeHigh = icon({ "tag": "svg", "attr": { "viewBox": "0 0 512 512" }, "child": [{ "tag": "path", "attr": { "d": "M232 416a23.88 23.88 0 0 1-14.2-4.68 8.27 8.27 0 0 1-.66-.51L125.76 336H56a24 24 0 0 1-24-24V200a24 24 0 0 1 24-24h69.75l91.37-74.81a8.27 8.27 0 0 1 .66-.51A24 24 0 0 1 256 120v272a24 24 0 0 1-24 24zm-106.18-80zm-.27-159.86zM320 336a16 16 0 0 1-14.29-23.19c9.49-18.87 14.3-38 14.3-56.81 0-19.38-4.66-37.94-14.25-56.73a16 16 0 0 1 28.5-14.54C346.19 208.12 352 231.44 352 256c0 23.86-6 47.81-17.7 71.19A16 16 0 0 1 320 336z" }, "child": [] }, { "tag": "path", "attr": { "d": "M368 384a16 16 0 0 1-13.86-24C373.05 327.09 384 299.51 384 256c0-44.17-10.93-71.56-29.82-103.94a16 16 0 0 1 27.64-16.12C402.92 172.11 416 204.81 416 256c0 50.43-13.06 83.29-34.13 120a16 16 0 0 1-13.87 8z" }, "child": [] }, { "tag": "path", "attr": { "d": "M416 432a16 16 0 0 1-13.39-24.74C429.85 365.47 448 323.76 448 256c0-66.5-18.18-108.62-45.49-151.39a16 16 0 1 1 27-17.22C459.81 134.89 480 181.74 480 256c0 64.75-14.66 113.63-50.6 168.74A16 16 0 0 1 416 432z" }, "child": [] }] });
|
|
54
|
+
const LiaRedoAltSolid = icon({ "tag": "svg", "attr": { "viewBox": "0 0 32 32" }, "child": [{ "tag": "path", "attr": { "d": "M 16 3 C 8.832031 3 3 8.832031 3 16 C 3 23.167969 8.832031 29 16 29 C 23.167969 29 29 23.167969 29 16 L 27 16 C 27 22.085938 22.085938 27 16 27 C 9.914063 27 5 22.085938 5 16 C 5 9.914063 9.914063 5 16 5 C 19.875 5 23.261719 6.984375 25.21875 10 L 20 10 L 20 12 L 28 12 L 28 4 L 26 4 L 26 7.71875 C 23.617188 4.84375 20.019531 3 16 3 Z" }, "child": [] }] });
|
|
55
|
+
const MdDragIndicator = icon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0V0z" }, "child": [] }, { "tag": "path", "attr": { "d": "M11 18c0 1.1-.9 2-2 2s-2-.9-2-2 .9-2 2-2 2 .9 2 2zm-2-8c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0-6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm6 4c1.1 0 2-.9 2-2s-.9-2-2-2-2 .9-2 2 .9 2 2 2zm0 2c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2zm0 6c-1.1 0-2 .9-2 2s.9 2 2 2 2-.9 2-2-.9-2-2-2z" }, "child": [] }] });
|
|
56
|
+
const MdScreenShare = icon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0V0z" }, "child": [] }, { "tag": "path", "attr": { "d": "M20 18c1.1 0 1.99-.9 1.99-2L22 6a2 2 0 0 0-2-2H4c-1.11 0-2 .89-2 2v10a2 2 0 0 0 2 2H0v2h24v-2h-4zm-7-3.53v-2.19c-2.78 0-4.61.85-6 2.72.56-2.67 2.11-5.33 6-5.87V7l4 3.73-4 3.74z" }, "child": [] }] });
|
|
57
|
+
const MdStopScreenShare = icon({ "tag": "svg", "attr": { "viewBox": "0 0 24 24" }, "child": [{ "tag": "path", "attr": { "fill": "none", "d": "M0 0h24v24H0V0z" }, "child": [] }, { "tag": "path", "attr": { "d": "m21.22 18.02 2 2H24v-2h-2.78zm.77-2 .01-10a2 2 0 0 0-2-2H7.22l5.23 5.23c.18-.04.36-.07.55-.1V7.02l4 3.73-1.58 1.47 5.54 5.54c.61-.33 1.03-.99 1.03-1.74zM2.39 1.73 1.11 3l1.54 1.54c-.4.36-.65.89-.65 1.48v10a2 2 0 0 0 2 2H0v2h18.13l2.71 2.71 1.27-1.27L2.39 1.73zM7 15.02c.31-1.48.92-2.95 2.07-4.06l1.59 1.59c-1.54.38-2.7 1.18-3.66 2.47z" }, "child": [] }] });
|
|
58
|
+
const PiWaveform = icon({ "tag": "svg", "attr": { "viewBox": "0 0 256 256", "fill": "currentColor" }, "child": [{ "tag": "path", "attr": { "d": "M56,96v64a8,8,0,0,1-16,0V96a8,8,0,0,1,16,0ZM88,24a8,8,0,0,0-8,8V224a8,8,0,0,0,16,0V32A8,8,0,0,0,88,24Zm40,32a8,8,0,0,0-8,8V192a8,8,0,0,0,16,0V64A8,8,0,0,0,128,56Zm40,32a8,8,0,0,0-8,8v64a8,8,0,0,0,16,0V96A8,8,0,0,0,168,88Zm40-16a8,8,0,0,0-8,8v96a8,8,0,0,0,16,0V80A8,8,0,0,0,208,72Z" }, "child": [] }] });
|
|
59
|
+
const detectEnvironment = () => {
|
|
60
|
+
var _a, _b, _c;
|
|
61
|
+
const isBrowser = typeof window !== "undefined";
|
|
62
|
+
const getEnv = (key) => {
|
|
63
|
+
try {
|
|
64
|
+
return typeof process !== "undefined" && process.env ? process.env[key] : void 0;
|
|
65
|
+
} catch {
|
|
66
|
+
return void 0;
|
|
67
|
+
}
|
|
68
|
+
};
|
|
69
|
+
const publicEnv = getEnv("NEXT_PUBLIC_ENVIRONMENT");
|
|
70
|
+
if (publicEnv === "PRODUCTION") {
|
|
71
|
+
return "production";
|
|
72
|
+
}
|
|
73
|
+
if (publicEnv === "PREVIEW" || publicEnv === "STAGING") {
|
|
74
|
+
return "development";
|
|
75
|
+
}
|
|
76
|
+
const nodeEnv = getEnv("NODE_ENV");
|
|
77
|
+
const reactEnv = getEnv("REACT_APP_ENV");
|
|
78
|
+
if (nodeEnv === "production" || reactEnv === "production") {
|
|
79
|
+
return "production";
|
|
80
|
+
}
|
|
81
|
+
if (nodeEnv === "development" || reactEnv === "development") {
|
|
82
|
+
return "development";
|
|
83
|
+
}
|
|
84
|
+
const viteDevUrl = getEnv("VITE_DEV_SERVER_URL");
|
|
85
|
+
if (viteDevUrl !== void 0) {
|
|
86
|
+
return "development";
|
|
87
|
+
}
|
|
88
|
+
if (isBrowser) {
|
|
89
|
+
if (((_a = window.location) == null ? void 0 : _a.hostname) === "localhost" || ((_b = window.location) == null ? void 0 : _b.hostname) === "127.0.0.1") {
|
|
90
|
+
return "development";
|
|
91
|
+
}
|
|
92
|
+
if (((_c = window.location) == null ? void 0 : _c.port) && ["3000", "3001", "5173", "8080"].includes(window.location.port)) {
|
|
93
|
+
return "development";
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return "production";
|
|
97
|
+
};
|
|
98
|
+
const environment = detectEnvironment();
|
|
99
|
+
const isDevelopment = environment === "development";
|
|
100
|
+
function shouldLog() {
|
|
101
|
+
if (isDevelopment) return true;
|
|
102
|
+
try {
|
|
103
|
+
if (typeof window !== "undefined" && window.__CONVAI_DEBUG__) {
|
|
104
|
+
return true;
|
|
105
|
+
}
|
|
106
|
+
} catch {
|
|
107
|
+
}
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
const devLogger = {
|
|
111
|
+
log: (...args) => console.log("[Convai]", ...args),
|
|
112
|
+
warn: (...args) => console.warn("[Convai]", ...args),
|
|
113
|
+
error: (...args) => console.error("[Convai]", ...args),
|
|
114
|
+
info: (...args) => console.info("[Convai]", ...args),
|
|
115
|
+
debug: (...args) => console.debug("[Convai]", ...args),
|
|
116
|
+
trace: (...args) => console.trace("[Convai]", ...args)
|
|
117
|
+
};
|
|
118
|
+
const noop = () => {
|
|
119
|
+
};
|
|
120
|
+
const logger = {
|
|
121
|
+
log: (...args) => shouldLog() ? devLogger.log(...args) : noop(),
|
|
122
|
+
warn: (...args) => shouldLog() ? devLogger.warn(...args) : noop(),
|
|
123
|
+
error: (...args) => shouldLog() ? devLogger.error(...args) : noop(),
|
|
124
|
+
info: (...args) => shouldLog() ? devLogger.info(...args) : noop(),
|
|
125
|
+
debug: (...args) => shouldLog() ? devLogger.debug(...args) : noop(),
|
|
126
|
+
trace: (...args) => shouldLog() ? devLogger.trace(...args) : noop()
|
|
127
|
+
};
|
|
128
|
+
const useCharacterInfo = (characterId, apiKey, authToken, baseUrl) => {
|
|
129
|
+
const [characterInfo, setCharacterInfo] = useState({
|
|
130
|
+
name: FALLBACK_CHARACTER_NAME,
|
|
131
|
+
image: null
|
|
132
|
+
});
|
|
133
|
+
const [isLoading, setIsLoading] = useState(true);
|
|
134
|
+
const [error, setError] = useState(null);
|
|
135
|
+
useEffect(() => {
|
|
136
|
+
if (!characterId || !apiKey) {
|
|
137
|
+
setIsLoading(false);
|
|
138
|
+
return;
|
|
139
|
+
}
|
|
140
|
+
const controller = new AbortController();
|
|
141
|
+
let cancelled = false;
|
|
142
|
+
setIsLoading(true);
|
|
143
|
+
setError(null);
|
|
144
|
+
fetchCharacterInfo({
|
|
145
|
+
characterId,
|
|
146
|
+
apiKey,
|
|
147
|
+
authToken,
|
|
148
|
+
baseUrl,
|
|
149
|
+
signal: controller.signal
|
|
150
|
+
}).then((info) => {
|
|
151
|
+
if (!cancelled) setCharacterInfo(info);
|
|
152
|
+
}).catch((err) => {
|
|
153
|
+
if (cancelled || controller.signal.aborted) return;
|
|
154
|
+
const error2 = err instanceof Error ? err : new Error("Unknown error");
|
|
155
|
+
logger.error("Failed to fetch character info:", error2);
|
|
156
|
+
setError(error2);
|
|
157
|
+
}).finally(() => {
|
|
158
|
+
if (!cancelled) setIsLoading(false);
|
|
159
|
+
});
|
|
160
|
+
return () => {
|
|
161
|
+
cancelled = true;
|
|
162
|
+
controller.abort();
|
|
163
|
+
};
|
|
164
|
+
}, [characterId, apiKey, authToken, baseUrl]);
|
|
165
|
+
return { ...characterInfo, isLoading, error };
|
|
166
|
+
};
|
|
167
|
+
const aeroTheme = {
|
|
168
|
+
// Color Palette
|
|
169
|
+
colors: {
|
|
170
|
+
// Primary colors
|
|
171
|
+
primary: {
|
|
172
|
+
300: "#7dd3fc",
|
|
173
|
+
500: "#0ea5e9"
|
|
174
|
+
},
|
|
175
|
+
convai: {
|
|
176
|
+
light: "#1EB453",
|
|
177
|
+
dark: "#084c3a"
|
|
178
|
+
},
|
|
179
|
+
// Neutral colors for glass effects
|
|
180
|
+
neutral: {
|
|
181
|
+
300: "#d4d4d4",
|
|
182
|
+
400: "#a3a3a3",
|
|
183
|
+
700: "#404040",
|
|
184
|
+
800: "#262626"
|
|
185
|
+
},
|
|
186
|
+
// Glass overlay colors
|
|
187
|
+
glass: {
|
|
188
|
+
light: "rgba(255, 255, 255, 0.1)",
|
|
189
|
+
medium: "rgba(255, 255, 255, 0.15)",
|
|
190
|
+
backdrop: "rgba(255, 255, 255, 0.8)"
|
|
191
|
+
},
|
|
192
|
+
// Text colors
|
|
193
|
+
text: {
|
|
194
|
+
primary: "#1f2937",
|
|
195
|
+
secondary: "#6b7280",
|
|
196
|
+
tertiary: "#9ca3af",
|
|
197
|
+
inverse: "#ffffff"
|
|
198
|
+
}
|
|
199
|
+
},
|
|
200
|
+
// Typography
|
|
201
|
+
typography: {
|
|
202
|
+
fontFamily: {
|
|
203
|
+
body: '-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif'
|
|
204
|
+
},
|
|
205
|
+
fontSize: {
|
|
206
|
+
xs: "0.75rem",
|
|
207
|
+
sm: "0.875rem",
|
|
208
|
+
lg: "1.125rem"
|
|
209
|
+
},
|
|
210
|
+
sizes: {
|
|
211
|
+
sm: "0.875rem",
|
|
212
|
+
body: "1rem",
|
|
213
|
+
caption: "0.75rem"
|
|
214
|
+
},
|
|
215
|
+
fontWeight: {
|
|
216
|
+
semibold: 600
|
|
217
|
+
}
|
|
218
|
+
},
|
|
219
|
+
// Spacing
|
|
220
|
+
spacing: {
|
|
221
|
+
xs: "0.25rem",
|
|
222
|
+
sm: "0.5rem",
|
|
223
|
+
md: "1rem"
|
|
224
|
+
},
|
|
225
|
+
// Border Radius
|
|
226
|
+
borderRadius: {
|
|
227
|
+
sm: "0.25rem",
|
|
228
|
+
md: "0.5rem",
|
|
229
|
+
lg: "0.75rem",
|
|
230
|
+
xl: "1rem",
|
|
231
|
+
full: "9999px"
|
|
232
|
+
},
|
|
233
|
+
// Shadows
|
|
234
|
+
shadows: {
|
|
235
|
+
xl: "0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04)",
|
|
236
|
+
glass: "0 8px 32px rgba(0, 0, 0, 0.1)"
|
|
237
|
+
},
|
|
238
|
+
// Glass Effects
|
|
239
|
+
glass: {
|
|
240
|
+
backdrop: "blur(20px)",
|
|
241
|
+
backdropLight: "blur(10px)",
|
|
242
|
+
border: "1px solid rgba(255, 255, 255, 0.2)"
|
|
243
|
+
},
|
|
244
|
+
// Transitions
|
|
245
|
+
transitions: {
|
|
246
|
+
normal: "0.2s ease-in-out"
|
|
247
|
+
}
|
|
248
|
+
};
|
|
249
|
+
const iconSizes = {
|
|
250
|
+
xs: "12px",
|
|
251
|
+
sm: "16px",
|
|
252
|
+
md: "20px",
|
|
253
|
+
lg: "24px",
|
|
254
|
+
xl: "32px",
|
|
255
|
+
"2xl": "40px"
|
|
256
|
+
};
|
|
257
|
+
const iosTransitions = {
|
|
258
|
+
// Fast and snappy transitions for buttons and small elements
|
|
259
|
+
snappy: {
|
|
260
|
+
type: "spring",
|
|
261
|
+
stiffness: 400,
|
|
262
|
+
damping: 30
|
|
263
|
+
},
|
|
264
|
+
// Smooth fade with pop effect
|
|
265
|
+
fadePop: {
|
|
266
|
+
type: "spring",
|
|
267
|
+
stiffness: 300,
|
|
268
|
+
damping: 25
|
|
269
|
+
},
|
|
270
|
+
// Modal slide from bottom
|
|
271
|
+
modalSlide: {
|
|
272
|
+
type: "spring",
|
|
273
|
+
stiffness: 260,
|
|
274
|
+
damping: 22
|
|
275
|
+
}
|
|
276
|
+
};
|
|
277
|
+
const ConvaiContainer = styled(motion.div)`
|
|
278
|
+
position: fixed !important;
|
|
279
|
+
bottom: 2rem !important;
|
|
280
|
+
right: 2rem !important;
|
|
281
|
+
z-index: 1000 !important;
|
|
282
|
+
isolation: isolate;
|
|
283
|
+
background: transparent !important;
|
|
284
|
+
pointer-events: none !important;
|
|
285
|
+
|
|
286
|
+
/* Override any inherited text styles */
|
|
287
|
+
* {
|
|
288
|
+
font-family: ${aeroTheme.typography.fontFamily.body} !important;
|
|
289
|
+
color-scheme: light !important;
|
|
290
|
+
font-synthesis: none !important;
|
|
291
|
+
text-rendering: optimizeLegibility !important;
|
|
292
|
+
-webkit-font-smoothing: antialiased !important;
|
|
293
|
+
-moz-osx-font-smoothing: grayscale !important;
|
|
294
|
+
-webkit-text-size-adjust: 100% !important;
|
|
295
|
+
}
|
|
296
|
+
`;
|
|
297
|
+
const MorphingContainer = styled(motion.div)`
|
|
298
|
+
position: relative !important;
|
|
299
|
+
background: ${(props) => {
|
|
300
|
+
var _a;
|
|
301
|
+
const opacity = (_a = props.$backgroundOpacity) != null ? _a : 0.95;
|
|
302
|
+
return `rgba(252, 252, 253, ${opacity})`;
|
|
303
|
+
}} !important;
|
|
304
|
+
backdrop-filter: blur(20px) saturate(180%) !important;
|
|
305
|
+
// Subtle dual-tone border for visibility on any background
|
|
306
|
+
border: 1px solid rgba(0, 0, 0, 0.06) !important;
|
|
307
|
+
box-shadow:
|
|
308
|
+
0 0 0 1px rgba(255, 255, 255, 0.8) inset, // Inner highlight
|
|
309
|
+
0 8px 32px rgba(0, 0, 0, 0.12), // Main shadow for light backgrounds
|
|
310
|
+
0 2px 8px rgba(0, 0, 0, 0.08) !important; // Subtle depth
|
|
311
|
+
display: flex !important;
|
|
312
|
+
flex-direction: column !important;
|
|
313
|
+
overflow: hidden !important;
|
|
314
|
+
isolation: isolate;
|
|
315
|
+
pointer-events: auto !important;
|
|
316
|
+
`;
|
|
317
|
+
const ButtonContent = styled(motion.div)`
|
|
318
|
+
width: 100% !important;
|
|
319
|
+
height: 100% !important;
|
|
320
|
+
display: flex !important;
|
|
321
|
+
align-items: center !important;
|
|
322
|
+
justify-content: center !important;
|
|
323
|
+
position: absolute !important;
|
|
324
|
+
top: 0 !important;
|
|
325
|
+
left: 0 !important;
|
|
326
|
+
background: transparent !important;
|
|
327
|
+
isolation: isolate;
|
|
328
|
+
pointer-events: auto !important;
|
|
329
|
+
`;
|
|
330
|
+
const Logo = styled(motion.div)`
|
|
331
|
+
width: 2rem !important;
|
|
332
|
+
height: 2rem !important;
|
|
333
|
+
display: flex !important;
|
|
334
|
+
align-items: center !important;
|
|
335
|
+
justify-content: center !important;
|
|
336
|
+
color: ${aeroTheme.colors.primary[500]} !important;
|
|
337
|
+
isolation: isolate;
|
|
338
|
+
contain: layout style paint;
|
|
339
|
+
`;
|
|
340
|
+
const ChatContent = styled(motion.div)`
|
|
341
|
+
width: 100% !important;
|
|
342
|
+
height: 100% !important;
|
|
343
|
+
display: flex !important;
|
|
344
|
+
flex-direction: column !important;
|
|
345
|
+
position: absolute !important;
|
|
346
|
+
top: 0 !important;
|
|
347
|
+
left: 0 !important;
|
|
348
|
+
overflow: hidden !important;
|
|
349
|
+
background: transparent !important;
|
|
350
|
+
isolation: isolate;
|
|
351
|
+
pointer-events: auto !important;
|
|
352
|
+
`;
|
|
353
|
+
const Header = styled(motion.div)`
|
|
354
|
+
padding: ${aeroTheme.spacing.md} !important;
|
|
355
|
+
border-bottom: 1px solid rgba(0, 0, 0, 0.05) !important;
|
|
356
|
+
display: flex !important;
|
|
357
|
+
align-items: center !important;
|
|
358
|
+
justify-content: space-between !important;
|
|
359
|
+
background: rgba(255, 255, 255, 0.5) !important;
|
|
360
|
+
position: relative !important;
|
|
361
|
+
z-index: 10 !important;
|
|
362
|
+
isolation: isolate;
|
|
363
|
+
contain: layout style paint;
|
|
364
|
+
`;
|
|
365
|
+
const Title = styled.h3`
|
|
366
|
+
margin: 0 !important;
|
|
367
|
+
font-size: ${aeroTheme.typography.fontSize.lg} !important;
|
|
368
|
+
font-weight: ${aeroTheme.typography.fontWeight.semibold} !important;
|
|
369
|
+
font-family: ${aeroTheme.typography.fontFamily.body} !important;
|
|
370
|
+
color: ${aeroTheme.colors.text.primary} !important;
|
|
371
|
+
text-align: center !important;
|
|
372
|
+
display: flex !important;
|
|
373
|
+
align-items: center !important;
|
|
374
|
+
justify-content: center !important;
|
|
375
|
+
gap: 0.5rem !important;
|
|
376
|
+
flex: 1 !important;
|
|
377
|
+
font-synthesis: none !important;
|
|
378
|
+
text-rendering: optimizeLegibility !important;
|
|
379
|
+
-webkit-font-smoothing: antialiased !important;
|
|
380
|
+
-moz-osx-font-smoothing: grayscale !important;
|
|
381
|
+
-webkit-text-size-adjust: 100% !important;
|
|
382
|
+
isolation: isolate;
|
|
383
|
+
contain: layout style paint;
|
|
384
|
+
`;
|
|
385
|
+
styled.div`
|
|
386
|
+
display: flex !important;
|
|
387
|
+
align-items: center !important;
|
|
388
|
+
justify-content: center !important;
|
|
389
|
+
isolation: isolate;
|
|
390
|
+
contain: layout style paint;
|
|
391
|
+
`;
|
|
392
|
+
const CloseButton = styled(motion.button)`
|
|
393
|
+
background: rgba(252, 252, 253, 0.95) !important;
|
|
394
|
+
backdrop-filter: blur(20px) saturate(180%);
|
|
395
|
+
border: 1px solid rgba(0, 0, 0, 0.06) !important;
|
|
396
|
+
border-radius: 50% !important;
|
|
397
|
+
width: 2rem;
|
|
398
|
+
height: 2rem;
|
|
399
|
+
display: flex;
|
|
400
|
+
align-items: center;
|
|
401
|
+
justify-content: center;
|
|
402
|
+
cursor: pointer !important;
|
|
403
|
+
color: ${aeroTheme.colors.text.primary} !important;
|
|
404
|
+
transition: ${aeroTheme.transitions.normal};
|
|
405
|
+
z-index: 1;
|
|
406
|
+
box-shadow:
|
|
407
|
+
0 0 0 1px rgba(255, 255, 255, 0.8) inset,
|
|
408
|
+
0 2px 8px rgba(0, 0, 0, 0.08);
|
|
409
|
+
outline: none !important;
|
|
410
|
+
padding: 0 !important;
|
|
411
|
+
font-size: inherit !important;
|
|
412
|
+
font-weight: inherit !important;
|
|
413
|
+
font-family: inherit !important;
|
|
414
|
+
|
|
415
|
+
&:hover {
|
|
416
|
+
background: rgba(255, 255, 255, 1) !important;
|
|
417
|
+
color: ${aeroTheme.colors.text.primary} !important;
|
|
418
|
+
box-shadow:
|
|
419
|
+
0 0 0 1px rgba(255, 255, 255, 1) inset,
|
|
420
|
+
0 4px 12px rgba(0, 0, 0, 0.12);
|
|
421
|
+
border-color: rgba(0, 0, 0, 0.08) !important;
|
|
422
|
+
}
|
|
423
|
+
|
|
424
|
+
&:focus {
|
|
425
|
+
outline: none !important;
|
|
426
|
+
}
|
|
427
|
+
|
|
428
|
+
&:focus-visible {
|
|
429
|
+
outline: none !important;
|
|
430
|
+
}
|
|
431
|
+
`;
|
|
432
|
+
const SettingsButton = styled(motion.button)`
|
|
433
|
+
background: rgba(252, 252, 253, 0.95) !important;
|
|
434
|
+
backdrop-filter: blur(20px) saturate(180%);
|
|
435
|
+
border: 1px solid rgba(0, 0, 0, 0.06) !important;
|
|
436
|
+
border-radius: 50% !important;
|
|
437
|
+
width: 2rem;
|
|
438
|
+
height: 2rem;
|
|
439
|
+
display: flex;
|
|
440
|
+
align-items: center;
|
|
441
|
+
justify-content: center;
|
|
442
|
+
cursor: pointer !important;
|
|
443
|
+
color: ${aeroTheme.colors.text.primary} !important;
|
|
444
|
+
transition: ${aeroTheme.transitions.normal};
|
|
445
|
+
z-index: 1;
|
|
446
|
+
box-shadow:
|
|
447
|
+
0 0 0 1px rgba(255, 255, 255, 0.8) inset,
|
|
448
|
+
0 2px 8px rgba(0, 0, 0, 0.08);
|
|
449
|
+
outline: none !important;
|
|
450
|
+
padding: 0 !important;
|
|
451
|
+
font-size: inherit !important;
|
|
452
|
+
font-weight: inherit !important;
|
|
453
|
+
font-family: inherit !important;
|
|
454
|
+
|
|
455
|
+
&:hover {
|
|
456
|
+
background: rgba(255, 255, 255, 1) !important;
|
|
457
|
+
color: ${aeroTheme.colors.text.primary} !important;
|
|
458
|
+
box-shadow:
|
|
459
|
+
0 0 0 1px rgba(255, 255, 255, 1) inset,
|
|
460
|
+
0 4px 12px rgba(0, 0, 0, 0.12);
|
|
461
|
+
border-color: rgba(0, 0, 0, 0.08) !important;
|
|
462
|
+
}
|
|
463
|
+
|
|
464
|
+
&:focus {
|
|
465
|
+
outline: none !important;
|
|
466
|
+
}
|
|
467
|
+
|
|
468
|
+
&:focus-visible {
|
|
469
|
+
outline: none !important;
|
|
470
|
+
}
|
|
471
|
+
`;
|
|
472
|
+
const SettingsTray$1 = styled(motion.div)`
|
|
473
|
+
background: rgba(252, 252, 253, 0.98) !important;
|
|
474
|
+
backdrop-filter: blur(20px) saturate(180%) !important;
|
|
475
|
+
border: 1px solid rgba(0, 0, 0, 0.08) !important;
|
|
476
|
+
border-radius: ${aeroTheme.borderRadius.lg} !important;
|
|
477
|
+
box-shadow:
|
|
478
|
+
0 0 0 1px rgba(255, 255, 255, 0.9) inset,
|
|
479
|
+
0 8px 32px rgba(0, 0, 0, 0.15) !important;
|
|
480
|
+
padding: 0 !important;
|
|
481
|
+
min-width: 0 !important;
|
|
482
|
+
isolation: isolate;
|
|
483
|
+
contain: layout style paint;
|
|
484
|
+
pointer-events: auto !important;
|
|
485
|
+
`;
|
|
486
|
+
const SettingsOption = styled(motion.button)`
|
|
487
|
+
padding: ${aeroTheme.spacing.sm} ${aeroTheme.spacing.md};
|
|
488
|
+
background: transparent;
|
|
489
|
+
border: none !important;
|
|
490
|
+
border-radius: ${aeroTheme.borderRadius.md} !important;
|
|
491
|
+
color: ${aeroTheme.colors.text.primary};
|
|
492
|
+
font-family: ${aeroTheme.typography.fontFamily.body} !important;
|
|
493
|
+
font-size: ${aeroTheme.typography.sizes.sm} !important;
|
|
494
|
+
font-weight: inherit !important;
|
|
495
|
+
cursor: pointer !important;
|
|
496
|
+
transition: ${aeroTheme.transitions.normal};
|
|
497
|
+
display: flex;
|
|
498
|
+
align-items: center;
|
|
499
|
+
justify-content: center;
|
|
500
|
+
gap: ${aeroTheme.spacing.sm};
|
|
501
|
+
outline: none !important;
|
|
502
|
+
pointer-events: auto !important;
|
|
503
|
+
flex: 1;
|
|
504
|
+
min-width: 2.5rem;
|
|
505
|
+
|
|
506
|
+
&:hover {
|
|
507
|
+
background: rgba(0, 0, 0, 0.05);
|
|
508
|
+
border-color: transparent !important;
|
|
509
|
+
}
|
|
510
|
+
|
|
511
|
+
&:active {
|
|
512
|
+
background: rgba(0, 0, 0, 0.1);
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
&:focus {
|
|
516
|
+
outline: none !important;
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
&:focus-visible {
|
|
520
|
+
outline: none !important;
|
|
521
|
+
}
|
|
522
|
+
`;
|
|
523
|
+
const Content = styled(motion.div)`
|
|
524
|
+
flex: 1 !important;
|
|
525
|
+
padding: ${aeroTheme.spacing.md} !important;
|
|
526
|
+
display: flex !important;
|
|
527
|
+
flex-direction: column !important;
|
|
528
|
+
justify-content: space-between !important;
|
|
529
|
+
min-height: 0 !important;
|
|
530
|
+
z-index: 1 !important;
|
|
531
|
+
overflow: hidden !important;
|
|
532
|
+
isolation: isolate;
|
|
533
|
+
contain: layout style paint;
|
|
534
|
+
`;
|
|
535
|
+
const Footer = styled(motion.div)`
|
|
536
|
+
padding: ${aeroTheme.spacing.md} !important;
|
|
537
|
+
border-top: 1px solid rgba(0, 0, 0, 0.05) !important;
|
|
538
|
+
background: rgba(255, 255, 255, 0.5) !important;
|
|
539
|
+
position: relative !important;
|
|
540
|
+
isolation: isolate;
|
|
541
|
+
contain: layout style paint;
|
|
542
|
+
`;
|
|
543
|
+
const InputContainer = styled(motion.div)`
|
|
544
|
+
display: flex !important;
|
|
545
|
+
align-items: center !important;
|
|
546
|
+
gap: ${aeroTheme.spacing.sm} !important;
|
|
547
|
+
background: rgba(252, 252, 253, 0.95) !important;
|
|
548
|
+
backdrop-filter: blur(20px) saturate(180%) !important;
|
|
549
|
+
border: 1px solid rgba(0, 0, 0, 0.06) !important;
|
|
550
|
+
border-radius: ${aeroTheme.borderRadius.full} !important;
|
|
551
|
+
min-height: 3rem !important;
|
|
552
|
+
box-shadow:
|
|
553
|
+
0 0 0 1px rgba(255, 255, 255, 0.8) inset,
|
|
554
|
+
0 2px 12px rgba(0, 0, 0, 0.08) !important;
|
|
555
|
+
isolation: isolate;
|
|
556
|
+
contain: layout style paint;
|
|
557
|
+
`;
|
|
558
|
+
const Input = styled.input`
|
|
559
|
+
flex: 1 !important;
|
|
560
|
+
background: transparent !important;
|
|
561
|
+
border: none !important;
|
|
562
|
+
outline: none !important;
|
|
563
|
+
color: ${aeroTheme.colors.text.primary} !important;
|
|
564
|
+
font-size: ${aeroTheme.typography.fontSize.sm} !important;
|
|
565
|
+
font-family: ${aeroTheme.typography.fontFamily.body} !important;
|
|
566
|
+
border-radius: ${aeroTheme.borderRadius.full} !important;
|
|
567
|
+
padding: 0.5rem 0.75rem !important;
|
|
568
|
+
line-height: 1.5 !important;
|
|
569
|
+
min-height: 2.25rem !important;
|
|
570
|
+
font-synthesis: none !important;
|
|
571
|
+
text-rendering: optimizeLegibility !important;
|
|
572
|
+
-webkit-font-smoothing: antialiased !important;
|
|
573
|
+
-moz-osx-font-smoothing: grayscale !important;
|
|
574
|
+
-webkit-text-size-adjust: 100% !important;
|
|
575
|
+
isolation: isolate;
|
|
576
|
+
contain: layout style paint;
|
|
577
|
+
|
|
578
|
+
&::placeholder {
|
|
579
|
+
color: ${aeroTheme.colors.text.tertiary} !important;
|
|
580
|
+
font-family: ${aeroTheme.typography.fontFamily.body} !important;
|
|
581
|
+
font-size: ${aeroTheme.typography.fontSize.sm} !important;
|
|
582
|
+
}
|
|
583
|
+
|
|
584
|
+
&:focus {
|
|
585
|
+
outline: none !important;
|
|
586
|
+
border: none !important;
|
|
587
|
+
}
|
|
588
|
+
`;
|
|
589
|
+
const ActionButton = styled(motion.button)`
|
|
590
|
+
width: 2.25rem !important;
|
|
591
|
+
height: 2.25rem !important;
|
|
592
|
+
min-width: 2.25rem !important;
|
|
593
|
+
min-height: 2.25rem !important;
|
|
594
|
+
flex-shrink: 0 !important;
|
|
595
|
+
border-radius: 50% !important;
|
|
596
|
+
border: none !important;
|
|
597
|
+
background: ${(props) => props.$active ? aeroTheme.colors.convai.light : aeroTheme.colors.text.primary};
|
|
598
|
+
color: ${(props) => props.$active ? aeroTheme.colors.text.inverse : "white"};
|
|
599
|
+
display: flex !important;
|
|
600
|
+
align-items: center !important;
|
|
601
|
+
justify-content: center !important;
|
|
602
|
+
cursor: pointer !important;
|
|
603
|
+
transition: ${aeroTheme.transitions.normal} !important;
|
|
604
|
+
outline: none !important;
|
|
605
|
+
padding: 0 !important;
|
|
606
|
+
font-size: inherit !important;
|
|
607
|
+
font-weight: inherit !important;
|
|
608
|
+
font-family: inherit !important;
|
|
609
|
+
isolation: isolate;
|
|
610
|
+
contain: layout style paint;
|
|
611
|
+
|
|
612
|
+
&:hover {
|
|
613
|
+
transform: scale(1.05);
|
|
614
|
+
background: ${aeroTheme.colors.neutral[800]} !important;
|
|
615
|
+
border-color: transparent !important;
|
|
616
|
+
}
|
|
617
|
+
|
|
618
|
+
&:active {
|
|
619
|
+
transform: scale(0.95);
|
|
620
|
+
}
|
|
621
|
+
|
|
622
|
+
&:focus {
|
|
623
|
+
outline: none !important;
|
|
624
|
+
}
|
|
625
|
+
|
|
626
|
+
&:focus-visible {
|
|
627
|
+
outline: none !important;
|
|
628
|
+
}
|
|
629
|
+
`;
|
|
630
|
+
styled.div`
|
|
631
|
+
flex: 1 !important;
|
|
632
|
+
overflow-y: auto !important;
|
|
633
|
+
padding: ${aeroTheme.spacing.md} !important;
|
|
634
|
+
display: flex !important;
|
|
635
|
+
flex-direction: column !important;
|
|
636
|
+
gap: ${aeroTheme.spacing.sm} !important;
|
|
637
|
+
isolation: isolate;
|
|
638
|
+
contain: layout style paint;
|
|
639
|
+
`;
|
|
640
|
+
styled.div`
|
|
641
|
+
display: flex !important;
|
|
642
|
+
flex-direction: ${(props) => props.isUser ? "row-reverse" : "row"} !important;
|
|
643
|
+
align-items: flex-start !important;
|
|
644
|
+
gap: ${aeroTheme.spacing.sm} !important;
|
|
645
|
+
margin-bottom: ${aeroTheme.spacing.sm} !important;
|
|
646
|
+
isolation: isolate;
|
|
647
|
+
contain: layout style paint;
|
|
648
|
+
`;
|
|
649
|
+
styled.div`
|
|
650
|
+
max-width: 70% !important;
|
|
651
|
+
padding: ${aeroTheme.spacing.sm} ${aeroTheme.spacing.md} !important;
|
|
652
|
+
background: ${(props) => props.isUser ? aeroTheme.colors.primary[500] : "rgba(255, 255, 255, 0.9)"} !important;
|
|
653
|
+
color: ${(props) => props.isUser ? "white" : aeroTheme.colors.text.primary} !important;
|
|
654
|
+
border-radius: ${aeroTheme.borderRadius.lg} !important;
|
|
655
|
+
font-size: ${aeroTheme.typography.fontSize.sm} !important;
|
|
656
|
+
font-family: ${aeroTheme.typography.fontFamily.body} !important;
|
|
657
|
+
line-height: 1.4 !important;
|
|
658
|
+
word-wrap: break-word !important;
|
|
659
|
+
box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
|
|
660
|
+
font-synthesis: none !important;
|
|
661
|
+
text-rendering: optimizeLegibility !important;
|
|
662
|
+
-webkit-font-smoothing: antialiased !important;
|
|
663
|
+
-moz-osx-font-smoothing: grayscale !important;
|
|
664
|
+
-webkit-text-size-adjust: 100% !important;
|
|
665
|
+
isolation: isolate;
|
|
666
|
+
contain: layout style paint;
|
|
667
|
+
`;
|
|
668
|
+
styled.div`
|
|
669
|
+
font-size: ${aeroTheme.typography.fontSize.xs} !important;
|
|
670
|
+
font-family: ${aeroTheme.typography.fontFamily.body} !important;
|
|
671
|
+
color: ${aeroTheme.colors.text.secondary} !important;
|
|
672
|
+
margin-top: ${aeroTheme.spacing.xs} !important;
|
|
673
|
+
text-align: ${(props) => props.isUser ? "right" : "left"} !important;
|
|
674
|
+
font-synthesis: none !important;
|
|
675
|
+
text-rendering: optimizeLegibility !important;
|
|
676
|
+
-webkit-font-smoothing: antialiased !important;
|
|
677
|
+
-moz-osx-font-smoothing: grayscale !important;
|
|
678
|
+
-webkit-text-size-adjust: 100% !important;
|
|
679
|
+
isolation: isolate;
|
|
680
|
+
contain: layout style paint;
|
|
681
|
+
`;
|
|
682
|
+
styled(motion.button)`
|
|
683
|
+
position: fixed !important;
|
|
684
|
+
bottom: 2rem !important;
|
|
685
|
+
right: 2rem !important;
|
|
686
|
+
width: 4rem !important;
|
|
687
|
+
height: 4rem !important;
|
|
688
|
+
border: none !important;
|
|
689
|
+
border-radius: 50% !important;
|
|
690
|
+
background: ${aeroTheme.colors.glass.backdrop} !important;
|
|
691
|
+
backdrop-filter: ${aeroTheme.glass.backdrop} !important;
|
|
692
|
+
border: ${aeroTheme.glass.border} !important;
|
|
693
|
+
box-shadow: ${aeroTheme.shadows.glass} !important;
|
|
694
|
+
cursor: pointer !important;
|
|
695
|
+
display: flex !important;
|
|
696
|
+
align-items: center !important;
|
|
697
|
+
justify-content: center !important;
|
|
698
|
+
z-index: 1000 !important;
|
|
699
|
+
isolation: isolate;
|
|
700
|
+
contain: layout style paint;
|
|
701
|
+
|
|
702
|
+
&:hover {
|
|
703
|
+
transform: scale(1.05) !important;
|
|
704
|
+
box-shadow: ${aeroTheme.shadows.xl} !important;
|
|
705
|
+
}
|
|
706
|
+
`;
|
|
707
|
+
styled(motion.div)`
|
|
708
|
+
width: 2rem !important;
|
|
709
|
+
height: 2rem !important;
|
|
710
|
+
display: flex !important;
|
|
711
|
+
align-items: center !important;
|
|
712
|
+
justify-content: center !important;
|
|
713
|
+
color: ${aeroTheme.colors.primary[500]} !important;
|
|
714
|
+
isolation: isolate;
|
|
715
|
+
contain: layout style paint;
|
|
716
|
+
`;
|
|
717
|
+
const ConviBubble = styled.div`
|
|
718
|
+
background: rgba(252, 252, 253, 0.95) !important;
|
|
719
|
+
backdrop-filter: blur(20px) saturate(180%) !important;
|
|
720
|
+
border: 1px solid rgba(0, 0, 0, 0.06) !important;
|
|
721
|
+
border-radius: 12px 12px 12px 4px !important;
|
|
722
|
+
padding: 12px !important;
|
|
723
|
+
box-shadow:
|
|
724
|
+
0 0 0 1px rgba(255, 255, 255, 0.8) inset,
|
|
725
|
+
0 2px 8px rgba(0, 0, 0, 0.08) !important;
|
|
726
|
+
color: ${aeroTheme.colors.text.primary} !important;
|
|
727
|
+
font-family: ${aeroTheme.typography.fontFamily.body} !important;
|
|
728
|
+
font-size: 14px !important;
|
|
729
|
+
line-height: 1.5 !important;
|
|
730
|
+
|
|
731
|
+
/* Markdown styling */
|
|
732
|
+
strong {
|
|
733
|
+
font-weight: 600 !important;
|
|
734
|
+
color: ${aeroTheme.colors.text.primary} !important;
|
|
735
|
+
}
|
|
736
|
+
|
|
737
|
+
em {
|
|
738
|
+
font-style: italic !important;
|
|
739
|
+
}
|
|
740
|
+
word-wrap: break-word !important;
|
|
741
|
+
max-width: 100% !important;
|
|
742
|
+
font-synthesis: none !important;
|
|
743
|
+
text-rendering: optimizeLegibility !important;
|
|
744
|
+
-webkit-font-smoothing: antialiased !important;
|
|
745
|
+
-moz-osx-font-smoothing: grayscale !important;
|
|
746
|
+
-webkit-text-size-adjust: 100% !important;
|
|
747
|
+
isolation: isolate;
|
|
748
|
+
contain: layout style paint;
|
|
749
|
+
`;
|
|
750
|
+
const ConviMessageContainer = styled.div`
|
|
751
|
+
display: flex !important;
|
|
752
|
+
flex-direction: column !important;
|
|
753
|
+
max-width: 70% !important;
|
|
754
|
+
margin-right: auto !important;
|
|
755
|
+
width: 100% !important;
|
|
756
|
+
isolation: isolate;
|
|
757
|
+
contain: layout style paint;
|
|
758
|
+
`;
|
|
759
|
+
const MessageHeader = styled.div`
|
|
760
|
+
display: flex !important;
|
|
761
|
+
align-items: center !important;
|
|
762
|
+
gap: ${aeroTheme.spacing.xs} !important;
|
|
763
|
+
margin-bottom: ${aeroTheme.spacing.xs} !important;
|
|
764
|
+
isolation: isolate;
|
|
765
|
+
contain: layout style paint;
|
|
766
|
+
`;
|
|
767
|
+
const ConviLabel = styled.span`
|
|
768
|
+
font-size: ${aeroTheme.typography.sizes.caption} !important;
|
|
769
|
+
color: #10b981 !important;
|
|
770
|
+
font-weight: 500 !important;
|
|
771
|
+
font-family: ${aeroTheme.typography.fontFamily.body} !important;
|
|
772
|
+
isolation: isolate;
|
|
773
|
+
contain: layout style paint;
|
|
774
|
+
`;
|
|
775
|
+
const LogoWrapper = styled.div`
|
|
776
|
+
width: 1rem !important;
|
|
777
|
+
height: 1rem !important;
|
|
778
|
+
display: flex !important;
|
|
779
|
+
align-items: center !important;
|
|
780
|
+
justify-content: center !important;
|
|
781
|
+
isolation: isolate;
|
|
782
|
+
contain: layout style paint;
|
|
783
|
+
`;
|
|
784
|
+
const UserBubble = styled.div`
|
|
785
|
+
background: rgba(252, 252, 253, 0.95) !important;
|
|
786
|
+
backdrop-filter: blur(20px) saturate(180%) !important;
|
|
787
|
+
border: 1px solid rgba(0, 0, 0, 0.06) !important;
|
|
788
|
+
border-radius: 12px 12px 4px 12px !important;
|
|
789
|
+
padding: 12px !important;
|
|
790
|
+
box-shadow:
|
|
791
|
+
0 0 0 1px rgba(255, 255, 255, 0.8) inset,
|
|
792
|
+
0 2px 8px rgba(0, 0, 0, 0.08) !important;
|
|
793
|
+
color: ${aeroTheme.colors.text.primary} !important;
|
|
794
|
+
font-family: ${aeroTheme.typography.fontFamily.body} !important;
|
|
795
|
+
font-size: 14px !important;
|
|
796
|
+
line-height: 1.5 !important;
|
|
797
|
+
|
|
798
|
+
/* Markdown styling */
|
|
799
|
+
strong {
|
|
800
|
+
font-weight: 600 !important;
|
|
801
|
+
color: ${aeroTheme.colors.text.primary} !important;
|
|
802
|
+
}
|
|
803
|
+
|
|
804
|
+
em {
|
|
805
|
+
font-style: italic !important;
|
|
806
|
+
}
|
|
807
|
+
word-wrap: break-word !important;
|
|
808
|
+
max-width: 100% !important;
|
|
809
|
+
font-synthesis: none !important;
|
|
810
|
+
text-rendering: optimizeLegibility !important;
|
|
811
|
+
-webkit-font-smoothing: antialiased !important;
|
|
812
|
+
-moz-osx-font-smoothing: grayscale !important;
|
|
813
|
+
-webkit-text-size-adjust: 100% !important;
|
|
814
|
+
isolation: isolate;
|
|
815
|
+
contain: layout style paint;
|
|
816
|
+
`;
|
|
817
|
+
const UserMessageContainer = styled.div`
|
|
818
|
+
display: flex !important;
|
|
819
|
+
flex-direction: column !important;
|
|
820
|
+
max-width: 70% !important;
|
|
821
|
+
margin-left: auto !important;
|
|
822
|
+
width: 100% !important;
|
|
823
|
+
isolation: isolate;
|
|
824
|
+
contain: layout style paint;
|
|
825
|
+
`;
|
|
826
|
+
const UserLabel = styled.span`
|
|
827
|
+
font-size: ${aeroTheme.typography.sizes.caption} !important;
|
|
828
|
+
color: ${aeroTheme.colors.convai.dark} !important;
|
|
829
|
+
font-weight: 500 !important;
|
|
830
|
+
font-family: ${aeroTheme.typography.fontFamily.body} !important;
|
|
831
|
+
isolation: isolate;
|
|
832
|
+
contain: layout style paint;
|
|
833
|
+
`;
|
|
834
|
+
styled(motion.div)`
|
|
835
|
+
display: flex !important;
|
|
836
|
+
flex-direction: column !important;
|
|
837
|
+
max-width: 70% !important;
|
|
838
|
+
margin: ${aeroTheme.spacing.sm} 0 !important;
|
|
839
|
+
align-self: ${(props) => props.$isUser ? "flex-end" : "flex-start"} !important;
|
|
840
|
+
isolation: isolate;
|
|
841
|
+
contain: layout style paint;
|
|
842
|
+
`;
|
|
843
|
+
styled(motion.div)`
|
|
844
|
+
background: ${(props) => props.$isUser ? "rgba(252, 252, 253, 0.95)" : "rgba(248, 250, 252, 0.95)"} !important;
|
|
845
|
+
backdrop-filter: blur(20px) saturate(180%) !important;
|
|
846
|
+
border: 1px solid rgba(0, 0, 0, 0.06) !important;
|
|
847
|
+
border-radius: ${(props) => props.$isUser ? `${aeroTheme.borderRadius.lg} ${aeroTheme.borderRadius.lg} ${aeroTheme.borderRadius.sm} ${aeroTheme.borderRadius.lg}` : `${aeroTheme.borderRadius.lg} ${aeroTheme.borderRadius.lg} ${aeroTheme.borderRadius.lg} ${aeroTheme.borderRadius.sm}`} !important;
|
|
848
|
+
padding: ${aeroTheme.spacing.md} !important;
|
|
849
|
+
box-shadow:
|
|
850
|
+
0 0 0 1px rgba(255, 255, 255, 0.8) inset,
|
|
851
|
+
0 2px 8px rgba(0, 0, 0, 0.08) !important;
|
|
852
|
+
color: ${aeroTheme.colors.text.primary} !important;
|
|
853
|
+
font-family: ${aeroTheme.typography.fontFamily.body} !important;
|
|
854
|
+
font-size: ${aeroTheme.typography.sizes.body} !important;
|
|
855
|
+
line-height: 1.5 !important;
|
|
856
|
+
word-wrap: break-word !important;
|
|
857
|
+
position: relative !important;
|
|
858
|
+
font-synthesis: none !important;
|
|
859
|
+
text-rendering: optimizeLegibility !important;
|
|
860
|
+
-webkit-font-smoothing: antialiased !important;
|
|
861
|
+
-moz-osx-font-smoothing: grayscale !important;
|
|
862
|
+
-webkit-text-size-adjust: 100% !important;
|
|
863
|
+
isolation: isolate;
|
|
864
|
+
contain: layout style paint;
|
|
865
|
+
`;
|
|
866
|
+
styled.span`
|
|
867
|
+
font-size: ${aeroTheme.typography.sizes.caption} !important;
|
|
868
|
+
color: ${aeroTheme.colors.text.secondary} !important;
|
|
869
|
+
margin-top: ${aeroTheme.spacing.xs} !important;
|
|
870
|
+
align-self: ${(props) => props.$isUser ? "flex-end" : "flex-start"} !important;
|
|
871
|
+
font-family: ${aeroTheme.typography.fontFamily.body} !important;
|
|
872
|
+
isolation: isolate;
|
|
873
|
+
contain: layout style paint;
|
|
874
|
+
`;
|
|
875
|
+
const MessageListContainer = styled.div`
|
|
876
|
+
display: flex !important;
|
|
877
|
+
flex-direction: column !important;
|
|
878
|
+
overflow-y: auto !important;
|
|
879
|
+
flex: 1 !important;
|
|
880
|
+
min-height: 0 !important;
|
|
881
|
+
width: 100% !important;
|
|
882
|
+
scroll-behavior: smooth !important;
|
|
883
|
+
isolation: isolate;
|
|
884
|
+
contain: layout style paint;
|
|
885
|
+
|
|
886
|
+
/* Custom scrollbar */
|
|
887
|
+
&::-webkit-scrollbar {
|
|
888
|
+
width: 4px !important;
|
|
889
|
+
}
|
|
890
|
+
|
|
891
|
+
&::-webkit-scrollbar-track {
|
|
892
|
+
background: transparent !important;
|
|
893
|
+
}
|
|
894
|
+
|
|
895
|
+
&::-webkit-scrollbar-thumb {
|
|
896
|
+
background: rgba(0, 0, 0, 0.1) !important;
|
|
897
|
+
border-radius: 2px !important;
|
|
898
|
+
}
|
|
899
|
+
|
|
900
|
+
&::-webkit-scrollbar-thumb:hover {
|
|
901
|
+
background: rgba(0, 0, 0, 0.2) !important;
|
|
902
|
+
}
|
|
903
|
+
`;
|
|
904
|
+
const MessageWrapper = styled.div`
|
|
905
|
+
margin-bottom: 16px !important;
|
|
906
|
+
width: 100% !important;
|
|
907
|
+
isolation: isolate;
|
|
908
|
+
contain: layout style paint;
|
|
909
|
+
|
|
910
|
+
&:last-child {
|
|
911
|
+
margin-bottom: 0 !important;
|
|
912
|
+
}
|
|
913
|
+
`;
|
|
914
|
+
const EmptyState = styled.div`
|
|
915
|
+
display: flex;
|
|
916
|
+
flex-direction: column;
|
|
917
|
+
align-items: center;
|
|
918
|
+
justify-content: center;
|
|
919
|
+
height: 100%;
|
|
920
|
+
color: ${aeroTheme.colors.text.secondary};
|
|
921
|
+
font-family: ${aeroTheme.typography.fontFamily.body};
|
|
922
|
+
font-size: ${aeroTheme.typography.sizes.body};
|
|
923
|
+
text-align: center;
|
|
924
|
+
padding: 32px;
|
|
925
|
+
`;
|
|
926
|
+
const LogoSVG = styled(motion.svg)`
|
|
927
|
+
width: ${(props) => props.$size || "100%"};
|
|
928
|
+
height: ${(props) => props.$size || "100%"};
|
|
929
|
+
fill: ${(props) => props.$color || "currentColor"};
|
|
930
|
+
outline: none;
|
|
931
|
+
-webkit-tap-highlight-color: transparent;
|
|
932
|
+
-webkit-touch-callout: none;
|
|
933
|
+
-webkit-user-select: none;
|
|
934
|
+
-khtml-user-select: none;
|
|
935
|
+
-moz-user-select: none;
|
|
936
|
+
-ms-user-select: none;
|
|
937
|
+
user-select: none;
|
|
938
|
+
`;
|
|
939
|
+
const stateVariants = {
|
|
940
|
+
idle: {
|
|
941
|
+
scale: 1,
|
|
942
|
+
opacity: 1,
|
|
943
|
+
color: "#0ea5e9"
|
|
944
|
+
// Primary blue
|
|
945
|
+
},
|
|
946
|
+
connecting: {
|
|
947
|
+
scale: [1, 1.1, 1],
|
|
948
|
+
opacity: [1, 0.7, 1],
|
|
949
|
+
color: "#f59e0b",
|
|
950
|
+
// Orange
|
|
951
|
+
transition: {
|
|
952
|
+
duration: 1.5,
|
|
953
|
+
repeat: Infinity,
|
|
954
|
+
ease: "easeInOut"
|
|
955
|
+
}
|
|
956
|
+
},
|
|
957
|
+
connected: {
|
|
958
|
+
scale: 1,
|
|
959
|
+
opacity: 1,
|
|
960
|
+
color: "#10b981",
|
|
961
|
+
// Green
|
|
962
|
+
transition: {
|
|
963
|
+
duration: 0.3,
|
|
964
|
+
ease: "easeInOut"
|
|
965
|
+
}
|
|
966
|
+
},
|
|
967
|
+
disconnected: {
|
|
968
|
+
scale: 1,
|
|
969
|
+
opacity: 0.5,
|
|
970
|
+
color: "#ef4444",
|
|
971
|
+
// Red
|
|
972
|
+
transition: {
|
|
973
|
+
duration: 0.3,
|
|
974
|
+
ease: "easeInOut"
|
|
975
|
+
}
|
|
976
|
+
},
|
|
977
|
+
typing: {
|
|
978
|
+
scale: [1, 1.05, 1],
|
|
979
|
+
opacity: 1,
|
|
980
|
+
color: "#8b5cf6",
|
|
981
|
+
// Purple
|
|
982
|
+
transition: {
|
|
983
|
+
duration: 0.8,
|
|
984
|
+
repeat: Infinity,
|
|
985
|
+
ease: "easeInOut"
|
|
986
|
+
}
|
|
987
|
+
},
|
|
988
|
+
listening: {
|
|
989
|
+
scale: [1, 1.08, 1],
|
|
990
|
+
opacity: [1, 0.8, 1],
|
|
991
|
+
color: "#3b82f6",
|
|
992
|
+
// Blue
|
|
993
|
+
transition: {
|
|
994
|
+
duration: 1.2,
|
|
995
|
+
repeat: Infinity,
|
|
996
|
+
ease: "easeInOut"
|
|
997
|
+
}
|
|
998
|
+
},
|
|
999
|
+
processing: {
|
|
1000
|
+
scale: [1, 1.02, 1],
|
|
1001
|
+
opacity: [1, 0.9, 1],
|
|
1002
|
+
color: "#6366f1",
|
|
1003
|
+
// Indigo
|
|
1004
|
+
transition: {
|
|
1005
|
+
duration: 0.6,
|
|
1006
|
+
repeat: Infinity,
|
|
1007
|
+
ease: "easeInOut"
|
|
1008
|
+
}
|
|
1009
|
+
}
|
|
1010
|
+
};
|
|
1011
|
+
const secondStripColors = {
|
|
1012
|
+
idle: "#1EB453",
|
|
1013
|
+
// Original green
|
|
1014
|
+
connecting: "#f59e0b",
|
|
1015
|
+
// Orange
|
|
1016
|
+
connected: "#1EB453",
|
|
1017
|
+
// Original green
|
|
1018
|
+
disconnected: "#ef4444",
|
|
1019
|
+
// Red
|
|
1020
|
+
typing: "#8b5cf6",
|
|
1021
|
+
// Purple
|
|
1022
|
+
listening: "#3b82f6",
|
|
1023
|
+
// Blue
|
|
1024
|
+
processing: "#6366f1"
|
|
1025
|
+
// Indigo
|
|
1026
|
+
};
|
|
1027
|
+
const pathVariants = {
|
|
1028
|
+
idle: {
|
|
1029
|
+
pathLength: 1,
|
|
1030
|
+
opacity: 1
|
|
1031
|
+
},
|
|
1032
|
+
connecting: {
|
|
1033
|
+
pathLength: [0.3, 0.7, 1],
|
|
1034
|
+
opacity: [0.5, 1, 0.8],
|
|
1035
|
+
transition: {
|
|
1036
|
+
duration: 2,
|
|
1037
|
+
repeat: Infinity,
|
|
1038
|
+
ease: "easeInOut"
|
|
1039
|
+
}
|
|
1040
|
+
},
|
|
1041
|
+
connected: {
|
|
1042
|
+
pathLength: 1,
|
|
1043
|
+
opacity: 1,
|
|
1044
|
+
transition: {
|
|
1045
|
+
duration: 0.5,
|
|
1046
|
+
ease: "easeInOut"
|
|
1047
|
+
}
|
|
1048
|
+
},
|
|
1049
|
+
disconnected: {
|
|
1050
|
+
pathLength: 0.6,
|
|
1051
|
+
opacity: 0.4,
|
|
1052
|
+
transition: {
|
|
1053
|
+
duration: 0.3,
|
|
1054
|
+
ease: "easeInOut"
|
|
1055
|
+
}
|
|
1056
|
+
},
|
|
1057
|
+
typing: {
|
|
1058
|
+
pathLength: [0.8, 1, 0.9],
|
|
1059
|
+
opacity: [1],
|
|
1060
|
+
transition: {
|
|
1061
|
+
duration: 1,
|
|
1062
|
+
repeat: Infinity,
|
|
1063
|
+
ease: "easeInOut"
|
|
1064
|
+
}
|
|
1065
|
+
},
|
|
1066
|
+
listening: {
|
|
1067
|
+
pathLength: [0.6, 1, 0.8],
|
|
1068
|
+
opacity: [0.6, 1, 0.7],
|
|
1069
|
+
transition: {
|
|
1070
|
+
duration: 1.5,
|
|
1071
|
+
repeat: Infinity,
|
|
1072
|
+
ease: "easeInOut"
|
|
1073
|
+
}
|
|
1074
|
+
},
|
|
1075
|
+
processing: {
|
|
1076
|
+
pathLength: [0.5, 1, 0.7],
|
|
1077
|
+
opacity: [0.5, 1, 0.6],
|
|
1078
|
+
transition: {
|
|
1079
|
+
duration: 1.2,
|
|
1080
|
+
repeat: Infinity,
|
|
1081
|
+
ease: "easeInOut"
|
|
1082
|
+
}
|
|
1083
|
+
}
|
|
1084
|
+
};
|
|
1085
|
+
const IconWrapper = styled.div`
|
|
1086
|
+
display: inline-flex;
|
|
1087
|
+
align-items: center;
|
|
1088
|
+
justify-content: center;
|
|
1089
|
+
width: ${(props) => {
|
|
1090
|
+
const size = props.$size || "md";
|
|
1091
|
+
return iconSizes[size];
|
|
1092
|
+
}};
|
|
1093
|
+
height: ${(props) => {
|
|
1094
|
+
const size = props.$size || "md";
|
|
1095
|
+
return iconSizes[size];
|
|
1096
|
+
}};
|
|
1097
|
+
color: ${(props) => props.$color || aeroTheme.colors.text.secondary};
|
|
1098
|
+
transition: ${aeroTheme.transitions.normal};
|
|
1099
|
+
|
|
1100
|
+
&:hover {
|
|
1101
|
+
color: ${(props) => props.$color || aeroTheme.colors.text.primary};
|
|
1102
|
+
}
|
|
1103
|
+
`;
|
|
1104
|
+
const AeroIcons = {
|
|
1105
|
+
// Chevron down icon for close button
|
|
1106
|
+
ChevronDown: ({
|
|
1107
|
+
size = "md",
|
|
1108
|
+
color
|
|
1109
|
+
}) => /* @__PURE__ */ jsx(IconWrapper, { $size: size, $color: color, children: /* @__PURE__ */ jsx(
|
|
1110
|
+
"svg",
|
|
1111
|
+
{
|
|
1112
|
+
width: iconSizes[size],
|
|
1113
|
+
height: iconSizes[size],
|
|
1114
|
+
viewBox: "0 0 24 24",
|
|
1115
|
+
fill: "none",
|
|
1116
|
+
stroke: "currentColor",
|
|
1117
|
+
strokeWidth: "2",
|
|
1118
|
+
children: /* @__PURE__ */ jsx("polyline", { points: "6,9 12,15 18,9" })
|
|
1119
|
+
}
|
|
1120
|
+
) }),
|
|
1121
|
+
// ConvaiLogo component with animated SVG
|
|
1122
|
+
ConvaiLogo: ({
|
|
1123
|
+
size = "md",
|
|
1124
|
+
color,
|
|
1125
|
+
animate = false,
|
|
1126
|
+
state = "idle"
|
|
1127
|
+
}) => {
|
|
1128
|
+
const [currentState, setCurrentState] = useState(state);
|
|
1129
|
+
const sizeMap = {
|
|
1130
|
+
xs: "0.75rem",
|
|
1131
|
+
sm: "1rem",
|
|
1132
|
+
md: "1.25rem",
|
|
1133
|
+
lg: "1.5rem",
|
|
1134
|
+
xl: "2rem",
|
|
1135
|
+
"2xl": "2.5rem"
|
|
1136
|
+
};
|
|
1137
|
+
const iconSize = sizeMap[size] || "1.25rem";
|
|
1138
|
+
useEffect(() => {
|
|
1139
|
+
setCurrentState(state);
|
|
1140
|
+
}, [state]);
|
|
1141
|
+
useEffect(() => {
|
|
1142
|
+
if (animate) {
|
|
1143
|
+
const states = [
|
|
1144
|
+
"idle",
|
|
1145
|
+
"connecting",
|
|
1146
|
+
"typing",
|
|
1147
|
+
"connected",
|
|
1148
|
+
"disconnected",
|
|
1149
|
+
"processing"
|
|
1150
|
+
];
|
|
1151
|
+
let currentIndex = 0;
|
|
1152
|
+
const interval = setInterval(() => {
|
|
1153
|
+
currentIndex = (currentIndex + 1) % states.length;
|
|
1154
|
+
setCurrentState(states[currentIndex]);
|
|
1155
|
+
}, 3e3);
|
|
1156
|
+
return () => clearInterval(interval);
|
|
1157
|
+
}
|
|
1158
|
+
}, [animate]);
|
|
1159
|
+
return /* @__PURE__ */ jsxs(
|
|
1160
|
+
LogoSVG,
|
|
1161
|
+
{
|
|
1162
|
+
viewBox: "0 0 384 384",
|
|
1163
|
+
$size: iconSize,
|
|
1164
|
+
$color: color,
|
|
1165
|
+
initial: animate ? { opacity: 1, scale: 1 } : false,
|
|
1166
|
+
animate: animate ? stateVariants[currentState] : false,
|
|
1167
|
+
transition: animate ? { duration: 0.2, ease: "easeInOut" } : void 0,
|
|
1168
|
+
whileHover: animate ? { scale: 1.1 } : void 0,
|
|
1169
|
+
whileTap: animate ? { scale: 0.9 } : void 0,
|
|
1170
|
+
children: [
|
|
1171
|
+
/* @__PURE__ */ jsx(
|
|
1172
|
+
motion.path,
|
|
1173
|
+
{
|
|
1174
|
+
d: "M0 0 C0.69959839 -0.0065712 1.39919678 -0.0131424 2.11999512 -0.01991272 C4.43522251 -0.03962096 6.75038501 -0.05130455 9.06567383 -0.0612793 C9.85831446 -0.06535482 10.65095509 -0.06943035 11.46761513 -0.07362938 C15.66541914 -0.0944825 19.86319057 -0.10878583 24.06103516 -0.11816406 C28.38410215 -0.12920936 32.70665171 -0.16358924 37.02953625 -0.20333576 C40.36427221 -0.22956171 43.69888619 -0.23786131 47.0337162 -0.24144554 C48.62643224 -0.24629839 50.21914331 -0.2578751 51.81175804 -0.27648354 C69.26930263 -0.46773456 69.26930263 -0.46773456 75.58610535 5.6245575 C80.21645647 10.85588298 81.33540199 14.49016989 81.35986328 21.4206543 C81.36497421 22.14311844 81.37008514 22.86558258 81.37535095 23.60993958 C81.38923214 25.99435754 81.38829113 28.37848592 81.38598633 30.76293945 C81.38987448 32.42436836 81.39420939 34.08579627 81.39897156 35.7472229 C81.40643089 39.22905703 81.40614488 42.71078976 81.40087891 46.19262695 C81.39508893 50.64694813 81.41200506 55.10085286 81.43522358 59.55510521 C81.44998192 62.98670871 81.4508297 66.41821245 81.44771385 69.84984207 C81.44822615 71.49163258 81.45344672 73.1334288 81.46352577 74.77518845 C81.47591195 77.07525124 81.46908575 79.37450987 81.45751953 81.67456055 C81.45814896 82.981539 81.45877838 84.28851746 81.45942688 85.63510132 C80.84254452 91.47371365 78.52732357 95.26249723 74.08520508 98.98950195 C73.40458008 99.57344727 72.72395508 100.15739258 72.02270508 100.7590332 C68.47350615 103.35653161 65.36290965 103.30519544 61.10424805 103.31884766 C59.87221649 103.32588211 58.64018494 103.33291656 57.37081909 103.34016418 C56.7124493 103.34198008 56.05407951 103.34379597 55.37575912 103.34566689 C53.30624131 103.35285669 51.23695729 103.36854441 49.16751099 103.38700867 C43.28366424 103.43934056 37.3999433 103.4873775 31.51586914 103.50292969 C27.91355676 103.5130737 24.3118307 103.54256243 20.70975113 103.5842495 C19.34402042 103.59647838 17.97820656 103.60169572 16.61242294 103.59945107 C8.73090231 103.58969075 1.87263728 103.81383569 -4.91479492 108.17700195 C-7.72384754 111.13052013 -9.15477197 114.52324306 -10.91479492 118.17700195 C-11.28512344 118.93435638 -11.65545197 119.69171082 -12.03700256 120.47201538 C-16.07726993 130.41632989 -15.43823163 140.76281367 -15.37008476 151.32646561 C-15.34801891 154.90096301 -15.35197296 158.47462262 -15.36256409 162.04916382 C-15.38412577 170.92003422 -15.36687668 179.79071265 -15.34106445 188.66156006 C-15.31962039 196.17710783 -15.31776573 203.69211414 -15.34398079 211.20765305 C-15.34831203 214.71647808 -15.32375642 218.22434564 -15.29844666 221.73306274 C-15.30371999 223.89748554 -15.31044419 226.06190545 -15.31884766 228.22631836 C-15.30393784 229.19074356 -15.28902802 230.15516876 -15.27366638 231.14881897 C-15.34508206 238.01141921 -16.9480351 243.5040945 -20.91479492 249.17700195 C-26.0538927 253.49142781 -30.93587496 255.28530317 -37.61843872 255.3309021 C-38.56028519 255.33950256 -39.50213165 255.34810303 -40.47251892 255.35696411 C-41.49906082 255.36122406 -42.52560272 255.36548401 -43.58325195 255.36987305 C-44.66992661 255.37805054 -45.75660126 255.38622803 -46.87620544 255.39465332 C-50.47500054 255.41947905 -54.07375621 255.43601739 -57.67260742 255.45043945 C-58.90313717 255.45576313 -60.13366692 255.46108681 -61.40148544 255.46657181 C-67.24488135 255.49053877 -73.08826109 255.5097802 -78.93169224 255.52259386 C-84.98841103 255.53614167 -91.04475988 255.56242227 -97.10131836 255.60913086 C-103.60933706 255.65850314 -110.11701183 255.68322666 -116.62520981 255.69032669 C-119.10105009 255.69703038 -121.57688297 255.71222923 -124.05261612 255.7362175 C-127.52547148 255.76794397 -130.99700762 255.7678936 -134.4699707 255.76049805 C-135.48436722 255.77690338 -136.49876373 255.79330872 -137.54389954 255.81021118 C-144.58516525 255.74911945 -150.0594436 254.18666177 -155.91479492 250.17700195 C-160.11922437 245.7740819 -162.02935988 241.44006577 -162.06869507 235.39033508 C-162.08159576 233.91218575 -162.08159576 233.91218575 -162.09475708 232.4041748 C-162.09901703 231.32414185 -162.10327698 230.24410889 -162.10766602 229.13134766 C-162.11584351 227.99283859 -162.124021 226.85432953 -162.13244629 225.68132019 C-162.15730395 221.90514656 -162.17381777 218.12901055 -162.18823242 214.3527832 C-162.1935561 213.06367727 -162.19887978 211.77457134 -162.20436478 210.4464016 C-162.22559522 205.02735272 -162.24472449 199.60831609 -162.25598717 194.18923664 C-162.27221051 186.43543753 -162.30535181 178.68214076 -162.36238801 170.92853099 C-162.40584504 164.81123062 -162.42174109 158.6941264 -162.42811966 152.57668114 C-162.43483541 149.9791729 -162.45006568 147.38167207 -162.47401047 144.78426552 C-162.50563862 141.14566586 -162.50570126 137.50833002 -162.49829102 133.86962891 C-162.51469635 132.7997171 -162.53110168 131.7298053 -162.54800415 130.62747192 C-162.49171427 123.86379339 -161.30224231 119.40867493 -156.91479492 114.17700195 C-150.70048633 108.27340879 -145.09496666 107.88810653 -136.89892578 107.9375 C-135.89334625 107.93548584 -134.88776672 107.93347168 -133.85171509 107.93139648 C-131.67026481 107.92785441 -129.48880427 107.92861384 -127.30735588 107.93317223 C-123.84643147 107.93877446 -120.38584111 107.92958995 -116.92494202 107.91596985 C-107.08536336 107.87889048 -97.24589659 107.86026615 -87.40625 107.87158203 C-81.38322548 107.87745814 -75.36066903 107.85904709 -69.33773994 107.82569313 C-67.05060701 107.81777476 -64.76342257 107.81896733 -62.47630119 107.82971764 C-43.45245929 108.09017669 -43.45245929 108.09017669 -26.78979492 99.73950195 C-23.10917107 94.70931602 -22.66695746 89.8832171 -22.67529297 83.76977539 C-22.67327881 83.05344437 -22.67126465 82.33711334 -22.66918945 81.59907532 C-22.66565984 80.05224746 -22.66639133 78.50540513 -22.67096519 76.95858002 C-22.67659236 74.50202502 -22.66734352 72.0459363 -22.65376282 69.5894165 C-22.61678347 62.60801088 -22.59805845 55.62676468 -22.609375 48.64526367 C-22.61525918 44.36517663 -22.59680667 40.08574677 -22.5634861 35.80579376 C-22.55558359 34.18408293 -22.55673851 32.56229947 -22.5675106 30.94060516 C-22.62477994 21.92945939 -22.61028477 13.70058716 -16.91479492 6.17700195 C-11.68775031 1.25109893 -7.03157131 0.05467437 0 0 Z",
|
|
1175
|
+
fill: "#1EB453",
|
|
1176
|
+
transform: "translate(275.914794921875,92.822998046875)",
|
|
1177
|
+
initial: animate ? { pathLength: 0 } : false,
|
|
1178
|
+
animate: animate ? pathVariants[currentState] : false,
|
|
1179
|
+
transition: animate ? { duration: 1.2, ease: "easeInOut" } : void 0
|
|
1180
|
+
}
|
|
1181
|
+
),
|
|
1182
|
+
/* @__PURE__ */ jsx(
|
|
1183
|
+
motion.path,
|
|
1184
|
+
{
|
|
1185
|
+
d: "M0 0 C0.70949799 -0.0065712 1.41899597 -0.0131424 2.1499939 -0.01991272 C4.49224974 -0.03958252 6.83444162 -0.05129463 9.17675781 -0.0612793 C9.97951393 -0.06535482 10.78227005 -0.06943035 11.60935211 -0.07362938 C15.85903157 -0.09446397 20.10867901 -0.10877652 24.35839844 -0.11816406 C28.73412049 -0.12921848 33.10933265 -0.16361435 37.48487473 -0.20333576 C40.86164252 -0.22955602 44.23828982 -0.2378607 47.61515045 -0.24144554 C49.22740367 -0.24629814 50.83965199 -0.25787412 52.45180511 -0.27648354 C61.87754315 -0.37851798 69.22600258 -0.40722527 76.90332031 5.81762695 C77.34933594 6.3487207 77.79535156 6.87981445 78.25488281 7.42700195 C78.94710937 8.20817383 78.94710937 8.20817383 79.65332031 9.00512695 C84.02596265 16.74776753 83.1900497 25.91727112 83.18066406 34.5168457 C83.18455855 36.00842913 83.18889475 37.50001147 83.19364929 38.99159241 C83.20108066 42.10738735 83.20084254 45.22306892 83.19555664 48.33886719 C83.189763 52.31076588 83.20670518 56.28219809 83.22990131 60.25401974 C83.24470727 63.33145309 83.24550113 66.40877581 83.24239159 69.48623848 C83.24290125 70.94971198 83.24807164 72.41319226 83.25820351 73.87663078 C83.37438765 93.0006229 83.37438765 93.0006229 77.12988281 100.05200195 C76.68128906 100.58567383 76.23269531 101.1193457 75.77050781 101.66918945 C70.71771348 105.69889733 65.71373184 106.5516213 59.38745117 106.56176758 C58.67430252 106.56714035 57.96115387 106.57251312 57.22639465 106.57804871 C55.69051241 106.58777157 54.15457559 106.5907876 52.6186657 106.58769226 C50.18403577 106.58318589 47.75012185 106.59729184 45.31556702 106.61608887 C39.27289347 106.65895188 33.23023785 106.67011114 27.18743896 106.68231201 C22.07081894 106.69385979 16.95452773 106.71746947 11.83804512 106.75700378 C9.4460817 106.7705322 7.05456878 106.76641182 4.6625824 106.76159668 C3.1893558 106.77094038 1.71613413 106.78110998 0.24291992 106.79223633 C-1.03724503 106.79429077 -2.31740997 106.79634521 -3.6363678 106.79846191 C-7.41637293 107.20919275 -9.82064532 108.34953123 -13.12011719 110.17700195 C-13.78011719 110.17700195 -14.44011719 110.17700195 -15.12011719 110.17700195 C-17.52280099 115.83889015 -17.41598579 121.16057712 -17.42871094 127.20043945 C-17.45386958 129.37752548 -17.47926763 131.55460875 -17.50488281 133.73168945 C-17.53360338 137.14379163 -17.55763834 140.55584604 -17.57641602 143.96801758 C-17.59814672 147.27490607 -17.63758849 150.58124339 -17.67871094 153.88793945 C-17.67882675 154.89964203 -17.67894257 155.9113446 -17.67906189 156.95370483 C-17.7841159 164.52274898 -19.03497091 169.98795471 -23.24511719 176.42700195 C-29.45623238 182.36806866 -36.31490332 183.78705333 -44.68652344 183.6730957 C-46.00401833 183.67527855 -46.00401833 183.67527855 -47.34812927 183.67750549 C-49.19102319 183.67585714 -51.03393241 183.66441631 -52.87670898 183.64355469 C-55.67914918 183.61453786 -58.47969965 183.62298099 -61.28222656 183.63598633 C-63.08366794 183.62974909 -64.88510341 183.62135826 -66.68652344 183.6105957 C-67.51382462 183.61353134 -68.34112579 183.61646698 -69.1934967 183.61949158 C-75.59165864 183.51691869 -81.40132888 182.53204156 -86.39746094 178.2043457 C-86.9453125 177.51469727 -87.49316406 176.82504883 -88.05761719 176.11450195 C-88.62351562 175.42227539 -89.18941406 174.73004883 -89.77246094 174.0168457 C-91.95579877 171.03611492 -92.25725067 169.22772898 -92.31298828 165.57885742 C-92.32905121 164.62381317 -92.34511414 163.66876892 -92.36166382 162.68478394 C-92.40618833 158.30003565 -92.44720831 153.91543939 -92.47021484 149.53051758 C-92.48674024 147.22214655 -92.51398466 144.91382596 -92.55224609 142.60571289 C-92.60721123 139.27243575 -92.62892302 135.94035974 -92.64355469 132.60668945 C-92.66622406 131.58243866 -92.68889343 130.55818787 -92.71224976 129.50289917 C-92.69275809 122.84191599 -91.55490715 118.27254494 -87.12011719 113.17700195 C-82.85713484 109.85187572 -79.42315905 108.06794719 -74.01928711 108.01928711 C-73.19800827 108.00902496 -72.37672943 107.99876282 -71.53056335 107.9881897 C-70.64617081 107.98088837 -69.76177826 107.97358704 -68.85058594 107.96606445 C-66.97362414 107.93799282 -65.09667113 107.90932834 -63.21972656 107.88012695 C-60.26391881 107.83890024 -57.30827464 107.80200782 -54.35229492 107.77563477 C-51.49721474 107.74795955 -48.64287792 107.70208605 -45.78808594 107.65356445 C-44.47060616 107.64868515 -44.47060616 107.64868515 -43.12651062 107.64370728 C-38.07403193 107.54295109 -34.47561603 107.02250373 -30.12011719 104.17700195 C-28.38692337 101.61731491 -28.38692337 101.61731491 -27.30761719 98.67700195 C-26.90929687 97.71793945 -26.51097656 96.75887695 -26.10058594 95.77075195 C-24.41267145 91.30551203 -23.99587525 87.9866657 -23.99414062 83.20214844 C-23.99227249 82.49600906 -23.99040436 81.78986969 -23.98847961 81.06233215 C-23.9844771 79.52854718 -23.98240091 77.99475626 -23.98201752 76.46096611 C-23.97859338 73.18930997 -23.95721325 69.91785101 -23.93678665 66.64626408 C-23.89884548 60.55842138 -23.86749302 54.47078699 -23.86962891 48.3828125 C-23.87042015 44.14504806 -23.84687404 39.90800348 -23.80774689 35.67042732 C-23.79734392 34.06268623 -23.79572049 32.45486145 -23.80339813 30.84710503 C-23.84202858 21.8556044 -23.77030332 13.69524181 -18.12011719 6.17700195 C-12.50415323 0.77468343 -7.52615394 0.05781024 0 0 Z",
|
|
1186
|
+
fill: secondStripColors[currentState],
|
|
1187
|
+
transform: "translate(92.1201171875,53.822998046875)",
|
|
1188
|
+
initial: animate ? { pathLength: 0 } : false,
|
|
1189
|
+
animate: animate ? pathVariants[currentState] : false,
|
|
1190
|
+
transition: animate ? { duration: 1.2, delay: 0.3, ease: "easeInOut" } : void 0
|
|
1191
|
+
}
|
|
1192
|
+
),
|
|
1193
|
+
/* @__PURE__ */ jsx(
|
|
1194
|
+
motion.path,
|
|
1195
|
+
{
|
|
1196
|
+
d: "M0 0 C0.66 0.33 1.32 0.66 2 1 C0.90033225 2.29549899 -0.20491801 3.58626071 -1.3125 4.875 C-1.92738281 5.59429687 -2.54226563 6.31359375 -3.17578125 7.0546875 C-5 9 -5 9 -8 11 C-6.60366572 6.55711819 -4.39598172 4.13475236 -1 1 C-0.67 0.67 -0.34 0.34 0 0 Z",
|
|
1197
|
+
fill: "currentColor",
|
|
1198
|
+
transform: "translate(264,95)",
|
|
1199
|
+
initial: animate ? { pathLength: 0 } : false,
|
|
1200
|
+
animate: animate ? pathVariants[currentState] : false,
|
|
1201
|
+
transition: animate ? { duration: 0.8, delay: 0.6, ease: "easeInOut" } : void 0
|
|
1202
|
+
}
|
|
1203
|
+
),
|
|
1204
|
+
/* @__PURE__ */ jsx(
|
|
1205
|
+
motion.path,
|
|
1206
|
+
{
|
|
1207
|
+
d: "M0 0 C0.66 0.33 1.32 0.66 2 1 C-0.64 3.64 -3.28 6.28 -6 9 C-6 6 -6 6 -3.5625 3.375 C-2.716875 2.59125 -1.87125 1.8075 -1 1 C-0.67 0.67 -0.34 0.34 0 0 Z",
|
|
1208
|
+
fill: "currentColor",
|
|
1209
|
+
transform: "translate(79,56)",
|
|
1210
|
+
initial: animate ? { pathLength: 0 } : false,
|
|
1211
|
+
animate: animate ? pathVariants[currentState] : false,
|
|
1212
|
+
transition: animate ? { duration: 0.8, delay: 0.9, ease: "easeInOut" } : void 0
|
|
1213
|
+
}
|
|
1214
|
+
)
|
|
1215
|
+
]
|
|
1216
|
+
}
|
|
1217
|
+
);
|
|
1218
|
+
}
|
|
1219
|
+
};
|
|
1220
|
+
styled.button`
|
|
1221
|
+
display: inline-flex !important;
|
|
1222
|
+
align-items: center !important;
|
|
1223
|
+
justify-content: center !important;
|
|
1224
|
+
width: ${(props) => {
|
|
1225
|
+
const size = props.$size || "md";
|
|
1226
|
+
return iconSizes[size];
|
|
1227
|
+
}} !important;
|
|
1228
|
+
height: ${(props) => {
|
|
1229
|
+
const size = props.$size || "md";
|
|
1230
|
+
return iconSizes[size];
|
|
1231
|
+
}} !important;
|
|
1232
|
+
border: none !important;
|
|
1233
|
+
border-radius: ${aeroTheme.borderRadius.md} !important;
|
|
1234
|
+
background: ${(props) => props.$variant === "glass" ? aeroTheme.colors.glass.light : "transparent"} !important;
|
|
1235
|
+
backdrop-filter: ${(props) => props.$variant === "glass" ? aeroTheme.glass.backdropLight : "none"} !important;
|
|
1236
|
+
color: ${aeroTheme.colors.text.secondary} !important;
|
|
1237
|
+
cursor: pointer !important;
|
|
1238
|
+
transition: ${aeroTheme.transitions.normal} !important;
|
|
1239
|
+
|
|
1240
|
+
&:hover {
|
|
1241
|
+
background: ${(props) => props.$variant === "glass" ? aeroTheme.colors.glass.medium : aeroTheme.colors.glass.light} !important;
|
|
1242
|
+
color: ${aeroTheme.colors.text.primary} !important;
|
|
1243
|
+
transform: translateY(-1px) !important;
|
|
1244
|
+
}
|
|
1245
|
+
|
|
1246
|
+
&:active {
|
|
1247
|
+
transform: translateY(0) !important;
|
|
1248
|
+
}
|
|
1249
|
+
`;
|
|
1250
|
+
const { ChevronDown, ConvaiLogo } = AeroIcons;
|
|
1251
|
+
const css$1 = (...objs) => Object.assign({}, ...objs);
|
|
1252
|
+
const SiteCard = ({ href, resolver }) => {
|
|
1253
|
+
const [meta, setMeta] = React.useState(null);
|
|
1254
|
+
const [faviconOk, setFaviconOk] = React.useState(true);
|
|
1255
|
+
const [imageOk, setImageOk] = React.useState(true);
|
|
1256
|
+
const [focused, setFocused] = React.useState(false);
|
|
1257
|
+
React.useEffect(() => {
|
|
1258
|
+
let live = true;
|
|
1259
|
+
resolveLinkPreviewCached(resolver, href).then((m) => {
|
|
1260
|
+
if (live && isCardWorthy(m)) setMeta(m);
|
|
1261
|
+
});
|
|
1262
|
+
return () => {
|
|
1263
|
+
live = false;
|
|
1264
|
+
};
|
|
1265
|
+
}, [href, resolver]);
|
|
1266
|
+
if (!meta) return null;
|
|
1267
|
+
const favicon = faviconFor(meta, href);
|
|
1268
|
+
return /* @__PURE__ */ jsxs(
|
|
1269
|
+
"a",
|
|
1270
|
+
{
|
|
1271
|
+
href,
|
|
1272
|
+
target: "_blank",
|
|
1273
|
+
rel: "noopener noreferrer",
|
|
1274
|
+
"data-convai-part": "message-site-card",
|
|
1275
|
+
style: css$1(presentationStyles.siteCard, focused ? presentationStyles.linkFocus : {}),
|
|
1276
|
+
onFocus: (e) => setFocused(e.target.matches(":focus-visible")),
|
|
1277
|
+
onBlur: () => setFocused(false),
|
|
1278
|
+
children: [
|
|
1279
|
+
/* @__PURE__ */ jsxs("span", { style: css$1(presentationStyles.siteHeader), children: [
|
|
1280
|
+
favicon && faviconOk && /* @__PURE__ */ jsx(
|
|
1281
|
+
"img",
|
|
1282
|
+
{
|
|
1283
|
+
src: favicon,
|
|
1284
|
+
alt: "",
|
|
1285
|
+
"data-convai-part": "message-site-favicon",
|
|
1286
|
+
style: css$1(presentationStyles.siteFavicon),
|
|
1287
|
+
onError: () => setFaviconOk(false)
|
|
1288
|
+
}
|
|
1289
|
+
),
|
|
1290
|
+
/* @__PURE__ */ jsx("span", { "data-convai-part": "message-site-name", style: css$1(presentationStyles.siteName), children: siteNameFor(meta, href) })
|
|
1291
|
+
] }),
|
|
1292
|
+
meta.title && /* @__PURE__ */ jsx("span", { "data-convai-part": "message-site-title", style: css$1(presentationStyles.siteTitle), children: meta.title }),
|
|
1293
|
+
meta.description && /* @__PURE__ */ jsx("span", { "data-convai-part": "message-site-description", style: css$1(presentationStyles.siteDescription), children: meta.description }),
|
|
1294
|
+
meta.image && imageOk && /* @__PURE__ */ jsx(
|
|
1295
|
+
"img",
|
|
1296
|
+
{
|
|
1297
|
+
src: meta.image,
|
|
1298
|
+
alt: "",
|
|
1299
|
+
loading: "lazy",
|
|
1300
|
+
"data-convai-part": "message-site-image",
|
|
1301
|
+
style: css$1(presentationStyles.siteImage),
|
|
1302
|
+
onError: () => setImageOk(false)
|
|
1303
|
+
}
|
|
1304
|
+
)
|
|
1305
|
+
]
|
|
1306
|
+
}
|
|
1307
|
+
);
|
|
1308
|
+
};
|
|
1309
|
+
const css = (...objs) => Object.assign({}, ...objs);
|
|
1310
|
+
const Glyph = ({ name, style }) => /* @__PURE__ */ jsx("span", { style: css(presentationStyles.contactGlyph, style != null ? style : {}), dangerouslySetInnerHTML: { __html: glyph(name) } });
|
|
1311
|
+
const useFocusRing = () => {
|
|
1312
|
+
const [focused, setFocused] = React.useState(false);
|
|
1313
|
+
return {
|
|
1314
|
+
style: focused ? presentationStyles.linkFocus : {},
|
|
1315
|
+
onFocus: (e) => setFocused(e.target.matches(":focus-visible")),
|
|
1316
|
+
onBlur: () => setFocused(false)
|
|
1317
|
+
};
|
|
1318
|
+
};
|
|
1319
|
+
const Anchor = ({ href, kind, label }) => {
|
|
1320
|
+
const ring = useFocusRing();
|
|
1321
|
+
const display = label === href ? compactUrl(label) : label;
|
|
1322
|
+
return /* @__PURE__ */ jsxs(
|
|
1323
|
+
"a",
|
|
1324
|
+
{
|
|
1325
|
+
href,
|
|
1326
|
+
target: "_blank",
|
|
1327
|
+
rel: "noopener noreferrer",
|
|
1328
|
+
title: hoverTitle(kind, href, display),
|
|
1329
|
+
"data-convai-part": "message-link",
|
|
1330
|
+
style: css(presentationStyles.link, ring.style),
|
|
1331
|
+
onFocus: ring.onFocus,
|
|
1332
|
+
onBlur: ring.onBlur,
|
|
1333
|
+
children: [
|
|
1334
|
+
display,
|
|
1335
|
+
kind === "ftp" && /* @__PURE__ */ jsx("span", { "data-convai-part": "message-link-badge", style: css(presentationStyles.badge), children: "FTP" })
|
|
1336
|
+
]
|
|
1337
|
+
}
|
|
1338
|
+
);
|
|
1339
|
+
};
|
|
1340
|
+
const ContactChip = ({ href, kind }) => {
|
|
1341
|
+
const ring = useFocusRing();
|
|
1342
|
+
return /* @__PURE__ */ jsxs(
|
|
1343
|
+
"a",
|
|
1344
|
+
{
|
|
1345
|
+
href,
|
|
1346
|
+
title: hoverTitle(kind, href, href),
|
|
1347
|
+
"data-convai-part": "message-contact",
|
|
1348
|
+
style: css(presentationStyles.contact, ring.style),
|
|
1349
|
+
onFocus: ring.onFocus,
|
|
1350
|
+
onBlur: ring.onBlur,
|
|
1351
|
+
children: [
|
|
1352
|
+
/* @__PURE__ */ jsx(Glyph, { name: kind }),
|
|
1353
|
+
/* @__PURE__ */ jsx("span", { children: contactLabel(href) })
|
|
1354
|
+
]
|
|
1355
|
+
}
|
|
1356
|
+
);
|
|
1357
|
+
};
|
|
1358
|
+
const DocumentCard = ({ href }) => {
|
|
1359
|
+
const ring = useFocusRing();
|
|
1360
|
+
let host = "";
|
|
1361
|
+
try {
|
|
1362
|
+
host = new URL(href).host;
|
|
1363
|
+
} catch {
|
|
1364
|
+
}
|
|
1365
|
+
return /* @__PURE__ */ jsxs(
|
|
1366
|
+
"a",
|
|
1367
|
+
{
|
|
1368
|
+
href,
|
|
1369
|
+
target: "_blank",
|
|
1370
|
+
rel: "noopener noreferrer",
|
|
1371
|
+
title: href,
|
|
1372
|
+
"data-convai-part": "message-file-card",
|
|
1373
|
+
style: css(presentationStyles.fileCard, ring.style),
|
|
1374
|
+
onFocus: ring.onFocus,
|
|
1375
|
+
onBlur: ring.onBlur,
|
|
1376
|
+
children: [
|
|
1377
|
+
/* @__PURE__ */ jsx("span", { "data-convai-part": "message-file-icon", style: css(presentationStyles.fileIcon), children: documentBadge(href) }),
|
|
1378
|
+
/* @__PURE__ */ jsxs("span", { style: css(presentationStyles.fileBody), children: [
|
|
1379
|
+
/* @__PURE__ */ jsx("span", { "data-convai-part": "message-file-name", style: css(presentationStyles.fileName), children: fileNameOf(href) }),
|
|
1380
|
+
/* @__PURE__ */ jsxs("span", { "data-convai-part": "message-file-meta", style: css(presentationStyles.fileMeta), children: [
|
|
1381
|
+
host,
|
|
1382
|
+
" · Opens in a new tab"
|
|
1383
|
+
] })
|
|
1384
|
+
] })
|
|
1385
|
+
]
|
|
1386
|
+
}
|
|
1387
|
+
);
|
|
1388
|
+
};
|
|
1389
|
+
const MediaPreview = ({
|
|
1390
|
+
src,
|
|
1391
|
+
alt,
|
|
1392
|
+
kind,
|
|
1393
|
+
pageProtocol
|
|
1394
|
+
}) => {
|
|
1395
|
+
const insecure = isMixedContent(src, pageProtocol);
|
|
1396
|
+
const [state, setState] = React.useState(insecure ? "error" : "loading");
|
|
1397
|
+
const cardRef = React.useRef(null);
|
|
1398
|
+
React.useEffect(() => {
|
|
1399
|
+
injectKeyframes(document);
|
|
1400
|
+
}, []);
|
|
1401
|
+
React.useEffect(() => {
|
|
1402
|
+
if (state !== "loading") return;
|
|
1403
|
+
const t = setTimeout(() => setState((s) => s === "loading" ? "error" : s), PREVIEW_TIMEOUT_MS);
|
|
1404
|
+
return () => clearTimeout(t);
|
|
1405
|
+
}, [state]);
|
|
1406
|
+
if (state === "error") {
|
|
1407
|
+
return /* @__PURE__ */ jsxs("span", { "data-convai-part": "message-media-unavailable", style: css(presentationStyles.unavailable), children: [
|
|
1408
|
+
"Preview unavailable — ",
|
|
1409
|
+
describeUrl(src),
|
|
1410
|
+
insecure ? " (insecure URL)" : ""
|
|
1411
|
+
] });
|
|
1412
|
+
}
|
|
1413
|
+
const ready = state === "ready";
|
|
1414
|
+
const open = () => openLightbox({
|
|
1415
|
+
src,
|
|
1416
|
+
alt,
|
|
1417
|
+
caption: describeUrl(src),
|
|
1418
|
+
href: src,
|
|
1419
|
+
root: document,
|
|
1420
|
+
returnFocusTo: cardRef.current
|
|
1421
|
+
});
|
|
1422
|
+
const buttonProps = kind === "image" ? {
|
|
1423
|
+
role: "button",
|
|
1424
|
+
tabIndex: 0,
|
|
1425
|
+
"aria-label": `Open image: ${fileNameOf(src)}`,
|
|
1426
|
+
onClick: open,
|
|
1427
|
+
onKeyDown: (e) => {
|
|
1428
|
+
if (e.key === "Enter" || e.key === " ") {
|
|
1429
|
+
e.preventDefault();
|
|
1430
|
+
open();
|
|
1431
|
+
}
|
|
1432
|
+
}
|
|
1433
|
+
} : {};
|
|
1434
|
+
return /* @__PURE__ */ jsxs(Fragment, { children: [
|
|
1435
|
+
/* @__PURE__ */ jsxs(
|
|
1436
|
+
"span",
|
|
1437
|
+
{
|
|
1438
|
+
ref: cardRef,
|
|
1439
|
+
"data-convai-part": "message-media-card",
|
|
1440
|
+
style: css(presentationStyles.card, kind === "image" ? presentationStyles.cardButton : {}),
|
|
1441
|
+
...buttonProps,
|
|
1442
|
+
children: [
|
|
1443
|
+
kind === "image" ? /* @__PURE__ */ jsx(
|
|
1444
|
+
"img",
|
|
1445
|
+
{
|
|
1446
|
+
src,
|
|
1447
|
+
alt,
|
|
1448
|
+
loading: "lazy",
|
|
1449
|
+
"data-convai-part": "message-media",
|
|
1450
|
+
onLoad: () => setState("ready"),
|
|
1451
|
+
onError: () => setState("error"),
|
|
1452
|
+
style: css(presentationStyles.media, { opacity: ready ? 1 : 0 })
|
|
1453
|
+
}
|
|
1454
|
+
) : /* @__PURE__ */ jsx(
|
|
1455
|
+
"video",
|
|
1456
|
+
{
|
|
1457
|
+
src,
|
|
1458
|
+
controls: true,
|
|
1459
|
+
preload: "metadata",
|
|
1460
|
+
"data-convai-part": "message-media",
|
|
1461
|
+
onLoadedMetadata: () => setState("ready"),
|
|
1462
|
+
onError: () => setState("error"),
|
|
1463
|
+
style: css(presentationStyles.media, presentationStyles.videoMedia, { opacity: ready ? 1 : 0 })
|
|
1464
|
+
}
|
|
1465
|
+
),
|
|
1466
|
+
!ready && /* @__PURE__ */ jsx(
|
|
1467
|
+
"span",
|
|
1468
|
+
{
|
|
1469
|
+
"data-convai-skeleton": "",
|
|
1470
|
+
"data-convai-part": "message-media-skeleton",
|
|
1471
|
+
style: css(presentationStyles.skeleton),
|
|
1472
|
+
"aria-hidden": "true"
|
|
1473
|
+
}
|
|
1474
|
+
),
|
|
1475
|
+
kind === "image" && /* @__PURE__ */ jsx("span", { "data-convai-part": "message-media-zoom", style: css(presentationStyles.zoom), children: /* @__PURE__ */ jsx(Glyph, { name: "zoom", style: { fontSize: 14 } }) })
|
|
1476
|
+
]
|
|
1477
|
+
}
|
|
1478
|
+
),
|
|
1479
|
+
/* @__PURE__ */ jsx("span", { "data-convai-part": "message-media-caption", style: css(presentationStyles.caption), children: describeUrl(src) })
|
|
1480
|
+
] });
|
|
1481
|
+
};
|
|
1482
|
+
const renderNode = (node, key, media, budget, pageProtocol, resolveLinkPreview) => {
|
|
1483
|
+
switch (node.kind) {
|
|
1484
|
+
case "strong":
|
|
1485
|
+
return /* @__PURE__ */ jsx("strong", { children: node.text }, key);
|
|
1486
|
+
case "em":
|
|
1487
|
+
return /* @__PURE__ */ jsx("em", { children: node.text }, key);
|
|
1488
|
+
case "blocked":
|
|
1489
|
+
return /* @__PURE__ */ jsx(
|
|
1490
|
+
"span",
|
|
1491
|
+
{
|
|
1492
|
+
"data-convai-part": "message-link-blocked",
|
|
1493
|
+
style: css(presentationStyles.blocked),
|
|
1494
|
+
title: `Link blocked: ${node.href}`,
|
|
1495
|
+
children: node.label
|
|
1496
|
+
},
|
|
1497
|
+
key
|
|
1498
|
+
);
|
|
1499
|
+
case "image": {
|
|
1500
|
+
if (media && budget.cards < MAX_CARDS_PER_MESSAGE) {
|
|
1501
|
+
budget.cards++;
|
|
1502
|
+
return /* @__PURE__ */ jsx(MediaPreview, { src: node.src, alt: node.alt, kind: "image", pageProtocol }, key);
|
|
1503
|
+
}
|
|
1504
|
+
return /* @__PURE__ */ jsx(Anchor, { href: node.src, kind: "image", label: node.alt || node.src }, key);
|
|
1505
|
+
}
|
|
1506
|
+
case "link": {
|
|
1507
|
+
const kind = linkKindForUrl(node.href);
|
|
1508
|
+
if (kind === "email" || kind === "phone" || kind === "sms") {
|
|
1509
|
+
return media ? /* @__PURE__ */ jsx(ContactChip, { href: node.href, kind }, key) : /* @__PURE__ */ jsx(Anchor, { href: node.href, kind, label: node.label }, key);
|
|
1510
|
+
}
|
|
1511
|
+
const wantsCard = media && (kind === "image" || kind === "video" || kind === "document") && budget.cards < MAX_CARDS_PER_MESSAGE;
|
|
1512
|
+
const wantsSiteCard = media && kind === "web" && !!resolveLinkPreview && budget.cards < MAX_CARDS_PER_MESSAGE;
|
|
1513
|
+
if (wantsCard || wantsSiteCard) budget.cards++;
|
|
1514
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
1515
|
+
/* @__PURE__ */ jsx(Anchor, { href: node.href, kind, label: node.label }),
|
|
1516
|
+
wantsCard && kind === "document" && /* @__PURE__ */ jsx(DocumentCard, { href: node.href }),
|
|
1517
|
+
wantsCard && kind !== "document" && /* @__PURE__ */ jsx(MediaPreview, { src: node.href, alt: node.label, kind, pageProtocol }),
|
|
1518
|
+
wantsSiteCard && /* @__PURE__ */ jsx(SiteCard, { href: node.href, resolver: resolveLinkPreview })
|
|
1519
|
+
] }, key);
|
|
1520
|
+
}
|
|
1521
|
+
default:
|
|
1522
|
+
return /* @__PURE__ */ jsx(React.Fragment, { children: node.text }, key);
|
|
1523
|
+
}
|
|
1524
|
+
};
|
|
1525
|
+
const wrapperStyle = { whiteSpace: "pre-wrap", wordWrap: "break-word" };
|
|
1526
|
+
const MarkdownRenderer = ({
|
|
1527
|
+
text,
|
|
1528
|
+
media = true,
|
|
1529
|
+
pageProtocol,
|
|
1530
|
+
resolveLinkPreview
|
|
1531
|
+
}) => {
|
|
1532
|
+
if (!text) return /* @__PURE__ */ jsx("div", { style: wrapperStyle });
|
|
1533
|
+
const lines = text.replace(/\\n/g, "\n").split("\n");
|
|
1534
|
+
const budget = { cards: 0 };
|
|
1535
|
+
return /* @__PURE__ */ jsx("div", { style: wrapperStyle, children: lines.map((line, lineIndex) => {
|
|
1536
|
+
if (line.trim() === "" && lineIndex > 0) return /* @__PURE__ */ jsx("br", {}, `br-${lineIndex}`);
|
|
1537
|
+
const nodes = parseInlineMarkdown(line).map(
|
|
1538
|
+
(node, i) => renderNode(
|
|
1539
|
+
node,
|
|
1540
|
+
`${node.kind}-${lineIndex}-${i}`,
|
|
1541
|
+
media,
|
|
1542
|
+
budget,
|
|
1543
|
+
pageProtocol,
|
|
1544
|
+
resolveLinkPreview
|
|
1545
|
+
)
|
|
1546
|
+
);
|
|
1547
|
+
return /* @__PURE__ */ jsxs(React.Fragment, { children: [
|
|
1548
|
+
nodes.length > 0 ? nodes : line,
|
|
1549
|
+
lineIndex < lines.length - 1 && /* @__PURE__ */ jsx("br", {})
|
|
1550
|
+
] }, `line-${lineIndex}`);
|
|
1551
|
+
}) });
|
|
1552
|
+
};
|
|
1553
|
+
const UserMessage = ({
|
|
1554
|
+
message,
|
|
1555
|
+
timestamp,
|
|
1556
|
+
className,
|
|
1557
|
+
sender
|
|
1558
|
+
}) => {
|
|
1559
|
+
return /* @__PURE__ */ jsxs(UserMessageContainer, { className, children: [
|
|
1560
|
+
/* @__PURE__ */ jsxs(UserBubble, { children: [
|
|
1561
|
+
sender && /* @__PURE__ */ jsxs(MessageHeader, { children: [
|
|
1562
|
+
/* @__PURE__ */ jsx(LogoWrapper, { children: /* @__PURE__ */ jsx(FaUser, { size: 16, color: aeroTheme.colors.convai.dark }) }),
|
|
1563
|
+
/* @__PURE__ */ jsx(UserLabel, { children: sender === "User" ? "You" : sender })
|
|
1564
|
+
] }),
|
|
1565
|
+
/* @__PURE__ */ jsx(MarkdownRenderer, { text: message, media: false })
|
|
1566
|
+
] }),
|
|
1567
|
+
timestamp && /* @__PURE__ */ jsx(
|
|
1568
|
+
"span",
|
|
1569
|
+
{
|
|
1570
|
+
style: {
|
|
1571
|
+
fontSize: aeroTheme.typography.sizes.caption,
|
|
1572
|
+
color: aeroTheme.colors.text.secondary,
|
|
1573
|
+
marginTop: 4,
|
|
1574
|
+
alignSelf: "flex-end",
|
|
1575
|
+
fontFamily: aeroTheme.typography.fontFamily.body
|
|
1576
|
+
},
|
|
1577
|
+
children: timestamp
|
|
1578
|
+
}
|
|
1579
|
+
)
|
|
1580
|
+
] });
|
|
1581
|
+
};
|
|
1582
|
+
const ConviMessage = ({
|
|
1583
|
+
message,
|
|
1584
|
+
timestamp,
|
|
1585
|
+
className,
|
|
1586
|
+
showLogo = true,
|
|
1587
|
+
sender,
|
|
1588
|
+
resolveLinkPreview
|
|
1589
|
+
}) => {
|
|
1590
|
+
return /* @__PURE__ */ jsxs(ConviMessageContainer, { className, children: [
|
|
1591
|
+
/* @__PURE__ */ jsxs(ConviBubble, { children: [
|
|
1592
|
+
showLogo && /* @__PURE__ */ jsxs(MessageHeader, { children: [
|
|
1593
|
+
/* @__PURE__ */ jsx(LogoWrapper, { children: /* @__PURE__ */ jsx(
|
|
1594
|
+
ConvaiLogo,
|
|
1595
|
+
{
|
|
1596
|
+
size: "sm",
|
|
1597
|
+
color: "#10b981",
|
|
1598
|
+
animate: false,
|
|
1599
|
+
state: "connected"
|
|
1600
|
+
}
|
|
1601
|
+
) }),
|
|
1602
|
+
/* @__PURE__ */ jsx(ConviLabel, { children: sender })
|
|
1603
|
+
] }),
|
|
1604
|
+
/* @__PURE__ */ jsx(MarkdownRenderer, { text: message, resolveLinkPreview })
|
|
1605
|
+
] }),
|
|
1606
|
+
timestamp && /* @__PURE__ */ jsx(
|
|
1607
|
+
"span",
|
|
1608
|
+
{
|
|
1609
|
+
style: {
|
|
1610
|
+
fontSize: aeroTheme.typography.sizes.caption,
|
|
1611
|
+
color: aeroTheme.colors.text.secondary,
|
|
1612
|
+
marginTop: 4,
|
|
1613
|
+
alignSelf: "flex-start",
|
|
1614
|
+
fontFamily: aeroTheme.typography.fontFamily.body
|
|
1615
|
+
},
|
|
1616
|
+
children: timestamp
|
|
1617
|
+
}
|
|
1618
|
+
)
|
|
1619
|
+
] });
|
|
1620
|
+
};
|
|
1621
|
+
const MessageList = ({
|
|
1622
|
+
messages,
|
|
1623
|
+
className,
|
|
1624
|
+
isStreaming = false,
|
|
1625
|
+
forceToBottomToken,
|
|
1626
|
+
linkPreviewResolver
|
|
1627
|
+
}) => {
|
|
1628
|
+
const containerRef = useRef(null);
|
|
1629
|
+
const [shouldAutoScroll, setShouldAutoScroll] = React.useState(true);
|
|
1630
|
+
const handleScroll = useCallback((e) => {
|
|
1631
|
+
const { scrollTop, scrollHeight, clientHeight } = e.currentTarget;
|
|
1632
|
+
const isNearBottom = scrollHeight - scrollTop - clientHeight < 100;
|
|
1633
|
+
setShouldAutoScroll(isNearBottom);
|
|
1634
|
+
}, []);
|
|
1635
|
+
const scrollToBottom = useCallback(() => {
|
|
1636
|
+
const el = containerRef.current;
|
|
1637
|
+
if (!el || !shouldAutoScroll) return;
|
|
1638
|
+
try {
|
|
1639
|
+
el.scrollTo({ top: el.scrollHeight, behavior: isStreaming ? "smooth" : "auto" });
|
|
1640
|
+
} catch {
|
|
1641
|
+
el.scrollTop = el.scrollHeight;
|
|
1642
|
+
}
|
|
1643
|
+
}, [shouldAutoScroll, isStreaming]);
|
|
1644
|
+
const scrollToBottomImmediate = useCallback(() => {
|
|
1645
|
+
const el = containerRef.current;
|
|
1646
|
+
if (!el) return;
|
|
1647
|
+
try {
|
|
1648
|
+
el.scrollTo({ top: el.scrollHeight, behavior: "auto" });
|
|
1649
|
+
} catch {
|
|
1650
|
+
el.scrollTop = el.scrollHeight;
|
|
1651
|
+
}
|
|
1652
|
+
}, []);
|
|
1653
|
+
useEffect(() => {
|
|
1654
|
+
if (messages.length > 0) {
|
|
1655
|
+
requestAnimationFrame(() => {
|
|
1656
|
+
scrollToBottom();
|
|
1657
|
+
});
|
|
1658
|
+
}
|
|
1659
|
+
}, [messages.length, scrollToBottom]);
|
|
1660
|
+
useEffect(() => {
|
|
1661
|
+
const el = containerRef.current;
|
|
1662
|
+
if (!el || typeof ResizeObserver === "undefined") return;
|
|
1663
|
+
const observer = new ResizeObserver(() => {
|
|
1664
|
+
if (!shouldAutoScroll) return;
|
|
1665
|
+
try {
|
|
1666
|
+
el.scrollTo({ top: el.scrollHeight, behavior: isStreaming ? "smooth" : "auto" });
|
|
1667
|
+
} catch {
|
|
1668
|
+
el.scrollTop = el.scrollHeight;
|
|
1669
|
+
}
|
|
1670
|
+
});
|
|
1671
|
+
observer.observe(el);
|
|
1672
|
+
return () => observer.disconnect();
|
|
1673
|
+
}, [shouldAutoScroll, isStreaming]);
|
|
1674
|
+
useEffect(() => {
|
|
1675
|
+
if (forceToBottomToken !== void 0) {
|
|
1676
|
+
requestAnimationFrame(() => scrollToBottomImmediate());
|
|
1677
|
+
}
|
|
1678
|
+
}, [forceToBottomToken, scrollToBottomImmediate]);
|
|
1679
|
+
useEffect(() => {
|
|
1680
|
+
if (containerRef.current && messages.length > 0) {
|
|
1681
|
+
containerRef.current.scrollTop = containerRef.current.scrollHeight;
|
|
1682
|
+
}
|
|
1683
|
+
}, []);
|
|
1684
|
+
if (messages.length === 0) {
|
|
1685
|
+
return /* @__PURE__ */ jsxs(EmptyState, { children: [
|
|
1686
|
+
/* @__PURE__ */ jsx("p", { children: "Start a conversation" }),
|
|
1687
|
+
/* @__PURE__ */ jsx(
|
|
1688
|
+
"p",
|
|
1689
|
+
{
|
|
1690
|
+
style: {
|
|
1691
|
+
fontSize: aeroTheme.typography.sizes.caption,
|
|
1692
|
+
marginTop: 8
|
|
1693
|
+
},
|
|
1694
|
+
children: "Type a message below to begin chatting"
|
|
1695
|
+
}
|
|
1696
|
+
)
|
|
1697
|
+
] });
|
|
1698
|
+
}
|
|
1699
|
+
return /* @__PURE__ */ jsx(
|
|
1700
|
+
MessageListContainer,
|
|
1701
|
+
{
|
|
1702
|
+
ref: containerRef,
|
|
1703
|
+
className,
|
|
1704
|
+
onScroll: handleScroll,
|
|
1705
|
+
children: messages.map((message) => /* @__PURE__ */ jsx(MessageWrapper, { children: message.isUser ? /* @__PURE__ */ jsx(
|
|
1706
|
+
UserMessage,
|
|
1707
|
+
{
|
|
1708
|
+
message: message.text,
|
|
1709
|
+
timestamp: message.timestamp,
|
|
1710
|
+
sender: message.sender
|
|
1711
|
+
}
|
|
1712
|
+
) : /* @__PURE__ */ jsx(
|
|
1713
|
+
ConviMessage,
|
|
1714
|
+
{
|
|
1715
|
+
message: message.text,
|
|
1716
|
+
timestamp: message.timestamp,
|
|
1717
|
+
showLogo: message.showLogo,
|
|
1718
|
+
sender: message.sender,
|
|
1719
|
+
resolveLinkPreview: linkPreviewResolver
|
|
1720
|
+
}
|
|
1721
|
+
) }, message.id))
|
|
1722
|
+
}
|
|
1723
|
+
);
|
|
1724
|
+
};
|
|
1725
|
+
const useLocalCameraTrack = () => {
|
|
1726
|
+
const { cameraTrack, localParticipant } = useLocalParticipant();
|
|
1727
|
+
const cameraTrackRef = useMemo(() => {
|
|
1728
|
+
return {
|
|
1729
|
+
participant: localParticipant,
|
|
1730
|
+
source: Track.Source.Camera,
|
|
1731
|
+
publication: cameraTrack
|
|
1732
|
+
};
|
|
1733
|
+
}, [localParticipant, cameraTrack]);
|
|
1734
|
+
return cameraTrackRef;
|
|
1735
|
+
};
|
|
1736
|
+
const LocalVideoDisplay = ({ mirror = false }) => {
|
|
1737
|
+
var _a;
|
|
1738
|
+
const cameraTrackRef = useLocalCameraTrack();
|
|
1739
|
+
if (!((_a = cameraTrackRef.publication) == null ? void 0 : _a.track)) {
|
|
1740
|
+
return /* @__PURE__ */ jsxs(
|
|
1741
|
+
"div",
|
|
1742
|
+
{
|
|
1743
|
+
style: {
|
|
1744
|
+
width: "100%",
|
|
1745
|
+
height: "100%",
|
|
1746
|
+
display: "flex",
|
|
1747
|
+
flexDirection: "column",
|
|
1748
|
+
alignItems: "center",
|
|
1749
|
+
justifyContent: "center",
|
|
1750
|
+
color: aeroTheme.colors.neutral[400],
|
|
1751
|
+
gap: "12px",
|
|
1752
|
+
background: "#000"
|
|
1753
|
+
},
|
|
1754
|
+
children: [
|
|
1755
|
+
/* @__PURE__ */ jsx(IoVideocamOff, { size: 48 }),
|
|
1756
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "14px", textAlign: "center" }, children: "Camera is off" })
|
|
1757
|
+
]
|
|
1758
|
+
}
|
|
1759
|
+
);
|
|
1760
|
+
}
|
|
1761
|
+
return /* @__PURE__ */ jsx(
|
|
1762
|
+
"div",
|
|
1763
|
+
{
|
|
1764
|
+
style: {
|
|
1765
|
+
width: "100%",
|
|
1766
|
+
height: "100%",
|
|
1767
|
+
position: "relative"
|
|
1768
|
+
},
|
|
1769
|
+
children: /* @__PURE__ */ jsx(
|
|
1770
|
+
"div",
|
|
1771
|
+
{
|
|
1772
|
+
style: {
|
|
1773
|
+
transform: mirror ? "scaleX(-1)" : "none",
|
|
1774
|
+
width: "100%",
|
|
1775
|
+
height: "100%"
|
|
1776
|
+
},
|
|
1777
|
+
children: /* @__PURE__ */ jsx(
|
|
1778
|
+
VideoTrack,
|
|
1779
|
+
{
|
|
1780
|
+
trackRef: cameraTrackRef,
|
|
1781
|
+
style: {
|
|
1782
|
+
width: "100%",
|
|
1783
|
+
height: "100%",
|
|
1784
|
+
objectFit: "cover"
|
|
1785
|
+
}
|
|
1786
|
+
}
|
|
1787
|
+
)
|
|
1788
|
+
}
|
|
1789
|
+
)
|
|
1790
|
+
}
|
|
1791
|
+
);
|
|
1792
|
+
};
|
|
1793
|
+
const FloatingVideo = ({
|
|
1794
|
+
isVisible,
|
|
1795
|
+
onClose,
|
|
1796
|
+
mirror = true
|
|
1797
|
+
}) => {
|
|
1798
|
+
const room = useRoomContext();
|
|
1799
|
+
const [position, setPosition] = useState({ x: 20, y: 20 });
|
|
1800
|
+
const [isDragging, setIsDragging] = useState(false);
|
|
1801
|
+
const containerRef = useRef(null);
|
|
1802
|
+
const handleDragEnd = (event, info) => {
|
|
1803
|
+
var _a, _b;
|
|
1804
|
+
setIsDragging(false);
|
|
1805
|
+
const windowWidth = window.innerWidth;
|
|
1806
|
+
const windowHeight = window.innerHeight;
|
|
1807
|
+
const containerWidth = ((_a = containerRef.current) == null ? void 0 : _a.offsetWidth) || 320;
|
|
1808
|
+
const containerHeight = ((_b = containerRef.current) == null ? void 0 : _b.offsetHeight) || 240;
|
|
1809
|
+
let newX = position.x + info.offset.x;
|
|
1810
|
+
let newY = position.y + info.offset.y;
|
|
1811
|
+
newX = Math.max(0, Math.min(newX, windowWidth - containerWidth));
|
|
1812
|
+
newY = Math.max(0, Math.min(newY, windowHeight - containerHeight));
|
|
1813
|
+
setPosition({ x: newX, y: newY });
|
|
1814
|
+
};
|
|
1815
|
+
if (!isVisible) return null;
|
|
1816
|
+
return /* @__PURE__ */ jsx(RoomContext.Provider, { value: room, children: /* @__PURE__ */ jsx(
|
|
1817
|
+
motion.div,
|
|
1818
|
+
{
|
|
1819
|
+
ref: containerRef,
|
|
1820
|
+
drag: true,
|
|
1821
|
+
dragMomentum: false,
|
|
1822
|
+
dragElastic: 0,
|
|
1823
|
+
onDragStart: () => setIsDragging(true),
|
|
1824
|
+
onDragEnd: handleDragEnd,
|
|
1825
|
+
initial: { opacity: 0, scale: 0.8 },
|
|
1826
|
+
animate: { opacity: 1, scale: 1 },
|
|
1827
|
+
exit: { opacity: 0, scale: 0.8 },
|
|
1828
|
+
transition: iosTransitions.modalSlide,
|
|
1829
|
+
style: {
|
|
1830
|
+
position: "fixed",
|
|
1831
|
+
left: position.x,
|
|
1832
|
+
top: position.y,
|
|
1833
|
+
zIndex: 1e4,
|
|
1834
|
+
width: "320px",
|
|
1835
|
+
borderRadius: aeroTheme.borderRadius.lg,
|
|
1836
|
+
overflow: "hidden",
|
|
1837
|
+
boxShadow: "0 8px 32px rgba(0, 0, 0, 0.3)",
|
|
1838
|
+
cursor: isDragging ? "grabbing" : "grab"
|
|
1839
|
+
},
|
|
1840
|
+
children: /* @__PURE__ */ jsxs(
|
|
1841
|
+
"div",
|
|
1842
|
+
{
|
|
1843
|
+
style: {
|
|
1844
|
+
background: "rgba(15, 23, 42, 0.95)",
|
|
1845
|
+
backdropFilter: "blur(20px)",
|
|
1846
|
+
border: `1px solid ${aeroTheme.colors.neutral[700]}`,
|
|
1847
|
+
borderRadius: aeroTheme.borderRadius.lg,
|
|
1848
|
+
overflow: "hidden"
|
|
1849
|
+
},
|
|
1850
|
+
children: [
|
|
1851
|
+
/* @__PURE__ */ jsxs(
|
|
1852
|
+
"div",
|
|
1853
|
+
{
|
|
1854
|
+
style: {
|
|
1855
|
+
display: "flex",
|
|
1856
|
+
alignItems: "center",
|
|
1857
|
+
justifyContent: "space-between",
|
|
1858
|
+
padding: "8px 12px",
|
|
1859
|
+
background: "rgba(0, 0, 0, 0.3)",
|
|
1860
|
+
borderBottom: `1px solid ${aeroTheme.colors.neutral[700]}`
|
|
1861
|
+
},
|
|
1862
|
+
children: [
|
|
1863
|
+
/* @__PURE__ */ jsxs(
|
|
1864
|
+
"div",
|
|
1865
|
+
{
|
|
1866
|
+
style: {
|
|
1867
|
+
display: "flex",
|
|
1868
|
+
alignItems: "center",
|
|
1869
|
+
gap: "8px",
|
|
1870
|
+
color: aeroTheme.colors.neutral[300],
|
|
1871
|
+
fontSize: "12px",
|
|
1872
|
+
fontWeight: 500
|
|
1873
|
+
},
|
|
1874
|
+
children: [
|
|
1875
|
+
/* @__PURE__ */ jsx(MdDragIndicator, { size: 16 }),
|
|
1876
|
+
/* @__PURE__ */ jsx("span", { children: "Your Camera" })
|
|
1877
|
+
]
|
|
1878
|
+
}
|
|
1879
|
+
),
|
|
1880
|
+
/* @__PURE__ */ jsx(
|
|
1881
|
+
motion.button,
|
|
1882
|
+
{
|
|
1883
|
+
onPointerDown: (e) => e.stopPropagation(),
|
|
1884
|
+
onClick: (e) => {
|
|
1885
|
+
e.stopPropagation();
|
|
1886
|
+
onClose();
|
|
1887
|
+
},
|
|
1888
|
+
whileHover: { scale: 1.1 },
|
|
1889
|
+
whileTap: { scale: 0.9 },
|
|
1890
|
+
style: {
|
|
1891
|
+
background: "transparent",
|
|
1892
|
+
border: "none",
|
|
1893
|
+
color: aeroTheme.colors.neutral[400],
|
|
1894
|
+
cursor: "pointer",
|
|
1895
|
+
display: "flex",
|
|
1896
|
+
alignItems: "center",
|
|
1897
|
+
justifyContent: "center",
|
|
1898
|
+
padding: "4px"
|
|
1899
|
+
},
|
|
1900
|
+
"aria-label": "Close video",
|
|
1901
|
+
children: /* @__PURE__ */ jsx(IoClose, { size: 20 })
|
|
1902
|
+
}
|
|
1903
|
+
)
|
|
1904
|
+
]
|
|
1905
|
+
}
|
|
1906
|
+
),
|
|
1907
|
+
/* @__PURE__ */ jsx(
|
|
1908
|
+
"div",
|
|
1909
|
+
{
|
|
1910
|
+
style: {
|
|
1911
|
+
position: "relative",
|
|
1912
|
+
width: "100%",
|
|
1913
|
+
paddingBottom: "75%",
|
|
1914
|
+
// 4:3 aspect ratio
|
|
1915
|
+
background: "#000"
|
|
1916
|
+
},
|
|
1917
|
+
children: /* @__PURE__ */ jsx(
|
|
1918
|
+
"div",
|
|
1919
|
+
{
|
|
1920
|
+
style: {
|
|
1921
|
+
position: "absolute",
|
|
1922
|
+
top: 0,
|
|
1923
|
+
left: 0,
|
|
1924
|
+
width: "100%",
|
|
1925
|
+
height: "100%"
|
|
1926
|
+
},
|
|
1927
|
+
children: /* @__PURE__ */ jsx(LocalVideoDisplay, { mirror })
|
|
1928
|
+
}
|
|
1929
|
+
)
|
|
1930
|
+
}
|
|
1931
|
+
)
|
|
1932
|
+
]
|
|
1933
|
+
}
|
|
1934
|
+
)
|
|
1935
|
+
}
|
|
1936
|
+
) });
|
|
1937
|
+
};
|
|
1938
|
+
const VisualizerContainer = styled.div`
|
|
1939
|
+
position: absolute;
|
|
1940
|
+
width: 100%;
|
|
1941
|
+
height: 100%;
|
|
1942
|
+
z-index: 1;
|
|
1943
|
+
pointer-events: none;
|
|
1944
|
+
border-radius: 50%;
|
|
1945
|
+
overflow: visible;
|
|
1946
|
+
`;
|
|
1947
|
+
const Canvas = styled.canvas`
|
|
1948
|
+
display: block;
|
|
1949
|
+
width: 100%;
|
|
1950
|
+
height: 100%;
|
|
1951
|
+
`;
|
|
1952
|
+
const AudioVisualizer = ({
|
|
1953
|
+
room,
|
|
1954
|
+
size = 350,
|
|
1955
|
+
color = "#10b981",
|
|
1956
|
+
opacity = 0.4,
|
|
1957
|
+
avatarRadius = 80,
|
|
1958
|
+
barCount = 64,
|
|
1959
|
+
onSpeakingChange
|
|
1960
|
+
}) => {
|
|
1961
|
+
const canvasRef = useRef(null);
|
|
1962
|
+
const animationFrameRef = useRef(null);
|
|
1963
|
+
const audioContextRef = useRef(null);
|
|
1964
|
+
const analyserRef = useRef(null);
|
|
1965
|
+
const sourceNodeRef = useRef(null);
|
|
1966
|
+
const isActiveRef = useRef(false);
|
|
1967
|
+
const timeRef = useRef(0);
|
|
1968
|
+
const previousSpeakingStateRef = useRef(false);
|
|
1969
|
+
const bandEdgesRef = useRef(null);
|
|
1970
|
+
useEffect(() => {
|
|
1971
|
+
if (!room) return;
|
|
1972
|
+
const canvas = canvasRef.current;
|
|
1973
|
+
if (!canvas) return;
|
|
1974
|
+
const ctx = canvas.getContext("2d");
|
|
1975
|
+
if (!ctx) return;
|
|
1976
|
+
canvas.width = size;
|
|
1977
|
+
canvas.height = size;
|
|
1978
|
+
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
|
1979
|
+
const analyser = audioContext.createAnalyser();
|
|
1980
|
+
analyser.fftSize = 512;
|
|
1981
|
+
analyser.smoothingTimeConstant = 0.6;
|
|
1982
|
+
audioContextRef.current = audioContext;
|
|
1983
|
+
analyserRef.current = analyser;
|
|
1984
|
+
const buildLogBands = () => {
|
|
1985
|
+
const nyquist = audioContext.sampleRate / 2;
|
|
1986
|
+
const bufferLength2 = analyser.frequencyBinCount;
|
|
1987
|
+
const minHz = 60;
|
|
1988
|
+
const maxHz = Math.min(8e3, nyquist);
|
|
1989
|
+
const edges = Array.from({ length: barCount + 1 }, (_, k) => {
|
|
1990
|
+
const hz = minHz * Math.pow(maxHz / minHz, k / barCount);
|
|
1991
|
+
const bin = Math.max(
|
|
1992
|
+
0,
|
|
1993
|
+
Math.min(bufferLength2 - 1, Math.floor(hz / nyquist * bufferLength2))
|
|
1994
|
+
);
|
|
1995
|
+
return bin;
|
|
1996
|
+
});
|
|
1997
|
+
for (let i = 1; i < edges.length; i++) {
|
|
1998
|
+
if (edges[i] <= edges[i - 1]) edges[i] = Math.min(edges[i - 1] + 1, bufferLength2 - 1);
|
|
1999
|
+
}
|
|
2000
|
+
bandEdgesRef.current = edges;
|
|
2001
|
+
};
|
|
2002
|
+
const findBotParticipant = (remoteParticipants, localParticipant) => {
|
|
2003
|
+
const participants = Array.from(remoteParticipants.values()).filter(
|
|
2004
|
+
(p) => p !== localParticipant && p !== room.localParticipant
|
|
2005
|
+
);
|
|
2006
|
+
if (participants.length === 0) {
|
|
2007
|
+
return null;
|
|
2008
|
+
}
|
|
2009
|
+
const participantsWithAudio = participants.filter((participant) => {
|
|
2010
|
+
if (!participant.trackPublications) return false;
|
|
2011
|
+
const audioTracks = Array.from(participant.trackPublications.values()).filter(
|
|
2012
|
+
(p) => p.kind === "audio" && p.track
|
|
2013
|
+
);
|
|
2014
|
+
return audioTracks.length > 0;
|
|
2015
|
+
});
|
|
2016
|
+
return participantsWithAudio.length > 0 ? participantsWithAudio[0] : participants[0];
|
|
2017
|
+
};
|
|
2018
|
+
const setupAudioSource = async () => {
|
|
2019
|
+
try {
|
|
2020
|
+
if (audioContext.state === "suspended") await audioContext.resume();
|
|
2021
|
+
const remoteParticipants = room.remoteParticipants;
|
|
2022
|
+
if (remoteParticipants.size === 0) {
|
|
2023
|
+
isActiveRef.current = false;
|
|
2024
|
+
return;
|
|
2025
|
+
}
|
|
2026
|
+
const botParticipant = findBotParticipant(remoteParticipants, room.localParticipant);
|
|
2027
|
+
if (!botParticipant) {
|
|
2028
|
+
isActiveRef.current = false;
|
|
2029
|
+
return;
|
|
2030
|
+
}
|
|
2031
|
+
const audioTracks = Array.from(botParticipant.trackPublications.values()).filter(
|
|
2032
|
+
(p) => p.kind === "audio" && p.track
|
|
2033
|
+
);
|
|
2034
|
+
if (audioTracks.length === 0) {
|
|
2035
|
+
isActiveRef.current = false;
|
|
2036
|
+
return;
|
|
2037
|
+
}
|
|
2038
|
+
const liveKitTrack = audioTracks[0].track;
|
|
2039
|
+
const mediaStreamTrack = liveKitTrack.mediaStreamTrack;
|
|
2040
|
+
if (!mediaStreamTrack) {
|
|
2041
|
+
isActiveRef.current = false;
|
|
2042
|
+
return;
|
|
2043
|
+
}
|
|
2044
|
+
const mediaStream = new MediaStream([mediaStreamTrack]);
|
|
2045
|
+
if (sourceNodeRef.current) sourceNodeRef.current.disconnect();
|
|
2046
|
+
const source = audioContext.createMediaStreamSource(mediaStream);
|
|
2047
|
+
source.connect(analyser);
|
|
2048
|
+
sourceNodeRef.current = source;
|
|
2049
|
+
buildLogBands();
|
|
2050
|
+
isActiveRef.current = true;
|
|
2051
|
+
} catch {
|
|
2052
|
+
isActiveRef.current = false;
|
|
2053
|
+
}
|
|
2054
|
+
};
|
|
2055
|
+
setupAudioSource();
|
|
2056
|
+
const setupTimeout = setTimeout(setupAudioSource, 500);
|
|
2057
|
+
const handleTrackSubscribed = (track, publication, participant) => {
|
|
2058
|
+
if (track && track.kind === "audio" && participant !== room.localParticipant) {
|
|
2059
|
+
setTimeout(setupAudioSource, 200);
|
|
2060
|
+
}
|
|
2061
|
+
};
|
|
2062
|
+
const handleParticipantConnected = (participant) => {
|
|
2063
|
+
if (participant !== room.localParticipant) setTimeout(setupAudioSource, 200);
|
|
2064
|
+
};
|
|
2065
|
+
room.on("trackSubscribed", handleTrackSubscribed);
|
|
2066
|
+
room.on("participantConnected", handleParticipantConnected);
|
|
2067
|
+
const bufferLength = analyser.frequencyBinCount;
|
|
2068
|
+
const dataArray = new Uint8Array(bufferLength);
|
|
2069
|
+
let frameParity = 0;
|
|
2070
|
+
let idleFramesPainted = 0;
|
|
2071
|
+
const draw = () => {
|
|
2072
|
+
frameParity ^= 1;
|
|
2073
|
+
if (frameParity) {
|
|
2074
|
+
animationFrameRef.current = requestAnimationFrame(draw);
|
|
2075
|
+
return;
|
|
2076
|
+
}
|
|
2077
|
+
timeRef.current += 0.16;
|
|
2078
|
+
analyser.getByteFrequencyData(dataArray);
|
|
2079
|
+
{
|
|
2080
|
+
let t = 0;
|
|
2081
|
+
for (let i = 0; i < bufferLength; i++) t += dataArray[i] || 0;
|
|
2082
|
+
if (!isActiveRef.current || t / (bufferLength * 255) < 0.01) {
|
|
2083
|
+
if (idleFramesPainted > 20) {
|
|
2084
|
+
animationFrameRef.current = requestAnimationFrame(draw);
|
|
2085
|
+
return;
|
|
2086
|
+
}
|
|
2087
|
+
idleFramesPainted++;
|
|
2088
|
+
} else {
|
|
2089
|
+
idleFramesPainted = 0;
|
|
2090
|
+
}
|
|
2091
|
+
}
|
|
2092
|
+
ctx.clearRect(0, 0, canvas.width, canvas.height);
|
|
2093
|
+
const centerX = canvas.width / 2;
|
|
2094
|
+
const centerY = canvas.height / 2;
|
|
2095
|
+
const characterRadius = 60;
|
|
2096
|
+
const innerRadius = characterRadius;
|
|
2097
|
+
const outerRadius = avatarRadius;
|
|
2098
|
+
const maxBarLength = outerRadius - innerRadius;
|
|
2099
|
+
ctx.save();
|
|
2100
|
+
const angleStep = Math.PI * 2 / barCount;
|
|
2101
|
+
let total = 0;
|
|
2102
|
+
for (let i = 0; i < bufferLength; i++) total += isActiveRef.current ? dataArray[i] || 0 : 0;
|
|
2103
|
+
const overallLevel = total / (bufferLength * 255);
|
|
2104
|
+
const speakingThreshold = 0.1;
|
|
2105
|
+
const isSpeaking = isActiveRef.current && overallLevel > speakingThreshold;
|
|
2106
|
+
if (onSpeakingChange && isSpeaking !== previousSpeakingStateRef.current) {
|
|
2107
|
+
previousSpeakingStateRef.current = isSpeaking;
|
|
2108
|
+
onSpeakingChange(isSpeaking);
|
|
2109
|
+
}
|
|
2110
|
+
if (!bandEdgesRef.current) {
|
|
2111
|
+
bandEdgesRef.current = Array.from(
|
|
2112
|
+
{ length: barCount + 1 },
|
|
2113
|
+
(_, k) => Math.floor(k / barCount * bufferLength)
|
|
2114
|
+
);
|
|
2115
|
+
}
|
|
2116
|
+
const edges = bandEdgesRef.current;
|
|
2117
|
+
const waveRevolutions = 2;
|
|
2118
|
+
const phasePerBar = Math.PI * 2 * waveRevolutions / barCount;
|
|
2119
|
+
const baseWaveAmp = 0.35;
|
|
2120
|
+
const waveAmp = baseWaveAmp * (0.3 + 0.7 * overallLevel);
|
|
2121
|
+
for (let i = 0; i < barCount; i++) {
|
|
2122
|
+
const angle = i * angleStep - Math.PI / 2;
|
|
2123
|
+
const startFreq = edges[i];
|
|
2124
|
+
const endFreq = edges[i + 1];
|
|
2125
|
+
let sum = 0;
|
|
2126
|
+
let count = 0;
|
|
2127
|
+
for (let f = startFreq; f < endFreq && f < bufferLength; f++) {
|
|
2128
|
+
sum += isActiveRef.current ? dataArray[f] || 0 : 0;
|
|
2129
|
+
count++;
|
|
2130
|
+
}
|
|
2131
|
+
const bandAvg = count > 0 ? sum / (count * 255) : 0;
|
|
2132
|
+
const energy = 0.4 * bandAvg + 0.6 * overallLevel;
|
|
2133
|
+
const wavePhase = i * phasePerBar;
|
|
2134
|
+
const wave = 1 + waveAmp * Math.sin(timeRef.current + wavePhase);
|
|
2135
|
+
const intensity = Math.min(1, energy * wave);
|
|
2136
|
+
const length = Math.max(maxBarLength * 0.03, intensity * maxBarLength * 0.95);
|
|
2137
|
+
const startX = centerX + Math.cos(angle) * innerRadius;
|
|
2138
|
+
const startY = centerY + Math.sin(angle) * innerRadius;
|
|
2139
|
+
const endX = centerX + Math.cos(angle) * (innerRadius + length);
|
|
2140
|
+
const endY = centerY + Math.sin(angle) * (innerRadius + length);
|
|
2141
|
+
ctx.strokeStyle = color;
|
|
2142
|
+
ctx.lineWidth = 5;
|
|
2143
|
+
ctx.lineCap = "round";
|
|
2144
|
+
ctx.globalAlpha = opacity * (0.5 + 0.5 * intensity);
|
|
2145
|
+
ctx.beginPath();
|
|
2146
|
+
ctx.moveTo(startX, startY);
|
|
2147
|
+
ctx.lineTo(endX, endY);
|
|
2148
|
+
ctx.stroke();
|
|
2149
|
+
}
|
|
2150
|
+
ctx.globalAlpha = 1;
|
|
2151
|
+
ctx.restore();
|
|
2152
|
+
animationFrameRef.current = requestAnimationFrame(draw);
|
|
2153
|
+
};
|
|
2154
|
+
draw();
|
|
2155
|
+
return () => {
|
|
2156
|
+
clearTimeout(setupTimeout);
|
|
2157
|
+
if (animationFrameRef.current) cancelAnimationFrame(animationFrameRef.current);
|
|
2158
|
+
if (sourceNodeRef.current) sourceNodeRef.current.disconnect();
|
|
2159
|
+
if (analyserRef.current) analyserRef.current.disconnect();
|
|
2160
|
+
if (audioContextRef.current && audioContextRef.current.state !== "closed") {
|
|
2161
|
+
audioContextRef.current.close();
|
|
2162
|
+
}
|
|
2163
|
+
room.off("trackSubscribed", handleTrackSubscribed);
|
|
2164
|
+
room.off("participantConnected", handleParticipantConnected);
|
|
2165
|
+
};
|
|
2166
|
+
}, [room, size, color, opacity, avatarRadius, barCount, onSpeakingChange]);
|
|
2167
|
+
return /* @__PURE__ */ jsx(VisualizerContainer, { style: { width: size, height: size }, children: /* @__PURE__ */ jsx(Canvas, { ref: canvasRef }) });
|
|
2168
|
+
};
|
|
2169
|
+
const SettingsTray = ({
|
|
2170
|
+
isOpen,
|
|
2171
|
+
isVideoVisible,
|
|
2172
|
+
isScreenShareActive,
|
|
2173
|
+
onReset,
|
|
2174
|
+
onDisconnect,
|
|
2175
|
+
onToggleVideo,
|
|
2176
|
+
onToggleScreenShare
|
|
2177
|
+
}) => {
|
|
2178
|
+
if (!isOpen) return null;
|
|
2179
|
+
return /* @__PURE__ */ jsx(AnimatePresence, { children: /* @__PURE__ */ jsx(
|
|
2180
|
+
SettingsTray$1,
|
|
2181
|
+
{
|
|
2182
|
+
"data-settings-tray": true,
|
|
2183
|
+
initial: { opacity: 0, y: -10, scale: 0.95 },
|
|
2184
|
+
animate: { opacity: 1, y: 0, scale: 1 },
|
|
2185
|
+
exit: { opacity: 0, y: -10, scale: 0.95 },
|
|
2186
|
+
transition: iosTransitions.fadePop,
|
|
2187
|
+
style: {
|
|
2188
|
+
position: "absolute",
|
|
2189
|
+
top: "60px",
|
|
2190
|
+
right: "16px",
|
|
2191
|
+
zIndex: 9999
|
|
2192
|
+
},
|
|
2193
|
+
onClick: (e) => e.stopPropagation(),
|
|
2194
|
+
children: /* @__PURE__ */ jsxs(
|
|
2195
|
+
"div",
|
|
2196
|
+
{
|
|
2197
|
+
style: {
|
|
2198
|
+
display: "flex",
|
|
2199
|
+
flexDirection: "row",
|
|
2200
|
+
alignItems: "center",
|
|
2201
|
+
padding: "8px",
|
|
2202
|
+
gap: "4px"
|
|
2203
|
+
},
|
|
2204
|
+
children: [
|
|
2205
|
+
onReset && /* @__PURE__ */ jsxs(
|
|
2206
|
+
SettingsOption,
|
|
2207
|
+
{
|
|
2208
|
+
onClick: onReset,
|
|
2209
|
+
whileHover: { scale: 1.02 },
|
|
2210
|
+
whileTap: { scale: 0.98 },
|
|
2211
|
+
transition: iosTransitions.snappy,
|
|
2212
|
+
style: {
|
|
2213
|
+
cursor: "pointer",
|
|
2214
|
+
flexDirection: "column",
|
|
2215
|
+
gap: "4px",
|
|
2216
|
+
padding: "8px 12px"
|
|
2217
|
+
},
|
|
2218
|
+
"aria-label": "Reset",
|
|
2219
|
+
title: "Reset",
|
|
2220
|
+
children: [
|
|
2221
|
+
/* @__PURE__ */ jsx(LiaRedoAltSolid, { size: 18 }),
|
|
2222
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "10px", fontWeight: 500 }, children: "Reset" })
|
|
2223
|
+
]
|
|
2224
|
+
}
|
|
2225
|
+
),
|
|
2226
|
+
onToggleVideo && /* @__PURE__ */ jsxs(
|
|
2227
|
+
SettingsOption,
|
|
2228
|
+
{
|
|
2229
|
+
onClick: (e) => {
|
|
2230
|
+
e.stopPropagation();
|
|
2231
|
+
onToggleVideo();
|
|
2232
|
+
},
|
|
2233
|
+
whileHover: { scale: 1.02 },
|
|
2234
|
+
whileTap: { scale: 0.98 },
|
|
2235
|
+
transition: iosTransitions.snappy,
|
|
2236
|
+
style: {
|
|
2237
|
+
cursor: "pointer",
|
|
2238
|
+
flexDirection: "column",
|
|
2239
|
+
gap: "4px",
|
|
2240
|
+
padding: "8px 12px",
|
|
2241
|
+
backgroundColor: isVideoVisible ? "rgba(16, 185, 129, 0.15)" : "transparent",
|
|
2242
|
+
color: isVideoVisible ? "#10b981" : aeroTheme.colors.text.primary
|
|
2243
|
+
},
|
|
2244
|
+
"aria-label": isVideoVisible ? "Hide Video" : "Show Video",
|
|
2245
|
+
title: isVideoVisible ? "Hide Video" : "Show Video",
|
|
2246
|
+
children: [
|
|
2247
|
+
isVideoVisible ? /* @__PURE__ */ jsx(IoVideocam, { size: 18 }) : /* @__PURE__ */ jsx(IoVideocamOff, { size: 18 }),
|
|
2248
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "10px", fontWeight: 500 }, children: "Video" })
|
|
2249
|
+
]
|
|
2250
|
+
}
|
|
2251
|
+
),
|
|
2252
|
+
onToggleScreenShare && /* @__PURE__ */ jsxs(
|
|
2253
|
+
SettingsOption,
|
|
2254
|
+
{
|
|
2255
|
+
onClick: (e) => {
|
|
2256
|
+
e.stopPropagation();
|
|
2257
|
+
onToggleScreenShare();
|
|
2258
|
+
},
|
|
2259
|
+
whileHover: { scale: 1.02 },
|
|
2260
|
+
whileTap: { scale: 0.98 },
|
|
2261
|
+
transition: iosTransitions.snappy,
|
|
2262
|
+
style: {
|
|
2263
|
+
cursor: "pointer",
|
|
2264
|
+
flexDirection: "column",
|
|
2265
|
+
gap: "4px",
|
|
2266
|
+
padding: "8px 12px",
|
|
2267
|
+
backgroundColor: isScreenShareActive ? "rgba(16, 185, 129, 0.15)" : "transparent",
|
|
2268
|
+
color: isScreenShareActive ? "#10b981" : aeroTheme.colors.text.primary
|
|
2269
|
+
},
|
|
2270
|
+
"aria-label": isScreenShareActive ? "Stop Sharing" : "Share Screen",
|
|
2271
|
+
title: isScreenShareActive ? "Stop Sharing" : "Share Screen",
|
|
2272
|
+
children: [
|
|
2273
|
+
isScreenShareActive ? /* @__PURE__ */ jsx(MdStopScreenShare, { size: 18 }) : /* @__PURE__ */ jsx(MdScreenShare, { size: 18 }),
|
|
2274
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "10px", fontWeight: 500 }, children: "Screen" })
|
|
2275
|
+
]
|
|
2276
|
+
}
|
|
2277
|
+
),
|
|
2278
|
+
onDisconnect && /* @__PURE__ */ jsxs(
|
|
2279
|
+
SettingsOption,
|
|
2280
|
+
{
|
|
2281
|
+
onClick: (e) => {
|
|
2282
|
+
e.stopPropagation();
|
|
2283
|
+
onDisconnect();
|
|
2284
|
+
},
|
|
2285
|
+
whileHover: { scale: 1.02 },
|
|
2286
|
+
whileTap: { scale: 0.98 },
|
|
2287
|
+
transition: iosTransitions.snappy,
|
|
2288
|
+
style: {
|
|
2289
|
+
cursor: "pointer",
|
|
2290
|
+
flexDirection: "column",
|
|
2291
|
+
gap: "4px",
|
|
2292
|
+
padding: "8px 12px",
|
|
2293
|
+
backgroundColor: "rgba(239, 68, 68, 0.1)",
|
|
2294
|
+
color: "#ef4444"
|
|
2295
|
+
},
|
|
2296
|
+
"aria-label": "Disconnect",
|
|
2297
|
+
title: "Disconnect",
|
|
2298
|
+
children: [
|
|
2299
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "18px" }, children: "⏻" }),
|
|
2300
|
+
/* @__PURE__ */ jsx("span", { style: { fontSize: "10px", fontWeight: 500 }, children: "Disconnect" })
|
|
2301
|
+
]
|
|
2302
|
+
}
|
|
2303
|
+
)
|
|
2304
|
+
]
|
|
2305
|
+
}
|
|
2306
|
+
)
|
|
2307
|
+
}
|
|
2308
|
+
) });
|
|
2309
|
+
};
|
|
2310
|
+
const VoiceModeOverlay = ({
|
|
2311
|
+
isActive,
|
|
2312
|
+
isTalking,
|
|
2313
|
+
isListening = false,
|
|
2314
|
+
convaiClient,
|
|
2315
|
+
characterImage,
|
|
2316
|
+
characterName = "Character",
|
|
2317
|
+
room
|
|
2318
|
+
}) => {
|
|
2319
|
+
var _a;
|
|
2320
|
+
const barsCount = 40;
|
|
2321
|
+
const audioLevelsRef = useRef(Array(barsCount).fill(0));
|
|
2322
|
+
const waveCanvasRef = useRef(null);
|
|
2323
|
+
const analyzerRef = useRef(null);
|
|
2324
|
+
const animationFrameRef = useRef(void 0);
|
|
2325
|
+
const audioContextRef = useRef(null);
|
|
2326
|
+
const waveFrameParityRef = useRef(0);
|
|
2327
|
+
const waveWasSilentRef = useRef(false);
|
|
2328
|
+
const drawWaves = () => {
|
|
2329
|
+
waveFrameParityRef.current ^= 1;
|
|
2330
|
+
if (waveFrameParityRef.current) return;
|
|
2331
|
+
const canvas = waveCanvasRef.current;
|
|
2332
|
+
if (!canvas) return;
|
|
2333
|
+
{
|
|
2334
|
+
const lv = audioLevelsRef.current;
|
|
2335
|
+
let sum = 0;
|
|
2336
|
+
for (let i = 0; i < lv.length; i++) sum += lv[i];
|
|
2337
|
+
const silent = sum / lv.length < 0.012;
|
|
2338
|
+
if (silent && waveWasSilentRef.current) return;
|
|
2339
|
+
waveWasSilentRef.current = silent;
|
|
2340
|
+
}
|
|
2341
|
+
const dpr = Math.min(window.devicePixelRatio || 1, 2);
|
|
2342
|
+
if (canvas.width !== 250 * dpr) {
|
|
2343
|
+
canvas.width = 250 * dpr;
|
|
2344
|
+
canvas.height = 80 * dpr;
|
|
2345
|
+
}
|
|
2346
|
+
const ctx = canvas.getContext("2d");
|
|
2347
|
+
if (!ctx) return;
|
|
2348
|
+
ctx.setTransform(dpr, 0, 0, dpr, 0, 0);
|
|
2349
|
+
ctx.clearRect(0, 0, 250, 80);
|
|
2350
|
+
const audioLevels = audioLevelsRef.current;
|
|
2351
|
+
const centerY = 40;
|
|
2352
|
+
const waveWidth = 250;
|
|
2353
|
+
const segments = barsCount;
|
|
2354
|
+
const avgLevel = audioLevels.reduce((sum, level) => sum + level, 0) / audioLevels.length;
|
|
2355
|
+
const waveColors = [
|
|
2356
|
+
aeroTheme.colors.convai.light,
|
|
2357
|
+
aeroTheme.colors.convai.light,
|
|
2358
|
+
"#34d399"
|
|
2359
|
+
];
|
|
2360
|
+
ctx.lineCap = "round";
|
|
2361
|
+
ctx.lineJoin = "round";
|
|
2362
|
+
for (let waveIndex = 2; waveIndex >= 0; waveIndex--) {
|
|
2363
|
+
ctx.beginPath();
|
|
2364
|
+
for (let i = 0; i <= segments; i++) {
|
|
2365
|
+
const x = i / segments * waveWidth;
|
|
2366
|
+
const levelIndex = Math.floor(i / segments * (audioLevels.length - 1));
|
|
2367
|
+
const level = audioLevels[levelIndex] || 0;
|
|
2368
|
+
const phase = (Date.now() / 500 + i * 0.2 + waveIndex * 1.5) % (Math.PI * 2);
|
|
2369
|
+
const baseAmplitude = avgLevel > 0.05 ? 2 + waveIndex * 1.5 : 0;
|
|
2370
|
+
const amplitude = baseAmplitude + level * (25 - baseAmplitude);
|
|
2371
|
+
const y = centerY + Math.sin(phase) * amplitude;
|
|
2372
|
+
if (i === 0) ctx.moveTo(x, y);
|
|
2373
|
+
else ctx.lineTo(x, y);
|
|
2374
|
+
}
|
|
2375
|
+
ctx.strokeStyle = waveColors[waveIndex];
|
|
2376
|
+
ctx.globalAlpha = 0.18 * (0.3 + avgLevel);
|
|
2377
|
+
ctx.lineWidth = 2.5 - waveIndex * 0.4 + 8 * avgLevel + 3;
|
|
2378
|
+
ctx.stroke();
|
|
2379
|
+
ctx.globalAlpha = 0.95 - waveIndex * 0.15;
|
|
2380
|
+
ctx.lineWidth = 2.5 - waveIndex * 0.4;
|
|
2381
|
+
ctx.stroke();
|
|
2382
|
+
}
|
|
2383
|
+
ctx.globalAlpha = 1;
|
|
2384
|
+
};
|
|
2385
|
+
useEffect(() => {
|
|
2386
|
+
if (!isActive) {
|
|
2387
|
+
if (animationFrameRef.current) {
|
|
2388
|
+
cancelAnimationFrame(animationFrameRef.current);
|
|
2389
|
+
}
|
|
2390
|
+
audioLevelsRef.current = Array(barsCount).fill(0);
|
|
2391
|
+
drawWaves();
|
|
2392
|
+
return;
|
|
2393
|
+
}
|
|
2394
|
+
let stream = null;
|
|
2395
|
+
const setupAudioAnalysis = async () => {
|
|
2396
|
+
try {
|
|
2397
|
+
stream = await navigator.mediaDevices.getUserMedia({ audio: true });
|
|
2398
|
+
const audioContext = new (window.AudioContext || window.webkitAudioContext)();
|
|
2399
|
+
audioContextRef.current = audioContext;
|
|
2400
|
+
const analyzer = audioContext.createAnalyser();
|
|
2401
|
+
analyzer.fftSize = 256;
|
|
2402
|
+
analyzer.smoothingTimeConstant = 0.7;
|
|
2403
|
+
analyzerRef.current = analyzer;
|
|
2404
|
+
const source = audioContext.createMediaStreamSource(stream);
|
|
2405
|
+
source.connect(analyzer);
|
|
2406
|
+
const dataArray = new Uint8Array(analyzer.fftSize);
|
|
2407
|
+
const updateLevels = () => {
|
|
2408
|
+
if (!analyzerRef.current) return;
|
|
2409
|
+
analyzer.getByteTimeDomainData(dataArray);
|
|
2410
|
+
let sum = 0;
|
|
2411
|
+
for (let i = 0; i < dataArray.length; i++) {
|
|
2412
|
+
const normalized = (dataArray[i] - 128) / 128;
|
|
2413
|
+
sum += normalized * normalized;
|
|
2414
|
+
}
|
|
2415
|
+
const rms = Math.sqrt(sum / dataArray.length);
|
|
2416
|
+
const volume = Math.min(1, rms * 3);
|
|
2417
|
+
const levels = audioLevelsRef.current;
|
|
2418
|
+
for (let i = 0; i < barsCount; i++) {
|
|
2419
|
+
const position = i / barsCount;
|
|
2420
|
+
const wavePhase = Date.now() / 300 + position * Math.PI * 2;
|
|
2421
|
+
const waveVariation = Math.sin(wavePhase) * 0.15 + 0.85;
|
|
2422
|
+
levels[i] = volume * waveVariation;
|
|
2423
|
+
}
|
|
2424
|
+
drawWaves();
|
|
2425
|
+
animationFrameRef.current = requestAnimationFrame(updateLevels);
|
|
2426
|
+
};
|
|
2427
|
+
updateLevels();
|
|
2428
|
+
} catch (error) {
|
|
2429
|
+
console.error("Error setting up audio analysis:", error);
|
|
2430
|
+
}
|
|
2431
|
+
};
|
|
2432
|
+
setupAudioAnalysis();
|
|
2433
|
+
return () => {
|
|
2434
|
+
if (animationFrameRef.current) {
|
|
2435
|
+
cancelAnimationFrame(animationFrameRef.current);
|
|
2436
|
+
}
|
|
2437
|
+
if (stream) {
|
|
2438
|
+
stream.getTracks().forEach((track) => track.stop());
|
|
2439
|
+
}
|
|
2440
|
+
if (audioContextRef.current) {
|
|
2441
|
+
audioContextRef.current.close();
|
|
2442
|
+
}
|
|
2443
|
+
};
|
|
2444
|
+
}, [isActive, barsCount]);
|
|
2445
|
+
const [isBotSpeaking, setIsBotSpeaking] = useState(false);
|
|
2446
|
+
return /* @__PURE__ */ jsxs(
|
|
2447
|
+
"div",
|
|
2448
|
+
{
|
|
2449
|
+
style: {
|
|
2450
|
+
position: "absolute",
|
|
2451
|
+
top: "50%",
|
|
2452
|
+
left: "50%",
|
|
2453
|
+
transform: "translate(-50%, -50%)",
|
|
2454
|
+
textAlign: "center",
|
|
2455
|
+
padding: "1rem",
|
|
2456
|
+
zIndex: 10,
|
|
2457
|
+
pointerEvents: "none",
|
|
2458
|
+
display: "flex",
|
|
2459
|
+
flexDirection: "column",
|
|
2460
|
+
alignItems: "center",
|
|
2461
|
+
gap: "2rem"
|
|
2462
|
+
},
|
|
2463
|
+
children: [
|
|
2464
|
+
/* @__PURE__ */ jsxs(
|
|
2465
|
+
"div",
|
|
2466
|
+
{
|
|
2467
|
+
style: {
|
|
2468
|
+
position: "relative",
|
|
2469
|
+
display: "flex",
|
|
2470
|
+
alignItems: "center",
|
|
2471
|
+
justifyContent: "center",
|
|
2472
|
+
isolation: "isolate"
|
|
2473
|
+
// Create stacking context
|
|
2474
|
+
},
|
|
2475
|
+
children: [
|
|
2476
|
+
room && /* @__PURE__ */ jsx(
|
|
2477
|
+
motion.div,
|
|
2478
|
+
{
|
|
2479
|
+
initial: { opacity: 0, scale: 0.8 },
|
|
2480
|
+
animate: {
|
|
2481
|
+
opacity: isBotSpeaking ? 1 : 0,
|
|
2482
|
+
scale: isBotSpeaking ? 1 : 0.8
|
|
2483
|
+
},
|
|
2484
|
+
transition: iosTransitions.fadePop,
|
|
2485
|
+
style: {
|
|
2486
|
+
position: "absolute",
|
|
2487
|
+
width: "220px",
|
|
2488
|
+
height: "220px",
|
|
2489
|
+
zIndex: -1,
|
|
2490
|
+
// Negative z-index to ensure it's behind
|
|
2491
|
+
pointerEvents: "none"
|
|
2492
|
+
},
|
|
2493
|
+
children: /* @__PURE__ */ jsx(
|
|
2494
|
+
AudioVisualizer,
|
|
2495
|
+
{
|
|
2496
|
+
room,
|
|
2497
|
+
size: 220,
|
|
2498
|
+
color: aeroTheme.colors.convai.light,
|
|
2499
|
+
opacity: 0.6,
|
|
2500
|
+
avatarRadius: 110,
|
|
2501
|
+
barCount: 48,
|
|
2502
|
+
onSpeakingChange: setIsBotSpeaking
|
|
2503
|
+
}
|
|
2504
|
+
)
|
|
2505
|
+
}
|
|
2506
|
+
),
|
|
2507
|
+
/* @__PURE__ */ jsxs(
|
|
2508
|
+
motion.div,
|
|
2509
|
+
{
|
|
2510
|
+
initial: { scale: 0.8, opacity: 0 },
|
|
2511
|
+
animate: { scale: 1, opacity: 1 },
|
|
2512
|
+
exit: { scale: 0.8, opacity: 0 },
|
|
2513
|
+
transition: iosTransitions.fadePop,
|
|
2514
|
+
style: {
|
|
2515
|
+
position: "relative",
|
|
2516
|
+
zIndex: 10,
|
|
2517
|
+
// Higher z-index to be clearly on top
|
|
2518
|
+
borderRadius: "50%",
|
|
2519
|
+
overflow: "visible",
|
|
2520
|
+
// Changed to visible to show glow
|
|
2521
|
+
boxShadow: "0 8px 32px rgba(0, 0, 0, 0.3)",
|
|
2522
|
+
background: "white"
|
|
2523
|
+
},
|
|
2524
|
+
children: [
|
|
2525
|
+
/* @__PURE__ */ jsx(
|
|
2526
|
+
motion.div,
|
|
2527
|
+
{
|
|
2528
|
+
animate: {
|
|
2529
|
+
rotate: [0, 360],
|
|
2530
|
+
scale: isBotSpeaking ? [1, 1.05, 1.02, 1.05, 1] : 1
|
|
2531
|
+
},
|
|
2532
|
+
transition: {
|
|
2533
|
+
rotate: { duration: 20, repeat: Infinity, ease: "linear" },
|
|
2534
|
+
scale: { duration: 3, repeat: Infinity, ease: "easeInOut" }
|
|
2535
|
+
},
|
|
2536
|
+
style: {
|
|
2537
|
+
position: "absolute",
|
|
2538
|
+
width: "126px",
|
|
2539
|
+
height: "126px",
|
|
2540
|
+
borderRadius: "50%",
|
|
2541
|
+
background: `
|
|
2542
|
+
conic-gradient(
|
|
2543
|
+
from 0deg,
|
|
2544
|
+
${aeroTheme.colors.convai.light}00 0%,
|
|
2545
|
+
${aeroTheme.colors.convai.light}40 25%,
|
|
2546
|
+
${aeroTheme.colors.convai.dark}60 50%,
|
|
2547
|
+
${aeroTheme.colors.convai.light}40 75%,
|
|
2548
|
+
${aeroTheme.colors.convai.light}00 100%
|
|
2549
|
+
)
|
|
2550
|
+
`,
|
|
2551
|
+
opacity: 0.8,
|
|
2552
|
+
filter: "blur(8px)",
|
|
2553
|
+
zIndex: -2
|
|
2554
|
+
}
|
|
2555
|
+
}
|
|
2556
|
+
),
|
|
2557
|
+
/* @__PURE__ */ jsx(
|
|
2558
|
+
motion.div,
|
|
2559
|
+
{
|
|
2560
|
+
animate: {
|
|
2561
|
+
rotate: [360, 0],
|
|
2562
|
+
scale: isBotSpeaking ? [1, 1.03, 1.06, 1.03, 1] : 1
|
|
2563
|
+
},
|
|
2564
|
+
transition: {
|
|
2565
|
+
rotate: { duration: 15, repeat: Infinity, ease: "linear" },
|
|
2566
|
+
scale: { duration: 2.5, repeat: Infinity, ease: "easeInOut" }
|
|
2567
|
+
},
|
|
2568
|
+
style: {
|
|
2569
|
+
position: "absolute",
|
|
2570
|
+
width: "126px",
|
|
2571
|
+
height: "126px",
|
|
2572
|
+
borderRadius: "50%",
|
|
2573
|
+
background: `
|
|
2574
|
+
radial-gradient(
|
|
2575
|
+
ellipse 80% 100% at 30% 40%,
|
|
2576
|
+
${aeroTheme.colors.convai.light}50,
|
|
2577
|
+
${aeroTheme.colors.convai.light}30 40%,
|
|
2578
|
+
transparent 70%
|
|
2579
|
+
),
|
|
2580
|
+
radial-gradient(
|
|
2581
|
+
ellipse 80% 100% at 70% 60%,
|
|
2582
|
+
${aeroTheme.colors.convai.dark}50,
|
|
2583
|
+
${aeroTheme.colors.convai.dark}30 40%,
|
|
2584
|
+
transparent 70%
|
|
2585
|
+
)
|
|
2586
|
+
`,
|
|
2587
|
+
opacity: 0.9,
|
|
2588
|
+
filter: "blur(6px)",
|
|
2589
|
+
zIndex: -1
|
|
2590
|
+
}
|
|
2591
|
+
}
|
|
2592
|
+
),
|
|
2593
|
+
/* @__PURE__ */ jsx(
|
|
2594
|
+
"div",
|
|
2595
|
+
{
|
|
2596
|
+
style: {
|
|
2597
|
+
position: "relative",
|
|
2598
|
+
borderRadius: "50%",
|
|
2599
|
+
overflow: "hidden",
|
|
2600
|
+
border: `3px solid rgba(255, 255, 255, 0.2)`
|
|
2601
|
+
},
|
|
2602
|
+
children: characterImage ? /* @__PURE__ */ jsx(
|
|
2603
|
+
motion.img,
|
|
2604
|
+
{
|
|
2605
|
+
src: characterImage,
|
|
2606
|
+
alt: characterName,
|
|
2607
|
+
animate: {
|
|
2608
|
+
scale: isBotSpeaking ? 1.05 : 1
|
|
2609
|
+
},
|
|
2610
|
+
transition: {
|
|
2611
|
+
duration: 0.3,
|
|
2612
|
+
ease: "easeInOut"
|
|
2613
|
+
},
|
|
2614
|
+
style: {
|
|
2615
|
+
width: "120px",
|
|
2616
|
+
height: "120px",
|
|
2617
|
+
objectFit: "cover",
|
|
2618
|
+
display: "block"
|
|
2619
|
+
}
|
|
2620
|
+
}
|
|
2621
|
+
) : /* @__PURE__ */ jsx(
|
|
2622
|
+
"div",
|
|
2623
|
+
{
|
|
2624
|
+
style: {
|
|
2625
|
+
width: "120px",
|
|
2626
|
+
height: "120px",
|
|
2627
|
+
backgroundColor: aeroTheme.colors.convai.light + "20",
|
|
2628
|
+
display: "flex",
|
|
2629
|
+
alignItems: "center",
|
|
2630
|
+
justifyContent: "center",
|
|
2631
|
+
fontSize: "48px",
|
|
2632
|
+
color: aeroTheme.colors.convai.light,
|
|
2633
|
+
fontWeight: 600
|
|
2634
|
+
},
|
|
2635
|
+
children: ((_a = characterName[0]) == null ? void 0 : _a.toUpperCase()) || "C"
|
|
2636
|
+
}
|
|
2637
|
+
)
|
|
2638
|
+
}
|
|
2639
|
+
)
|
|
2640
|
+
]
|
|
2641
|
+
},
|
|
2642
|
+
"center-avatar"
|
|
2643
|
+
)
|
|
2644
|
+
]
|
|
2645
|
+
}
|
|
2646
|
+
),
|
|
2647
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: isActive && /* @__PURE__ */ jsx(
|
|
2648
|
+
motion.div,
|
|
2649
|
+
{
|
|
2650
|
+
initial: { opacity: 0, y: 20 },
|
|
2651
|
+
animate: { opacity: 1, y: 0 },
|
|
2652
|
+
exit: { opacity: 0, y: -20 },
|
|
2653
|
+
transition: iosTransitions.fadePop,
|
|
2654
|
+
style: {
|
|
2655
|
+
width: "250px",
|
|
2656
|
+
height: "80px",
|
|
2657
|
+
position: "relative"
|
|
2658
|
+
},
|
|
2659
|
+
children: /* @__PURE__ */ jsx(
|
|
2660
|
+
"canvas",
|
|
2661
|
+
{
|
|
2662
|
+
ref: waveCanvasRef,
|
|
2663
|
+
style: { width: "250px", height: "80px" }
|
|
2664
|
+
}
|
|
2665
|
+
)
|
|
2666
|
+
}
|
|
2667
|
+
) }),
|
|
2668
|
+
/* @__PURE__ */ jsxs(
|
|
2669
|
+
motion.div,
|
|
2670
|
+
{
|
|
2671
|
+
initial: { opacity: 0, y: 10 },
|
|
2672
|
+
animate: { opacity: 1, y: 0 },
|
|
2673
|
+
transition: { delay: 0.2, ...iosTransitions.fadePop },
|
|
2674
|
+
children: [
|
|
2675
|
+
/* @__PURE__ */ jsx(
|
|
2676
|
+
"div",
|
|
2677
|
+
{
|
|
2678
|
+
style: {
|
|
2679
|
+
fontSize: "16px",
|
|
2680
|
+
fontWeight: 600,
|
|
2681
|
+
color: aeroTheme.colors.text.primary,
|
|
2682
|
+
marginBottom: "0.5rem"
|
|
2683
|
+
},
|
|
2684
|
+
children: isTalking ? `${characterName} Speaking...` : isListening || isActive ? "Listening..." : "Voice Mode"
|
|
2685
|
+
}
|
|
2686
|
+
),
|
|
2687
|
+
/* @__PURE__ */ jsx(
|
|
2688
|
+
"div",
|
|
2689
|
+
{
|
|
2690
|
+
style: {
|
|
2691
|
+
fontSize: "13px",
|
|
2692
|
+
color: aeroTheme.colors.text.secondary
|
|
2693
|
+
},
|
|
2694
|
+
children: isListening || isActive || isTalking ? "Audio active" : "Tap microphone to talk"
|
|
2695
|
+
}
|
|
2696
|
+
)
|
|
2697
|
+
]
|
|
2698
|
+
}
|
|
2699
|
+
)
|
|
2700
|
+
]
|
|
2701
|
+
}
|
|
2702
|
+
);
|
|
2703
|
+
};
|
|
2704
|
+
const ConvaiWidget = ({
|
|
2705
|
+
convaiClient,
|
|
2706
|
+
showVideo = true,
|
|
2707
|
+
showScreenShare = true,
|
|
2708
|
+
defaultVoiceMode = true,
|
|
2709
|
+
requestPublicationGrant,
|
|
2710
|
+
publishedChatConnectOptions,
|
|
2711
|
+
publishedChatDescriptor,
|
|
2712
|
+
linkPreviewResolver
|
|
2713
|
+
}) => {
|
|
2714
|
+
var _a, _b, _c, _d;
|
|
2715
|
+
const isTextOnly = Boolean(requestPublicationGrant) || convaiClient.connectionType === "text";
|
|
2716
|
+
const {
|
|
2717
|
+
name: fetchedCharacterName,
|
|
2718
|
+
image: fetchedCharacterImage,
|
|
2719
|
+
isLoading: isFetchedCharacterLoading
|
|
2720
|
+
} = useCharacterInfo(
|
|
2721
|
+
convaiClient.characterId || void 0,
|
|
2722
|
+
convaiClient.apiKey || void 0,
|
|
2723
|
+
convaiClient.authToken || void 0,
|
|
2724
|
+
convaiClient.characterInfoUrl
|
|
2725
|
+
);
|
|
2726
|
+
const characterName = (publishedChatDescriptor == null ? void 0 : publishedChatDescriptor.display_name) || fetchedCharacterName;
|
|
2727
|
+
const characterImage = (_a = publishedChatDescriptor == null ? void 0 : publishedChatDescriptor.image_url) != null ? _a : fetchedCharacterImage;
|
|
2728
|
+
const [isOpen, setIsOpen] = useState(false);
|
|
2729
|
+
const [inputValue, setInputValue] = useState("");
|
|
2730
|
+
const [isSettingsOpen, setIsSettingsOpen] = useState(false);
|
|
2731
|
+
const [isVoiceMode, setIsVoiceMode] = useState(
|
|
2732
|
+
defaultVoiceMode && !isTextOnly
|
|
2733
|
+
);
|
|
2734
|
+
const [isMuted, setIsMuted] = useState(false);
|
|
2735
|
+
const [isVideoVisible, setIsVideoVisible] = useState(false);
|
|
2736
|
+
const [hasEnteredDefaultVoiceMode, setHasEnteredDefaultVoiceMode] = useState(false);
|
|
2737
|
+
const settingsButtonRef = useRef(null);
|
|
2738
|
+
const hasConnectedBeforeRef = useRef(false);
|
|
2739
|
+
const isStartingConnectionRef = useRef(false);
|
|
2740
|
+
const isUnmountedRef = useRef(false);
|
|
2741
|
+
const requiresBotReadyForText = Boolean(requestPublicationGrant) || convaiClient.isPublishedChatSession;
|
|
2742
|
+
const canSendText = convaiClient.state.isConnected && (!requiresBotReadyForText || convaiClient.isBotReady);
|
|
2743
|
+
const selectedCharacter = {
|
|
2744
|
+
id: convaiClient.characterId || "unknown",
|
|
2745
|
+
name: characterName,
|
|
2746
|
+
image: characterImage
|
|
2747
|
+
};
|
|
2748
|
+
const getBotStatusColor = () => {
|
|
2749
|
+
if (!convaiClient.state.isConnected) {
|
|
2750
|
+
return { color: "#ef4444", label: "Disconnected" };
|
|
2751
|
+
}
|
|
2752
|
+
if (convaiClient.state.isConnecting || !convaiClient.isBotReady) {
|
|
2753
|
+
return { color: "#f59e0b", label: "Connecting" };
|
|
2754
|
+
}
|
|
2755
|
+
if (convaiClient.state.isListening) {
|
|
2756
|
+
return { color: "#3b82f6", label: "Listening" };
|
|
2757
|
+
}
|
|
2758
|
+
return { color: "#10b981", label: "Connected" };
|
|
2759
|
+
};
|
|
2760
|
+
const formatMessages = () => {
|
|
2761
|
+
const filteredMessages = convaiClient.chatMessages.filter(
|
|
2762
|
+
(msg) => (msg.type === "user-transcription" || msg.type === "user-llm-text" || msg.type === "bot-llm-text" || msg.type === "bot-output" || msg.type === "bot-emotion") && msg.content && // Ensure content exists
|
|
2763
|
+
msg.content.trim().length > 0
|
|
2764
|
+
// Ensure content is not empty or just whitespace
|
|
2765
|
+
);
|
|
2766
|
+
return filteredMessages.map((msg) => ({
|
|
2767
|
+
id: msg.id,
|
|
2768
|
+
text: msg.content,
|
|
2769
|
+
isUser: msg.type.includes("user"),
|
|
2770
|
+
timestamp: new Date(msg.timestamp).toLocaleTimeString([], {
|
|
2771
|
+
hour: "2-digit",
|
|
2772
|
+
minute: "2-digit"
|
|
2773
|
+
}),
|
|
2774
|
+
sender: msg.type.includes("user") ? "You" : selectedCharacter.name,
|
|
2775
|
+
showLogo: msg.type.includes("bot")
|
|
2776
|
+
}));
|
|
2777
|
+
};
|
|
2778
|
+
const handleToggle = async () => {
|
|
2779
|
+
if (isStartingConnectionRef.current) {
|
|
2780
|
+
return;
|
|
2781
|
+
}
|
|
2782
|
+
if (!convaiClient.state.isConnected && !convaiClient.state.isConnecting) {
|
|
2783
|
+
isStartingConnectionRef.current = true;
|
|
2784
|
+
try {
|
|
2785
|
+
if (requestPublicationGrant || convaiClient.isPublishedChatSession) {
|
|
2786
|
+
if (!requestPublicationGrant) {
|
|
2787
|
+
throw new Error(
|
|
2788
|
+
"Published chat widgets require requestPublicationGrant to start a new session"
|
|
2789
|
+
);
|
|
2790
|
+
}
|
|
2791
|
+
if (!convaiClient.connectWithPublicationGrant) {
|
|
2792
|
+
throw new Error(
|
|
2793
|
+
"This Convai client does not support published chat connections"
|
|
2794
|
+
);
|
|
2795
|
+
}
|
|
2796
|
+
const launchToken = await requestPublicationGrant();
|
|
2797
|
+
if (isUnmountedRef.current) return;
|
|
2798
|
+
await convaiClient.connectWithPublicationGrant(
|
|
2799
|
+
launchToken,
|
|
2800
|
+
freshPublicationGrantOptions(publishedChatConnectOptions)
|
|
2801
|
+
);
|
|
2802
|
+
} else if (hasConnectedBeforeRef.current && typeof convaiClient.reconnect === "function") {
|
|
2803
|
+
await convaiClient.reconnect();
|
|
2804
|
+
} else {
|
|
2805
|
+
await convaiClient.connect();
|
|
2806
|
+
}
|
|
2807
|
+
if (isUnmountedRef.current) {
|
|
2808
|
+
await convaiClient.disconnect();
|
|
2809
|
+
return;
|
|
2810
|
+
}
|
|
2811
|
+
setIsOpen(true);
|
|
2812
|
+
} catch (error) {
|
|
2813
|
+
console.error("Failed to connect:", error);
|
|
2814
|
+
} finally {
|
|
2815
|
+
isStartingConnectionRef.current = false;
|
|
2816
|
+
}
|
|
2817
|
+
} else {
|
|
2818
|
+
setIsOpen(!isOpen);
|
|
2819
|
+
}
|
|
2820
|
+
};
|
|
2821
|
+
const handleClose = () => {
|
|
2822
|
+
setIsOpen(false);
|
|
2823
|
+
};
|
|
2824
|
+
const handleInputChange = (e) => {
|
|
2825
|
+
setInputValue(e.target.value);
|
|
2826
|
+
};
|
|
2827
|
+
const handleSend = () => {
|
|
2828
|
+
if (inputValue.trim() && canSendText) {
|
|
2829
|
+
convaiClient.sendUserTextMessage(inputValue);
|
|
2830
|
+
setInputValue("");
|
|
2831
|
+
}
|
|
2832
|
+
};
|
|
2833
|
+
const handleKeyPress = (e) => {
|
|
2834
|
+
if (e.key === "Enter") {
|
|
2835
|
+
handleSend();
|
|
2836
|
+
}
|
|
2837
|
+
};
|
|
2838
|
+
const handleToggleMute = () => {
|
|
2839
|
+
const newMutedState = !isMuted;
|
|
2840
|
+
convaiClient.setCharacterMuted(newMutedState);
|
|
2841
|
+
setIsMuted(newMutedState);
|
|
2842
|
+
};
|
|
2843
|
+
const handleReset = async () => {
|
|
2844
|
+
setIsSettingsOpen(false);
|
|
2845
|
+
try {
|
|
2846
|
+
await convaiClient.disconnect();
|
|
2847
|
+
convaiClient.resetSession();
|
|
2848
|
+
setIsMuted(false);
|
|
2849
|
+
setIsVoiceMode(false);
|
|
2850
|
+
} catch (error) {
|
|
2851
|
+
console.error("Failed to reset:", error);
|
|
2852
|
+
}
|
|
2853
|
+
};
|
|
2854
|
+
const handleDisconnect = async () => {
|
|
2855
|
+
setIsSettingsOpen(false);
|
|
2856
|
+
await convaiClient.disconnect();
|
|
2857
|
+
setIsMuted(false);
|
|
2858
|
+
setIsVoiceMode(false);
|
|
2859
|
+
};
|
|
2860
|
+
const handleToggleVideo = async () => {
|
|
2861
|
+
if (convaiClient.connectionType !== "video") {
|
|
2862
|
+
console.warn("Video capability requires connection type to be 'video'");
|
|
2863
|
+
return;
|
|
2864
|
+
}
|
|
2865
|
+
if (convaiClient.isVideoEnabled) {
|
|
2866
|
+
await convaiClient.videoControls.disableVideo();
|
|
2867
|
+
} else {
|
|
2868
|
+
await convaiClient.videoControls.enableVideo();
|
|
2869
|
+
}
|
|
2870
|
+
};
|
|
2871
|
+
const handleToggleScreenShare = async () => {
|
|
2872
|
+
await convaiClient.screenShareControls.toggleScreenShare();
|
|
2873
|
+
};
|
|
2874
|
+
const handleSettingsToggle = () => {
|
|
2875
|
+
setIsSettingsOpen(!isSettingsOpen);
|
|
2876
|
+
};
|
|
2877
|
+
useEffect(() => {
|
|
2878
|
+
isUnmountedRef.current = false;
|
|
2879
|
+
return () => {
|
|
2880
|
+
isUnmountedRef.current = true;
|
|
2881
|
+
};
|
|
2882
|
+
}, []);
|
|
2883
|
+
useEffect(() => {
|
|
2884
|
+
if (convaiClient.state.isConnected) {
|
|
2885
|
+
hasConnectedBeforeRef.current = true;
|
|
2886
|
+
}
|
|
2887
|
+
}, [convaiClient.state.isConnected]);
|
|
2888
|
+
useEffect(() => {
|
|
2889
|
+
if (!convaiClient.state.isConnected && !convaiClient.state.isConnecting) {
|
|
2890
|
+
if (isOpen) {
|
|
2891
|
+
setIsOpen(false);
|
|
2892
|
+
}
|
|
2893
|
+
setIsMuted(false);
|
|
2894
|
+
setIsVoiceMode(false);
|
|
2895
|
+
setHasEnteredDefaultVoiceMode(false);
|
|
2896
|
+
}
|
|
2897
|
+
}, [convaiClient.state.isConnected, convaiClient.state.isConnecting, isOpen]);
|
|
2898
|
+
useEffect(() => {
|
|
2899
|
+
setIsVideoVisible(convaiClient.isVideoEnabled);
|
|
2900
|
+
}, [convaiClient.isVideoEnabled]);
|
|
2901
|
+
useEffect(() => {
|
|
2902
|
+
if (isTextOnly && isVoiceMode) {
|
|
2903
|
+
setIsVoiceMode(false);
|
|
2904
|
+
}
|
|
2905
|
+
}, [isTextOnly, isVoiceMode]);
|
|
2906
|
+
useEffect(() => {
|
|
2907
|
+
const ensureMicState = async () => {
|
|
2908
|
+
if (!isVoiceMode && !convaiClient.isAudioMuted) {
|
|
2909
|
+
await convaiClient.audioControls.muteAudio();
|
|
2910
|
+
}
|
|
2911
|
+
};
|
|
2912
|
+
ensureMicState();
|
|
2913
|
+
}, [isVoiceMode, convaiClient]);
|
|
2914
|
+
const showVoiceMode = isVoiceMode || defaultVoiceMode && !isTextOnly && !hasEnteredDefaultVoiceMode;
|
|
2915
|
+
useEffect(() => {
|
|
2916
|
+
if (isOpen && defaultVoiceMode && !isTextOnly && convaiClient.state.isConnected && !hasEnteredDefaultVoiceMode && !isVoiceMode) {
|
|
2917
|
+
const enterVoiceMode = async () => {
|
|
2918
|
+
try {
|
|
2919
|
+
await convaiClient.audioControls.unmuteAudio();
|
|
2920
|
+
setIsVoiceMode(true);
|
|
2921
|
+
setHasEnteredDefaultVoiceMode(true);
|
|
2922
|
+
} catch (error) {
|
|
2923
|
+
console.error("Failed to enter voice mode:", error);
|
|
2924
|
+
}
|
|
2925
|
+
};
|
|
2926
|
+
enterVoiceMode();
|
|
2927
|
+
}
|
|
2928
|
+
}, [isOpen, defaultVoiceMode, isTextOnly, convaiClient.state.isConnected, hasEnteredDefaultVoiceMode, isVoiceMode, convaiClient]);
|
|
2929
|
+
useEffect(() => {
|
|
2930
|
+
const handleClickOutside = (event) => {
|
|
2931
|
+
if (isSettingsOpen && settingsButtonRef.current) {
|
|
2932
|
+
const target = event.target;
|
|
2933
|
+
const settingsButton = settingsButtonRef.current;
|
|
2934
|
+
if (!settingsButton.contains(target)) {
|
|
2935
|
+
const settingsTray = document.querySelector("[data-settings-tray]");
|
|
2936
|
+
if (settingsTray && !settingsTray.contains(target)) {
|
|
2937
|
+
setIsSettingsOpen(false);
|
|
2938
|
+
}
|
|
2939
|
+
}
|
|
2940
|
+
}
|
|
2941
|
+
};
|
|
2942
|
+
if (isSettingsOpen) {
|
|
2943
|
+
document.addEventListener("mousedown", handleClickOutside);
|
|
2944
|
+
}
|
|
2945
|
+
return () => {
|
|
2946
|
+
document.removeEventListener("mousedown", handleClickOutside);
|
|
2947
|
+
};
|
|
2948
|
+
}, [isSettingsOpen]);
|
|
2949
|
+
const getLogoState = () => {
|
|
2950
|
+
if (convaiClient.state.isConnecting) return "connecting";
|
|
2951
|
+
if (convaiClient.state.isConnected) return "connected";
|
|
2952
|
+
return "idle";
|
|
2953
|
+
};
|
|
2954
|
+
const getLogoColor = () => {
|
|
2955
|
+
if (convaiClient.state.isConnected) return aeroTheme.colors.primary[500];
|
|
2956
|
+
if (convaiClient.state.isConnecting) return aeroTheme.colors.primary[300];
|
|
2957
|
+
return aeroTheme.colors.primary[500];
|
|
2958
|
+
};
|
|
2959
|
+
const audioRendererRef = useRef(null);
|
|
2960
|
+
useEffect(() => {
|
|
2961
|
+
if (!convaiClient.room || convaiClient.room.state !== "connected") return;
|
|
2962
|
+
audioRendererRef.current = new AudioRenderer(convaiClient.room);
|
|
2963
|
+
return () => {
|
|
2964
|
+
if (audioRendererRef.current) {
|
|
2965
|
+
audioRendererRef.current.destroy();
|
|
2966
|
+
audioRendererRef.current = null;
|
|
2967
|
+
}
|
|
2968
|
+
};
|
|
2969
|
+
}, [convaiClient.room, convaiClient.state.isConnected]);
|
|
2970
|
+
return /* @__PURE__ */ jsxs(RoomContext.Provider, { value: ((_b = convaiClient.room) == null ? void 0 : _b.state) === "connected" ? convaiClient.room : void 0, children: [
|
|
2971
|
+
/* @__PURE__ */ jsxs(
|
|
2972
|
+
ConvaiContainer,
|
|
2973
|
+
{
|
|
2974
|
+
initial: { opacity: 0, scale: 0.8 },
|
|
2975
|
+
animate: { opacity: 1, scale: 1 },
|
|
2976
|
+
transition: { duration: 0.4, ease: "easeOut" },
|
|
2977
|
+
children: [
|
|
2978
|
+
/* @__PURE__ */ jsxs(
|
|
2979
|
+
MorphingContainer,
|
|
2980
|
+
{
|
|
2981
|
+
onClick: !isOpen ? handleToggle : void 0,
|
|
2982
|
+
whileHover: !isOpen ? { scale: 1.05 } : void 0,
|
|
2983
|
+
whileTap: !isOpen ? { scale: 0.95 } : void 0,
|
|
2984
|
+
animate: {
|
|
2985
|
+
width: isOpen ? "400px" : "4rem",
|
|
2986
|
+
height: isOpen ? "600px" : "4rem",
|
|
2987
|
+
borderRadius: isOpen ? aeroTheme.borderRadius.xl : "50%"
|
|
2988
|
+
},
|
|
2989
|
+
transition: { duration: 0.3, ease: "easeInOut" },
|
|
2990
|
+
style: { cursor: !isOpen ? "pointer" : "default" },
|
|
2991
|
+
children: [
|
|
2992
|
+
/* @__PURE__ */ jsx(
|
|
2993
|
+
ButtonContent,
|
|
2994
|
+
{
|
|
2995
|
+
animate: {
|
|
2996
|
+
opacity: isOpen ? 0 : 1,
|
|
2997
|
+
scale: isOpen ? 0.8 : 1
|
|
2998
|
+
},
|
|
2999
|
+
transition: { duration: 0.3 },
|
|
3000
|
+
children: /* @__PURE__ */ jsx(Logo, { children: /* @__PURE__ */ jsx(
|
|
3001
|
+
ConvaiLogo,
|
|
3002
|
+
{
|
|
3003
|
+
size: "xl",
|
|
3004
|
+
color: getLogoColor(),
|
|
3005
|
+
animate: convaiClient.state.isConnecting,
|
|
3006
|
+
state: getLogoState()
|
|
3007
|
+
}
|
|
3008
|
+
) })
|
|
3009
|
+
}
|
|
3010
|
+
),
|
|
3011
|
+
convaiClient.state.isConnected && /* @__PURE__ */ jsxs(
|
|
3012
|
+
ChatContent,
|
|
3013
|
+
{
|
|
3014
|
+
animate: {
|
|
3015
|
+
opacity: isOpen ? 1 : 0,
|
|
3016
|
+
scale: isOpen ? 1 : 0.8
|
|
3017
|
+
},
|
|
3018
|
+
transition: {
|
|
3019
|
+
duration: 0.2,
|
|
3020
|
+
delay: isOpen ? 0.2 : 0
|
|
3021
|
+
},
|
|
3022
|
+
style: {
|
|
3023
|
+
pointerEvents: isOpen ? "auto" : "none"
|
|
3024
|
+
},
|
|
3025
|
+
children: [
|
|
3026
|
+
/* @__PURE__ */ jsxs(
|
|
3027
|
+
Header,
|
|
3028
|
+
{
|
|
3029
|
+
initial: { opacity: 0, y: -20 },
|
|
3030
|
+
animate: {
|
|
3031
|
+
opacity: isOpen ? 1 : 0,
|
|
3032
|
+
y: isOpen ? 0 : -20
|
|
3033
|
+
},
|
|
3034
|
+
transition: {
|
|
3035
|
+
delay: isOpen ? 0.4 : 0,
|
|
3036
|
+
...iosTransitions.modalSlide
|
|
3037
|
+
},
|
|
3038
|
+
style: {
|
|
3039
|
+
pointerEvents: isOpen ? "auto" : "none",
|
|
3040
|
+
minHeight: "3.5rem"
|
|
3041
|
+
// Ensure consistent height
|
|
3042
|
+
},
|
|
3043
|
+
children: [
|
|
3044
|
+
/* @__PURE__ */ jsx(
|
|
3045
|
+
CloseButton,
|
|
3046
|
+
{
|
|
3047
|
+
onClick: handleClose,
|
|
3048
|
+
whileHover: { scale: 1.1 },
|
|
3049
|
+
whileTap: { scale: 0.9 },
|
|
3050
|
+
transition: iosTransitions.snappy,
|
|
3051
|
+
style: { cursor: "pointer", pointerEvents: "auto" },
|
|
3052
|
+
children: /* @__PURE__ */ jsx(ChevronDown, { size: "md" })
|
|
3053
|
+
}
|
|
3054
|
+
),
|
|
3055
|
+
/* @__PURE__ */ jsxs(Title, { children: [
|
|
3056
|
+
selectedCharacter.image && !showVoiceMode && /* @__PURE__ */ jsx(
|
|
3057
|
+
motion.img,
|
|
3058
|
+
{
|
|
3059
|
+
src: selectedCharacter.image,
|
|
3060
|
+
alt: selectedCharacter.name,
|
|
3061
|
+
initial: { scale: 0.8, opacity: 0 },
|
|
3062
|
+
animate: { scale: 1, opacity: 1 },
|
|
3063
|
+
exit: { scale: 0.8, opacity: 0 },
|
|
3064
|
+
transition: iosTransitions.fadePop,
|
|
3065
|
+
style: {
|
|
3066
|
+
width: "1.5rem",
|
|
3067
|
+
height: "1.5rem",
|
|
3068
|
+
borderRadius: "50%",
|
|
3069
|
+
objectFit: "cover",
|
|
3070
|
+
marginRight: "0.5rem",
|
|
3071
|
+
border: `1.5px solid ${getBotStatusColor().color}`,
|
|
3072
|
+
boxShadow: `0 0 6px ${getBotStatusColor().color}40`,
|
|
3073
|
+
transition: "all 0.3s ease"
|
|
3074
|
+
}
|
|
3075
|
+
},
|
|
3076
|
+
"header-avatar"
|
|
3077
|
+
),
|
|
3078
|
+
selectedCharacter.name,
|
|
3079
|
+
/* @__PURE__ */ jsx(
|
|
3080
|
+
motion.button,
|
|
3081
|
+
{
|
|
3082
|
+
onClick: handleToggleMute,
|
|
3083
|
+
whileHover: { scale: 1.1 },
|
|
3084
|
+
whileTap: { scale: 0.9 },
|
|
3085
|
+
transition: iosTransitions.snappy,
|
|
3086
|
+
style: {
|
|
3087
|
+
cursor: "pointer",
|
|
3088
|
+
pointerEvents: "auto",
|
|
3089
|
+
background: "transparent",
|
|
3090
|
+
border: "none",
|
|
3091
|
+
boxShadow: "none",
|
|
3092
|
+
width: "auto",
|
|
3093
|
+
height: "auto",
|
|
3094
|
+
padding: "0",
|
|
3095
|
+
display: "inline-flex",
|
|
3096
|
+
alignItems: "center",
|
|
3097
|
+
marginLeft: "0.5rem",
|
|
3098
|
+
outline: "none"
|
|
3099
|
+
},
|
|
3100
|
+
"aria-label": isMuted ? "Unmute" : "Mute",
|
|
3101
|
+
title: isMuted ? "Unmute" : "Mute",
|
|
3102
|
+
children: isMuted ? /* @__PURE__ */ jsx(IoVolumeMute, { size: 16, color: "#919EABA6" }) : /* @__PURE__ */ jsx(IoVolumeHigh, { size: 16, color: "#0E7360" })
|
|
3103
|
+
}
|
|
3104
|
+
),
|
|
3105
|
+
showVoiceMode && /* @__PURE__ */ jsx(
|
|
3106
|
+
"span",
|
|
3107
|
+
{
|
|
3108
|
+
style: {
|
|
3109
|
+
fontSize: "10px",
|
|
3110
|
+
color: aeroTheme.colors.convai.light,
|
|
3111
|
+
fontWeight: 500,
|
|
3112
|
+
marginLeft: "8px",
|
|
3113
|
+
padding: "2px 6px",
|
|
3114
|
+
borderRadius: "4px",
|
|
3115
|
+
backgroundColor: aeroTheme.colors.convai.light + "20"
|
|
3116
|
+
},
|
|
3117
|
+
children: "VOICE"
|
|
3118
|
+
}
|
|
3119
|
+
),
|
|
3120
|
+
convaiClient.state.isSpeaking && /* @__PURE__ */ jsxs(
|
|
3121
|
+
motion.span,
|
|
3122
|
+
{
|
|
3123
|
+
initial: { scale: 0.8, opacity: 0 },
|
|
3124
|
+
animate: { scale: 1, opacity: 1 },
|
|
3125
|
+
exit: { scale: 0.8, opacity: 0 },
|
|
3126
|
+
transition: { duration: 0.2 },
|
|
3127
|
+
style: {
|
|
3128
|
+
fontSize: "10px",
|
|
3129
|
+
color: "#10b981",
|
|
3130
|
+
fontWeight: 600,
|
|
3131
|
+
marginLeft: "8px",
|
|
3132
|
+
padding: "3px 8px",
|
|
3133
|
+
borderRadius: "6px",
|
|
3134
|
+
backgroundColor: "#10b98120",
|
|
3135
|
+
border: "1px solid #10b98140",
|
|
3136
|
+
display: "inline-flex",
|
|
3137
|
+
alignItems: "center",
|
|
3138
|
+
gap: "4px"
|
|
3139
|
+
},
|
|
3140
|
+
children: [
|
|
3141
|
+
/* @__PURE__ */ jsx(
|
|
3142
|
+
motion.span,
|
|
3143
|
+
{
|
|
3144
|
+
animate: {
|
|
3145
|
+
scale: [1, 1.2, 1],
|
|
3146
|
+
opacity: [1, 0.7, 1]
|
|
3147
|
+
},
|
|
3148
|
+
transition: {
|
|
3149
|
+
duration: 1.5,
|
|
3150
|
+
repeat: Infinity,
|
|
3151
|
+
ease: "easeInOut"
|
|
3152
|
+
},
|
|
3153
|
+
style: {
|
|
3154
|
+
width: "6px",
|
|
3155
|
+
height: "6px",
|
|
3156
|
+
borderRadius: "50%",
|
|
3157
|
+
backgroundColor: "#10b981",
|
|
3158
|
+
display: "inline-block"
|
|
3159
|
+
}
|
|
3160
|
+
}
|
|
3161
|
+
),
|
|
3162
|
+
"SPEAKING"
|
|
3163
|
+
]
|
|
3164
|
+
}
|
|
3165
|
+
),
|
|
3166
|
+
convaiClient.state.isListening && !convaiClient.state.isSpeaking && /* @__PURE__ */ jsxs(
|
|
3167
|
+
motion.span,
|
|
3168
|
+
{
|
|
3169
|
+
initial: { scale: 0.8, opacity: 0 },
|
|
3170
|
+
animate: { scale: 1, opacity: 1 },
|
|
3171
|
+
exit: { scale: 0.8, opacity: 0 },
|
|
3172
|
+
transition: { duration: 0.2 },
|
|
3173
|
+
style: {
|
|
3174
|
+
fontSize: "10px",
|
|
3175
|
+
color: "#3b82f6",
|
|
3176
|
+
fontWeight: 600,
|
|
3177
|
+
marginLeft: "8px",
|
|
3178
|
+
padding: "3px 8px",
|
|
3179
|
+
borderRadius: "6px",
|
|
3180
|
+
backgroundColor: "#3b82f620",
|
|
3181
|
+
border: "1px solid #3b82f640",
|
|
3182
|
+
display: "inline-flex",
|
|
3183
|
+
alignItems: "center",
|
|
3184
|
+
gap: "4px"
|
|
3185
|
+
},
|
|
3186
|
+
children: [
|
|
3187
|
+
/* @__PURE__ */ jsx(
|
|
3188
|
+
motion.span,
|
|
3189
|
+
{
|
|
3190
|
+
animate: {
|
|
3191
|
+
scale: [1, 1.2, 1],
|
|
3192
|
+
opacity: [1, 0.7, 1]
|
|
3193
|
+
},
|
|
3194
|
+
transition: {
|
|
3195
|
+
duration: 1.5,
|
|
3196
|
+
repeat: Infinity,
|
|
3197
|
+
ease: "easeInOut"
|
|
3198
|
+
},
|
|
3199
|
+
style: {
|
|
3200
|
+
width: "6px",
|
|
3201
|
+
height: "6px",
|
|
3202
|
+
borderRadius: "50%",
|
|
3203
|
+
backgroundColor: "#3b82f6",
|
|
3204
|
+
display: "inline-block"
|
|
3205
|
+
}
|
|
3206
|
+
}
|
|
3207
|
+
),
|
|
3208
|
+
"LISTENING"
|
|
3209
|
+
]
|
|
3210
|
+
}
|
|
3211
|
+
)
|
|
3212
|
+
] }),
|
|
3213
|
+
/* @__PURE__ */ jsx(
|
|
3214
|
+
"div",
|
|
3215
|
+
{
|
|
3216
|
+
style: {
|
|
3217
|
+
display: "flex",
|
|
3218
|
+
alignItems: "center",
|
|
3219
|
+
gap: "0.5rem",
|
|
3220
|
+
position: "relative"
|
|
3221
|
+
},
|
|
3222
|
+
children: /* @__PURE__ */ jsx(
|
|
3223
|
+
SettingsButton,
|
|
3224
|
+
{
|
|
3225
|
+
ref: settingsButtonRef,
|
|
3226
|
+
onClick: handleSettingsToggle,
|
|
3227
|
+
whileHover: { scale: 1.1 },
|
|
3228
|
+
whileTap: { scale: 0.9 },
|
|
3229
|
+
transition: iosTransitions.snappy,
|
|
3230
|
+
style: { cursor: "pointer" },
|
|
3231
|
+
children: /* @__PURE__ */ jsx(FiMoreVertical, { size: 20 })
|
|
3232
|
+
}
|
|
3233
|
+
)
|
|
3234
|
+
}
|
|
3235
|
+
)
|
|
3236
|
+
]
|
|
3237
|
+
}
|
|
3238
|
+
),
|
|
3239
|
+
/* @__PURE__ */ jsxs(
|
|
3240
|
+
Content,
|
|
3241
|
+
{
|
|
3242
|
+
style: {
|
|
3243
|
+
background: showVoiceMode ? "rgba(255, 255, 255, 0.98)" : "transparent",
|
|
3244
|
+
filter: isSettingsOpen ? "blur(3px)" : "none",
|
|
3245
|
+
position: "relative"
|
|
3246
|
+
},
|
|
3247
|
+
children: [
|
|
3248
|
+
/* @__PURE__ */ jsx(AnimatePresence, { children: convaiClient.state.isConnected && !convaiClient.isBotReady && /* @__PURE__ */ jsxs(
|
|
3249
|
+
motion.div,
|
|
3250
|
+
{
|
|
3251
|
+
initial: { opacity: 0 },
|
|
3252
|
+
animate: { opacity: 1 },
|
|
3253
|
+
exit: { opacity: 0 },
|
|
3254
|
+
transition: { duration: 0.3 },
|
|
3255
|
+
style: {
|
|
3256
|
+
position: "absolute",
|
|
3257
|
+
top: 0,
|
|
3258
|
+
left: 0,
|
|
3259
|
+
right: 0,
|
|
3260
|
+
bottom: 0,
|
|
3261
|
+
display: "flex",
|
|
3262
|
+
flexDirection: "column",
|
|
3263
|
+
alignItems: "center",
|
|
3264
|
+
justifyContent: "center",
|
|
3265
|
+
backgroundColor: "rgba(255, 255, 255, 0.95)",
|
|
3266
|
+
zIndex: 100,
|
|
3267
|
+
gap: "1rem"
|
|
3268
|
+
},
|
|
3269
|
+
children: [
|
|
3270
|
+
/* @__PURE__ */ jsx(
|
|
3271
|
+
motion.div,
|
|
3272
|
+
{
|
|
3273
|
+
animate: {
|
|
3274
|
+
rotate: 360
|
|
3275
|
+
},
|
|
3276
|
+
transition: {
|
|
3277
|
+
duration: 2,
|
|
3278
|
+
repeat: Infinity,
|
|
3279
|
+
ease: "linear"
|
|
3280
|
+
},
|
|
3281
|
+
children: /* @__PURE__ */ jsx(
|
|
3282
|
+
ConvaiLogo,
|
|
3283
|
+
{
|
|
3284
|
+
size: "xl",
|
|
3285
|
+
color: aeroTheme.colors.convai.light,
|
|
3286
|
+
state: "connecting"
|
|
3287
|
+
}
|
|
3288
|
+
)
|
|
3289
|
+
}
|
|
3290
|
+
),
|
|
3291
|
+
/* @__PURE__ */ jsxs(
|
|
3292
|
+
motion.div,
|
|
3293
|
+
{
|
|
3294
|
+
animate: {
|
|
3295
|
+
opacity: [0.5, 1, 0.5]
|
|
3296
|
+
},
|
|
3297
|
+
transition: {
|
|
3298
|
+
duration: 2,
|
|
3299
|
+
repeat: Infinity,
|
|
3300
|
+
ease: "easeInOut"
|
|
3301
|
+
},
|
|
3302
|
+
style: {
|
|
3303
|
+
fontSize: "14px",
|
|
3304
|
+
fontWeight: 500,
|
|
3305
|
+
color: aeroTheme.colors.text.secondary
|
|
3306
|
+
},
|
|
3307
|
+
children: [
|
|
3308
|
+
"Connecting to ",
|
|
3309
|
+
selectedCharacter.name,
|
|
3310
|
+
"..."
|
|
3311
|
+
]
|
|
3312
|
+
}
|
|
3313
|
+
)
|
|
3314
|
+
]
|
|
3315
|
+
}
|
|
3316
|
+
) }),
|
|
3317
|
+
showVoiceMode && /* @__PURE__ */ jsx(
|
|
3318
|
+
VoiceModeOverlay,
|
|
3319
|
+
{
|
|
3320
|
+
isActive: !convaiClient.isAudioMuted,
|
|
3321
|
+
isTalking: convaiClient.state.isSpeaking,
|
|
3322
|
+
isListening: convaiClient.state.isListening,
|
|
3323
|
+
convaiClient: null,
|
|
3324
|
+
characterImage: characterImage || void 0,
|
|
3325
|
+
characterName: characterName || void 0,
|
|
3326
|
+
room: ((_c = convaiClient.room) == null ? void 0 : _c.state) === "connected" ? convaiClient.room : null
|
|
3327
|
+
}
|
|
3328
|
+
),
|
|
3329
|
+
!showVoiceMode && /* @__PURE__ */ jsx(
|
|
3330
|
+
MessageList,
|
|
3331
|
+
{
|
|
3332
|
+
messages: formatMessages(),
|
|
3333
|
+
isStreaming: convaiClient.state.isSpeaking,
|
|
3334
|
+
forceToBottomToken: `${isOpen}-${convaiClient.chatMessages.length}`,
|
|
3335
|
+
linkPreviewResolver
|
|
3336
|
+
}
|
|
3337
|
+
)
|
|
3338
|
+
]
|
|
3339
|
+
}
|
|
3340
|
+
),
|
|
3341
|
+
/* @__PURE__ */ jsx(
|
|
3342
|
+
Footer,
|
|
3343
|
+
{
|
|
3344
|
+
initial: { y: 20, opacity: 0 },
|
|
3345
|
+
animate: { y: 0, opacity: 1 },
|
|
3346
|
+
transition: {
|
|
3347
|
+
delay: 0.7,
|
|
3348
|
+
...iosTransitions.modalSlide
|
|
3349
|
+
},
|
|
3350
|
+
style: {
|
|
3351
|
+
filter: isSettingsOpen ? "blur(3px)" : "none",
|
|
3352
|
+
transition: "filter 0.2s ease",
|
|
3353
|
+
display: "flex",
|
|
3354
|
+
gap: "0.5rem",
|
|
3355
|
+
alignItems: "center",
|
|
3356
|
+
position: "relative",
|
|
3357
|
+
justifyContent: showVoiceMode ? "center" : "flex-start",
|
|
3358
|
+
minHeight: "3.5rem"
|
|
3359
|
+
// Ensure consistent height
|
|
3360
|
+
},
|
|
3361
|
+
children: showVoiceMode ? /* @__PURE__ */ jsx(
|
|
3362
|
+
motion.button,
|
|
3363
|
+
{
|
|
3364
|
+
initial: { scale: 0.8, opacity: 0 },
|
|
3365
|
+
animate: { scale: 1, opacity: 1 },
|
|
3366
|
+
exit: { scale: 0.8, opacity: 0 },
|
|
3367
|
+
transition: {
|
|
3368
|
+
duration: 0.3,
|
|
3369
|
+
ease: "easeOut"
|
|
3370
|
+
},
|
|
3371
|
+
onClick: async () => {
|
|
3372
|
+
var _a2;
|
|
3373
|
+
convaiClient.sendInterruptMessage();
|
|
3374
|
+
await convaiClient.audioControls.muteAudio();
|
|
3375
|
+
if (((_a2 = convaiClient.room) == null ? void 0 : _a2.state) !== "connected") {
|
|
3376
|
+
convaiClient.toggleStt(false);
|
|
3377
|
+
}
|
|
3378
|
+
setIsVoiceMode(false);
|
|
3379
|
+
setHasEnteredDefaultVoiceMode(true);
|
|
3380
|
+
},
|
|
3381
|
+
whileHover: { scale: 1.1 },
|
|
3382
|
+
whileTap: { scale: 0.9 },
|
|
3383
|
+
style: {
|
|
3384
|
+
cursor: "pointer",
|
|
3385
|
+
backgroundColor: "#ef4444",
|
|
3386
|
+
color: "#ffffff",
|
|
3387
|
+
border: "none",
|
|
3388
|
+
borderRadius: "50%",
|
|
3389
|
+
width: "2.25rem",
|
|
3390
|
+
height: "2.25rem",
|
|
3391
|
+
minWidth: "2.25rem",
|
|
3392
|
+
minHeight: "2.25rem",
|
|
3393
|
+
display: "flex",
|
|
3394
|
+
alignItems: "center",
|
|
3395
|
+
justifyContent: "center",
|
|
3396
|
+
flexShrink: 0,
|
|
3397
|
+
padding: 0,
|
|
3398
|
+
outline: "none"
|
|
3399
|
+
},
|
|
3400
|
+
"aria-label": "Exit Voice Mode",
|
|
3401
|
+
title: "Exit voice mode",
|
|
3402
|
+
children: /* @__PURE__ */ jsx(FiPhoneOff, { size: 20 })
|
|
3403
|
+
},
|
|
3404
|
+
"voice-mode-exit"
|
|
3405
|
+
) : /* @__PURE__ */ jsx(Fragment, { children: /* @__PURE__ */ jsxs(InputContainer, { style: { flex: 1, position: "relative" }, children: [
|
|
3406
|
+
/* @__PURE__ */ jsx(
|
|
3407
|
+
Input,
|
|
3408
|
+
{
|
|
3409
|
+
type: "text",
|
|
3410
|
+
placeholder: "Conversation",
|
|
3411
|
+
value: inputValue,
|
|
3412
|
+
onChange: handleInputChange,
|
|
3413
|
+
onKeyPress: handleKeyPress,
|
|
3414
|
+
disabled: !canSendText,
|
|
3415
|
+
style: { paddingRight: "2.75rem" }
|
|
3416
|
+
}
|
|
3417
|
+
),
|
|
3418
|
+
/* @__PURE__ */ jsx(
|
|
3419
|
+
"div",
|
|
3420
|
+
{
|
|
3421
|
+
style: {
|
|
3422
|
+
position: "absolute",
|
|
3423
|
+
right: "0.375rem",
|
|
3424
|
+
top: "50%",
|
|
3425
|
+
transform: "translateY(-50%)",
|
|
3426
|
+
width: "2.25rem",
|
|
3427
|
+
height: "2.25rem",
|
|
3428
|
+
minWidth: "2.25rem",
|
|
3429
|
+
minHeight: "2.25rem",
|
|
3430
|
+
flexShrink: 0,
|
|
3431
|
+
overflow: "visible",
|
|
3432
|
+
display: "flex",
|
|
3433
|
+
alignItems: "center",
|
|
3434
|
+
justifyContent: "center",
|
|
3435
|
+
zIndex: 2
|
|
3436
|
+
},
|
|
3437
|
+
children: /* @__PURE__ */ jsx(AnimatePresence, { mode: "wait", children: inputValue.length > 0 || isTextOnly ? /* @__PURE__ */ jsx(
|
|
3438
|
+
ActionButton,
|
|
3439
|
+
{
|
|
3440
|
+
initial: { y: "100%" },
|
|
3441
|
+
animate: { y: "0%" },
|
|
3442
|
+
exit: { y: "-100%" },
|
|
3443
|
+
transition: {
|
|
3444
|
+
duration: 0.1,
|
|
3445
|
+
ease: "linear"
|
|
3446
|
+
},
|
|
3447
|
+
onClick: handleSend,
|
|
3448
|
+
disabled: inputValue.length === 0 || !canSendText,
|
|
3449
|
+
whileTap: { scale: 0.9 },
|
|
3450
|
+
style: {
|
|
3451
|
+
position: "absolute",
|
|
3452
|
+
top: 0,
|
|
3453
|
+
left: 0,
|
|
3454
|
+
cursor: "pointer"
|
|
3455
|
+
},
|
|
3456
|
+
children: /* @__PURE__ */ jsx(FiSend, { size: 20 })
|
|
3457
|
+
},
|
|
3458
|
+
"send"
|
|
3459
|
+
) : /* @__PURE__ */ jsx(
|
|
3460
|
+
motion.button,
|
|
3461
|
+
{
|
|
3462
|
+
initial: { y: "100%" },
|
|
3463
|
+
animate: { y: "0%" },
|
|
3464
|
+
exit: { y: "-100%" },
|
|
3465
|
+
transition: {
|
|
3466
|
+
duration: 0.1,
|
|
3467
|
+
ease: "linear"
|
|
3468
|
+
},
|
|
3469
|
+
onClick: async () => {
|
|
3470
|
+
var _a2;
|
|
3471
|
+
convaiClient.sendInterruptMessage();
|
|
3472
|
+
if (((_a2 = convaiClient.room) == null ? void 0 : _a2.state) !== "connected") {
|
|
3473
|
+
convaiClient.toggleStt(true);
|
|
3474
|
+
}
|
|
3475
|
+
await convaiClient.audioControls.unmuteAudio();
|
|
3476
|
+
setIsVoiceMode(true);
|
|
3477
|
+
},
|
|
3478
|
+
whileHover: { scale: 1.1 },
|
|
3479
|
+
whileTap: { scale: 0.9 },
|
|
3480
|
+
style: {
|
|
3481
|
+
position: "absolute",
|
|
3482
|
+
top: 0,
|
|
3483
|
+
left: 0,
|
|
3484
|
+
cursor: "pointer",
|
|
3485
|
+
backgroundColor: "transparent",
|
|
3486
|
+
color: aeroTheme.colors.text.primary,
|
|
3487
|
+
border: `1px solid ${aeroTheme.colors.neutral[300]}`,
|
|
3488
|
+
borderRadius: "50%",
|
|
3489
|
+
width: "2.25rem",
|
|
3490
|
+
height: "2.25rem",
|
|
3491
|
+
minWidth: "2.25rem",
|
|
3492
|
+
minHeight: "2.25rem",
|
|
3493
|
+
display: "flex",
|
|
3494
|
+
alignItems: "center",
|
|
3495
|
+
justifyContent: "center",
|
|
3496
|
+
flexShrink: 0,
|
|
3497
|
+
padding: 0,
|
|
3498
|
+
outline: "none"
|
|
3499
|
+
},
|
|
3500
|
+
"aria-label": "Enter Voice Mode",
|
|
3501
|
+
title: "Use voice mode",
|
|
3502
|
+
children: /* @__PURE__ */ jsx(PiWaveform, { size: 20 })
|
|
3503
|
+
},
|
|
3504
|
+
"voice"
|
|
3505
|
+
) })
|
|
3506
|
+
}
|
|
3507
|
+
)
|
|
3508
|
+
] }) })
|
|
3509
|
+
}
|
|
3510
|
+
)
|
|
3511
|
+
]
|
|
3512
|
+
}
|
|
3513
|
+
)
|
|
3514
|
+
]
|
|
3515
|
+
}
|
|
3516
|
+
),
|
|
3517
|
+
convaiClient.state.isConnected && /* @__PURE__ */ jsx(
|
|
3518
|
+
SettingsTray,
|
|
3519
|
+
{
|
|
3520
|
+
isOpen: isSettingsOpen,
|
|
3521
|
+
onReset: convaiClient.isPublishedChatSession && !requestPublicationGrant ? void 0 : handleReset,
|
|
3522
|
+
onDisconnect: convaiClient.isPublishedChatSession && !requestPublicationGrant ? void 0 : handleDisconnect,
|
|
3523
|
+
onToggleVideo: convaiClient.connectionType === "video" && showVideo ? handleToggleVideo : void 0,
|
|
3524
|
+
isVideoVisible,
|
|
3525
|
+
onToggleScreenShare: convaiClient.connectionType === "video" && showScreenShare ? handleToggleScreenShare : void 0,
|
|
3526
|
+
isScreenShareActive: convaiClient.isScreenShareActive
|
|
3527
|
+
}
|
|
3528
|
+
)
|
|
3529
|
+
]
|
|
3530
|
+
}
|
|
3531
|
+
),
|
|
3532
|
+
((_d = convaiClient.room) == null ? void 0 : _d.state) === "connected" && /* @__PURE__ */ jsx(
|
|
3533
|
+
FloatingVideo,
|
|
3534
|
+
{
|
|
3535
|
+
isVisible: isVideoVisible,
|
|
3536
|
+
onClose: async () => {
|
|
3537
|
+
await convaiClient.videoControls.disableVideo();
|
|
3538
|
+
},
|
|
3539
|
+
mirror: true
|
|
3540
|
+
}
|
|
3541
|
+
)
|
|
3542
|
+
] });
|
|
3543
|
+
};
|
|
3544
|
+
export {
|
|
3545
|
+
RoomContext2 as AudioContext,
|
|
3546
|
+
RoomAudioRenderer as AudioRenderer,
|
|
3547
|
+
ConvaiWidget,
|
|
3548
|
+
MarkdownRenderer,
|
|
3549
|
+
useCharacterInfo,
|
|
3550
|
+
useLocalCameraTrack
|
|
3551
|
+
};
|