@howone/sdk 0.1.18 → 0.1.20

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -232,7 +232,7 @@ var FloatingButton = ({
232
232
  {
233
233
  onClick,
234
234
  id: "floating-howone-btn",
235
- className: `fixed flex bg-white gap-2 items-center right-4 z-50 text-black px-3 py-2 rounded-lg shadow-lg transition-colors duration-200 ${className}`,
235
+ className: `fixed flex bg-background gap-2 items-center right-4 z-50 text-black dark:text-white px-3 py-2 rounded-lg shadow-lg transition-colors duration-200 border border-gray-200 dark:border-gray-700 ${className}`,
236
236
  style: {
237
237
  fontSize: "14px",
238
238
  fontWeight: "bold",
@@ -245,7 +245,7 @@ var FloatingButton = ({
245
245
  e.stopPropagation();
246
246
  const btn = document.getElementById("floating-howone-btn");
247
247
  if (btn) btn.style.display = "none";
248
- }, className: "w-5 h-5 font-bold pointer-events-auto" })
248
+ }, className: "w-5 h-5 font-bold pointer-events-auto text-gray-500 dark:text-gray-400 hover:text-gray-700 dark:hover:text-gray-200" })
249
249
  ] })
250
250
  }
251
251
  );
@@ -1498,111 +1498,87 @@ var LoginForm = ({
1498
1498
  };
1499
1499
 
1500
1500
  // src/components/auth/AuthProvider.tsx
1501
- import { createContext, useContext, useEffect as useEffect3, useState as useState3 } from "react";
1502
1501
  init_auth();
1503
- init_config();
1502
+ import { createContext as createContext2, useContext as useContext2, useState as useState4 } from "react";
1504
1503
 
1505
- // src/components/ui/Loading.tsx
1506
- import { jsx as jsx3, jsxs as jsxs3 } from "react/jsx-runtime";
1507
- var Loading = ({
1508
- size = "md",
1509
- text = "Loading...",
1510
- className = "",
1511
- fullScreen = false
1512
- }) => {
1513
- const sizeClasses = {
1514
- sm: "h-4 w-4",
1515
- md: "h-8 w-8",
1516
- lg: "h-12 w-12"
1517
- };
1518
- const containerClasses = fullScreen ? "fixed inset-0 flex items-center justify-center bg-white/80 backdrop-blur-sm z-50" : "flex items-center justify-center p-4";
1519
- return /* @__PURE__ */ jsx3("div", { className: `${containerClasses} ${className}`, children: /* @__PURE__ */ jsxs3("div", { className: "text-center", children: [
1520
- /* @__PURE__ */ jsx3(
1521
- "div",
1522
- {
1523
- className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 mx-auto ${sizeClasses[size]}`
1524
- }
1525
- ),
1526
- text && /* @__PURE__ */ jsx3("p", { className: "mt-2 text-sm text-gray-600", children: text })
1527
- ] }) });
1504
+ // src/components/theme/ThemeProvider.tsx
1505
+ import { createContext, useContext, useEffect as useEffect3, useState as useState3 } from "react";
1506
+ import { jsx as jsx3 } from "react/jsx-runtime";
1507
+ var initialState = {
1508
+ theme: "system",
1509
+ setTheme: () => null
1528
1510
  };
1529
- var LoadingSpinner = ({
1530
- size = "md",
1531
- className = ""
1532
- }) => {
1533
- const sizeClasses = {
1534
- sm: "h-4 w-4",
1535
- md: "h-8 w-8",
1536
- lg: "h-12 w-12"
1511
+ var ThemeProviderContext = createContext(initialState);
1512
+ function ThemeProvider({
1513
+ children,
1514
+ defaultTheme = "system",
1515
+ storageKey = "vite-ui-theme",
1516
+ forceDefault = false,
1517
+ ...props
1518
+ }) {
1519
+ const [theme, setTheme] = useState3(() => {
1520
+ if (forceDefault) {
1521
+ localStorage.setItem(storageKey, defaultTheme);
1522
+ return defaultTheme;
1523
+ }
1524
+ const stored = localStorage.getItem(storageKey);
1525
+ const initialTheme = stored || defaultTheme;
1526
+ if (!stored) {
1527
+ localStorage.setItem(storageKey, defaultTheme);
1528
+ }
1529
+ return initialTheme;
1530
+ });
1531
+ useEffect3(() => {
1532
+ const root = window.document.documentElement;
1533
+ root.classList.remove("light", "dark");
1534
+ if (theme === "system") {
1535
+ const systemTheme = window.matchMedia("(prefers-color-scheme: dark)").matches ? "dark" : "light";
1536
+ root.classList.add(systemTheme);
1537
+ return;
1538
+ }
1539
+ root.classList.add(theme);
1540
+ }, [theme]);
1541
+ const value = {
1542
+ theme,
1543
+ setTheme: (theme2) => {
1544
+ localStorage.setItem(storageKey, theme2);
1545
+ setTheme(theme2);
1546
+ }
1537
1547
  };
1538
- return /* @__PURE__ */ jsx3(
1539
- "div",
1548
+ return /* @__PURE__ */ jsx3(ThemeProviderContext.Provider, { ...props, value, children });
1549
+ }
1550
+ var useTheme = () => {
1551
+ const context = useContext(ThemeProviderContext);
1552
+ if (context === void 0)
1553
+ throw new Error("useTheme must be used within a ThemeProvider");
1554
+ return context;
1555
+ };
1556
+
1557
+ // src/components/ui/Toast/GlobalToastContainer.tsx
1558
+ import { ToastContainer } from "react-toastify";
1559
+ import { jsx as jsx4 } from "react/jsx-runtime";
1560
+ function GlobalToastContainer() {
1561
+ return /* @__PURE__ */ jsx4(
1562
+ ToastContainer,
1540
1563
  {
1541
- className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 ${sizeClasses[size]} ${className}`
1564
+ newestOnTop: false,
1565
+ closeButton: false
1542
1566
  }
1543
1567
  );
1544
- };
1568
+ }
1545
1569
 
1546
1570
  // src/components/auth/AuthProvider.tsx
1547
- import { Fragment, jsx as jsx4, jsxs as jsxs4 } from "react/jsx-runtime";
1548
- var AuthContext = createContext(null);
1549
- var AuthProvider = ({ children, autoRedirect = true, showFloatingButton = true, projectId }) => {
1550
- const [user, setUser] = useState3(() => parseUserFromToken(getToken()));
1551
- const [token, setTokenState] = useState3(() => getToken());
1552
- const [isLoading, setIsLoading] = useState3(false);
1553
- useEffect3(() => {
1554
- try {
1555
- if (projectId) setDefaultProjectId(String(projectId));
1556
- } catch {
1557
- }
1558
- setIsLoading(true);
1559
- try {
1560
- const cb = unifiedAuth.checkOAuthCallback();
1561
- if (cb && cb.success) {
1562
- setTokenState(cb.token ?? getToken());
1563
- setUser(cb.user ?? parseUserFromToken(cb.token ?? getToken()));
1564
- setIsLoading(false);
1565
- return;
1566
- }
1567
- } catch {
1568
- }
1569
- const unsubscribe = onAuthStateChanged((state) => {
1570
- try {
1571
- setTokenState(getToken());
1572
- setUser(state.user ?? parseUserFromToken(getToken()));
1573
- } catch {
1574
- }
1575
- setIsLoading(false);
1576
- if (autoRedirect && !state.user) {
1577
- try {
1578
- const root = getAuthRoot();
1579
- const authUrl = new URL("/auth", String(root));
1580
- authUrl.searchParams.set("redirect_uri", window.location.href);
1581
- const pid = getDefaultProjectId();
1582
- if (pid) authUrl.searchParams.set("project_id", pid);
1583
- try {
1584
- if (window.top && window.top !== window) {
1585
- window.top.location.replace(authUrl.toString());
1586
- } else {
1587
- window.location.replace(authUrl.toString());
1588
- }
1589
- } catch (e) {
1590
- try {
1591
- window.location.replace(authUrl.toString());
1592
- } catch {
1593
- }
1594
- }
1595
- } catch {
1596
- }
1597
- }
1598
- });
1599
- return () => {
1600
- try {
1601
- unsubscribe();
1602
- } catch {
1603
- }
1604
- };
1605
- }, [autoRedirect]);
1571
+ import { jsx as jsx5, jsxs as jsxs3 } from "react/jsx-runtime";
1572
+ var AuthContext = createContext2(null);
1573
+ var HowoneProvider = ({
1574
+ children,
1575
+ showFloatingButton = true,
1576
+ defaultTheme = "system",
1577
+ themeStorageKey = "howone-theme",
1578
+ forceDefaultTheme = false
1579
+ }) => {
1580
+ const [user, setUser] = useState4(() => parseUserFromToken(getToken()));
1581
+ const [token, setTokenState] = useState4(() => getToken());
1606
1582
  const logout = () => {
1607
1583
  try {
1608
1584
  setToken(null);
@@ -1617,16 +1593,24 @@ var AuthProvider = ({ children, autoRedirect = true, showFloatingButton = true,
1617
1593
  isAuthenticated: !!token,
1618
1594
  logout
1619
1595
  };
1620
- return /* @__PURE__ */ jsx4(AuthContext.Provider, { value, children: isLoading ? /* @__PURE__ */ jsxs4(Fragment, { children: [
1621
- /* @__PURE__ */ jsx4(Loading, { fullScreen: true, text: "Checking authentication..." }),
1622
- showFloatingButton && /* @__PURE__ */ jsx4(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") })
1623
- ] }) : /* @__PURE__ */ jsxs4(Fragment, { children: [
1624
- children,
1625
- showFloatingButton && /* @__PURE__ */ jsx4(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") })
1626
- ] }) });
1596
+ return /* @__PURE__ */ jsxs3(
1597
+ ThemeProvider,
1598
+ {
1599
+ defaultTheme,
1600
+ storageKey: themeStorageKey,
1601
+ forceDefault: forceDefaultTheme,
1602
+ children: [
1603
+ /* @__PURE__ */ jsxs3(AuthContext.Provider, { value, children: [
1604
+ children,
1605
+ showFloatingButton && /* @__PURE__ */ jsx5(FloatingButton, { onClick: () => window.open("https://howone.ai", "_blank") })
1606
+ ] }),
1607
+ /* @__PURE__ */ jsx5(GlobalToastContainer, {})
1608
+ ]
1609
+ }
1610
+ );
1627
1611
  };
1628
1612
  function useAuthContext() {
1629
- const ctx = useContext(AuthContext);
1613
+ const ctx = useContext2(AuthContext);
1630
1614
  if (!ctx) {
1631
1615
  const t = getToken();
1632
1616
  return {
@@ -1643,6 +1627,7 @@ function useAuthContext() {
1643
1627
  }
1644
1628
  return ctx;
1645
1629
  }
1630
+ var AuthProvider = HowoneProvider;
1646
1631
 
1647
1632
  // src/components/index.ts
1648
1633
  init_auth();
@@ -1729,9 +1714,50 @@ var howone = {
1729
1714
  };
1730
1715
  var client_default = howone;
1731
1716
 
1717
+ // src/components/ui/Loading.tsx
1718
+ import { jsx as jsx6, jsxs as jsxs4 } from "react/jsx-runtime";
1719
+ var Loading = ({
1720
+ size = "md",
1721
+ text = "Loading...",
1722
+ className = "",
1723
+ fullScreen = false
1724
+ }) => {
1725
+ const sizeClasses = {
1726
+ sm: "h-4 w-4",
1727
+ md: "h-8 w-8",
1728
+ lg: "h-12 w-12"
1729
+ };
1730
+ const containerClasses = fullScreen ? "fixed inset-0 flex items-center justify-center bg-white/80 backdrop-blur-sm z-50" : "flex items-center justify-center p-4";
1731
+ return /* @__PURE__ */ jsx6("div", { className: `${containerClasses} ${className}`, children: /* @__PURE__ */ jsxs4("div", { className: "text-center", children: [
1732
+ /* @__PURE__ */ jsx6(
1733
+ "div",
1734
+ {
1735
+ className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 mx-auto ${sizeClasses[size]}`
1736
+ }
1737
+ ),
1738
+ text && /* @__PURE__ */ jsx6("p", { className: "mt-2 text-sm text-gray-600", children: text })
1739
+ ] }) });
1740
+ };
1741
+ var LoadingSpinner = ({
1742
+ size = "md",
1743
+ className = ""
1744
+ }) => {
1745
+ const sizeClasses = {
1746
+ sm: "h-4 w-4",
1747
+ md: "h-8 w-8",
1748
+ lg: "h-12 w-12"
1749
+ };
1750
+ return /* @__PURE__ */ jsx6(
1751
+ "div",
1752
+ {
1753
+ className: `animate-spin rounded-full border-2 border-gray-300 border-t-blue-600 ${sizeClasses[size]} ${className}`
1754
+ }
1755
+ );
1756
+ };
1757
+
1732
1758
  // src/components/ui/ErrorBoundary.tsx
1733
1759
  import { Component } from "react";
1734
- import { jsx as jsx5, jsxs as jsxs5 } from "react/jsx-runtime";
1760
+ import { jsx as jsx7, jsxs as jsxs5 } from "react/jsx-runtime";
1735
1761
  var ErrorBoundary = class extends Component {
1736
1762
  constructor(props) {
1737
1763
  super(props);
@@ -1754,13 +1780,13 @@ var ErrorBoundary = class extends Component {
1754
1780
  if (this.state.hasError) {
1755
1781
  if (this.props.fallback) {
1756
1782
  const FallbackComponent = this.props.fallback;
1757
- return /* @__PURE__ */ jsx5(FallbackComponent, { error: this.state.error, retry: this.handleRetry });
1783
+ return /* @__PURE__ */ jsx7(FallbackComponent, { error: this.state.error, retry: this.handleRetry });
1758
1784
  }
1759
- return /* @__PURE__ */ jsx5("div", { className: "min-h-[400px] flex items-center justify-center p-4", children: /* @__PURE__ */ jsxs5("div", { className: "text-center max-w-md", children: [
1760
- /* @__PURE__ */ jsx5("div", { className: "text-red-500 text-6xl mb-4", children: "\u26A0\uFE0F" }),
1761
- /* @__PURE__ */ jsx5("h2", { className: "text-xl font-semibold text-gray-900 mb-2", children: "Something went wrong" }),
1762
- /* @__PURE__ */ jsx5("p", { className: "text-gray-600 mb-4", children: "An unexpected error occurred. Please try refreshing the page." }),
1763
- /* @__PURE__ */ jsx5(
1785
+ return /* @__PURE__ */ jsx7("div", { className: "min-h-[400px] flex items-center justify-center p-4", children: /* @__PURE__ */ jsxs5("div", { className: "text-center max-w-md", children: [
1786
+ /* @__PURE__ */ jsx7("div", { className: "text-red-500 text-6xl mb-4", children: "\u26A0\uFE0F" }),
1787
+ /* @__PURE__ */ jsx7("h2", { className: "text-xl font-semibold text-gray-900 mb-2", children: "Something went wrong" }),
1788
+ /* @__PURE__ */ jsx7("p", { className: "text-gray-600 mb-4", children: "An unexpected error occurred. Please try refreshing the page." }),
1789
+ /* @__PURE__ */ jsx7(
1764
1790
  "button",
1765
1791
  {
1766
1792
  onClick: this.handleRetry,
@@ -1774,10 +1800,10 @@ var ErrorBoundary = class extends Component {
1774
1800
  return this.props.children;
1775
1801
  }
1776
1802
  };
1777
- var DefaultErrorFallback = ({ retry }) => /* @__PURE__ */ jsx5("div", { className: "min-h-[200px] flex items-center justify-center p-4", children: /* @__PURE__ */ jsxs5("div", { className: "text-center", children: [
1778
- /* @__PURE__ */ jsx5("div", { className: "text-red-500 text-4xl mb-2", children: "\u26A0\uFE0F" }),
1779
- /* @__PURE__ */ jsx5("p", { className: "text-gray-600 mb-2", children: "Something went wrong" }),
1780
- retry && /* @__PURE__ */ jsx5(
1803
+ var DefaultErrorFallback = ({ retry }) => /* @__PURE__ */ jsx7("div", { className: "min-h-[200px] flex items-center justify-center p-4", children: /* @__PURE__ */ jsxs5("div", { className: "text-center", children: [
1804
+ /* @__PURE__ */ jsx7("div", { className: "text-red-500 text-4xl mb-2", children: "\u26A0\uFE0F" }),
1805
+ /* @__PURE__ */ jsx7("p", { className: "text-gray-600 mb-2", children: "Something went wrong" }),
1806
+ retry && /* @__PURE__ */ jsx7(
1781
1807
  "button",
1782
1808
  {
1783
1809
  onClick: retry,
@@ -1787,12 +1813,217 @@ var DefaultErrorFallback = ({ retry }) => /* @__PURE__ */ jsx5("div", { classNam
1787
1813
  )
1788
1814
  ] }) });
1789
1815
 
1790
- // src/hooks/use-mobile.ts
1816
+ // src/components/theme/ThemeToggle.tsx
1791
1817
  import * as React4 from "react";
1818
+ import { useTheme as useTheme2 } from "next-themes";
1819
+ import { Icon as Icon3 } from "@iconify/react";
1820
+ import { jsx as jsx8, jsxs as jsxs6 } from "react/jsx-runtime";
1821
+ function ThemeToggle({ className }) {
1822
+ const { setTheme, theme } = useTheme2();
1823
+ const [mounted, setMounted] = React4.useState(false);
1824
+ React4.useEffect(() => {
1825
+ setMounted(true);
1826
+ }, []);
1827
+ if (!mounted) {
1828
+ return /* @__PURE__ */ jsxs6(
1829
+ "button",
1830
+ {
1831
+ className: `relative inline-flex h-10 w-12 items-center justify-center rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground ${className || ""}`,
1832
+ disabled: true,
1833
+ children: [
1834
+ /* @__PURE__ */ jsx8(Icon3, { icon: "solar:sun-2-linear", width: 20, height: 20 }),
1835
+ /* @__PURE__ */ jsx8("span", { className: "sr-only", children: "Toggle theme" })
1836
+ ]
1837
+ }
1838
+ );
1839
+ }
1840
+ return /* @__PURE__ */ jsxs6(
1841
+ "button",
1842
+ {
1843
+ className: `inline-flex h-10 w-12 items-center justify-center rounded-md border border-input bg-background hover:bg-accent hover:text-accent-foreground transition-colors ${className || ""}`,
1844
+ onClick: () => setTheme(theme === "light" ? "dark" : "light"),
1845
+ children: [
1846
+ theme === "light" ? /* @__PURE__ */ jsx8(Icon3, { icon: "solar:sun-2-linear", width: 20, height: 20 }) : /* @__PURE__ */ jsx8(Icon3, { icon: "solar:moon-linear", width: 20, height: 20 }),
1847
+ /* @__PURE__ */ jsx8("span", { className: "sr-only", children: "Toggle theme" })
1848
+ ]
1849
+ }
1850
+ );
1851
+ }
1852
+
1853
+ // src/components/ui/Toast/ClayxToast.tsx
1854
+ import React5, { useCallback } from "react";
1855
+ import { Bounce, toast } from "react-toastify";
1856
+ import { Icon as Icon4 } from "@iconify/react";
1857
+ import { jsx as jsx9, jsxs as jsxs7 } from "react/jsx-runtime";
1858
+ var TOAST_ICONS = {
1859
+ success: {
1860
+ icon: "mdi:success",
1861
+ color: "text-green-400",
1862
+ className: "text-green-400",
1863
+ bgGradient: "bg-[#14181df2]",
1864
+ gradientColor: "#389726",
1865
+ borderGradient: "border-[#389726]",
1866
+ borderGradientColor: "#389726"
1867
+ },
1868
+ error: {
1869
+ icon: "ic:outline-close",
1870
+ color: "text-red-400",
1871
+ className: "text-red-400",
1872
+ bgGradient: "bg-[#14181df2]",
1873
+ gradientColor: "#ef4444",
1874
+ borderGradient: "border-[#ef4444]",
1875
+ borderGradientColor: "#ef4444"
1876
+ },
1877
+ warning: {
1878
+ icon: "mi:warning",
1879
+ color: "text-yellow-400",
1880
+ className: "text-yellow-400",
1881
+ bgGradient: "bg-[#14181df2]",
1882
+ gradientColor: "#facc15",
1883
+ borderGradient: "border-[#facc15]",
1884
+ borderGradientColor: "#facc15"
1885
+ },
1886
+ info: {
1887
+ icon: "ic:outline-info",
1888
+ color: "text-blue-400",
1889
+ className: "text-blue-400",
1890
+ bgGradient: "bg-[#14181df2]",
1891
+ gradientColor: "#60a5fa",
1892
+ borderGradient: "border-[#60a5fa]",
1893
+ borderGradientColor: "#f0f0f0"
1894
+ },
1895
+ default: {
1896
+ icon: "ic:round-notifications",
1897
+ color: "text-gray-400",
1898
+ className: "text-gray-400",
1899
+ bgGradient: "bg-[#14181df2]",
1900
+ gradientColor: "#9ca3af",
1901
+ borderGradient: "border-[#9ca3af]",
1902
+ borderGradientColor: "#9ca3af"
1903
+ }
1904
+ };
1905
+ var CloseButton = React5.memo(({ closeToast }) => {
1906
+ const handleClick = useCallback((e) => {
1907
+ e.preventDefault();
1908
+ e.stopPropagation();
1909
+ closeToast?.();
1910
+ }, [closeToast]);
1911
+ return /* @__PURE__ */ jsx9(
1912
+ Icon4,
1913
+ {
1914
+ icon: "vaadin:close",
1915
+ className: "flex items-center justify-center rounded-full relative z-10 flex-shrink-0 cursor-pointer \n !text-[#b4b4b4] hover:text-white transition-colors duration-200 drop-shadow-sm",
1916
+ onClick: handleClick,
1917
+ width: 14,
1918
+ height: 14
1919
+ }
1920
+ );
1921
+ });
1922
+ CloseButton.displayName = "CloseButton";
1923
+ var ToastContent = ({ type, title, message, component, closeToast }) => {
1924
+ const iconConfig = TOAST_ICONS[type];
1925
+ const handleClose = useCallback(() => {
1926
+ closeToast?.();
1927
+ }, [closeToast]);
1928
+ console.log(iconConfig, "????????");
1929
+ if (component) {
1930
+ return /* @__PURE__ */ jsxs7("div", { className: `flex items-start gap-3 min-h-[80px] w-full backdrop-blur-md
1931
+ rounded-xl p-4 shadow-2xl relative overflow-hidden ${iconConfig.bgGradient}`, children: [
1932
+ /* @__PURE__ */ jsx9("div", { className: "flex-1 relative z-10", children: component }),
1933
+ /* @__PURE__ */ jsx9("div", { className: "relative z-10", children: /* @__PURE__ */ jsx9(CloseButton, { closeToast: handleClose }) })
1934
+ ] });
1935
+ }
1936
+ return /* @__PURE__ */ jsxs7("div", { className: `flex items-start gap-3 min-h-[60px] w-full backdrop-blur-md
1937
+ rounded-xl p-4 shadow-2xl relative overflow-hidden ${iconConfig.bgGradient}`, children: [
1938
+ /* @__PURE__ */ jsx9(
1939
+ "div",
1940
+ {
1941
+ className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-xl",
1942
+ style: {
1943
+ background: `linear-gradient(135deg, ${iconConfig.gradientColor}30 0%, ${iconConfig.gradientColor}20 15%, #14181df2 30%)`
1944
+ }
1945
+ }
1946
+ ),
1947
+ /* @__PURE__ */ jsx9(
1948
+ "div",
1949
+ {
1950
+ className: "absolute left-0 top-0 w-full h-full pointer-events-none rounded-xl",
1951
+ style: {
1952
+ border: "2px solid transparent",
1953
+ backgroundImage: `linear-gradient(135deg, ${iconConfig.borderGradientColor}60 0%, ${iconConfig.borderGradientColor}40 5%, transparent 22%)`,
1954
+ backgroundOrigin: "border-box",
1955
+ backgroundClip: "border-box",
1956
+ WebkitMask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
1957
+ WebkitMaskComposite: "xor",
1958
+ mask: "linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0)",
1959
+ maskComposite: "exclude"
1960
+ }
1961
+ }
1962
+ ),
1963
+ /* @__PURE__ */ jsx9("div", { className: "flex-shrink-0 mt-0.5 relative z-10 ", children: /* @__PURE__ */ jsx9("div", { className: "w-7 h-7 bg-white/10 backdrop-blur-sm rounded-full flex items-center justify-center", children: /* @__PURE__ */ jsx9(
1964
+ Icon4,
1965
+ {
1966
+ icon: iconConfig.icon,
1967
+ width: 16,
1968
+ height: 16,
1969
+ className: iconConfig.color
1970
+ }
1971
+ ) }) }),
1972
+ /* @__PURE__ */ jsxs7("div", { className: "flex flex-col gap-1 flex-1 relative z-10", children: [
1973
+ title && /* @__PURE__ */ jsx9("div", { className: "text-[16px] font-semibold leading-tight text-white/95 drop-shadow-sm", children: title }),
1974
+ message && /* @__PURE__ */ jsx9("div", { className: "text-[13px] font-normal leading-relaxed text-white/75 drop-shadow-sm", children: message })
1975
+ ] }),
1976
+ /* @__PURE__ */ jsx9("div", { className: "relative z-10", children: /* @__PURE__ */ jsx9(CloseButton, { closeToast: handleClose }) })
1977
+ ] });
1978
+ };
1979
+ var defaultToastOptions = {
1980
+ position: "bottom-right",
1981
+ autoClose: 3e3,
1982
+ hideProgressBar: true,
1983
+ closeOnClick: false,
1984
+ pauseOnHover: true,
1985
+ draggable: true,
1986
+ pauseOnFocusLoss: false,
1987
+ theme: "dark",
1988
+ transition: Bounce
1989
+ };
1990
+ var createToast = (type) => {
1991
+ return (params) => {
1992
+ const { title, message, component, options } = params;
1993
+ toast(
1994
+ ({ closeToast }) => /* @__PURE__ */ jsx9(
1995
+ ToastContent,
1996
+ {
1997
+ type,
1998
+ title,
1999
+ message: message || "",
2000
+ component,
2001
+ closeToast
2002
+ }
2003
+ ),
2004
+ {
2005
+ ...defaultToastOptions,
2006
+ ...options,
2007
+ className: "!bg-transparent !p-0 !shadow-none",
2008
+ style: { background: "transparent", padding: 0 }
2009
+ }
2010
+ );
2011
+ };
2012
+ };
2013
+ var ClayxToast = {
2014
+ success: createToast("success"),
2015
+ error: createToast("error"),
2016
+ warning: createToast("warning"),
2017
+ info: createToast("info"),
2018
+ default: createToast("default")
2019
+ };
2020
+
2021
+ // src/hooks/use-mobile.ts
2022
+ import * as React6 from "react";
1792
2023
  var MOBILE_BREAKPOINT = 768;
1793
2024
  function useIsMobile() {
1794
- const [isMobile, setIsMobile] = React4.useState(void 0);
1795
- React4.useEffect(() => {
2025
+ const [isMobile, setIsMobile] = React6.useState(void 0);
2026
+ React6.useEffect(() => {
1796
2027
  const mql = window.matchMedia(`(max-width: ${MOBILE_BREAKPOINT - 1}px)`);
1797
2028
  const onChange = () => {
1798
2029
  setIsMobile(window.innerWidth < MOBILE_BREAKPOINT);
@@ -1805,10 +2036,10 @@ function useIsMobile() {
1805
2036
  }
1806
2037
 
1807
2038
  // src/hooks/use-debounce.ts
1808
- import { useState as useState5, useEffect as useEffect5 } from "react";
2039
+ import { useState as useState7, useEffect as useEffect6 } from "react";
1809
2040
  function useDebounce(value, delay) {
1810
- const [debouncedValue, setDebouncedValue] = useState5(value);
1811
- useEffect5(() => {
2041
+ const [debouncedValue, setDebouncedValue] = useState7(value);
2042
+ useEffect6(() => {
1812
2043
  const handler = setTimeout(() => {
1813
2044
  setDebouncedValue(value);
1814
2045
  }, delay);
@@ -1819,214 +2050,335 @@ function useDebounce(value, delay) {
1819
2050
  return debouncedValue;
1820
2051
  }
1821
2052
 
1822
- // src/utils/earlyErrorHandler.ts
1823
- function injectEarlyErrorHandler() {
1824
- if (typeof window === "undefined" || typeof document === "undefined") return;
1825
- const code = `
1826
- (function () {
1827
- const isIframe = window.self !== window.top;
1828
- console.log("isIframe", isIframe);
2053
+ // src/utils/errorHandler.ts
2054
+ var ERROR_HANDLER_SCRIPT = `(function () {
2055
+ // \u68C0\u67E5\u662F\u5426\u5728 iframe \u4E2D\u8FD0\u884C
2056
+ const isIframe = window.self !== window.top;
2057
+ console.log("isIframe", isIframe);
1829
2058
 
1830
- console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u521D\u59CB\u5316");
2059
+ console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u521D\u59CB\u5316");
1831
2060
 
1832
- window.__SEND_ERROR_TO_PARENT__ = function (error, details) {
1833
- try {
1834
- const errorPayload = {
1835
- message: error instanceof Error ? error.message : String(error),
1836
- stack: error instanceof Error ? error.stack : undefined,
1837
- filename: details?.file || details?.filename,
1838
- lineno: details?.line,
1839
- colno: details?.column,
1840
- timestamp: Date.now(),
1841
- type: details?.type || "compile-error",
1842
- details: details,
1843
- };
2061
+ // \u76F4\u63A5\u53D1\u9001\u9519\u8BEF\u5230\u7236\u7A97\u53E3\u7684\u51FD\u6570
2062
+ window.__SEND_ERROR_TO_PARENT__ = function (error, details) {
2063
+ try {
2064
+ const errorPayload = {
2065
+ message: error instanceof Error ? error.message : String(error),
2066
+ stack: error instanceof Error ? error.stack : undefined,
2067
+ filename: details?.file || details?.filename,
2068
+ lineno: details?.line,
2069
+ colno: details?.column,
2070
+ timestamp: Date.now(),
2071
+ type: details?.type || "compile-error",
2072
+ details: details,
2073
+ };
1844
2074
 
1845
- window.parent.postMessage({ type: "ERROR_EVENT", payload: errorPayload }, "*");
1846
- console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u9519\u8BEF\u5DF2\u53D1\u9001\u5230\u7236\u7A97\u53E3:", errorPayload);
1847
- } catch (e) {
1848
- console.error("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u53D1\u9001\u9519\u8BEF\u5230\u7236\u7A97\u53E3\u5931\u8D25:", e);
1849
- }
1850
- };
2075
+ window.parent.postMessage(
2076
+ {
2077
+ type: "ERROR_EVENT",
2078
+ payload: errorPayload,
2079
+ },
2080
+ "*"
2081
+ );
1851
2082
 
1852
- function setupViteOverlayObserver() {
1853
- if (!window.MutationObserver) return;
2083
+ console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u9519\u8BEF\u5DF2\u53D1\u9001\u5230\u7236\u7A97\u53E3:", errorPayload);
2084
+ } catch (e) {
2085
+ console.error("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u53D1\u9001\u9519\u8BEF\u5230\u7236\u7A97\u53E3\u5931\u8D25:", e);
2086
+ }
2087
+ };
1854
2088
 
1855
- console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u8BBE\u7F6E Vite \u9519\u8BEF overlay \u76D1\u542C\u5668");
2089
+ // \u8BBE\u7F6E MutationObserver \u76D1\u542C vite-error-overlay
2090
+ function setupViteOverlayObserver() {
2091
+ if (!window.MutationObserver) return;
1856
2092
 
1857
- function processViteErrorOverlay(overlay) {
1858
- try {
1859
- if (overlay.hasAttribute("data-error-sent")) return;
1860
- const shadowRoot = overlay.shadowRoot;
1861
- if (!shadowRoot) return;
2093
+ console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u8BBE\u7F6E Vite \u9519\u8BEF overlay \u76D1\u542C\u5668");
2094
+
2095
+ function processViteErrorOverlay(overlay) {
2096
+ try {
2097
+ if (overlay.hasAttribute("data-error-sent")) return;
2098
+
2099
+ const shadowRoot = overlay.shadowRoot;
2100
+ if (!shadowRoot) {
2101
+ console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] vite-error-overlay \u6CA1\u6709 Shadow DOM");
2102
+ return;
2103
+ }
1862
2104
 
1863
- const messageElement = shadowRoot.querySelector("pre.message");
1864
- const fileElement = shadowRoot.querySelector("pre.file");
1865
- const frameElements = shadowRoot.querySelectorAll("pre.frame");
1866
- const stackElement = shadowRoot.querySelector("pre.stack");
2105
+ const messageElement = shadowRoot.querySelector("pre.message");
2106
+ const fileElement = shadowRoot.querySelector("pre.file");
2107
+ const frameElements = shadowRoot.querySelectorAll("pre.frame");
2108
+ const stackElement = shadowRoot.querySelector("pre.stack");
1867
2109
 
1868
- const message = messageElement ? messageElement.textContent : "";
1869
- const file = fileElement ? fileElement.textContent : "";
1870
- const frames = Array.from(frameElements).map((el) => el.textContent).join("
2110
+ const message = messageElement ? messageElement.textContent : "";
2111
+ const file = fileElement ? fileElement.textContent : "";
2112
+ const frames = Array.from(frameElements)
2113
+ .map((el) => el.textContent)
2114
+ .join("
1871
2115
  ");
1872
- const stack = stackElement ? stackElement.textContent : "";
2116
+ const stack = stackElement ? stackElement.textContent : "";
1873
2117
 
1874
- let line, column;
1875
- const fileStr = file || "";
1876
- const lineColMatch = fileStr.match(/(?:line|at|:)(?:.*?)(?::| )(d+)(?::| )(d+)/i);
1877
- if (lineColMatch) {
1878
- line = parseInt(lineColMatch[1], 10);
1879
- column = parseInt(lineColMatch[2], 10);
1880
- }
2118
+ let line, column;
2119
+ const fileStr = file || "";
2120
+ const lineColMatch = fileStr.match(/(?:line|at|:)(?:.*?)(?::| )(d+)(?::| )(d+)/i);
2121
+ if (lineColMatch) {
2122
+ line = parseInt(lineColMatch[1], 10);
2123
+ column = parseInt(lineColMatch[2], 10);
2124
+ }
1881
2125
 
1882
- const messageStr = message || "";
1883
- const isReactError =
1884
- messageStr.includes("React") ||
1885
- messageStr.includes("JSX") ||
1886
- messageStr.includes("Unexpected token") ||
1887
- messageStr.includes("vite:react-babel");
2126
+ const messageStr = message || "";
2127
+ const isReactError =
2128
+ messageStr.includes("React") ||
2129
+ messageStr.includes("JSX") ||
2130
+ messageStr.includes("Unexpected token") ||
2131
+ messageStr.includes("vite:react-babel");
1888
2132
 
1889
- const viteError = new Error(messageStr);
2133
+ const viteError = new Error(messageStr);
1890
2134
 
1891
- window.__SEND_ERROR_TO_PARENT__(viteError, {
1892
- file,
1893
- line,
1894
- column,
1895
- frames,
1896
- stack,
1897
- isReactError,
1898
- type: isReactError ? "react-syntax" : "vite-error-overlay",
1899
- });
2135
+ window.__SEND_ERROR_TO_PARENT__(viteError, {
2136
+ file,
2137
+ line,
2138
+ column,
2139
+ frames,
2140
+ stack,
2141
+ isReactError,
2142
+ type: isReactError ? "react-syntax" : "vite-error-overlay",
2143
+ });
1900
2144
 
1901
- overlay.setAttribute("data-error-sent", "true");
1902
- } catch (e) {
1903
- console.error("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u5904\u7406 vite-error-overlay \u5931\u8D25:", e);
1904
- }
2145
+ overlay.setAttribute("data-error-sent", "true");
2146
+ } catch (e) {
2147
+ console.error("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u5904\u7406 vite-error-overlay \u5931\u8D25:", e);
1905
2148
  }
2149
+ }
1906
2150
 
1907
- function checkExistingOverlays() {
1908
- const viteErrorOverlays = document.querySelectorAll("vite-error-overlay");
1909
- if (viteErrorOverlays.length > 0) {
1910
- viteErrorOverlays.forEach((overlay) => {
1911
- if (!overlay.hasAttribute("data-error-sent")) {
1912
- processViteErrorOverlay(overlay);
1913
- }
1914
- });
1915
- }
2151
+ function checkExistingOverlays() {
2152
+ const viteErrorOverlays = document.querySelectorAll("vite-error-overlay");
2153
+ if (viteErrorOverlays.length > 0) {
2154
+ viteErrorOverlays.forEach((overlay) => {
2155
+ if (!overlay.hasAttribute("data-error-sent")) {
2156
+ processViteErrorOverlay(overlay);
2157
+ }
2158
+ });
1916
2159
  }
2160
+ }
1917
2161
 
1918
- const observer = new MutationObserver((mutations) => {
1919
- for (const mutation of mutations) {
1920
- if (mutation.addedNodes.length > 0) {
1921
- for (const node of Array.from(mutation.addedNodes)) {
1922
- if (node.nodeType === Node.ELEMENT_NODE) {
1923
- const element = node;
1924
- if (element.tagName === "VITE-ERROR-OVERLAY" && !element.hasAttribute("data-error-sent")) {
1925
- setTimeout(() => processViteErrorOverlay(element), 100);
1926
- }
1927
- const viteErrorOverlays = element.querySelectorAll("vite-error-overlay");
1928
- for (const viteErrorOverlay of Array.from(viteErrorOverlays)) {
1929
- if (!viteErrorOverlay.hasAttribute("data-error-sent")) {
1930
- setTimeout(() => processViteErrorOverlay(viteErrorOverlay), 100);
1931
- }
2162
+ const observer = new MutationObserver((mutations) => {
2163
+ for (const mutation of mutations) {
2164
+ if (mutation.addedNodes.length > 0) {
2165
+ for (const node of Array.from(mutation.addedNodes)) {
2166
+ if (node.nodeType === Node.ELEMENT_NODE) {
2167
+ const element = node;
2168
+
2169
+ if (
2170
+ element.tagName === "VITE-ERROR-OVERLAY" &&
2171
+ !element.hasAttribute("data-error-sent")
2172
+ ) {
2173
+ setTimeout(() => processViteErrorOverlay(element), 100);
2174
+ }
2175
+
2176
+ const viteErrorOverlays = element.querySelectorAll("vite-error-overlay");
2177
+ for (const viteErrorOverlay of Array.from(viteErrorOverlays)) {
2178
+ if (!viteErrorOverlay.hasAttribute("data-error-sent")) {
2179
+ setTimeout(() => processViteErrorOverlay(viteErrorOverlay), 100);
1932
2180
  }
1933
2181
  }
1934
2182
  }
1935
2183
  }
1936
2184
  }
1937
- });
2185
+ }
2186
+ });
1938
2187
 
1939
- observer.observe(document.documentElement, { childList: true, subtree: true, attributes: true, characterData: true });
1940
- setTimeout(checkExistingOverlays, 500);
1941
- setInterval(checkExistingOverlays, 2000);
1942
- }
2188
+ observer.observe(document.documentElement, {
2189
+ childList: true,
2190
+ subtree: true,
2191
+ attributes: true,
2192
+ characterData: true,
2193
+ });
1943
2194
 
1944
- window.addEventListener(
1945
- "error",
1946
- function (event) {
1947
- const target = event && (event.target || event.srcElement);
1948
- const tagName = target && target.tagName;
1949
- if (tagName) {
1950
- const url = (target && (target.src || target.href || target.currentSrc)) || (target && target.getAttribute && (target.getAttribute('src') || target.getAttribute('href')));
1951
- const preview = target && target.outerHTML ? String(target.outerHTML).slice(0, 300) : undefined;
1952
- const resourceError = new Error('Resource load error: ' + tagName + ' ' + (url || 'unknown'));
1953
- window.__SEND_ERROR_TO_PARENT__(resourceError, { filename: url, tagName: tagName, element: preview, type: "resource" });
1954
- return;
1955
- }
2195
+ setTimeout(checkExistingOverlays, 500);
2196
+ setInterval(checkExistingOverlays, 2000);
2197
+ }
1956
2198
 
1957
- var stack = (event && event.error && event.error.stack) || "";
1958
- var message = typeof event.message === "string" ? event.message : "";
1959
- if ((stack && stack.indexOf('error-handler') !== -1) || !message) return;
2199
+ window.addEventListener(
2200
+ "error",
2201
+ function (event) {
2202
+ const target = event && (event.target || event.srcElement);
2203
+ const tagName = target && target.tagName;
2204
+ if (tagName) {
2205
+ const url = (target && (target.src || target.href || target.currentSrc)) ||
2206
+ (target && target.getAttribute && (target.getAttribute('src') || target.getAttribute('href')));
2207
+ const preview = target && target.outerHTML ? String(target.outerHTML).slice(0, 300) : undefined;
2208
+ const resourceError = new Error('Resource load error: ' + tagName + ' ' + (url || 'unknown'));
2209
+ window.__SEND_ERROR_TO_PARENT__(resourceError, {
2210
+ filename: url,
2211
+ tagName: tagName,
2212
+ element: preview,
2213
+ type: "resource"
2214
+ });
2215
+ return;
2216
+ }
1960
2217
 
1961
- window.__SEND_ERROR_TO_PARENT__(event.error || new Error(event.message), { filename: event.filename, line: event.lineno, column: event.colno, type: "runtime" });
1962
- },
1963
- true
2218
+ var stack = (event && event.error && event.error.stack) || "";
2219
+ var message = typeof event.message === "string" ? event.message : "";
2220
+ if ((stack && stack.indexOf('error-handler') !== -1) || !message) return;
2221
+
2222
+ window.__SEND_ERROR_TO_PARENT__(event.error || new Error(event.message), {
2223
+ filename: event.filename,
2224
+ line: event.lineno,
2225
+ column: event.colno,
2226
+ type: "runtime",
2227
+ });
2228
+ },
2229
+ true
2230
+ );
2231
+
2232
+ window.addEventListener("unhandledrejection", function (event) {
2233
+ const reason = event.reason;
2234
+ window.__SEND_ERROR_TO_PARENT__(
2235
+ reason instanceof Error ? reason : new Error(String(reason)),
2236
+ { type: "promise" }
1964
2237
  );
2238
+ });
1965
2239
 
1966
- window.addEventListener("unhandledrejection", function (event) {
1967
- const reason = event.reason;
1968
- window.__SEND_ERROR_TO_PARENT__(reason instanceof Error ? reason : new Error(String(reason)), { type: "promise" });
1969
- });
2240
+ setupViteOverlayObserver();
1970
2241
 
1971
- setupViteOverlayObserver();
2242
+ if (!window.__FETCH_INTERCEPTED__) {
2243
+ window.__FETCH_INTERCEPTED__ = true;
2244
+ const originalFetch = window.fetch;
2245
+
2246
+ function handleFetchError(error, url, response = null) {
2247
+ const errorDetails = {
2248
+ type: "network",
2249
+ method: "fetch",
2250
+ url: url
2251
+ };
2252
+
2253
+ if (response && !response.ok) {
2254
+ errorDetails.status = response.status;
2255
+ errorDetails.statusText = response.statusText;
2256
+ errorDetails.networkError = false;
2257
+ } else {
2258
+ errorDetails.networkError = true;
2259
+ }
2260
+ window.__SEND_ERROR_TO_PARENT__(error, errorDetails);
2261
+ }
2262
+
2263
+ window.fetch = function(...args) {
2264
+ const url = args[0] instanceof Request ? args[0].url : args[0];
2265
+
2266
+ return originalFetch.apply(this, args)
2267
+ .then(response => {
2268
+ if (!response.ok) {
2269
+ const networkError = new Error(\`HTTP \${response.status}: \${response.statusText}\`);
2270
+ handleFetchError(networkError, url, response);
2271
+ }
2272
+ return response;
2273
+ })
2274
+ .catch(error => {
2275
+ handleFetchError(error, url);
2276
+ throw error;
2277
+ });
2278
+ };
2279
+ }
1972
2280
 
1973
- if (!window.__CONSOLE_ERROR_INTERCEPTED__) {
1974
- window.__CONSOLE_ERROR_INTERCEPTED__ = true;
1975
- const originalConsoleError = console.error;
1976
- console.error = function () {
1977
- try {
1978
- var args = Array.prototype.slice.call(arguments);
1979
- var first = args[0];
1980
- var firstStr = typeof first === "string" ? first : "";
1981
- var isReact = firstStr.indexOf("React") !== -1;
1982
- var isVite = firstStr.indexOf("[vite]") !== -1 || firstStr.indexOf("Failed to reload") !== -1;
1983
- if (isReact || isVite) {
1984
- var joined = args.map(function (a) {
2281
+ if (!window.__XHR_INTERCEPTED__) {
2282
+ window.__XHR_INTERCEPTED__ = true;
2283
+ const originalXHROpen = XMLHttpRequest.prototype.open;
2284
+ const originalXHRSend = XMLHttpRequest.prototype.send;
2285
+
2286
+ function handleXHRError(error, xhr, isNetworkError = false) {
2287
+ const errorDetails = {
2288
+ type: "network",
2289
+ method: "xhr",
2290
+ url: xhr.__intercepted_url__
2291
+ };
2292
+
2293
+ if (!isNetworkError && xhr.status >= 400) {
2294
+ errorDetails.status = xhr.status;
2295
+ errorDetails.statusText = xhr.statusText;
2296
+ errorDetails.networkError = false;
2297
+ } else {
2298
+ errorDetails.networkError = true;
2299
+ }
2300
+
2301
+ window.__SEND_ERROR_TO_PARENT__(error, errorDetails);
2302
+ }
2303
+
2304
+ XMLHttpRequest.prototype.open = function(method, url, ...args) {
2305
+ this.__intercepted_method__ = method;
2306
+ this.__intercepted_url__ = url;
2307
+ return originalXHROpen.apply(this, [method, url, ...args]);
2308
+ };
2309
+
2310
+ XMLHttpRequest.prototype.send = function(...args) {
2311
+ const xhr = this;
2312
+
2313
+ const originalOnReadyStateChange = xhr.onreadystatechange;
2314
+ xhr.onreadystatechange = function() {
2315
+ if (xhr.readyState === 4) {
2316
+ if (xhr.status >= 400) {
2317
+ const networkError = new Error(\`HTTP \${xhr.status}: \${xhr.statusText}\`);
2318
+ handleXHRError(networkError, xhr, false);
2319
+ }
2320
+ }
2321
+
2322
+ if (originalOnReadyStateChange) {
2323
+ return originalOnReadyStateChange.apply(this, arguments);
2324
+ }
2325
+ };
2326
+
2327
+ const originalOnError = xhr.onerror;
2328
+ xhr.onerror = function() {
2329
+ const networkError = new Error(\`Network error for \${xhr.__intercepted_method__} \${xhr.__intercepted_url__}\`);
2330
+ handleXHRError(networkError, xhr, true);
2331
+
2332
+ if (originalOnError) {
2333
+ return originalOnError.apply(this, arguments);
2334
+ }
2335
+ };
2336
+
2337
+ return originalXHRSend.apply(this, args);
2338
+ };
2339
+ }
2340
+
2341
+ if (!window.__CONSOLE_ERROR_INTERCEPTED__) {
2342
+ window.__CONSOLE_ERROR_INTERCEPTED__ = true;
2343
+ const originalConsoleError = console.error;
2344
+ console.error = function () {
2345
+ try {
2346
+ var args = Array.prototype.slice.call(arguments);
2347
+ var first = args[0];
2348
+ var firstStr = typeof first === "string" ? first : "";
2349
+ var isReact = firstStr.indexOf("React") !== -1;
2350
+ var isVite = firstStr.indexOf("[vite]") !== -1 || firstStr.indexOf("Failed to reload") !== -1;
2351
+ if (isReact || isVite) {
2352
+ var joined = args
2353
+ .map(function (a) {
1985
2354
  if (a instanceof Error) return a.message;
1986
2355
  if (typeof a === "string") return a;
1987
2356
  if (a && typeof a.message === "string") return a.message;
1988
- try { return JSON.stringify(a); } catch (e) { return String(a); }
1989
- }).join(" ");
1990
- var errorForReport = new Error(joined);
1991
- window.__SEND_ERROR_TO_PARENT__(errorForReport, { type: "runtime", viteErrorType: "console" });
1992
- }
1993
- } catch (e) { void e }
1994
- return originalConsoleError.apply(console, arguments);
1995
- };
1996
- }
2357
+ try { return JSON.stringify(a); } catch (_) { return String(a); }
2358
+ })
2359
+ .join(" ");
2360
+ var errorForReport = new Error(joined);
2361
+ window.__SEND_ERROR_TO_PARENT__(errorForReport, { type: "runtime", viteErrorType: "console" });
2362
+ }
2363
+ } catch (_) {}
2364
+ return originalConsoleError.apply(console, arguments);
2365
+ };
2366
+ }
1997
2367
 
1998
- console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u521D\u59CB\u5316\u5B8C\u6210");
1999
- })();
2000
- `;
2368
+ console.log("[\u65E9\u671F\u9519\u8BEF\u5904\u7406] \u521D\u59CB\u5316\u5B8C\u6210");
2369
+ })();`;
2370
+ function injectEarlyErrorHandler() {
2371
+ if (typeof document === "undefined") return;
2001
2372
  try {
2002
- const parent = document.head || document.documentElement;
2003
- try {
2004
- const external = document.createElement("script");
2005
- external.type = "text/javascript";
2006
- external.src = "/error-handler.js";
2007
- external.async = false;
2008
- parent.prepend(external);
2009
- return;
2010
- } catch (e) {
2011
- void e;
2012
- }
2373
+ if (window.__EARLY_ERROR_HANDLER_INJECTED__) return;
2013
2374
  const script = document.createElement("script");
2014
2375
  script.type = "text/javascript";
2015
- try {
2016
- if ("textContent" in script) {
2017
- script.textContent = code;
2018
- } else {
2019
- script.appendChild(document.createTextNode(code));
2020
- }
2021
- } catch (e) {
2022
- try {
2023
- script.appendChild(document.createTextNode(code));
2024
- } catch {
2025
- }
2026
- }
2027
- parent.prepend(script);
2376
+ script.text = ERROR_HANDLER_SCRIPT;
2377
+ const head = document.head || document.getElementsByTagName("head")[0];
2378
+ if (head && head.firstChild) head.insertBefore(script, head.firstChild);
2379
+ else if (head) head.appendChild(script);
2380
+ window.__EARLY_ERROR_HANDLER_INJECTED__ = true;
2028
2381
  } catch (e) {
2029
- void e;
2030
2382
  }
2031
2383
  }
2032
2384
 
@@ -2037,12 +2389,17 @@ export {
2037
2389
  AUTH_ROOT,
2038
2390
  AUTH_TOKEN_KEY,
2039
2391
  AuthProvider,
2392
+ ClayxToast,
2040
2393
  DefaultErrorFallback,
2041
2394
  ErrorBoundary,
2042
2395
  FloatingButton,
2396
+ GlobalToastContainer,
2397
+ HowoneProvider,
2043
2398
  Loading,
2044
2399
  LoadingSpinner,
2045
2400
  LoginForm,
2401
+ ThemeProvider,
2402
+ ThemeToggle,
2046
2403
  aiRequest,
2047
2404
  aiWorkflow,
2048
2405
  canAccessArtifact,
@@ -2071,6 +2428,7 @@ export {
2071
2428
  useAuthContext,
2072
2429
  useDebounce,
2073
2430
  useIsMobile,
2431
+ useTheme,
2074
2432
  workflowRequest
2075
2433
  };
2076
2434
  //# sourceMappingURL=index.mjs.map