research-agent-ui 0.1.93 → 0.1.95

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.
Files changed (59) hide show
  1. package/README.md +0 -3
  2. package/dist/api/handlers/autocomplete.d.ts +1 -0
  3. package/dist/api/handlers/mcpservers.d.ts +7 -0
  4. package/dist/api/handlers/messages.d.ts +7 -0
  5. package/dist/api/handlers/rewrite.d.ts +3 -0
  6. package/dist/api/handlers/transcript.d.ts +7 -0
  7. package/dist/api/handlers/validate-openrouter.d.ts +3 -0
  8. package/dist/api/handlers/voice.d.ts +7 -0
  9. package/dist/api/index.d.ts +3 -0
  10. package/dist/api/types.d.ts +1 -1
  11. package/dist/api.cjs +3 -3
  12. package/dist/api.mjs +5 -4
  13. package/dist/cloudflare/worker.d.ts +1 -0
  14. package/dist/components/ArticleReader/ArticleAIResponse.d.ts +1 -1
  15. package/dist/components/ArticleReader/ArticleActionButtons.d.ts +1 -2
  16. package/dist/components/ArticleReader/ArticleFollowupQuestions.d.ts +1 -1
  17. package/dist/components/ArticleReader/ArticlePanelHeader.d.ts +1 -1
  18. package/dist/components/ArticleReader/ArticlePromptInput.d.ts +1 -1
  19. package/dist/components/ArticleReader/index.d.ts +1 -1
  20. package/dist/components/ChatConversation/DownloadsDialog.d.ts +6 -0
  21. package/dist/components/ChatConversation/background-art.d.ts +3 -0
  22. package/dist/components/ChatHistoryDropdown/HistorySubmenu.d.ts +7 -0
  23. package/dist/components/ChatHistoryDropdown/index.d.ts +1 -1
  24. package/dist/components/ChatHistoryDropdown/useRecentChats.d.ts +13 -0
  25. package/dist/components/FileUpload/FilePreviewCard.d.ts +4 -2
  26. package/dist/components/Footer.d.ts +2 -0
  27. package/dist/components/MessageComposer/ActionBar.d.ts +4 -2
  28. package/dist/components/MessageComposer/MessageInputIconSet.d.ts +4 -2
  29. package/dist/components/MessageComposer/PastedContentCard.d.ts +4 -2
  30. package/dist/config.d.ts +12 -0
  31. package/dist/hooks/useChat/ChatContext.d.ts +14 -0
  32. package/dist/hooks/voice/useSpeechToTranscript.d.ts +17 -2
  33. package/dist/hooks/voice/useVoiceAutoStart.d.ts +6 -0
  34. package/dist/icons/IconSearchAcademic.d.ts +3 -0
  35. package/dist/icons/IconSearchFiles.d.ts +3 -0
  36. package/dist/icons/IconSearchImages.d.ts +3 -0
  37. package/dist/icons/IconSearchNews.d.ts +3 -0
  38. package/dist/icons/IconSearchTech.d.ts +3 -0
  39. package/dist/icons/IconSearchVideos.d.ts +3 -0
  40. package/dist/icons/IconSearchWeb.d.ts +3 -0
  41. package/dist/index.cjs +15 -15
  42. package/dist/index.d.ts +1 -0
  43. package/dist/index.mjs +1237 -939
  44. package/dist/lib/composer.d.ts +1 -1
  45. package/dist/lib/file-sources.d.ts +7 -0
  46. package/dist/lib/guest.d.ts +6 -0
  47. package/dist/lib/relative-time.d.ts +1 -1
  48. package/dist/lib/url-autolink.d.ts +1 -2
  49. package/dist/lib/utils.d.ts +3 -0
  50. package/dist/lib/voiceAutoStart.d.ts +22 -0
  51. package/dist/{rolldown-runtime-CMqjfN_6.cjs → rolldown-runtime-BocRIvOZ.cjs} +1 -1
  52. package/dist/settings/index.d.ts +57 -0
  53. package/dist/stories/mocks.d.ts +1 -1
  54. package/dist/types/fileSource.d.ts +3 -0
  55. package/dist/types/research.d.ts +1 -1
  56. package/package.json +29 -11
  57. package/src/settings/index.ts +96 -0
  58. package/src/settings/search.json +161 -0
  59. package/src/settings/sections.json +65 -0
package/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ import { clsx as _ } from "clsx";
8
8
  import { twMerge as v } from "tailwind-merge";
9
9
  import y from "markdown-to-jsx";
10
10
  import * as b from "lucide-react";
11
- import { AlertCircle as x, Archive as S, ArrowLeftRight as C, ArrowUp as w, BookMarked as T, Bot as E, BrainCircuit as D, CalendarDays as O, Check as k, CheckIcon as A, ChevronDown as j, ChevronRight as ee, ChevronRightIcon as M, ChevronUp as N, Clipboard as P, ClipboardList as F, Clock as I, Cloud as L, CloudIcon as R, Copy as z, Cpu as te, Download as ne, ExternalLink as B, EyeOff as re, File as ie, FileDown as ae, FileSpreadsheet as oe, FileText as se, FileType as ce, FolderOpen as le, Highlighter as ue, History as de, Image as fe, Link as pe, Link2 as me, Loader2 as V, Lock as he, MessageCircleQuestion as ge, Mic as _e, Paperclip as ve, Pencil as ye, Pin as be, Plus as xe, Search as Se, Settings as Ce, Settings2 as we, Share2 as Te, SlidersHorizontal as Ee, Square as De, SquarePen as Oe, Star as ke, StopCircle as Ae, Sun as je, Trash as Me, Trash2 as Ne, Upload as Pe, Video as Fe, Volume2 as Ie, X as Le, XIcon as Re, ZoomIn as ze, ZoomOut as Be } from "lucide-react";
11
+ import { AlertCircle as x, Archive as S, ArrowLeftRight as C, ArrowUp as w, BookMarked as T, Bot as E, BrainCircuit as D, CalendarDays as O, Check as k, CheckIcon as A, ChevronDown as j, ChevronRight as M, ChevronRightIcon as N, ChevronUp as ee, Clipboard as P, ClipboardList as F, Clock as I, Cloud as te, CloudIcon as L, Copy as R, Cpu as ne, Download as re, ExternalLink as ie, EyeOff as ae, File as oe, FileDown as se, FileSpreadsheet as z, FileText as ce, FileType as B, FolderOpen as le, Highlighter as ue, History as de, Image as fe, Link as pe, Link2 as me, Loader2 as V, Lock as he, MessageCircleQuestion as ge, Mic as _e, Paperclip as ve, Pencil as ye, Pin as be, Plus as xe, Search as Se, Settings as Ce, Settings2 as we, Share2 as Te, SlidersHorizontal as Ee, Square as De, SquarePen as Oe, Star as ke, StopCircle as Ae, Sun as je, Trash as Me, Trash2 as Ne, Upload as Pe, Video as Fe, Volume2 as Ie, X as Le, XIcon as Re, ZoomIn as ze, ZoomOut as Be } from "lucide-react";
12
12
  import { addFavorite as Ve, agentChat as He, agentSearch as Ue, articleFollowups as We, articleQa as Ge, autocomplete as Ke, createDocument as qe, deleteAllChats as Je, deleteChatById as Ye, deleteUploadedFile as Xe, getArticle as Ze, getChatById as Qe, getGoogleDriveFile as $e, getGoogleToken as et, googleDocsAuth as tt, googleDocsAuthStatus as nt, listChats as rt, listFavorites as it, listProviders as at, removeFavorite as ot, saveMessage as st, searchChats as ct, shareChat as lt, updateArticle as ut, uploadFiles as dt } from "qwksearch-api-client";
13
13
  import { convertURLSafeHTMLToHTML as ft } from "extract-webpage/html-to-content/html-utils";
14
14
  import { AnimatePresence as pt, animate as mt, motion as ht } from "motion/react";
@@ -24,24 +24,29 @@ import xt from "turndown";
24
24
  import { Slot as St } from "@radix-ui/react-slot";
25
25
  import { cva as Ct } from "class-variance-authority";
26
26
  import wt from "quantum-sphere-loading-icon/react";
27
- import Tt from "dompurify";
28
- import Et from "next/link";
29
- import { Streamdown as Dt } from "streamdown";
27
+ import { LiveTranscriber as Tt } from "use-voice-control/client";
28
+ import { SpokenPhraseOverlay as Et } from "use-voice-control/react";
29
+ import Dt from "dompurify";
30
+ import Ot from "next/link";
31
+ import { Streamdown as kt } from "streamdown";
32
+ import { DownloadAppButton as At } from "react-native-app-buttons";
33
+ import { WeatherForecast as jt } from "use-weather-forecast";
34
+ import { TrendingNews as Mt } from "trending-news-api";
30
35
  //#region src/lib/utils.ts
31
36
  function q(...e) {
32
37
  return v(_(e));
33
38
  }
