@kite-copilot/chat-panel 0.2.43 → 0.2.44
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/auto.cjs +143 -69
- package/dist/auto.js +1 -1
- package/dist/{chunk-XZM4VX5Y.js → chunk-G74XTXWW.js} +151 -77
- package/dist/embed.global.js +20 -20
- package/dist/index.cjs +143 -69
- package/dist/index.js +1 -1
- package/package.json +1 -1
|
@@ -882,7 +882,7 @@ function DataRenderer({ type, data }) {
|
|
|
882
882
|
}
|
|
883
883
|
|
|
884
884
|
// src/ChatPanel.tsx
|
|
885
|
-
import * as
|
|
885
|
+
import * as React6 from "react";
|
|
886
886
|
import { createClient } from "@supabase/supabase-js";
|
|
887
887
|
import { ArrowLeft, ArrowUp, Command, CornerDownLeft, CheckCircle2 as CheckCircle23, SquarePen, Paperclip, X, FileSpreadsheet, Loader2 as Loader22, ChevronLeft, ChevronRight, Sparkles, Minus } from "lucide-react";
|
|
888
888
|
|
|
@@ -953,6 +953,47 @@ function useUserAuth({
|
|
|
953
953
|
return { authState, retry };
|
|
954
954
|
}
|
|
955
955
|
|
|
956
|
+
// src/hooks/useOrgConfig.ts
|
|
957
|
+
import * as React5 from "react";
|
|
958
|
+
function useOrgConfig({ agentUrl, orgId }) {
|
|
959
|
+
const [state, setState] = React5.useState({
|
|
960
|
+
status: "idle",
|
|
961
|
+
config: null,
|
|
962
|
+
error: null
|
|
963
|
+
});
|
|
964
|
+
React5.useEffect(() => {
|
|
965
|
+
if (!agentUrl || !orgId) {
|
|
966
|
+
console.log("[useOrgConfig] Skipping - missing agentUrl or orgId", { agentUrl, orgId });
|
|
967
|
+
return;
|
|
968
|
+
}
|
|
969
|
+
const fetchConfig = async () => {
|
|
970
|
+
setState({ status: "loading", config: null, error: null });
|
|
971
|
+
const url = `${agentUrl}/org/${orgId}/config`;
|
|
972
|
+
console.log("[useOrgConfig] Fetching org config from:", url);
|
|
973
|
+
try {
|
|
974
|
+
const response = await fetch(url, {
|
|
975
|
+
method: "GET",
|
|
976
|
+
headers: {
|
|
977
|
+
"Accept": "application/json"
|
|
978
|
+
}
|
|
979
|
+
});
|
|
980
|
+
if (!response.ok) {
|
|
981
|
+
throw new Error(`Failed to fetch org config (${response.status})`);
|
|
982
|
+
}
|
|
983
|
+
const config = await response.json();
|
|
984
|
+
console.log("[useOrgConfig] Received config:", config);
|
|
985
|
+
setState({ status: "success", config, error: null });
|
|
986
|
+
} catch (error) {
|
|
987
|
+
const message = error instanceof Error ? error.message : "Failed to fetch org config";
|
|
988
|
+
console.error("[useOrgConfig] Error:", message);
|
|
989
|
+
setState({ status: "error", config: null, error: message });
|
|
990
|
+
}
|
|
991
|
+
};
|
|
992
|
+
fetchConfig();
|
|
993
|
+
}, [agentUrl, orgId]);
|
|
994
|
+
return state;
|
|
995
|
+
}
|
|
996
|
+
|
|
956
997
|
// src/components/TypingIndicator.tsx
|
|
957
998
|
import { jsx as jsx9, jsxs as jsxs5 } from "react/jsx-runtime";
|
|
958
999
|
function TypingIndicator({ className = "" }) {
|
|
@@ -983,7 +1024,7 @@ function TypingIndicator({ className = "" }) {
|
|
|
983
1024
|
|
|
984
1025
|
// src/ChatPanel.tsx
|
|
985
1026
|
import { Fragment as Fragment2, jsx as jsx10, jsxs as jsxs6 } from "react/jsx-runtime";
|
|
986
|
-
var CHAT_PANEL_VERSION = true ? "0.2.
|
|
1027
|
+
var CHAT_PANEL_VERSION = true ? "0.2.44" : "dev";
|
|
987
1028
|
var DEFAULT_AGENT_URL = "http://localhost:5002";
|
|
988
1029
|
var PANEL_WIDTH = 340;
|
|
989
1030
|
function unescapeJsonString(str) {
|
|
@@ -1447,16 +1488,18 @@ function ChatPanel({
|
|
|
1447
1488
|
supabaseAnonKey,
|
|
1448
1489
|
productBackendUrl
|
|
1449
1490
|
} = {}) {
|
|
1450
|
-
const [messages, setMessages] =
|
|
1451
|
-
const [input, setInput] =
|
|
1452
|
-
const [sessionId, setSessionId] =
|
|
1491
|
+
const [messages, setMessages] = React6.useState(initialMessages);
|
|
1492
|
+
const [input, setInput] = React6.useState("");
|
|
1493
|
+
const [sessionId, setSessionId] = React6.useState(() => crypto.randomUUID());
|
|
1494
|
+
const orgConfigState = useOrgConfig({ agentUrl, orgId: orgId || "" });
|
|
1495
|
+
const effectiveProductBackendUrl = orgConfigState.config?.productBackendUrl || productBackendUrl;
|
|
1453
1496
|
const { authState, retry: retryAuth } = useUserAuth({
|
|
1454
|
-
productBackendUrl,
|
|
1497
|
+
productBackendUrl: effectiveProductBackendUrl,
|
|
1455
1498
|
sessionId,
|
|
1456
|
-
enabled: !!
|
|
1457
|
-
// Only enable
|
|
1499
|
+
enabled: !!effectiveProductBackendUrl && orgConfigState.status === "success"
|
|
1500
|
+
// Only enable after config is fetched
|
|
1458
1501
|
});
|
|
1459
|
-
const effectiveUser =
|
|
1502
|
+
const effectiveUser = React6.useMemo(() => {
|
|
1460
1503
|
if (authState.status === "authenticated") {
|
|
1461
1504
|
return {
|
|
1462
1505
|
userId: authState.user.id,
|
|
@@ -1474,16 +1517,16 @@ function ChatPanel({
|
|
|
1474
1517
|
isInternal: false
|
|
1475
1518
|
};
|
|
1476
1519
|
}, [authState, userId, userName, userEmail]);
|
|
1477
|
-
const [isEscalated, setIsEscalated] =
|
|
1478
|
-
const escalationWsRef =
|
|
1479
|
-
const [agentIsTyping, setAgentIsTyping] =
|
|
1480
|
-
const supabaseRef =
|
|
1481
|
-
const typingChannelRef =
|
|
1482
|
-
const typingTimeoutRef =
|
|
1483
|
-
|
|
1520
|
+
const [isEscalated, setIsEscalated] = React6.useState(false);
|
|
1521
|
+
const escalationWsRef = React6.useRef(null);
|
|
1522
|
+
const [agentIsTyping, setAgentIsTyping] = React6.useState(false);
|
|
1523
|
+
const supabaseRef = React6.useRef(null);
|
|
1524
|
+
const typingChannelRef = React6.useRef(null);
|
|
1525
|
+
const typingTimeoutRef = React6.useRef(null);
|
|
1526
|
+
React6.useEffect(() => {
|
|
1484
1527
|
console.log(`[KiteChat] Chat Panel v${CHAT_PANEL_VERSION} loaded`);
|
|
1485
1528
|
}, []);
|
|
1486
|
-
const resetSession =
|
|
1529
|
+
const resetSession = React6.useCallback(() => {
|
|
1487
1530
|
console.log("[KiteChat] resetSession called", { isEscalated, hasSupabase: !!supabaseRef.current, sessionId });
|
|
1488
1531
|
if (isEscalated && supabaseRef.current && sessionId) {
|
|
1489
1532
|
console.log("[KiteChat] Updating customer_status to disconnected for session:", sessionId);
|
|
@@ -1513,12 +1556,12 @@ function ChatPanel({
|
|
|
1513
1556
|
typingChannelRef.current = null;
|
|
1514
1557
|
}
|
|
1515
1558
|
}, [isEscalated, sessionId]);
|
|
1516
|
-
|
|
1559
|
+
React6.useEffect(() => {
|
|
1517
1560
|
if (supabaseUrl && supabaseAnonKey && !supabaseRef.current) {
|
|
1518
1561
|
supabaseRef.current = createClient(supabaseUrl, supabaseAnonKey);
|
|
1519
1562
|
}
|
|
1520
1563
|
}, [supabaseUrl, supabaseAnonKey]);
|
|
1521
|
-
|
|
1564
|
+
React6.useEffect(() => {
|
|
1522
1565
|
if (!isEscalated || !sessionId || !supabaseRef.current) {
|
|
1523
1566
|
return;
|
|
1524
1567
|
}
|
|
@@ -1555,8 +1598,8 @@ function ChatPanel({
|
|
|
1555
1598
|
}
|
|
1556
1599
|
};
|
|
1557
1600
|
}, [isEscalated, sessionId]);
|
|
1558
|
-
const heartbeatIntervalRef =
|
|
1559
|
-
const updateCustomerStatus =
|
|
1601
|
+
const heartbeatIntervalRef = React6.useRef(null);
|
|
1602
|
+
const updateCustomerStatus = React6.useCallback(async (status) => {
|
|
1560
1603
|
if (!supabaseRef.current || !sessionId) return;
|
|
1561
1604
|
try {
|
|
1562
1605
|
await supabaseRef.current.from("escalations").update({
|
|
@@ -1567,7 +1610,7 @@ function ChatPanel({
|
|
|
1567
1610
|
console.error("[KiteChat] Failed to update customer status:", err);
|
|
1568
1611
|
}
|
|
1569
1612
|
}, [sessionId]);
|
|
1570
|
-
|
|
1613
|
+
React6.useEffect(() => {
|
|
1571
1614
|
if (!isEscalated || !sessionId || !supabaseRef.current) {
|
|
1572
1615
|
return;
|
|
1573
1616
|
}
|
|
@@ -1615,7 +1658,7 @@ function ChatPanel({
|
|
|
1615
1658
|
}
|
|
1616
1659
|
};
|
|
1617
1660
|
}, [isEscalated, sessionId, updateCustomerStatus]);
|
|
1618
|
-
const sendTypingIndicator =
|
|
1661
|
+
const sendTypingIndicator = React6.useCallback((isTyping) => {
|
|
1619
1662
|
if (!typingChannelRef.current) {
|
|
1620
1663
|
console.log("[KiteChat] Cannot send typing - channel not ready");
|
|
1621
1664
|
return;
|
|
@@ -1631,8 +1674,8 @@ function ChatPanel({
|
|
|
1631
1674
|
payload: { sender: "user", isTyping }
|
|
1632
1675
|
});
|
|
1633
1676
|
}, [isEscalated]);
|
|
1634
|
-
const userTypingTimeoutRef =
|
|
1635
|
-
const handleTypingStart =
|
|
1677
|
+
const userTypingTimeoutRef = React6.useRef(null);
|
|
1678
|
+
const handleTypingStart = React6.useCallback(() => {
|
|
1636
1679
|
if (!isEscalated || !supabaseRef.current) return;
|
|
1637
1680
|
sendTypingIndicator(true);
|
|
1638
1681
|
updateCustomerStatus("active");
|
|
@@ -1643,19 +1686,19 @@ function ChatPanel({
|
|
|
1643
1686
|
sendTypingIndicator(false);
|
|
1644
1687
|
}, 1500);
|
|
1645
1688
|
}, [isEscalated, sendTypingIndicator, updateCustomerStatus]);
|
|
1646
|
-
const streamIntervals =
|
|
1689
|
+
const streamIntervals = React6.useRef({});
|
|
1647
1690
|
const isEmpty = messages.length === 0;
|
|
1648
|
-
const [phase, setPhase] =
|
|
1649
|
-
const [progressSteps, setProgressSteps] =
|
|
1650
|
-
const phaseTimers =
|
|
1691
|
+
const [phase, setPhase] = React6.useState("idle");
|
|
1692
|
+
const [progressSteps, setProgressSteps] = React6.useState([]);
|
|
1693
|
+
const phaseTimers = React6.useRef([]);
|
|
1651
1694
|
const lastRole = messages.length ? messages[messages.length - 1].role : void 0;
|
|
1652
|
-
const [panelView, setPanelView] =
|
|
1695
|
+
const [panelView, setPanelView] = React6.useState(
|
|
1653
1696
|
"landing"
|
|
1654
1697
|
);
|
|
1655
|
-
const [currentFolderId, setCurrentFolderId] =
|
|
1656
|
-
const [startingQuestions, setStartingQuestions] =
|
|
1657
|
-
const [loadingQuestions, setLoadingQuestions] =
|
|
1658
|
-
|
|
1698
|
+
const [currentFolderId, setCurrentFolderId] = React6.useState(void 0);
|
|
1699
|
+
const [startingQuestions, setStartingQuestions] = React6.useState(startingQuestionsProp || defaultStartingQuestions);
|
|
1700
|
+
const [loadingQuestions, setLoadingQuestions] = React6.useState(false);
|
|
1701
|
+
React6.useEffect(() => {
|
|
1659
1702
|
if (startingQuestionsEndpoint && !startingQuestionsProp) {
|
|
1660
1703
|
setLoadingQuestions(true);
|
|
1661
1704
|
fetch(startingQuestionsEndpoint).then((res) => res.json()).then((data) => {
|
|
@@ -1667,16 +1710,16 @@ function ChatPanel({
|
|
|
1667
1710
|
}).finally(() => setLoadingQuestions(false));
|
|
1668
1711
|
}
|
|
1669
1712
|
}, [startingQuestionsEndpoint, startingQuestionsProp]);
|
|
1670
|
-
|
|
1713
|
+
React6.useEffect(() => {
|
|
1671
1714
|
if (startingQuestionsProp) {
|
|
1672
1715
|
setStartingQuestions(startingQuestionsProp);
|
|
1673
1716
|
}
|
|
1674
1717
|
}, [startingQuestionsProp]);
|
|
1675
|
-
const [activeGuide, setActiveGuide] =
|
|
1676
|
-
const activeGuideRef =
|
|
1677
|
-
const latestBulkSummaryNavigationRef =
|
|
1678
|
-
const [guideComplete, setGuideComplete] =
|
|
1679
|
-
|
|
1718
|
+
const [activeGuide, setActiveGuide] = React6.useState(void 0);
|
|
1719
|
+
const activeGuideRef = React6.useRef(void 0);
|
|
1720
|
+
const latestBulkSummaryNavigationRef = React6.useRef(null);
|
|
1721
|
+
const [guideComplete, setGuideComplete] = React6.useState(false);
|
|
1722
|
+
React6.useEffect(() => {
|
|
1680
1723
|
window.resetIntegrationNotification = () => {
|
|
1681
1724
|
localStorage.removeItem("gmailNotificationSeen");
|
|
1682
1725
|
console.log(
|
|
@@ -1710,7 +1753,7 @@ function ChatPanel({
|
|
|
1710
1753
|
);
|
|
1711
1754
|
};
|
|
1712
1755
|
}, []);
|
|
1713
|
-
|
|
1756
|
+
React6.useEffect(() => {
|
|
1714
1757
|
if (activeGuide) {
|
|
1715
1758
|
if (!activeGuideRef.current || activeGuideRef.current.id !== activeGuide.id || activeGuideRef.current.stepIndex !== activeGuide.stepIndex) {
|
|
1716
1759
|
activeGuideRef.current = activeGuide;
|
|
@@ -1719,21 +1762,21 @@ function ChatPanel({
|
|
|
1719
1762
|
activeGuideRef.current = void 0;
|
|
1720
1763
|
}
|
|
1721
1764
|
}, [activeGuide]);
|
|
1722
|
-
const [pendingNavigation, setPendingNavigation] =
|
|
1723
|
-
const [pendingAction, setPendingAction] =
|
|
1724
|
-
const [actionFormData, setActionFormData] =
|
|
1725
|
-
const messagesEndRef =
|
|
1726
|
-
const messagesContainerRef =
|
|
1727
|
-
const currentStepRef =
|
|
1765
|
+
const [pendingNavigation, setPendingNavigation] = React6.useState(null);
|
|
1766
|
+
const [pendingAction, setPendingAction] = React6.useState(null);
|
|
1767
|
+
const [actionFormData, setActionFormData] = React6.useState({});
|
|
1768
|
+
const messagesEndRef = React6.useRef(null);
|
|
1769
|
+
const messagesContainerRef = React6.useRef(null);
|
|
1770
|
+
const currentStepRef = React6.useRef(null);
|
|
1728
1771
|
const { cursorState, moveTo, hide } = useGuideCursor();
|
|
1729
|
-
const [pendingFile, setPendingFile] =
|
|
1730
|
-
const [pendingBulkSession, setPendingBulkSession] =
|
|
1731
|
-
const pendingBulkSessionRef =
|
|
1732
|
-
const fileInputRef =
|
|
1733
|
-
const [searchExpanded, setSearchExpanded] =
|
|
1734
|
-
const [searchInput, setSearchInput] =
|
|
1735
|
-
const searchInputRef =
|
|
1736
|
-
|
|
1772
|
+
const [pendingFile, setPendingFile] = React6.useState(null);
|
|
1773
|
+
const [pendingBulkSession, setPendingBulkSession] = React6.useState(null);
|
|
1774
|
+
const pendingBulkSessionRef = React6.useRef(null);
|
|
1775
|
+
const fileInputRef = React6.useRef(null);
|
|
1776
|
+
const [searchExpanded, setSearchExpanded] = React6.useState(false);
|
|
1777
|
+
const [searchInput, setSearchInput] = React6.useState("");
|
|
1778
|
+
const searchInputRef = React6.useRef(null);
|
|
1779
|
+
React6.useEffect(() => {
|
|
1737
1780
|
if (!activeGuide || activeGuide.id !== "add-api-key" || activeGuide.stepIndex !== 2) {
|
|
1738
1781
|
return;
|
|
1739
1782
|
}
|
|
@@ -1759,7 +1802,7 @@ function ChatPanel({
|
|
|
1759
1802
|
const interval = setInterval(checkForDialogOpen, 300);
|
|
1760
1803
|
return () => clearInterval(interval);
|
|
1761
1804
|
}, [activeGuide, hide]);
|
|
1762
|
-
|
|
1805
|
+
React6.useEffect(() => {
|
|
1763
1806
|
return () => {
|
|
1764
1807
|
Object.values(streamIntervals.current).forEach(
|
|
1765
1808
|
(id) => window.clearInterval(id)
|
|
@@ -1769,7 +1812,7 @@ function ChatPanel({
|
|
|
1769
1812
|
phaseTimers.current = [];
|
|
1770
1813
|
};
|
|
1771
1814
|
}, []);
|
|
1772
|
-
|
|
1815
|
+
React6.useEffect(() => {
|
|
1773
1816
|
if (activeGuide && messages.length > 0) {
|
|
1774
1817
|
const lastMessage = messages[messages.length - 1];
|
|
1775
1818
|
if (lastMessage.kind === "guideStep" || lastMessage.kind === "guideComplete") {
|
|
@@ -1786,7 +1829,7 @@ function ChatPanel({
|
|
|
1786
1829
|
messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
|
|
1787
1830
|
}
|
|
1788
1831
|
}, [messages, phase, activeGuide]);
|
|
1789
|
-
const latestBulkSummaryNavigation =
|
|
1832
|
+
const latestBulkSummaryNavigation = React6.useMemo(() => {
|
|
1790
1833
|
for (let i = messages.length - 1; i >= 0; i--) {
|
|
1791
1834
|
const msg = messages[i];
|
|
1792
1835
|
if (msg.kind === "bulkSummary" && msg.bulkSummary?.navigationPage && msg.bulkSummary.successes > 0) {
|
|
@@ -1795,13 +1838,13 @@ function ChatPanel({
|
|
|
1795
1838
|
}
|
|
1796
1839
|
return null;
|
|
1797
1840
|
}, [messages]);
|
|
1798
|
-
|
|
1841
|
+
React6.useEffect(() => {
|
|
1799
1842
|
latestBulkSummaryNavigationRef.current = latestBulkSummaryNavigation;
|
|
1800
1843
|
}, [latestBulkSummaryNavigation]);
|
|
1801
|
-
|
|
1844
|
+
React6.useEffect(() => {
|
|
1802
1845
|
pendingBulkSessionRef.current = pendingBulkSession;
|
|
1803
1846
|
}, [pendingBulkSession]);
|
|
1804
|
-
|
|
1847
|
+
React6.useEffect(() => {
|
|
1805
1848
|
const handleKeyDown = (e) => {
|
|
1806
1849
|
if ((e.metaKey || e.ctrlKey) && e.key === "Enter") {
|
|
1807
1850
|
const currentBulkSession = pendingBulkSessionRef.current;
|
|
@@ -1864,7 +1907,7 @@ function ChatPanel({
|
|
|
1864
1907
|
guideComplete,
|
|
1865
1908
|
onNavigate
|
|
1866
1909
|
]);
|
|
1867
|
-
const connectToEscalationWs =
|
|
1910
|
+
const connectToEscalationWs = React6.useCallback((currentSessionId) => {
|
|
1868
1911
|
if (!agentUrl) return;
|
|
1869
1912
|
if (escalationWsRef.current) {
|
|
1870
1913
|
escalationWsRef.current.close();
|
|
@@ -1907,7 +1950,7 @@ function ChatPanel({
|
|
|
1907
1950
|
};
|
|
1908
1951
|
escalationWsRef.current = ws;
|
|
1909
1952
|
}, [agentUrl]);
|
|
1910
|
-
const sendEscalatedMessage =
|
|
1953
|
+
const sendEscalatedMessage = React6.useCallback(async (content) => {
|
|
1911
1954
|
if (!escalationWsRef.current || escalationWsRef.current.readyState !== WebSocket.OPEN) {
|
|
1912
1955
|
console.error("[KiteChat] Escalation WebSocket not connected");
|
|
1913
1956
|
return false;
|
|
@@ -1924,14 +1967,14 @@ function ChatPanel({
|
|
|
1924
1967
|
return false;
|
|
1925
1968
|
}
|
|
1926
1969
|
}, [updateCustomerStatus]);
|
|
1927
|
-
|
|
1970
|
+
React6.useEffect(() => {
|
|
1928
1971
|
return () => {
|
|
1929
1972
|
if (escalationWsRef.current) {
|
|
1930
1973
|
escalationWsRef.current.close();
|
|
1931
1974
|
}
|
|
1932
1975
|
};
|
|
1933
1976
|
}, []);
|
|
1934
|
-
|
|
1977
|
+
React6.useEffect(() => {
|
|
1935
1978
|
if (isEscalated && sessionId) {
|
|
1936
1979
|
connectToEscalationWs(sessionId);
|
|
1937
1980
|
}
|
|
@@ -3160,7 +3203,38 @@ ${userText}`
|
|
|
3160
3203
|
] })
|
|
3161
3204
|
] }) }) });
|
|
3162
3205
|
}
|
|
3163
|
-
if (
|
|
3206
|
+
if (orgConfigState.status === "loading") {
|
|
3207
|
+
return /* @__PURE__ */ jsxs6(
|
|
3208
|
+
"section",
|
|
3209
|
+
{
|
|
3210
|
+
className: `fixed top-0 right-0 z-40 flex flex-col bg-white border-l border-gray-200 h-full overflow-hidden transition-transform duration-300 ${isOpen ? "translate-x-0" : "translate-x-full"}`,
|
|
3211
|
+
style: { width: `${PANEL_WIDTH}px` },
|
|
3212
|
+
children: [
|
|
3213
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center justify-between px-4 py-3 border-b border-gray-100 bg-gradient-to-r from-gray-50 to-white shrink-0", children: [
|
|
3214
|
+
/* @__PURE__ */ jsxs6("div", { className: "flex items-center gap-2.5", children: [
|
|
3215
|
+
/* @__PURE__ */ jsx10(Sparkles, { className: "h-3.5 w-3.5 text-black", fill: "currentColor" }),
|
|
3216
|
+
/* @__PURE__ */ jsx10("h3", { className: "text-sm font-semibold text-gray-800", children: "Copilot" })
|
|
3217
|
+
] }),
|
|
3218
|
+
/* @__PURE__ */ jsx10(
|
|
3219
|
+
Button,
|
|
3220
|
+
{
|
|
3221
|
+
variant: "ghost",
|
|
3222
|
+
size: "sm",
|
|
3223
|
+
className: "h-7 w-7 p-0 text-gray-400 hover:text-gray-600 hover:bg-gray-100 rounded-full",
|
|
3224
|
+
onClick: () => onClose?.(),
|
|
3225
|
+
children: /* @__PURE__ */ jsx10(X, { className: "h-4 w-4" })
|
|
3226
|
+
}
|
|
3227
|
+
)
|
|
3228
|
+
] }),
|
|
3229
|
+
/* @__PURE__ */ jsx10("div", { className: "flex-1 flex items-center justify-center", children: /* @__PURE__ */ jsxs6("div", { className: "text-center", children: [
|
|
3230
|
+
/* @__PURE__ */ jsx10(Loader22, { className: "h-8 w-8 animate-spin text-gray-400 mx-auto mb-3" }),
|
|
3231
|
+
/* @__PURE__ */ jsx10("p", { className: "text-sm text-gray-500", children: "Loading..." })
|
|
3232
|
+
] }) })
|
|
3233
|
+
]
|
|
3234
|
+
}
|
|
3235
|
+
);
|
|
3236
|
+
}
|
|
3237
|
+
if (effectiveProductBackendUrl) {
|
|
3164
3238
|
if (authState.status === "loading") {
|
|
3165
3239
|
return /* @__PURE__ */ jsxs6(
|
|
3166
3240
|
"section",
|
|
@@ -4335,7 +4409,7 @@ ${userText}`
|
|
|
4335
4409
|
message.id
|
|
4336
4410
|
);
|
|
4337
4411
|
}
|
|
4338
|
-
return /* @__PURE__ */ jsx10(
|
|
4412
|
+
return /* @__PURE__ */ jsx10(React6.Fragment, { children: /* @__PURE__ */ jsxs6(
|
|
4339
4413
|
"div",
|
|
4340
4414
|
{
|
|
4341
4415
|
ref: isCurrentGuideStep ? currentStepRef : null,
|
|
@@ -4592,7 +4666,7 @@ function ChatPanelWithToggle({
|
|
|
4592
4666
|
supabaseAnonKey,
|
|
4593
4667
|
productBackendUrl
|
|
4594
4668
|
}) {
|
|
4595
|
-
const [internalIsOpen, setInternalIsOpen] =
|
|
4669
|
+
const [internalIsOpen, setInternalIsOpen] = React6.useState(defaultOpen);
|
|
4596
4670
|
const isOpen = controlledIsOpen !== void 0 ? controlledIsOpen : internalIsOpen;
|
|
4597
4671
|
const setIsOpen = (open) => {
|
|
4598
4672
|
if (controlledIsOpen === void 0) {
|
|
@@ -4600,7 +4674,7 @@ function ChatPanelWithToggle({
|
|
|
4600
4674
|
}
|
|
4601
4675
|
onOpenChange?.(open);
|
|
4602
4676
|
};
|
|
4603
|
-
|
|
4677
|
+
React6.useEffect(() => {
|
|
4604
4678
|
const originalPadding = document.body.style.paddingRight;
|
|
4605
4679
|
const originalTransition = document.body.style.transition;
|
|
4606
4680
|
document.body.style.transition = "padding-right 0.3s ease";
|
|
@@ -4647,7 +4721,7 @@ function HelpButton({ onClick, className = "" }) {
|
|
|
4647
4721
|
}
|
|
4648
4722
|
|
|
4649
4723
|
// src/createKiteChat.tsx
|
|
4650
|
-
import
|
|
4724
|
+
import React7 from "react";
|
|
4651
4725
|
import { createRoot } from "react-dom/client";
|
|
4652
4726
|
import { jsx as jsx11 } from "react/jsx-runtime";
|
|
4653
4727
|
function KiteChatWrapper({
|
|
@@ -4655,14 +4729,14 @@ function KiteChatWrapper({
|
|
|
4655
4729
|
onConfigUpdate,
|
|
4656
4730
|
onStateUpdate
|
|
4657
4731
|
}) {
|
|
4658
|
-
const [config, setConfig] =
|
|
4659
|
-
const [currentPage, setCurrentPage] =
|
|
4660
|
-
const [isOpen, setIsOpen] =
|
|
4661
|
-
const isOpenRef =
|
|
4662
|
-
|
|
4732
|
+
const [config, setConfig] = React7.useState(initialConfig);
|
|
4733
|
+
const [currentPage, setCurrentPage] = React7.useState(initialConfig.currentPage || "dashboard");
|
|
4734
|
+
const [isOpen, setIsOpen] = React7.useState(false);
|
|
4735
|
+
const isOpenRef = React7.useRef(false);
|
|
4736
|
+
React7.useEffect(() => {
|
|
4663
4737
|
isOpenRef.current = isOpen;
|
|
4664
4738
|
}, [isOpen]);
|
|
4665
|
-
|
|
4739
|
+
React7.useEffect(() => {
|
|
4666
4740
|
onConfigUpdate((newConfig) => {
|
|
4667
4741
|
if (newConfig.currentPage !== void 0) {
|
|
4668
4742
|
setCurrentPage(newConfig.currentPage);
|
|
@@ -4674,7 +4748,7 @@ function KiteChatWrapper({
|
|
|
4674
4748
|
getIsOpen: () => isOpenRef.current
|
|
4675
4749
|
});
|
|
4676
4750
|
}, [onConfigUpdate, onStateUpdate]);
|
|
4677
|
-
|
|
4751
|
+
React7.useEffect(() => {
|
|
4678
4752
|
const container = document.getElementById("kite-chat-root");
|
|
4679
4753
|
if (!container) return;
|
|
4680
4754
|
if (config.theme === "dark") {
|