34
- var Ot = (e) => {
39
+ var Nt = (e) => {
35
40
  let t = new Date(e);
36
41
  return Number.isNaN(t.getTime()) ? "" : t.toLocaleTimeString([], {
37
42
  hour: "numeric",
38
43
  minute: "2-digit"
39
44
  });
40
- }, kt = (e, t) => {
45
+ }, Pt = (e, t) => {
41
46
  e = new Date(e), t = new Date(t);
42
47
  let n = Math.floor(Math.abs(t.getTime() - e.getTime()) / 1e3);
43
48
  return n < 60 ? `${n} second${n === 1 ? "" : "s"}` : n < 3600 ? `${Math.floor(n / 60)} minute${Math.floor(n / 60) === 1 ? "" : "s"}` : n < 86400 ? `${Math.floor(n / 3600)} hour${Math.floor(n / 3600) === 1 ? "" : "s"}` : n < 31536e3 ? `${Math.floor(n / 86400)} day${Math.floor(n / 86400) === 1 ? "" : "s"}` : `${Math.floor(n / 31536e3)} year${Math.floor(n / 31536e3) === 1 ? "" : "s"}`;
44
- }, At = s(({ blur: e = 0, inactiveZone: t = .7, proximity: n = 0, spread: r = 20, variant: i = "default", glow: a = !1, className: o, movementDuration: s = 2, borderWidth: l = 1, disabled: d = !0 }) => {
49
+ }, Ft = s(({ blur: e = 0, inactiveZone: t = .7, proximity: n = 0, spread: r = 20, variant: i = "default", glow: a = !1, className: o, movementDuration: s = 2, borderWidth: l = 1, disabled: d = !0 }) => {
45
50
  let p = f(null), m = f({
46
51
  x: 0,
47
52
  y: 0
@@ -61,8 +66,8 @@ var Ot = (e) => {
61
66
  }
62
67
  let f = l > i - n && l < i + o + n && u > a - n && u < a + c + n;
63
68
  if (r.style.setProperty("--active", f ? "1" : "0"), !f) return;
64
- let h = parseFloat(r.style.getPropertyValue("--start")) || 0;
65
- mt(h, h + ((180 * Math.atan2(u - d[1], l - d[0]) / Math.PI + 90 - h + 180) % 360 - 180), {
69
+ let h = parseFloat(r.style.getPropertyValue("--start")) || 0, g = h + ((180 * Math.atan2(u - d[1], l - d[0]) / Math.PI + 90 - h + 180) % 360 - 180);
70
+ mt(h, g, {
66
71
  duration: s,
67
72
  ease: [
68
73
  .16,
@@ -101,16 +106,16 @@ var Ot = (e) => {
101
106
  children: /* @__PURE__ */ U("div", { className: q("glow", "rounded-[inherit]", "after:content-[\"\"] after:rounded-[inherit] after:absolute after:inset-[calc(-1*var(--glowingeffect-border-width))]", "after:[border:var(--glowingeffect-border-width)_solid_transparent]", "after:[background:var(--gradient)] after:[background-attachment:fixed]", "after:opacity-[var(--active)] after:transition-opacity after:duration-300", "after:[mask-clip:padding-box,border-box]", "after:[mask-composite:intersect]", "after:[mask-image:linear-gradient(#0000,#0000),conic-gradient(from_calc((var(--start)-var(--spread))*1deg),#00000000_0deg,#fff,#00000000_calc(var(--spread)*2deg))]") })
102
107
  })] });
103
108
  });
104
- At.displayName = "GlowingEffect";
109
+ Ft.displayName = "GlowingEffect";
105
110
  //#endregion
106
111
  //#region src/components/ArticleReader/ExtractPanelContext.tsx
107
- var jt = a(void 0), Mt = () => {
108
- let e = l(jt);
112
+ var It = a(void 0), Lt = () => {
113
+ let e = l(It);
109
114
  if (!e) throw Error("useExtractPanel must be used within an ExtractPanelProvider");
110
115
  return e;
111
- }, Nt = ({ children: e }) => {
116
+ }, Rt = ({ children: e }) => {
112
117
  let [t, n] = p(!1), [r, i] = p(""), [a, o] = p(""), [s, c] = p(600);
113
- return /* @__PURE__ */ U(jt.Provider, {
118
+ return /* @__PURE__ */ U(It.Provider, {
114
119
  value: {
115
120
  isOpen: t,
116
121
  url: r,
@@ -149,7 +154,7 @@ var jt = a(void 0), Mt = () => {
149
154
  };
150
155
  //#endregion
151
156
  //#region src/icons/IconSearchWeb.tsx
152
- function Pt(e) {
157
+ function zt(e) {
153
158
  return /* @__PURE__ */ W("svg", {
154
159
  xmlns: "http://www.w3.org/2000/svg",
155
160
  xmlnsXlink: "http://www.w3.org/1999/xlink",
@@ -191,7 +196,7 @@ function Pt(e) {
191
196
  }
192
197
  //#endregion
193
198
  //#region src/icons/IconSearchNews.tsx
194
- function Ft(e) {
199
+ function Bt(e) {
195
200
  return /* @__PURE__ */ W("svg", {
196
201
  version: "1.1",
197
202
  xmlns: "http://www.w3.org/2000/svg",
@@ -267,7 +272,7 @@ function Ft(e) {
267
272
  }
268
273
  //#endregion
269
274
  //#region src/icons/IconSearchVideos.tsx
270
- function It(e) {
275
+ function Vt(e) {
271
276
  return /* @__PURE__ */ W("svg", {
272
277
  version: "1.1",
273
278
  xmlns: "http://www.w3.org/2000/svg",
@@ -508,7 +513,7 @@ function It(e) {
508
513
  }
509
514
  //#endregion
510
515
  //#region src/icons/IconSearchImages.tsx
511
- function Lt(e) {
516
+ function Ht(e) {
512
517
  return /* @__PURE__ */ U("svg", {
513
518
  width: "800px",
514
519
  height: "800px",
@@ -573,7 +578,7 @@ function Lt(e) {
573
578
  }
574
579
  //#endregion
575
580
  //#region src/icons/IconSearchAcademic.tsx
576
- function Rt(e) {
581
+ function Ut(e) {
577
582
  return /* @__PURE__ */ W("svg", {
578
583
  width: "800px",
579
584
  height: "800px",
@@ -619,7 +624,7 @@ function Rt(e) {
619
624
  }
620
625
  //#endregion
621
626
  //#region src/icons/IconSearchFiles.tsx
622
- function zt(e) {
627
+ function Wt(e) {
623
628
  return /* @__PURE__ */ W("svg", {
624
629
  height: "800px",
625
630
  width: "800px",
@@ -672,7 +677,7 @@ function zt(e) {
672
677
  }
673
678
  //#endregion
674
679
  //#region src/icons/IconSearchTech.tsx
675
- function Bt(e) {
680
+ function Gt(e) {
676
681
  return /* @__PURE__ */ W("svg", {
677
682
  height: "800px",
678
683
  width: "800px",
@@ -799,64 +804,73 @@ function Bt(e) {
799
804
  }
800
805
  //#endregion
801
806
  //#region src/components/SearchConfig/categories.ts
802
- var Vt = [
807
+ var Kt = [
803
808
  {
804
809
  code: "general",
805
- icon: Pt,
810
+ icon: zt,
806
811
  name: "Web"
807
812
  },
808
813
  {
809
814
  code: "news",
810
- icon: Ft,
815
+ icon: Bt,
811
816
  name: "News"
812
817
  },
813
818
  {
814
819
  code: "videos",
815
- icon: It,
820
+ icon: Vt,
816
821
  name: "Videos"
817
822
  },
818
823
  {
819
824
  code: "images",
820
- icon: Lt,
825
+ icon: Ht,
821
826
  name: "Images"
822
827
  },
823
828
  {
824
829
  code: "science",
825
- icon: Rt,
830
+ icon: Ut,
826
831
  name: "Academic"
827
832
  },
828
833
  {
829
834
  code: "files",
830
- icon: zt,
835
+ icon: Wt,
831
836
  name: "Files"
832
837
  },
833
838
  {
834
839
  code: "it",
835
- icon: Bt,
840
+ icon: Gt,
836
841
  name: "Tech"
837
842
  }
838
- ], Ht = Vt.filter((e) => [
843
+ ], qt = Kt.filter((e) => [
839
844
  "general",
840
845
  "news",
841
846
  "videos",
842
847
  "images",
843
848
  "science",
844
849
  "files"
845
- ].includes(e.code)), Ut = ({ sources: e, query: t }) => {
846
- let [n, r] = p("general"), [i, a] = p(e), [o, s] = p(!1), [l, d] = p(!1), [m, h] = p(1), [g, _] = p(!0), [v, y] = p(!1), b = f(null), x = f(!1), S = f(!1), { openPanel: C, isOpen: w } = Mt(), [T, E] = p({});
850
+ ].includes(e.code)), Jt = ({ sources: e, query: t }) => {
851
+ let [n, r] = p("general"), [i, a] = p(e), [o, s] = p(!1), [l, d] = p(!1), [m, h] = p(1), [g, _] = p(!0), [v, y] = p(!1), [b, x] = p(!1), S = f(null), C = f(!1), w = f(!1), { openPanel: T, isOpen: E } = Lt();
852
+ u(() => {
853
+ let e = () => {
854
+ x(localStorage.getItem("searchResultGlow") === "true");
855
+ };
856
+ return e(), window.addEventListener("client-config-changed", e), window.addEventListener("storage", e), () => {
857
+ window.removeEventListener("client-config-changed", e), window.removeEventListener("storage", e);
858
+ };
859
+ }, []);
860
+ let [D, O] = p({});
847
861
  u(() => {
848
862
  let e = () => {
849
863
  y(window.innerWidth >= 1024);
850
864
  };
851
865
  return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
852
866
  }, []), u(() => {
853
- a(e), r("general"), h(1), _(!0), E({}), D(e);
867
+ a(e), r("general"), h(1), _(!0), O({}), k(e);
854
868
  }, [e]);
855
- let D = c(async (e) => {
869
+ let k = c(async (e) => {
856
870
  let t = e.filter((e) => e.metadata.url && e.metadata.url !== "File" && !e.metadata.iframe_src);
857
871
  for (let e of t) try {
858
872
  let { data: t } = await Ze({ query: { url: e.metadata.url } });
859
- t?.cached && t?.article?.html && E((t) => ({
873
+ t?.cached && t?.article?.html && O((t) => ({
860
874
  ...t,
861
875
  [e.metadata.url]: "loaded"
862
876
  }));
@@ -865,35 +879,35 @@ var Vt = [
865
879
  u(() => {
866
880
  if (typeof window < "u") {
867
881
  let e = new URLSearchParams(window.location.search).get("extract");
868
- e && (C(decodeURIComponent(e), ""), S.current = !1);
882
+ e && (T(decodeURIComponent(e), ""), w.current = !1);
869
883
  }
870
- }, [C]), u(() => {
871
- S.current = !1;
884
+ }, [T]), u(() => {
885
+ w.current = !1;
872
886
  }, [e]), u(() => {
873
- x.current && !w && (S.current = !0), x.current = w;
874
- }, [w]), u(() => {
875
- if (v && i && i.length > 0 && !w && !S.current) {
887
+ C.current && !E && (w.current = !0), C.current = E;
888
+ }, [E]), u(() => {
889
+ if (v && i && i.length > 0 && !E && !w.current) {
876
890
  let e = i[0];
877
- e?.metadata?.url && C(e.metadata.url, "");
891
+ e?.metadata?.url && T(e.metadata.url, "");
878
892
  }
879
893
  }, [i, v]);
880
- let O = async (e, t) => {
881
- e.preventDefault(), S.current = !1, E((e) => ({
894
+ let A = async (e, t) => {
895
+ e.preventDefault(), w.current = !1, O((e) => ({
882
896
  ...e,
883
897
  [t]: "loading"
884
- })), C(t, "");
898
+ })), T(t, "");
885
899
  try {
886
- await Ze({ query: { url: t } }), E((e) => ({
900
+ await Ze({ query: { url: t } }), O((e) => ({
887
901
  ...e,
888
902
  [t]: "loaded"
889
903
  }));
890
904
  } catch {
891
- E((e) => ({
905
+ O((e) => ({
892
906
  ...e,
893
907
  [t]: "loaded"
894
908
  }));
895
909
  }
896
- }, k = c(async () => {
910
+ }, j = c(async () => {
897
911
  if (!t || l || !g) return;
898
912
  d(!0);
899
913
  let e = m + 1, { data: r } = await Ue({ query: {
@@ -930,7 +944,7 @@ var Vt = [
930
944
  m,
931
945
  l,
932
946
  g
933
- ]), A = async (e) => {
947
+ ]), M = async (e) => {
934
948
  if (!(e === n || !t)) {
935
949
  r(e), s(!0), h(1), _(!0);
936
950
  try {
@@ -967,22 +981,22 @@ var Vt = [
967
981
  }
968
982
  };
969
983
  u(() => {
970
- let e = b.current;
984
+ let e = S.current;
971
985
  if (!e) return;
972
986
  let t = () => {
973
987
  let { scrollTop: t, scrollHeight: n, clientHeight: r } = e;
974
- n - t - r < 100 && k();
988
+ n - t - r < 100 && j();
975
989
  };
976
990
  return e.addEventListener("scroll", t), () => e.removeEventListener("scroll", t);
977
- }, [k]);
978
- let j = (e, t) => {
991
+ }, [j]);
992
+ let N = (e, t) => {
979
993
  let r = n === "images", i = n === "videos", a = e.metadata.img_src || e.metadata.thumbnail;
980
994
  if (r && a) return /* @__PURE__ */ U("div", {
981
995
  className: "relative rounded-lg group",
982
996
  children: /* @__PURE__ */ W("a", {
983
997
  className: "relative block overflow-hidden rounded-lg cursor-pointer",
984
998
  href: e.metadata.url,
985
- onClick: (t) => O(t, e.metadata.url),
999
+ onClick: (t) => A(t, e.metadata.url),
986
1000
  children: [/* @__PURE__ */ U("img", {
987
1001
  src: a,
988
1002
  alt: e.metadata.title,
@@ -1002,10 +1016,10 @@ var Vt = [
1002
1016
  }, t);
1003
1017
  if (i && a) return /* @__PURE__ */ W("div", {
1004
1018
  className: "relative rounded-xl",
1005
- children: [/* @__PURE__ */ U(At, {
1019
+ children: [/* @__PURE__ */ U(Ft, {
1006
1020
  spread: 40,
1007
1021
  glow: !0,
1008
- disabled: !1,
1022
+ disabled: !b,
1009
1023
  proximity: 64,
1010
1024
  inactiveZone: .01,
1011
1025
  borderWidth: 2
@@ -1036,26 +1050,26 @@ var Vt = [
1036
1050
  })]
1037
1051
  })]
1038
1052
  }, t);
1039
- let o = T[e.metadata.url];
1053
+ let o = D[e.metadata.url];
1040
1054
  return /* @__PURE__ */ W("div", {
1041
1055
  className: "relative rounded-xl group h-full",
1042
- children: [/* @__PURE__ */ U(At, {
1056
+ children: [/* @__PURE__ */ U(Ft, {
1043
1057
  spread: 40,
1044
1058
  glow: !0,
1045
- disabled: !1,
1059
+ disabled: !b,
1046
1060
  proximity: 64,
1047
1061
  inactiveZone: .01,
1048
1062
  borderWidth: 2
1049
1063
  }), /* @__PURE__ */ W("div", {
1050
1064
  className: "relative bg-card text-card-foreground border border-border rounded-xl p-2.5 flex flex-col font-medium cursor-pointer shadow-sm hover:shadow-md transition-all duration-200 h-full",
1051
- onClick: (t) => O(t, e.metadata.url),
1065
+ onClick: (t) => A(t, e.metadata.url),
1052
1066
  children: [
1053
1067
  o && /* @__PURE__ */ U("div", {
1054
1068
  className: "absolute top-1.5 left-1.5 p-1 rounded-md bg-background/80 backdrop-blur-sm z-[5]",
1055
1069
  children: o === "loading" ? /* @__PURE__ */ U(V, {
1056
1070
  size: 14,
1057
1071
  className: "text-primary animate-spin"
1058
- }) : /* @__PURE__ */ U(se, {
1072
+ }) : /* @__PURE__ */ U(ce, {
1059
1073
  size: 14,
1060
1074
  className: "text-green-500"
1061
1075
  })
@@ -1067,7 +1081,7 @@ var Vt = [
1067
1081
  onClick: (e) => e.stopPropagation(),
1068
1082
  className: "absolute top-1.5 right-1.5 p-1 rounded-md bg-secondary/50 opacity-0 group-hover:opacity-100 transition-opacity hover:bg-secondary z-10",
1069
1083
  title: "Open in new tab",
1070
- children: /* @__PURE__ */ U(B, {
1084
+ children: /* @__PURE__ */ U(ie, {
1071
1085
  size: 12,
1072
1086
  className: "text-muted-foreground"
1073
1087
  })
@@ -1079,7 +1093,7 @@ var Vt = [
1079
1093
  className: "inline-flex items-center gap-1 font-semibold text-foreground/70 align-middle",
1080
1094
  children: [e.metadata.url === "File" ? /* @__PURE__ */ U("span", {
1081
1095
  className: "inline-flex items-center justify-center w-3.5 h-3.5 rounded-full bg-secondary flex-shrink-0",
1082
- children: /* @__PURE__ */ U(ie, {
1096
+ children: /* @__PURE__ */ U(oe, {
1083
1097
  size: 10,
1084
1098
  className: "text-muted-foreground"
1085
1099
  })
@@ -1104,22 +1118,22 @@ var Vt = [
1104
1118
  };
1105
1119
  return /* @__PURE__ */ W(H, { children: [t && /* @__PURE__ */ U("div", {
1106
1120
  className: "flex items-center gap-1 mb-3 overflow-x-auto pb-1",
1107
- children: Ht.map((e) => /* @__PURE__ */ W("button", {
1108
- onClick: () => A(e.code),
1121
+ children: qt.map((e) => /* @__PURE__ */ W("button", {
1122
+ onClick: () => M(e.code),
1109
1123
  disabled: o,
1110
1124
  className: q("flex items-center gap-1.5 px-3 py-1.5 rounded-lg text-sm font-medium transition-all duration-200 whitespace-nowrap", n === e.code ? "bg-primary text-primary-foreground" : "bg-secondary/50 text-muted-foreground hover:bg-secondary hover:text-foreground"),
1111
1125
  children: [/* @__PURE__ */ U(e.icon, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: e.name })]
1112
1126
  }, e.code))
1113
1127
  }), /* @__PURE__ */ U("div", {
1114
- ref: b,
1128
+ ref: S,
1115
1129
  className: q("overflow-y-auto pb-2 pr-1", n === "images" ? "max-h-[400px] lg:max-h-[500px]" : "max-h-[180px] lg:max-h-[280px]"),
1116
1130
  children: o ? /* @__PURE__ */ U("div", {
1117
1131
  className: "flex items-center justify-center py-8",
1118
1132
  children: /* @__PURE__ */ U(V, { className: "w-6 h-6 animate-spin text-muted-foreground" })
1119
1133
  }) : i.length > 0 ? /* @__PURE__ */ W(H, { children: [
1120
1134
  /* @__PURE__ */ U("div", {
1121
- className: q(n === "images" ? "columns-2 sm:columns-3 lg:columns-4 gap-2 [&>div]:mb-2 [&>div]:break-inside-avoid" : q("grid gap-3 auto-rows-fr", w && v ? "grid-cols-2" : "grid-cols-3")),
1122
- children: i.map((e, t) => j(e, t))
1135
+ className: q(n === "images" ? "columns-2 sm:columns-3 lg:columns-4 gap-2 [&>div]:mb-2 [&>div]:break-inside-avoid" : q("grid gap-3 auto-rows-fr", E && v ? "grid-cols-2" : "grid-cols-3")),
1136
+ children: i.map((e, t) => N(e, t))
1123
1137
  }),
1124
1138
  l && /* @__PURE__ */ U("div", {
1125
1139
  className: "flex items-center justify-center py-4",
@@ -1134,7 +1148,7 @@ var Vt = [
1134
1148
  children: "No results found"
1135
1149
  })
1136
1150
  })] });
1137
- }, Wt = {
1151
+ }, Yt = {
1138
1152
  extract: "Extract",
1139
1153
  arxiv: "ArXiv",
1140
1154
  "google scholar": "Scholar",
@@ -1143,10 +1157,10 @@ var Vt = [
1143
1157
  youtube: "YouTube",
1144
1158
  Web: "Web"
1145
1159
  };
1146
- function Gt(e) {
1147
- return e ? Wt[e] ?? e : "Web";
1160
+ function Xt(e) {
1161
+ return e ? Yt[e] ?? e : "Web";
1148
1162
  }
1149
- function Kt({ queries: e, loading: t }) {
1163
+ function Zt({ queries: e, loading: t }) {
1150
1164
  let n = e.filter((e) => e.status === "done").length, r = e.length, i = t && e.some((e) => e.status === "running");
1151
1165
  return t ? /* @__PURE__ */ W("div", {
1152
1166
  className: "rounded-xl border border-border bg-secondary/20 overflow-hidden text-sm",
@@ -1175,7 +1189,7 @@ function Kt({ queries: e, loading: t }) {
1175
1189
  className: "flex items-baseline gap-1.5 min-w-0 flex-1",
1176
1190
  children: [/* @__PURE__ */ W("span", {
1177
1191
  className: "text-xs text-muted-foreground whitespace-nowrap flex-shrink-0",
1178
- children: [Gt(e.category), " ·"]
1192
+ children: [Xt(e.category), " ·"]
1179
1193
  }), /* @__PURE__ */ U("span", {
1180
1194
  className: "text-foreground/80 truncate",
1181
1195
  children: e.query
@@ -1187,57 +1201,57 @@ function Kt({ queries: e, loading: t }) {
1187
1201
  }
1188
1202
  //#endregion
1189
1203
  //#region src/lib/kokoro.ts
1190
- var qt = {
1204
+ var Qt = {
1191
1205
  device: "webgpu",
1192
1206
  dtype: "fp32"
1193
- }, Jt = {
1207
+ }, $t = {
1194
1208
  device: "wasm",
1195
1209
  dtype: "q8"
1196
- }, Yt = "hexgrad/Kokoro-82M", Xt = null, Zt = null;
1197
- function Qt() {
1210
+ }, en = "hexgrad/Kokoro-82M", tn = null, nn = null;
1211
+ function rn() {
1198
1212
  return typeof navigator < "u" && "gpu" in navigator;
1199
1213
  }
1200
- async function $t() {
1201
- if (!Qt()) return !1;
1214
+ async function an() {
1215
+ if (!rn()) return !1;
1202
1216
  try {
1203
1217
  return await navigator.gpu.requestAdapter() != null;
1204
1218
  } catch {
1205
1219
  return !1;
1206
1220
  }
1207
1221
  }
1208
- async function en() {
1222
+ async function on() {
1209
1223
  let e = [];
1210
- await $t() && e.push(qt), e.push(Jt);
1224
+ await an() && e.push(Qt), e.push($t);
1211
1225
  let { KokoroTTS: t } = await import("kokoro-js"), n;
1212
1226
  for (let r of e) try {
1213
- let e = await t.from_pretrained(Yt, {
1227
+ let e = await t.from_pretrained(en, {
1214
1228
  device: r.device,
1215
1229
  dtype: r.dtype
1216
1230
  });
1217
- return Zt = r.device, e;
1231
+ return nn = r.device, e;
1218
1232
  } catch (e) {
1219
1233
  n = e, console.warn(`Kokoro model failed to load on "${r.device}" backend:`, e);
1220
1234
  }
1221
1235
  throw n instanceof Error ? n : /* @__PURE__ */ Error("Failed to load Kokoro model");
1222
1236
  }
1223
- async function tn() {
1224
- return Xt ||= en().catch((e) => {
1225
- throw Xt = null, e;
1226
- }), Xt;
1237
+ async function sn() {
1238
+ return tn ||= on().catch((e) => {
1239
+ throw tn = null, e;
1240
+ }), tn;
1227
1241
  }
1228
- async function nn() {
1229
- return tn();
1242
+ async function cn() {
1243
+ return sn();
1230
1244
  }
1231
- async function rn() {
1232
- let e = await nn();
1245
+ async function ln() {
1246
+ let e = await cn();
1233
1247
  return Object.keys(e.voices);
1234
1248
  }
1235
- function an() {
1236
- return Zt;
1249
+ function un() {
1250
+ return nn;
1237
1251
  }
1238
1252
  //#endregion
1239
1253
  //#region src/hooks/voice/useTextToVoice.ts
1240
- function on(e, t) {
1254
+ function dn(e, t) {
1241
1255
  let [n, r] = p("stopped"), i = f(null), a = f(null), o = f(null), s = f(t);
1242
1256
  s.current = t;
1243
1257
  let l = c(() => {
@@ -1265,7 +1279,7 @@ function on(e, t) {
1265
1279
  o.current = t;
1266
1280
  try {
1267
1281
  if (localStorage.getItem("useTTSKokoro") !== "false") try {
1268
- let t = await nn(), n = localStorage.getItem("kokoroVoice") || "af_heart", a = (await t.generate(e.slice(0, 5e3), { voice: n })).toWav(), o = new Blob([a], { type: "audio/wav" }), s = URL.createObjectURL(o), c = new Audio(s);
1282
+ let t = await cn(), n = localStorage.getItem("kokoroVoice") || "af_heart", a = (await t.generate(e.slice(0, 5e3), { voice: n })).toWav(), o = new Blob([a], { type: "audio/wav" }), s = URL.createObjectURL(o), c = new Audio(s);
1269
1283
  i.current = c, c.onended = () => {
1270
1284
  r("stopped"), URL.revokeObjectURL(s), i.current = null;
1271
1285
  }, c.onerror = () => {
@@ -1275,7 +1289,7 @@ function on(e, t) {
1275
1289
  } catch (e) {
1276
1290
  console.debug("Kokoro TTS unavailable, using server-side TTS:", e instanceof Error ? e.message : String(e));
1277
1291
  }
1278
- let n = await gt("/api/agent/voice", {
1292
+ let n = await gt("agent/voice", {
1279
1293
  method: "POST",
1280
1294
  body: {
1281
1295
  text: e.slice(0, 5e3),
@@ -1308,20 +1322,20 @@ function on(e, t) {
1308
1322
  }
1309
1323
  //#endregion
1310
1324
  //#region src/hooks/useChat/chatConfig.ts
1311
- var sn = async (e, t, n) => {
1312
- let r = localStorage.getItem("chatModelKey"), i = localStorage.getItem("chatModelProviderId"), a = (await gt("/api/agent/providers"))?.providers || [];
1325
+ var fn = async (e, t, n) => {
1326
+ let r = localStorage.getItem("chatModelKey"), i = localStorage.getItem("chatModelProviderId"), a = (await gt("agent/providers"))?.providers || [];
1313
1327
  if (!a || a.length === 0) {
1314
1328
  t(!0);
1315
1329
  return;
1316
1330
  }
1317
1331
  let o = a.find((e) => e.id === i && (e.chatModels?.length ?? 0) > 0);
1318
- if (o ||= a.find((e) => e.name.toLowerCase().includes("openrouter") && (e.chatModels?.length ?? 0) > 0) || a.find((e) => e.name.toLowerCase().includes("nvidia") && (e.chatModels?.length ?? 0) > 0) || a.find((e) => (e.chatModels?.length ?? 0) > 0), !o) {
1332
+ if (o ||= a.find((e) => e.name.toLowerCase().includes("openrouter") && (e.chatModels?.length ?? 0) > 0) || a.find((e) => e.name.toLowerCase().includes("anyapi") && (e.chatModels?.length ?? 0) > 0) || a.find((e) => e.name.toLowerCase().includes("nvidia") && (e.chatModels?.length ?? 0) > 0) || a.find((e) => (e.chatModels?.length ?? 0) > 0), !o) {
1319
1333
  t(!0);
1320
1334
  return;
1321
1335
  }
1322
1336
  i = o.id;
1323
1337
  let s = o.chatModels.find((e) => e.key === r);
1324
- if (s || (o.name.toLowerCase().includes("openrouter") && (s = o.chatModels.find((e) => e.key === "openrouter/free")), !s && o.name.toLowerCase().includes("openrouter") && (s = o.chatModels.find((e) => e.key === "nvidia/nemotron-3-super-120b-a12b:free")), s ||= o.chatModels.find((e) => (e.key.toLowerCase().includes("nemotron-3-super") || e.name.toLowerCase().includes("nemotron 3 super")) && e.key.toLowerCase().includes("120b")), s ||= o.chatModels.find((e) => e.key.toLowerCase().includes("nemotron") || e.name.toLowerCase().includes("nemotron")), s ||= o.chatModels[0]), !s) {
1338
+ if (s || (o.name.toLowerCase().includes("openrouter") && (s = o.chatModels.find((e) => e.key === "openrouter/free")), !s && o.name.toLowerCase().includes("openrouter") && (s = o.chatModels.find((e) => e.key === "nvidia/nemotron-3-super-120b-a12b:free")), !s && o.name.toLowerCase().includes("anyapi") && (s = o.chatModels.find((e) => e.key === "deepseek/deepseek-v3:free")), s ||= o.chatModels.find((e) => (e.key.toLowerCase().includes("nemotron-3-super") || e.name.toLowerCase().includes("nemotron 3 super")) && e.key.toLowerCase().includes("120b")), s ||= o.chatModels.find((e) => e.key.toLowerCase().includes("nemotron") || e.name.toLowerCase().includes("nemotron")), s ||= o.chatModels[0]), !s) {
1325
1339
  t(!0);
1326
1340
  return;
1327
1341
  }
@@ -1329,52 +1343,52 @@ var sn = async (e, t, n) => {
1329
1343
  key: r,
1330
1344
  providerId: i
1331
1345
  }), t(!0);
1332
- }, cn = "qwksearch_guest_chats", ln = typeof window < "u";
1333
- function un() {
1334
- if (!ln) return [];
1346
+ }, pn = "qwksearch_guest_chats", mn = typeof window < "u";
1347
+ function hn() {
1348
+ if (!mn) return [];
1335
1349
  try {
1336
- let e = localStorage.getItem(cn);
1350
+ let e = localStorage.getItem(pn);
1337
1351
  return e ? JSON.parse(e).sort((e, t) => new Date(t.createdAt).getTime() - new Date(e.createdAt).getTime()) : [];
1338
1352
  } catch (e) {
1339
1353
  return console.error("Failed to get guest chats:", e), [];
1340
1354
  }
1341
1355
  }
1342
- function dn(e) {
1343
- return ln && un().find((t) => t.id === e) || null;
1356
+ function gn(e) {
1357
+ return mn && hn().find((t) => t.id === e) || null;
1344
1358
  }
1345
- function fn(e) {
1346
- if (ln) try {
1347
- let t = un(), n = t.findIndex((t) => t.id === e.id);
1348
- n >= 0 ? t[n] = e : t.push(e), localStorage.setItem(cn, JSON.stringify(t));
1359
+ function _n(e) {
1360
+ if (mn) try {
1361
+ let t = hn(), n = t.findIndex((t) => t.id === e.id);
1362
+ n >= 0 ? t[n] = e : t.push(e), localStorage.setItem(pn, JSON.stringify(t));
1349
1363
  } catch (e) {
1350
1364
  console.error("Failed to save guest chat:", e);
1351
1365
  }
1352
1366
  }
1353
- function pn(e) {
1354
- if (ln) try {
1355
- let t = un().filter((t) => t.id !== e);
1356
- localStorage.setItem(cn, JSON.stringify(t));
1367
+ function vn(e) {
1368
+ if (mn) try {
1369
+ let t = hn().filter((t) => t.id !== e);
1370
+ localStorage.setItem(pn, JSON.stringify(t));
1357
1371
  } catch (e) {
1358
1372
  console.error("Failed to delete guest chat:", e);
1359
1373
  }
1360
1374
  }
1361
- function mn() {
1362
- if (ln) try {
1363
- localStorage.removeItem(cn);
1375
+ function yn() {
1376
+ if (mn) try {
1377
+ localStorage.removeItem(pn);
1364
1378
  } catch (e) {
1365
1379
  console.error("Failed to clear guest chats:", e);
1366
1380
  }
1367
1381
  }
1368
- function hn(e, t) {
1369
- if (!ln) return;
1370
- let n = dn(e);
1371
- n && (n.title = t, fn(n));
1382
+ function bn(e, t) {
1383
+ if (!mn) return;
1384
+ let n = gn(e);
1385
+ n && (n.title = t, _n(n));
1372
1386
  }
1373
1387
  //#endregion
1374
1388
  //#region src/hooks/useChat/chatMessages.ts
1375
- var gn = async (e, t, n, r, i, a, o, s, c) => {
1389
+ var xn = async (e, t, n, r, i, a, o, s, c) => {
1376
1390
  if (!t) {
1377
- let t = dn(e);
1391
+ let t = gn(e);
1378
1392
  if (t) {
1379
1393
  n(t.messages);
1380
1394
  let e = t.messages.filter((e) => e.role === "user" || e.role === "assistant"), o = e.map((e) => [e.role, e.content]);
@@ -1438,7 +1452,7 @@ var gn = async (e, t, n, r, i, a, o, s, c) => {
1438
1452
  } catch (e) {
1439
1453
  console.error("[chatMessages] Failed to load chat:", e), o(!0), r(!0);
1440
1454
  }
1441
- }, _n = (e) => {
1455
+ }, Sn = (e) => {
1442
1456
  let t = [];
1443
1457
  return e.forEach((n, r) => {
1444
1458
  if (n.role === "user") {
@@ -1470,7 +1484,7 @@ var gn = async (e, t, n, r, i, a, o, s, c) => {
1470
1484
  });
1471
1485
  }
1472
1486
  }), t;
1473
- }, vn = async (e) => {
1487
+ }, Cn = async (e) => {
1474
1488
  let t = localStorage.getItem("chatModelKey"), n = localStorage.getItem("chatModelProviderId"), r = parseInt(localStorage.getItem("maxFollowupQuestions") || "4"), i = e.filter((e) => e.role === "user" || e.role === "assistant");
1475
1489
  try {
1476
1490
  let e = await gt("agent/suggestions", {
@@ -1488,24 +1502,27 @@ var gn = async (e, t, n, r, i, a, o, s, c) => {
1488
1502
  } catch {
1489
1503
  return [];
1490
1504
  }
1491
- }, yn = 3, bn = "Analyze the uploaded file(s) and summarize the key points.", xn = () => Array.from(crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(7)), (e) => e.toString(16).padStart(2, "0")).join(""), Sn = "sourceExtractionEnabled", Cn = "thinkingTimeLimit";
1492
- async function wn(e, n) {
1493
- let { message: r, messageId: i, rewrite: a = !1 } = e, { chatId: o, loading: s, messages: c, fileIds: l, files: u, focusMode: d, category: f, optimizationMode: p, chatHistory: m, chatModelProvider: h, isAuthenticated: g, messagesRef: _, abortControllerRef: v, setLoading: y, setMessageAppeared: b, setMessages: x, setChatHistory: S, setChatModelProvider: C } = n, w = typeof window < "u" && localStorage.getItem(Sn) === "true", T = typeof window < "u" && Number(localStorage.getItem(Cn) ?? "0") || 0;
1505
+ }, wn = 3, Tn = "Analyze the uploaded file(s) and summarize the key points.", En = () => Array.from(crypto.getRandomValues(/* @__PURE__ */ new Uint8Array(7)), (e) => e.toString(16).padStart(2, "0")).join(""), Dn = "sourceExtractionEnabled", On = "thinkingTimeLimit";
1506
+ async function kn(e, n) {
1507
+ let { message: r, messageId: i, rewrite: a = !1 } = e, { chatId: o, loading: s, messages: c, fileIds: l, files: u, focusMode: d, category: f, optimizationMode: p, chatHistory: m, chatModelProvider: h, isAuthenticated: g, messagesRef: _, abortControllerRef: v, setLoading: y, setMessageAppeared: b, setMessages: x, setChatHistory: S, setChatModelProvider: C } = n, w = typeof window < "u" && localStorage.getItem(Dn) === "true", T = typeof window < "u" && Number(localStorage.getItem(On) ?? "0") || 0;
1494
1508
  if (s) return;
1495
1509
  let E = r?.trim() ?? "", D = Array.isArray(l) && l.length > 0;
1496
1510
  if (!E && !D) return;
1497
- let O = E ? r : bn, k = new AbortController();
1498
- v.current = k, y(!0), b(!1), c.length <= 1 && window.history.replaceState(null, "", `/c/${o}`);
1499
- let A = "", j = !1, ee = !1, M = [], N = Date.now(), P = T > 0, F = "", I = "", L = i ?? xn(), R = Array.isArray(u) ? [...u] : [];
1511
+ let O = E ? r : Tn, k = new AbortController();
1512
+ if (v.current = k, y(!0), b(!1), c.length <= 1 && !t.onOpenChat) {
1513
+ let e = new URL(window.location.href);
1514
+ e.searchParams.set("chat", o), window.history.replaceState(null, "", `${e.pathname}?${e.searchParams.toString()}${e.hash}`);
1515
+ }
1516
+ let A = "", j = !1, M = !1, N = [], ee = Date.now(), P = T > 0, F = "", I = "", te = i ?? En(), L = Array.isArray(u) ? [...u] : [];
1500
1517
  x((e) => [...e, {
1501
1518
  content: O,
1502
- messageId: L,
1519
+ messageId: te,
1503
1520
  chatId: o,
1504
1521
  role: "user",
1505
1522
  createdAt: /* @__PURE__ */ new Date(),
1506
- ...R.length > 0 ? { files: R } : {}
1523
+ ...L.length > 0 ? { files: L } : {}
1507
1524
  }]);
1508
- let z = async (e) => {
1525
+ let R = async (e) => {
1509
1526
  if (e.type === "error") {
1510
1527
  let t = e.data;
1511
1528
  typeof t == "string" && (t.includes("no longer available") || t.includes("deprecated") || t.includes("410")) && (localStorage.removeItem("chatModelKey"), localStorage.removeItem("chatModelProviderId"), C?.({
@@ -1550,13 +1567,13 @@ async function wn(e, n) {
1550
1567
  });
1551
1568
  });
1552
1569
  }
1553
- if (e.type === "sources" && (M = e.data || [], x((t) => [...t, {
1570
+ if (e.type === "sources" && (N = e.data || [], x((t) => [...t, {
1554
1571
  messageId: e.messageId,
1555
1572
  chatId: o,
1556
1573
  role: "source",
1557
- sources: M,
1574
+ sources: N,
1558
1575
  createdAt: /* @__PURE__ */ new Date()
1559
- }]), M.length > 0 && (b(!0), M.slice(0, yn).forEach((e) => {
1576
+ }]), N.length > 0 && (b(!0), N.slice(0, wn).forEach((e) => {
1560
1577
  let t = e?.metadata?.url;
1561
1578
  t && t !== "File" && gt(`doc/article?url=${encodeURIComponent(t)}`).catch(() => {});
1562
1579
  }))), e.type === "message" && (A += e.data, P ? (F += e.data, I ||= e.messageId, j = !0) : j ? x((t) => t.map((t) => t.messageId === e.messageId && t.role === "assistant" ? {
@@ -1582,9 +1599,9 @@ async function wn(e, n) {
1582
1599
  ["assistant", A]
1583
1600
  ]), y(!1);
1584
1601
  let e = _.current[_.current.length - 1];
1585
- if (t.getAutoMediaSearch() && (document.getElementById(`search-images-${e.messageId}`)?.click(), document.getElementById(`search-videos-${e.messageId}`)?.click()), !ee) {
1586
- ee = !0;
1587
- let e = await vn(_.current), t = xn();
1602
+ if (t.getAutoMediaSearch() && (document.getElementById(`search-images-${e.messageId}`)?.click(), document.getElementById(`search-videos-${e.messageId}`)?.click()), !M) {
1603
+ M = !0;
1604
+ let e = await Cn(_.current), t = En();
1588
1605
  if (x((n) => [...n, {
1589
1606
  role: "suggestion",
1590
1607
  suggestions: e,
@@ -1604,25 +1621,25 @@ async function wn(e, n) {
1604
1621
  }
1605
1622
  };
1606
1623
  if (P) {
1607
- let e = Date.now() - N, t = T * 1e3 - e;
1624
+ let e = Date.now() - ee, t = T * 1e3 - e;
1608
1625
  t > 0 && await new Promise((e) => setTimeout(e, t));
1609
1626
  }
1610
1627
  await e();
1611
1628
  }
1612
- }, te = c.findIndex((e) => e.messageId === L);
1629
+ }, ne = c.findIndex((e) => e.messageId === te);
1613
1630
  try {
1614
1631
  let { stream: e } = await He({
1615
1632
  signal: k.signal,
1616
1633
  body: {
1617
1634
  message: {
1618
- messageId: L,
1635
+ messageId: te,
1619
1636
  chatId: o,
1620
1637
  content: O
1621
1638
  },
1622
1639
  optimizationMode: p,
1623
1640
  focusMode: d,
1624
1641
  category: f,
1625
- history: a ? m.slice(0, te === -1 ? void 0 : te) : m,
1642
+ history: a ? m.slice(0, ne === -1 ? void 0 : ne) : m,
1626
1643
  files: l,
1627
1644
  chatModel: {
1628
1645
  key: h.key,
@@ -1640,7 +1657,7 @@ async function wn(e, n) {
1640
1657
  G.error("Failed to send message. Please try again."), y(!1);
1641
1658
  }
1642
1659
  });
1643
- for await (let t of e) await z(t);
1660
+ for await (let t of e) await R(t);
1644
1661
  } catch (e) {
1645
1662
  if (e.name === "AbortError") {
1646
1663
  P && F && (x((e) => [...e, {
@@ -1662,11 +1679,11 @@ async function wn(e, n) {
1662
1679
  }
1663
1680
  //#endregion
1664
1681
  //#region src/hooks/useChat/useChatState.ts
1665
- function Tn(e) {
1666
- let [t, n] = p(e), [r, i] = p(!1), [a, o] = p(!1), [s, c] = p(!1), [l, u] = p(!1), [m, h] = p(!1), [g, _] = p(!1), [v, y] = p(!1), [b, x] = p(!1), [S, C] = p([]), [w, T] = p([]), [E, D] = p([]), [O, k] = p([]), [A, j] = p("webSearch"), [ee, M] = p("general"), [N, P] = p("speed"), [F, I] = p({
1682
+ function An(e) {
1683
+ let [t, n] = p(e), [r, i] = p(!1), [a, o] = p(!1), [s, c] = p(!1), [l, u] = p(!1), [m, h] = p(!1), [g, _] = p(!1), [v, y] = p(!1), [b, x] = p(!1), [S, C] = p([]), [w, T] = p([]), [E, D] = p([]), [O, k] = p([]), [A, j] = p("webSearch"), [M, N] = p("general"), [ee, P] = p("speed"), [F, I] = p({
1667
1684
  key: "",
1668
1685
  providerId: ""
1669
- }), L = f([]), R = d(() => w.filter((e) => e.role === "user" || e.role === "assistant"), [w]), z = d(() => _n(w), [w]);
1686
+ }), te = f([]), L = d(() => w.filter((e) => e.role === "user" || e.role === "assistant"), [w]), R = d(() => Sn(w), [w]);
1670
1687
  return {
1671
1688
  state: {
1672
1689
  chatId: t,
@@ -1678,8 +1695,8 @@ function Tn(e) {
1678
1695
  files: E,
1679
1696
  fileIds: O,
1680
1697
  focusMode: A,
1681
- category: ee,
1682
- optimizationMode: N,
1698
+ category: M,
1699
+ optimizationMode: ee,
1683
1700
  isMessagesLoaded: l,
1684
1701
  notFound: b,
1685
1702
  chatModelProvider: F,
@@ -1697,7 +1714,7 @@ function Tn(e) {
1697
1714
  setFiles: D,
1698
1715
  setFileIds: k,
1699
1716
  setFocusMode: j,
1700
- setCategory: M,
1717
+ setCategory: N,
1701
1718
  setOptimizationMode: P,
1702
1719
  setIsMessagesLoaded: u,
1703
1720
  setNotFound: x,
@@ -1706,14 +1723,14 @@ function Tn(e) {
1706
1723
  setHasError: _,
1707
1724
  setIsReady: y
1708
1725
  },
1709
- messagesRef: L,
1710
- chatTurns: R,
1711
- sections: z
1726
+ messagesRef: te,
1727
+ chatTurns: L,
1728
+ sections: R
1712
1729
  };
1713
1730
  }
1714
1731
  //#endregion
1715
1732
  //#region src/hooks/useChat/ChatContext.tsx
1716
- var En = a({
1733
+ var jn = a({
1717
1734
  chatHistory: [],
1718
1735
  chatId: "",
1719
1736
  fileIds: [],
@@ -1745,15 +1762,17 @@ var En = a({
1745
1762
  setChatModelProvider: () => {},
1746
1763
  stopStreaming: () => {},
1747
1764
  newChat: () => {},
1765
+ startNewChat: () => {},
1766
+ switchToChat: () => {},
1748
1767
  incognito: !1,
1749
1768
  setIncognito: () => {}
1750
1769
  });
1751
1770
  function J() {
1752
- return l(En);
1771
+ return l(jn);
1753
1772
  }
1754
1773
  //#endregion
1755
1774
  //#region src/lib/chatTitle.ts
1756
- var Dn = async (e, t) => {
1775
+ var Mn = async (e, t) => {
1757
1776
  let n = localStorage.getItem("chatModelKey"), r = localStorage.getItem("chatModelProviderId"), i = t.filter((e) => e.role === "user" || e.role === "assistant").map((e) => ({
1758
1777
  role: e.role,
1759
1778
  content: e.content ?? ""
@@ -1775,14 +1794,14 @@ var Dn = async (e, t) => {
1775
1794
  } catch {
1776
1795
  return "";
1777
1796
  }
1778
- }, On = a({
1797
+ }, Nn = a({
1779
1798
  user: null,
1780
1799
  isLoading: !0,
1781
1800
  isAuthenticated: !1,
1782
1801
  signIn: () => {},
1783
1802
  signOut: async () => {}
1784
1803
  });
1785
- function kn({ children: e, authClient: t, enableGoogleOneTap: n = !0 }) {
1804
+ function Pn({ children: e, authClient: t, enableGoogleOneTap: n = !0 }) {
1786
1805
  let [r, i] = p(null), [a, o] = p(!0);
1787
1806
  return u(() => {
1788
1807
  (async () => {
@@ -1804,7 +1823,7 @@ function kn({ children: e, authClient: t, enableGoogleOneTap: n = !0 }) {
1804
1823
  a,
1805
1824
  r,
1806
1825
  n
1807
- ]), /* @__PURE__ */ U(On.Provider, {
1826
+ ]), /* @__PURE__ */ U(Nn.Provider, {
1808
1827
  value: {
1809
1828
  user: r,
1810
1829
  isLoading: a,
@@ -1828,23 +1847,23 @@ function kn({ children: e, authClient: t, enableGoogleOneTap: n = !0 }) {
1828
1847
  children: e
1829
1848
  });
1830
1849
  }
1831
- function An() {
1832
- let e = l(On);
1850
+ function Fn() {
1851
+ let e = l(Nn);
1833
1852
  if (!e) throw Error("useSession must be used within SessionProvider");
1834
1853
  return e;
1835
1854
  }
1836
1855
  //#endregion
1837
1856
  //#region src/hooks/useChat/ChatProvider.tsx
1838
- function jn({ children: e }) {
1839
- let t = m(), n = g(), r = h(), i = n.get("q"), { isAuthenticated: a, isLoading: o } = An(), { state: s, setters: l, messagesRef: d, chatTurns: _, sections: v } = Tn(t.chatId), y = f(null), [b, x] = p(!1), S = f({}), C = f(/* @__PURE__ */ new Set());
1857
+ function In({ children: e }) {
1858
+ let t = m(), n = g(), r = h(), i = n.get("q"), { isAuthenticated: a, isLoading: o } = Fn(), { state: s, setters: l, messagesRef: d, chatTurns: _, sections: v } = An(t.chatId), y = f(null), [b, x] = p(!1), S = f({}), C = f(/* @__PURE__ */ new Set());
1840
1859
  u(() => {
1841
- sn(l.setChatModelProvider, l.setIsConfigReady, l.setHasError);
1860
+ fn(l.setChatModelProvider, l.setIsConfigReady, l.setHasError);
1842
1861
  }, []), u(() => {
1843
1862
  t.chatId && t.chatId !== s.chatId && (l.setChatId(t.chatId), l.setMessages([]), l.setChatHistory([]), l.setFiles([]), l.setFileIds([]), l.setIsMessagesLoaded(!1), l.setNotFound(!1), l.setNewChatCreated(!1));
1844
1863
  }, [t.chatId, s.chatId]), u(() => {
1845
1864
  if (s.chatId && !s.newChatCreated && !s.isMessagesLoaded && s.messages.length === 0) {
1846
1865
  if (o) return;
1847
- gn(s.chatId, a, l.setMessages, l.setIsMessagesLoaded, l.setChatHistory, l.setFocusMode, l.setNotFound, l.setFiles, l.setFileIds);
1866
+ xn(s.chatId, a, l.setMessages, l.setIsMessagesLoaded, l.setChatHistory, l.setFocusMode, l.setNotFound, l.setFiles, l.setFileIds);
1848
1867
  } else s.chatId || (l.setNewChatCreated(!0), l.setIsMessagesLoaded(!0), l.setChatId(crypto.randomUUID()));
1849
1868
  }, [
1850
1869
  s.chatId,
@@ -1858,7 +1877,7 @@ function jn({ children: e }) {
1858
1877
  let e = s.messages.filter((e) => e.role === "user" || e.role === "assistant");
1859
1878
  if (e.length > 0) {
1860
1879
  let t = S.current[s.chatId] ?? e[0].content.slice(0, 50);
1861
- fn({
1880
+ _n({
1862
1881
  id: s.chatId,
1863
1882
  title: t,
1864
1883
  createdAt: (/* @__PURE__ */ new Date()).toISOString(),
@@ -1878,12 +1897,12 @@ function jn({ children: e }) {
1878
1897
  if (b || !s.chatId || !s.isMessagesLoaded || !s.newChatCreated || s.loading || _.filter((e) => e.role === "user").length < 2) return;
1879
1898
  let e = s.chatId;
1880
1899
  C.current.has(e) || (C.current.add(e), (async () => {
1881
- let t = await Dn(e, s.messages);
1900
+ let t = await Mn(e, s.messages);
1882
1901
  if (!t) {
1883
1902
  C.current.delete(e);
1884
1903
  return;
1885
1904
  }
1886
- S.current[e] = t, a || hn(e, t);
1905
+ S.current[e] = t, a || bn(e, t);
1887
1906
  })());
1888
1907
  }, [
1889
1908
  _,
@@ -1906,7 +1925,7 @@ function jn({ children: e }) {
1906
1925
  i
1907
1926
  ]);
1908
1927
  let w = c(async (e, t, n = !1) => {
1909
- s.chatId && await wn({
1928
+ s.chatId && await kn({
1910
1929
  message: e,
1911
1930
  messageId: t,
1912
1931
  rewrite: n
@@ -1971,7 +1990,11 @@ function jn({ children: e }) {
1971
1990
  y.current &&= (y.current.abort(), null);
1972
1991
  }, []), O = c(() => {
1973
1992
  D(), l.setMessages([]), l.setChatHistory([]), l.setFiles([]), l.setFileIds([]), l.setChatId(void 0), l.setNewChatCreated(!1), l.setIsMessagesLoaded(!1), l.setNotFound(!1), r.push("/");
1974
- }, [D, r]), k = {
1993
+ }, [D, r]), k = c((e) => {
1994
+ D(), l.setMessages([]), l.setChatHistory([]), l.setFiles([]), l.setFileIds([]), l.setNotFound(!1), l.setNewChatCreated(!0), l.setIsMessagesLoaded(!0), l.setChatId(e);
1995
+ }, [D]), A = c((e) => {
1996
+ e !== s.chatId && (D(), l.setMessages([]), l.setChatHistory([]), l.setFiles([]), l.setFileIds([]), l.setIsMessagesLoaded(!1), l.setNotFound(!1), l.setNewChatCreated(!1), l.setChatId(e));
1997
+ }, [D, s.chatId]), j = {
1975
1998
  messages: s.messages,
1976
1999
  chatTurns: _,
1977
2000
  sections: v,
@@ -2001,16 +2024,18 @@ function jn({ children: e }) {
2001
2024
  setChatModelProvider: l.setChatModelProvider,
2002
2025
  stopStreaming: D,
2003
2026
  newChat: O,
2027
+ startNewChat: k,
2028
+ switchToChat: A,
2004
2029
  setIncognito: x
2005
2030
  };
2006
- return /* @__PURE__ */ U(En.Provider, {
2007
- value: k,
2031
+ return /* @__PURE__ */ U(jn.Provider, {
2032
+ value: j,
2008
2033
  children: e
2009
2034
  });
2010
2035
  }
2011
2036
  //#endregion
2012
2037
  //#region src/ui/tooltip.tsx
2013
- function Mn({ delayDuration: e = 0, ...t }) {
2038
+ function Ln({ delayDuration: e = 0, ...t }) {
2014
2039
  return /* @__PURE__ */ U(_t.Provider, {
2015
2040
  "data-slot": "tooltip-provider",
2016
2041
  delayDuration: e,
@@ -2018,7 +2043,7 @@ function Mn({ delayDuration: e = 0, ...t }) {
2018
2043
  });
2019
2044
  }
2020
2045
  function Y({ ...e }) {
2021
- return /* @__PURE__ */ U(Mn, { children: /* @__PURE__ */ U(_t.Root, {
2046
+ return /* @__PURE__ */ U(Ln, { children: /* @__PURE__ */ U(_t.Root, {
2022
2047
  "data-slot": "tooltip",
2023
2048
  ...e
2024
2049
  }) });
@@ -2033,15 +2058,15 @@ function Z({ className: e, sideOffset: t = 0, children: n, ...r }) {
2033
2058
  return /* @__PURE__ */ U(_t.Portal, { children: /* @__PURE__ */ W(_t.Content, {
2034
2059
  "data-slot": "tooltip-content",
2035
2060
  sideOffset: t,
2036
- className: q("bg-primary text-primary-foreground animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-2xl px-3 py-1.5 text-xs text-balance", e),
2061
+ className: q("bg-popover text-popover-foreground border border-border shadow-md animate-in fade-in-0 zoom-in-95 data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=closed]:zoom-out-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 w-fit origin-(--radix-tooltip-content-transform-origin) rounded-2xl px-3 py-1.5 text-xs text-balance", e),
2037
2062
  ...r,
2038
- children: [n, /* @__PURE__ */ U(_t.Arrow, { className: "bg-primary fill-primary z-50 size-2.5 translate-y-[calc(-50%_-_2px)] rotate-45 rounded-[2px]" })]
2063
+ children: [n, /* @__PURE__ */ U(_t.Arrow, { className: "bg-popover fill-popover z-50 size-2.5 translate-y-[calc(-50%-2px)] rotate-45 rounded-[2px]" })]
2039
2064
  }) });
2040
2065
  }
2041
2066
  //#endregion
2042
2067
  //#region src/components/SearchResults/WebCitationBadge.tsx
2043
- var Nn = ({ href: e, children: t, sources: n }) => {
2044
- let { openPanel: r } = Mt(), i = d(() => !n || !e ? null : n.find((t) => t.metadata?.url === e) ?? null, [n, e]), a = d(() => {
2068
+ var Rn = ({ href: e, children: t, sources: n }) => {
2069
+ let { openPanel: r } = Lt(), i = d(() => !n || !e ? null : n.find((t) => t.metadata?.url === e) ?? null, [n, e]), a = d(() => {
2045
2070
  try {
2046
2071
  return new URL(e).hostname.replace("www.", "");
2047
2072
  } catch {
@@ -2081,7 +2106,7 @@ var Nn = ({ href: e, children: t, sources: n }) => {
2081
2106
  })]
2082
2107
  })
2083
2108
  })] });
2084
- }, Pn = ({ content: e, thinkingEnded: t }) => {
2109
+ }, zn = ({ content: e, thinkingEnded: t }) => {
2085
2110
  let [n, r] = p(!0);
2086
2111
  return u(() => {
2087
2112
  r(!t);
@@ -2099,7 +2124,7 @@ var Nn = ({ href: e, children: t, sources: n }) => {
2099
2124
  className: "font-medium text-sm",
2100
2125
  children: "Thinking Process"
2101
2126
  })]
2102
- }), U(n ? N : j, {
2127
+ }), U(n ? ee : j, {
2103
2128
  size: 18,
2104
2129
  className: "text-muted-foreground"
2105
2130
  })]
@@ -2108,41 +2133,41 @@ var Nn = ({ href: e, children: t, sources: n }) => {
2108
2133
  children: e
2109
2134
  })]
2110
2135
  });
2111
- }, Fn = ({ children: e, thinkingEnded: t }) => /* @__PURE__ */ U(Pn, {
2136
+ }, Bn = ({ children: e, thinkingEnded: t }) => /* @__PURE__ */ U(zn, {
2112
2137
  content: e,
2113
2138
  thinkingEnded: t
2114
2139
  });
2115
2140
  //#endregion
2116
2141
  //#region src/ui/dialog.tsx
2117
- function In({ ...e }) {
2142
+ function Vn({ ...e }) {
2118
2143
  return /* @__PURE__ */ U(vt.Root, {
2119
2144
  "data-slot": "dialog",
2120
2145
  ...e
2121
2146
  });
2122
2147
  }
2123
- function Ln({ ...e }) {
2148
+ function Hn({ ...e }) {
2124
2149
  return /* @__PURE__ */ U(vt.Trigger, {
2125
2150
  "data-slot": "dialog-trigger",
2126
2151
  ...e
2127
2152
  });
2128
2153
  }
2129
- function Rn({ ...e }) {
2154
+ function Un({ ...e }) {
2130
2155
  return /* @__PURE__ */ U(vt.Portal, {
2131
2156
  "data-slot": "dialog-portal",
2132
2157
  ...e
2133
2158
  });
2134
2159
  }
2135
- function zn({ className: e, ...t }) {
2160
+ function Wn({ className: e, ...t }) {
2136
2161
  return /* @__PURE__ */ U(vt.Overlay, {
2137
2162
  "data-slot": "dialog-overlay",
2138
2163
  className: q("data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 fixed inset-0 z-50 bg-black/50 backdrop-blur-xs", e),
2139
2164
  ...t
2140
2165
  });
2141
2166
  }
2142
- function Bn({ className: e, children: t, hideCloseButton: n = !1, ...r }) {
2143
- return /* @__PURE__ */ W(Rn, {
2167
+ function Gn({ className: e, children: t, hideCloseButton: n = !1, ...r }) {
2168
+ return /* @__PURE__ */ W(Un, {
2144
2169
  "data-slot": "dialog-portal",
2145
- children: [/* @__PURE__ */ U(zn, {}), /* @__PURE__ */ W(vt.Content, {
2170
+ children: [/* @__PURE__ */ U(Wn, {}), /* @__PURE__ */ W(vt.Content, {
2146
2171
  "data-slot": "dialog-content",
2147
2172
  "aria-describedby": r["aria-describedby"] ?? void 0,
2148
2173
  className: q("z-[9999] bg-background data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 fixed top-[50%] left-[50%] z-50 grid w-full max-w-[calc(100%-2rem)] translate-x-[-50%] translate-y-[-50%] gap-4 rounded-2xl border p-6 shadow-lg duration-200", e),
@@ -2157,14 +2182,14 @@ function Bn({ className: e, children: t, hideCloseButton: n = !1, ...r }) {
2157
2182
  })]
2158
2183
  });
2159
2184
  }
2160
- function Vn({ className: e, ...t }) {
2185
+ function Kn({ className: e, ...t }) {
2161
2186
  return /* @__PURE__ */ U(vt.Title, {
2162
2187
  "data-slot": "dialog-title",
2163
2188
  className: q("text-lg leading-none font-semibold", e),
2164
2189
  ...t
2165
2190
  });
2166
2191
  }
2167
- function Hn({ className: e, ...t }) {
2192
+ function qn({ className: e, ...t }) {
2168
2193
  return /* @__PURE__ */ U(vt.Description, {
2169
2194
  "data-slot": "dialog-description",
2170
2195
  className: q("text-muted-foreground text-sm", e),
@@ -2173,7 +2198,7 @@ function Hn({ className: e, ...t }) {
2173
2198
  }
2174
2199
  //#endregion
2175
2200
  //#region src/components/ChatConversation/MessageBubble/MessageAttachments.tsx
2176
- var Un = [
2201
+ var Jn = [
2177
2202
  "png",
2178
2203
  "jpg",
2179
2204
  "jpeg",
@@ -2182,17 +2207,17 @@ var Un = [
2182
2207
  "svg",
2183
2208
  "bmp",
2184
2209
  "avif"
2185
- ], Wn = (e) => {
2210
+ ], Yn = (e) => {
2186
2211
  let t = (e || "").toLowerCase();
2187
- return Un.includes(t) ? /* @__PURE__ */ U(fe, { size: 15 }) : U(t === "url" ? me : se, { size: 15 });
2188
- }, Gn = ({ file: e }) => {
2212
+ return Jn.includes(t) ? /* @__PURE__ */ U(fe, { size: 15 }) : U(t === "url" ? me : ce, { size: 15 });
2213
+ }, Xn = ({ file: e }) => {
2189
2214
  let { deleteAttachedFile: t } = J(), [n, r] = p(!1), [i, a] = p(!1);
2190
2215
  return /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ W("div", {
2191
2216
  className: "group inline-flex max-w-full items-center gap-2 rounded-lg border border-border bg-secondary/40 py-1.5 pl-2.5 pr-1.5 text-sm",
2192
2217
  children: [
2193
2218
  /* @__PURE__ */ U("span", {
2194
2219
  className: "text-muted-foreground",
2195
- children: Wn(e.fileExtension)
2220
+ children: Yn(e.fileExtension)
2196
2221
  }),
2197
2222
  /* @__PURE__ */ U("span", {
2198
2223
  className: "min-w-0 truncate font-medium text-foreground",
@@ -2211,19 +2236,19 @@ var Un = [
2211
2236
  children: /* @__PURE__ */ U(Ne, { size: 14 })
2212
2237
  })
2213
2238
  ]
2214
- }), /* @__PURE__ */ U(In, {
2239
+ }), /* @__PURE__ */ U(Vn, {
2215
2240
  open: n,
2216
2241
  onOpenChange: (e) => {
2217
2242
  i || r(e);
2218
2243
  },
2219
- children: /* @__PURE__ */ W(Bn, {
2244
+ children: /* @__PURE__ */ W(Gn, {
2220
2245
  className: "w-full max-w-md rounded-2xl",
2221
2246
  children: [
2222
- /* @__PURE__ */ U(Vn, {
2247
+ /* @__PURE__ */ U(Kn, {
2223
2248
  className: "text-lg font-medium leading-6",
2224
2249
  children: "Delete file"
2225
2250
  }),
2226
- /* @__PURE__ */ W(Hn, {
2251
+ /* @__PURE__ */ W(qn, {
2227
2252
  className: "text-sm text-muted-foreground",
2228
2253
  children: [
2229
2254
  "Are you sure you want to delete",
@@ -2263,10 +2288,10 @@ var Un = [
2263
2288
  ]
2264
2289
  })
2265
2290
  })] });
2266
- }, Kn = ({ files: e }) => !e || e.length === 0 ? null : /* @__PURE__ */ U("div", {
2291
+ }, Zn = ({ files: e }) => !e || e.length === 0 ? null : /* @__PURE__ */ U("div", {
2267
2292
  className: "ml-10 mt-2 flex flex-wrap gap-2",
2268
- children: e.map((e) => /* @__PURE__ */ U(Gn, { file: e }, e.fileId))
2269
- }), qn = ({ section: e, isExpanded: t, setIsExpanded: n, isEditing: r, setIsEditing: i, editText: a, setEditText: o, handleEditSubmit: s, copiedUserMsg: c, handleCopyUserMsg: l }) => {
2293
+ children: e.map((e) => /* @__PURE__ */ U(Xn, { file: e }, e.fileId))
2294
+ }), Qn = ({ section: e, isExpanded: t, setIsExpanded: n, isEditing: r, setIsEditing: i, editText: a, setEditText: o, handleEditSubmit: s, copiedUserMsg: c, handleCopyUserMsg: l }) => {
2270
2295
  let u = f(null);
2271
2296
  return /* @__PURE__ */ W("div", {
2272
2297
  className: "w-full pt-8 break-words",
@@ -2276,7 +2301,7 @@ var Un = [
2276
2301
  className: "flex items-center gap-3 group text-left w-full",
2277
2302
  children: [/* @__PURE__ */ U("div", {
2278
2303
  className: "flex-shrink-0 p-1.5 rounded-lg bg-secondary/50 group-hover:bg-secondary transition-colors duration-200",
2279
- children: U(t ? j : ee, {
2304
+ children: U(t ? j : M, {
2280
2305
  size: 18,
2281
2306
  className: "text-muted-foreground group-hover:text-foreground transition-colors"
2282
2307
  })
@@ -2289,7 +2314,7 @@ var Un = [
2289
2314
  className: "flex items-center gap-0.5 mt-1 ml-10",
2290
2315
  children: [
2291
2316
  (() => {
2292
- let t = Ot(e.userMessage.createdAt);
2317
+ let t = Nt(e.userMessage.createdAt);
2293
2318
  return t ? /* @__PURE__ */ U("time", {
2294
2319
  dateTime: new Date(e.userMessage.createdAt).toISOString(),
2295
2320
  className: "mr-1.5 text-xs text-muted-foreground tabular-nums select-none",
@@ -2328,7 +2353,7 @@ var Un = [
2328
2353
  })] })
2329
2354
  ]
2330
2355
  }),
2331
- /* @__PURE__ */ U(Kn, { files: e.userMessage.files }),
2356
+ /* @__PURE__ */ U(Zn, { files: e.userMessage.files }),
2332
2357
  r && /* @__PURE__ */ W("div", {
2333
2358
  className: "mt-3 ml-10 flex flex-col gap-2",
2334
2359
  children: [/* @__PURE__ */ U("textarea", {
@@ -2359,19 +2384,19 @@ var Un = [
2359
2384
  };
2360
2385
  //#endregion
2361
2386
  //#region src/ui/dropdown-menu.tsx
2362
- function Jn({ ...e }) {
2387
+ function $n({ ...e }) {
2363
2388
  return /* @__PURE__ */ U(K.Root, {
2364
2389
  "data-slot": "dropdown-menu",
2365
2390
  ...e
2366
2391
  });
2367
2392
  }
2368
- function Yn({ ...e }) {
2393
+ function er({ ...e }) {
2369
2394
  return /* @__PURE__ */ U(K.Trigger, {
2370
2395
  "data-slot": "dropdown-menu-trigger",
2371
2396
  ...e
2372
2397
  });
2373
2398
  }
2374
- function Xn({ className: e, sideOffset: t = 4, ...n }) {
2399
+ function tr({ className: e, sideOffset: t = 4, ...n }) {
2375
2400
  return /* @__PURE__ */ U(K.Portal, { children: /* @__PURE__ */ U(K.Content, {
2376
2401
  "data-slot": "dropdown-menu-content",
2377
2402
  sideOffset: t,
@@ -2388,7 +2413,7 @@ function Q({ className: e, inset: t, variant: n = "default", ...r }) {
2388
2413
  ...r
2389
2414
  });
2390
2415
  }
2391
- function Zn({ className: e, children: t, checked: n, ...r }) {
2416
+ function nr({ className: e, children: t, checked: n, ...r }) {
2392
2417
  return /* @__PURE__ */ W(K.CheckboxItem, {
2393
2418
  "data-slot": "dropdown-menu-checkbox-item",
2394
2419
  className: q("focus:bg-accent focus:text-accent-foreground relative flex cursor-default items-center gap-2 rounded-2xl py-1.5 pr-2 pl-8 text-sm outline-hidden select-none data-[disabled]:pointer-events-none data-[disabled]:opacity-50 [&_svg]:pointer-events-none [&_svg]:shrink-0 [&_svg:not([class*='size-'])]:size-4", e),
@@ -2400,7 +2425,7 @@ function Zn({ className: e, children: t, checked: n, ...r }) {
2400
2425
  }), t]
2401
2426
  });
2402
2427
  }
2403
- function Qn({ className: e, inset: t, ...n }) {
2428
+ function rr({ className: e, inset: t, ...n }) {
2404
2429
  return /* @__PURE__ */ U(K.Label, {
2405
2430
  "data-slot": "dropdown-menu-label",
2406
2431
  "data-inset": t,
@@ -2408,29 +2433,29 @@ function Qn({ className: e, inset: t, ...n }) {
2408
2433
  ...n
2409
2434
  });
2410
2435
  }
2411
- function $n({ className: e, ...t }) {
2436
+ function ir({ className: e, ...t }) {
2412
2437
  return /* @__PURE__ */ U(K.Separator, {
2413
2438
  "data-slot": "dropdown-menu-separator",
2414
2439
  className: q("bg-border -mx-1 my-1 h-px", e),
2415
2440
  ...t
2416
2441
  });
2417
2442
  }
2418
- function er({ ...e }) {
2443
+ function ar({ ...e }) {
2419
2444
  return /* @__PURE__ */ U(K.Sub, {
2420
2445
  "data-slot": "dropdown-menu-sub",
2421
2446
  ...e
2422
2447
  });
2423
2448
  }
2424
- function tr({ className: e, inset: t, children: n, ...r }) {
2449
+ function or({ className: e, inset: t, children: n, ...r }) {
2425
2450
  return /* @__PURE__ */ W(K.SubTrigger, {
2426
2451
  "data-slot": "dropdown-menu-sub-trigger",
2427
2452
  "data-inset": t,
2428
2453
  className: q("focus:bg-accent focus:text-accent-foreground data-[state=open]:bg-accent data-[state=open]:text-accent-foreground flex cursor-default items-center rounded-2xl px-2 py-1.5 text-sm outline-hidden select-none data-[inset]:pl-8", e),
2429
2454
  ...r,
2430
- children: [n, /* @__PURE__ */ U(M, { className: "ml-auto size-4" })]
2455
+ children: [n, /* @__PURE__ */ U(N, { className: "ml-auto size-4" })]
2431
2456
  });
2432
2457
  }
2433
- function nr({ className: e, ...t }) {
2458
+ function sr({ className: e, ...t }) {
2434
2459
  return /* @__PURE__ */ U(K.SubContent, {
2435
2460
  "data-slot": "dropdown-menu-sub-content",
2436
2461
  className: q("bg-card text-popover-foreground data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:zoom-out-95 data-[state=open]:zoom-in-95 data-[side=bottom]:slide-in-from-top-2 data-[side=left]:slide-in-from-right-2 data-[side=right]:slide-in-from-left-2 data-[side=top]:slide-in-from-bottom-2 z-50 min-w-[8rem] origin-(--radix-dropdown-menu-content-transform-origin) overflow-hidden rounded-2xl border p-1 shadow-lg", e),
@@ -2439,7 +2464,7 @@ function nr({ className: e, ...t }) {
2439
2464
  }
2440
2465
  //#endregion
2441
2466
  //#region src/components/MessageActions/CopyMessageButton.tsx
2442
- var rr = ({ section: e, initialMessage: t }) => {
2467
+ var cr = ({ section: e, initialMessage: t }) => {
2443
2468
  let [n, r] = p(!1);
2444
2469
  return /* @__PURE__ */ W(Y, { children: [/* @__PURE__ */ U(X, {
2445
2470
  asChild: !0,
@@ -2458,19 +2483,19 @@ var rr = ({ section: e, initialMessage: t }) => {
2458
2483
  };
2459
2484
  //#endregion
2460
2485
  //#region src/ui/popover.tsx
2461
- function ir({ ...e }) {
2486
+ function lr({ ...e }) {
2462
2487
  return /* @__PURE__ */ U(yt.Root, {
2463
2488
  "data-slot": "popover",
2464
2489
  ...e
2465
2490
  });
2466
2491
  }
2467
- function ar({ ...e }) {
2492
+ function ur({ ...e }) {
2468
2493
  return /* @__PURE__ */ U(yt.Trigger, {
2469
2494
  "data-slot": "popover-trigger",
2470
2495
  ...e
2471
2496
  });
2472
2497
  }
2473
- function or({ className: e, align: t = "center", sideOffset: n = 4, container: r, ...i }) {
2498
+ function dr({ className: e, align: t = "center", sideOffset: n = 4, container: r, ...i }) {
2474
2499
  return /* @__PURE__ */ U(yt.Portal, {
2475
2500
  container: r,
2476
2501
  children: /* @__PURE__ */ U(yt.Content, {
@@ -2487,9 +2512,9 @@ function or({ className: e, align: t = "center", sideOffset: n = 4, container: r
2487
2512
  var $ = {
2488
2513
  Plus: xe,
2489
2514
  Paperclip: ve,
2490
- Cloud: L,
2515
+ Cloud: te,
2491
2516
  Upload: Pe,
2492
- File: ie,
2517
+ File: oe,
2493
2518
  SquarePen: Oe,
2494
2519
  Thinking: (e) => /* @__PURE__ */ U("svg", {
2495
2520
  width: "20",
@@ -2503,7 +2528,7 @@ var $ = {
2503
2528
  SelectArrow: j,
2504
2529
  ArrowUp: w,
2505
2530
  X: Le,
2506
- FileText: se,
2531
+ FileText: ce,
2507
2532
  Loader2: V,
2508
2533
  Check: k,
2509
2534
  Archive: S,
@@ -2518,7 +2543,7 @@ var $ = {
2518
2543
  ...e,
2519
2544
  children: /* @__PURE__ */ U("path", { d: "M10.3857 2.50977C14.3486 2.71054 17.5 5.98724 17.5 10C17.5 14.1421 14.1421 17.5 10 17.5C5.85786 17.5 2.5 14.1421 2.5 10C2.5 9.72386 2.72386 9.5 3 9.5C3.27614 9.5 3.5 9.72386 3.5 10C3.5 13.5899 6.41015 16.5 10 16.5C13.5899 16.5 16.5 13.5899 16.5 10C16.5 6.5225 13.7691 3.68312 10.335 3.50879L10 3.5L9.89941 3.49023C9.67145 3.44371 9.5 3.24171 9.5 3C9.5 2.72386 9.72386 2.5 10 2.5L10.3857 2.50977ZM10 5.5C10.2761 5.5 10.5 5.72386 10.5 6V9.69043L13.2236 11.0527C13.4706 11.1762 13.5708 11.4766 13.4473 11.7236C13.3392 11.9397 13.0957 12.0435 12.8711 11.9834L12.7764 11.9473L9.77637 10.4473C9.60698 10.3626 9.5 10.1894 9.5 10V6C9.5 5.72386 9.72386 5.5 10 5.5ZM3.66211 6.94141C4.0273 6.94159 4.32303 7.23735 4.32324 7.60254C4.32324 7.96791 4.02743 8.26446 3.66211 8.26465C3.29663 8.26465 3 7.96802 3 7.60254C3.00021 7.23723 3.29676 6.94141 3.66211 6.94141ZM4.95605 4.29395C5.32146 4.29404 5.61719 4.59063 5.61719 4.95605C5.6171 5.3214 5.3214 5.61709 4.95605 5.61719C4.59063 5.61719 4.29403 5.32146 4.29395 4.95605C4.29395 4.59057 4.59057 4.29395 4.95605 4.29395ZM7.60254 3C7.96802 3 8.26465 3.29663 8.26465 3.66211C8.26446 4.02743 7.96791 4.32324 7.60254 4.32324C7.23736 4.32302 6.94159 4.0273 6.94141 3.66211C6.94141 3.29676 7.23724 3.00022 7.60254 3Z" })
2520
2545
  })
2521
- }, sr = ({ messageId: e }) => {
2546
+ }, fr = ({ messageId: e }) => {
2522
2547
  let { rewrite: t, chatModelProvider: n, setChatModelProvider: r } = J(), [i, a] = p([]), [o, s] = p(!0), [c, l] = p(""), [f, m] = p(!1);
2523
2548
  u(() => {
2524
2549
  f && (async () => {
@@ -2553,12 +2578,12 @@ var $ = {
2553
2578
  key: i
2554
2579
  }), localStorage.setItem("chatModelProviderId", n), localStorage.setItem("chatModelKey", i), m(!1), t(e);
2555
2580
  };
2556
- return /* @__PURE__ */ W(ir, {
2581
+ return /* @__PURE__ */ W(lr, {
2557
2582
  open: f,
2558
2583
  onOpenChange: m,
2559
2584
  children: [/* @__PURE__ */ W(Y, { children: [/* @__PURE__ */ U(X, {
2560
2585
  asChild: !0,
2561
- children: /* @__PURE__ */ U(ar, {
2586
+ children: /* @__PURE__ */ U(ur, {
2562
2587
  asChild: !0,
2563
2588
  children: /* @__PURE__ */ U("button", {
2564
2589
  className: "p-2 text-muted-foreground rounded-full backdrop-blur-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition duration-200 hover:text-foreground",
@@ -2568,7 +2593,7 @@ var $ = {
2568
2593
  }), /* @__PURE__ */ W(Z, {
2569
2594
  side: "bottom",
2570
2595
  children: ["Rewrite with ", g]
2571
- })] }), /* @__PURE__ */ U(or, {
2596
+ })] }), /* @__PURE__ */ U(dr, {
2572
2597
  className: "w-[280px] p-0",
2573
2598
  align: "start",
2574
2599
  side: "top",
@@ -2619,7 +2644,7 @@ var $ = {
2619
2644
  className: q("px-3 py-2 flex items-center justify-between text-start duration-200 cursor-pointer transition rounded-xl group", n?.providerId === e.id && n?.key === t.key ? "bg-sky-50 dark:bg-sky-500/10" : "hover:bg-bg-100 dark:hover:bg-[#30302E]"),
2620
2645
  children: [/* @__PURE__ */ W("div", {
2621
2646
  className: "flex items-center space-x-2.5 min-w-0 flex-1",
2622
- children: [/* @__PURE__ */ U(te, {
2647
+ children: [/* @__PURE__ */ U(ne, {
2623
2648
  size: 14,
2624
2649
  className: q("shrink-0", n?.providerId === e.id && n?.key === t.key ? "text-sky-500" : "text-text-400 dark:text-[#999999] group-hover:text-text-300 dark:group-hover:text-[#B4B4B4]")
2625
2650
  }), /* @__PURE__ */ U("p", {
@@ -2636,10 +2661,10 @@ var $ = {
2636
2661
  })
2637
2662
  })]
2638
2663
  });
2639
- }, cr = /* @__PURE__ */ new Map();
2640
- function lr(e) {
2664
+ }, pr = /* @__PURE__ */ new Map();
2665
+ function mr(e) {
2641
2666
  if (typeof window > "u") return Promise.reject(/* @__PURE__ */ Error("CDN scripts require a browser environment"));
2642
- let t = cr.get(e);
2667
+ let t = pr.get(e);
2643
2668
  if (t) return t;
2644
2669
  let n = new Promise((t, n) => {
2645
2670
  let r = document.querySelector(`script[data-cdn-loader="${e}"]`);
@@ -2651,34 +2676,34 @@ function lr(e) {
2651
2676
  i.src = e, i.async = !0, i.dataset.cdnLoader = e, i.onload = () => {
2652
2677
  i.dataset.loaded = "true", t();
2653
2678
  }, i.onerror = () => {
2654
- cr.delete(e), n(/* @__PURE__ */ Error(`Failed to load ${e}`));
2679
+ pr.delete(e), n(/* @__PURE__ */ Error(`Failed to load ${e}`));
2655
2680
  }, document.head.appendChild(i);
2656
2681
  });
2657
- return cr.set(e, n), n;
2682
+ return pr.set(e, n), n;
2658
2683
  }
2659
- var ur = "https://cdn.jsdelivr.net/npm/jspdf@2.5.2/dist/jspdf.umd.min.js", dr = "https://cdn.jsdelivr.net/npm/docx@9.5.1/build/index.umd.min.js";
2660
- async function fr() {
2661
- await lr(ur);
2684
+ var hr = "https://cdn.jsdelivr.net/npm/jspdf@2.5.2/dist/jspdf.umd.min.js", gr = "https://cdn.jsdelivr.net/npm/docx@9.5.1/build/index.umd.min.js";
2685
+ async function _r() {
2686
+ await mr(hr);
2662
2687
  let e = window.jspdf?.jsPDF;
2663
2688
  if (!e) throw Error("jsPDF global not found after CDN load");
2664
2689
  return e;
2665
2690
  }
2666
- async function pr() {
2667
- await lr(dr);
2691
+ async function vr() {
2692
+ await mr(gr);
2668
2693
  let e = window.docx;
2669
2694
  if (!e) throw Error("docx global not found after CDN load");
2670
2695
  return e;
2671
2696
  }
2672
2697
  //#endregion
2673
2698
  //#region src/lib/export.ts
2674
- async function mr(e, t) {
2675
- vr(`# ${e}\n\n${new xt({
2699
+ async function yr(e, t) {
2700
+ Cr(`# ${e}\n\n${new xt({
2676
2701
  headingStyle: "atx",
2677
2702
  codeBlockStyle: "fenced"
2678
2703
  }).turndown(t)}`, `${e}.md`, "text/markdown");
2679
2704
  }
2680
- async function hr(e, t) {
2681
- let { Document: n, Paragraph: r, TextRun: i, HeadingLevel: a, Packer: o } = await pr(), s = new DOMParser().parseFromString(t, "text/html"), c = [];
2705
+ async function br(e, t) {
2706
+ let { Document: n, Paragraph: r, TextRun: i, HeadingLevel: a, Packer: o } = await vr(), s = new DOMParser().parseFromString(t, "text/html"), c = [];
2682
2707
  c.push(new r({
2683
2708
  text: e,
2684
2709
  heading: a.HEADING_1,
@@ -2752,14 +2777,14 @@ async function hr(e, t) {
2752
2777
  }] }), d = await o.toBlob(u), f = URL.createObjectURL(d), p = document.createElement("a");
2753
2778
  p.href = f, p.download = `${e}.docx`, p.click(), URL.revokeObjectURL(f);
2754
2779
  }
2755
- async function gr(e, t) {
2780
+ async function xr(e, t) {
2756
2781
  let n = document.createElement("div");
2757
2782
  n.style.position = "absolute", n.style.left = "-9999px", n.style.width = "210mm", n.style.padding = "20mm", n.style.backgroundColor = "white", n.style.fontFamily = "Arial, sans-serif", n.style.fontSize = "12pt", n.style.lineHeight = "1.6", n.innerHTML = `
2758
2783
  <h1 style="font-size: 24pt; margin-bottom: 20px;">${e}</h1>
2759
2784
  ${t}
2760
2785
  `, document.body.appendChild(n);
2761
2786
  try {
2762
- let t = await fr(), r = await bt(n, {
2787
+ let t = await _r(), r = await bt(n, {
2763
2788
  scale: 2,
2764
2789
  useCORS: !0,
2765
2790
  logging: !1
@@ -2774,7 +2799,7 @@ async function gr(e, t) {
2774
2799
  document.body.removeChild(n);
2775
2800
  }
2776
2801
  }
2777
- async function _r(e, t) {
2802
+ async function Sr(e, t) {
2778
2803
  try {
2779
2804
  let n = `${e}\n\n${new xt().turndown(t)}`;
2780
2805
  await navigator.clipboard.writeText(n), window.open("https://docs.google.com/document/create", "_blank"), alert("Content copied to clipboard! Paste it into the new Google Doc.");
@@ -2782,19 +2807,19 @@ async function _r(e, t) {
2782
2807
  console.error("Failed to export to Google Docs:", e), alert("Failed to copy content to clipboard. Please try again.");
2783
2808
  }
2784
2809
  }
2785
- function vr(e, t, n) {
2810
+ function Cr(e, t, n) {
2786
2811
  let r = new Blob([e], { type: n }), i = URL.createObjectURL(r), a = document.createElement("a");
2787
2812
  a.href = i, a.download = t, a.click(), URL.revokeObjectURL(i);
2788
2813
  }
2789
2814
  //#endregion
2790
2815
  //#region src/components/ChatConversation/MessageBubble/AssistantMessageActions.tsx
2791
- var yr = ({ section: e, speechStatus: t, start: n, stop: r, handleOpenInLLM: i }) => e.assistantMessage ? /* @__PURE__ */ U("div", {
2816
+ var wr = ({ section: e, speechStatus: t, start: n, stop: r, handleOpenInLLM: i }) => e.assistantMessage ? /* @__PURE__ */ U("div", {
2792
2817
  className: "flex flex-row items-center justify-end w-full text-foreground py-4 -mx-2",
2793
2818
  children: /* @__PURE__ */ W("div", {
2794
2819
  className: "flex flex-row items-center space-x-1",
2795
2820
  children: [
2796
- /* @__PURE__ */ U(sr, { messageId: e.assistantMessage.messageId }),
2797
- /* @__PURE__ */ U(rr, {
2821
+ /* @__PURE__ */ U(fr, { messageId: e.assistantMessage.messageId }),
2822
+ /* @__PURE__ */ U(cr, {
2798
2823
  initialMessage: e.assistantMessage.content,
2799
2824
  section: e
2800
2825
  }),
@@ -2811,53 +2836,53 @@ var yr = ({ section: e, speechStatus: t, start: n, stop: r, handleOpenInLLM: i }
2811
2836
  side: "bottom",
2812
2837
  children: t === "started" ? "Stop" : "Read aloud"
2813
2838
  })] }),
2814
- /* @__PURE__ */ W(Jn, { children: [/* @__PURE__ */ W(Y, { children: [/* @__PURE__ */ U(X, {
2839
+ /* @__PURE__ */ W($n, { children: [/* @__PURE__ */ W(Y, { children: [/* @__PURE__ */ U(X, {
2815
2840
  asChild: !0,
2816
- children: /* @__PURE__ */ U(Yn, {
2841
+ children: /* @__PURE__ */ U(er, {
2817
2842
  asChild: !0,
2818
2843
  children: /* @__PURE__ */ U("button", {
2819
2844
  className: "p-2 text-muted-foreground rounded-full backdrop-blur-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition duration-200 hover:text-foreground",
2820
- children: /* @__PURE__ */ U(ne, { size: 18 })
2845
+ children: /* @__PURE__ */ U(re, { size: 18 })
2821
2846
  })
2822
2847
  })
2823
2848
  }), /* @__PURE__ */ U(Z, {
2824
2849
  side: "bottom",
2825
2850
  children: "Export"
2826
- })] }), /* @__PURE__ */ W(Xn, {
2851
+ })] }), /* @__PURE__ */ W(tr, {
2827
2852
  align: "end",
2828
2853
  side: "top",
2829
2854
  children: [
2830
2855
  /* @__PURE__ */ W(Q, {
2831
- onClick: () => mr(e.userMessage.content, e.assistantMessage.content),
2832
- children: [/* @__PURE__ */ U(se, { size: 16 }), "Markdown"]
2856
+ onClick: () => yr(e.userMessage.content, e.assistantMessage.content),
2857
+ children: [/* @__PURE__ */ U(ce, { size: 16 }), "Markdown"]
2833
2858
  }),
2834
2859
  /* @__PURE__ */ W(Q, {
2835
- onClick: () => gr(e.userMessage.content, e.assistantMessage.content),
2836
- children: [/* @__PURE__ */ U(ce, { size: 16 }), "PDF"]
2860
+ onClick: () => xr(e.userMessage.content, e.assistantMessage.content),
2861
+ children: [/* @__PURE__ */ U(B, { size: 16 }), "PDF"]
2837
2862
  }),
2838
2863
  /* @__PURE__ */ W(Q, {
2839
- onClick: () => hr(e.userMessage.content, e.assistantMessage.content),
2840
- children: [/* @__PURE__ */ U(ae, { size: 16 }), "DOCX"]
2864
+ onClick: () => br(e.userMessage.content, e.assistantMessage.content),
2865
+ children: [/* @__PURE__ */ U(se, { size: 16 }), "DOCX"]
2841
2866
  }),
2842
2867
  /* @__PURE__ */ W(Q, {
2843
- onClick: () => _r(e.userMessage.content, e.assistantMessage.content),
2844
- children: [/* @__PURE__ */ U(oe, { size: 16 }), "Google Docs"]
2868
+ onClick: () => Sr(e.userMessage.content, e.assistantMessage.content),
2869
+ children: [/* @__PURE__ */ U(z, { size: 16 }), "Google Docs"]
2845
2870
  })
2846
2871
  ]
2847
2872
  })] }),
2848
- /* @__PURE__ */ W(Jn, { children: [/* @__PURE__ */ W(Y, { children: [/* @__PURE__ */ U(X, {
2873
+ /* @__PURE__ */ W($n, { children: [/* @__PURE__ */ W(Y, { children: [/* @__PURE__ */ U(X, {
2849
2874
  asChild: !0,
2850
- children: /* @__PURE__ */ U(Yn, {
2875
+ children: /* @__PURE__ */ U(er, {
2851
2876
  asChild: !0,
2852
2877
  children: /* @__PURE__ */ U("button", {
2853
2878
  className: "p-2 text-muted-foreground rounded-full backdrop-blur-md bg-white/10 dark:bg-black/10 hover:bg-white/20 dark:hover:bg-black/20 transition duration-200 hover:text-foreground",
2854
- children: /* @__PURE__ */ U(B, { size: 18 })
2879
+ children: /* @__PURE__ */ U(ie, { size: 18 })
2855
2880
  })
2856
2881
  })
2857
2882
  }), /* @__PURE__ */ U(Z, {
2858
2883
  side: "bottom",
2859
2884
  children: "Open in LLM"
2860
- })] }), /* @__PURE__ */ W(Xn, {
2885
+ })] }), /* @__PURE__ */ W(tr, {
2861
2886
  align: "end",
2862
2887
  side: "top",
2863
2888
  children: [
@@ -2885,7 +2910,7 @@ var yr = ({ section: e, speechStatus: t, start: n, stop: r, handleOpenInLLM: i }
2885
2910
  })] })
2886
2911
  ]
2887
2912
  })
2888
- }) : null, br = Ct("inline-flex items-center justify-center rounded-2xl border px-3 py-1.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden", {
2913
+ }) : null, Tr = Ct("inline-flex items-center justify-center rounded-2xl border px-3 py-1.5 text-xs font-medium w-fit whitespace-nowrap shrink-0 [&>svg]:size-3 gap-1 [&>svg]:pointer-events-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive transition-[color,box-shadow] overflow-hidden", {
2889
2914
  variants: { variant: {
2890
2915
  default: "border-transparent bg-primary text-primary-foreground [a&]:hover:bg-primary/90",
2891
2916
  secondary: "border-transparent bg-gray-100 text-gray-700 [a&]:hover:bg-gray-200 dark:bg-gray-800 dark:text-gray-300 dark:[a&]:hover:bg-gray-700",
@@ -2897,16 +2922,16 @@ var yr = ({ section: e, speechStatus: t, start: n, stop: r, handleOpenInLLM: i }
2897
2922
  } },
2898
2923
  defaultVariants: { variant: "default" }
2899
2924
  });
2900
- function xr({ className: e, variant: t, asChild: n = !1, ...r }) {
2925
+ function Er({ className: e, variant: t, asChild: n = !1, ...r }) {
2901
2926
  return /* @__PURE__ */ U(n ? St : "span", {
2902
2927
  "data-slot": "badge",
2903
- className: q(br({ variant: t }), e),
2928
+ className: q(Tr({ variant: t }), e),
2904
2929
  ...r
2905
2930
  });
2906
2931
  }
2907
2932
  //#endregion
2908
2933
  //#region src/components/ChatConversation/MessageBubble/FollowUpSuggestions.tsx
2909
- var Sr = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
2934
+ var Dr = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
2910
2935
  let i = f([]);
2911
2936
  return u(() => {
2912
2937
  e.suggestions && e.suggestions.length > 0 && (i.current = e.suggestions.slice(0, 5));
@@ -2928,7 +2953,7 @@ var Sr = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
2928
2953
  children: /* @__PURE__ */ W("div", {
2929
2954
  className: "flex items-center gap-3",
2930
2955
  children: [
2931
- /* @__PURE__ */ U(xr, {
2956
+ /* @__PURE__ */ U(Er, {
2932
2957
  variant: "secondary",
2933
2958
  className: "flex-shrink-0 h-6 w-6 p-0 flex items-center justify-center rounded-full text-sm font-semibold",
2934
2959
  children: t + 1
@@ -2946,12 +2971,12 @@ var Sr = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
2946
2971
  }, t))
2947
2972
  })
2948
2973
  });
2949
- }, Cr = ({ section: e, dividerRef: t, isLast: n }) => {
2974
+ }, Or = ({ section: e, dividerRef: t, isLast: n }) => {
2950
2975
  let { loading: r, sendMessage: i } = J(), [a, o] = p(!0), [s, c] = p(!1), [l, u] = p(!1), [d, f] = p(e.userMessage.content), m = () => {
2951
2976
  navigator.clipboard.writeText(e.userMessage.content), c(!0), setTimeout(() => c(!1), 1500);
2952
2977
  }, h = () => {
2953
2978
  d.trim() && (i(d.trim()), u(!1));
2954
- }, g = e.parsedAssistantMessage || "", _ = e.speechMessage || "", v = e.thinkingEnded, { speechStatus: b, start: x, stop: S } = on(_, { enableInterrupt: !0 }), C = (t) => {
2979
+ }, g = e.parsedAssistantMessage || "", _ = e.speechMessage || "", v = e.thinkingEnded, { speechStatus: b, start: x, stop: S } = dn(_, { enableInterrupt: !0 }), C = (t) => {
2955
2980
  if (!e.assistantMessage) return;
2956
2981
  let n = `${e.userMessage.content}\n\n${e.assistantMessage.content}`;
2957
2982
  navigator.clipboard.writeText(n);
@@ -2965,11 +2990,11 @@ var Sr = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
2965
2990
  r && window.open(`${r}${encodeURIComponent(n)}`, "_blank");
2966
2991
  }, w = { overrides: {
2967
2992
  think: {
2968
- component: Fn,
2993
+ component: Bn,
2969
2994
  props: { thinkingEnded: v }
2970
2995
  },
2971
2996
  citation: {
2972
- component: Nn,
2997
+ component: Rn,
2973
2998
  props: { sources: e.sourceMessage?.sources || [] }
2974
2999
  },
2975
3000
  table: { component: ({ children: e, ...t }) => /* @__PURE__ */ U("div", {
@@ -2983,7 +3008,7 @@ var Sr = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
2983
3008
  } };
2984
3009
  return /* @__PURE__ */ W("div", {
2985
3010
  className: "space-y-3",
2986
- children: [/* @__PURE__ */ U(qn, {
3011
+ children: [/* @__PURE__ */ U(Qn, {
2987
3012
  section: e,
2988
3013
  isExpanded: a,
2989
3014
  setIsExpanded: o,
@@ -3000,13 +3025,13 @@ var Sr = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
3000
3025
  ref: t,
3001
3026
  className: "flex flex-col space-y-6 w-full",
3002
3027
  children: [
3003
- e.searchingMessage && e.searchingMessage.queries.length > 0 && /* @__PURE__ */ U(Kt, {
3028
+ e.searchingMessage && e.searchingMessage.queries.length > 0 && /* @__PURE__ */ U(Zt, {
3004
3029
  queries: e.searchingMessage.queries,
3005
3030
  loading: r && n
3006
3031
  }),
3007
3032
  e.sourceMessage && e.sourceMessage.sources.length > 0 && /* @__PURE__ */ U("div", {
3008
3033
  className: "flex flex-col space-y-2",
3009
- children: /* @__PURE__ */ U(Ut, {
3034
+ children: /* @__PURE__ */ U(Jt, {
3010
3035
  sources: e.sourceMessage.sources,
3011
3036
  query: e.userMessage.content
3012
3037
  })
@@ -3019,14 +3044,14 @@ var Sr = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
3019
3044
  options: w,
3020
3045
  children: g
3021
3046
  }),
3022
- r && n ? null : /* @__PURE__ */ U(yr, {
3047
+ r && n ? null : /* @__PURE__ */ U(wr, {
3023
3048
  section: e,
3024
3049
  speechStatus: b,
3025
3050
  start: x,
3026
3051
  stop: S,
3027
3052
  handleOpenInLLM: C
3028
3053
  }),
3029
- /* @__PURE__ */ U(Sr, {
3054
+ /* @__PURE__ */ U(Dr, {
3030
3055
  section: e,
3031
3056
  isLast: n,
3032
3057
  loading: r,
@@ -3038,7 +3063,7 @@ var Sr = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
3038
3063
  })
3039
3064
  })]
3040
3065
  });
3041
- }, wr = (e) => {
3066
+ }, kr = (e) => {
3042
3067
  if (e === 0) return "0 Bytes";
3043
3068
  let t = 1024, n = [
3044
3069
  "Bytes",
@@ -3047,62 +3072,65 @@ var Sr = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
3047
3072
  "GB"
3048
3073
  ], r = Math.floor(Math.log(e) / Math.log(t));
3049
3074
  return parseFloat((e / t ** r).toFixed(2)) + " " + n[r];
3050
- }, Tr = ({ file: e, onRemove: t }) => /* @__PURE__ */ W("div", {
3051
- className: "relative group flex-shrink-0 w-24 h-24 rounded-xl overflow-hidden border border-bg-300 bg-bg-200 animate-fade-in transition-all hover:border-text-400",
3052
- children: [
3053
- e.type.startsWith("image/") && e.preview ? /* @__PURE__ */ W("div", {
3054
- className: "w-full h-full relative",
3055
- children: [
3056
- /* @__PURE__ */ U("img", {
3057
- src: e.preview,
3058
- alt: e.file.name,
3059
- className: "w-full h-full object-cover"
3060
- }),
3061
- /* @__PURE__ */ U("div", { className: "absolute inset-0 bg-black/20 group-hover:bg-black/0 transition-colors" }),
3062
- /* @__PURE__ */ U("span", {
3063
- className: "absolute bottom-1 left-1 px-1.5 py-0.5 rounded-md bg-black/60 text-white text-[10px] font-medium leading-none backdrop-blur-sm pointer-events-none",
3064
- title: e.file.name,
3065
- children: wr(e.file.size)
3066
- })
3067
- ]
3068
- }) : /* @__PURE__ */ W("div", {
3069
- className: "w-full h-full p-3 flex flex-col justify-between",
3070
- children: [/* @__PURE__ */ W("div", {
3071
- className: "flex items-center gap-2",
3072
- children: [/* @__PURE__ */ U("div", {
3073
- className: "p-1.5 bg-bg-300 rounded",
3074
- children: /* @__PURE__ */ U($.FileText, { className: "w-4 h-4 text-text-300" })
3075
- }), /* @__PURE__ */ U("span", {
3076
- className: "text-[10px] font-medium text-text-400 uppercase tracking-wider truncate",
3077
- children: e.file.name.split(".").pop()
3078
- })]
3079
- }), /* @__PURE__ */ W("div", {
3080
- className: "space-y-0.5",
3081
- children: [/* @__PURE__ */ U("p", {
3082
- className: "text-xs font-medium text-text-200 truncate",
3083
- title: e.file.name,
3084
- children: e.file.name
3085
- }), /* @__PURE__ */ U("p", {
3086
- className: "text-[10px] text-text-500",
3087
- children: wr(e.file.size)
3075
+ }, Ar = ({ file: e, onRemove: t }) => {
3076
+ let n = e.type.startsWith("image/") && e.preview;
3077
+ return /* @__PURE__ */ W("div", {
3078
+ className: "relative group flex-shrink-0 w-24 h-24 rounded-xl overflow-hidden border border-bg-300 bg-bg-200 animate-fade-in transition-all hover:border-text-400",
3079
+ children: [
3080
+ n ? /* @__PURE__ */ W("div", {
3081
+ className: "w-full h-full relative",
3082
+ children: [
3083
+ /* @__PURE__ */ U("img", {
3084
+ src: e.preview,
3085
+ alt: e.file.name,
3086
+ className: "w-full h-full object-cover"
3087
+ }),
3088
+ /* @__PURE__ */ U("div", { className: "absolute inset-0 bg-black/20 group-hover:bg-black/0 transition-colors" }),
3089
+ /* @__PURE__ */ U("span", {
3090
+ className: "absolute bottom-1 left-1 px-1.5 py-0.5 rounded-md bg-black/60 text-white text-[10px] font-medium leading-none backdrop-blur-sm pointer-events-none",
3091
+ title: e.file.name,
3092
+ children: kr(e.file.size)
3093
+ })
3094
+ ]
3095
+ }) : /* @__PURE__ */ W("div", {
3096
+ className: "w-full h-full p-3 flex flex-col justify-between",
3097
+ children: [/* @__PURE__ */ W("div", {
3098
+ className: "flex items-center gap-2",
3099
+ children: [/* @__PURE__ */ U("div", {
3100
+ className: "p-1.5 bg-bg-300 rounded",
3101
+ children: /* @__PURE__ */ U($.FileText, { className: "w-4 h-4 text-text-300" })
3102
+ }), /* @__PURE__ */ U("span", {
3103
+ className: "text-[10px] font-medium text-text-400 uppercase tracking-wider truncate",
3104
+ children: e.file.name.split(".").pop()
3105
+ })]
3106
+ }), /* @__PURE__ */ W("div", {
3107
+ className: "space-y-0.5",
3108
+ children: [/* @__PURE__ */ U("p", {
3109
+ className: "text-xs font-medium text-text-200 truncate",
3110
+ title: e.file.name,
3111
+ children: e.file.name
3112
+ }), /* @__PURE__ */ U("p", {
3113
+ className: "text-[10px] text-text-500",
3114
+ children: kr(e.file.size)
3115
+ })]
3088
3116
  })]
3089
- })]
3090
- }),
3091
- /* @__PURE__ */ U("button", {
3092
- onClick: () => t(e.id),
3093
- className: "absolute top-1 right-1 p-1 bg-black/50 hover:bg-black/70 rounded-full text-white opacity-0 group-hover:opacity-100 transition-opacity",
3094
- children: /* @__PURE__ */ U($.X, { className: "w-3 h-3" })
3095
- }),
3096
- e.uploadStatus === "uploading" && /* @__PURE__ */ U("div", {
3097
- className: "absolute inset-0 bg-black/40 flex items-center justify-center",
3098
- children: /* @__PURE__ */ U($.Loader2, { className: "w-5 h-5 text-white animate-spin" })
3099
- }),
3100
- e.uploadStatus === "error" && /* @__PURE__ */ U("div", {
3101
- className: "absolute inset-0 bg-red-900/60 flex items-center justify-center",
3102
- children: /* @__PURE__ */ U($.X, { className: "w-5 h-5 text-red-300" })
3103
- })
3104
- ]
3105
- }), Er = ({ content: e, onRemove: t }) => /* @__PURE__ */ W("div", {
3117
+ }),
3118
+ /* @__PURE__ */ U("button", {
3119
+ onClick: () => t(e.id),
3120
+ className: "absolute top-1 right-1 p-1 bg-black/50 hover:bg-black/70 rounded-full text-white opacity-0 group-hover:opacity-100 transition-opacity",
3121
+ children: /* @__PURE__ */ U($.X, { className: "w-3 h-3" })
3122
+ }),
3123
+ e.uploadStatus === "uploading" && /* @__PURE__ */ U("div", {
3124
+ className: "absolute inset-0 bg-black/40 flex items-center justify-center",
3125
+ children: /* @__PURE__ */ U($.Loader2, { className: "w-5 h-5 text-white animate-spin" })
3126
+ }),
3127
+ e.uploadStatus === "error" && /* @__PURE__ */ U("div", {
3128
+ className: "absolute inset-0 bg-red-900/60 flex items-center justify-center",
3129
+ children: /* @__PURE__ */ U($.X, { className: "w-5 h-5 text-red-300" })
3130
+ })
3131
+ ]
3132
+ });
3133
+ }, jr = ({ content: e, onRemove: t }) => /* @__PURE__ */ W("div", {
3106
3134
  className: "relative group flex-shrink-0 w-28 h-28 rounded-2xl overflow-hidden border border-[#E5E5E5] dark:border-[#30302E] bg-white dark:bg-[#20201F] animate-fade-in p-3 flex flex-col justify-between shadow-[0_1px_2px_rgba(0,0,0,0.05)]",
3107
3135
  children: [
3108
3136
  /* @__PURE__ */ U("div", {
@@ -3131,103 +3159,148 @@ var Sr = ({ section: e, isLast: t, loading: n, sendMessage: r }) => {
3131
3159
  });
3132
3160
  //#endregion
3133
3161
  //#region src/hooks/voice/useSpeechToTranscript.ts
3134
- function Dr(e, t) {
3135
- let [n, r] = p(!1), i = f(null), a = f(null), o = f(null), s = f([]), c = f(!1), l = f(!1), d = typeof window < "u" ? window.SpeechRecognition || window.webkitSpeechRecognition : null, m = () => {
3136
- let e = a.current;
3137
- e && e.state !== "inactive" ? e.stop() : (o.current?.getTracks().forEach((e) => e.stop()), o.current = null, a.current = null, r(!1), t());
3138
- }, h = async (e) => {
3162
+ function Mr() {
3163
+ return typeof window > "u" ? !1 : !!(window.SpeechRecognition || window.webkitSpeechRecognition);
3164
+ }
3165
+ function Nr(e, t, n = {}) {
3166
+ let [r, i] = p(!1), [a, o] = p(""), [s, l] = p(""), [m, h] = p(0), g = f(null), _ = f(null), v = f([]), y = f({
3167
+ onTranscript: e,
3168
+ onEnd: t,
3169
+ onPartial: n.onPartial
3170
+ });
3171
+ y.current = {
3172
+ onTranscript: e,
3173
+ onEnd: t,
3174
+ onPartial: n.onPartial
3175
+ };
3176
+ let b = d(() => new Tt({
3177
+ engine: "webspeech",
3178
+ language: n.language ?? "en-US",
3179
+ onStateChange: i,
3180
+ onPartial: (e) => {
3181
+ o(e), e && (l(e), h((e) => e + 1)), y.current.onPartial?.(e);
3182
+ },
3183
+ onCommit: (e) => {
3184
+ o(""), l(e), h((e) => e + 1), y.current.onTranscript(e);
3185
+ },
3186
+ onError: () => {
3187
+ G.error("Speech recognition stopped unexpectedly.");
3188
+ }
3189
+ }), [n.language]), x = c(() => {
3190
+ let e = g.current;
3191
+ if (e && e.state !== "inactive") {
3192
+ e.stop();
3193
+ return;
3194
+ }
3195
+ _.current?.getTracks().forEach((e) => e.stop()), _.current = null, g.current = null;
3196
+ }, []), S = async (e) => {
3139
3197
  let t = new FormData();
3140
- return t.append("file", e, "speech-input.webm"), t.append("languageCode", "en"), ((await gt("/api/agent/transcript", {
3198
+ return t.append("file", e, "speech-input.webm"), t.append("languageCode", "en"), ((await gt("agent/transcript", {
3141
3199
  method: "POST",
3142
3200
  body: t
3143
3201
  }))?.text ?? "").trim();
3144
- }, g = async () => {
3202
+ }, C = c(async () => {
3145
3203
  if (typeof navigator > "u" || !navigator.mediaDevices?.getUserMedia || typeof MediaRecorder > "u") {
3146
- G.error("Speech input is not supported in this browser", { duration: 5e3 }), r(!1), t();
3204
+ G.error("Speech input is not supported in this browser", { duration: 5e3 }), i(!1), y.current.onEnd();
3147
3205
  return;
3148
3206
  }
3149
3207
  try {
3150
- let n = await navigator.mediaDevices.getUserMedia({ audio: !0 }), i = new MediaRecorder(n);
3151
- s.current = [], o.current = n, a.current = i, i.ondataavailable = (e) => {
3152
- e.data.size > 0 && s.current.push(e.data);
3153
- }, i.onstart = () => {
3154
- r(!0);
3155
- }, i.onstop = async () => {
3208
+ let e = await navigator.mediaDevices.getUserMedia({ audio: !0 }), t = new MediaRecorder(e);
3209
+ v.current = [], _.current = e, g.current = t, t.ondataavailable = (e) => {
3210
+ e.data.size > 0 && v.current.push(e.data);
3211
+ }, t.onstart = () => {
3212
+ i(!0);
3213
+ }, t.onstop = async () => {
3156
3214
  try {
3157
- let n = new Blob(s.current, { type: "audio/webm" });
3158
- if (s.current = [], o.current?.getTracks().forEach((e) => e.stop()), o.current = null, a.current = null, r(!1), n.size === 0) {
3159
- t();
3160
- return;
3161
- }
3162
- let i = await h(n);
3163
- i ? e(i) : G.error("No speech detected. Please try again.");
3215
+ let e = new Blob(v.current, { type: "audio/webm" });
3216
+ if (v.current = [], _.current?.getTracks().forEach((e) => e.stop()), _.current = null, g.current = null, i(!1), e.size === 0) return;
3217
+ let t = await S(e);
3218
+ t ? (l(t), h((e) => e + 1), y.current.onTranscript(t)) : G.error("No speech detected. Please try again.");
3164
3219
  } catch {
3165
3220
  G.error("Unable to transcribe audio.");
3166
3221
  } finally {
3167
- t();
3222
+ y.current.onEnd();
3168
3223
  }
3169
- }, i.start();
3224
+ }, t.start();
3170
3225
  } catch {
3171
- G.error("Microphone access is required for speech input."), r(!1), t();
3226
+ G.error("Microphone access is required for speech input."), i(!1), y.current.onEnd();
3172
3227
  }
3173
- }, _ = async () => {
3174
- if (n) {
3175
- i.current?.stop(), m();
3228
+ }, []), w = c(async () => {
3229
+ if (b.isListening()) {
3230
+ await b.stop(), o(""), y.current.onEnd();
3176
3231
  return;
3177
3232
  }
3178
- if (l.current = !1, c.current = !1, !d) {
3179
- await g();
3233
+ if (g.current) {
3234
+ x();
3180
3235
  return;
3181
3236
  }
3182
- let a = new d();
3183
- a.continuous = !1, a.interimResults = !1, a.lang = "en-US", a.onstart = () => r(!0), a.onresult = (t) => {
3184
- let n = t.results[0][0].transcript;
3185
- c.current = !0, e(n);
3186
- }, a.onend = async () => {
3187
- if (r(!1), i.current = null, l.current) {
3188
- l.current = !1;
3189
- return;
3190
- }
3191
- t();
3192
- }, a.onerror = async (e) => {
3193
- r(!1), i.current = null;
3194
- let t = e?.error;
3195
- if (!c.current && t !== "aborted") {
3196
- l.current = !0, await g();
3197
- return;
3198
- }
3199
- }, i.current = a;
3200
- try {
3201
- a.start();
3202
- } catch {
3203
- i.current = null, r(!1), await g();
3237
+ if (Mr()) {
3238
+ await b.start();
3239
+ return;
3204
3240
  }
3205
- };
3241
+ await C();
3242
+ }, [
3243
+ b,
3244
+ C,
3245
+ x
3246
+ ]);
3206
3247
  u(() => {
3207
3248
  let e = (e) => {
3208
- e.ctrlKey && e.key === "`" && (e.preventDefault(), _());
3209
- };
3210
- return window.addEventListener("keydown", e), () => {
3211
- window.removeEventListener("keydown", e), i.current?.stop(), m();
3249
+ e.ctrlKey && e.key === "`" && (e.preventDefault(), w());
3212
3250
  };
3213
- }, [n]);
3214
- let v = typeof navigator < "u" && !!navigator.mediaDevices?.getUserMedia && typeof MediaRecorder < "u";
3251
+ return window.addEventListener("keydown", e), () => window.removeEventListener("keydown", e);
3252
+ }, [w]), u(() => () => {
3253
+ b.stop(), x();
3254
+ }, [b, x]);
3255
+ let T = typeof navigator < "u" && !!navigator.mediaDevices?.getUserMedia && typeof MediaRecorder < "u";
3215
3256
  return {
3216
- isListening: n,
3217
- toggleSpeech: _,
3218
- isSpeechSupported: !!d || v
3257
+ isListening: r,
3258
+ toggleSpeech: w,
3259
+ isSpeechSupported: Mr() || T,
3260
+ partial: a,
3261
+ lastPhrase: s,
3262
+ phraseId: m
3219
3263
  };
3220
3264
  }
3221
3265
  //#endregion
3266
+ //#region src/lib/voiceAutoStart.ts
3267
+ var Pr = "voiceAutoStart", Fr = "voiceAutoStartTriggered", Ir = typeof window < "u";
3268
+ function Lr() {
3269
+ return Ir ? localStorage.getItem(Pr) === "true" : !1;
3270
+ }
3271
+ function Rr(e) {
3272
+ Ir && localStorage.setItem(Pr, String(e));
3273
+ }
3274
+ function zr() {
3275
+ Ir && localStorage.setItem(Fr, "true");
3276
+ }
3277
+ function Br({ enabled: e, isSpeechSupported: t, isListening: n }, r) {
3278
+ return e && t && !n && !r;
3279
+ }
3280
+ function Vr() {
3281
+ return Ir ? localStorage.getItem(Fr) === "true" : !1;
3282
+ }
3283
+ //#endregion
3284
+ //#region src/hooks/voice/useVoiceAutoStart.ts
3285
+ function Hr({ isSpeechSupported: e, isListening: t, toggleSpeech: n }) {
3286
+ u(() => {
3287
+ Br({
3288
+ enabled: Lr(),
3289
+ isSpeechSupported: e,
3290
+ isListening: t
3291
+ }, Vr()) && (zr(), n());
3292
+ }, [e]);
3293
+ }
3294
+ //#endregion
3222
3295
  //#region src/components/FileUpload/useFileHandling.ts
3223
- var Or = [
3296
+ var Ur = [
3224
3297
  "pdf",
3225
3298
  "docx",
3226
3299
  "txt",
3227
3300
  "md",
3228
3301
  "html",
3229
3302
  "htm"
3230
- ], kr = [
3303
+ ], Wr = [
3231
3304
  "png",
3232
3305
  "jpg",
3233
3306
  "jpeg",
@@ -3236,21 +3309,21 @@ var Or = [
3236
3309
  "svg",
3237
3310
  "bmp",
3238
3311
  "avif"
3239
- ], Ar = [...Or, ...kr], jr = 10, Mr = 50 * 1024 * 1024, Nr = (e, t) => {
3312
+ ], Gr = [...Ur, ...Wr], Kr = 10, qr = 52428800, Jr = (e, t) => {
3240
3313
  if (e && typeof e == "object") {
3241
3314
  let t = e.message ?? e.error ?? e.data?.message;
3242
3315
  if (typeof t == "string" && t.length > 0) return t;
3243
3316
  }
3244
3317
  return typeof e == "string" && e.length > 0 ? e : t;
3245
3318
  };
3246
- function Pr({ setMessage: e, contextFiles: t, contextFileIds: n, setContextFiles: r, setContextFileIds: i }) {
3319
+ function Yr({ setMessage: e, contextFiles: t, contextFileIds: n, setContextFiles: r, setContextFileIds: i }) {
3247
3320
  let [a, o] = p([]), [s, l] = p([]), [u, d] = p(!1), [f, m] = p(!1), h = c(async (e) => {
3248
3321
  let a = Array.from(e);
3249
- a.length > jr && (G.error(`You can attach up to ${jr} files at a time.`), a = a.slice(0, jr));
3250
- let s = a.filter((e) => e.size > Mr);
3251
- if (s.length > 0 && (G.error(`${s.map((e) => e.name).join(", ")} exceed${s.length === 1 ? "s" : ""} the 50 MB per-file limit.`), a = a.filter((e) => e.size <= Mr)), a.length === 0) return;
3322
+ a.length > Kr && (G.error(`You can attach up to ${Kr} files at a time.`), a = a.slice(0, Kr));
3323
+ let s = a.filter((e) => e.size > qr);
3324
+ if (s.length > 0 && (G.error(`${s.map((e) => e.name).join(", ")} exceed${s.length === 1 ? "s" : ""} the 50 MB per-file limit.`), a = a.filter((e) => e.size <= qr)), a.length === 0) return;
3252
3325
  let c = a.map((e) => {
3253
- let t = e.type.startsWith("image/") || /\.(jpg|jpeg|png|gif|webp|svg)$/i.test(e.name), n = e.name.split(".").pop()?.toLowerCase() ?? "", r = Ar.includes(n);
3326
+ let t = e.type.startsWith("image/") || /\.(jpg|jpeg|png|gif|webp|svg)$/i.test(e.name), n = e.name.split(".").pop()?.toLowerCase() ?? "", r = Gr.includes(n);
3254
3327
  return {
3255
3328
  id: Math.random().toString(36).substr(2, 9),
3256
3329
  file: e,
@@ -3260,7 +3333,7 @@ function Pr({ setMessage: e, contextFiles: t, contextFileIds: n, setContextFiles
3260
3333
  _ext: n
3261
3334
  };
3262
3335
  });
3263
- o((e) => [...e, ...c]), c.filter((e) => !Ar.includes(e._ext)).forEach((e) => {
3336
+ o((e) => [...e, ...c]), c.filter((e) => !Gr.includes(e._ext)).forEach((e) => {
3264
3337
  setTimeout(() => {
3265
3338
  o((t) => t.map((t) => t.id === e.id ? {
3266
3339
  ...t,
@@ -3268,16 +3341,16 @@ function Pr({ setMessage: e, contextFiles: t, contextFileIds: n, setContextFiles
3268
3341
  } : t));
3269
3342
  }, 600 + Math.random() * 600);
3270
3343
  });
3271
- let l = c.filter((e) => Ar.includes(e._ext));
3344
+ let l = c.filter((e) => Gr.includes(e._ext));
3272
3345
  if (l.length !== 0) try {
3273
3346
  let { data: e, error: a } = await dt({ body: { files: l.map((e) => e.file) } });
3274
- if (a || !e?.files) throw Error(Nr(a ?? e, "Upload failed."));
3347
+ if (a || !e?.files) throw Error(Jr(a ?? e, "Upload failed."));
3275
3348
  o((e) => e.map((e) => l.some((t) => t.id === e.id) ? {
3276
3349
  ...e,
3277
3350
  uploadStatus: "complete"
3278
3351
  } : e)), r([...t, ...e.files]), i([...n, ...e.files.map((e) => e.fileId)]);
3279
3352
  } catch (e) {
3280
- G.error(Nr(e, "Failed to upload files.")), o((e) => e.map((e) => l.some((t) => t.id === e.id) ? {
3353
+ G.error(Jr(e, "Failed to upload files.")), o((e) => e.map((e) => l.some((t) => t.id === e.id) ? {
3281
3354
  ...e,
3282
3355
  uploadStatus: "error"
3283
3356
  } : e));
@@ -3307,10 +3380,10 @@ function Pr({ setMessage: e, contextFiles: t, contextFileIds: n, setContextFiles
3307
3380
  headers: { "Content-Type": "application/json" },
3308
3381
  body: JSON.stringify({ url: a })
3309
3382
  })).json();
3310
- if (!e?.files || e.files.length === 0) throw Error(Nr(e, `Could not extract content from ${a}`));
3383
+ if (!e?.files || e.files.length === 0) throw Error(Jr(e, `Could not extract content from ${a}`));
3311
3384
  return r([...t, ...e.files]), i([...n, ...e.files.map((e) => e.fileId)]), G.success(`Added "${e.files[0].fileName}" as context.`), !0;
3312
3385
  } catch (e) {
3313
- return G.error(Nr(e, "Failed to extract URL.")), !1;
3386
+ return G.error(Jr(e, "Failed to extract URL.")), !1;
3314
3387
  } finally {
3315
3388
  m(!1);
3316
3389
  }
@@ -3357,24 +3430,24 @@ function Pr({ setMessage: e, contextFiles: t, contextFileIds: n, setContextFiles
3357
3430
  }
3358
3431
  //#endregion
3359
3432
  //#region src/components/FileUpload/GoogleDrivePicker.tsx
3360
- var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3433
+ var Xr = () => window.gapi, Zr = () => window.google, Qr = () => {
3361
3434
  let e = f(!1), n = f(!1);
3362
3435
  return u(() => {
3363
- Fr() ? n.current = !0 : (() => {
3436
+ Xr() ? n.current = !0 : (() => {
3364
3437
  let e = document.createElement("script");
3365
3438
  e.src = "https://apis.google.com/js/api.js", e.onload = () => {
3366
- Fr()?.load("client:picker", () => {
3439
+ Xr()?.load("client:picker", () => {
3367
3440
  n.current = !0;
3368
3441
  });
3369
3442
  }, document.body.appendChild(e);
3370
- })(), Ir()?.picker ? e.current = !0 : (() => {
3443
+ })(), Zr()?.picker ? e.current = !0 : (() => {
3371
3444
  let t = document.createElement("script");
3372
3445
  t.src = "https://www.google.com/jsapi", t.onload = () => {
3373
3446
  e.current = !0;
3374
3447
  }, document.body.appendChild(t);
3375
3448
  })();
3376
3449
  }, []), { openPicker: async (e, r, i) => {
3377
- let a = Ir();
3450
+ let a = Zr();
3378
3451
  if (!n.current || !a?.picker) {
3379
3452
  i?.("Google Picker API not loaded yet. Please try again.");
3380
3453
  return;
@@ -3391,7 +3464,7 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3391
3464
  i?.(e.message || "Failed to open Google Picker");
3392
3465
  }
3393
3466
  } };
3394
- }, Rr = () => {
3467
+ }, $r = () => {
3395
3468
  let { chatModelProvider: e, setChatModelProvider: t } = J(), [n, r] = p([]), [i, a] = p(!0), o = h();
3396
3469
  u(() => {
3397
3470
  (async () => {
@@ -3432,17 +3505,17 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3432
3505
  key: n
3433
3506
  }), localStorage.setItem("chatModelProviderId", e), localStorage.setItem("chatModelKey", n);
3434
3507
  };
3435
- return /* @__PURE__ */ W(er, { children: [/* @__PURE__ */ W(tr, {
3508
+ return /* @__PURE__ */ W(ar, { children: [/* @__PURE__ */ W(or, {
3436
3509
  className: "gap-2",
3437
3510
  children: [
3438
- /* @__PURE__ */ U(te, { className: "w-4 h-4 flex-shrink-0 text-sky-500" }),
3511
+ /* @__PURE__ */ U(ne, { className: "w-4 h-4 flex-shrink-0 text-sky-500" }),
3439
3512
  /* @__PURE__ */ U("span", { children: "Model" }),
3440
3513
  /* @__PURE__ */ U("span", {
3441
3514
  className: "ml-auto text-xs text-muted-foreground truncate max-w-[55px]",
3442
3515
  children: s
3443
3516
  })
3444
3517
  ]
3445
- }), /* @__PURE__ */ W(nr, {
3518
+ }), /* @__PURE__ */ W(sr, {
3446
3519
  className: "w-52 max-h-[400px] overflow-y-auto",
3447
3520
  children: [
3448
3521
  i ? /* @__PURE__ */ U("div", {
@@ -3452,7 +3525,7 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3452
3525
  className: "px-3 py-2 text-xs text-muted-foreground",
3453
3526
  children: "No models configured"
3454
3527
  }) : n.map((t, r) => /* @__PURE__ */ W("div", { children: [
3455
- /* @__PURE__ */ U(Qn, {
3528
+ /* @__PURE__ */ U(rr, {
3456
3529
  className: "text-[10px] uppercase tracking-wider text-muted-foreground font-medium",
3457
3530
  children: t.name
3458
3531
  }),
@@ -3460,7 +3533,7 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3460
3533
  onSelect: () => c(t.id, n.key),
3461
3534
  className: q("gap-2", e?.providerId === t.id && e?.key === n.key && "bg-secondary"),
3462
3535
  children: [
3463
- /* @__PURE__ */ U(te, { className: q("h-3.5 w-3.5 flex-shrink-0", e?.providerId === t.id && e?.key === n.key ? "text-sky-500" : "text-muted-foreground") }),
3536
+ /* @__PURE__ */ U(ne, { className: q("h-3.5 w-3.5 flex-shrink-0", e?.providerId === t.id && e?.key === n.key ? "text-sky-500" : "text-muted-foreground") }),
3464
3537
  /* @__PURE__ */ U("span", {
3465
3538
  className: "truncate",
3466
3539
  children: n.name
@@ -3479,9 +3552,9 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3479
3552
  })
3480
3553
  ]
3481
3554
  }, n.key)),
3482
- r < n.length - 1 && /* @__PURE__ */ U($n, {})
3555
+ r < n.length - 1 && /* @__PURE__ */ U(ir, {})
3483
3556
  ] }, t.id)),
3484
- /* @__PURE__ */ U($n, {}),
3557
+ /* @__PURE__ */ U(ir, {}),
3485
3558
  /* @__PURE__ */ W(Q, {
3486
3559
  onSelect: () => o.push("/settings?section=models"),
3487
3560
  className: "gap-2",
@@ -3489,7 +3562,133 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3489
3562
  })
3490
3563
  ]
3491
3564
  })] });
3492
- }, zr = [
3565
+ };
3566
+ //#endregion
3567
+ //#region src/components/ChatHistoryDropdown/useRecentChats.ts
3568
+ function ei(e) {
3569
+ let t = e.messages?.[e.messages.length - 1], n = t && "createdAt" in t ? t.createdAt : void 0;
3570
+ if (n) {
3571
+ let e = new Date(n).getTime();
3572
+ if (!Number.isNaN(e)) return new Date(e).toISOString();
3573
+ }
3574
+ return e.createdAt;
3575
+ }
3576
+ var ti = (e) => new Date(e.lastMessageAt || e.createdAt).getTime();
3577
+ function ni() {
3578
+ return hn().map((e) => ({
3579
+ ...e,
3580
+ messageCount: e.messages?.filter((e) => e.role === "user").length ?? 0,
3581
+ lastMessageAt: ei(e)
3582
+ }));
3583
+ }
3584
+ function ri(e = 10) {
3585
+ let [t, n] = p([]), [r, i] = p(!1), { isAuthenticated: a, isLoading: o } = Fn(), s = f(!1), l = c(async (e = !1) => {
3586
+ if (!o && !(s.current && !e)) {
3587
+ s.current = !0, i(!0);
3588
+ try {
3589
+ if (a) {
3590
+ let { data: e, error: t } = await rt();
3591
+ if (t) {
3592
+ n(ni());
3593
+ return;
3594
+ }
3595
+ n(Array.isArray(e?.chats) ? e.chats : []);
3596
+ } else n(ni());
3597
+ } catch (e) {
3598
+ console.error("Failed to fetch recent chats:", e), n([]);
3599
+ } finally {
3600
+ i(!1);
3601
+ }
3602
+ }
3603
+ }, [a, o]);
3604
+ return {
3605
+ recentChats: [...t].sort((e, t) => ti(t) - ti(e)).slice(0, e),
3606
+ loading: r,
3607
+ load: l
3608
+ };
3609
+ }
3610
+ //#endregion
3611
+ //#region src/lib/relative-time.ts
3612
+ function ii(e) {
3613
+ let t = new Date(e).getTime();
3614
+ if (Number.isNaN(t)) return "";
3615
+ let n = Math.round((Date.now() - t) / 1e3);
3616
+ if (n < 5) return "just now";
3617
+ if (n < 60) return `${n} sec`;
3618
+ let r = Math.round(n / 60);
3619
+ if (r < 60) return `${r} min`;
3620
+ let i = Math.round(r / 60);
3621
+ if (i < 24) return `${i} hr`;
3622
+ let a = Math.round(i / 24);
3623
+ if (a < 7) return `${a} day${a === 1 ? "" : "s"}`;
3624
+ let o = Math.round(a / 7);
3625
+ if (o < 5) return `${o} week${o === 1 ? "" : "s"}`;
3626
+ let s = Math.round(a / 30);
3627
+ if (s < 12) return `${s} month${s === 1 ? "" : "s"}`;
3628
+ let c = Math.round(a / 365);
3629
+ return `${c} year${c === 1 ? "" : "s"}`;
3630
+ }
3631
+ //#endregion
3632
+ //#region src/components/ChatHistoryDropdown/HistorySubmenu.tsx
3633
+ var ai = 10, oi = () => {
3634
+ let e = h(), { incognito: n, setIncognito: r } = J(), { recentChats: i, loading: a, load: o } = ri(ai), s = (e) => {
3635
+ r(e), G.success(e ? "Private mode on — messages won't be saved" : "Private mode off");
3636
+ }, c = (n) => {
3637
+ t.onOpenChat?.(n) || e.push(`/c/${n}`);
3638
+ };
3639
+ return /* @__PURE__ */ W(ar, {
3640
+ onOpenChange: (e) => {
3641
+ e && o();
3642
+ },
3643
+ children: [/* @__PURE__ */ W(or, {
3644
+ className: "gap-2",
3645
+ children: [/* @__PURE__ */ U(de, { className: "w-4 h-4 flex-shrink-0 text-muted-foreground" }), /* @__PURE__ */ U("span", { children: "History" })]
3646
+ }), /* @__PURE__ */ W(sr, {
3647
+ className: "w-64 max-h-[70vh] overflow-y-auto",
3648
+ children: [
3649
+ /* @__PURE__ */ W(nr, {
3650
+ checked: n,
3651
+ onCheckedChange: s,
3652
+ onSelect: (e) => e.preventDefault(),
3653
+ className: "gap-2",
3654
+ children: [/* @__PURE__ */ U(ae, { className: "w-4 h-4 flex-shrink-0 text-muted-foreground" }), /* @__PURE__ */ U("span", { children: "Private" })]
3655
+ }),
3656
+ /* @__PURE__ */ U(ir, {}),
3657
+ a ? /* @__PURE__ */ W(Q, {
3658
+ disabled: !0,
3659
+ className: "gap-2",
3660
+ children: [/* @__PURE__ */ U(V, { className: "w-3.5 h-3.5 animate-spin flex-shrink-0" }), /* @__PURE__ */ U("span", { children: "Loading…" })]
3661
+ }) : i.length === 0 ? /* @__PURE__ */ U(Q, {
3662
+ disabled: !0,
3663
+ children: /* @__PURE__ */ U("span", {
3664
+ className: "text-muted-foreground",
3665
+ children: "No recent chats"
3666
+ })
3667
+ }) : i.map((e) => {
3668
+ let t = ii(e.lastMessageAt || e.createdAt);
3669
+ return /* @__PURE__ */ W(Q, {
3670
+ onSelect: () => c(e.id),
3671
+ className: "gap-2",
3672
+ title: e.title,
3673
+ children: [/* @__PURE__ */ U("span", {
3674
+ className: "truncate",
3675
+ children: e.title
3676
+ }), t && /* @__PURE__ */ U("span", {
3677
+ className: "ml-auto pl-2 text-xs italic text-muted-foreground/70 whitespace-nowrap",
3678
+ children: t
3679
+ })]
3680
+ }, e.id);
3681
+ }),
3682
+ /* @__PURE__ */ U(ir, {}),
3683
+ /* @__PURE__ */ W(Q, {
3684
+ onSelect: () => e.push("/library"),
3685
+ className: "gap-2",
3686
+ children: [/* @__PURE__ */ U(de, { className: "w-4 h-4 flex-shrink-0 text-muted-foreground" }), /* @__PURE__ */ U("span", { children: "All history" })]
3687
+ })
3688
+ ]
3689
+ })]
3690
+ });
3691
+ }, si = [
3493
3692
  {
3494
3693
  label: "5s",
3495
3694
  value: 5
@@ -3514,33 +3713,33 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3514
3713
  label: "Unlimited",
3515
3714
  value: 0
3516
3715
  }
3517
- ], Br = [
3716
+ ], ci = [
3518
3717
  "pdf",
3519
3718
  "docx",
3520
3719
  "txt",
3521
3720
  "md",
3522
3721
  "html",
3523
3722
  "htm"
3524
- ], Vr = /* @__PURE__ */ "markdown.js.jsx.ts.tsx.py.rb.go.rs.java.c.cpp.h.hpp.cs.swift.kt.sh.bash.zsh.json.yaml.yml.toml.ini.cfg.conf.xml.csv.tsv.log.env.sql.graphql.vue.svelte.astro.css.scss.less.sass.tex.bib.rst.adoc.org".split("."), Hr = ({ onFileSelect: e, disabled: n = !1 }) => {
3525
- let i = h(), { category: a, setCategory: o, incognito: s, setIncognito: c, sections: l, chatId: d } = J(), { isAuthenticated: f } = An(), m = a ? a.split(",").filter(Boolean) : ["general"], g = Vt.find((e) => e.code === m[0]) || Vt[0], _ = (e) => {
3723
+ ], li = /* @__PURE__ */ "markdown.js.jsx.ts.tsx.py.rb.go.rs.java.c.cpp.h.hpp.cs.swift.kt.sh.bash.zsh.json.yaml.yml.toml.ini.cfg.conf.xml.csv.tsv.log.env.sql.graphql.vue.svelte.astro.css.scss.less.sass.tex.bib.rst.adoc.org".split("."), ui = ({ onFileSelect: e, disabled: n = !1 }) => {
3724
+ let i = h(), { category: a, setCategory: o, sections: s, chatId: c } = J(), { isAuthenticated: l } = Fn(), d = a ? a.split(",").filter(Boolean) : ["general"], f = Kt.find((e) => e.code === d[0]) || Kt[0], m = (e) => {
3526
3725
  let t = a ? a.split(",").filter(Boolean) : ["general"], n = t.includes(e) ? t.filter((t) => t !== e) : [...t, e];
3527
3726
  o(n.length > 0 ? n.join(",") : "general");
3528
- }, [v, y] = p(!1), [b, x] = p(!1), [S, C] = p(!1), [w, E] = p(!1), [D, O] = p(() => {
3727
+ }, [g, _] = p(!1), [v, y] = p(!1), [b, x] = p(!1), [S, C] = p(!1), [w, E] = p(() => {
3529
3728
  if (typeof window > "u") return 5;
3530
3729
  let e = Number(localStorage.getItem("thinkingTimeLimit") ?? "5");
3531
3730
  return Number.isFinite(e) ? e : 5;
3532
- }), k = r.useRef(null), { openPicker: A } = Lr();
3731
+ }), D = r.useRef(null), { openPicker: O } = Qr();
3533
3732
  u(() => {
3534
- j();
3733
+ k();
3535
3734
  }, []);
3536
- let j = async () => {
3735
+ let k = async () => {
3537
3736
  try {
3538
3737
  let { data: e } = await nt();
3539
- y(e?.isConnected || !1);
3738
+ _(e?.isConnected || !1);
3540
3739
  } catch {}
3541
- }, ee = (e) => {
3542
- O(e), localStorage.setItem("thinkingTimeLimit", String(e));
3543
- }, M = async () => {
3740
+ }, A = (e) => {
3741
+ E(e), localStorage.setItem("thinkingTimeLimit", String(e));
3742
+ }, j = async () => {
3544
3743
  if ("showOpenFilePicker" in window) try {
3545
3744
  let t = await window.showOpenFilePicker({
3546
3745
  multiple: !0,
@@ -3565,61 +3764,61 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3565
3764
  }), n = await Promise.all(t.map((e) => e.getFile()));
3566
3765
  n.length > 0 && e(n);
3567
3766
  } catch (e) {
3568
- e?.name !== "AbortError" && (console.error("Failed to open file picker:", e), k.current?.click());
3767
+ e?.name !== "AbortError" && (console.error("Failed to open file picker:", e), D.current?.click());
3569
3768
  }
3570
- else k.current?.click();
3769
+ else D.current?.click();
3571
3770
  };
3572
- async function N(e, t = "") {
3771
+ async function M(e, t = "") {
3573
3772
  let n = [];
3574
3773
  for await (let r of e.values()) if (r.kind === "file") {
3575
3774
  let e = await r.getFile(), i = e.name.split(".").pop()?.toLowerCase() ?? "";
3576
- if (Br.includes(i)) n.push(e);
3577
- else if (Vr.includes(i)) try {
3775
+ if (ci.includes(i)) n.push(e);
3776
+ else if (li.includes(i)) try {
3578
3777
  let r = await e.text(), i = t ? `${t}/${e.name}` : e.name;
3579
3778
  n.push(new File([r], `${i.replace(/[/\\]/g, "_")}.txt`, { type: "text/plain" }));
3580
3779
  } catch {}
3581
3780
  } else if (r.kind === "directory") {
3582
3781
  let e = r;
3583
3782
  if (e.name.startsWith(".") || e.name === "node_modules" || e.name === "__pycache__") continue;
3584
- n.push(...await N(e, t ? `${t}/${e.name}` : e.name));
3783
+ n.push(...await M(e, t ? `${t}/${e.name}` : e.name));
3585
3784
  }
3586
3785
  return n;
3587
3786
  }
3588
- let P = async () => {
3787
+ let N = async () => {
3589
3788
  if (!("showDirectoryPicker" in window)) {
3590
3789
  alert("Your browser does not support the File System Access API. Please use Chrome or Edge.");
3591
3790
  return;
3592
3791
  }
3593
- E(!0);
3792
+ C(!0);
3594
3793
  try {
3595
- let t = await N(await window.showDirectoryPicker({ mode: "read" }));
3794
+ let t = await M(await window.showDirectoryPicker({ mode: "read" }));
3596
3795
  t.length > 0 ? e(t) : alert("No supported files found in the selected folder.");
3597
3796
  } catch (e) {
3598
3797
  e?.name !== "AbortError" && console.error("Failed to access folder:", e);
3599
3798
  } finally {
3600
- E(!1);
3799
+ C(!1);
3601
3800
  }
3602
- }, F = async () => {
3603
- x(!0);
3801
+ }, ee = async () => {
3802
+ y(!0);
3604
3803
  try {
3605
3804
  let { data: e } = await tt();
3606
3805
  if (e?.success && e?.data?.authUrl) {
3607
3806
  let t = e.data.authUrl, n = window.screenX + (window.outerWidth - 600) / 2, r = window.screenY + (window.outerHeight - 700) / 2, i = window.open(t, "Google Drive Authorization", `width=600,height=700,left=${n},top=${r}`), a = (e) => {
3608
- e.data.type === "google-drive-connected" && (y(!0), i?.close(), window.removeEventListener("message", a));
3807
+ e.data.type === "google-drive-connected" && (_(!0), i?.close(), window.removeEventListener("message", a));
3609
3808
  };
3610
3809
  window.addEventListener("message", a);
3611
3810
  }
3612
3811
  } catch {
3613
3812
  console.error("Failed to connect to Google Drive");
3614
3813
  } finally {
3615
- x(!1);
3814
+ y(!1);
3616
3815
  }
3617
- }, L = async () => {
3816
+ }, P = async () => {
3618
3817
  try {
3619
3818
  let { data: t } = await et();
3620
3819
  if (!t?.success || !t.accessToken) throw Error("Failed to get access token");
3621
- await A(t.accessToken, async (t) => {
3622
- C(!0);
3820
+ await O(t.accessToken, async (t) => {
3821
+ x(!0);
3623
3822
  try {
3624
3823
  let n = [];
3625
3824
  for (let e of t) {
@@ -3634,7 +3833,7 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3634
3833
  } catch {
3635
3834
  alert("Failed to load files from Google Drive");
3636
3835
  } finally {
3637
- C(!1);
3836
+ x(!1);
3638
3837
  }
3639
3838
  }, (e) => {
3640
3839
  console.error("Google Picker error:", e), alert(e);
@@ -3642,11 +3841,11 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3642
3841
  } catch (e) {
3643
3842
  alert(e.message || "Failed to open Google Drive picker");
3644
3843
  }
3645
- }, z = zr.find((e) => e.value === D)?.label ?? "Unlimited";
3844
+ }, F = si.find((e) => e.value === w)?.label ?? "Unlimited";
3646
3845
  return /* @__PURE__ */ W(H, { children: [
3647
3846
  /* @__PURE__ */ W("div", {
3648
3847
  className: "relative flex shrink min-w-8 !shrink-0 group",
3649
- children: [/* @__PURE__ */ W(Jn, { children: [/* @__PURE__ */ U(Yn, {
3848
+ children: [/* @__PURE__ */ W($n, { children: [/* @__PURE__ */ U(er, {
3650
3849
  asChild: !0,
3651
3850
  children: /* @__PURE__ */ U("button", {
3652
3851
  disabled: n,
@@ -3655,51 +3854,51 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3655
3854
  "aria-label": "Search options",
3656
3855
  children: /* @__PURE__ */ U(Ee, { className: "w-5 h-5" })
3657
3856
  })
3658
- }), /* @__PURE__ */ W(Xn, {
3857
+ }), /* @__PURE__ */ W(tr, {
3659
3858
  align: "start",
3660
3859
  side: "top",
3661
3860
  sideOffset: 8,
3662
3861
  className: "w-44",
3663
3862
  children: [
3664
- /* @__PURE__ */ W(er, { children: [/* @__PURE__ */ W(tr, {
3863
+ /* @__PURE__ */ W(ar, { children: [/* @__PURE__ */ W(or, {
3665
3864
  className: "gap-2",
3666
- children: [g && /* @__PURE__ */ U(g.icon, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: "Category" })]
3667
- }), /* @__PURE__ */ W(nr, {
3865
+ children: [f && /* @__PURE__ */ U(f.icon, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: "Category" })]
3866
+ }), /* @__PURE__ */ W(sr, {
3668
3867
  className: "w-44",
3669
3868
  children: [
3670
- /* @__PURE__ */ W(Zn, {
3671
- checked: m.length === 0,
3869
+ /* @__PURE__ */ W(nr, {
3870
+ checked: d.length === 0,
3672
3871
  onCheckedChange: () => o("general"),
3673
3872
  onSelect: (e) => e.preventDefault(),
3674
3873
  className: "gap-2",
3675
3874
  children: [/* @__PURE__ */ U("div", { className: "w-3.5 h-3.5 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: "None" })]
3676
3875
  }),
3677
- /* @__PURE__ */ U($n, {}),
3678
- Vt.map((e) => /* @__PURE__ */ W(Zn, {
3679
- checked: m.includes(e.code),
3680
- onCheckedChange: () => _(e.code),
3876
+ /* @__PURE__ */ U(ir, {}),
3877
+ Kt.map((e) => /* @__PURE__ */ W(nr, {
3878
+ checked: d.includes(e.code),
3879
+ onCheckedChange: () => m(e.code),
3681
3880
  onSelect: (e) => e.preventDefault(),
3682
3881
  className: "gap-2",
3683
3882
  children: [e.icon && /* @__PURE__ */ U(e.icon, { className: "w-3.5 h-3.5 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: e.name })]
3684
3883
  }, e.code))
3685
3884
  ]
3686
3885
  })] }),
3687
- /* @__PURE__ */ W(er, { children: [/* @__PURE__ */ W(tr, {
3886
+ /* @__PURE__ */ W(ar, { children: [/* @__PURE__ */ W(or, {
3688
3887
  className: "gap-2",
3689
3888
  children: [
3690
3889
  /* @__PURE__ */ U(I, { className: "w-4 h-4 flex-shrink-0 text-muted-foreground" }),
3691
3890
  /* @__PURE__ */ U("span", { children: "Speed" }),
3692
3891
  /* @__PURE__ */ U("span", {
3693
3892
  className: "ml-auto text-xs text-muted-foreground",
3694
- children: z
3893
+ children: F
3695
3894
  })
3696
3895
  ]
3697
- }), /* @__PURE__ */ U(nr, {
3896
+ }), /* @__PURE__ */ U(sr, {
3698
3897
  className: "w-36",
3699
- children: zr.map((e) => /* @__PURE__ */ W(Q, {
3700
- onSelect: () => ee(e.value),
3701
- className: q("justify-between", D === e.value && "bg-secondary"),
3702
- children: [/* @__PURE__ */ U("span", { children: e.label }), D === e.value && /* @__PURE__ */ U("svg", {
3898
+ children: si.map((e) => /* @__PURE__ */ W(Q, {
3899
+ onSelect: () => A(e.value),
3900
+ className: q("justify-between", w === e.value && "bg-secondary"),
3901
+ children: [/* @__PURE__ */ U("span", { children: e.label }), w === e.value && /* @__PURE__ */ U("svg", {
3703
3902
  className: "w-3 h-3 text-primary",
3704
3903
  fill: "none",
3705
3904
  viewBox: "0 0 10 10",
@@ -3713,71 +3912,63 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3713
3912
  })]
3714
3913
  }, e.value))
3715
3914
  })] }),
3716
- /* @__PURE__ */ U($n, {}),
3717
- /* @__PURE__ */ U(Rr, {}),
3718
- /* @__PURE__ */ U($n, {}),
3719
- /* @__PURE__ */ W(er, { children: [/* @__PURE__ */ W(tr, {
3915
+ /* @__PURE__ */ U(ir, {}),
3916
+ /* @__PURE__ */ U($r, {}),
3917
+ /* @__PURE__ */ U(ir, {}),
3918
+ /* @__PURE__ */ W(ar, { children: [/* @__PURE__ */ W(or, {
3720
3919
  className: "gap-2",
3721
3920
  children: [/* @__PURE__ */ U(Pe, { className: "w-4 h-4 flex-shrink-0 text-muted-foreground" }), /* @__PURE__ */ U("span", { children: "Upload" })]
3722
- }), /* @__PURE__ */ W(nr, {
3921
+ }), /* @__PURE__ */ W(sr, {
3723
3922
  className: "w-44",
3724
3923
  children: [
3725
3924
  /* @__PURE__ */ W(Q, {
3726
- onSelect: M,
3925
+ onSelect: j,
3727
3926
  className: "gap-2",
3728
3927
  children: [/* @__PURE__ */ U(Pe, { className: "h-3.5 w-3.5 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: "Your Device" })]
3729
3928
  }),
3730
3929
  /* @__PURE__ */ W(Q, {
3731
- onSelect: P,
3732
- disabled: w,
3930
+ onSelect: N,
3931
+ disabled: S,
3733
3932
  className: "gap-2",
3734
- children: [w ? /* @__PURE__ */ U(V, { className: "h-3.5 w-3.5 animate-spin flex-shrink-0" }) : /* @__PURE__ */ U(le, { className: "h-3.5 w-3.5 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: w ? "Scanning…" : "Local Folder" })]
3933
+ children: [S ? /* @__PURE__ */ U(V, { className: "h-3.5 w-3.5 animate-spin flex-shrink-0" }) : /* @__PURE__ */ U(le, { className: "h-3.5 w-3.5 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: S ? "Scanning…" : "Local Folder" })]
3735
3934
  }),
3736
- /* @__PURE__ */ U($n, {}),
3737
- /* @__PURE__ */ U(Qn, {
3935
+ /* @__PURE__ */ U(ir, {}),
3936
+ /* @__PURE__ */ U(rr, {
3738
3937
  className: "text-xs font-normal text-muted-foreground",
3739
3938
  children: "Cloud"
3740
3939
  }),
3741
- v ? /* @__PURE__ */ W(Q, {
3742
- onSelect: L,
3743
- disabled: S,
3940
+ g ? /* @__PURE__ */ W(Q, {
3941
+ onSelect: P,
3942
+ disabled: b,
3744
3943
  className: "gap-2",
3745
- children: [S ? /* @__PURE__ */ U(V, { className: "h-3.5 w-3.5 animate-spin flex-shrink-0" }) : /* @__PURE__ */ U(R, { className: "h-3.5 w-3.5 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: S ? "Loading…" : "Google Drive" })]
3944
+ children: [b ? /* @__PURE__ */ U(V, { className: "h-3.5 w-3.5 animate-spin flex-shrink-0" }) : /* @__PURE__ */ U(L, { className: "h-3.5 w-3.5 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: b ? "Loading…" : "Google Drive" })]
3746
3945
  }) : /* @__PURE__ */ W(Q, {
3747
- onSelect: F,
3748
- disabled: b,
3946
+ onSelect: ee,
3947
+ disabled: v,
3749
3948
  className: "gap-2",
3750
- children: [b ? /* @__PURE__ */ U(V, { className: "h-3.5 w-3.5 animate-spin flex-shrink-0" }) : /* @__PURE__ */ U(R, { className: "h-3.5 w-3.5 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: b ? "Connecting…" : "Connect Google Drive" })]
3949
+ children: [v ? /* @__PURE__ */ U(V, { className: "h-3.5 w-3.5 animate-spin flex-shrink-0" }) : /* @__PURE__ */ U(L, { className: "h-3.5 w-3.5 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: v ? "Connecting…" : "Connect Google Drive" })]
3751
3950
  })
3752
3951
  ]
3753
3952
  })] }),
3754
- /* @__PURE__ */ U($n, {}),
3755
- /* @__PURE__ */ W(Zn, {
3756
- checked: s,
3757
- onCheckedChange: c,
3758
- onSelect: (e) => e.preventDefault(),
3759
- className: "gap-2",
3760
- children: [/* @__PURE__ */ U(re, { className: "w-4 h-4 flex-shrink-0 text-muted-foreground" }), /* @__PURE__ */ U("span", { children: "Private" })]
3761
- }),
3762
- /* @__PURE__ */ U($n, {}),
3763
- l.length > 0 && /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ W(er, { children: [/* @__PURE__ */ W(tr, {
3953
+ /* @__PURE__ */ U(ir, {}),
3954
+ s.length > 0 && /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ W(ar, { children: [/* @__PURE__ */ W(or, {
3764
3955
  className: "gap-2",
3765
3956
  children: [/* @__PURE__ */ U(Te, { className: "w-4 h-4 flex-shrink-0 text-muted-foreground" }), /* @__PURE__ */ U("span", { children: "Share" })]
3766
- }), /* @__PURE__ */ W(nr, {
3957
+ }), /* @__PURE__ */ W(sr, {
3767
3958
  className: "w-48",
3768
3959
  children: [
3769
3960
  /* @__PURE__ */ W(Q, {
3770
3961
  onSelect: async () => {
3771
- if (!d) {
3962
+ if (!c) {
3772
3963
  G.error("No chat to share");
3773
3964
  return;
3774
3965
  }
3775
- if (!f) {
3966
+ if (!l) {
3776
3967
  G.error("Please sign in to share chats");
3777
3968
  return;
3778
3969
  }
3779
3970
  try {
3780
- let { data: e, error: t } = await lt({ body: { chatId: d } });
3971
+ let { data: e, error: t } = await lt({ body: { chatId: c } });
3781
3972
  if (!t && e?.success && e?.data?.shareUrl) await navigator.clipboard.writeText(e.data.shareUrl), G.success("Chat is now public - link copied to clipboard");
3782
3973
  else throw Error(t?.error || "Failed to share chat");
3783
3974
  } catch (e) {
@@ -3791,7 +3982,7 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3791
3982
  }),
3792
3983
  /* @__PURE__ */ W(Q, {
3793
3984
  onSelect: async () => {
3794
- let e = l[0]?.userMessage?.content || "Chat", t = l.map((e) => `## ${e.userMessage.content}\n\n${e.assistantMessage?.content || ""}`).join("\n\n---\n\n");
3985
+ let e = s[0]?.userMessage?.content || "Chat", t = s.map((e) => `## ${e.userMessage.content}\n\n${e.assistantMessage?.content || ""}`).join("\n\n---\n\n");
3795
3986
  try {
3796
3987
  await qe({ body: {
3797
3988
  title: e,
@@ -3809,42 +4000,38 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3809
4000
  className: "gap-2",
3810
4001
  children: [/* @__PURE__ */ U(T, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: "Save to QwkDocs" })]
3811
4002
  }),
3812
- /* @__PURE__ */ U($n, {}),
4003
+ /* @__PURE__ */ U(ir, {}),
3813
4004
  /* @__PURE__ */ W(Q, {
3814
4005
  onSelect: () => {
3815
- mr(l[0]?.userMessage?.content || "Chat", l.map((e) => `<h2>${e.userMessage.content}</h2>${e.assistantMessage?.content || ""}`).join("\n"));
4006
+ yr(s[0]?.userMessage?.content || "Chat", s.map((e) => `<h2>${e.userMessage.content}</h2>${e.assistantMessage?.content || ""}`).join("\n"));
3816
4007
  },
3817
4008
  className: "gap-2",
3818
- children: [/* @__PURE__ */ U(se, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: "Export as Markdown" })]
4009
+ children: [/* @__PURE__ */ U(ce, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: "Export as Markdown" })]
3819
4010
  }),
3820
4011
  /* @__PURE__ */ W(Q, {
3821
4012
  onSelect: () => {
3822
- gr(l[0]?.userMessage?.content || "Chat", l.map((e) => `<h2>${e.userMessage.content}</h2>${e.assistantMessage?.content || ""}`).join("\n"));
4013
+ xr(s[0]?.userMessage?.content || "Chat", s.map((e) => `<h2>${e.userMessage.content}</h2>${e.assistantMessage?.content || ""}`).join("\n"));
3823
4014
  },
3824
4015
  className: "gap-2",
3825
- children: [/* @__PURE__ */ U(ce, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: "Export as PDF" })]
4016
+ children: [/* @__PURE__ */ U(B, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: "Export as PDF" })]
3826
4017
  }),
3827
4018
  /* @__PURE__ */ W(Q, {
3828
4019
  onSelect: () => {
3829
- hr(l[0]?.userMessage?.content || "Chat", l.map((e) => `<h2>${e.userMessage.content}</h2>${e.assistantMessage?.content || ""}`).join("\n"));
4020
+ br(s[0]?.userMessage?.content || "Chat", s.map((e) => `<h2>${e.userMessage.content}</h2>${e.assistantMessage?.content || ""}`).join("\n"));
3830
4021
  },
3831
4022
  className: "gap-2",
3832
- children: [/* @__PURE__ */ U(ae, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: "Export as DOCX" })]
4023
+ children: [/* @__PURE__ */ U(se, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: "Export as DOCX" })]
3833
4024
  }),
3834
4025
  /* @__PURE__ */ W(Q, {
3835
4026
  onSelect: () => {
3836
- _r(l[0]?.userMessage?.content || "Chat", l.map((e) => `<h2>${e.userMessage.content}</h2>${e.assistantMessage?.content || ""}`).join("\n"));
4027
+ Sr(s[0]?.userMessage?.content || "Chat", s.map((e) => `<h2>${e.userMessage.content}</h2>${e.assistantMessage?.content || ""}`).join("\n"));
3837
4028
  },
3838
4029
  className: "gap-2",
3839
- children: [/* @__PURE__ */ U(oe, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: "Export to Google Docs" })]
4030
+ children: [/* @__PURE__ */ U(z, { className: "w-4 h-4 flex-shrink-0" }), /* @__PURE__ */ U("span", { children: "Export to Google Docs" })]
3840
4031
  })
3841
4032
  ]
3842
- })] }), /* @__PURE__ */ U($n, {})] }),
3843
- /* @__PURE__ */ W(Q, {
3844
- onSelect: () => i.push("/library"),
3845
- className: "gap-2",
3846
- children: [/* @__PURE__ */ U(de, { className: "w-4 h-4 flex-shrink-0 text-muted-foreground" }), /* @__PURE__ */ U("span", { children: "History" })]
3847
- }),
4033
+ })] }), /* @__PURE__ */ U(ir, {})] }),
4034
+ /* @__PURE__ */ U(oi, {}),
3848
4035
  /* @__PURE__ */ W(Q, {
3849
4036
  onSelect: () => {
3850
4037
  t.onOpenSettings?.() || i.push("/settings");
@@ -3866,7 +4053,7 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3866
4053
  children: [/* @__PURE__ */ U("button", {
3867
4054
  type: "button",
3868
4055
  disabled: n,
3869
- onClick: M,
4056
+ onClick: j,
3870
4057
  "aria-label": "Attach files",
3871
4058
  className: "inline-flex items-center justify-center relative shrink-0 transition-colors duration-200 h-7 w-7 rounded-md active:scale-95 text-text-400 hover:text-text-200 hover:bg-bg-200 disabled:opacity-50 disabled:cursor-not-allowed group-active:scale-95",
3872
4059
  children: /* @__PURE__ */ U(ve, { className: "w-[18px] h-[18px]" })
@@ -3879,7 +4066,7 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3879
4066
  })]
3880
4067
  }),
3881
4068
  /* @__PURE__ */ U("input", {
3882
- ref: k,
4069
+ ref: D,
3883
4070
  type: "file",
3884
4071
  multiple: !0,
3885
4072
  onChange: (t) => {
@@ -3888,8 +4075,8 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3888
4075
  className: "hidden"
3889
4076
  })
3890
4077
  ] });
3891
- }, Ur = o(({ active: e = !1, processing: t = !1, barWidth: n = 3, barHeight: r = 4, barGap: i = 1, barRadius: a = 1.5, barColor: o, fadeEdges: s = !0, fadeWidth: l = 24, height: d = 64, sensitivity: p = 1, smoothingTimeConstant: m = .8, fftSize: h = 256, historySize: g = 60, updateRate: _ = 30, mode: v = "static", onError: y, onStreamReady: b, onStreamEnd: x, className: S, ...C }, w) => {
3892
- let T = f(null), E = f(null), D = f(null), O = f(null), k = f(null), A = f(0), j = f([]), ee = f(0), M = f(0), N = c(() => {
4078
+ }, di = o(({ active: e = !1, processing: t = !1, barWidth: n = 3, barHeight: r = 4, barGap: i = 1, barRadius: a = 1.5, barColor: o, fadeEdges: s = !0, fadeWidth: l = 24, height: d = 64, sensitivity: p = 1, smoothingTimeConstant: m = .8, fftSize: h = 256, historySize: g = 60, updateRate: _ = 30, mode: v = "static", onError: y, onStreamReady: b, onStreamEnd: x, className: S, ...C }, w) => {
4079
+ let T = f(null), E = f(null), D = f(null), O = f(null), k = f(null), A = f(0), j = f([]), M = f(0), N = f(0), ee = c(() => {
3893
4080
  A.current &&= (cancelAnimationFrame(A.current), 0), k.current &&= (k.current.disconnect(), null), O.current &&= (O.current.getTracks().forEach((e) => e.stop()), null), E.current &&= (E.current.close().catch(() => {}), null), D.current = null, j.current = [], x?.();
3894
4081
  }, [x]), P = c((e, t, o, s, c) => {
3895
4082
  let l = n + i, u = Math.floor(t / c / l), d = u * l - i, f = (t / c - d) / 2, m = s.length;
@@ -3927,13 +4114,13 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3927
4114
  i,
3928
4115
  r,
3929
4116
  a
3930
- ]), L = c((e, t, n) => {
4117
+ ]), te = c((e, t, n) => {
3931
4118
  if (!s) return;
3932
4119
  e.save(), e.globalCompositeOperation = "destination-in";
3933
4120
  let r = e.createLinearGradient(0, 0, t, 0);
3934
4121
  r.addColorStop(0, "rgba(0,0,0,0)"), r.addColorStop(Math.min(l / (t || 1), .3), "rgba(0,0,0,1)"), r.addColorStop(Math.max(1 - l / (t || 1), .7), "rgba(0,0,0,1)"), r.addColorStop(1, "rgba(0,0,0,0)"), e.fillStyle = r, e.fillRect(0, 0, t, n), e.restore();
3935
4122
  }, [s, l]);
3936
- return u(() => {
4123
+ u(() => {
3937
4124
  if (!e && !t) {
3938
4125
  let e = T.current;
3939
4126
  if (e) {
@@ -3949,11 +4136,11 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3949
4136
  A.current = requestAnimationFrame(r);
3950
4137
  return;
3951
4138
  }
3952
- if (i - M.current < _) {
4139
+ if (i - N.current < _) {
3953
4140
  A.current = requestAnimationFrame(r);
3954
4141
  return;
3955
4142
  }
3956
- M.current = i;
4143
+ N.current = i;
3957
4144
  let s = window.devicePixelRatio || 1, c = a.getBoundingClientRect(), l = c.width * s, u = c.height * s;
3958
4145
  (a.width !== l || a.height !== u) && (a.width = l, a.height = u);
3959
4146
  let d = a.getContext("2d");
@@ -3961,7 +4148,7 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3961
4148
  A.current = requestAnimationFrame(r);
3962
4149
  return;
3963
4150
  }
3964
- if (d.clearRect(0, 0, l, u), d.fillStyle = o || getComputedStyle(a).getPropertyValue("color") || "#888", d.save(), d.setTransform(1, 0, 0, 1, 0, 0), t && !e) ee.current += .06, I(d, l, u, s, ee.current);
4151
+ if (d.clearRect(0, 0, l, u), d.fillStyle = o || getComputedStyle(a).getPropertyValue("color") || "#888", d.save(), d.setTransform(1, 0, 0, 1, 0, 0), t && !e) M.current += .06, I(d, l, u, s, M.current);
3965
4152
  else if (e && D.current) {
3966
4153
  let e = new Uint8Array(D.current.frequencyBinCount);
3967
4154
  if (D.current.getByteFrequencyData(e), v === "scrolling") {
@@ -3971,7 +4158,7 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3971
4158
  j.current.push(n), j.current.length > g * 2 && (j.current = j.current.slice(-g)), F(d, l, u, s);
3972
4159
  } else P(d, l, u, e, s);
3973
4160
  }
3974
- L(d, l, u), d.restore(), A.current = requestAnimationFrame(r);
4161
+ te(d, l, u), d.restore(), A.current = requestAnimationFrame(r);
3975
4162
  };
3976
4163
  return A.current = requestAnimationFrame(r), () => {
3977
4164
  n = !1, A.current &&= (cancelAnimationFrame(A.current), 0);
@@ -3986,10 +4173,10 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
3986
4173
  P,
3987
4174
  F,
3988
4175
  I,
3989
- L
4176
+ te
3990
4177
  ]), u(() => {
3991
4178
  if (!e) {
3992
- N();
4179
+ ee();
3993
4180
  return;
3994
4181
  }
3995
4182
  let t = !1;
@@ -4008,20 +4195,22 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
4008
4195
  t || y?.(e instanceof Error ? e : Error(String(e)));
4009
4196
  }
4010
4197
  })(), () => {
4011
- t = !0, N();
4198
+ t = !0, ee();
4012
4199
  };
4013
4200
  }, [
4014
4201
  e,
4015
4202
  h,
4016
4203
  m,
4017
- N,
4204
+ ee,
4018
4205
  y,
4019
4206
  b
4020
- ]), /* @__PURE__ */ U("div", {
4207
+ ]);
4208
+ let L = typeof d == "number" ? `${d}px` : d;
4209
+ return /* @__PURE__ */ U("div", {
4021
4210
  ref: w,
4022
4211
  className: S,
4023
4212
  style: {
4024
- height: typeof d == "number" ? `${d}px` : d,
4213
+ height: L,
4025
4214
  width: "100%",
4026
4215
  position: "relative"
4027
4216
  },
@@ -4037,23 +4226,23 @@ var Fr = () => window.gapi, Ir = () => window.google, Lr = () => {
4037
4226
  })
4038
4227
  });
4039
4228
  });
4040
- Ur.displayName = "LiveWaveform";
4229
+ di.displayName = "LiveWaveform";
4041
4230
  //#endregion
4042
4231
  //#region src/components/MessageComposer/ChatInputBox.tsx
4043
- var Wr = [
4232
+ var fi = [
4044
4233
  "What are you curious to research?",
4045
4234
  "Search the latest news...",
4046
4235
  "Analyze a video, doc, or URL...",
4047
4236
  "Find academic research on...",
4048
4237
  "Compare products to buy..."
4049
- ], Gr = {
4238
+ ], pi = {
4050
4239
  initial: {},
4051
4240
  animate: { transition: { staggerChildren: .025 } },
4052
4241
  exit: { transition: {
4053
4242
  staggerChildren: .015,
4054
4243
  staggerDirection: -1
4055
4244
  } }
4056
- }, Kr = {
4245
+ }, mi = {
4057
4246
  initial: {
4058
4247
  opacity: 0,
4059
4248
  filter: "blur(12px)",
@@ -4087,8 +4276,8 @@ var Wr = [
4087
4276
  }
4088
4277
  }
4089
4278
  }
4090
- }, qr = ({ onNewChat: e }) => {
4091
- let { loading: t, sendMessage: n, stopStreaming: r, files: i, fileIds: a, setFiles: o, setFileIds: s, newChat: c, sections: l } = J(), [d, m] = p(""), h = f(null), g = f(null), { files: _, setFiles: v, pastedContent: y, setPastedContent: b, isDragging: x, handleFiles: S, onDragOver: C, onDragLeave: w, onDrop: T, handlePaste: E, resetAttachments: D } = Pr({
4279
+ }, hi = ({ onNewChat: e }) => {
4280
+ let { loading: t, sendMessage: n, stopStreaming: r, files: i, fileIds: a, setFiles: o, setFileIds: s, newChat: c, sections: l } = J(), [d, m] = p(""), h = f(null), g = f(null), { files: _, setFiles: v, pastedContent: y, setPastedContent: b, isDragging: x, handleFiles: S, onDragOver: C, onDragLeave: w, onDrop: T, handlePaste: E, resetAttachments: D } = Yr({
4092
4281
  setMessage: m,
4093
4282
  contextFiles: i,
4094
4283
  contextFileIds: a,
@@ -4096,25 +4285,38 @@ var Wr = [
4096
4285
  setContextFileIds: s
4097
4286
  }), O = () => {
4098
4287
  m(""), D(), h.current && (h.current.style.height = "auto");
4099
- }, { isListening: k, toggleSpeech: A, isSpeechSupported: j } = Dr((e) => m(e), () => {
4288
+ }, k = f(""), A = (e, t) => e && !/\s$/.test(e) ? `${e} ${t}` : `${e}${t}`, { isListening: j, toggleSpeech: M, isSpeechSupported: N, lastPhrase: ee, phraseId: P } = Nr((e) => {
4289
+ m(() => {
4290
+ let t = `${A(k.current, e)} `;
4291
+ return k.current = t, t;
4292
+ });
4293
+ }, () => {
4100
4294
  m((e) => (e.trim() && setTimeout(() => {
4101
4295
  n(e), O();
4102
4296
  }, 0), e));
4103
- }), [ee, M] = p(0), [N, P] = p(!0), [F, I] = p(!1), [L, R] = p([]), [z, te] = p([]), [ne, B] = p(-1), [re, ie] = p(!1), [ae, oe] = p("below"), se = f(!1), ce = f(null);
4297
+ }, { onPartial: (e) => m(e ? A(k.current, e) : k.current) });
4298
+ u(() => {
4299
+ j && (k.current = d);
4300
+ }, [j]), Hr({
4301
+ isSpeechSupported: N,
4302
+ isListening: j,
4303
+ toggleSpeech: M
4304
+ });
4305
+ let [F, I] = p(0), [te, L] = p(!0), [R, ne] = p(!1), [re, ie] = p([]), [ae, oe] = p([]), [se, z] = p(-1), [ce, B] = p(!1), [le, ue] = p("below"), de = f(!1), fe = f(null);
4104
4306
  u(() => {
4105
- if (se.current) {
4106
- se.current = !1;
4307
+ if (de.current) {
4308
+ de.current = !1;
4107
4309
  return;
4108
4310
  }
4109
- let { query: e } = le(d);
4110
- if (!F || e.length < 2) {
4111
- R([]), te([]), ie(!1), B(-1);
4311
+ let { query: e } = pe(d);
4312
+ if (!R || e.length < 2) {
4313
+ ie([]), oe([]), B(!1), z(-1);
4112
4314
  return;
4113
4315
  }
4114
4316
  let t = setTimeout(async () => {
4115
- ce.current?.abort();
4317
+ fe.current?.abort();
4116
4318
  let t = new AbortController();
4117
- ce.current = t;
4319
+ fe.current = t;
4118
4320
  try {
4119
4321
  let { data: n, error: r } = await Ke({
4120
4322
  query: {
@@ -4125,21 +4327,21 @@ var Wr = [
4125
4327
  });
4126
4328
  if (r) return;
4127
4329
  let i = Array.isArray(n?.suggestions) ? n.suggestions : [], a = Array.isArray(n?.domains) ? n.domains : [];
4128
- if (R(i), te(a), i.length + a.length > 0) {
4330
+ if (ie(i), oe(a), i.length + a.length > 0) {
4129
4331
  if (g.current) {
4130
4332
  let e = g.current.getBoundingClientRect(), t = window.innerHeight - e.bottom, n = e.top;
4131
- t < Math.min(288, (i.length + a.length) * 36) && n > t ? oe("above") : oe("below");
4333
+ t < Math.min(288, (i.length + a.length) * 36) && n > t ? ue("above") : ue("below");
4132
4334
  }
4133
- ie(!0);
4134
- } else ie(!1);
4135
- B(-1);
4335
+ B(!0);
4336
+ } else B(!1);
4337
+ z(-1);
4136
4338
  } catch (e) {
4137
4339
  e?.name !== "AbortError" && console.error("Autocomplete fetch failed", e);
4138
4340
  }
4139
4341
  }, 180);
4140
4342
  return () => clearTimeout(t);
4141
- }, [d, F]);
4142
- let le = (e) => {
4343
+ }, [d, R]);
4344
+ let pe = (e) => {
4143
4345
  let t = e.trimEnd();
4144
4346
  if (!t) return {
4145
4347
  prefix: "",
@@ -4150,63 +4352,63 @@ var Wr = [
4150
4352
  prefix: n.length > r ? n.slice(0, -r).join(" ") + " " : "",
4151
4353
  query: i
4152
4354
  };
4153
- }, ue = (e) => {
4154
- se.current = !0;
4155
- let { prefix: t } = le(d);
4156
- m(t + e), R([]), te([]), ie(!1), B(-1), h.current?.focus();
4157
- }, de = (e) => {
4158
- ie(!1), B(-1), window.location.href = `https://${e.domain}`;
4159
- }, fe = z.length + L.length, pe = (e) => {
4160
- e < z.length ? de(z[e]) : ue(L[e - z.length]);
4355
+ }, me = (e) => {
4356
+ de.current = !0;
4357
+ let { prefix: t } = pe(d);
4358
+ m(t + e), ie([]), oe([]), B(!1), z(-1), h.current?.focus();
4359
+ }, V = (e) => {
4360
+ B(!1), z(-1), window.location.href = `https://${e.domain}`;
4361
+ }, he = ae.length + re.length, ge = (e) => {
4362
+ e < ae.length ? V(ae[e]) : me(re[e - ae.length]);
4161
4363
  };
4162
4364
  u(() => {
4163
- if (F || d) return;
4365
+ if (R || d) return;
4164
4366
  let e = setInterval(() => {
4165
- P(!1), setTimeout(() => {
4166
- M((e) => (e + 1) % Wr.length), P(!0);
4367
+ L(!1), setTimeout(() => {
4368
+ I((e) => (e + 1) % fi.length), L(!0);
4167
4369
  }, 400);
4168
4370
  }, 3e3);
4169
4371
  return () => clearInterval(e);
4170
- }, [F, d]), u(() => {
4372
+ }, [R, d]), u(() => {
4171
4373
  let e = (e) => {
4172
- g.current && !g.current.contains(e.target) && (d || I(!1));
4374
+ g.current && !g.current.contains(e.target) && (d || ne(!1));
4173
4375
  };
4174
4376
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
4175
4377
  }, [d]), u(() => {
4176
4378
  h.current && (h.current.style.height = "auto", h.current.style.height = Math.min(h.current.scrollHeight, 384) + "px");
4177
4379
  }, [d]);
4178
- let me = () => {
4380
+ let _e = () => {
4179
4381
  t || !d.trim() && _.length === 0 && y.length === 0 || (n(d), O());
4180
- }, V = (e) => {
4181
- if (re && fe > 0) {
4382
+ }, ve = (e) => {
4383
+ if (ce && he > 0) {
4182
4384
  if (e.key === "ArrowDown") {
4183
- e.preventDefault(), B((e) => (e + 1) % fe);
4385
+ e.preventDefault(), z((e) => (e + 1) % he);
4184
4386
  return;
4185
4387
  }
4186
4388
  if (e.key === "ArrowUp") {
4187
- e.preventDefault(), B((e) => e <= 0 ? fe - 1 : e - 1);
4389
+ e.preventDefault(), z((e) => e <= 0 ? he - 1 : e - 1);
4188
4390
  return;
4189
4391
  }
4190
4392
  if (e.key === "Escape") {
4191
- e.preventDefault(), ie(!1), B(-1);
4393
+ e.preventDefault(), B(!1), z(-1);
4192
4394
  return;
4193
4395
  }
4194
- if (e.key === "Tab" && ne >= 0) {
4195
- e.preventDefault(), pe(ne);
4396
+ if (e.key === "Tab" && se >= 0) {
4397
+ e.preventDefault(), ge(se);
4196
4398
  return;
4197
4399
  }
4198
- if (e.key === "Enter" && !e.shiftKey && ne >= 0) {
4199
- e.preventDefault(), pe(ne);
4400
+ if (e.key === "Enter" && !e.shiftKey && se >= 0) {
4401
+ e.preventDefault(), ge(se);
4200
4402
  return;
4201
4403
  }
4202
4404
  let t = parseInt(e.key, 10);
4203
- if (t >= 1 && t <= fe && t <= 9) {
4204
- e.preventDefault(), pe(t - 1);
4405
+ if (t >= 1 && t <= he && t <= 9) {
4406
+ e.preventDefault(), ge(t - 1);
4205
4407
  return;
4206
4408
  }
4207
4409
  }
4208
- e.key === "Enter" && !e.shiftKey && (e.preventDefault(), me());
4209
- }, he = !!(d.trim() || _.length > 0 || y.length > 0);
4410
+ e.key === "Enter" && !e.shiftKey && (e.preventDefault(), _e());
4411
+ }, ye = !!(d.trim() || _.length > 0 || y.length > 0);
4210
4412
  return /* @__PURE__ */ W("div", {
4211
4413
  className: "relative w-full max-w-2xl mx-auto transition-all duration-300 font-sans",
4212
4414
  onDragOver: C,
@@ -4216,28 +4418,28 @@ var Wr = [
4216
4418
  /* @__PURE__ */ W(ht.div, {
4217
4419
  ref: g,
4218
4420
  className: "!box-content flex flex-col mx-2 md:mx-0 items-stretch relative z-10 rounded-[28px] bg-gray-50 dark:bg-[#30302E] border border-bg-300 dark:border-transparent cursor-text font-sans antialiased",
4219
- animate: { boxShadow: F || d ? "0 8px 32px 0 rgba(0,0,0,0.16)" : "0 2px 8px 0 rgba(0,0,0,0.08)" },
4421
+ animate: { boxShadow: R || d ? "0 8px 32px 0 rgba(0,0,0,0.16)" : "0 2px 8px 0 rgba(0,0,0,0.08)" },
4220
4422
  transition: {
4221
4423
  type: "spring",
4222
4424
  stiffness: 120,
4223
4425
  damping: 18
4224
4426
  },
4225
- onClick: () => I(!0),
4427
+ onClick: () => ne(!0),
4226
4428
  children: [
4227
4429
  (_.length > 0 || y.length > 0) && /* @__PURE__ */ W("div", {
4228
4430
  className: "flex gap-3 overflow-x-auto custom-scrollbar px-3 pt-3 pb-1",
4229
- children: [y.map((e) => /* @__PURE__ */ U(Er, {
4431
+ children: [y.map((e) => /* @__PURE__ */ U(jr, {
4230
4432
  content: e,
4231
4433
  onRemove: (e) => b((t) => t.filter((t) => t.id !== e))
4232
- }, e.id)), _.map((e) => /* @__PURE__ */ U(Tr, {
4434
+ }, e.id)), _.map((e) => /* @__PURE__ */ U(Ar, {
4233
4435
  file: e,
4234
4436
  onRemove: (e) => v((t) => t.filter((t) => t.id !== e))
4235
4437
  }, e.id))]
4236
4438
  }),
4237
- k && /* @__PURE__ */ U("div", {
4439
+ j && /* @__PURE__ */ U("div", {
4238
4440
  className: "px-3 pt-2",
4239
- children: /* @__PURE__ */ U(Ur, {
4240
- active: k,
4441
+ children: /* @__PURE__ */ U(di, {
4442
+ active: j,
4241
4443
  mode: "static",
4242
4444
  height: 48,
4243
4445
  barWidth: 3,
@@ -4248,10 +4450,15 @@ var Wr = [
4248
4450
  className: "w-full rounded-lg"
4249
4451
  })
4250
4452
  }),
4453
+ /* @__PURE__ */ U(Et, {
4454
+ phrase: ee,
4455
+ phraseId: P,
4456
+ visible: j
4457
+ }),
4251
4458
  /* @__PURE__ */ W("div", {
4252
4459
  className: "flex items-center gap-2 p-3",
4253
4460
  children: [
4254
- /* @__PURE__ */ U(Hr, {
4461
+ /* @__PURE__ */ U(ui, {
4255
4462
  onFileSelect: S,
4256
4463
  disabled: t
4257
4464
  }),
@@ -4264,8 +4471,8 @@ var Wr = [
4264
4471
  value: d,
4265
4472
  onChange: (e) => m(e.target.value),
4266
4473
  onPaste: E,
4267
- onKeyDown: V,
4268
- onFocus: () => I(!0),
4474
+ onKeyDown: ve,
4475
+ onFocus: () => ne(!0),
4269
4476
  className: "w-full bg-transparent border-0 outline-none text-text-200 dark:text-text-100 text-[16px] resize-none overflow-hidden py-1 leading-relaxed block font-normal antialiased",
4270
4477
  rows: 1,
4271
4478
  autoFocus: !0,
@@ -4275,43 +4482,43 @@ var Wr = [
4275
4482
  className: "absolute left-0 top-0 w-full h-full pointer-events-none flex items-center",
4276
4483
  children: /* @__PURE__ */ U(pt, {
4277
4484
  mode: "wait",
4278
- children: N && !F && !d && /* @__PURE__ */ U(ht.span, {
4485
+ children: te && !R && !d && /* @__PURE__ */ U(ht.span, {
4279
4486
  className: "absolute left-0 top-1/2 -translate-y-1/2 text-text-400 select-none pointer-events-none text-[16px] font-normal",
4280
4487
  style: {
4281
4488
  whiteSpace: "nowrap",
4282
4489
  overflow: "hidden",
4283
4490
  textOverflow: "ellipsis"
4284
4491
  },
4285
- variants: Gr,
4492
+ variants: pi,
4286
4493
  initial: "initial",
4287
4494
  animate: "animate",
4288
4495
  exit: "exit",
4289
- children: Wr[ee].split("").map((e, t) => /* @__PURE__ */ U(ht.span, {
4290
- variants: Kr,
4496
+ children: fi[F].split("").map((e, t) => /* @__PURE__ */ U(ht.span, {
4497
+ variants: mi,
4291
4498
  style: { display: "inline-block" },
4292
4499
  children: e === " " ? "\xA0" : e
4293
4500
  }, t))
4294
- }, ee)
4501
+ }, F)
4295
4502
  })
4296
4503
  })]
4297
4504
  }),
4298
- j && /* @__PURE__ */ W("div", {
4505
+ N && /* @__PURE__ */ W("div", {
4299
4506
  className: "relative flex shrink !shrink-0 group",
4300
4507
  children: [/* @__PURE__ */ U("button", {
4301
4508
  onClick: (e) => {
4302
- e.stopPropagation(), A();
4509
+ e.stopPropagation(), M();
4303
4510
  },
4304
4511
  disabled: t,
4305
4512
  className: `transition-all duration-200 h-8 w-8 flex items-center justify-center rounded-full active:scale-95
4306
- ${k ? "text-red-500 bg-red-500/10 animate-pulse" : "text-text-400 hover:text-text-200 hover:bg-bg-200"}
4513
+ ${j ? "text-red-500 bg-red-500/10 animate-pulse" : "text-text-400 hover:text-text-200 hover:bg-bg-200"}
4307
4514
  `,
4308
- "aria-label": k ? "Stop listening" : "Voice input",
4515
+ "aria-label": j ? "Stop listening" : "Voice input",
4309
4516
  children: /* @__PURE__ */ U($.Mic, { className: "w-5 h-5" })
4310
4517
  }), /* @__PURE__ */ U("div", {
4311
4518
  className: "absolute bottom-full left-1/2 -translate-x-1/2 mb-2 px-2 py-1 bg-[#1F1E1D] dark:bg-[#EEEEEC] text-[11px] font-medium rounded-[6px] opacity-0 group-hover:opacity-100 transition-opacity whitespace-nowrap pointer-events-none z-50 shadow-sm tracking-wide",
4312
4519
  children: /* @__PURE__ */ U("span", {
4313
4520
  className: "text-[#ECECEC] dark:text-[#1F1E1D]",
4314
- children: k ? "Stop listening" : "Voice input"
4521
+ children: j ? "Stop listening" : "Voice input"
4315
4522
  })
4316
4523
  })]
4317
4524
  }),
@@ -4345,11 +4552,11 @@ var Wr = [
4345
4552
  children: /* @__PURE__ */ U($.Stop, { className: "w-3.5 h-3.5 fill-current" })
4346
4553
  }) : /* @__PURE__ */ U("button", {
4347
4554
  onClick: (e) => {
4348
- e.stopPropagation(), me();
4555
+ e.stopPropagation(), _e();
4349
4556
  },
4350
- disabled: !he,
4557
+ disabled: !ye,
4351
4558
  className: `inline-flex items-center justify-center shrink-0 transition-all duration-200 h-8 w-8 rounded-full active:scale-95
4352
- ${he ? "bg-accent text-bg-0 hover:bg-accent-hover shadow-md" : "bg-bg-300 text-text-400 cursor-default opacity-50"}
4559
+ ${ye ? "bg-accent text-bg-0 hover:bg-accent-hover shadow-md" : "bg-bg-300 text-text-400 cursor-default opacity-50"}
4353
4560
  `,
4354
4561
  type: "button",
4355
4562
  "aria-label": "Send message",
@@ -4366,13 +4573,13 @@ var Wr = [
4366
4573
  })
4367
4574
  ]
4368
4575
  }),
4369
- /* @__PURE__ */ U(pt, { children: re && fe > 0 && /* @__PURE__ */ U(ht.div, {
4576
+ /* @__PURE__ */ U(pt, { children: ce && he > 0 && /* @__PURE__ */ U(ht.div, {
4370
4577
  ref: (e) => {
4371
4578
  e && g.current && g.current.contains(e);
4372
4579
  },
4373
4580
  initial: {
4374
4581
  opacity: 0,
4375
- y: ae === "above" ? 4 : -4
4582
+ y: le === "above" ? 4 : -4
4376
4583
  },
4377
4584
  animate: {
4378
4585
  opacity: 1,
@@ -4380,18 +4587,18 @@ var Wr = [
4380
4587
  },
4381
4588
  exit: {
4382
4589
  opacity: 0,
4383
- y: ae === "above" ? 4 : -4
4590
+ y: le === "above" ? 4 : -4
4384
4591
  },
4385
4592
  transition: { duration: .12 },
4386
- className: `absolute left-2 right-2 md:left-0 md:right-0 z-20 rounded-2xl bg-gray-50 dark:bg-[#30302E] border border-bg-300 dark:border-transparent shadow-xl overflow-hidden ${ae === "above" ? "bottom-full" : "top-full"}`,
4593
+ className: `absolute left-2 right-2 md:left-0 md:right-0 z-20 rounded-2xl bg-gray-50 dark:bg-[#30302E] border border-bg-300 dark:border-transparent shadow-xl overflow-hidden ${le === "above" ? "bottom-full" : "top-full"}`,
4387
4594
  onMouseDown: (e) => e.preventDefault(),
4388
4595
  children: /* @__PURE__ */ W("ul", {
4389
4596
  className: "max-h-72 overflow-y-auto custom-scrollbar py-1",
4390
- children: [z.map((e, t) => /* @__PURE__ */ U("li", { children: /* @__PURE__ */ W("button", {
4597
+ children: [ae.map((e, t) => /* @__PURE__ */ U("li", { children: /* @__PURE__ */ W("button", {
4391
4598
  type: "button",
4392
- onMouseEnter: () => B(t),
4393
- onClick: () => de(e),
4394
- className: `w-full text-left px-4 py-1.5 text-[15px] flex items-center gap-3 transition-colors ${t === ne ? "bg-bg-200 text-text-100" : "text-text-200 hover:bg-bg-100 dark:hover:bg-[#3A3A38]"}`,
4599
+ onMouseEnter: () => z(t),
4600
+ onClick: () => V(e),
4601
+ className: `w-full text-left px-4 py-1.5 text-[15px] flex items-center gap-3 transition-colors ${t === se ? "bg-bg-200 text-text-100" : "text-text-200 hover:bg-bg-100 dark:hover:bg-[#3A3A38]"}`,
4395
4602
  children: [
4396
4603
  /* @__PURE__ */ U("span", {
4397
4604
  className: "w-5 h-5 flex items-center justify-center rounded bg-bg-200 dark:bg-[#3A3A38] text-[11px] font-semibold text-text-400 shrink-0",
@@ -4409,15 +4616,19 @@ var Wr = [
4409
4616
  /* @__PURE__ */ U("span", {
4410
4617
  className: "truncate text-[13px] text-text-400 shrink-0",
4411
4618
  children: e.domain
4619
+ }),
4620
+ Number.isFinite(e.rank) && e.rank < 2 ** 53 - 1 && /* @__PURE__ */ W("span", {
4621
+ className: "ml-auto shrink-0 px-1.5 py-0.5 rounded-full text-[10px] font-semibold tabular-nums bg-bg-200 dark:bg-[#3A3A38] text-text-400",
4622
+ children: ["#", e.rank.toLocaleString()]
4412
4623
  })
4413
4624
  ]
4414
- }) }, `domain-${e.domain}`)), L.map((e, t) => {
4415
- let n = z.length + t;
4625
+ }) }, `domain-${e.domain}`)), re.map((e, t) => {
4626
+ let n = ae.length + t;
4416
4627
  return /* @__PURE__ */ U("li", { children: /* @__PURE__ */ W("button", {
4417
4628
  type: "button",
4418
- onMouseEnter: () => B(n),
4419
- onClick: () => ue(e),
4420
- className: `w-full text-left px-4 py-1.5 text-[15px] flex items-center gap-3 transition-colors ${n === ne ? "bg-bg-200 text-text-100" : "text-text-200 hover:bg-bg-100 dark:hover:bg-[#3A3A38]"}`,
4629
+ onMouseEnter: () => z(n),
4630
+ onClick: () => me(e),
4631
+ className: `w-full text-left px-4 py-1.5 text-[15px] flex items-center gap-3 transition-colors ${n === se ? "bg-bg-200 text-text-100" : "text-text-200 hover:bg-bg-100 dark:hover:bg-[#3A3A38]"}`,
4421
4632
  children: [
4422
4633
  /* @__PURE__ */ U("span", {
4423
4634
  className: "w-5 h-5 flex items-center justify-center rounded bg-bg-200 dark:bg-[#3A3A38] text-[11px] font-semibold text-text-400 shrink-0",
@@ -4442,7 +4653,7 @@ var Wr = [
4442
4653
  })
4443
4654
  ]
4444
4655
  });
4445
- }, Jr = n.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ U("span", {
4656
+ }, gi = n.forwardRef(({ className: e, ...t }, n) => /* @__PURE__ */ U("span", {
4446
4657
  ref: n,
4447
4658
  className: q("absolute w-px h-px p-0 -m-px overflow-hidden whitespace-nowrap border-0", e),
4448
4659
  style: {
@@ -4451,17 +4662,17 @@ var Wr = [
4451
4662
  },
4452
4663
  ...t
4453
4664
  }));
4454
- Jr.displayName = "VisuallyHidden";
4665
+ gi.displayName = "VisuallyHidden";
4455
4666
  //#endregion
4456
4667
  //#region src/components/ArticleReader/ArticlePanelHeader.tsx
4457
- var Yr = ({ onClose: e }) => /* @__PURE__ */ U("div", {
4668
+ var _i = ({ onClose: e }) => /* @__PURE__ */ U("div", {
4458
4669
  className: "flex items-center justify-between bg-secondary px-4 py-3 border-b border-border",
4459
4670
  children: /* @__PURE__ */ U("button", {
4460
4671
  onClick: e,
4461
4672
  className: "rounded-md p-1 hover:bg-accent transition-colors",
4462
4673
  children: /* @__PURE__ */ U(Le, { className: "h-5 w-5" })
4463
4674
  })
4464
- }), Xr = Ct("inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-2xl text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", {
4675
+ }), vi = Ct("inline-flex cursor-pointer items-center justify-center gap-2 whitespace-nowrap rounded-2xl text-sm font-medium transition-all disabled:pointer-events-none disabled:opacity-50 [&_svg]:pointer-events-none [&_svg:not([class*='size-'])]:size-4 shrink-0 [&_svg]:shrink-0 outline-none focus-visible:border-ring focus-visible:ring-ring/50 focus-visible:ring-[3px] aria-invalid:ring-destructive/20 dark:aria-invalid:ring-destructive/40 aria-invalid:border-destructive", {
4465
4676
  variants: {
4466
4677
  variant: {
4467
4678
  default: "bg-primary text-primary-foreground hover:bg-primary/90",
@@ -4483,10 +4694,10 @@ var Yr = ({ onClose: e }) => /* @__PURE__ */ U("div", {
4483
4694
  size: "default"
4484
4695
  }
4485
4696
  });
4486
- function Zr({ className: e, variant: t, size: n, asChild: r = !1, ...i }) {
4697
+ function yi({ className: e, variant: t, size: n, asChild: r = !1, ...i }) {
4487
4698
  return /* @__PURE__ */ U(r ? St : "button", {
4488
4699
  "data-slot": "button",
4489
- className: q(Xr({
4700
+ className: q(vi({
4490
4701
  variant: t,
4491
4702
  size: n,
4492
4703
  className: e
@@ -4496,7 +4707,7 @@ function Zr({ className: e, variant: t, size: n, asChild: r = !1, ...i }) {
4496
4707
  }
4497
4708
  //#endregion
4498
4709
  //#region src/components/ArticleReader/ArticleActionButtons.tsx
4499
- var Qr = {
4710
+ var bi = {
4500
4711
  ask: {
4501
4712
  alt: !0,
4502
4713
  key: "a"
@@ -4537,12 +4748,12 @@ var Qr = {
4537
4748
  alt: !1,
4538
4749
  key: "Escape"
4539
4750
  }
4540
- }, $r = typeof navigator < "u" && /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent || "");
4541
- function ei(e) {
4542
- let { alt: t, key: n } = Qr[e], r = n === "Escape" ? "Esc" : n.length === 1 ? n.toUpperCase() : n;
4543
- return t ? $r ? `⌥${r}` : `Alt+${r}` : r;
4751
+ }, xi = typeof navigator < "u" && /Mac|iPhone|iPad|iPod/.test(navigator.platform || navigator.userAgent || "");
4752
+ function Si(e) {
4753
+ let { alt: t, key: n } = bi[e], r = n === "Escape" ? "Esc" : n.length === 1 ? n.toUpperCase() : n;
4754
+ return t ? xi ? `⌥${r}` : `Alt+${r}` : r;
4544
4755
  }
4545
- var ti = q("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80 hover:text-foreground text-muted-foreground"), ni = ({ label: e, action: t, children: n }) => /* @__PURE__ */ W(Y, { children: [/* @__PURE__ */ U(X, {
4756
+ var Ci = q("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80 hover:text-foreground text-muted-foreground"), wi = ({ label: e, action: t, children: n }) => /* @__PURE__ */ W(Y, { children: [/* @__PURE__ */ U(X, {
4546
4757
  asChild: !0,
4547
4758
  children: n
4548
4759
  }), /* @__PURE__ */ U(Z, {
@@ -4551,18 +4762,18 @@ var ti = q("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80
4551
4762
  className: "flex items-center gap-1.5",
4552
4763
  children: [/* @__PURE__ */ U("span", { children: e }), t && /* @__PURE__ */ U("kbd", {
4553
4764
  className: "rounded bg-primary-foreground/20 px-1 py-0.5 text-[10px] font-semibold leading-none tracking-wide",
4554
- children: ei(t)
4765
+ children: Si(t)
4555
4766
  })]
4556
4767
  })
4557
- })] }), ri = ({ isLoadingAI: e, isLoadingFollowups: t, isLoadingFavorite: n, isFavorited: r, isHighlightMode: i, articleUrl: a, fontScale: o, onAskClick: s, onSuggestClick: c, onCopyClick: l, onFavoriteClick: u, onHighlightToggle: d, onZoomIn: f, onZoomOut: p, onZoomReset: m, onClose: h }) => {
4768
+ })] }), Ti = ({ isLoadingAI: e, isLoadingFollowups: t, isLoadingFavorite: n, isFavorited: r, isHighlightMode: i, articleUrl: a, fontScale: o, onAskClick: s, onSuggestClick: c, onCopyClick: l, onFavoriteClick: u, onHighlightToggle: d, onZoomIn: f, onZoomOut: p, onZoomReset: m, onClose: h }) => {
4558
4769
  let g = f || p, _ = Math.round((o ?? 1) * 100);
4559
4770
  return /* @__PURE__ */ W("div", {
4560
4771
  className: "flex flex-nowrap items-center gap-1 rounded-2xl border border-muted bg-gradient-to-b from-background to-muted/30 p-1 shadow-sm",
4561
4772
  children: [
4562
- /* @__PURE__ */ U(ni, {
4773
+ /* @__PURE__ */ U(wi, {
4563
4774
  label: "Ask AI about this article",
4564
4775
  action: "ask",
4565
- children: /* @__PURE__ */ W(Zr, {
4776
+ children: /* @__PURE__ */ W(yi, {
4566
4777
  onClick: s,
4567
4778
  disabled: e,
4568
4779
  variant: "ghost",
@@ -4574,10 +4785,10 @@ var ti = q("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80
4574
4785
  })]
4575
4786
  })
4576
4787
  }),
4577
- /* @__PURE__ */ U(ni, {
4788
+ /* @__PURE__ */ U(wi, {
4578
4789
  label: "Suggest follow-up questions",
4579
4790
  action: "suggest",
4580
- children: /* @__PURE__ */ W(Zr, {
4791
+ children: /* @__PURE__ */ W(yi, {
4581
4792
  onClick: c,
4582
4793
  disabled: t,
4583
4794
  variant: "ghost",
@@ -4589,21 +4800,21 @@ var ti = q("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80
4589
4800
  })]
4590
4801
  })
4591
4802
  }),
4592
- /* @__PURE__ */ U(ni, {
4803
+ /* @__PURE__ */ U(wi, {
4593
4804
  label: "Copy article",
4594
4805
  action: "copy",
4595
- children: /* @__PURE__ */ U(Zr, {
4806
+ children: /* @__PURE__ */ U(yi, {
4596
4807
  onClick: l,
4597
4808
  variant: "ghost",
4598
4809
  size: "icon",
4599
- className: ti,
4810
+ className: Ci,
4600
4811
  children: /* @__PURE__ */ U(P, { className: "size-4" })
4601
4812
  })
4602
4813
  }),
4603
- /* @__PURE__ */ U(ni, {
4814
+ /* @__PURE__ */ U(wi, {
4604
4815
  label: i ? "Disable highlighting" : "Enable highlighting",
4605
4816
  action: "highlight",
4606
- children: /* @__PURE__ */ U(Zr, {
4817
+ children: /* @__PURE__ */ U(yi, {
4607
4818
  onClick: d,
4608
4819
  variant: "ghost",
4609
4820
  size: "icon",
@@ -4611,10 +4822,10 @@ var ti = q("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80
4611
4822
  children: /* @__PURE__ */ U(ue, { className: "size-4" })
4612
4823
  })
4613
4824
  }),
4614
- /* @__PURE__ */ U(ni, {
4825
+ /* @__PURE__ */ U(wi, {
4615
4826
  label: r ? "Remove from favorites" : "Add to favorites",
4616
4827
  action: "favorite",
4617
- children: /* @__PURE__ */ U(Zr, {
4828
+ children: /* @__PURE__ */ U(yi, {
4618
4829
  onClick: u,
4619
4830
  disabled: n,
4620
4831
  variant: "ghost",
@@ -4623,29 +4834,29 @@ var ti = q("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80
4623
4834
  children: /* @__PURE__ */ U(ke, { className: q("size-4", r && "fill-yellow-400") })
4624
4835
  })
4625
4836
  }),
4626
- a && /* @__PURE__ */ U(ni, {
4837
+ a && /* @__PURE__ */ U(wi, {
4627
4838
  label: "Open in new tab",
4628
4839
  action: "open",
4629
- children: /* @__PURE__ */ U(Zr, {
4840
+ children: /* @__PURE__ */ U(yi, {
4630
4841
  asChild: !0,
4631
4842
  variant: "ghost",
4632
4843
  size: "icon",
4633
- className: ti,
4844
+ className: Ci,
4634
4845
  children: /* @__PURE__ */ U("a", {
4635
4846
  href: a,
4636
4847
  target: "_blank",
4637
4848
  rel: "noopener noreferrer",
4638
- children: /* @__PURE__ */ U(B, { className: "size-4" })
4849
+ children: /* @__PURE__ */ U(ie, { className: "size-4" })
4639
4850
  })
4640
4851
  })
4641
4852
  }),
4642
4853
  g && /* @__PURE__ */ W("div", {
4643
4854
  className: "ml-auto flex items-center gap-0.5 rounded-xl border border-muted/60 bg-muted/20 px-1",
4644
4855
  children: [
4645
- /* @__PURE__ */ U(ni, {
4856
+ /* @__PURE__ */ U(wi, {
4646
4857
  label: "Zoom out",
4647
4858
  action: "zoomOut",
4648
- children: /* @__PURE__ */ U(Zr, {
4859
+ children: /* @__PURE__ */ U(yi, {
4649
4860
  onClick: p,
4650
4861
  variant: "ghost",
4651
4862
  size: "icon",
@@ -4653,7 +4864,7 @@ var ti = q("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80
4653
4864
  children: /* @__PURE__ */ U(Be, { className: "size-4" })
4654
4865
  })
4655
4866
  }),
4656
- /* @__PURE__ */ U(ni, {
4867
+ /* @__PURE__ */ U(wi, {
4657
4868
  label: "Reset zoom",
4658
4869
  action: "zoomReset",
4659
4870
  children: /* @__PURE__ */ W("button", {
@@ -4663,10 +4874,10 @@ var ti = q("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80
4663
4874
  children: [_, "%"]
4664
4875
  })
4665
4876
  }),
4666
- /* @__PURE__ */ U(ni, {
4877
+ /* @__PURE__ */ U(wi, {
4667
4878
  label: "Zoom in",
4668
4879
  action: "zoomIn",
4669
- children: /* @__PURE__ */ U(Zr, {
4880
+ children: /* @__PURE__ */ U(yi, {
4670
4881
  onClick: f,
4671
4882
  variant: "ghost",
4672
4883
  size: "icon",
@@ -4676,20 +4887,20 @@ var ti = q("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80
4676
4887
  })
4677
4888
  ]
4678
4889
  }),
4679
- /* @__PURE__ */ U(ni, {
4890
+ /* @__PURE__ */ U(wi, {
4680
4891
  label: "Close",
4681
4892
  action: "close",
4682
- children: /* @__PURE__ */ U(Zr, {
4893
+ children: /* @__PURE__ */ U(yi, {
4683
4894
  onClick: h,
4684
4895
  variant: "ghost",
4685
4896
  size: "icon",
4686
- className: q(ti, !g && "ml-auto"),
4897
+ className: q(Ci, !g && "ml-auto"),
4687
4898
  children: /* @__PURE__ */ U(Le, { className: "size-4" })
4688
4899
  })
4689
4900
  })
4690
4901
  ]
4691
4902
  });
4692
- }, ii = ({ value: e, onChange: t, onSubmit: n }) => /* @__PURE__ */ U("div", {
4903
+ }, Ei = ({ value: e, onChange: t, onSubmit: n }) => /* @__PURE__ */ U("div", {
4693
4904
  className: "relative",
4694
4905
  children: /* @__PURE__ */ U("input", {
4695
4906
  value: e,
@@ -4699,7 +4910,7 @@ var ti = q("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80
4699
4910
  placeholder: "Ask AI any question...",
4700
4911
  className: "w-full px-3 py-2 text-sm rounded-md border border-input bg-background text-foreground focus:outline-none focus:ring-2 focus:ring-ring"
4701
4912
  })
4702
- }), ai = ({ questions: e, isLoading: n, error: i, onQuestionClick: a }) => {
4913
+ }), Di = ({ questions: e, isLoading: n, error: i, onQuestionClick: a }) => {
4703
4914
  let o = r.useMemo(() => {
4704
4915
  let t = [];
4705
4916
  return e.forEach((e) => {
@@ -4736,7 +4947,7 @@ var ti = q("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80
4736
4947
  children: i
4737
4948
  })
4738
4949
  ] });
4739
- }, oi = ({ response: e, isLoading: t, error: n }) => /* @__PURE__ */ W(H, { children: [
4950
+ }, Oi = ({ response: e, isLoading: t, error: n }) => /* @__PURE__ */ W(H, { children: [
4740
4951
  t && /* @__PURE__ */ U("div", {
4741
4952
  className: "flex justify-center",
4742
4953
  children: /* @__PURE__ */ U("div", { className: "animate-spin rounded-full h-8 w-8 border-b-2 border-blue-500" })
@@ -4750,10 +4961,10 @@ var ti = q("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80
4750
4961
  className: "bg-red-500 text-white p-2 rounded-md text-sm",
4751
4962
  children: n
4752
4963
  })
4753
- ] }), si = ({ html: e, isHighlightMode: t = !1, fontScale: n = 1 }) => {
4964
+ ] }), ki = ({ html: e, isHighlightMode: t = !1, fontScale: n = 1 }) => {
4754
4965
  let [r, i] = p("");
4755
4966
  return u(() => {
4756
- i(Tt.sanitize(e || "", {
4967
+ i(Dt.sanitize(e || "", {
4757
4968
  ADD_TAGS: ["figure", "figcaption"],
4758
4969
  ADD_ATTR: ["loading"]
4759
4970
  }));
@@ -4773,7 +4984,7 @@ var ti = q("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80
4773
4984
  },
4774
4985
  dangerouslySetInnerHTML: { __html: r }
4775
4986
  });
4776
- }, ci = ({ article: e, isHighlightMode: t, fontScale: n = 1 }) => /* @__PURE__ */ U("div", {
4987
+ }, Ai = ({ article: e, isHighlightMode: t, fontScale: n = 1 }) => /* @__PURE__ */ U("div", {
4777
4988
  className: "border-t border-border pt-6",
4778
4989
  children: /* @__PURE__ */ W("div", { children: [
4779
4990
  /* @__PURE__ */ U("div", { className: "flex items-start justify-between mb-2" }),
@@ -4794,24 +5005,24 @@ var ti = q("h-9 w-9 rounded-xl transition-all duration-200", "hover:bg-muted/80
4794
5005
  }),
4795
5006
  /* @__PURE__ */ U("div", {
4796
5007
  id: "article-content",
4797
- children: /* @__PURE__ */ U(si, {
5008
+ children: /* @__PURE__ */ U(ki, {
4798
5009
  html: e.html || "",
4799
5010
  isHighlightMode: t,
4800
5011
  fontScale: n
4801
5012
  })
4802
5013
  })
4803
5014
  ] })
4804
- }), li = /(?:https?:\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/g, ui = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;
4805
- function di(e) {
5015
+ }), ji = /(?:https?:\/\/)?(?:www\.)?[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6}\b(?:[-a-zA-Z0-9()@:%_\+.~#?&\/=]*)/g, Mi = /[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}/g;
5016
+ function Ni(e) {
4806
5017
  return e.includes("](") || e.includes(")[") ? !1 : /\.(com|org|net|io|dev|co|uk|de|fr|it|es|jp|cn|in|br|au|ca|us|gov|edu|mil|int|xyz|info|app|tech|online|site|website|store|shop|blog|news|tv|me|cc|ws|name|mobi|asia|tel|travel|jobs|pro|museum|coop|aero|arpa|biz|cat|jobs|post|tel|xxx|ac|ad|ae|af|ag|ai|al|am|ao|aq|ar|as|at|aw|ax|az|ba|bb|bd|be|bf|bg|bh|bi|bj|bm|bn|bo|br|bs|bt|bv|bw|by|bz|ca|cc|cd|cf|cg|ch|ci|ck|cl|cm|cn|co|cr|cu|cv|cw|cx|cy|cz|de|dj|dk|dm|do|dz|ec|ee|eg|eh|er|es|et|eu|fi|fj|fk|fm|fo|fr|ga|gb|gd|ge|gf|gg|gh|gi|gl|gm|gn|gp|gq|gr|gs|gt|gu|gw|gy|hk|hm|hn|hr|ht|hu|id|ie|il|im|in|io|iq|ir|is|it|je|jm|jo|jp|ke|kg|kh|ki|km|kn|kp|kr|kw|ky|kz|la|lb|lc|li|lk|lr|ls|lt|lu|lv|ly|ma|mc|md|me|mg|mh|mk|ml|mm|mn|mo|mp|mq|mr|ms|mt|mu|mv|mw|mx|my|mz|na|nc|ne|nf|ng|ni|nl|no|np|nr|nu|nz|om|pa|pe|pf|pg|ph|pk|pl|pm|pn|pr|ps|pt|pw|py|qa|re|ro|rs|ru|rw|sa|sb|sc|sd|se|sg|sh|si|sj|sk|sl|sm|sn|so|sr|ss|st|su|sv|sx|sy|sz|tc|td|tf|tg|th|tj|tk|tl|tm|tn|to|tr|tt|tv|tw|tz|ua|ug|uk|um|us|uy|uz|va|vc|ve|vg|vi|vn|vu|wf|ws|ye|yt|za|zm|zw)(?:\/|$)/i.test(e);
4807
5018
  }
4808
- function fi(e) {
5019
+ function Pi(e) {
4809
5020
  return /^https?:\/\//i.test(e) ? e : `https://${e}`;
4810
5021
  }
4811
- function pi(e) {
5022
+ function Fi(e) {
4812
5023
  if (!e || typeof e != "string") return e;
4813
5024
  let t = e, n = [], r;
4814
- for (ui.lastIndex = 0; (r = ui.exec(t)) !== null;) {
5025
+ for (Mi.lastIndex = 0; (r = Mi.exec(t)) !== null;) {
4815
5026
  let e = r[0], i = r.index, a = t.substring(0, i), o = t.substring(i + e.length);
4816
5027
  !a.endsWith("](") && !o.startsWith(")") && n.push({
4817
5028
  email: e,
@@ -4823,9 +5034,9 @@ function pi(e) {
4823
5034
  t = t.substring(0, i) + `[${r}](mailto:${r})` + t.substring(i + r.length);
4824
5035
  }
4825
5036
  let i = [], a;
4826
- for (li.lastIndex = 0; (a = li.exec(t)) !== null;) {
5037
+ for (ji.lastIndex = 0; (a = ji.exec(t)) !== null;) {
4827
5038
  let e = a[0], n = a.index;
4828
- if (ui.test(e)) continue;
5039
+ if (Mi.test(e)) continue;
4829
5040
  let r = t.substring(0, n), o = t.substring(n + e.length);
4830
5041
  if (r.endsWith("](") || o.startsWith(")") || (r.match(/```/g) || []).length % 2 != 0) continue;
4831
5042
  let s = r.lastIndexOf("`");
@@ -4833,23 +5044,23 @@ function pi(e) {
4833
5044
  let e = t.substring(s + 1).indexOf("`");
4834
5045
  if (e !== -1 && e > n - s - 1) continue;
4835
5046
  }
4836
- di(e) && i.push({
5047
+ Ni(e) && i.push({
4837
5048
  url: e,
4838
5049
  index: n
4839
5050
  });
4840
5051
  }
4841
5052
  for (let e = i.length - 1; e >= 0; e--) {
4842
- let { url: n, index: r } = i[e], a = fi(n);
5053
+ let { url: n, index: r } = i[e], a = Pi(n);
4843
5054
  t = t.substring(0, r) + `[${n}](${a})` + t.substring(r + n.length);
4844
5055
  }
4845
5056
  return t;
4846
5057
  }
4847
5058
  //#endregion
4848
5059
  //#region src/components/ArticleReader/unified-markdown.tsx
4849
- function mi(e) {
5060
+ function Ii(e) {
4850
5061
  return !e || e.startsWith("http://") || e.startsWith("https://") || e.includes("://") ? !1 : e.startsWith("/") || e.startsWith("#");
4851
5062
  }
4852
- function hi(e, t) {
5063
+ function Li(e, t) {
4853
5064
  if (t.startsWith("#")) {
4854
5065
  e.preventDefault();
4855
5066
  let n = t.substring(1), r = document.getElementById(n);
@@ -4859,22 +5070,22 @@ function hi(e, t) {
4859
5070
  });
4860
5071
  }
4861
5072
  }
4862
- function gi({ code: e }) {
4863
- let [t, n] = p(!1);
5073
+ function Ri({ code: e }) {
5074
+ let [t, n] = p(!1), r = c(async () => {
5075
+ try {
5076
+ await navigator.clipboard.writeText(e), n(!0), setTimeout(() => n(!1), 2e3);
5077
+ } catch (e) {
5078
+ console.error("Failed to copy:", e);
5079
+ }
5080
+ }, [e]);
4864
5081
  return /* @__PURE__ */ U("button", {
4865
- onClick: c(async () => {
4866
- try {
4867
- await navigator.clipboard.writeText(e), n(!0), setTimeout(() => n(!1), 2e3);
4868
- } catch (e) {
4869
- console.error("Failed to copy:", e);
4870
- }
4871
- }, [e]),
5082
+ onClick: r,
4872
5083
  className: q("absolute top-3 right-3 p-1.5 rounded-md", "opacity-0 group-hover:opacity-100 transition-opacity duration-150", "bg-zinc-200/80 hover:bg-zinc-300 dark:bg-zinc-700/80 dark:hover:bg-zinc-600", "text-zinc-600 hover:text-zinc-800 dark:text-zinc-400 dark:hover:text-zinc-200", "focus:outline-none focus:ring-1 focus:ring-zinc-400 dark:focus:ring-zinc-500"),
4873
5084
  "aria-label": t ? "Copied!" : "Copy code",
4874
- children: t ? /* @__PURE__ */ U(k, { className: "h-4 w-4 text-green-600 dark:text-green-400" }) : /* @__PURE__ */ U(z, { className: "h-4 w-4" })
5085
+ children: t ? /* @__PURE__ */ U(k, { className: "h-4 w-4 text-green-600 dark:text-green-400" }) : /* @__PURE__ */ U(R, { className: "h-4 w-4" })
4875
5086
  });
4876
5087
  }
4877
- function _i({ children: e }) {
5088
+ function zi({ children: e }) {
4878
5089
  let t = f(null), [n, r] = p("");
4879
5090
  return u(() => {
4880
5091
  if (t.current) {
@@ -4890,18 +5101,18 @@ function _i({ children: e }) {
4890
5101
  ref: t,
4891
5102
  className: q("p-4 rounded-xl overflow-x-auto", "bg-zinc-100 dark:bg-zinc-900", "border border-zinc-200 dark:border-zinc-800", "text-[13px] font-mono leading-relaxed", "text-zinc-800 dark:text-zinc-200", "[&_code]:bg-transparent [&_code]:text-inherit [&_code]:p-0"),
4892
5103
  children: e
4893
- }), n && /* @__PURE__ */ U(gi, { code: n })]
5104
+ }), n && /* @__PURE__ */ U(Ri, { code: n })]
4894
5105
  });
4895
5106
  }
4896
- var vi = r.memo(({ content: e, className: t, isStreaming: n = !1 }) => {
5107
+ var Bi = r.memo(({ content: e, className: t, isStreaming: n = !1 }) => {
4897
5108
  if (!e) return /* @__PURE__ */ U("div", {
4898
5109
  className: q("text-muted-foreground text-sm", t),
4899
5110
  children: "No content"
4900
5111
  });
4901
- let r = pi(e);
5112
+ let r = Fi(e);
4902
5113
  return /* @__PURE__ */ U("div", {
4903
5114
  className: q("kortix-markdown", t),
4904
- children: /* @__PURE__ */ U(Dt, {
5115
+ children: /* @__PURE__ */ U(kt, {
4905
5116
  isAnimating: n,
4906
5117
  components: {
4907
5118
  h1: ({ children: e }) => /* @__PURE__ */ U("h1", {
@@ -4945,13 +5156,13 @@ var vi = r.memo(({ content: e, className: t, isStreaming: n = !1 }) => {
4945
5156
  children: e
4946
5157
  }),
4947
5158
  a: ({ href: e, children: t }) => {
4948
- let n = mi(e), r = e?.startsWith("#"), i = q("font-medium text-foreground", "underline decoration-foreground/30 underline-offset-[3px] decoration-[1px]", "hover:decoration-foreground/60 transition-colors duration-150");
5159
+ let n = Ii(e), r = e?.startsWith("#"), i = q("font-medium text-foreground", "underline decoration-foreground/30 underline-offset-[3px] decoration-[1px]", "hover:decoration-foreground/60 transition-colors duration-150");
4949
5160
  return r ? /* @__PURE__ */ U("a", {
4950
5161
  href: e,
4951
- onClick: (t) => hi(t, e),
5162
+ onClick: (t) => Li(t, e),
4952
5163
  className: i,
4953
5164
  children: t
4954
- }) : n ? /* @__PURE__ */ U(Et, {
5165
+ }) : n ? /* @__PURE__ */ U(Ot, {
4955
5166
  href: e || "#",
4956
5167
  className: i,
4957
5168
  children: t
@@ -4970,7 +5181,7 @@ var vi = r.memo(({ content: e, className: t, isStreaming: n = !1 }) => {
4970
5181
  className: "px-2 py-1 rounded-md text-[13px] font-mono bg-card dark:bg-[#161618] border border-neutral-200 dark:border-neutral-700/50 text-foreground",
4971
5182
  children: e
4972
5183
  }),
4973
- pre: ({ children: e }) => /* @__PURE__ */ U(_i, { children: e }),
5184
+ pre: ({ children: e }) => /* @__PURE__ */ U(zi, { children: e }),
4974
5185
  blockquote: ({ children: e }) => /* @__PURE__ */ U("blockquote", {
4975
5186
  className: q("my-5 pl-4 py-1 text-sm", "border-l-2 border-border", "text-muted-foreground", "[&>p]:my-2"),
4976
5187
  children: e
@@ -5051,11 +5262,11 @@ var vi = r.memo(({ content: e, className: t, isStreaming: n = !1 }) => {
5051
5262
  })
5052
5263
  });
5053
5264
  });
5054
- vi.displayName = "UnifiedMarkdown";
5265
+ Bi.displayName = "UnifiedMarkdown";
5055
5266
  //#endregion
5056
5267
  //#region src/components/ArticleReader/ArticleExtractPanel.tsx
5057
- var yi = (e) => {
5058
- let { isOpen: n, url: r, searchText: i, panelWidth: a, setPanelWidth: o, closePanel: s } = Mt(), { isAuthenticated: c } = An(), { chatModelProvider: l } = J(), d = e.isOpen === void 0 ? n : e.isOpen, m = e.onClose || s, h = e.url || r, g = e.searchText === void 0 ? i : e.searchText, [_, v] = p(null), [y, b] = p([]), [x, S] = p(!1), [C, w] = p(t.defaultSummarizePrompt), [T, E] = p(!1), [D, O] = p(!1), [k, A] = p(!1), [j, ee] = p(""), [M, N] = p(""), [P, F] = p([]), [I, L] = p(""), [R, z] = p(!1), [te, ne] = p(!1), [B, re] = p(!1), [ie, ae] = p(!1), [oe, se] = p(a), [ce, le] = p(!1), [ue, de] = p(!1), [fe, pe] = p(1), me = f(null), V = f({}), he = .5, ge = 1.8, _e = .1;
5268
+ var Vi = (e) => {
5269
+ let { isOpen: n, url: r, searchText: i, panelWidth: a, setPanelWidth: o, closePanel: s } = Lt(), { isAuthenticated: c } = Fn(), { chatModelProvider: l } = J(), d = e.isOpen === void 0 ? n : e.isOpen, m = e.onClose || s, h = e.url || r, g = e.searchText === void 0 ? i : e.searchText, [_, v] = p(null), [y, b] = p([]), [x, S] = p(!1), [C, w] = p(t.defaultSummarizePrompt), [T, E] = p(!1), [D, O] = p(!1), [k, A] = p(!1), [j, M] = p(""), [N, ee] = p(""), [P, F] = p([]), [I, te] = p(""), [L, R] = p(!1), [ne, re] = p(!1), [ie, ae] = p(!1), [oe, se] = p(!1), [z, ce] = p(a), [B, le] = p(!1), [ue, de] = p(!1), [fe, pe] = p(1), me = f(null), V = f({}), he = .5, ge = 1.8, _e = .1;
5059
5270
  u(() => {
5060
5271
  let e = parseFloat(localStorage.getItem("articleFontScale") || "");
5061
5272
  Number.isNaN(e) || pe(Math.min(ge, Math.max(he, e)));
@@ -5071,21 +5282,21 @@ var yi = (e) => {
5071
5282
  }, ye = () => ve(fe + _e), be = () => ve(fe - _e), xe = () => ve(1);
5072
5283
  u(() => {
5073
5284
  let e = () => {
5074
- ae(window.innerWidth >= 1024);
5285
+ se(window.innerWidth >= 1024);
5075
5286
  };
5076
5287
  return e(), window.addEventListener("resize", e), () => window.removeEventListener("resize", e);
5077
5288
  }, []), u(() => {
5078
5289
  let e = (e) => {
5079
- if (!ce) return;
5290
+ if (!B) return;
5080
5291
  let t = window.innerWidth - e.clientX, n = Math.max(400, Math.min(t, window.innerWidth - 100));
5081
- se(n), o(n);
5292
+ ce(n), o(n);
5082
5293
  }, t = () => {
5083
5294
  le(!1);
5084
5295
  };
5085
- return ce && (document.addEventListener("mousemove", e), document.addEventListener("mouseup", t), document.body.style.cursor = "ew-resize", document.body.style.userSelect = "none"), () => {
5296
+ return B && (document.addEventListener("mousemove", e), document.addEventListener("mouseup", t), document.body.style.cursor = "ew-resize", document.body.style.userSelect = "none"), () => {
5086
5297
  document.removeEventListener("mousemove", e), document.removeEventListener("mouseup", t), document.body.style.cursor = "", document.body.style.userSelect = "";
5087
5298
  };
5088
- }, [ce, o]), u(() => {
5299
+ }, [B, o]), u(() => {
5089
5300
  d && h ? (de(!1), Se()) : d || de(!1);
5090
5301
  }, [d, h]);
5091
5302
  let Se = async () => {
@@ -5126,15 +5337,15 @@ var yi = (e) => {
5126
5337
  }, Ce = async () => {
5127
5338
  try {
5128
5339
  let { data: e } = await it(), t = e?.favorites?.some((e) => e.url === h);
5129
- z(!!t);
5340
+ R(!!t);
5130
5341
  } catch (e) {
5131
5342
  console.error("Error checking favorite status:", e);
5132
5343
  }
5133
5344
  }, we = async () => {
5134
5345
  if (_) {
5135
- ne(!0);
5346
+ re(!0);
5136
5347
  try {
5137
- R ? (await ot({ query: { url: h } }), z(!1), G.info("Removed from favorites")) : (await Ve({ body: {
5348
+ L ? (await ot({ query: { url: h } }), R(!1), G.info("Removed from favorites")) : (await Ve({ body: {
5138
5349
  url: _.url || h,
5139
5350
  title: _.title,
5140
5351
  cite: _.cite,
@@ -5144,11 +5355,11 @@ var yi = (e) => {
5144
5355
  source: _.source,
5145
5356
  word_count: _.word_count,
5146
5357
  html: _.html
5147
- } }), z(!0), G.success("Added to favorites"));
5358
+ } }), R(!0), G.success("Added to favorites"));
5148
5359
  } catch (e) {
5149
5360
  console.error("Error toggling favorite:", e), G.error("Failed to toggle favorite");
5150
5361
  } finally {
5151
- ne(!1);
5362
+ re(!1);
5152
5363
  }
5153
5364
  }
5154
5365
  }, Te = () => {
@@ -5165,7 +5376,7 @@ var yi = (e) => {
5165
5376
  return l;
5166
5377
  }, Ee = async (e) => {
5167
5378
  if (!_) return;
5168
- let n = Te(), r = _.html?.replace(/<[^>]*>?/g, "").slice(0, t.maxArticleLength), i = e === "question", a = i ? O : A, o = i ? N : L;
5379
+ let n = Te(), r = _.html?.replace(/<[^>]*>?/g, "").slice(0, t.maxArticleLength), i = e === "question", a = i ? O : A, o = i ? ee : te;
5169
5380
  a(!0), o("");
5170
5381
  try {
5171
5382
  if (i) {
@@ -5182,7 +5393,7 @@ var yi = (e) => {
5182
5393
  throw Error(e);
5183
5394
  }
5184
5395
  let a = t?.content || "";
5185
- ee(a), b((e) => [
5396
+ M(a), b((e) => [
5186
5397
  ...e,
5187
5398
  {
5188
5399
  role: "user",
@@ -5248,7 +5459,7 @@ var yi = (e) => {
5248
5459
  ask: () => Ee("question"),
5249
5460
  suggest: () => Ee("suggest-followups"),
5250
5461
  copy: Oe,
5251
- highlight: () => re((e) => !e),
5462
+ highlight: () => ae((e) => !e),
5252
5463
  favorite: we,
5253
5464
  open: () => {
5254
5465
  let e = _?.url || h;
@@ -5261,8 +5472,8 @@ var yi = (e) => {
5261
5472
  }, u(() => {
5262
5473
  if (!d) return;
5263
5474
  let e = (e) => /^[a-z]$/.test(e) ? `Key${e.toUpperCase()}` : /^[0-9]$/.test(e) ? `Digit${e}` : e === "-" ? "Minus" : e === "=" ? "Equal" : e, t = {};
5264
- Object.keys(Qr).forEach((n) => {
5265
- let { alt: r, key: i } = Qr[n];
5475
+ Object.keys(bi).forEach((n) => {
5476
+ let { alt: r, key: i } = bi[n];
5266
5477
  r && (t[e(i.toLowerCase())] = n);
5267
5478
  });
5268
5479
  let n = (e) => {
@@ -5284,19 +5495,19 @@ var yi = (e) => {
5284
5495
  className: "flex h-full flex-col bg-background shadow-xl",
5285
5496
  children: [/* @__PURE__ */ U("div", {
5286
5497
  className: "shrink-0 border-b border-border bg-background/95 px-4 py-3 backdrop-blur supports-[backdrop-filter]:bg-background/80",
5287
- children: /* @__PURE__ */ U(ri, {
5498
+ children: /* @__PURE__ */ U(Ti, {
5288
5499
  isLoadingAI: D,
5289
5500
  isLoadingFollowups: k,
5290
- isLoadingFavorite: te,
5291
- isFavorited: R,
5292
- isHighlightMode: B,
5501
+ isLoadingFavorite: ne,
5502
+ isFavorited: L,
5503
+ isHighlightMode: ie,
5293
5504
  articleUrl: _?.url || h,
5294
5505
  fontScale: fe,
5295
5506
  onAskClick: () => Ee("question"),
5296
5507
  onSuggestClick: () => Ee("suggest-followups"),
5297
5508
  onCopyClick: Oe,
5298
5509
  onFavoriteClick: we,
5299
- onHighlightToggle: () => re(!B),
5510
+ onHighlightToggle: () => ae(!ie),
5300
5511
  onZoomIn: ye,
5301
5512
  onZoomOut: be,
5302
5513
  onZoomReset: xe,
@@ -5313,12 +5524,12 @@ var yi = (e) => {
5313
5524
  className: "bg-blue-500 text-white text-sm font-medium px-3 py-2 rounded-md shadow-lg",
5314
5525
  children: "Copied!"
5315
5526
  }),
5316
- /* @__PURE__ */ U(ii, {
5527
+ /* @__PURE__ */ U(Ei, {
5317
5528
  value: C,
5318
5529
  onChange: w,
5319
5530
  onSubmit: () => Ee("question")
5320
5531
  }),
5321
- /* @__PURE__ */ U(ai, {
5532
+ /* @__PURE__ */ U(Di, {
5322
5533
  questions: P,
5323
5534
  isLoading: k,
5324
5535
  error: I,
@@ -5349,27 +5560,27 @@ var yi = (e) => {
5349
5560
  })
5350
5561
  }, t))
5351
5562
  }),
5352
- (D || j && y.length === 0) && /* @__PURE__ */ U(oi, {
5563
+ (D || j && y.length === 0) && /* @__PURE__ */ U(Oi, {
5353
5564
  response: j,
5354
5565
  isLoading: D,
5355
- error: M
5566
+ error: N
5356
5567
  }),
5357
- M && !D && /* @__PURE__ */ U("div", {
5568
+ N && !D && /* @__PURE__ */ U("div", {
5358
5569
  className: "bg-red-500 text-white p-2 rounded-md text-sm",
5359
- children: M
5570
+ children: N
5360
5571
  })
5361
5572
  ]
5362
- }), _ && /* @__PURE__ */ U(ci, {
5573
+ }), _ && /* @__PURE__ */ U(Ai, {
5363
5574
  article: _,
5364
- isHighlightMode: B,
5575
+ isHighlightMode: ie,
5365
5576
  fontScale: fe
5366
5577
  })]
5367
5578
  })
5368
5579
  })]
5369
5580
  });
5370
- return !d || !ue ? null : ie ? /* @__PURE__ */ W("div", {
5581
+ return !d || !ue ? null : oe ? /* @__PURE__ */ W("div", {
5371
5582
  className: "fixed top-0 right-0 h-screen z-40 transition-all duration-300",
5372
- style: { width: `${oe}px` },
5583
+ style: { width: `${z}px` },
5373
5584
  children: [/* @__PURE__ */ U("div", {
5374
5585
  ref: me,
5375
5586
  onMouseDown: () => le(!0),
@@ -5377,21 +5588,21 @@ var yi = (e) => {
5377
5588
  style: { touchAction: "none" },
5378
5589
  children: /* @__PURE__ */ U("div", { className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2 w-1 h-12 rounded-full bg-muted-foreground opacity-50 hover:opacity-100 transition-opacity" })
5379
5590
  }), ke()]
5380
- }) : /* @__PURE__ */ U(In, {
5591
+ }) : /* @__PURE__ */ U(Vn, {
5381
5592
  open: d,
5382
5593
  onOpenChange: (e) => !e && m(),
5383
- children: /* @__PURE__ */ W(Bn, {
5594
+ children: /* @__PURE__ */ W(Gn, {
5384
5595
  className: "pointer-events-auto fixed inset-0 !top-0 !left-0 !translate-x-0 !translate-y-0 h-full w-full max-w-none p-0 m-0 rounded-none border-0 overflow-hidden data-[state=open]:animate-in data-[state=closed]:animate-out data-[state=closed]:fade-out-0 data-[state=open]:fade-in-0 data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right",
5385
5596
  hideCloseButton: !0,
5386
- children: [/* @__PURE__ */ U(Jr, { children: /* @__PURE__ */ U(Vn, { children: "Article Details" }) }), /* @__PURE__ */ U("div", {
5597
+ children: [/* @__PURE__ */ U(gi, { children: /* @__PURE__ */ U(Kn, { children: "Article Details" }) }), /* @__PURE__ */ U("div", {
5387
5598
  className: "h-full overflow-y-auto",
5388
5599
  children: ke()
5389
5600
  })]
5390
5601
  })
5391
5602
  });
5392
- }, bi = () => {
5393
- let { sections: e, chatTurns: n, loading: r, messageAppeared: a, newChat: o, chatId: s } = J(), { isOpen: c, panelWidth: l } = Mt(), { isAuthenticated: d } = An(), [m, h] = p(!1), g = f(null), _ = f(null), v = f(!1);
5394
- return u(() => {
5603
+ }, Hi = () => {
5604
+ let { sections: e, chatTurns: n, loading: r, messageAppeared: a, newChat: o, chatId: s } = J(), { isOpen: c, panelWidth: l } = Lt(), { isAuthenticated: d } = Fn(), [m, h] = p(!1), g = f(null), _ = f(null), v = f(!1);
5605
+ u(() => {
5395
5606
  let e = () => {
5396
5607
  h(window.innerWidth >= 1024);
5397
5608
  };
@@ -5403,15 +5614,17 @@ var yi = (e) => {
5403
5614
  }, 100);
5404
5615
  return;
5405
5616
  }
5406
- }, [n]), /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ W("div", {
5617
+ }, [n]);
5618
+ let y = m && c ? { width: `calc(100% - ${l}px)` } : {};
5619
+ return /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ W("div", {
5407
5620
  className: "flex flex-col min-h-full transition-all duration-300",
5408
- style: m && c ? { width: `calc(100% - ${l}px)` } : {},
5621
+ style: y,
5409
5622
  children: [/* @__PURE__ */ W("div", {
5410
5623
  className: `flex-1 flex flex-col space-y-3 pb-48 ${m && !c ? "px-0 max-w-[800px] mx-auto w-full" : "px-4 lg:px-8"}`,
5411
5624
  children: [
5412
5625
  e.map((t, n) => {
5413
5626
  let r = n === e.length - 1;
5414
- return /* @__PURE__ */ W(i, { children: [/* @__PURE__ */ U(Cr, {
5627
+ return /* @__PURE__ */ W(i, { children: [/* @__PURE__ */ U(Or, {
5415
5628
  section: t,
5416
5629
  sectionIndex: n,
5417
5630
  dividerRef: r ? g : void 0,
@@ -5442,13 +5655,13 @@ var yi = (e) => {
5442
5655
  ]
5443
5656
  }), /* @__PURE__ */ U("div", {
5444
5657
  className: "sticky bottom-[60px] md:bottom-0 z-40 bg-gradient-to-t from-background via-background to-transparent pt-4 pb-2",
5445
- children: /* @__PURE__ */ U(qr, {})
5658
+ children: /* @__PURE__ */ U(hi, {})
5446
5659
  })]
5447
- }), /* @__PURE__ */ U(yi, {})] });
5660
+ }), /* @__PURE__ */ U(Vi, {})] });
5448
5661
  };
5449
5662
  //#endregion
5450
5663
  //#region src/ui/gradient-blur.tsx
5451
- function xi({ radius: e = 60, opacityDecay: t = .025, backgroundColor: n = "transparent", color: r, colorGenerator: i }) {
5664
+ function Ui({ radius: e = 60, opacityDecay: t = .025, backgroundColor: n = "transparent", color: r, colorGenerator: i }) {
5452
5665
  let a = f(null), o = f({
5453
5666
  x: 0,
5454
5667
  y: 0
@@ -5462,11 +5675,11 @@ function xi({ radius: e = 60, opacityDecay: t = .025, backgroundColor: n = "tran
5462
5675
  if (!r) return;
5463
5676
  let i = r.getContext("2d");
5464
5677
  if (!i) return;
5465
- let c = () => {
5678
+ let c = 0, u = () => {
5466
5679
  r.width = window.innerWidth, r.height = window.innerHeight;
5467
5680
  };
5468
- c();
5469
- let u = () => {
5681
+ u();
5682
+ let d = () => {
5470
5683
  i.globalCompositeOperation = "source-over", n === "transparent" ? i.clearRect(0, 0, r.width, r.height) : (i.fillStyle = n, i.fillRect(0, 0, r.width, r.height)), i.globalCompositeOperation = "lighter";
5471
5684
  let a = {
5472
5685
  col: l(),
@@ -5476,20 +5689,20 @@ function xi({ radius: e = 60, opacityDecay: t = .025, backgroundColor: n = "tran
5476
5689
  alpha: 1
5477
5690
  };
5478
5691
  s.current.push(a);
5479
- let c = [];
5692
+ let u = [];
5480
5693
  for (let n = 0; n < s.current.length; n++) {
5481
5694
  let r = s.current[n];
5482
- r.grdblur.addColorStop(0, `rgba(${r.col[0]},${r.col[1]},${r.col[2]},0.95)`), r.grdblur.addColorStop(.2, `rgba(${r.col[0]},${r.col[1]},${r.col[2]},0.7)`), r.grdblur.addColorStop(.5, `rgba(${r.col[0]},${r.col[1]},${r.col[2]},0.3)`), r.grdblur.addColorStop(1, `rgba(${r.col[0]},${r.col[1]},${r.col[2]},0)`), i.beginPath(), i.fillStyle = r.grdblur, i.globalAlpha = r.alpha, i.arc(r.x, r.y, e, 0, Math.PI * 2), i.fill(), r.alpha -= t, r.alpha <= 0 && c.push(n);
5695
+ r.grdblur.addColorStop(0, `rgba(${r.col[0]},${r.col[1]},${r.col[2]},0.95)`), r.grdblur.addColorStop(.2, `rgba(${r.col[0]},${r.col[1]},${r.col[2]},0.7)`), r.grdblur.addColorStop(.5, `rgba(${r.col[0]},${r.col[1]},${r.col[2]},0.3)`), r.grdblur.addColorStop(1, `rgba(${r.col[0]},${r.col[1]},${r.col[2]},0)`), i.beginPath(), i.fillStyle = r.grdblur, i.globalAlpha = r.alpha, i.arc(r.x, r.y, e, 0, Math.PI * 2), i.fill(), r.alpha -= t, r.alpha <= 0 && u.push(n);
5483
5696
  }
5484
- for (let e = c.length - 1; e >= 0; e--) s.current.splice(c[e], 1);
5485
- i.globalAlpha = 1, requestAnimationFrame(u);
5486
- }, d = (e) => {
5487
- o.current.x = e.pageX, o.current.y = e.pageY;
5697
+ for (let e = u.length - 1; e >= 0; e--) s.current.splice(u[e], 1);
5698
+ i.globalAlpha = 1, c = requestAnimationFrame(d);
5488
5699
  }, f = (e) => {
5700
+ o.current.x = e.pageX, o.current.y = e.pageY;
5701
+ }, p = (e) => {
5489
5702
  o.current.x = e.touches[0].pageX, o.current.y = e.touches[0].pageY;
5490
5703
  };
5491
- return window.addEventListener("mousemove", d), window.addEventListener("touchmove", f, { passive: !0 }), window.addEventListener("resize", c), u(), () => {
5492
- window.removeEventListener("mousemove", d), window.removeEventListener("touchmove", f), window.removeEventListener("resize", c);
5704
+ return window.addEventListener("mousemove", f), window.addEventListener("touchmove", p, { passive: !0 }), window.addEventListener("resize", u), d(), () => {
5705
+ cancelAnimationFrame(c), window.removeEventListener("mousemove", f), window.removeEventListener("touchmove", p), window.removeEventListener("resize", u), s.current = [];
5493
5706
  };
5494
5707
  }, [
5495
5708
  e,
@@ -5508,8 +5721,8 @@ function xi({ radius: e = 60, opacityDecay: t = .025, backgroundColor: n = "tran
5508
5721
  }
5509
5722
  //#endregion
5510
5723
  //#region src/components/ChatHistoryDropdown/useHistoryState.ts
5511
- var Si = "qwksearch_pinned_chats";
5512
- function Ci(e) {
5724
+ var Wi = "qwksearch_pinned_chats";
5725
+ function Gi(e) {
5513
5726
  let t = e.messages?.[e.messages.length - 1], n = t && "createdAt" in t ? t.createdAt : void 0;
5514
5727
  if (n) {
5515
5728
  let e = new Date(n).getTime();
@@ -5517,46 +5730,46 @@ function Ci(e) {
5517
5730
  }
5518
5731
  return e.createdAt;
5519
5732
  }
5520
- function wi() {
5733
+ function Ki() {
5521
5734
  if (typeof window > "u") return [];
5522
5735
  try {
5523
- let e = localStorage.getItem(Si);
5736
+ let e = localStorage.getItem(Wi);
5524
5737
  return e ? JSON.parse(e) : [];
5525
5738
  } catch {
5526
5739
  return [];
5527
5740
  }
5528
5741
  }
5529
- function Ti(e) {
5530
- typeof window > "u" || localStorage.setItem(Si, JSON.stringify(e));
5742
+ function qi(e) {
5743
+ typeof window > "u" || localStorage.setItem(Wi, JSON.stringify(e));
5531
5744
  }
5532
- function Ei() {
5533
- let [e, t] = p([]), [n, r] = p(!0), [i, a] = p(!1), [o, s] = p(null), [l, f] = p(!1), [m, h] = p(!1), [g, _] = p(!1), [v, y] = p([]), [b, x] = p(""), [S, C] = p([]), [w, T] = p(!1), { isAuthenticated: E, isLoading: D } = An(), { incognito: O, setIncognito: k } = J();
5745
+ function Ji() {
5746
+ let [e, t] = p([]), [n, r] = p(!0), [i, a] = p(!1), [o, s] = p(null), [l, f] = p(!1), [m, h] = p(!1), [g, _] = p(!1), [v, y] = p([]), [b, x] = p(""), [S, C] = p([]), [w, T] = p(!1), { isAuthenticated: E, isLoading: D } = Fn(), { incognito: O, setIncognito: k } = J();
5534
5747
  u(() => {
5535
- y(wi());
5748
+ y(Ki());
5536
5749
  }, []);
5537
5750
  let A = c((e, t) => {
5538
5751
  e.preventDefault(), e.stopPropagation(), y((e) => {
5539
5752
  let n = e.includes(t) ? e.filter((e) => e !== t) : [...e, t];
5540
- return Ti(n), n;
5753
+ return qi(n), n;
5541
5754
  });
5542
5755
  }, []), j = d(() => [...e].sort((e, t) => {
5543
5756
  let n = v.includes(e.id), r = v.includes(t.id);
5544
5757
  return n && !r ? -1 : !n && r ? 1 : 0;
5545
- }), [e, v]), ee = d(() => b.trim() ? S : j, [
5758
+ }), [e, v]), M = d(() => b.trim() ? S : j, [
5546
5759
  b,
5547
5760
  S,
5548
5761
  j
5549
- ]), M = c(async () => {
5762
+ ]), N = c(async () => {
5550
5763
  if (!D) {
5551
5764
  r(!0);
5552
5765
  try {
5553
5766
  if (E) {
5554
5767
  let { data: e, error: n } = await rt();
5555
5768
  if (n && n.status === 401) {
5556
- let e = un().map((e) => ({
5769
+ let e = hn().map((e) => ({
5557
5770
  ...e,
5558
5771
  messageCount: e.messages?.filter((e) => e.role === "user").length ?? 0,
5559
- lastMessageAt: Ci(e)
5772
+ lastMessageAt: Gi(e)
5560
5773
  }));
5561
5774
  t(e);
5562
5775
  return;
@@ -5564,7 +5777,7 @@ function Ei() {
5564
5777
  if (n) throw Error(`Failed to fetch chats: ${n.message}`);
5565
5778
  t(Array.isArray(e?.chats) ? e.chats : []);
5566
5779
  } else {
5567
- let e = un().map((e) => ({
5780
+ let e = hn().map((e) => ({
5568
5781
  ...e,
5569
5782
  messageCount: e.messages?.filter((e) => e.role === "user").length ?? 0
5570
5783
  }));
@@ -5578,9 +5791,9 @@ function Ei() {
5578
5791
  }
5579
5792
  }, [E, D]);
5580
5793
  u(() => {
5581
- M();
5582
- }, [M]);
5583
- let N = (e, t) => {
5794
+ N();
5795
+ }, [N]);
5796
+ let ee = (e, t) => {
5584
5797
  e.preventDefault(), e.stopPropagation(), s(t), a(!0);
5585
5798
  }, P = async () => {
5586
5799
  if (o) {
@@ -5589,7 +5802,7 @@ function Ei() {
5589
5802
  if (E) {
5590
5803
  let { error: e } = await Ye({ path: { id: o } });
5591
5804
  if (e) throw Error(`Failed to delete chat: ${e.message}`);
5592
- } else pn(o);
5805
+ } else vn(o);
5593
5806
  t((e) => e.filter((e) => e.id !== o)), G.success("Chat deleted");
5594
5807
  } catch (e) {
5595
5808
  G.error(e.message || "Failed to delete chat");
@@ -5605,16 +5818,16 @@ function Ei() {
5605
5818
  if (E) {
5606
5819
  let { error: e } = await Je();
5607
5820
  if (e) throw Error(`Failed to clear history: ${e.message}`);
5608
- } else mn();
5821
+ } else yn();
5609
5822
  t([]), G.success("All history cleared");
5610
5823
  } catch (e) {
5611
5824
  G.error(e.message || "Failed to clear history");
5612
5825
  } finally {
5613
5826
  h(!1), _(!1);
5614
5827
  }
5615
- }, L = () => {
5828
+ }, te = () => {
5616
5829
  k(!O), G.success(O ? "Private mode off" : "Private mode on — messages won't be saved");
5617
- }, R = c(async (e) => {
5830
+ }, L = c(async (e) => {
5618
5831
  if (!e.trim()) {
5619
5832
  C([]), T(!1);
5620
5833
  return;
@@ -5626,14 +5839,14 @@ function Ei() {
5626
5839
  if (n) throw Error(`Failed to search chats: ${n.message}`);
5627
5840
  C(Array.isArray(t?.chats) ? t.chats : []);
5628
5841
  } else {
5629
- let t = un().filter((t) => {
5842
+ let t = hn().filter((t) => {
5630
5843
  let n = t.title.toLowerCase().includes(e.toLowerCase()), r = t.messages?.some((t) => "content" in t && t.content?.toLowerCase().includes(e.toLowerCase()));
5631
5844
  return n || r;
5632
5845
  });
5633
5846
  C(t.map((e) => ({
5634
5847
  ...e,
5635
5848
  messageCount: e.messages?.filter((e) => e.role === "user").length ?? 0,
5636
- lastMessageAt: Ci(e)
5849
+ lastMessageAt: Gi(e)
5637
5850
  })));
5638
5851
  }
5639
5852
  } catch (e) {
@@ -5644,18 +5857,18 @@ function Ei() {
5644
5857
  }, [E]);
5645
5858
  return u(() => {
5646
5859
  let e = setTimeout(() => {
5647
- R(b);
5860
+ L(b);
5648
5861
  }, 300);
5649
5862
  return () => clearTimeout(e);
5650
- }, [b, R]), {
5863
+ }, [b, L]), {
5651
5864
  chats: e,
5652
5865
  sortedChats: j,
5653
- displayChats: ee,
5866
+ displayChats: M,
5654
5867
  loading: n,
5655
5868
  pinnedIds: v,
5656
5869
  togglePin: A,
5657
5870
  incognito: O,
5658
- toggleIncognito: L,
5871
+ toggleIncognito: te,
5659
5872
  searchQuery: b,
5660
5873
  searchResults: S,
5661
5874
  searching: w,
@@ -5667,7 +5880,7 @@ function Ei() {
5667
5880
  chatToDelete: o,
5668
5881
  setChatToDelete: s,
5669
5882
  deleting: l,
5670
- handleDeleteClick: N,
5883
+ handleDeleteClick: ee,
5671
5884
  handleConfirmDelete: P,
5672
5885
  clearAllDialogOpen: m,
5673
5886
  setClearAllDialogOpen: h,
@@ -5678,7 +5891,7 @@ function Ei() {
5678
5891
  }
5679
5892
  //#endregion
5680
5893
  //#region src/components/ChatHistoryDropdown/HistoryHeader.tsx
5681
- function Di({ incognito: e, onToggleIncognito: t, showClearAll: n, onClearAll: r, searchQuery: i, onSearchChange: a }) {
5894
+ function Yi({ incognito: e, onToggleIncognito: t, showClearAll: n, onClearAll: r, searchQuery: i, onSearchChange: a }) {
5682
5895
  return /* @__PURE__ */ W("div", {
5683
5896
  className: "mb-2 pb-2 border-b border-border space-y-2",
5684
5897
  children: [/* @__PURE__ */ W("div", {
@@ -5725,39 +5938,42 @@ function Di({ incognito: e, onToggleIncognito: t, showClearAll: n, onClearAll: r
5725
5938
  }
5726
5939
  //#endregion
5727
5940
  //#region src/components/ChatHistoryDropdown/HistoryChatItem.tsx
5728
- function Oi({ chat: e, isPinned: t, onTogglePin: n, onDelete: r }) {
5729
- let i = e.messageCount ?? 0;
5941
+ function Xi({ chat: e, isPinned: n, onTogglePin: r, onDelete: i }) {
5942
+ let a = e.messageCount ?? 0;
5730
5943
  return /* @__PURE__ */ W("div", {
5731
5944
  className: "group flex items-center gap-1 px-2 py-1 rounded-lg hover:bg-secondary transition-colors duration-200",
5732
5945
  children: [
5733
- /* @__PURE__ */ W(Et, {
5946
+ /* @__PURE__ */ W(Ot, {
5734
5947
  href: `/c/${e.id}`,
5948
+ onClick: (n) => {
5949
+ t.onOpenChat?.(e.id) && n.preventDefault();
5950
+ },
5735
5951
  className: "flex-1 min-w-0 flex items-center gap-1.5",
5736
5952
  children: [/* @__PURE__ */ W("span", {
5737
5953
  className: "flex items-center gap-1 shrink-0",
5738
- children: [i > 0 && /* @__PURE__ */ W(xr, {
5954
+ children: [a > 0 && /* @__PURE__ */ W(Er, {
5739
5955
  className: "px-1.5 py-0 text-[10px] font-medium bg-zinc-200 text-zinc-700 hover:bg-zinc-200 dark:bg-zinc-700 dark:text-zinc-300 dark:hover:bg-zinc-700 border-0 rounded-md",
5740
- children: [i, "Q"]
5741
- }), /* @__PURE__ */ U(xr, {
5956
+ children: [a, "Q"]
5957
+ }), /* @__PURE__ */ U(Er, {
5742
5958
  className: "px-1.5 py-0 text-[10px] font-medium bg-zinc-100 text-zinc-500 hover:bg-zinc-100 dark:bg-zinc-800 dark:text-zinc-400 dark:hover:bg-zinc-800 border-0 rounded-md",
5743
- children: kt(/* @__PURE__ */ new Date(), e.createdAt)
5959
+ children: Pt(/* @__PURE__ */ new Date(), e.createdAt)
5744
5960
  })]
5745
5961
  }), /* @__PURE__ */ W("p", {
5746
5962
  className: "text-xs text-popover-foreground truncate",
5747
- children: [t && /* @__PURE__ */ U(be, {
5963
+ children: [n && /* @__PURE__ */ U(be, {
5748
5964
  size: 10,
5749
5965
  className: "inline mr-1 text-primary"
5750
5966
  }), e.title]
5751
5967
  })]
5752
5968
  }),
5753
5969
  /* @__PURE__ */ U("button", {
5754
- onClick: (t) => n(t, e.id),
5755
- className: `p-1.5 rounded-lg transition-all duration-200 ${t ? "opacity-100 text-primary hover:bg-primary/10" : "opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-primary hover:bg-primary/10"}`,
5756
- title: t ? "Unpin chat" : "Pin chat",
5970
+ onClick: (t) => r(t, e.id),
5971
+ className: `p-1.5 rounded-lg transition-all duration-200 ${n ? "opacity-100 text-primary hover:bg-primary/10" : "opacity-0 group-hover:opacity-100 text-muted-foreground hover:text-primary hover:bg-primary/10"}`,
5972
+ title: n ? "Unpin chat" : "Pin chat",
5757
5973
  children: /* @__PURE__ */ U(be, { size: 14 })
5758
5974
  }),
5759
5975
  /* @__PURE__ */ U("button", {
5760
- onClick: (t) => r(t, e.id),
5976
+ onClick: (t) => i(t, e.id),
5761
5977
  className: "opacity-0 group-hover:opacity-100 p-1.5 rounded-lg hover:bg-red-500/10 text-muted-foreground hover:text-red-500 transition-all duration-200",
5762
5978
  title: "Delete chat",
5763
5979
  children: /* @__PURE__ */ U(Me, { size: 14 })
@@ -5767,20 +5983,20 @@ function Oi({ chat: e, isPinned: t, onTogglePin: n, onDelete: r }) {
5767
5983
  }
5768
5984
  //#endregion
5769
5985
  //#region src/components/ChatHistoryDropdown/HistoryDialogs.tsx
5770
- function ki({ open: e, onOpenChange: t, title: n, description: r, confirmLabel: i, loadingLabel: a, loading: o, onConfirm: s }) {
5771
- return /* @__PURE__ */ U(In, {
5986
+ function Zi({ open: e, onOpenChange: t, title: n, description: r, confirmLabel: i, loadingLabel: a, loading: o, onConfirm: s }) {
5987
+ return /* @__PURE__ */ U(Vn, {
5772
5988
  open: e,
5773
5989
  onOpenChange: (e) => {
5774
5990
  !e && !o && t(!1);
5775
5991
  },
5776
- children: /* @__PURE__ */ W(Bn, {
5992
+ children: /* @__PURE__ */ W(Gn, {
5777
5993
  className: "w-full max-w-md transform rounded-2xl bg-light-secondary dark:bg-dark-secondary border border-light-200 dark:border-dark-200 p-6 text-left align-middle shadow-xl",
5778
5994
  children: [
5779
- /* @__PURE__ */ U(Vn, {
5995
+ /* @__PURE__ */ U(Kn, {
5780
5996
  className: "text-lg font-medium leading-6 dark:text-white",
5781
5997
  children: n
5782
5998
  }),
5783
- /* @__PURE__ */ U(Hn, {
5999
+ /* @__PURE__ */ U(qn, {
5784
6000
  className: "text-sm dark:text-white/70 text-black/70 mt-2",
5785
6001
  children: r
5786
6002
  }),
@@ -5803,8 +6019,8 @@ function ki({ open: e, onOpenChange: t, title: n, description: r, confirmLabel:
5803
6019
  })
5804
6020
  });
5805
6021
  }
5806
- function Ai({ deleteDialogOpen: e, setDeleteDialogOpen: t, chatToDelete: n, setChatToDelete: r, deleting: i, onConfirmDelete: a, clearAllDialogOpen: o, setClearAllDialogOpen: s, clearingAll: c, onConfirmClearAll: l }) {
5807
- return /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ U(ki, {
6022
+ function Qi({ deleteDialogOpen: e, setDeleteDialogOpen: t, chatToDelete: n, setChatToDelete: r, deleting: i, onConfirmDelete: a, clearAllDialogOpen: o, setClearAllDialogOpen: s, clearingAll: c, onConfirmClearAll: l }) {
6023
+ return /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ U(Zi, {
5808
6024
  open: e,
5809
6025
  onOpenChange: (e) => {
5810
6026
  t(e), e || r(null);
@@ -5815,7 +6031,7 @@ function Ai({ deleteDialogOpen: e, setDeleteDialogOpen: t, chatToDelete: n, setC
5815
6031
  loadingLabel: "Deleting...",
5816
6032
  loading: i,
5817
6033
  onConfirm: a
5818
- }), /* @__PURE__ */ U(ki, {
6034
+ }), /* @__PURE__ */ U(Zi, {
5819
6035
  open: o,
5820
6036
  onOpenChange: s,
5821
6037
  title: "Clear All History",
@@ -5828,14 +6044,14 @@ function Ai({ deleteDialogOpen: e, setDeleteDialogOpen: t, chatToDelete: n, setC
5828
6044
  }
5829
6045
  //#endregion
5830
6046
  //#region src/components/ChatHistoryDropdown/HistoryDropdown.tsx
5831
- var ji = {
6047
+ var $i = {
5832
6048
  Today: /* @__PURE__ */ U(je, { size: 12 }),
5833
6049
  Yesterday: /* @__PURE__ */ U(I, { size: 12 }),
5834
6050
  "This Week": /* @__PURE__ */ U(O, { size: 12 }),
5835
6051
  Older: /* @__PURE__ */ U(S, { size: 12 })
5836
6052
  };
5837
- function Mi(e) {
5838
- let t = /* @__PURE__ */ new Date(), n = new Date(t.getFullYear(), t.getMonth(), t.getDate()), r = /* @__PURE__ */ new Date(n.getTime() - 864e5), i = /* @__PURE__ */ new Date(n.getTime() - 6 * 864e5), a = {
6053
+ function ea(e) {
6054
+ let t = /* @__PURE__ */ new Date(), n = new Date(t.getFullYear(), t.getMonth(), t.getDate()), r = /* @__PURE__ */ new Date(n.getTime() - 864e5), i = /* @__PURE__ */ new Date(n.getTime() - 5184e5), a = {
5839
6055
  Today: [],
5840
6056
  Yesterday: [],
5841
6057
  "This Week": [],
@@ -5855,19 +6071,19 @@ function Mi(e) {
5855
6071
  chats: a[e]
5856
6072
  }));
5857
6073
  }
5858
- var Ni = ({ showLabel: e = !1 }) => {
5859
- let t = Ei();
5860
- return /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ W(In, { children: [/* @__PURE__ */ W(Ln, {
6074
+ var ta = ({ showLabel: e = !1 }) => {
6075
+ let t = Ji();
6076
+ return /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ W(Vn, { children: [/* @__PURE__ */ W(Hn, {
5861
6077
  className: e ? "inline-flex items-center gap-1.5 px-3 py-1 rounded-full text-xs text-muted-foreground bg-secondary hover:bg-secondary/80 hover:text-foreground transition-colors duration-150" : "p-2 text-muted-foreground rounded-2xl bg-background/60 backdrop-blur-md hover:bg-secondary/80 transition duration-200 hover:text-foreground border border-border/30",
5862
6078
  children: [/* @__PURE__ */ U(de, { size: e ? 14 : 18 }), e && /* @__PURE__ */ U("span", { children: "History" })]
5863
- }), /* @__PURE__ */ W(Bn, {
6079
+ }), /* @__PURE__ */ W(Gn, {
5864
6080
  className: "max-w-[420px] p-3",
5865
6081
  children: [
5866
- /* @__PURE__ */ U(Vn, {
6082
+ /* @__PURE__ */ U(Kn, {
5867
6083
  className: "sr-only",
5868
6084
  children: "Chat History"
5869
6085
  }),
5870
- /* @__PURE__ */ U(Di, {
6086
+ /* @__PURE__ */ U(Yi, {
5871
6087
  incognito: t.incognito,
5872
6088
  onToggleIncognito: t.toggleIncognito,
5873
6089
  showClearAll: t.chats.length > 0 && !t.loading,
@@ -5905,15 +6121,15 @@ var Ni = ({ showLabel: e = !1 }) => {
5905
6121
  })
5906
6122
  }) : /* @__PURE__ */ U("div", {
5907
6123
  className: "space-y-1 max-h-[500px] overflow-y-auto",
5908
- children: t.searchQuery.trim() ? t.displayChats.map((e) => /* @__PURE__ */ U(Oi, {
6124
+ children: t.searchQuery.trim() ? t.displayChats.map((e) => /* @__PURE__ */ U(Xi, {
5909
6125
  chat: e,
5910
6126
  isPinned: t.pinnedIds.includes(e.id),
5911
6127
  onTogglePin: t.togglePin,
5912
6128
  onDelete: t.handleDeleteClick
5913
- }, e.id)) : Mi(t.displayChats).map(({ label: e, chats: n }) => /* @__PURE__ */ W("div", { children: [/* @__PURE__ */ W("div", {
6129
+ }, e.id)) : ea(t.displayChats).map(({ label: e, chats: n }) => /* @__PURE__ */ W("div", { children: [/* @__PURE__ */ W("div", {
5914
6130
  className: "flex items-center gap-1.5 px-3 py-1.5 text-xs font-semibold text-muted-foreground/70 uppercase tracking-wider",
5915
- children: [ji[e], e]
5916
- }), n.map((e) => /* @__PURE__ */ U(Oi, {
6131
+ children: [$i[e], e]
6132
+ }), n.map((e) => /* @__PURE__ */ U(Xi, {
5917
6133
  chat: e,
5918
6134
  isPinned: t.pinnedIds.includes(e.id),
5919
6135
  onTogglePin: t.togglePin,
@@ -5922,14 +6138,14 @@ var Ni = ({ showLabel: e = !1 }) => {
5922
6138
  }),
5923
6139
  t.chats.length > 0 && /* @__PURE__ */ U("div", {
5924
6140
  className: "mt-2 pt-2 border-t border-border",
5925
- children: /* @__PURE__ */ U(Et, {
6141
+ children: /* @__PURE__ */ U(Ot, {
5926
6142
  href: "/library",
5927
6143
  className: "block text-center text-xs text-primary hover:underline",
5928
6144
  children: "View all chats"
5929
6145
  })
5930
6146
  })
5931
6147
  ]
5932
- })] }), /* @__PURE__ */ U(Ai, {
6148
+ })] }), /* @__PURE__ */ U(Qi, {
5933
6149
  deleteDialogOpen: t.deleteDialogOpen,
5934
6150
  setDeleteDialogOpen: t.setDeleteDialogOpen,
5935
6151
  chatToDelete: t.chatToDelete,
@@ -5941,47 +6157,26 @@ var Ni = ({ showLabel: e = !1 }) => {
5941
6157
  clearingAll: t.clearingAll,
5942
6158
  onConfirmClearAll: t.handleConfirmClearAll
5943
6159
  })] });
5944
- };
5945
- //#endregion
5946
- //#region src/lib/relative-time.ts
5947
- function Pi(e) {
5948
- let t = new Date(e).getTime();
5949
- if (Number.isNaN(t)) return "";
5950
- let n = Math.round((Date.now() - t) / 1e3);
5951
- if (n < 5) return "just now";
5952
- if (n < 60) return `${n} sec`;
5953
- let r = Math.round(n / 60);
5954
- if (r < 60) return `${r} min`;
5955
- let i = Math.round(r / 60);
5956
- if (i < 24) return `${i} hr`;
5957
- let a = Math.round(i / 24);
5958
- if (a < 7) return `${a} day${a === 1 ? "" : "s"}`;
5959
- let o = Math.round(a / 7);
5960
- if (o < 5) return `${o} week${o === 1 ? "" : "s"}`;
5961
- let s = Math.round(a / 30);
5962
- if (s < 12) return `${s} month${s === 1 ? "" : "s"}`;
5963
- let c = Math.round(a / 365);
5964
- return `${c} year${c === 1 ? "" : "s"}`;
5965
- }
5966
- //#endregion
5967
- //#region src/components/ChatConversation/RecentHistoryChips.tsx
5968
- var Fi = (e) => new Date(e.lastMessageAt || e.createdAt).getTime();
5969
- function Ii() {
5970
- let { chats: e, loading: t } = Ei(), n = [...e].sort((e, t) => Fi(t) - Fi(e)).slice(0, 5);
5971
- return t || n.length === 0 ? null : /* @__PURE__ */ W("div", {
6160
+ }, na = (e) => new Date(e.lastMessageAt || e.createdAt).getTime();
6161
+ function ra() {
6162
+ let { chats: e, loading: n } = Ji(), r = [...e].sort((e, t) => na(t) - na(e)).slice(0, 5);
6163
+ return n || r.length === 0 ? null : /* @__PURE__ */ W("div", {
5972
6164
  className: "flex flex-row items-center justify-center gap-2 flex-wrap",
5973
- children: [/* @__PURE__ */ U(Ni, { showLabel: !0 }), n.map((e) => {
5974
- let t = Pi(e.lastMessageAt || e.createdAt);
5975
- return /* @__PURE__ */ W(Et, {
6165
+ children: [/* @__PURE__ */ U(ta, { showLabel: !0 }), r.map((e) => {
6166
+ let n = ii(e.lastMessageAt || e.createdAt);
6167
+ return /* @__PURE__ */ W(Ot, {
5976
6168
  href: `/c/${e.id}`,
6169
+ onClick: (n) => {
6170
+ t.onOpenChat?.(e.id) && n.preventDefault();
6171
+ },
5977
6172
  className: "flex items-center gap-1.5 px-3 py-1 rounded-full text-xs text-muted-foreground bg-secondary hover:bg-secondary/80 hover:text-foreground transition-colors duration-150 max-w-[220px]",
5978
6173
  title: e.title,
5979
6174
  children: [/* @__PURE__ */ U("span", {
5980
6175
  className: "truncate",
5981
6176
  children: e.title
5982
- }), t && /* @__PURE__ */ U("span", {
6177
+ }), n && /* @__PURE__ */ U("span", {
5983
6178
  className: "italic text-muted-foreground/70 whitespace-nowrap",
5984
- children: t
6179
+ children: n
5985
6180
  })]
5986
6181
  }, e.id);
5987
6182
  })]
@@ -5989,7 +6184,7 @@ function Ii() {
5989
6184
  }
5990
6185
  //#endregion
5991
6186
  //#region src/components/Footer.tsx
5992
- function Li({ listFooterLinks: e = [], optionShowIcons: t = !0, optionBackgroundColor: n = "bg-black/40" }) {
6187
+ function ia({ listFooterLinks: e = [], optionShowIcons: t = !0, optionBackgroundColor: n = "bg-black/40" }) {
5993
6188
  let [r, i] = p(!1), a = f(null);
5994
6189
  u(() => {
5995
6190
  if (!r) return;
@@ -5998,12 +6193,12 @@ function Li({ listFooterLinks: e = [], optionShowIcons: t = !0, optionBackground
5998
6193
  };
5999
6194
  return document.addEventListener("mousedown", e), () => document.removeEventListener("mousedown", e);
6000
6195
  }, [r]);
6001
- let o = () => e.map(({ url: e, text: n, icon: r }) => {
6002
- let i = r ? b[r] : null, a = e.startsWith("http"), o = a ? {
6196
+ let o = () => e.map(({ url: e, text: n, icon: r, onClick: i }) => {
6197
+ let a = r ? b[r] : null, o = e.startsWith("http"), s = o ? {
6003
6198
  target: "_blank",
6004
6199
  rel: "noopener noreferrer"
6005
- } : {}, s = /* @__PURE__ */ W(H, { children: [
6006
- t && i && /* @__PURE__ */ U(i, { size: 14 }),
6200
+ } : {}, c = /* @__PURE__ */ W(H, { children: [
6201
+ t && a && /* @__PURE__ */ U(a, { size: 14 }),
6007
6202
  /* @__PURE__ */ U("span", {
6008
6203
  className: "font-semibold tracking-wide text-md",
6009
6204
  style: { fontVariant: "small-caps" },
@@ -6011,15 +6206,20 @@ function Li({ listFooterLinks: e = [], optionShowIcons: t = !0, optionBackground
6011
6206
  }),
6012
6207
  /* @__PURE__ */ U("span", { className: "absolute bottom-0 left-0 w-0 h-0.5 bg-current transition-all duration-300 group-hover:w-full group-hover:shadow-[0_0_8px_rgba(255,255,255,0.6)]" })
6013
6208
  ] });
6014
- return a ? /* @__PURE__ */ U("a", {
6209
+ return i ? /* @__PURE__ */ U("button", {
6210
+ type: "button",
6211
+ onClick: i,
6212
+ className: "relative group inline-flex items-center gap-1 hover:text-white hover:drop-shadow-[0_0_8px_rgba(255,255,255,0.8)] transition-all duration-300 whitespace-nowrap",
6213
+ children: c
6214
+ }, e) : o ? /* @__PURE__ */ U("a", {
6015
6215
  href: e,
6016
- ...o,
6216
+ ...s,
6017
6217
  className: "relative group inline-flex items-center gap-1 hover:text-white hover:drop-shadow-[0_0_8px_rgba(255,255,255,0.8)] transition-all duration-300 whitespace-nowrap",
6018
- children: s
6019
- }, e) : /* @__PURE__ */ U(Et, {
6218
+ children: c
6219
+ }, e) : /* @__PURE__ */ U(Ot, {
6020
6220
  href: e,
6021
6221
  className: "relative group inline-flex items-center gap-1 hover:text-white hover:drop-shadow-[0_0_8px_rgba(255,255,255,0.8)] transition-all duration-300 whitespace-nowrap",
6022
- children: s
6222
+ children: c
6023
6223
  }, e);
6024
6224
  }), s = b.Info;
6025
6225
  return /* @__PURE__ */ W(H, { children: [/* @__PURE__ */ U("div", {
@@ -6045,32 +6245,80 @@ function Li({ listFooterLinks: e = [], optionShowIcons: t = !0, optionBackground
6045
6245
  })] });
6046
6246
  }
6047
6247
  //#endregion
6248
+ //#region src/components/ChatConversation/DownloadsDialog.tsx
6249
+ function aa({ open: e, onOpenChange: n }) {
6250
+ return /* @__PURE__ */ U(Vn, {
6251
+ open: e,
6252
+ onOpenChange: n,
6253
+ children: /* @__PURE__ */ W(Gn, {
6254
+ className: "w-full max-w-md rounded-2xl bg-light-secondary dark:bg-dark-secondary border border-light-200 dark:border-dark-200 p-6 text-center align-middle shadow-xl",
6255
+ children: [
6256
+ /* @__PURE__ */ U(Kn, {
6257
+ className: "text-lg font-medium leading-6 dark:text-white",
6258
+ children: "Download QwkSearch"
6259
+ }),
6260
+ /* @__PURE__ */ U(qn, {
6261
+ className: "text-sm dark:text-white/70 text-black/70 mt-2",
6262
+ children: "Get QwkSearch on your browser or desktop."
6263
+ }),
6264
+ /* @__PURE__ */ W("div", {
6265
+ className: "flex flex-wrap items-center justify-center gap-3 mt-6",
6266
+ children: [/* @__PURE__ */ U(At, {
6267
+ platform: "chrome-extension",
6268
+ href: t.downloadChromeUrl,
6269
+ autoHighlight: !0
6270
+ }), /* @__PURE__ */ U(At, {
6271
+ platform: "windows",
6272
+ appId: t.downloadWindowsStoreId,
6273
+ autoHighlight: !0
6274
+ })]
6275
+ })
6276
+ ]
6277
+ })
6278
+ });
6279
+ }
6280
+ //#endregion
6048
6281
  //#region src/components/ChatConversation/background-art.ts
6049
- function Ri() {
6282
+ function oa() {
6050
6283
  let e = /* @__PURE__ */ "hyZbH3n.mp4,iOeZcCk.mp4,dUZlxYE.mp4,GpWeP6E.gif,LuKUsLE.png,w7X11Dd.png,MHmVtCr.png,HmnUAee.png,vKP22VU.png,l1lsV39.png,Ku8F2qc.png,KUEXtwm.png,vvKFPmY.png,5p8eaEf.png,VAKuJcG.png,sTMPtQW.png,m0gHbZZ.png,cKu7dWQ.png,ogfefYD.png,ey5vAae.png,twuLrvk.png,ELILiYt.png,9el5qpP.png,Up6xTkk.png,W1XKBo0.png,1Y6xvW0.png,JXOytMz.png,DNiI6pp.png,XDv5s6p.jpeg,eRwiRJ9.jpeg,DRAfJoc.jpeg,ASVRQ1G.jpeg,35svwUT.jpeg,81xLiVI.jpeg,6kod2Em.jpeg,eU0C8zt.jpeg,Bv0PBY8.jpeg,DQNbjIZ.jpeg,2uACPqZ.jpeg,XEKltMF.jpeg,WHgLfBm.jpeg,QFYM0Fw.jpeg,K12HCao.jpeg,oN8rtsE.jpeg,9fGnrns.jpeg,2ONJJeW.jpeg,DO23Va7.jpeg,QaKeoXk.jpeg,QU5oCBR.jpeg,MhlYZmh.jpeg,ylL1ToB.jpeg,AWWsCv8.jpeg,Tk9Tzzj.jpeg".split(",");
6051
6284
  return "https://i.imgur.com/" + e[Math.floor(Math.random() * e.length)];
6052
6285
  }
6053
6286
  //#endregion
6054
6287
  //#region src/components/ChatConversation/ChatHomepage.tsx
6055
- function zi() {
6056
- let { sendMessage: e } = J(), [n, r] = p(null), [i, a] = p(null), [o, s] = p(!1), [c, l] = p({ os: "" });
6288
+ function sa(e) {
6289
+ return e ? e.split(/\r?\n/).map((e) => e.trim()).filter(Boolean).map((e) => {
6290
+ let t = e.split(",").map((e) => e.trim()), n = Number(t[t.length - 2]), r = Number(t[t.length - 1]);
6291
+ return t.length >= 2 && t[t.length - 2] !== "" && t[t.length - 1] !== "" && Number.isFinite(n) && Number.isFinite(r) ? {
6292
+ label: t.slice(0, t.length - 2).filter(Boolean).join(", ") || void 0,
6293
+ latitude: n,
6294
+ longitude: r
6295
+ } : { label: e };
6296
+ }) : [];
6297
+ }
6298
+ function ca() {
6299
+ let { sendMessage: e } = J(), [n, r] = p(null), [i, a] = p(null), [o, s] = p(!1), [c, l] = p(!1), [d, f] = p([]), [m, h] = p(null), [g, _] = p(!1), [v, y] = p(!1), b = t.footerLinks.map((e) => e.url === "/#downloads" ? {
6300
+ ...e,
6301
+ onClick: () => l(!0)
6302
+ } : e);
6057
6303
  u(() => {
6304
+ let e = () => {
6305
+ f(sa(localStorage.getItem("weatherLocations"))), h(localStorage.getItem("trendingNewsApiUrl")), _(localStorage.getItem("orbHoverGlow") === "true"), y(localStorage.getItem("cursorGlowTrail") === "true");
6306
+ };
6307
+ return e(), window.addEventListener("client-config-changed", e), window.addEventListener("storage", e), () => {
6308
+ window.removeEventListener("client-config-changed", e), window.removeEventListener("storage", e);
6309
+ };
6310
+ }, []), u(() => {
6058
6311
  if (localStorage.getItem("showBackgroundArt") === "false") return;
6059
- r(Ri());
6312
+ r(oa());
6060
6313
  let e = setInterval(() => {
6061
- let e = Ri();
6314
+ let e = oa();
6062
6315
  a(e), s(!0), setTimeout(() => {
6063
6316
  r(e), s(!1), a(null);
6064
6317
  }, 1e3);
6065
6318
  }, 2e4);
6066
6319
  return () => clearInterval(e);
6067
- }, []), u(() => {
6068
- if (typeof window < "u") {
6069
- let e = window.navigator.userAgent.toLowerCase();
6070
- e.includes("win") ? l({ os: "Windows" }) : e.includes("mac") ? l({ os: "MacOS" }) : l({ os: "Other" });
6071
- }
6072
6320
  }, []);
6073
- let d = (e) => e.endsWith(".webm") || e.endsWith(".mp4"), f = (e, t) => d(e) ? /* @__PURE__ */ U("video", {
6321
+ let x = (e) => e.endsWith(".webm") || e.endsWith(".mp4"), S = (e, t) => x(e) ? /* @__PURE__ */ U("video", {
6074
6322
  src: e,
6075
6323
  autoPlay: !0,
6076
6324
  loop: !0,
@@ -6086,60 +6334,79 @@ function zi() {
6086
6334
  className: "relative min-h-screen w-full",
6087
6335
  children: [
6088
6336
  /* @__PURE__ */ W("div", {
6089
- className: "fixed inset-0 z-0",
6337
+ className: "absolute inset-0 z-0",
6090
6338
  children: [
6091
- n && f(n, o ? "opacity-0" : "opacity-30"),
6092
- i && f(i, o ? "opacity-30" : "opacity-0"),
6093
- /* @__PURE__ */ U(xi, {})
6339
+ n && S(n, o ? "opacity-0" : "opacity-30"),
6340
+ i && S(i, o ? "opacity-30" : "opacity-0"),
6341
+ v && /* @__PURE__ */ U(Ui, {})
6094
6342
  ]
6095
6343
  }),
6096
6344
  /* @__PURE__ */ U("div", {
6097
6345
  className: "relative z-10",
6098
6346
  children: /* @__PURE__ */ W("div", {
6099
6347
  className: "flex flex-col items-center justify-end md:justify-center min-h-[calc(100dvh-64px)] md:min-h-screen max-w-screen-sm mx-auto p-2 pb-1 md:pb-2",
6100
- children: [
6101
- /* @__PURE__ */ U("div", {
6102
- style: {
6103
- height: "200px",
6104
- width: "100%",
6105
- display: "flex",
6106
- alignItems: "center",
6107
- justifyContent: "center"
6108
- },
6109
- children: /* @__PURE__ */ U(wt, {
6110
- autoRandomize: !0,
6111
- onSphereClick: () => console.log("Sphere clicked"),
6112
- className: "my-custom-class"
6113
- })
6114
- }),
6115
- /* @__PURE__ */ W("p", {
6116
- className: "text-lg text-gray-500 text-center justify-center mt-4",
6117
- children: [/* @__PURE__ */ U("a", {
6118
- "aria-label": "Chrome Web Store",
6119
- className: "download-chrome download-btn text-center justify-center",
6120
- target: "_blank",
6121
- href: t.downloadChromeUrl
6122
- }), /* @__PURE__ */ U("a", {
6123
- "aria-label": "Microsoft Store",
6124
- className: "download-windows download-btn text-center justify-center",
6125
- target: "_blank",
6126
- href: c.os == "Windows" ? `ms-windows-store://pdp/?productid=${t.downloadWindowsStoreId}` : `https://apps.microsoft.com/detail/${t.downloadWindowsStoreId}?rtc=1`
6127
- })]
6128
- }),
6129
- /* @__PURE__ */ W("div", {
6130
- className: "w-full max-w-2xl mt-8 space-y-2",
6131
- children: [/* @__PURE__ */ U(Ii, {}), /* @__PURE__ */ U(qr, {})]
6348
+ children: [/* @__PURE__ */ U("div", {
6349
+ style: {
6350
+ height: "200px",
6351
+ width: "100%",
6352
+ display: "flex",
6353
+ alignItems: "center",
6354
+ justifyContent: "center"
6355
+ },
6356
+ className: g ? void 0 : "pointer-events-none",
6357
+ children: /* @__PURE__ */ U(wt, {
6358
+ autoRandomize: !0,
6359
+ onSphereClick: () => console.log("Sphere clicked"),
6360
+ className: "my-custom-class"
6132
6361
  })
6133
- ]
6362
+ }), /* @__PURE__ */ W("div", {
6363
+ className: "w-full max-w-2xl mt-8 space-y-2",
6364
+ children: [
6365
+ /* @__PURE__ */ U(ra, {}),
6366
+ /* @__PURE__ */ W("div", {
6367
+ className: "flex flex-col md:flex-row gap-2 w-full",
6368
+ children: [/* @__PURE__ */ U(jt, {
6369
+ compact: !0,
6370
+ forecastDays: 5,
6371
+ forecastHours: 12,
6372
+ locations: d.length > 0 ? d : void 0,
6373
+ className: "rounded-2xl",
6374
+ style: {
6375
+ background: "rgba(255,255,255,0.08)",
6376
+ border: "1px solid rgba(255,255,255,0.15)",
6377
+ color: "inherit",
6378
+ backdropFilter: "blur(8px)"
6379
+ }
6380
+ }), /* @__PURE__ */ U(Mt, {
6381
+ compact: !0,
6382
+ maxTopics: 6,
6383
+ apiEndpoint: m || void 0,
6384
+ className: "rounded-2xl md:flex-1",
6385
+ style: {
6386
+ background: "rgba(255,255,255,0.08)",
6387
+ border: "1px solid rgba(255,255,255,0.15)",
6388
+ color: "inherit",
6389
+ backdropFilter: "blur(8px)",
6390
+ maxWidth: "100%"
6391
+ }
6392
+ })]
6393
+ }),
6394
+ /* @__PURE__ */ U(hi, {})
6395
+ ]
6396
+ })]
6134
6397
  })
6135
6398
  }),
6136
- /* @__PURE__ */ U(Li, { listFooterLinks: t.footerLinks })
6399
+ /* @__PURE__ */ U(ia, { listFooterLinks: b }),
6400
+ /* @__PURE__ */ U(aa, {
6401
+ open: c,
6402
+ onOpenChange: l
6403
+ })
6137
6404
  ]
6138
6405
  });
6139
6406
  }
6140
6407
  //#endregion
6141
6408
  //#region src/ui/Loader.tsx
6142
- var Bi = () => /* @__PURE__ */ W("svg", {
6409
+ var la = () => /* @__PURE__ */ W("svg", {
6143
6410
  "aria-hidden": "true",
6144
6411
  className: "w-8 h-8 text-border fill-secondary animate-spin",
6145
6412
  viewBox: "0 0 100 101",
@@ -6155,7 +6422,7 @@ var Bi = () => /* @__PURE__ */ W("svg", {
6155
6422
  });
6156
6423
  //#endregion
6157
6424
  //#region src/components/ConfigError.tsx
6158
- function Vi() {
6425
+ function ua() {
6159
6426
  return /* @__PURE__ */ U("div", {
6160
6427
  className: "flex min-h-screen flex-col items-center justify-center p-8",
6161
6428
  children: /* @__PURE__ */ W("div", {
@@ -6273,8 +6540,8 @@ function Vi() {
6273
6540
  }
6274
6541
  //#endregion
6275
6542
  //#region src/components/ChatConversation/ChatWindow.tsx
6276
- var Hi = () => {
6277
- let e = h(), { hasError: t, isReady: n, notFound: r, messages: i } = J(), { isAuthenticated: a } = An();
6543
+ var da = () => {
6544
+ let e = h(), { hasError: t, isReady: n, notFound: r, messages: i } = J(), { isAuthenticated: a } = Fn();
6278
6545
  return u(() => {
6279
6546
  n && r && !a && e.replace("/");
6280
6547
  }, [
@@ -6282,9 +6549,9 @@ var Hi = () => {
6282
6549
  r,
6283
6550
  a,
6284
6551
  e
6285
- ]), t ? /* @__PURE__ */ U(Vi, {}) : n && r && !a ? /* @__PURE__ */ U("div", {
6552
+ ]), t ? /* @__PURE__ */ U(ua, {}) : n && r && !a ? /* @__PURE__ */ U("div", {
6286
6553
  className: "flex flex-row items-center justify-center min-h-screen",
6287
- children: /* @__PURE__ */ U(Bi, {})
6554
+ children: /* @__PURE__ */ U(la, {})
6288
6555
  }) : n ? r ? /* @__PURE__ */ W("div", {
6289
6556
  className: "flex min-h-screen flex-col items-center justify-center gap-3 px-4 text-center",
6290
6557
  children: [/* @__PURE__ */ U("p", {
@@ -6296,14 +6563,14 @@ var Hi = () => {
6296
6563
  className: "rounded-md border border-black/15 px-3 py-1.5 text-sm hover:bg-black/5 dark:border-white/20 dark:hover:bg-white/10",
6297
6564
  children: "Go Home"
6298
6565
  })]
6299
- }) : /* @__PURE__ */ U("div", { children: i.length > 0 ? /* @__PURE__ */ U(H, { children: /* @__PURE__ */ U(bi, {}) }) : /* @__PURE__ */ U(zi, {}) }) : /* @__PURE__ */ U("div", {
6566
+ }) : /* @__PURE__ */ U("div", { children: i.length > 0 ? /* @__PURE__ */ U(H, { children: /* @__PURE__ */ U(Hi, {}) }) : /* @__PURE__ */ U(ca, {}) }) : /* @__PURE__ */ U("div", {
6300
6567
  className: "flex flex-row items-center justify-center min-h-screen",
6301
- children: /* @__PURE__ */ U(Bi, {})
6568
+ children: /* @__PURE__ */ U(la, {})
6302
6569
  });
6303
6570
  };
6304
6571
  //#endregion
6305
6572
  //#region src/hooks/voice/useKokoroTTS.ts
6306
- function Ui(e, t) {
6573
+ function fa(e, t) {
6307
6574
  let [n, r] = p("idle"), [i, a] = p(!1), [o, s] = p([]), [l, d] = p("af_heart"), [m, h] = p(null), g = f(null), _ = f(null);
6308
6575
  u(() => {
6309
6576
  t?.autoPreload && !i && y();
@@ -6317,8 +6584,8 @@ function Ui(e, t) {
6317
6584
  g.current &&= (g.current.pause(), g.current.src.startsWith("blob:") && URL.revokeObjectURL(g.current.src), null), _.current?.abort(), _.current = null;
6318
6585
  }, []), y = c(async () => {
6319
6586
  try {
6320
- r("loading"), h(null), await tn();
6321
- let e = await rn();
6587
+ r("loading"), h(null), await sn();
6588
+ let e = await ln();
6322
6589
  s(e), e.length && !e.includes(l) && d(e[0]), a(!0), r("idle");
6323
6590
  } catch (e) {
6324
6591
  let t = e instanceof Error ? e.message : "Failed to load model";
@@ -6342,7 +6609,7 @@ function Ui(e, t) {
6342
6609
  v(), r("generating"), h(null);
6343
6610
  let t = new AbortController();
6344
6611
  _.current = t;
6345
- let n = (await (await nn()).generate(e.slice(0, 5e3), { voice: l })).toWav(), i = new Blob([n], { type: "audio/wav" }), a = URL.createObjectURL(i), o = new Audio(a);
6612
+ let n = (await (await cn()).generate(e.slice(0, 5e3), { voice: l })).toWav(), i = new Blob([n], { type: "audio/wav" }), a = URL.createObjectURL(i), o = new Audio(a);
6346
6613
  g.current = o, o.onended = () => {
6347
6614
  r("idle"), URL.revokeObjectURL(a), g.current = null;
6348
6615
  }, o.onerror = () => {
@@ -6367,12 +6634,12 @@ function Ui(e, t) {
6367
6634
  changeVoice: c((e) => {
6368
6635
  d(e), localStorage.setItem("kokoroVoice", e);
6369
6636
  }, []),
6370
- backend: an()
6637
+ backend: un()
6371
6638
  };
6372
6639
  }
6373
6640
  //#endregion
6374
6641
  //#region src/components/VoiceSettings/KokoroVoiceSelector.tsx
6375
- var Wi = {
6642
+ var pa = {
6376
6643
  af_heart: "American Female - Heart",
6377
6644
  af_bella: "American Female - Bella",
6378
6645
  af_nicole: "American Female - Nicole",
@@ -6384,8 +6651,8 @@ var Wi = {
6384
6651
  bm_george: "British Male - George",
6385
6652
  bm_thomas: "British Male - Thomas"
6386
6653
  };
6387
- function Gi({ preloadOnMount: e = !1 }) {
6388
- let { status: t, modelReady: n, voices: r, selectedVoice: i, error: a, warmupModel: o, changeVoice: s, backend: c } = Ui("", { autoPreload: e }), [l, u] = p(!1), d = t === "loading", f = t === "error";
6654
+ function ma({ preloadOnMount: e = !1 }) {
6655
+ let { status: t, modelReady: n, voices: r, selectedVoice: i, error: a, warmupModel: o, changeVoice: s, backend: c } = fa("", { autoPreload: e }), [l, u] = p(!1), d = t === "loading", f = t === "error";
6389
6656
  return /* @__PURE__ */ W("div", {
6390
6657
  className: "flex flex-col gap-3",
6391
6658
  children: [/* @__PURE__ */ W("div", {
@@ -6400,7 +6667,7 @@ function Gi({ preloadOnMount: e = !1 }) {
6400
6667
  children: d ? /* @__PURE__ */ U(V, {
6401
6668
  size: 18,
6402
6669
  className: "animate-spin"
6403
- }) : /* @__PURE__ */ U(ne, { size: 18 })
6670
+ }) : /* @__PURE__ */ U(re, { size: 18 })
6404
6671
  })
6405
6672
  }), /* @__PURE__ */ U(Z, {
6406
6673
  side: "bottom",
@@ -6434,7 +6701,7 @@ function Gi({ preloadOnMount: e = !1 }) {
6434
6701
  className: "w-full text-left px-3 py-2 rounded-md bg-white/5 dark:bg-black/5 hover:bg-white/10 dark:hover:bg-black/10 transition text-sm font-medium",
6435
6702
  children: /* @__PURE__ */ W("div", {
6436
6703
  className: "flex items-center gap-2",
6437
- children: [/* @__PURE__ */ U(Ie, { size: 16 }), Wi[i] || i]
6704
+ children: [/* @__PURE__ */ U(Ie, { size: 16 }), pa[i] || i]
6438
6705
  })
6439
6706
  }), l && /* @__PURE__ */ U("div", {
6440
6707
  className: "grid grid-cols-2 gap-2 p-2 bg-white/5 dark:bg-black/5 rounded-md max-h-64 overflow-y-auto",
@@ -6443,7 +6710,7 @@ function Gi({ preloadOnMount: e = !1 }) {
6443
6710
  s(e), u(!1);
6444
6711
  },
6445
6712
  className: q("p-2 text-left text-sm rounded transition duration-200", i === e ? "bg-blue-500/20 text-blue-600 dark:text-blue-400 font-medium" : "bg-white/5 dark:bg-black/5 text-foreground hover:bg-white/10 dark:hover:bg-black/10"),
6446
- children: Wi[e] || e
6713
+ children: pa[e] || e
6447
6714
  }, e))
6448
6715
  })]
6449
6716
  })]
@@ -6451,11 +6718,13 @@ function Gi({ preloadOnMount: e = !1 }) {
6451
6718
  }
6452
6719
  //#endregion
6453
6720
  //#region src/components/VoiceSettings/VoiceSettingsPanel.tsx
6454
- function Ki() {
6455
- let [e, t] = p(!1), [n, r] = p(() => localStorage.getItem("useTTSKokoro") !== "false"), [i, a] = p(() => localStorage.getItem("ttsSpeaker") || "angus"), { start: o, speechStatus: s } = on("This is a preview of the selected voice.", { enableInterrupt: !1 }), c = (e) => {
6721
+ function ha() {
6722
+ let [e, t] = p(!1), [n, r] = p(() => localStorage.getItem("useTTSKokoro") !== "false"), [i, a] = p(() => localStorage.getItem("ttsSpeaker") || "angus"), [o, s] = p(() => Lr()), { start: c, speechStatus: l } = dn("This is a preview of the selected voice.", { enableInterrupt: !1 }), u = (e) => {
6456
6723
  r(e), localStorage.setItem("useTTSKokoro", String(e));
6457
- }, l = (e) => {
6724
+ }, d = (e) => {
6458
6725
  a(e), localStorage.setItem("ttsSpeaker", e);
6726
+ }, f = (e) => {
6727
+ s(e), Rr(e);
6459
6728
  };
6460
6729
  return /* @__PURE__ */ W("div", {
6461
6730
  className: "space-y-4",
@@ -6483,7 +6752,7 @@ function Ki() {
6483
6752
  /* @__PURE__ */ U("input", {
6484
6753
  type: "checkbox",
6485
6754
  checked: n,
6486
- onChange: (e) => c(e.target.checked),
6755
+ onChange: (e) => u(e.target.checked),
6487
6756
  className: "rounded"
6488
6757
  }),
6489
6758
  /* @__PURE__ */ U("span", {
@@ -6502,7 +6771,7 @@ function Ki() {
6502
6771
  children: "Runs locally in your browser. No server requests, lower latency, and multiple voice options."
6503
6772
  })] })
6504
6773
  ]
6505
- }), n && /* @__PURE__ */ U(Gi, { preloadOnMount: !1 })]
6774
+ }), n && /* @__PURE__ */ U(ma, { preloadOnMount: !1 })]
6506
6775
  }),
6507
6776
  /* @__PURE__ */ W("div", {
6508
6777
  className: "space-y-2",
@@ -6512,7 +6781,7 @@ function Ki() {
6512
6781
  /* @__PURE__ */ U("input", {
6513
6782
  type: "checkbox",
6514
6783
  checked: !n,
6515
- onChange: (e) => c(!e.target.checked),
6784
+ onChange: (e) => u(!e.target.checked),
6516
6785
  className: "rounded"
6517
6786
  }),
6518
6787
  /* @__PURE__ */ U("span", {
@@ -6535,7 +6804,7 @@ function Ki() {
6535
6804
  className: "space-y-2",
6536
6805
  children: [/* @__PURE__ */ W("select", {
6537
6806
  value: i,
6538
- onChange: (e) => l(e.target.value),
6807
+ onChange: (e) => d(e.target.value),
6539
6808
  className: "w-full px-3 py-2 rounded-md bg-white/10 dark:bg-black/10 border border-white/20 dark:border-black/20 text-sm",
6540
6809
  children: [
6541
6810
  /* @__PURE__ */ U("option", {
@@ -6556,13 +6825,42 @@ function Ki() {
6556
6825
  })
6557
6826
  ]
6558
6827
  }), /* @__PURE__ */ W("button", {
6559
- onClick: () => o(),
6560
- disabled: s === "started",
6561
- className: q("w-full flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium transition", s === "started" ? "bg-gray-500/20 text-gray-600 dark:text-gray-400 cursor-not-allowed" : "bg-blue-500/20 text-blue-600 dark:text-blue-400 hover:bg-blue-500/30"),
6562
- children: [/* @__PURE__ */ U(Ie, { size: 16 }), s === "started" ? "Playing..." : "Preview"]
6828
+ onClick: () => c(),
6829
+ disabled: l === "started",
6830
+ className: q("w-full flex items-center justify-center gap-2 px-3 py-2 rounded-md text-sm font-medium transition", l === "started" ? "bg-gray-500/20 text-gray-600 dark:text-gray-400 cursor-not-allowed" : "bg-blue-500/20 text-blue-600 dark:text-blue-400 hover:bg-blue-500/30"),
6831
+ children: [/* @__PURE__ */ U(Ie, { size: 16 }), l === "started" ? "Playing..." : "Preview"]
6563
6832
  })]
6564
6833
  })]
6565
6834
  }),
6835
+ /* @__PURE__ */ U("div", {
6836
+ className: "space-y-2 pt-2 border-t border-white/10 dark:border-black/10",
6837
+ children: /* @__PURE__ */ W("label", {
6838
+ className: "flex items-center gap-2 cursor-pointer",
6839
+ children: [
6840
+ /* @__PURE__ */ U("input", {
6841
+ type: "checkbox",
6842
+ checked: o,
6843
+ onChange: (e) => f(e.target.checked),
6844
+ className: "rounded"
6845
+ }),
6846
+ /* @__PURE__ */ U("span", {
6847
+ className: "font-medium text-sm",
6848
+ children: "Start talking automatically on first visit"
6849
+ }),
6850
+ /* @__PURE__ */ W(Y, { children: [/* @__PURE__ */ U(X, {
6851
+ asChild: !0,
6852
+ children: /* @__PURE__ */ U("span", {
6853
+ className: "text-xs text-muted-foreground cursor-help",
6854
+ children: "ⓘ"
6855
+ })
6856
+ }), /* @__PURE__ */ U(Z, {
6857
+ side: "right",
6858
+ className: "max-w-xs",
6859
+ children: "Opens the mic the first time you load the chat composer in this browser, so you can start talking right away instead of clicking the mic button."
6860
+ })] })
6861
+ ]
6862
+ })
6863
+ }),
6566
6864
  /* @__PURE__ */ U("div", {
6567
6865
  className: "text-xs text-muted-foreground pt-2 border-t border-white/10 dark:border-black/10",
6568
6866
  children: /* @__PURE__ */ W("p", { children: [/* @__PURE__ */ U("strong", { children: "Tip:" }), " Kokoro.js loads once and runs locally. The first model load may take a few seconds, but subsequent TTS generation is very fast."] })
@@ -6572,4 +6870,4 @@ function Ki() {
6572
6870
  });
6573
6871
  }
6574
6872
  //#endregion
6575
- export { Qr as ARTICLE_TOOLBAR_SHORTCUTS, oi as ArticleAIResponse, ri as ArticleActionButtons, ci as ArticleContent, ai as ArticleFollowupQuestions, Yr as ArticlePanelHeader, ii as ArticlePromptInput, jn as ChatProvider, Hi as ChatWindow, Nt as ExtractPanelProvider, Ai as HistoryDialogs, Ni as HistoryDropdown, Gi as KokoroVoiceSelector, si as LexicalArticleViewer, kn as SessionProvider, vi as UnifiedMarkdown, Ki as VoiceSettingsPanel, q as cn, e as configureResearchAgentUI, Ot as formatMessageTime, kt as formatTimeDifference, ei as formatToolbarShortcut, t as researchAgentUIConfig, J as useChat, Tn as useChatState, Mt as useExtractPanel, Ei as useHistoryState, Ui as useKokoroTTS, An as useSession, on as useTextToSpeech };
6873
+ export { bi as ARTICLE_TOOLBAR_SHORTCUTS, Oi as ArticleAIResponse, Ti as ArticleActionButtons, Ai as ArticleContent, Di as ArticleFollowupQuestions, _i as ArticlePanelHeader, Ei as ArticlePromptInput, hi as ChatInputBox, In as ChatProvider, da as ChatWindow, Rt as ExtractPanelProvider, Qi as HistoryDialogs, ta as HistoryDropdown, ma as KokoroVoiceSelector, ki as LexicalArticleViewer, Pn as SessionProvider, Bi as UnifiedMarkdown, ha as VoiceSettingsPanel, q as cn, e as configureResearchAgentUI, Nt as formatMessageTime, Pt as formatTimeDifference, Si as formatToolbarShortcut, t as researchAgentUIConfig, J as useChat, An as useChatState, Lt as useExtractPanel, Ji as useHistoryState, fa as useKokoroTTS, Fn as useSession, dn as useTextToSpeech };