gentiq 0.8.0 → 0.8.2

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.
@@ -1,35 +1,35 @@
1
1
  import { jsx as e, jsxs as r, Fragment as ke } from "react/jsx-runtime";
2
- import * as ae from "react";
3
- import { useState as T, useMemo as R, useEffect as F, useRef as Z, useCallback as J, useLayoutEffect as Je } from "react";
4
- import { QueryClient as Ye, QueryClientProvider as Ze, useQueryClient as ue, useQuery as et, useInfiniteQuery as tt } from "@tanstack/react-query";
5
- import { I18nextProvider as at, useTranslation as de } from "react-i18next";
6
- import { Trans as Za, Translation as er, useTranslation as tr, withTranslation as ar } from "react-i18next";
7
- import { g as rt, u as E, d as nt, C as Fe, T as st, a as te, b as je, j as be, G as Pe, c as ce, e as v, f as ot, h as Oe, i as $e, k as Ue, l as Be, B as Y, m as Ke, n as ge, D as He, o as it, p as Qe, L as Q, I as W, S as ve, q as xe, r as ye, s as we, t as pe, v as lt, w as ct, x as Te, y as dt, z as ut, A as mt, E as me, F as ht, H as pt, J as gt, K as ft, M as bt, N as vt } from "./checkbox-CjhpdOWd.js";
8
- import { O as nr, P as sr, Q as or, R as ir, U as lr, V as cr, W as dr, X as ur, Y as mr, Z as hr, _ as pr, $ as gr, a0 as fr, a1 as br } from "./checkbox-CjhpdOWd.js";
9
- import { Loader2Icon as xt, OctagonXIcon as yt, TriangleAlertIcon as wt, InfoIcon as Nt, CircleCheckIcon as kt, XIcon as _t, PanelLeftIcon as Ct, Layers as Me, User as St, ShieldCheck as Pt, Settings as Ne, Smartphone as Tt, Lock as Mt, Save as Dt, Sun as It, Moon as Et, Monitor as At, Zap as De, Globe as Lt, Coins as zt, LogOut as qt, CirclePlus as Rt, Plus as Ft, Search as jt, Check as Ot, X as $t, Pin as Ie, MoreVertical as Ut, PinOff as Bt, Share2 as Kt, Pencil as Ht, Trash as Qt } from "lucide-react";
10
- import { useTheme as Vt } from "next-themes";
11
- import { Toaster as Gt, toast as X } from "sonner";
12
- import { useChat as Wt } from "@ai-sdk/react";
13
- import { DefaultChatTransport as Xt } from "ai";
14
- import { useLocation as Ve, useNavigate as _e, Navigate as Jt, useParams as Yt } from "react-router-dom";
2
+ import * as ne from "react";
3
+ import { useState as T, useMemo as O, useEffect as $, useRef as ae, useCallback as J, useLayoutEffect as Ye } from "react";
4
+ import { QueryClient as Ze, QueryClientProvider as et, useQueryClient as ue, useQuery as tt, useInfiniteQuery as at } from "@tanstack/react-query";
5
+ import { I18nextProvider as rt, useTranslation as de } from "react-i18next";
6
+ import { Trans as er, Translation as tr, useTranslation as ar, withTranslation as rr } from "react-i18next";
7
+ import { g as nt, u as D, d as st, C as Fe, T as ot, a as re, b as je, j as be, G as Pe, c as ce, e as Oe, f as v, h as it, i as $e, k as Ue, l as Be, m as Ke, B as te, n as Qe, o as ge, D as He, p as lt, q as Ve, L as G, I as X, S as xe, r as ve, s as ye, t as we, v as pe, w as ct, x as dt, y as Te, z as ut, A as mt, E as ht, F as me, H as pt, J as gt, K as ft, M as bt, N as xt, O as vt } from "./checkbox-BZPTGt7D.js";
8
+ import { P as sr, Q as or, R as ir, U as lr, V as cr, W as dr, X as ur, Y as mr, Z as hr, _ as pr, $ as gr, a0 as fr, a1 as br, a2 as xr, a3 as vr, a4 as yr, a5 as wr, a6 as Nr } from "./checkbox-BZPTGt7D.js";
9
+ import { Loader2Icon as yt, OctagonXIcon as wt, TriangleAlertIcon as Nt, InfoIcon as kt, CircleCheckIcon as _t, XIcon as Ct, PanelLeftIcon as St, Layers as Me, User as Pt, ShieldCheck as Tt, Settings as Ne, Smartphone as Mt, Lock as It, Save as Dt, Sun as At, Moon as Et, Monitor as Lt, Zap as Ie, Globe as Rt, Coins as zt, LogOut as qt, CirclePlus as Ft, Plus as jt, Search as Ot, Check as $t, X as Ut, Pin as De, MoreVertical as Bt, PinOff as Kt, Share2 as Qt, Pencil as Ht, Trash as Vt } from "lucide-react";
10
+ import { useTheme as Gt } from "next-themes";
11
+ import { Toaster as Wt, toast as ee } from "sonner";
12
+ import { useChat as Xt } from "@ai-sdk/react";
13
+ import { DefaultChatTransport as Jt } from "ai";
14
+ import { useLocation as Ge, useNavigate as _e, Navigate as Yt, useParams as Zt } from "react-router-dom";
15
15
  import { nanoid as he } from "nanoid";
16
- import { Slot as Zt } from "@radix-ui/react-slot";
17
- import { cva as ea } from "class-variance-authority";
16
+ import { Slot as ea } from "@radix-ui/react-slot";
17
+ import { cva as ta } from "class-variance-authority";
18
18
  import "@radix-ui/react-separator";
19
- import * as oe from "@radix-ui/react-dialog";
20
- const ta = ({ ...a }) => {
21
- const { theme: t = "system" } = Vt();
19
+ import * as ie from "@radix-ui/react-dialog";
20
+ const aa = ({ ...a }) => {
21
+ const { theme: t = "system" } = Gt();
22
22
  return /* @__PURE__ */ e(
23
- Gt,
23
+ Wt,
24
24
  {
25
25
  theme: t,
26
26
  className: "toaster group",
27
27
  icons: {
28
- success: /* @__PURE__ */ e(kt, { className: "size-4" }),
29
- info: /* @__PURE__ */ e(Nt, { className: "size-4" }),
30
- warning: /* @__PURE__ */ e(wt, { className: "size-4" }),
31
- error: /* @__PURE__ */ e(yt, { className: "size-4" }),
32
- loading: /* @__PURE__ */ e(xt, { className: "size-4 animate-spin" })
28
+ success: /* @__PURE__ */ e(_t, { className: "size-4" }),
29
+ info: /* @__PURE__ */ e(kt, { className: "size-4" }),
30
+ warning: /* @__PURE__ */ e(Nt, { className: "size-4" }),
31
+ error: /* @__PURE__ */ e(wt, { className: "size-4" }),
32
+ loading: /* @__PURE__ */ e(yt, { className: "size-4 animate-spin" })
33
33
  },
34
34
  style: {
35
35
  "--normal-bg": "var(--popover)",
@@ -41,115 +41,115 @@ const ta = ({ ...a }) => {
41
41
  }
42
42
  );
43
43
  };
44
- function Qa({
44
+ function Va({
45
45
  children: a,
46
46
  api: t,
47
- app: o,
48
- i18n: u,
49
- components: l,
50
- history: d,
51
- welcome: h,
52
- threadActions: p,
53
- composer: m,
54
- theme: w,
55
- disclaimer: x,
47
+ app: i,
48
+ i18n: m,
49
+ components: c,
50
+ history: u,
51
+ welcome: g,
52
+ threadActions: f,
53
+ composer: h,
54
+ theme: N,
55
+ disclaimer: y,
56
56
  settings: C
57
57
  }) {
58
- const [n, D] = T(null), P = R(
59
- () => u?.instance ?? rt,
58
+ const [s, M] = T(null), P = O(
59
+ () => m?.instance ?? nt,
60
60
  // eslint-disable-next-line react-hooks/exhaustive-deps
61
- [u?.instance]
62
- ), j = t || {};
63
- F(() => {
64
- E.getAppConfig().then((b) => D(b)).catch((b) => console.debug("Gentiq: No dynamic settings available or fetch failed", b));
65
- }, []), F(() => {
66
- n?.app_name && (document.title = P.t(n.app_name));
67
- }, [n, P]);
68
- const U = R(() => {
69
- const b = {
61
+ [m?.instance]
62
+ ), U = t || {};
63
+ $(() => {
64
+ D.getAppConfig().then((d) => M(d)).catch((d) => console.debug("Gentiq: No dynamic settings available or fetch failed", d));
65
+ }, []), $(() => {
66
+ s?.app_name && (document.title = P.t(s.app_name));
67
+ }, [s, P]);
68
+ const q = O(() => {
69
+ const d = {
70
70
  basePath: "/",
71
71
  cacheNamespace: "gentiq",
72
- ...o
72
+ ...i
73
73
  };
74
- return n ? {
75
- ...b,
76
- name: (n.app_name ? P.t(n.app_name) : null) || b.name,
77
- adminTitle: (n.admin_title ? P.t(n.admin_title) : null) || b.adminTitle,
78
- version: n.app_version || b.version,
79
- showSettings: n.show_settings ?? b.showSettings,
80
- showVersionInSettings: n.show_version_in_settings ?? b.showVersionInSettings,
81
- showToolDetails: n.show_tool_details ?? b.showToolDetails,
82
- disableSignup: n.disable_signup ?? b.disableSignup,
83
- disableAuthPage: n.disable_auth_page ?? b.disableAuthPage,
84
- settingsGeneralMode: n.settings_general_mode || b.settingsGeneralMode,
85
- settingsProfileMode: n.settings_profile_mode || b.settingsProfileMode,
86
- settingsAccountMode: n.settings_account_mode || b.settingsAccountMode
87
- } : b;
88
- }, [o, n, P]), I = R(() => {
89
- if (!n) return h;
90
- const b = typeof h?.greeting == "function" ? h.greeting : n.welcome_greeting || h?.greeting;
74
+ return s ? {
75
+ ...d,
76
+ name: (s.app_name ? P.t(s.app_name) : null) || d.name,
77
+ adminTitle: (s.admin_title ? P.t(s.admin_title) : null) || d.adminTitle,
78
+ version: s.app_version || d.version,
79
+ showSettings: s.show_settings ?? d.showSettings,
80
+ showVersionInSettings: s.show_version_in_settings ?? d.showVersionInSettings,
81
+ showToolDetails: s.show_tool_details ?? d.showToolDetails,
82
+ disableSignup: s.disable_signup ?? d.disableSignup,
83
+ disableAuthPage: s.disable_auth_page ?? d.disableAuthPage,
84
+ settingsGeneralMode: s.settings_general_mode || d.settingsGeneralMode,
85
+ settingsProfileMode: s.settings_profile_mode || d.settingsProfileMode,
86
+ settingsAccountMode: s.settings_account_mode || d.settingsAccountMode
87
+ } : d;
88
+ }, [i, s, P]), A = O(() => {
89
+ if (!s) return g;
90
+ const d = typeof g?.greeting == "function" ? g.greeting : s.welcome_greeting || g?.greeting;
91
91
  return {
92
- ...h,
93
- greeting: b,
94
- subtitle: n.welcome_subtitle || h?.subtitle
92
+ ...g,
93
+ greeting: d,
94
+ subtitle: s.welcome_subtitle || g?.subtitle
95
95
  };
96
- }, [h, n]), f = R(() => {
97
- const b = n?.disclaimer || x;
98
- return b && P.t(b);
99
- }, [x, n, P]), q = R(() => n ? {
100
- ...d,
101
- enabled: n.history_enabled ?? d?.enabled,
102
- showDelete: n.history_show_delete ?? d?.showDelete,
103
- showRename: n.history_show_rename ?? d?.showRename,
104
- showShare: n.history_show_share ?? d?.showShare,
105
- showPin: n.history_show_pin ?? d?.showPin
106
- } : d, [d, n]), g = R(() => n ? {
107
- ...p,
108
- feedback: n.thread_actions_feedback ?? p?.feedback,
109
- retry: n.thread_actions_retry ?? p?.retry
110
- } : p, [p, n]), B = R(() => n ? {
111
- ...m,
96
+ }, [g, s]), p = O(() => {
97
+ const d = s?.disclaimer || y;
98
+ return d && P.t(d);
99
+ }, [y, s, P]), Q = O(() => s ? {
100
+ ...u,
101
+ enabled: s.history_enabled ?? u?.enabled,
102
+ showDelete: s.history_show_delete ?? u?.showDelete,
103
+ showRename: s.history_show_rename ?? u?.showRename,
104
+ showShare: s.history_show_share ?? u?.showShare,
105
+ showPin: s.history_show_pin ?? u?.showPin
106
+ } : u, [u, s]), x = O(() => s ? {
107
+ ...f,
108
+ feedback: s.thread_actions_feedback ?? f?.feedback,
109
+ retry: s.thread_actions_retry ?? f?.retry
110
+ } : f, [f, s]), B = O(() => s ? {
111
+ ...h,
112
112
  attachments: {
113
- ...m?.attachments,
114
- enabled: n.composer_attachments ?? m?.attachments?.enabled
113
+ ...h?.attachments,
114
+ enabled: s.composer_attachments ?? h?.attachments?.enabled
115
115
  }
116
- } : m, [m, n]), V = R(() => ({
117
- ...w,
118
- defaultTheme: n?.default_theme ?? w?.defaultTheme,
119
- accent: n?.default_accent ?? w?.accent
120
- }), [w, n]), O = R(() => n ? {
116
+ } : h, [h, s]), W = O(() => ({
117
+ ...N,
118
+ defaultTheme: s?.default_theme ?? N?.defaultTheme,
119
+ accent: s?.default_accent ?? N?.accent
120
+ }), [N, s]), K = O(() => s ? {
121
121
  ...C,
122
122
  sections: {
123
123
  ...C?.sections,
124
124
  general: {
125
125
  ...C?.sections?.general,
126
- mode: n.settings_general_mode || C?.sections?.general?.mode,
126
+ mode: s.settings_general_mode || C?.sections?.general?.mode,
127
127
  enabled: C?.sections?.general?.enabled ?? !0,
128
128
  fields: {
129
129
  ...C?.sections?.general?.fields,
130
- ...n.settings_general_fields
130
+ ...s.settings_general_fields
131
131
  }
132
132
  },
133
133
  profile: {
134
134
  ...C?.sections?.profile,
135
- mode: n.settings_profile_mode || C?.sections?.profile?.mode,
135
+ mode: s.settings_profile_mode || C?.sections?.profile?.mode,
136
136
  enabled: C?.sections?.profile?.enabled ?? !0,
137
137
  fields: {
138
138
  ...C?.sections?.profile?.fields,
139
- ...n.settings_profile_fields
139
+ ...s.settings_profile_fields
140
140
  }
141
141
  },
142
142
  account: {
143
143
  ...C?.sections?.account,
144
- mode: n.settings_account_mode || C?.sections?.account?.mode,
144
+ mode: s.settings_account_mode || C?.sections?.account?.mode,
145
145
  enabled: C?.sections?.account?.enabled ?? !0,
146
146
  fields: {
147
147
  ...C?.sections?.account?.fields,
148
- ...n.settings_account_fields
148
+ ...s.settings_account_fields
149
149
  }
150
150
  }
151
151
  }
152
- } : C, [C, n]), z = R(() => new Ye({
152
+ } : C, [C, s]), E = O(() => new Ze({
153
153
  defaultOptions: {
154
154
  queries: {
155
155
  staleTime: 5e3,
@@ -157,315 +157,357 @@ function Qa({
157
157
  }
158
158
  }
159
159
  }), []);
160
- F(() => {
161
- E.init({
162
- api: j,
163
- app: U
160
+ $(() => {
161
+ D.init({
162
+ api: U,
163
+ app: q
164
164
  });
165
- }, [U]);
166
- const K = Z(null), L = u?.resources;
167
- L !== K.current && (K.current = L, L && Object.entries(L).forEach(([b, c]) => {
168
- Object.entries(c).forEach(([k, A]) => {
169
- P.addResourceBundle(b, k, A, !0, !0);
165
+ }, [q]);
166
+ const V = ae(null), R = m?.resources;
167
+ R !== V.current && (V.current = R, R && Object.entries(R).forEach(([d, n]) => {
168
+ Object.entries(n).forEach(([k, I]) => {
169
+ P.addResourceBundle(d, k, I, !0, !0);
170
170
  });
171
171
  }));
172
- const H = Z(null), $ = n?.translations;
173
- $ && $ !== H.current && (H.current = $, Object.entries($).forEach(([b, c]) => {
174
- Object.entries(c).forEach(([k, A]) => {
175
- P.addResourceBundle(b, k, A, !0, !0);
172
+ const L = ae(null), H = s?.translations;
173
+ H && H !== L.current && (L.current = H, Object.entries(H).forEach(([d, n]) => {
174
+ Object.entries(n).forEach(([k, I]) => {
175
+ P.addResourceBundle(d, k, I, !0, !0);
176
176
  });
177
177
  }));
178
- const N = Z(null), y = u?.instance;
179
- return y && y !== N.current && (N.current = y, Object.entries(nt).forEach(([b, c]) => {
180
- Object.entries(c).forEach(([k, A]) => {
181
- y.hasResourceBundle(b, k) || y.addResourceBundle(b, k, A, !0, !1);
178
+ const F = ae(null), b = m?.instance;
179
+ return b && b !== F.current && (F.current = b, Object.entries(st).forEach(([d, n]) => {
180
+ Object.entries(n).forEach(([k, I]) => {
181
+ b.hasResourceBundle(d, k) || b.addResourceBundle(d, k, I, !0, !1);
182
182
  });
183
- })), /* @__PURE__ */ e(at, { i18n: P, children: /* @__PURE__ */ r(Ze, { client: z, children: [
183
+ })), /* @__PURE__ */ e(rt, { i18n: P, children: /* @__PURE__ */ r(et, { client: E, children: [
184
184
  /* @__PURE__ */ r(
185
185
  Fe,
186
186
  {
187
- components: l,
188
- history: q,
189
- welcome: I,
190
- threadActions: g,
187
+ components: c,
188
+ history: Q,
189
+ welcome: A,
190
+ threadActions: x,
191
191
  composer: B,
192
- theme: V,
193
- disclaimer: f,
194
- app: U,
195
- i18n: u,
196
- settings: O,
192
+ theme: W,
193
+ disclaimer: p,
194
+ app: q,
195
+ i18n: m,
196
+ settings: K,
197
197
  children: [
198
- /* @__PURE__ */ e(aa, {}),
199
- /* @__PURE__ */ e(st, { defaultTheme: "system", storageKey: "chatbot-theme", config: V, children: a })
198
+ /* @__PURE__ */ e(ra, {}),
199
+ /* @__PURE__ */ e(ot, { defaultTheme: "system", storageKey: "chatbot-theme", config: W, children: a })
200
200
  ]
201
201
  }
202
202
  ),
203
- /* @__PURE__ */ e(ta, { richColors: !0 })
203
+ /* @__PURE__ */ e(aa, { richColors: !0 })
204
204
  ] }) });
205
205
  }
206
- function aa() {
207
- const { app: a } = te();
208
- return je(), F(() => {
206
+ function ra() {
207
+ const { app: a } = re();
208
+ return je(), $(() => {
209
209
  a?.name && (document.title = a.name);
210
- }, [a?.name]), F(() => {
210
+ }, [a?.name]), $(() => {
211
211
  if (!a?.favicon) return;
212
212
  let t = document.querySelector("link[rel~='icon']");
213
213
  t || (t = document.createElement("link"), t.rel = "icon", document.head.appendChild(t)), t.href = a.favicon;
214
214
  }, [a?.favicon]), null;
215
215
  }
216
216
  function Ce() {
217
- const a = Ve(), t = _e(), u = E.getConfig().app?.basePath || "/", l = R(() => {
218
- const h = a.pathname, p = h.endsWith("/") && h !== "/" ? h.slice(0, -1) : h, m = u.endsWith("/") && u !== "/" ? u.slice(0, -1) : u;
219
- if (p === (m || "/")) return "/";
220
- if (h.startsWith(m) && m !== "/") {
221
- let w = h.slice(m.length);
222
- return w.startsWith("/") || (w = "/" + w), w;
217
+ const a = Ge(), t = _e(), m = D.getConfig().app?.basePath || "/", c = O(() => {
218
+ const g = a.pathname, f = g.endsWith("/") && g !== "/" ? g.slice(0, -1) : g, h = m.endsWith("/") && m !== "/" ? m.slice(0, -1) : m;
219
+ if (f === (h || "/")) return "/";
220
+ if (g.startsWith(h) && h !== "/") {
221
+ let N = g.slice(h.length);
222
+ return N.startsWith("/") || (N = "/" + N), N;
223
223
  }
224
- return m === "/" ? h : "/";
225
- }, [a.pathname, u]), d = J((h) => {
226
- t(be(u, h || "/"), { replace: !1 });
227
- }, [t, u]);
228
- return [l, d];
224
+ return h === "/" ? g : "/";
225
+ }, [a.pathname, m]), u = J((g) => {
226
+ t(be(m, g || "/"), { replace: !1 });
227
+ }, [t, m]);
228
+ return [c, u];
229
229
  }
230
- function ra({ onFinish: a } = {}) {
231
- const { t } = de(["chat", "errors"]), o = ue(), u = E.getConfig(), l = u.app?.cacheNamespace || "gentiq", [d, h] = Ce(), [p, m] = T(() => he()), w = Z(/* @__PURE__ */ new Set());
232
- F(() => {
233
- d === "/" ? m(he()) : p && d !== `/${p}` && m(he());
234
- }, [d]);
235
- const x = R(() => d === "/" ? p : d.replace(/^\//, ""), [d, p]), C = J((N) => (w.current.add(N), N), []), n = J(() => {
236
- w.current.forEach((N) => URL.revokeObjectURL(N)), w.current.clear();
230
+ function na({ onFinish: a } = {}) {
231
+ const { t } = de(["chat", "errors"]), i = ue(), m = D.getConfig(), c = m.app?.cacheNamespace || "gentiq", [u, g] = Ce(), [f, h] = T(() => he()), N = ae(/* @__PURE__ */ new Set());
232
+ $(() => {
233
+ u === "/" ? h(he()) : f && u !== `/${f}` && h(he());
234
+ }, [u]);
235
+ const y = O(() => u === "/" ? f : u.replace(/^\//, ""), [u, f]), C = J((b) => (N.current.add(b), b), []), s = J(() => {
236
+ N.current.forEach((b) => URL.revokeObjectURL(b)), N.current.clear();
237
237
  }, []);
238
- F(() => () => n(), [n]);
238
+ $(() => () => s(), [s]);
239
239
  const {
240
- data: D,
240
+ data: M,
241
241
  isLoading: P,
242
- isError: j
243
- } = et({
244
- queryKey: [l, "threadMessages", x],
242
+ isError: U
243
+ } = tt({
244
+ queryKey: [c, "threadMessages", y],
245
245
  queryFn: async () => {
246
- if (d === "/") return [];
247
- if (d === `/${p}`) return [];
248
- const N = await E.getThreadMessages(x);
249
- return !N.items || !Array.isArray(N.items) ? [] : Promise.all(
250
- N.items.map(async (y) => {
251
- const b = typeof y.content == "string" ? y.content : y.content?.text || JSON.stringify(y.content), k = [...Array.isArray(y.parts) && y.parts.length > 0 ? y.parts : [{ type: "text", text: b }]].sort((S, M) => S.type === "file" && M.type !== "file" ? -1 : S.type !== "file" && M.type === "file" ? 1 : 0), A = await Promise.all(
252
- k.map(async (S) => {
246
+ if (u === "/") return [];
247
+ if (u === `/${f}`) return [];
248
+ const b = await D.getThreadMessages(y);
249
+ return !b.items || !Array.isArray(b.items) ? [] : Promise.all(
250
+ b.items.map(async (d) => {
251
+ const n = typeof d.content == "string" ? d.content : d.content?.text || JSON.stringify(d.content), I = [...Array.isArray(d.parts) && d.parts.length > 0 ? d.parts : [{ type: "text", text: n }]].sort((S, w) => S.type === "file" && w.type !== "file" ? -1 : S.type !== "file" && w.type === "file" ? 1 : 0), j = await Promise.all(
252
+ I.map(async (S) => {
253
253
  if (S.type === "file" && S.object_name && !S.url)
254
254
  try {
255
- const M = await E.getAttachmentBlobUrl(S.object_name);
256
- return { ...S, url: C(M), mediaType: S.mediaType || S.media_type };
257
- } catch (M) {
258
- return console.warn("Load attachment failed:", S.object_name, M), { ...S, mediaType: S.mediaType || S.media_type };
255
+ const w = await D.getAttachmentBlobUrl(S.object_name);
256
+ return { ...S, url: C(w), mediaType: S.mediaType || S.media_type };
257
+ } catch (w) {
258
+ return console.warn("Load attachment failed:", S.object_name, w), { ...S, mediaType: S.mediaType || S.media_type };
259
259
  }
260
260
  return S;
261
261
  })
262
262
  );
263
263
  return {
264
- id: y.id || he(),
265
- role: y.role,
266
- parts: A,
267
- metadata: { feedback: y.feedback }
264
+ id: d.id || he(),
265
+ role: d.role,
266
+ parts: j,
267
+ metadata: { feedback: d.feedback }
268
268
  };
269
269
  })
270
270
  );
271
271
  },
272
- enabled: d !== "/",
272
+ enabled: u !== "/",
273
273
  staleTime: 5e3
274
274
  // Keep history fresh for 5 seconds
275
- }), U = R(() => new Xt({
276
- api: E.getEndpoint("chat", "/chat"),
277
- fetch: async (N, y) => {
278
- const b = new Headers(y?.headers), c = E.getHeaders();
279
- Object.entries(c).forEach(([M, G]) => {
280
- b.set(M, G);
281
- }), b.set("X-Thread-Id", x);
282
- const k = u.api?.basePath || "/api", A = typeof N == "string" && !N.startsWith("http") ? `${k}${N.startsWith("/") ? N : "/" + N}` : N, S = await fetch(A, { ...y, headers: b });
275
+ }), q = O(() => new Jt({
276
+ api: D.getEndpoint("chat", "/chat"),
277
+ fetch: async (b, d) => {
278
+ const n = new Headers(d?.headers), k = D.getHeaders();
279
+ Object.entries(k).forEach(([w, z]) => {
280
+ n.set(w, z);
281
+ }), n.set("X-Thread-Id", y);
282
+ const I = m.api?.basePath || "/api", j = typeof b == "string" && !b.startsWith("http") ? `${I}${b.startsWith("/") ? b : "/" + b}` : b, S = await fetch(j, { ...d, headers: n });
283
283
  if (!S.ok) {
284
- const M = await S.json().catch(() => ({}));
285
- if (M.error && (typeof M.error.code == "string" || typeof M.error.message == "string"))
286
- throw new Pe(M, S.status);
287
- let G = S.statusText || `HTTP ${S.status}`, ee = "error", re = null;
288
- throw typeof M.detail == "string" ? G = M.detail : typeof M.message == "string" ? G = M.message : typeof M.error == "string" ? G = M.error : Array.isArray(M.detail) ? (G = "Validation failed", re = M.detail, ee = "validation_error") : M.error && typeof M.error.message == "string" && (G = M.error.message), new Pe({
284
+ const w = await S.json().catch(() => ({}));
285
+ if (w.error && (typeof w.error.code == "string" || typeof w.error.message == "string"))
286
+ throw new Pe(w, S.status);
287
+ let z = S.statusText || `HTTP ${S.status}`, Y = "error", Z = null;
288
+ throw typeof w.detail == "string" ? z = w.detail : typeof w.message == "string" ? z = w.message : typeof w.error == "string" ? z = w.error : Array.isArray(w.detail) ? (z = "Validation failed", Z = w.detail, Y = "validation_error") : w.error && typeof w.error.message == "string" && (z = w.error.message), new Pe({
289
289
  error: {
290
- code: ee,
291
- message: G,
292
- details: re
290
+ code: Y,
291
+ message: z,
292
+ details: Z
293
293
  }
294
294
  }, S.status);
295
295
  }
296
296
  return S;
297
297
  }
298
- }), [x, u.api?.basePath]), I = J(() => {
299
- g("ready"), o.invalidateQueries({ queryKey: [l, "conversations"] }), a?.();
300
- }, [o, a, l]), f = Wt({
301
- id: x,
302
- onFinish: I,
303
- transport: U
304
- }), [q, g] = T("idle"), [B, V] = T(null), O = J(() => {
305
- V(null);
298
+ }), [y, m.api?.basePath]), A = J(() => {
299
+ x("ready"), i.invalidateQueries({ queryKey: [c, "conversations"] }), a?.();
300
+ }, [i, a, c]), p = Xt({
301
+ id: y,
302
+ onFinish: A,
303
+ transport: q
304
+ }), [Q, x] = T("idle"), [B, W] = T(null), K = J(() => {
305
+ W(null);
306
306
  }, []);
307
- F(() => {
308
- D && (d === `/${p}` || (f.setMessages(D), g("ready")));
309
- }, [D, f.setMessages, d, p]), F(() => {
310
- d === "/" && (f.setMessages([]), g("idle"));
311
- }, [d, f.setMessages]), F(() => {
312
- if (d === "/") {
313
- g("idle");
307
+ $(() => {
308
+ M && (u === `/${f}` || (p.setMessages(M), x("ready")));
309
+ }, [M, p.setMessages, u, f]), $(() => {
310
+ u === "/" && (p.setMessages([]), x("idle"));
311
+ }, [u, p.setMessages]), $(() => {
312
+ if (u === "/") {
313
+ x("idle");
314
314
  return;
315
315
  }
316
- const N = d === `/${p}`;
317
- P && !N ? g("loading-history") : j || B || f.error ? g("error") : f.status === "streaming" || f.status === "submitted" ? g(f.status) : g("ready");
318
- }, [P, j, f.status, B, f.error, d, p]), F(() => () => {
319
- f.stop();
320
- }, [x, f.stop]);
321
- const z = Z(/* @__PURE__ */ new Set()), K = R(() => f.messages.filter((N) => N.role === "assistant"), [f.messages]);
322
- F(() => {
323
- let N = !1;
324
- for (const y of K) {
325
- if (z.current.has(y.id)) continue;
326
- const b = y.parts.find((c) => c.type === "data-title");
327
- b && b.data?.[0]?.title && (z.current.add(y.id), N = !0);
316
+ const b = u === `/${f}`;
317
+ P && !b ? x("loading-history") : U || B || p.error ? x("error") : p.status === "streaming" || p.status === "submitted" ? x(p.status) : x("ready");
318
+ }, [P, U, p.status, B, p.error, u, f]), $(() => () => {
319
+ p.stop();
320
+ }, [y, p.stop]);
321
+ const E = ae(/* @__PURE__ */ new Set()), V = O(() => p.messages.filter((b) => b.role === "assistant"), [p.messages]);
322
+ $(() => {
323
+ let b = !1;
324
+ for (const d of V) {
325
+ if (E.current.has(d.id)) continue;
326
+ const n = d.parts.find((k) => k.type === "data-title");
327
+ n && n.data?.[0]?.title && (E.current.add(d.id), b = !0);
328
328
  }
329
- N && o.invalidateQueries({ queryKey: [l, "conversations"] });
330
- }, [K, o, l]);
331
- const L = J(async (N, y) => {
332
- const b = d === "/", c = N.trim();
333
- if (!(!c && (!y || y.length === 0)) && !(q === "loading-history" || q === "streaming" || q === "submitted")) {
334
- if (f.stop(), b) {
335
- h(`/${x}`);
336
- const k = c || t("attach_file"), A = k.length > 30 ? k.slice(0, 30) + "..." : k;
337
- o.setQueryData([l, "conversations"], (S) => {
338
- const M = { id: `/${x}`, firstMessage: A, timestamp: Date.now() };
339
- return S && Array.isArray(S.pages) ? {
340
- ...S,
341
- pages: S.pages.map((G, ee) => ee === 0 ? {
342
- ...G,
343
- threads: [M, ...G.threads || []]
344
- } : G)
345
- } : [M, ...Array.isArray(S) ? S : []];
329
+ b && i.invalidateQueries({ queryKey: [c, "conversations"] });
330
+ }, [V, i, c]);
331
+ const R = J((b) => {
332
+ if (b.length === 0) return;
333
+ const d = b.map((n) => ({
334
+ type: "data-reference",
335
+ data: n
336
+ }));
337
+ p.setMessages((n) => {
338
+ const k = new Set(b.map((w) => w.id));
339
+ if (n.some(
340
+ (w) => w.parts.some((z) => z.type === "data-reference" && k.has(z.data?.id))
341
+ )) return n;
342
+ const j = [...n].reverse().findIndex((w) => w.role === "user" && !w.parts.some((z) => z.type === "data-reference"));
343
+ if (j === -1) return n;
344
+ const S = n.length - 1 - j;
345
+ return n.map((w, z) => z !== S ? w : {
346
+ ...w,
347
+ metadata: {
348
+ ...w.metadata || {},
349
+ references: b
350
+ },
351
+ parts: [
352
+ ...d,
353
+ ...w.parts
354
+ ]
355
+ });
356
+ });
357
+ }, [p.setMessages]), L = J(async (b, d, n = []) => {
358
+ const k = u === "/", I = b.trim();
359
+ if (!(!I && (!d || d.length === 0) && n.length === 0) && !(Q === "loading-history" || Q === "streaming" || Q === "submitted")) {
360
+ if (p.stop(), k) {
361
+ g(`/${y}`);
362
+ const j = I || (n[0]?.excerpt ? `↳ ${n[0].excerpt}` : t("attach_file")), S = j.length > 30 ? j.slice(0, 30) + "..." : j;
363
+ i.setQueryData([c, "conversations"], (w) => {
364
+ const z = { id: `/${y}`, firstMessage: S, timestamp: Date.now() };
365
+ return w && Array.isArray(w.pages) ? {
366
+ ...w,
367
+ pages: w.pages.map((Y, Z) => Z === 0 ? {
368
+ ...Y,
369
+ threads: [z, ...Y.threads || []]
370
+ } : Y)
371
+ } : [z, ...Array.isArray(w) ? w : []];
346
372
  });
347
373
  }
348
- g("submitted"), V(null);
374
+ x("submitted"), W(null);
349
375
  try {
350
- await f.sendMessage({ text: c, files: y });
351
- } catch (k) {
352
- console.error("Failed to send message:", k);
353
- const A = ce(k, t);
354
- V(new Error(A)), g("error");
376
+ if (n.length > 0) {
377
+ const j = p.sendMessage({ text: I, files: d }, { body: { references: n } });
378
+ window.setTimeout(() => R(n), 0), window.setTimeout(() => R(n), 80), await j;
379
+ } else
380
+ await p.sendMessage({ text: I, files: d });
381
+ } catch (j) {
382
+ console.error("Failed to send message:", j);
383
+ const S = ce(j, t);
384
+ W(new Error(S)), x("error");
355
385
  }
356
386
  }
357
- }, [f, h, d, x, t, o, q, l]), H = J(() => {
358
- f.stop(), g("ready"), o.invalidateQueries({ queryKey: [l, "conversations"] });
359
- }, [f.stop, o, l]), $ = R(() => {
387
+ }, [p, g, u, y, t, i, Q, c, R]), H = J(() => {
388
+ p.stop(), x("ready"), i.invalidateQueries({ queryKey: [c, "conversations"] });
389
+ }, [p.stop, i, c]), F = O(() => {
360
390
  if (B) return B;
361
- if (f.error) {
362
- const N = ce(f.error, t);
363
- return new Error(N);
391
+ if (p.error) {
392
+ const b = ce(p.error, t);
393
+ return new Error(b);
364
394
  }
365
395
  return null;
366
- }, [B, f.error, t]);
367
- return R(() => ({
368
- ...f,
396
+ }, [B, p.error, t]);
397
+ return O(() => ({
398
+ ...p,
369
399
  sendMessage: L,
370
400
  stop: H,
371
- clearError: O,
372
- error: $,
373
- status: q,
401
+ clearError: K,
402
+ error: F,
403
+ status: Q,
374
404
  // Cast to any to satisfy Chat.tsx expectations of AI SDK statuses
375
- isLoadingHistory: q === "loading-history",
376
- isErrorHistory: q === "error" || !!$ || j,
377
- conversationId: d
378
- }), [f, L, H, O, $, q, j, d]);
405
+ isLoadingHistory: Q === "loading-history",
406
+ isErrorHistory: Q === "error" || !!F || U,
407
+ conversationId: u
408
+ }), [p, L, H, K, F, Q, U, u]);
379
409
  }
380
- function na({ classNames: a = {}, disclaimer: t }) {
381
- const { t: o, i18n: u } = de(["chat", "translation"]), l = ra(), { messages: d, status: h, regenerate: p, error: m, clearError: w, stop: x, isLoadingHistory: C, conversationId: n, sendMessage: D } = l, { MessageList: P, PromptInput: j, disclaimer: U } = te(), I = t ?? U, f = u.exists("chat:disclaimer") ? o("chat:disclaimer") : null, q = typeof I == "string" ? o(I) : I ?? f, [g, B] = T(null), V = Z(h);
382
- Je(() => {
383
- m && w();
384
- }, [n, w, m]);
385
- const O = d[d.length - 1], z = O?.role === "assistant" && (h === "ready" || O.parts.some((L) => L.type === "data-chat-finished"));
386
- F(() => {
387
- h === "error" && V.current !== "error" && g !== n ? B(n) : h === "submitted" && g !== null && B(null), V.current = h;
388
- }, [h, n]);
389
- const K = h === "error" && (n === "/" || g === n);
390
- return /* @__PURE__ */ r("div", { className: v("relative flex flex-col h-full overflow-hidden", a.container), children: [
391
- /* @__PURE__ */ e(
392
- P,
393
- {
394
- messages: d,
395
- status: h,
396
- isLoadingHistory: C,
397
- error: K ? m : null,
398
- conversationId: n,
399
- regen: (L) => p({ messageId: L }),
400
- onSuggestionClick: (L) => D(L),
401
- chat: l,
402
- className: v("flex-1", a.messageList)
403
- }
404
- ),
405
- /* @__PURE__ */ r("div", { className: "absolute bottom-0 left-0 right-0 z-10 pointer-events-none flex flex-col items-stretch", children: [
406
- /* @__PURE__ */ e(
407
- j,
408
- {
409
- onSend: D,
410
- status: h,
411
- isLastMessageFinished: z,
412
- stop: x,
413
- isErrorVisible: K,
414
- conversationId: n,
415
- className: v("pointer-events-auto", a.inputArea, q && "pb-0 md:pb-0")
416
- }
417
- ),
418
- q && /* @__PURE__ */ r("div", { className: "relative py-1 px-4 flex justify-center items-center pointer-events-auto", children: [
419
- /* @__PURE__ */ e("div", { className: "absolute inset-x-0 bottom-0 top-[-20px] bg-background/80 backdrop-blur-sm [mask-image:linear-gradient(to_top,black_60%,transparent)] pointer-events-none -z-10" }),
420
- /* @__PURE__ */ e("p", { className: "text-[10px] md:text-[11px] text-muted-foreground/60 select-none text-center leading-tight", children: q })
410
+ function sa({ classNames: a = {}, disclaimer: t }) {
411
+ const { t: i, i18n: m } = de(["chat", "translation"]), c = na(), { messages: u, status: g, regenerate: f, error: h, clearError: N, stop: y, isLoadingHistory: C, conversationId: s, sendMessage: M } = c, { MessageList: P, PromptInput: U, composer: q, disclaimer: A } = re(), p = t ?? A, Q = m.exists("chat:disclaimer") ? i("chat:disclaimer") : null, x = typeof p == "string" ? i(p) : p ?? Q, [B, W] = T(null), K = ae(g);
412
+ Ye(() => {
413
+ h && N();
414
+ }, [s, N, h]);
415
+ const E = u[u.length - 1], V = E?.role === "assistant" && (g === "ready" || E.parts.some((L) => L.type === "data-chat-finished"));
416
+ $(() => {
417
+ g === "error" && K.current !== "error" && B !== s ? W(s) : g === "submitted" && B !== null && W(null), K.current = g;
418
+ }, [g, s]);
419
+ const R = g === "error" && (s === "/" || B === s);
420
+ return /* @__PURE__ */ e(
421
+ Oe,
422
+ {
423
+ enabled: q?.references?.enabled ?? !0,
424
+ maxItems: q?.references?.maxItems,
425
+ maxExcerptLength: q?.references?.maxExcerptLength,
426
+ children: /* @__PURE__ */ r("div", { className: v("relative flex flex-col h-full overflow-hidden", a.container), children: [
427
+ /* @__PURE__ */ e(
428
+ P,
429
+ {
430
+ messages: u,
431
+ status: g,
432
+ isLoadingHistory: C,
433
+ error: R ? h : null,
434
+ conversationId: s,
435
+ regen: (L) => f({ messageId: L }),
436
+ onSuggestionClick: (L) => M(L),
437
+ chat: c,
438
+ className: v("flex-1", a.messageList)
439
+ }
440
+ ),
441
+ /* @__PURE__ */ r("div", { className: "absolute bottom-0 left-0 right-0 z-10 pointer-events-none flex flex-col items-stretch", children: [
442
+ /* @__PURE__ */ e(
443
+ U,
444
+ {
445
+ onSend: M,
446
+ status: g,
447
+ isLastMessageFinished: V,
448
+ stop: y,
449
+ isErrorVisible: R,
450
+ conversationId: s,
451
+ className: v("pointer-events-auto", a.inputArea, x && "pb-0 md:pb-0")
452
+ }
453
+ ),
454
+ x && /* @__PURE__ */ r("div", { className: "relative py-1 px-4 flex justify-center items-center pointer-events-auto", children: [
455
+ /* @__PURE__ */ e("div", { className: "absolute inset-x-0 bottom-0 top-[-20px] bg-background/80 backdrop-blur-sm [mask-image:linear-gradient(to_top,black_60%,transparent)] pointer-events-none -z-10" }),
456
+ /* @__PURE__ */ e("p", { className: "text-[10px] md:text-[11px] text-muted-foreground/60 select-none text-center leading-tight", children: x })
457
+ ] })
458
+ ] })
421
459
  ] })
422
- ] })
423
- ] });
460
+ }
461
+ );
424
462
  }
425
- const sa = ({
463
+ const oa = ({
426
464
  components: a,
427
465
  history: t,
428
- welcome: o,
429
- threadActions: u,
430
- composer: l,
431
- theme: d,
432
- disclaimer: h,
433
- ...p
466
+ welcome: i,
467
+ threadActions: m,
468
+ composer: c,
469
+ theme: u,
470
+ disclaimer: g,
471
+ ...f
434
472
  }) => {
435
- const m = te(), w = R(() => ({
436
- ...m,
473
+ const h = re(), N = O(() => ({
474
+ ...h,
437
475
  ...a,
438
476
  toolComponents: {
439
- ...m.toolComponents,
477
+ ...h.toolComponents,
440
478
  ...a?.toolComponents
479
+ },
480
+ referenceAdapters: {
481
+ ...h.referenceAdapters,
482
+ ...a?.referenceAdapters
441
483
  }
442
- }), [m, a]);
484
+ }), [h, a]);
443
485
  return /* @__PURE__ */ e(
444
486
  Fe,
445
487
  {
446
- components: w,
447
- history: t ?? m.history,
448
- welcome: o ?? m.welcome,
449
- threadActions: u ?? m.threadActions,
450
- composer: l ?? m.composer,
451
- theme: d ?? m.theme,
452
- disclaimer: h ?? m.disclaimer,
453
- app: m.app,
454
- i18n: m.i18n,
455
- settings: m.settings,
456
- children: /* @__PURE__ */ e(na, { ...p })
488
+ components: N,
489
+ history: t ?? h.history,
490
+ welcome: i ?? h.welcome,
491
+ threadActions: m ?? h.threadActions,
492
+ composer: c ?? h.composer,
493
+ theme: u ?? h.theme,
494
+ disclaimer: g ?? h.disclaimer,
495
+ app: h.app,
496
+ i18n: h.i18n,
497
+ settings: h.settings,
498
+ children: /* @__PURE__ */ e(sa, { ...f })
457
499
  }
458
500
  );
459
501
  };
460
- function oa({ ...a }) {
461
- return /* @__PURE__ */ e(oe.Root, { "data-slot": "sheet", ...a });
462
- }
463
502
  function ia({ ...a }) {
464
- return /* @__PURE__ */ e(oe.Portal, { "data-slot": "sheet-portal", ...a });
503
+ return /* @__PURE__ */ e(ie.Root, { "data-slot": "sheet", ...a });
465
504
  }
466
- function la({ className: a, ...t }) {
505
+ function la({ ...a }) {
506
+ return /* @__PURE__ */ e(ie.Portal, { "data-slot": "sheet-portal", ...a });
507
+ }
508
+ function ca({ className: a, ...t }) {
467
509
  return /* @__PURE__ */ e(
468
- oe.Overlay,
510
+ ie.Overlay,
469
511
  {
470
512
  "data-slot": "sheet-overlay",
471
513
  className: v(
@@ -476,31 +518,31 @@ function la({ className: a, ...t }) {
476
518
  }
477
519
  );
478
520
  }
479
- function ca({
521
+ function da({
480
522
  className: a,
481
523
  children: t,
482
- side: o = "right",
483
- ...u
524
+ side: i = "right",
525
+ ...m
484
526
  }) {
485
- return /* @__PURE__ */ r(ia, { children: [
486
- /* @__PURE__ */ e(la, {}),
527
+ return /* @__PURE__ */ r(la, { children: [
528
+ /* @__PURE__ */ e(ca, {}),
487
529
  /* @__PURE__ */ r(
488
- oe.Content,
530
+ ie.Content,
489
531
  {
490
532
  "data-slot": "sheet-content",
491
533
  className: v(
492
534
  "bg-background data-[state=open]:animate-in data-[state=closed]:animate-out fixed z-50 flex flex-col gap-4 shadow-lg transition ease-in-out data-[state=closed]:duration-300 data-[state=open]:duration-500",
493
- o === "right" && "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",
494
- o === "left" && "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",
495
- o === "top" && "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
496
- o === "bottom" && "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
535
+ i === "right" && "data-[state=closed]:slide-out-to-right data-[state=open]:slide-in-from-right inset-y-0 right-0 h-full w-3/4 border-l sm:max-w-sm",
536
+ i === "left" && "data-[state=closed]:slide-out-to-left data-[state=open]:slide-in-from-left inset-y-0 left-0 h-full w-3/4 border-r sm:max-w-sm",
537
+ i === "top" && "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
538
+ i === "bottom" && "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
497
539
  a
498
540
  ),
499
- ...u,
541
+ ...m,
500
542
  children: [
501
543
  t,
502
- /* @__PURE__ */ r(oe.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none", children: [
503
- /* @__PURE__ */ e(_t, { className: "size-4" }),
544
+ /* @__PURE__ */ r(ie.Close, { className: "ring-offset-background focus:ring-ring data-[state=open]:bg-secondary absolute top-4 right-4 rounded-xs opacity-70 transition-opacity hover:opacity-100 focus:ring-2 focus:ring-offset-2 focus:outline-hidden disabled:pointer-events-none", children: [
545
+ /* @__PURE__ */ e(Ct, { className: "size-4" }),
504
546
  /* @__PURE__ */ e("span", { className: "sr-only", children: "Close" })
505
547
  ] })
506
548
  ]
@@ -508,12 +550,12 @@ function ca({
508
550
  )
509
551
  ] });
510
552
  }
511
- function da({ className: a, ...t }) {
553
+ function ua({ className: a, ...t }) {
512
554
  return /* @__PURE__ */ e("div", { "data-slot": "sheet-header", className: v("flex flex-col gap-1.5 p-4", a), ...t });
513
555
  }
514
- function ua({ className: a, ...t }) {
556
+ function ma({ className: a, ...t }) {
515
557
  return /* @__PURE__ */ e(
516
- oe.Title,
558
+ ie.Title,
517
559
  {
518
560
  "data-slot": "sheet-title",
519
561
  className: v("text-foreground font-semibold", a),
@@ -521,9 +563,9 @@ function ua({ className: a, ...t }) {
521
563
  }
522
564
  );
523
565
  }
524
- function ma({ className: a, ...t }) {
566
+ function ha({ className: a, ...t }) {
525
567
  return /* @__PURE__ */ e(
526
- oe.Description,
568
+ ie.Description,
527
569
  {
528
570
  "data-slot": "sheet-description",
529
571
  className: v("text-muted-foreground text-sm", a),
@@ -531,109 +573,109 @@ function ma({ className: a, ...t }) {
531
573
  }
532
574
  );
533
575
  }
534
- const ha = "sidebar_state", pa = 3600 * 24 * 7, ga = "19rem", fa = "18rem", ba = "3rem", va = "b", Ge = ae.createContext(null);
576
+ const pa = "sidebar_state", ga = 3600 * 24 * 7, fa = "19rem", ba = "18rem", xa = "3rem", va = "b", We = ne.createContext(null);
535
577
  function fe() {
536
- const a = ae.useContext(Ge);
578
+ const a = ne.useContext(We);
537
579
  if (!a)
538
580
  throw new Error("useSidebar must be used within a SidebarProvider.");
539
581
  return a;
540
582
  }
541
- function xa({
583
+ function ya({
542
584
  defaultOpen: a = !0,
543
585
  open: t,
544
- onOpenChange: o,
545
- className: u,
546
- style: l,
547
- children: d,
548
- ...h
586
+ onOpenChange: i,
587
+ className: m,
588
+ style: c,
589
+ children: u,
590
+ ...g
549
591
  }) {
550
- const p = ot(), [m, w] = ae.useState(!1), [x, C] = ae.useState(a), n = t ?? x, D = ae.useCallback(
551
- (I) => {
552
- const f = typeof I == "function" ? I(n) : I;
553
- o ? o(f) : C(f), document.cookie = `${ha}=${f}; path=/; max-age=${pa}`;
592
+ const f = it(), [h, N] = ne.useState(!1), [y, C] = ne.useState(a), s = t ?? y, M = ne.useCallback(
593
+ (A) => {
594
+ const p = typeof A == "function" ? A(s) : A;
595
+ i ? i(p) : C(p), document.cookie = `${pa}=${p}; path=/; max-age=${ga}`;
554
596
  },
555
- [o, n]
556
- ), P = ae.useCallback(() => {
557
- p ? w((I) => !I) : D((I) => !I);
558
- }, [p, D, w]);
559
- ae.useEffect(() => {
560
- const I = (f) => {
561
- f.key === va && (f.metaKey || f.ctrlKey) && (f.preventDefault(), P());
597
+ [i, s]
598
+ ), P = ne.useCallback(() => {
599
+ f ? N((A) => !A) : M((A) => !A);
600
+ }, [f, M, N]);
601
+ ne.useEffect(() => {
602
+ const A = (p) => {
603
+ p.key === va && (p.metaKey || p.ctrlKey) && (p.preventDefault(), P());
562
604
  };
563
- return window.addEventListener("keydown", I), () => {
564
- window.removeEventListener("keydown", I);
605
+ return window.addEventListener("keydown", A), () => {
606
+ window.removeEventListener("keydown", A);
565
607
  };
566
608
  }, [P]);
567
- const j = n ? "expanded" : "collapsed", U = ae.useMemo(
609
+ const U = s ? "expanded" : "collapsed", q = ne.useMemo(
568
610
  () => ({
569
- state: j,
570
- open: n,
571
- setOpen: D,
572
- isMobile: p,
573
- openMobile: m,
574
- setOpenMobile: w,
611
+ state: U,
612
+ open: s,
613
+ setOpen: M,
614
+ isMobile: f,
615
+ openMobile: h,
616
+ setOpenMobile: N,
575
617
  toggleSidebar: P
576
618
  }),
577
- [j, n, D, p, m, w, P]
619
+ [U, s, M, f, h, N, P]
578
620
  );
579
- return /* @__PURE__ */ e(Ge.Provider, { value: U, children: /* @__PURE__ */ e(Oe, { delayDuration: 0, children: /* @__PURE__ */ e(
621
+ return /* @__PURE__ */ e(We.Provider, { value: q, children: /* @__PURE__ */ e($e, { delayDuration: 0, children: /* @__PURE__ */ e(
580
622
  "div",
581
623
  {
582
624
  "data-slot": "sidebar-wrapper",
583
625
  style: {
584
- "--sidebar-width": ga,
585
- "--sidebar-width-icon": ba,
586
- ...l
626
+ "--sidebar-width": fa,
627
+ "--sidebar-width-icon": xa,
628
+ ...c
587
629
  },
588
- className: v("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full", u),
589
- ...h,
590
- children: d
630
+ className: v("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full", m),
631
+ ...g,
632
+ children: u
591
633
  }
592
634
  ) }) });
593
635
  }
594
- function ya({
636
+ function wa({
595
637
  side: a = "left",
596
638
  variant: t = "sidebar",
597
- collapsible: o = "offcanvas",
598
- className: u,
599
- children: l,
600
- ...d
639
+ collapsible: i = "offcanvas",
640
+ className: m,
641
+ children: c,
642
+ ...u
601
643
  }) {
602
- const { isMobile: h, state: p, openMobile: m, setOpenMobile: w } = fe();
603
- return o === "none" ? /* @__PURE__ */ e(
644
+ const { isMobile: g, state: f, openMobile: h, setOpenMobile: N } = fe();
645
+ return i === "none" ? /* @__PURE__ */ e(
604
646
  "div",
605
647
  {
606
648
  "data-slot": "sidebar",
607
- className: v("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col", u),
608
- ...d,
609
- children: l
649
+ className: v("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col", m),
650
+ ...u,
651
+ children: c
610
652
  }
611
- ) : h ? /* @__PURE__ */ e(oa, { open: m, onOpenChange: w, ...d, children: /* @__PURE__ */ r(
612
- ca,
653
+ ) : g ? /* @__PURE__ */ e(ia, { open: h, onOpenChange: N, ...u, children: /* @__PURE__ */ r(
654
+ da,
613
655
  {
614
- onOpenAutoFocus: (x) => x.preventDefault(),
656
+ onOpenAutoFocus: (y) => y.preventDefault(),
615
657
  "data-sidebar": "sidebar",
616
658
  "data-slot": "sidebar",
617
659
  "data-mobile": "true",
618
660
  className: "bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden",
619
661
  style: {
620
- "--sidebar-width": fa
662
+ "--sidebar-width": ba
621
663
  },
622
664
  side: a,
623
665
  children: [
624
- /* @__PURE__ */ r(da, { className: "sr-only", children: [
625
- /* @__PURE__ */ e(ua, { children: "Sidebar" }),
626
- /* @__PURE__ */ e(ma, { children: "Displays the mobile sidebar." })
666
+ /* @__PURE__ */ r(ua, { className: "sr-only", children: [
667
+ /* @__PURE__ */ e(ma, { children: "Sidebar" }),
668
+ /* @__PURE__ */ e(ha, { children: "Displays the mobile sidebar." })
627
669
  ] }),
628
- /* @__PURE__ */ e("div", { className: "flex h-full w-full flex-col", children: l })
670
+ /* @__PURE__ */ e("div", { className: "flex h-full w-full flex-col", children: c })
629
671
  ]
630
672
  }
631
673
  ) }) : /* @__PURE__ */ r(
632
674
  "div",
633
675
  {
634
676
  className: "group peer text-sidebar-foreground hidden md:block",
635
- "data-state": p,
636
- "data-collapsible": p === "collapsed" ? o : "",
677
+ "data-state": f,
678
+ "data-collapsible": f === "collapsed" ? i : "",
637
679
  "data-variant": t,
638
680
  "data-side": a,
639
681
  "data-slot": "sidebar",
@@ -659,16 +701,16 @@ function ya({
659
701
  a === "left" ? "left-0 group-data-[collapsible=offcanvas]:left-[calc(var(--sidebar-width)*-1)]" : "right-0 group-data-[collapsible=offcanvas]:right-[calc(var(--sidebar-width)*-1)]",
660
702
  // Adjust the padding for floating and inset variants.
661
703
  t === "floating" || t === "inset" ? "p-2 group-data-[collapsible=icon]:w-[calc(var(--sidebar-width-icon)+(--spacing(4))+2px)]" : "group-data-[collapsible=icon]:w-(--sidebar-width-icon) group-data-[side=left]:border-r group-data-[side=right]:border-l",
662
- u
704
+ m
663
705
  ),
664
- ...d,
706
+ ...u,
665
707
  children: /* @__PURE__ */ e(
666
708
  "div",
667
709
  {
668
710
  "data-sidebar": "sidebar",
669
711
  "data-slot": "sidebar-inner",
670
712
  className: "bg-sidebar group-data-[variant=floating]:border-sidebar-border flex h-full w-full flex-col group-data-[variant=floating]:rounded-lg group-data-[variant=floating]:border group-data-[variant=floating]:shadow-sm",
671
- children: l
713
+ children: c
672
714
  }
673
715
  )
674
716
  }
@@ -677,28 +719,28 @@ function ya({
677
719
  }
678
720
  );
679
721
  }
680
- function wa({ className: a, onClick: t, ...o }) {
681
- const { toggleSidebar: u } = fe();
722
+ function Na({ className: a, onClick: t, ...i }) {
723
+ const { toggleSidebar: m } = fe();
682
724
  return /* @__PURE__ */ r(
683
- Y,
725
+ te,
684
726
  {
685
727
  "data-sidebar": "trigger",
686
728
  "data-slot": "sidebar-trigger",
687
729
  variant: "ghost",
688
730
  size: "icon",
689
731
  className: v("size-7", a),
690
- onClick: (l) => {
691
- t?.(l), u();
732
+ onClick: (c) => {
733
+ t?.(c), m();
692
734
  },
693
- ...o,
735
+ ...i,
694
736
  children: [
695
- /* @__PURE__ */ e(Ct, {}),
737
+ /* @__PURE__ */ e(St, {}),
696
738
  /* @__PURE__ */ e("span", { className: "sr-only", children: "Toggle Sidebar" })
697
739
  ]
698
740
  }
699
741
  );
700
742
  }
701
- function Na({ className: a, ...t }) {
743
+ function ka({ className: a, ...t }) {
702
744
  return /* @__PURE__ */ e(
703
745
  "div",
704
746
  {
@@ -709,7 +751,7 @@ function Na({ className: a, ...t }) {
709
751
  }
710
752
  );
711
753
  }
712
- function ka({ className: a, ...t }) {
754
+ function _a({ className: a, ...t }) {
713
755
  return /* @__PURE__ */ e(
714
756
  "div",
715
757
  {
@@ -723,7 +765,7 @@ function ka({ className: a, ...t }) {
723
765
  }
724
766
  );
725
767
  }
726
- function _a({ className: a, ...t }) {
768
+ function Ca({ className: a, ...t }) {
727
769
  return /* @__PURE__ */ e(
728
770
  "div",
729
771
  {
@@ -734,7 +776,7 @@ function _a({ className: a, ...t }) {
734
776
  }
735
777
  );
736
778
  }
737
- function Ee({ className: a, ...t }) {
779
+ function Ae({ className: a, ...t }) {
738
780
  return /* @__PURE__ */ e(
739
781
  "div",
740
782
  {
@@ -745,7 +787,7 @@ function Ee({ className: a, ...t }) {
745
787
  }
746
788
  );
747
789
  }
748
- function Ae({ className: a, ...t }) {
790
+ function Ee({ className: a, ...t }) {
749
791
  return /* @__PURE__ */ e(
750
792
  "ul",
751
793
  {
@@ -767,7 +809,7 @@ function Le({ className: a, ...t }) {
767
809
  }
768
810
  );
769
811
  }
770
- const Ca = ea(
812
+ const Sa = ta(
771
813
  "peer/menu-button flex w-full items-center gap-2 overflow-hidden rounded-md p-2 text-start text-sm outline-hidden ring-sidebar-ring transition-[width,height,padding] hover:bg-sidebar-accent hover:text-sidebar-accent-foreground focus-visible:ring-2 active:bg-sidebar-accent active:text-sidebar-accent-foreground disabled:pointer-events-none disabled:opacity-50 group-has-data-[sidebar=menu-action]/menu-item:pr-8 aria-disabled:pointer-events-none aria-disabled:opacity-50 data-[active=true]:bg-sidebar-accent data-[active=true]:font-medium data-[active=true]:text-sidebar-accent-foreground data-[state=open]:hover:bg-sidebar-accent data-[state=open]:hover:text-sidebar-accent-foreground group-data-[collapsible=icon]:size-8! group-data-[collapsible=icon]:p-2! [&>span:last-child]:truncate [&>svg]:size-4 [&>svg]:shrink-0",
772
814
  {
773
815
  variants: {
@@ -787,98 +829,98 @@ const Ca = ea(
787
829
  }
788
830
  }
789
831
  );
790
- function ze({
832
+ function Re({
791
833
  asChild: a = !1,
792
834
  isActive: t = !1,
793
- variant: o = "default",
794
- size: u = "default",
795
- tooltip: l,
796
- className: d,
797
- ...h
835
+ variant: i = "default",
836
+ size: m = "default",
837
+ tooltip: c,
838
+ className: u,
839
+ ...g
798
840
  }) {
799
- const p = a ? Zt : "button", { isMobile: m, state: w } = fe(), x = /* @__PURE__ */ e(
800
- p,
841
+ const f = a ? ea : "button", { isMobile: h, state: N } = fe(), y = /* @__PURE__ */ e(
842
+ f,
801
843
  {
802
844
  "data-slot": "sidebar-menu-button",
803
845
  "data-sidebar": "menu-button",
804
- "data-size": u,
846
+ "data-size": m,
805
847
  "data-active": t,
806
- className: v(Ca({ variant: o, size: u }), d),
807
- ...h
848
+ className: v(Sa({ variant: i, size: m }), u),
849
+ ...g
808
850
  }
809
851
  );
810
- return l ? (typeof l == "string" && (l = {
811
- children: l
812
- }), /* @__PURE__ */ r($e, { children: [
813
- /* @__PURE__ */ e(Ue, { asChild: !0, children: x }),
814
- /* @__PURE__ */ e(Be, { side: "right", align: "center", hidden: w !== "collapsed" || m, ...l })
815
- ] })) : x;
852
+ return c ? (typeof c == "string" && (c = {
853
+ children: c
854
+ }), /* @__PURE__ */ r(Ue, { children: [
855
+ /* @__PURE__ */ e(Be, { asChild: !0, children: y }),
856
+ /* @__PURE__ */ e(Ke, { side: "right", align: "center", hidden: N !== "collapsed" || h, ...c })
857
+ ] })) : y;
816
858
  }
817
- function Sa({ trigger: a }) {
818
- const { t, i18n: o } = de(["settings", "translation"]), { app: u, settings: l } = te(), d = ue(), { theme: h, setTheme: p, accent: m, setAccent: w, radius: x, setRadius: C } = Ke(), [n, D] = T(null), [P, j] = T(!1), U = Z(null), I = R(() => [
859
+ function Pa({ trigger: a }) {
860
+ const { t, i18n: i } = de(["settings", "translation"]), { app: m, settings: c } = re(), u = ue(), { theme: g, setTheme: f, accent: h, setAccent: N, radius: y, setRadius: C } = Qe(), [s, M] = T(null), [P, U] = T(!1), q = ae(null), A = O(() => [
819
861
  { id: "general", label: t("sections.general", "General"), icon: Me },
820
- { id: "profile", label: t("sections.profile", "Profile"), icon: St },
821
- { id: "account", label: t("sections.account", "Account"), icon: Pt }
822
- ].filter((s) => {
823
- const _ = l?.sections?.[s.id];
862
+ { id: "profile", label: t("sections.profile", "Profile"), icon: Pt },
863
+ { id: "account", label: t("sections.account", "Account"), icon: Tt }
864
+ ].filter((o) => {
865
+ const _ = c?.sections?.[o.id];
824
866
  return (_?.mode ?? (_?.enabled === !1 ? "hidden" : "editable")) !== "hidden";
825
- }), [t, l]), [f, q] = T(I[0]?.id || "general"), g = J((i, s, _ = "editable") => {
826
- const se = l?.sections?.[i]?.fields;
827
- return se && se[s] || _;
828
- }, [l]), [B, V] = T(""), [O, z] = T(""), [K, L] = T(""), [H, $] = T(""), N = R(() => u?.userMetadataFields?.filter((i) => i.showInProfile) || [], [u?.userMetadataFields]), [y, b] = T({}), [c, k] = T(!1), A = o.language === "fa", S = A ? "text-right" : "text-left", M = J(async () => {
867
+ }), [t, c]), [p, Q] = T(A[0]?.id || "general"), x = J((l, o, _ = "editable") => {
868
+ const oe = c?.sections?.[l]?.fields;
869
+ return oe && oe[o] || _;
870
+ }, [c]), [B, W] = T(""), [K, E] = T(""), [V, R] = T(""), [L, H] = T(""), F = O(() => m?.userMetadataFields?.filter((l) => l.showInProfile) || [], [m?.userMetadataFields]), [b, d] = T({}), [n, k] = T(!1), I = i.language === "fa", j = I ? "text-right" : "text-left", S = J(async () => {
829
871
  try {
830
- const i = await E.getMe();
831
- D(i), V(i.name || ""), z(i.surname || ""), L(i.phone || "");
832
- const s = {};
833
- N.forEach((_) => {
834
- s[_.key] = i.metadata?.[_.key] ?? _.defaultValue ?? "";
835
- }), b(s);
836
- } catch (i) {
837
- console.error("Failed to fetch user:", i), X.error(ce(i, t));
872
+ const l = await D.getMe();
873
+ M(l), W(l.name || ""), E(l.surname || ""), R(l.phone || "");
874
+ const o = {};
875
+ F.forEach((_) => {
876
+ o[_.key] = l.metadata?.[_.key] ?? _.defaultValue ?? "";
877
+ }), d(o);
878
+ } catch (l) {
879
+ console.error("Failed to fetch user:", l), ee.error(ce(l, t));
838
880
  }
839
- }, [t, N]);
840
- F(() => {
881
+ }, [t, F]);
882
+ $(() => {
841
883
  if (!P) {
842
- U.current = null;
884
+ q.current = null;
843
885
  return;
844
886
  }
845
- (U.current === null || f === "account") && M(), U.current = f;
846
- }, [P, f, M]), F(() => {
847
- const i = { ...y };
848
- let s = !1;
849
- N.forEach((_) => {
850
- _.condition && !ge(_.condition, y) && i[_.key] !== void 0 && (delete i[_.key], s = !0);
851
- }), s && b(i);
852
- }, [y, N]);
853
- const G = async () => {
887
+ (q.current === null || p === "account") && S(), q.current = p;
888
+ }, [P, p, S]), $(() => {
889
+ const l = { ...b };
890
+ let o = !1;
891
+ F.forEach((_) => {
892
+ _.condition && !ge(_.condition, b) && l[_.key] !== void 0 && (delete l[_.key], o = !0);
893
+ }), o && d(l);
894
+ }, [b, F]);
895
+ const w = async () => {
854
896
  k(!0);
855
897
  try {
856
- const i = { name: B, surname: O, phone: K, metadata: y };
857
- H && (i.password = H);
858
- const s = await E.updateMe(i);
859
- d.setQueryData(
860
- lt(u?.cacheNamespace || "gentiq"),
861
- s
862
- ), X.success(t("profile.success", "Profile updated successfully")), $(""), M();
863
- } catch (i) {
864
- X.error(ce(i, t));
898
+ const l = { name: B, surname: K, phone: V, metadata: b };
899
+ L && (l.password = L);
900
+ const o = await D.updateMe(l);
901
+ u.setQueryData(
902
+ ct(m?.cacheNamespace || "gentiq"),
903
+ o
904
+ ), ee.success(t("profile.success", "Profile updated successfully")), H(""), S();
905
+ } catch (l) {
906
+ ee.error(ce(l, t));
865
907
  } finally {
866
908
  k(!1);
867
909
  }
868
- }, ee = () => {
869
- window.confirm(t("account.logout_confirm", "Are you sure you want to logout?")) && (E.clearToken(), window.location.reload());
870
- }, re = (i) => {
871
- o.changeLanguage(i);
872
- }, ie = n?.balance ? Math.max(0, Math.min(100, n.balance.tokens / (n.balance.token_limit || 1) * 100)) : 0, ne = n?.balance ? Math.max(0, Math.min(100, n.balance.requests / (n.balance.request_limit || 1) * 100)) : 0;
873
- return /* @__PURE__ */ r(He, { open: P, onOpenChange: j, children: [
874
- /* @__PURE__ */ e(it, { asChild: !0, children: a || /* @__PURE__ */ e(Y, { variant: "ghost", size: "icon", className: "rounded-full", children: /* @__PURE__ */ e(Ne, { className: "h-5 w-5" }) }) }),
910
+ }, z = () => {
911
+ window.confirm(t("account.logout_confirm", "Are you sure you want to logout?")) && (D.clearToken(), window.location.reload());
912
+ }, Y = (l) => {
913
+ i.changeLanguage(l);
914
+ }, Z = s?.balance ? Math.max(0, Math.min(100, s.balance.tokens / (s.balance.token_limit || 1) * 100)) : 0, se = s?.balance ? Math.max(0, Math.min(100, s.balance.requests / (s.balance.request_limit || 1) * 100)) : 0;
915
+ return /* @__PURE__ */ r(He, { open: P, onOpenChange: U, children: [
916
+ /* @__PURE__ */ e(lt, { asChild: !0, children: a || /* @__PURE__ */ e(te, { variant: "ghost", size: "icon", className: "rounded-full", children: /* @__PURE__ */ e(Ne, { className: "h-5 w-5" }) }) }),
875
917
  /* @__PURE__ */ e(
876
- Qe,
918
+ Ve,
877
919
  {
878
- dir: A ? "rtl" : "ltr",
920
+ dir: I ? "rtl" : "ltr",
879
921
  className: v(
880
922
  "w-full sm:w-[95vw] sm:max-w-[700px] p-0 gap-0 overflow-hidden rounded-t-2xl sm:rounded-3xl border-none shadow-2xl bg-background/95 backdrop-blur-md h-[90vh] sm:h-[750px]",
881
- A && "rtl"
923
+ I && "rtl"
882
924
  ),
883
925
  children: /* @__PURE__ */ r("div", { className: "flex flex-col h-full w-full min-h-0 overflow-hidden", children: [
884
926
  /* @__PURE__ */ r("div", { className: "w-full bg-muted/20 sm:bg-muted/30 border-b border-border/40 pt-12 sm:pt-6 flex flex-col shrink-0", children: [
@@ -886,90 +928,90 @@ function Sa({ trigger: a }) {
886
928
  /* @__PURE__ */ e("div", { className: "bg-primary/10 p-1.5 rounded-lg", children: /* @__PURE__ */ e(Ne, { className: "h-5 w-5 text-primary" }) }),
887
929
  /* @__PURE__ */ e("span", { className: "font-bold text-lg", children: t("title", "Settings") })
888
930
  ] }) }),
889
- /* @__PURE__ */ e("div", { className: "w-full overflow-x-auto no-scrollbar pt-2 px-2 sm:px-4", children: /* @__PURE__ */ e("nav", { className: "flex items-center gap-2 sm:gap-6 w-max", children: I.map((i) => /* @__PURE__ */ r(
931
+ /* @__PURE__ */ e("div", { className: "w-full overflow-x-auto no-scrollbar pt-2 px-2 sm:px-4", children: /* @__PURE__ */ e("nav", { className: "flex items-center gap-2 sm:gap-6 w-max", children: A.map((l) => /* @__PURE__ */ r(
890
932
  "button",
891
933
  {
892
- onClick: () => q(i.id),
934
+ onClick: () => Q(l.id),
893
935
  className: v(
894
936
  "flex items-center gap-1.5 sm:gap-2 pb-2 sm:pb-3 pt-1 px-2 sm:px-1 text-sm sm:text-base font-medium transition-all border-b-2 whitespace-nowrap shrink-0",
895
- f === i.id ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border",
896
- l?.sections?.[i.id]?.mode === "faded" && "opacity-50 pointer-events-none select-none"
937
+ p === l.id ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border",
938
+ c?.sections?.[l.id]?.mode === "faded" && "opacity-50 pointer-events-none select-none"
897
939
  ),
898
940
  children: [
899
- /* @__PURE__ */ e(i.icon, { className: v(
941
+ /* @__PURE__ */ e(l.icon, { className: v(
900
942
  "h-3.5 w-3.5 sm:h-4 sm:w-4 transition-transform",
901
- f === i.id && "scale-110"
943
+ p === l.id && "scale-110"
902
944
  ) }),
903
- i.label
945
+ l.label
904
946
  ]
905
947
  },
906
- i.id
948
+ l.id
907
949
  )) }) })
908
950
  ] }),
909
951
  /* @__PURE__ */ e("div", { className: "flex-1 relative min-h-0 h-full bg-background", children: /* @__PURE__ */ r("div", { className: "absolute inset-0 overflow-y-auto p-5 sm:p-8 pt-12 sm:pt-12 custom-scrollbar", children: [
910
- f === "profile" && /* @__PURE__ */ r("div", { className: "space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
952
+ p === "profile" && /* @__PURE__ */ r("div", { className: "space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
911
953
  /* @__PURE__ */ r("div", { children: [
912
954
  /* @__PURE__ */ e("h2", { className: "text-xl font-bold tracking-tight", children: t("profile.title", "Profile Information") }),
913
955
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("profile.subtitle", "Update your personal details below.") })
914
956
  ] }),
915
957
  /* @__PURE__ */ r("div", { className: "grid gap-6", children: [
916
958
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
917
- g("profile", "name") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", g("profile", "name") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
918
- /* @__PURE__ */ e(Q, { htmlFor: "name", className: "px-1", children: t("profile.name", "First Name") }),
959
+ x("profile", "name") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", x("profile", "name") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
960
+ /* @__PURE__ */ e(G, { htmlFor: "name", className: "px-1", children: t("profile.name", "First Name") }),
919
961
  /* @__PURE__ */ e(
920
- W,
962
+ X,
921
963
  {
922
964
  id: "name",
923
965
  value: B,
924
- onChange: (i) => V(i.target.value),
925
- disabled: g("profile", "name") === "faded",
926
- className: v("bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11", S)
966
+ onChange: (l) => W(l.target.value),
967
+ disabled: x("profile", "name") === "faded",
968
+ className: v("bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11", j)
927
969
  }
928
970
  )
929
971
  ] }),
930
- g("profile", "surname") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", g("profile", "surname") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
931
- /* @__PURE__ */ e(Q, { htmlFor: "surname", className: "px-1", children: t("profile.surname", "Last Name") }),
972
+ x("profile", "surname") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", x("profile", "surname") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
973
+ /* @__PURE__ */ e(G, { htmlFor: "surname", className: "px-1", children: t("profile.surname", "Last Name") }),
932
974
  /* @__PURE__ */ e(
933
- W,
975
+ X,
934
976
  {
935
977
  id: "surname",
936
- value: O,
937
- onChange: (i) => z(i.target.value),
938
- disabled: g("profile", "surname") === "faded",
939
- className: v("bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11", S)
978
+ value: K,
979
+ onChange: (l) => E(l.target.value),
980
+ disabled: x("profile", "surname") === "faded",
981
+ className: v("bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11", j)
940
982
  }
941
983
  )
942
984
  ] })
943
985
  ] }),
944
- g("profile", "phone") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", g("profile", "phone") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
945
- /* @__PURE__ */ e(Q, { htmlFor: "phone", className: "px-1 text-left", children: t("profile.phone", "Phone Number") }),
986
+ x("profile", "phone") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", x("profile", "phone") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
987
+ /* @__PURE__ */ e(G, { htmlFor: "phone", className: "px-1 text-left", children: t("profile.phone", "Phone Number") }),
946
988
  /* @__PURE__ */ r("div", { className: "relative", children: [
947
- /* @__PURE__ */ e(Tt, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground left-3" }),
989
+ /* @__PURE__ */ e(Mt, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground left-3" }),
948
990
  /* @__PURE__ */ e(
949
- W,
991
+ X,
950
992
  {
951
993
  id: "phone",
952
- value: K,
953
- onChange: (i) => L(i.target.value),
954
- disabled: g("profile", "phone") === "faded",
994
+ value: V,
995
+ onChange: (l) => R(l.target.value),
996
+ disabled: x("profile", "phone") === "faded",
955
997
  className: "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary pl-10 pr-3 text-left",
956
998
  dir: "ltr"
957
999
  }
958
1000
  )
959
1001
  ] })
960
1002
  ] }),
961
- g("profile", "password") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", g("profile", "password") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
962
- /* @__PURE__ */ e(Q, { htmlFor: "pass", className: "px-1 text-left", children: t("profile.password", "New Password") }),
1003
+ x("profile", "password") !== "hidden" && /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3", x("profile", "password") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
1004
+ /* @__PURE__ */ e(G, { htmlFor: "pass", className: "px-1 text-left", children: t("profile.password", "New Password") }),
963
1005
  /* @__PURE__ */ r("div", { className: "relative", children: [
964
- /* @__PURE__ */ e(Mt, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground left-3" }),
1006
+ /* @__PURE__ */ e(It, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground left-3" }),
965
1007
  /* @__PURE__ */ e(
966
- W,
1008
+ X,
967
1009
  {
968
1010
  id: "pass",
969
1011
  type: "password",
970
- value: H,
971
- onChange: (i) => $(i.target.value),
972
- disabled: g("profile", "password") === "faded",
1012
+ value: L,
1013
+ onChange: (l) => H(l.target.value),
1014
+ disabled: x("profile", "password") === "faded",
973
1015
  placeholder: t("profile.password_placeholder", "Leave empty to keep current"),
974
1016
  className: "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary pl-10 pr-3 text-left",
975
1017
  dir: "ltr"
@@ -977,71 +1019,71 @@ function Sa({ trigger: a }) {
977
1019
  )
978
1020
  ] })
979
1021
  ] }),
980
- N.map((i) => {
981
- const s = g("profile", i.key, i.mode || "editable");
982
- return s === "hidden" || !ge(i.condition, y) ? null : /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3 animate-in fade-in slide-in-from-top-1 duration-200", s === "faded" && "opacity-50 pointer-events-none select-none"), children: [
983
- /* @__PURE__ */ e(Q, { htmlFor: `profile-${i.key}`, className: "px-1", children: t(i.label) }),
984
- i.type === "select" ? /* @__PURE__ */ r(
985
- ve,
1022
+ F.map((l) => {
1023
+ const o = x("profile", l.key, l.mode || "editable");
1024
+ return o === "hidden" || !ge(l.condition, b) ? null : /* @__PURE__ */ r("div", { className: v("flex flex-col gap-3 animate-in fade-in slide-in-from-top-1 duration-200", o === "faded" && "opacity-50 pointer-events-none select-none"), children: [
1025
+ /* @__PURE__ */ e(G, { htmlFor: `profile-${l.key}`, className: "px-1", children: t(l.label) }),
1026
+ l.type === "select" ? /* @__PURE__ */ r(
1027
+ xe,
986
1028
  {
987
- value: String(y[i.key] || ""),
988
- onValueChange: (_) => b({ ...y, [i.key]: _ }),
989
- disabled: s === "faded",
990
- dir: A ? "rtl" : "ltr",
1029
+ value: String(b[l.key] || ""),
1030
+ onValueChange: (_) => d({ ...b, [l.key]: _ }),
1031
+ disabled: o === "faded",
1032
+ dir: I ? "rtl" : "ltr",
991
1033
  children: [
992
- /* @__PURE__ */ e(xe, { className: "bg-muted/30 border-border/50 rounded-xl focus:ring-primary h-11", children: /* @__PURE__ */ e(ye, { placeholder: t(i.placeholder || "profile.select_placeholder") }) }),
993
- /* @__PURE__ */ e(we, { className: "rounded-xl border-border/40 shadow-xl bg-background/95 backdrop-blur-md", children: i.options?.map((_) => /* @__PURE__ */ e(pe, { value: String(_.value), className: "rounded-lg focus:bg-primary/10", children: t(_.label) }, String(_.value))) })
1034
+ /* @__PURE__ */ e(ve, { className: "bg-muted/30 border-border/50 rounded-xl focus:ring-primary h-11", children: /* @__PURE__ */ e(ye, { placeholder: t(l.placeholder || "profile.select_placeholder") }) }),
1035
+ /* @__PURE__ */ e(we, { className: "rounded-xl border-border/40 shadow-xl bg-background/95 backdrop-blur-md", children: l.options?.map((_) => /* @__PURE__ */ e(pe, { value: String(_.value), className: "rounded-lg focus:bg-primary/10", children: t(_.label) }, String(_.value))) })
994
1036
  ]
995
1037
  }
996
- ) : i.type === "checkbox" ? /* @__PURE__ */ r("div", { className: "flex items-center gap-3 px-1 py-1", children: [
1038
+ ) : l.type === "checkbox" ? /* @__PURE__ */ r("div", { className: "flex items-center gap-3 px-1 py-1", children: [
997
1039
  /* @__PURE__ */ e(
998
1040
  "input",
999
1041
  {
1000
- id: `profile-${i.key}`,
1042
+ id: `profile-${l.key}`,
1001
1043
  type: "checkbox",
1002
- checked: !!y[i.key],
1003
- disabled: s === "faded",
1004
- onChange: (_) => b({ ...y, [i.key]: _.target.checked }),
1044
+ checked: !!b[l.key],
1045
+ disabled: o === "faded",
1046
+ onChange: (_) => d({ ...b, [l.key]: _.target.checked }),
1005
1047
  className: "h-5 w-5 rounded-md border-border/50 bg-muted/30 text-primary focus:ring-primary transition-all cursor-pointer"
1006
1048
  }
1007
1049
  ),
1008
- /* @__PURE__ */ e(Q, { htmlFor: `profile-${i.key}`, className: "text-sm font-medium text-muted-foreground cursor-pointer", children: t(i.placeholder || i.label) })
1050
+ /* @__PURE__ */ e(G, { htmlFor: `profile-${l.key}`, className: "text-sm font-medium text-muted-foreground cursor-pointer", children: t(l.placeholder || l.label) })
1009
1051
  ] }) : /* @__PURE__ */ e(
1010
- W,
1052
+ X,
1011
1053
  {
1012
- id: `profile-${i.key}`,
1013
- type: i.type,
1014
- value: y[i.key] || "",
1015
- disabled: s === "faded",
1016
- onChange: (_) => b({ ...y, [i.key]: _.target.value }),
1017
- placeholder: t(i.placeholder || ""),
1018
- className: v("bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11", S)
1054
+ id: `profile-${l.key}`,
1055
+ type: l.type,
1056
+ value: b[l.key] || "",
1057
+ disabled: o === "faded",
1058
+ onChange: (_) => d({ ...b, [l.key]: _.target.value }),
1059
+ placeholder: t(l.placeholder || ""),
1060
+ className: v("bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11", j)
1019
1061
  }
1020
1062
  )
1021
- ] }, i.key);
1063
+ ] }, l.key);
1022
1064
  }),
1023
1065
  /* @__PURE__ */ e("div", { className: "pt-4 flex justify-center", children: /* @__PURE__ */ r(
1024
- Y,
1066
+ te,
1025
1067
  {
1026
- onClick: G,
1027
- disabled: c,
1068
+ onClick: w,
1069
+ disabled: n,
1028
1070
  className: "w-full sm:w-auto px-8 rounded-xl gap-2 font-semibold shadow-lg shadow-primary/20 h-11 transition-all active:scale-[0.98]",
1029
1071
  children: [
1030
1072
  /* @__PURE__ */ e(Dt, { className: "h-4 w-4" }),
1031
- c ? t("profile.saving", "Saving...") : t("profile.save", "Save Changes")
1073
+ n ? t("profile.saving", "Saving...") : t("profile.save", "Save Changes")
1032
1074
  ]
1033
1075
  }
1034
1076
  ) })
1035
1077
  ] })
1036
1078
  ] }),
1037
- f === "general" && /* @__PURE__ */ r("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1079
+ p === "general" && /* @__PURE__ */ r("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1038
1080
  /* @__PURE__ */ r("div", { children: [
1039
1081
  /* @__PURE__ */ e("h2", { className: "text-xl font-bold tracking-tight", children: t("general.title", "General Settings") }),
1040
1082
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("general.subtitle", "Configure look and feel and language.") })
1041
1083
  ] }),
1042
1084
  /* @__PURE__ */ r("div", { className: "space-y-8", children: [
1043
- g("general", "theme") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-3", g("general", "theme") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
1044
- /* @__PURE__ */ r(Q, { className: "text-sm font-semibold flex items-center gap-2", children: [
1085
+ x("general", "theme") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-3", x("general", "theme") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
1086
+ /* @__PURE__ */ r(G, { className: "text-sm font-semibold flex items-center gap-2", children: [
1045
1087
  /* @__PURE__ */ e(Me, { className: "h-4 w-4 text-primary" }),
1046
1088
  t("general.theme", "Theme")
1047
1089
  ] }),
@@ -1049,14 +1091,14 @@ function Sa({ trigger: a }) {
1049
1091
  /* @__PURE__ */ r(
1050
1092
  "button",
1051
1093
  {
1052
- onClick: () => p("light"),
1053
- disabled: g("general", "theme") === "faded",
1094
+ onClick: () => f("light"),
1095
+ disabled: x("general", "theme") === "faded",
1054
1096
  className: v(
1055
1097
  "flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
1056
- h === "light" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1098
+ g === "light" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1057
1099
  ),
1058
1100
  children: [
1059
- /* @__PURE__ */ e(It, { className: "h-4 w-4" }),
1101
+ /* @__PURE__ */ e(At, { className: "h-4 w-4" }),
1060
1102
  /* @__PURE__ */ e("span", { className: "text-sm font-medium", children: t("general.themes.light", "Light") })
1061
1103
  ]
1062
1104
  }
@@ -1064,11 +1106,11 @@ function Sa({ trigger: a }) {
1064
1106
  /* @__PURE__ */ r(
1065
1107
  "button",
1066
1108
  {
1067
- onClick: () => p("dark"),
1068
- disabled: g("general", "theme") === "faded",
1109
+ onClick: () => f("dark"),
1110
+ disabled: x("general", "theme") === "faded",
1069
1111
  className: v(
1070
1112
  "flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
1071
- h === "dark" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1113
+ g === "dark" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1072
1114
  ),
1073
1115
  children: [
1074
1116
  /* @__PURE__ */ e(Et, { className: "h-4 w-4" }),
@@ -1079,23 +1121,23 @@ function Sa({ trigger: a }) {
1079
1121
  /* @__PURE__ */ r(
1080
1122
  "button",
1081
1123
  {
1082
- onClick: () => p("system"),
1083
- disabled: g("general", "theme") === "faded",
1124
+ onClick: () => f("system"),
1125
+ disabled: x("general", "theme") === "faded",
1084
1126
  className: v(
1085
1127
  "flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
1086
- h === "system" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1128
+ g === "system" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1087
1129
  ),
1088
1130
  children: [
1089
- /* @__PURE__ */ e(At, { className: "h-4 w-4" }),
1131
+ /* @__PURE__ */ e(Lt, { className: "h-4 w-4" }),
1090
1132
  /* @__PURE__ */ e("span", { className: "text-sm font-medium", children: t("general.themes.system", "System") })
1091
1133
  ]
1092
1134
  }
1093
1135
  )
1094
1136
  ] })
1095
1137
  ] }),
1096
- g("general", "accent") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-4", g("general", "accent") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
1097
- /* @__PURE__ */ r(Q, { className: "text-sm font-semibold flex items-center gap-2", children: [
1098
- /* @__PURE__ */ e(De, { className: "h-4 w-4 text-primary" }),
1138
+ x("general", "accent") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-4", x("general", "accent") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
1139
+ /* @__PURE__ */ r(G, { className: "text-sm font-semibold flex items-center gap-2", children: [
1140
+ /* @__PURE__ */ e(Ie, { className: "h-4 w-4 text-primary" }),
1099
1141
  t("general.accent", "Accent Color")
1100
1142
  ] }),
1101
1143
  /* @__PURE__ */ e("div", { className: "grid grid-cols-4 sm:grid-cols-8 gap-3 w-full", children: [
@@ -1115,62 +1157,62 @@ function Sa({ trigger: a }) {
1115
1157
  // Teal
1116
1158
  "oklch(0.552 0.016 285.938)"
1117
1159
  // Slate
1118
- ].map((i) => {
1119
- const s = (m || "oklch(0.623 0.214 259.815)") === i;
1160
+ ].map((l) => {
1161
+ const o = (h || "oklch(0.623 0.214 259.815)") === l;
1120
1162
  return /* @__PURE__ */ e(
1121
1163
  "button",
1122
1164
  {
1123
- onClick: () => w(i),
1124
- disabled: g("general", "accent") === "faded",
1165
+ onClick: () => N(l),
1166
+ disabled: x("general", "accent") === "faded",
1125
1167
  className: v(
1126
1168
  "h-8 w-8 rounded-full border-2 transition-all hover:scale-110 active:scale-95 shadow-sm",
1127
- s ? "border-foreground" : "border-transparent"
1169
+ o ? "border-foreground" : "border-transparent"
1128
1170
  ),
1129
- style: { backgroundColor: i }
1171
+ style: { backgroundColor: l }
1130
1172
  },
1131
- i
1173
+ l
1132
1174
  );
1133
1175
  }) })
1134
1176
  ] }),
1135
- g("general", "radius") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-4", g("general", "radius") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
1136
- /* @__PURE__ */ r(Q, { className: "text-sm font-semibold flex items-center gap-2", children: [
1177
+ x("general", "radius") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-4", x("general", "radius") === "faded" && "opacity-50 pointer-events-none select-none"), children: [
1178
+ /* @__PURE__ */ r(G, { className: "text-sm font-semibold flex items-center gap-2", children: [
1137
1179
  /* @__PURE__ */ e("div", { className: "h-4 w-4 rounded-md border-2 border-primary" }),
1138
1180
  t("general.radius", "Rounded Corners")
1139
1181
  ] }),
1140
1182
  /* @__PURE__ */ e("div", { className: "flex p-1 bg-muted/50 rounded-2xl border border-border/40 w-full", children: [
1141
1183
  { id: "sharp", value: "0.3rem" },
1142
1184
  { id: "round", value: "1.25rem" }
1143
- ].map((i) => {
1144
- const s = (x || "1.25rem") === i.value;
1185
+ ].map((l) => {
1186
+ const o = (y || "1.25rem") === l.value;
1145
1187
  return /* @__PURE__ */ e(
1146
1188
  "button",
1147
1189
  {
1148
- onClick: () => C(i.value),
1149
- disabled: g("general", "radius") === "faded",
1190
+ onClick: () => C(l.value),
1191
+ disabled: x("general", "radius") === "faded",
1150
1192
  className: v(
1151
1193
  "flex-1 py-2 rounded-xl transition-all text-sm font-medium",
1152
- s ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1194
+ o ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1153
1195
  ),
1154
- children: t(`general.radius_levels.${i.id}`)
1196
+ children: t(`general.radius_levels.${l.id}`)
1155
1197
  },
1156
- i.id
1198
+ l.id
1157
1199
  );
1158
1200
  }) })
1159
1201
  ] }),
1160
- g("general", "language") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-3", g("general", "language") === "faded" && "opacity-50"), children: [
1161
- /* @__PURE__ */ r(Q, { className: "text-sm font-semibold flex items-center gap-2", children: [
1162
- /* @__PURE__ */ e(Lt, { className: "h-4 w-4 text-primary" }),
1202
+ x("general", "language") !== "hidden" && /* @__PURE__ */ r("div", { className: v("space-y-3", x("general", "language") === "faded" && "opacity-50"), children: [
1203
+ /* @__PURE__ */ r(G, { className: "text-sm font-semibold flex items-center gap-2", children: [
1204
+ /* @__PURE__ */ e(Rt, { className: "h-4 w-4 text-primary" }),
1163
1205
  t("general.language", "Language")
1164
1206
  ] }),
1165
1207
  /* @__PURE__ */ r(
1166
- ve,
1208
+ xe,
1167
1209
  {
1168
- value: o.language,
1169
- onValueChange: re,
1170
- disabled: g("general", "language") === "faded",
1171
- dir: A ? "rtl" : "ltr",
1210
+ value: i.language,
1211
+ onValueChange: Y,
1212
+ disabled: x("general", "language") === "faded",
1213
+ dir: I ? "rtl" : "ltr",
1172
1214
  children: [
1173
- /* @__PURE__ */ e(xe, { className: "w-full bg-muted/50 rounded-2xl border-border/40 h-11 focus:ring-primary/20", children: /* @__PURE__ */ e(ye, { placeholder: t("general.language_placeholder", "Select language") }) }),
1215
+ /* @__PURE__ */ e(ve, { className: "w-full bg-muted/50 rounded-2xl border-border/40 h-11 focus:ring-primary/20", children: /* @__PURE__ */ e(ye, { placeholder: t("general.language_placeholder", "Select language") }) }),
1174
1216
  /* @__PURE__ */ r(we, { className: "rounded-2xl border-border/40 shadow-xl bg-background/95 backdrop-blur-md", children: [
1175
1217
  /* @__PURE__ */ e(pe, { value: "en", className: "rounded-xl focus:bg-primary/10", children: /* @__PURE__ */ r("span", { className: "flex items-center gap-2", children: [
1176
1218
  /* @__PURE__ */ e("span", { className: "text-xs font-bold text-muted-foreground mr-1", children: "EN" }),
@@ -1187,14 +1229,14 @@ function Sa({ trigger: a }) {
1187
1229
  ] })
1188
1230
  ] })
1189
1231
  ] }),
1190
- f === "account" && /* @__PURE__ */ r("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1232
+ p === "account" && /* @__PURE__ */ r("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1191
1233
  /* @__PURE__ */ r("div", { children: [
1192
1234
  /* @__PURE__ */ e("h2", { className: "text-xl font-bold tracking-tight", children: t("account.title", "Account & Usage") }),
1193
1235
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("account.subtitle", "Monitor your quotas and manage your session.") })
1194
1236
  ] }),
1195
1237
  /* @__PURE__ */ r("div", { className: "space-y-6", children: [
1196
- g("account", "balance") !== "hidden" && /* @__PURE__ */ r("div", { className: v("p-6 bg-muted/30 rounded-3xl border border-border/40 space-y-6", g("account", "balance") === "faded" && "opacity-50"), children: [
1197
- /* @__PURE__ */ r(Q, { className: "text-xs font-bold uppercase tracking-wider text-primary flex items-center gap-2", children: [
1238
+ x("account", "balance") !== "hidden" && /* @__PURE__ */ r("div", { className: v("p-6 bg-muted/30 rounded-3xl border border-border/40 space-y-6", x("account", "balance") === "faded" && "opacity-50"), children: [
1239
+ /* @__PURE__ */ r(G, { className: "text-xs font-bold uppercase tracking-wider text-primary flex items-center gap-2", children: [
1198
1240
  /* @__PURE__ */ e(zt, { className: "h-4 w-4" }),
1199
1241
  t("account.balance", "Current Balance")
1200
1242
  ] }),
@@ -1203,7 +1245,7 @@ function Sa({ trigger: a }) {
1203
1245
  /* @__PURE__ */ r("div", { className: "flex justify-between text-sm mb-1", children: [
1204
1246
  /* @__PURE__ */ e("span", { className: "font-medium text-muted-foreground", children: t("account.tokens", "Tokens") }),
1205
1247
  /* @__PURE__ */ r("span", { className: "font-bold text-primary", children: [
1206
- ie.toLocaleString(o.language, { maximumFractionDigits: 0 }),
1248
+ Z.toLocaleString(i.language, { maximumFractionDigits: 0 }),
1207
1249
  "%"
1208
1250
  ] })
1209
1251
  ] }),
@@ -1212,20 +1254,20 @@ function Sa({ trigger: a }) {
1212
1254
  {
1213
1255
  className: v(
1214
1256
  "h-full rounded-full transition-all duration-1000 shadow-sm",
1215
- ie > 60 ? "bg-emerald-500 shadow-emerald-500/20" : ie > 20 ? "bg-amber-500 shadow-amber-500/20" : "bg-destructive shadow-destructive/20"
1257
+ Z > 60 ? "bg-emerald-500 shadow-emerald-500/20" : Z > 20 ? "bg-amber-500 shadow-amber-500/20" : "bg-destructive shadow-destructive/20"
1216
1258
  ),
1217
- style: { width: `${ie}%` }
1259
+ style: { width: `${Z}%` }
1218
1260
  }
1219
1261
  ) })
1220
1262
  ] }),
1221
1263
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
1222
1264
  /* @__PURE__ */ r("div", { className: "flex justify-between text-sm mb-1", children: [
1223
1265
  /* @__PURE__ */ r("span", { className: "font-medium text-muted-foreground flex items-center gap-1.5 focus:outline-none", children: [
1224
- /* @__PURE__ */ e(De, { className: "h-3.5 w-3.5 text-blue-500" }),
1266
+ /* @__PURE__ */ e(Ie, { className: "h-3.5 w-3.5 text-blue-500" }),
1225
1267
  t("account.requests", "Requests")
1226
1268
  ] }),
1227
1269
  /* @__PURE__ */ r("span", { className: "font-bold text-primary", children: [
1228
- ne.toLocaleString(o.language, { maximumFractionDigits: 0 }),
1270
+ se.toLocaleString(i.language, { maximumFractionDigits: 0 }),
1229
1271
  "%"
1230
1272
  ] })
1231
1273
  ] }),
@@ -1234,27 +1276,27 @@ function Sa({ trigger: a }) {
1234
1276
  {
1235
1277
  className: v(
1236
1278
  "h-full rounded-full transition-all duration-1000 shadow-sm",
1237
- ne > 60 ? "bg-emerald-500 shadow-emerald-500/20" : ne > 20 ? "bg-amber-500 shadow-amber-500/20" : "bg-destructive shadow-destructive/20"
1279
+ se > 60 ? "bg-emerald-500 shadow-emerald-500/20" : se > 20 ? "bg-amber-500 shadow-amber-500/20" : "bg-destructive shadow-destructive/20"
1238
1280
  ),
1239
- style: { width: `${ne}%` }
1281
+ style: { width: `${se}%` }
1240
1282
  }
1241
1283
  ) })
1242
1284
  ] })
1243
1285
  ] })
1244
1286
  ] }),
1245
1287
  /* @__PURE__ */ r("div", { className: "pt-2 flex flex-col gap-3", children: [
1246
- n?.balance?.updated_at && g("account", "balance") !== "hidden" && /* @__PURE__ */ r("p", { className: "text-xs text-muted-foreground px-1", children: [
1288
+ s?.balance?.updated_at && x("account", "balance") !== "hidden" && /* @__PURE__ */ r("p", { className: "text-xs text-muted-foreground px-1", children: [
1247
1289
  t("account.last_recharge", "Last balance update on"),
1248
1290
  ": ",
1249
- new Date(n.balance?.updated_at || "").toLocaleDateString(o.language)
1291
+ new Date(s.balance?.updated_at || "").toLocaleDateString(i.language)
1250
1292
  ] }),
1251
- g("account", "logout") !== "hidden" && /* @__PURE__ */ r(
1252
- Y,
1293
+ x("account", "logout") !== "hidden" && /* @__PURE__ */ r(
1294
+ te,
1253
1295
  {
1254
1296
  variant: "destructive",
1255
- onClick: ee,
1256
- disabled: g("account", "logout") === "faded",
1257
- className: v("rounded-2xl gap-2 font-bold h-12 shadow-lg shadow-destructive/10 transition-all active:scale-[0.98]", g("account", "logout") === "faded" && "opacity-50 pointer-events-none"),
1297
+ onClick: z,
1298
+ disabled: x("account", "logout") === "faded",
1299
+ className: v("rounded-2xl gap-2 font-bold h-12 shadow-lg shadow-destructive/10 transition-all active:scale-[0.98]", x("account", "logout") === "faded" && "opacity-50 pointer-events-none"),
1258
1300
  children: [
1259
1301
  /* @__PURE__ */ e(qt, { className: "h-4 w-4" }),
1260
1302
  t("account.logout", "Logout from Account")
@@ -1265,55 +1307,55 @@ function Sa({ trigger: a }) {
1265
1307
  ] })
1266
1308
  ] })
1267
1309
  ] }) }),
1268
- u?.showVersionInSettings !== !1 && u?.version && g("general", "version") !== "hidden" && /* @__PURE__ */ e("div", { className: v("shrink-0 border-t border-border/30 px-5 sm:px-8 py-3 flex justify-center bg-background/80", g("general", "version", "faded") === "faded" && "opacity-70"), children: /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground text-center", dir: "ltr", children: /* @__PURE__ */ r("span", { className: "font-mono text-foreground/75", children: [
1310
+ m?.showVersionInSettings !== !1 && m?.version && x("general", "version") !== "hidden" && /* @__PURE__ */ e("div", { className: v("shrink-0 border-t border-border/30 px-5 sm:px-8 py-3 flex justify-center bg-background/80", x("general", "version", "faded") === "faded" && "opacity-70"), children: /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground text-center", dir: "ltr", children: /* @__PURE__ */ r("span", { className: "font-mono text-foreground/75", children: [
1269
1311
  "v",
1270
- u.version
1312
+ m.version
1271
1313
  ] }) }) })
1272
1314
  ] })
1273
1315
  }
1274
1316
  )
1275
1317
  ] });
1276
1318
  }
1277
- function We({ hideActions: a = !1 }) {
1278
- const [, t] = Ce(), { t: o } = de(["sidebar", "chat"]), { history: u, app: l } = te(), { theme: d } = Ke(), h = !a && (u?.enabled ?? !0), [p, m] = T("light");
1279
- F(() => {
1280
- if (d === "system") {
1319
+ function Xe({ hideActions: a = !1 }) {
1320
+ const [, t] = Ce(), { t: i } = de(["sidebar", "chat"]), { history: m, app: c } = re(), { theme: u } = Qe(), g = !a && (m?.enabled ?? !0), [f, h] = T("light");
1321
+ $(() => {
1322
+ if (u === "system") {
1281
1323
  const C = window.matchMedia("(prefers-color-scheme: dark)").matches;
1282
- m(C ? "dark" : "light");
1324
+ h(C ? "dark" : "light");
1283
1325
  } else
1284
- m(d);
1285
- }, [d]);
1286
- const w = R(() => l?.logo ? typeof l.logo == "string" ? l.logo : p === "dark" ? l.logo.dark : l.logo.light : ct, [l?.logo, p]), x = l?.name || "Gentiq";
1326
+ h(u);
1327
+ }, [u]);
1328
+ const N = O(() => c?.logo ? typeof c.logo == "string" ? c.logo : f === "dark" ? c.logo.dark : c.logo.light : dt, [c?.logo, f]), y = c?.name || "Gentiq";
1287
1329
  return /* @__PURE__ */ r("header", { className: "relative flex items-center justify-between px-3 md:px-4 h-14 sticky top-0 z-40 w-full glass border-b border-border/30 transition-all duration-300", children: [
1288
- /* @__PURE__ */ e("div", { className: "flex items-center gap-1.5 md:gap-2 min-w-[36px] md:min-w-[80px]", children: h && /* @__PURE__ */ e(wa, { className: "hover:bg-accent/60 transition-all duration-200 hover:scale-105 active:scale-95 rounded-lg size-9" }) }),
1330
+ /* @__PURE__ */ e("div", { className: "flex items-center gap-1.5 md:gap-2 min-w-[36px] md:min-w-[80px]", children: g && /* @__PURE__ */ e(Na, { className: "hover:bg-accent/60 transition-all duration-200 hover:scale-105 active:scale-95 rounded-lg size-9" }) }),
1289
1331
  /* @__PURE__ */ e("div", { className: "absolute left-1/2 top-1/2 -translate-x-1/2 -translate-y-1/2", children: /* @__PURE__ */ e("div", { className: "flex items-center gap-2.5 select-none animate-in fade-in zoom-in-95 duration-500", children: /* @__PURE__ */ e(
1290
1332
  "img",
1291
1333
  {
1292
- src: w,
1293
- alt: x,
1334
+ src: N,
1335
+ alt: y,
1294
1336
  className: "size-8 object-contain"
1295
1337
  }
1296
1338
  ) }) }),
1297
1339
  /* @__PURE__ */ e("div", { className: "flex items-center gap-1.5 min-w-[36px] md:min-w-[80px] justify-end", children: !a && /* @__PURE__ */ r(ke, { children: [
1298
- /* @__PURE__ */ r($e, { children: [
1299
- /* @__PURE__ */ e(Ue, { asChild: !0, children: /* @__PURE__ */ e(
1340
+ /* @__PURE__ */ r(Ue, { children: [
1341
+ /* @__PURE__ */ e(Be, { asChild: !0, children: /* @__PURE__ */ e(
1300
1342
  "button",
1301
1343
  {
1302
1344
  type: "button",
1303
1345
  className: v(
1304
1346
  "flex items-center justify-center size-9 rounded-lg hover:bg-accent/60 transition-all duration-200 hover:scale-105 active:scale-95 text-muted-foreground hover:text-primary",
1305
- h && "md:hidden"
1347
+ g && "md:hidden"
1306
1348
  ),
1307
1349
  onClick: () => {
1308
1350
  t("/");
1309
1351
  },
1310
- children: /* @__PURE__ */ e(Rt, { className: "size-5" })
1352
+ children: /* @__PURE__ */ e(Ft, { className: "size-5" })
1311
1353
  }
1312
1354
  ) }),
1313
- /* @__PURE__ */ e(Be, { side: "bottom", className: "text-xs", children: o("new_chat") })
1355
+ /* @__PURE__ */ e(Ke, { side: "bottom", className: "text-xs", children: i("new_chat") })
1314
1356
  ] }),
1315
- l?.showSettings !== !1 && /* @__PURE__ */ e(
1316
- Sa,
1357
+ c?.showSettings !== !1 && /* @__PURE__ */ e(
1358
+ Pa,
1317
1359
  {
1318
1360
  trigger: /* @__PURE__ */ e(
1319
1361
  "button",
@@ -1328,104 +1370,104 @@ function We({ hideActions: a = !1 }) {
1328
1370
  ] }) })
1329
1371
  ] });
1330
1372
  }
1331
- const qe = 20;
1332
- function Pa() {
1333
- const t = E.getConfig().app?.cacheNamespace || "gentiq";
1334
- return tt({
1373
+ const ze = 20;
1374
+ function Ta() {
1375
+ const t = D.getConfig().app?.cacheNamespace || "gentiq";
1376
+ return at({
1335
1377
  queryKey: [t, "conversations"],
1336
- queryFn: async ({ pageParam: o = 0 }) => {
1337
- const u = await E.getHistory(o, qe);
1378
+ queryFn: async ({ pageParam: i = 0 }) => {
1379
+ const m = await D.getHistory(i, ze);
1338
1380
  return {
1339
- threads: u.threads.map((l) => ({
1340
- id: `/${l.id}`,
1341
- firstMessage: l.title || l.firstMessage || "Chat",
1342
- timestamp: new Date(l.created_at).getTime(),
1343
- pinned: !!l.pinned
1381
+ threads: m.threads.map((c) => ({
1382
+ id: `/${c.id}`,
1383
+ firstMessage: c.title || c.firstMessage || "Chat",
1384
+ timestamp: new Date(c.created_at).getTime(),
1385
+ pinned: !!c.pinned
1344
1386
  })),
1345
- nextSkip: o + qe,
1346
- hasMore: o + u.threads.length < (u.total_count ?? 0)
1387
+ nextSkip: i + ze,
1388
+ hasMore: i + m.threads.length < (m.total_count ?? 0)
1347
1389
  };
1348
1390
  },
1349
1391
  initialPageParam: 0,
1350
- getNextPageParam: (o) => o.hasMore ? o.nextSkip : void 0,
1392
+ getNextPageParam: (i) => i.hasMore ? i.nextSkip : void 0,
1351
1393
  staleTime: 1e3 * 60 * 5
1352
1394
  // 5 minutes
1353
1395
  });
1354
1396
  }
1355
- async function Ta(a, t, o, u) {
1356
- const d = E.getConfig().app?.cacheNamespace || "gentiq";
1397
+ async function Ma(a, t, i, m) {
1398
+ const u = D.getConfig().app?.cacheNamespace || "gentiq";
1357
1399
  try {
1358
- await E.deleteThread(a), t.invalidateQueries({ queryKey: [d, "conversations"] }), u === a && o("/");
1359
- } catch (h) {
1360
- console.error("Failed to delete conversation:", h), X.error("Failed to delete conversation");
1400
+ await D.deleteThread(a), t.invalidateQueries({ queryKey: [u, "conversations"] }), m === a && i("/");
1401
+ } catch (g) {
1402
+ console.error("Failed to delete conversation:", g), ee.error("Failed to delete conversation");
1361
1403
  }
1362
1404
  }
1363
- function Ma({ side: a = "left" }) {
1364
- const { t, i18n: o } = de(["sidebar", "translation"]), { setOpenMobile: u, isMobile: l } = fe(), {
1365
- data: d,
1366
- fetchNextPage: h,
1367
- hasNextPage: p,
1368
- isFetchingNextPage: m,
1369
- isLoading: w
1370
- } = Pa(), { history: x, app: C } = te(), n = C?.basePath || "/", D = x?.enabled ?? !1, P = d?.pages.flatMap((s) => s.threads) ?? [], [j, U] = Ce(), I = ue(), f = Z(null), q = J(
1371
- (s) => {
1372
- f.current && (f.current.disconnect(), f.current = null), s && p && !m && (f.current = new IntersectionObserver(
1405
+ function Ia({ side: a = "left" }) {
1406
+ const { t, i18n: i } = de(["sidebar", "translation"]), { setOpenMobile: m, isMobile: c } = fe(), {
1407
+ data: u,
1408
+ fetchNextPage: g,
1409
+ hasNextPage: f,
1410
+ isFetchingNextPage: h,
1411
+ isLoading: N
1412
+ } = Ta(), { history: y, app: C } = re(), s = C?.basePath || "/", M = y?.enabled ?? !1, P = u?.pages.flatMap((o) => o.threads) ?? [], [U, q] = Ce(), A = ue(), p = ae(null), Q = J(
1413
+ (o) => {
1414
+ p.current && (p.current.disconnect(), p.current = null), o && f && !h && (p.current = new IntersectionObserver(
1373
1415
  (_) => {
1374
- _[0].isIntersecting && h();
1416
+ _[0].isIntersecting && g();
1375
1417
  },
1376
1418
  {
1377
1419
  threshold: 0,
1378
1420
  rootMargin: "100px"
1379
1421
  }
1380
- ), f.current.observe(s));
1422
+ ), p.current.observe(o));
1381
1423
  },
1382
- [p, h, m]
1383
- ), B = E.getConfig().app?.cacheNamespace || "gentiq", [V, O] = T(!1), [z, K] = T(null), [L, H] = T(""), [$, N] = T(null), [y, b] = T(""), c = Z(null), k = J((s, _) => {
1384
- s.button !== 0 || s.metaKey || s.ctrlKey || (s.preventDefault(), U(_), l && u(!1));
1385
- }, [U, l, u]), A = P.filter(
1386
- (s) => s.firstMessage?.toLowerCase().includes(L.toLowerCase())
1387
- ).sort((s, _) => s.pinned && !_.pinned ? -1 : !s.pinned && _.pinned ? 1 : _.timestamp - s.timestamp), S = async (s) => {
1424
+ [f, g, h]
1425
+ ), B = D.getConfig().app?.cacheNamespace || "gentiq", [W, K] = T(!1), [E, V] = T(null), [R, L] = T(""), [H, F] = T(null), [b, d] = T(""), n = ae(null), k = J((o, _) => {
1426
+ o.button !== 0 || o.metaKey || o.ctrlKey || (o.preventDefault(), q(_), c && m(!1));
1427
+ }, [q, c, m]), I = P.filter(
1428
+ (o) => o.firstMessage?.toLowerCase().includes(R.toLowerCase())
1429
+ ).sort((o, _) => o.pinned && !_.pinned ? -1 : !o.pinned && _.pinned ? 1 : _.timestamp - o.timestamp), j = async (o) => {
1388
1430
  try {
1389
- await E.pinThread(s.id.replace(/^\//, ""), !s.pinned), I.invalidateQueries({ queryKey: [B, "conversations"] }), X.success(s.pinned ? t("unpinned_success") : t("pinned_success"));
1431
+ await D.pinThread(o.id.replace(/^\//, ""), !o.pinned), A.invalidateQueries({ queryKey: [B, "conversations"] }), ee.success(o.pinned ? t("unpinned_success") : t("pinned_success"));
1390
1432
  } catch {
1391
- X.error(t("pin_failed"));
1433
+ ee.error(t("pin_failed"));
1392
1434
  }
1393
- }, M = async (s) => {
1435
+ }, S = async (o) => {
1394
1436
  try {
1395
- const _ = await E.shareThread(s.id.replace(/^\//, "")), se = `${window.location.origin}${_.url}`;
1396
- navigator.clipboard.writeText(se), X.success(t("share_success"), {
1437
+ const _ = await D.shareThread(o.id.replace(/^\//, "")), oe = `${window.location.origin}${_.url}`;
1438
+ navigator.clipboard.writeText(oe), ee.success(t("share_success"), {
1397
1439
  description: t("share_description")
1398
1440
  });
1399
1441
  } catch {
1400
- X.error(t("share_failed"));
1442
+ ee.error(t("share_failed"));
1401
1443
  }
1402
- }, G = (s) => {
1403
- N(s.id), b(s.firstMessage ?? ""), setTimeout(() => c.current?.focus(), 0);
1404
- }, ee = (s) => {
1405
- s?.preventDefault(), s?.stopPropagation(), N(null), b("");
1406
- }, re = async (s) => {
1407
- if (s?.preventDefault(), s && "stopPropagation" in s && s.stopPropagation(), !(!$ || !y.trim()))
1444
+ }, w = (o) => {
1445
+ F(o.id), d(o.firstMessage ?? ""), setTimeout(() => n.current?.focus(), 0);
1446
+ }, z = (o) => {
1447
+ o?.preventDefault(), o?.stopPropagation(), F(null), d("");
1448
+ }, Y = async (o) => {
1449
+ if (o?.preventDefault(), o && "stopPropagation" in o && o.stopPropagation(), !(!H || !b.trim()))
1408
1450
  try {
1409
- await E.updateThreadTitle($, y), I.invalidateQueries({ queryKey: [B, "conversations"] }), N(null), X.success(t("rename_success"));
1451
+ await D.updateThreadTitle(H, b), A.invalidateQueries({ queryKey: [B, "conversations"] }), F(null), ee.success(t("rename_success"));
1410
1452
  } catch {
1411
- X.error(t("rename_failed"));
1453
+ ee.error(t("rename_failed"));
1412
1454
  }
1413
- }, ie = (s) => {
1414
- K(s), O(!0);
1415
- }, ne = () => {
1416
- z && (Ta(z.id, I, U, j), O(!1), K(null), X.success(t("chat_deleted_success")));
1417
- }, i = (s) => new Intl.DateTimeFormat(o.language, {
1455
+ }, Z = (o) => {
1456
+ V(o), K(!0);
1457
+ }, se = () => {
1458
+ E && (Ma(E.id, A, q, U), K(!1), V(null), ee.success(t("chat_deleted_success")));
1459
+ }, l = (o) => new Intl.DateTimeFormat(i.language, {
1418
1460
  year: "numeric",
1419
1461
  month: "short",
1420
1462
  day: "numeric",
1421
1463
  hour: "2-digit",
1422
1464
  minute: "2-digit",
1423
- calendar: o.language === "fa" ? "persian" : "gregory"
1424
- }).format(new Date(s));
1425
- return /* @__PURE__ */ e(Oe, { children: /* @__PURE__ */ r(ya, { collapsible: "icon", side: a, children: [
1426
- /* @__PURE__ */ e(ka, { className: "custom-scrollbar", children: /* @__PURE__ */ r(_a, { children: [
1427
- /* @__PURE__ */ e(Ae, { className: "mt-2 mb-6 px-2 group-data-[collapsible=icon]:px-0", children: /* @__PURE__ */ e(Le, { className: "group-data-[collapsible=icon]:flex group-data-[collapsible=icon]:justify-center", children: /* @__PURE__ */ e(
1428
- ze,
1465
+ calendar: i.language === "fa" ? "persian" : "gregory"
1466
+ }).format(new Date(o));
1467
+ return /* @__PURE__ */ e($e, { children: /* @__PURE__ */ r(wa, { collapsible: "icon", side: a, children: [
1468
+ /* @__PURE__ */ e(_a, { className: "custom-scrollbar", children: /* @__PURE__ */ r(Ca, { children: [
1469
+ /* @__PURE__ */ e(Ee, { className: "mt-2 mb-6 px-2 group-data-[collapsible=icon]:px-0", children: /* @__PURE__ */ e(Le, { className: "group-data-[collapsible=icon]:flex group-data-[collapsible=icon]:justify-center", children: /* @__PURE__ */ e(
1470
+ Re,
1429
1471
  {
1430
1472
  asChild: !0,
1431
1473
  tooltip: t("tooltip_new_conversation"),
@@ -1433,69 +1475,69 @@ function Ma({ side: a = "left" }) {
1433
1475
  children: /* @__PURE__ */ r(
1434
1476
  "a",
1435
1477
  {
1436
- href: be(n, "/"),
1437
- onClick: (s) => k(s, "/"),
1478
+ href: be(s, "/"),
1479
+ onClick: (o) => k(o, "/"),
1438
1480
  className: "px-5 group-data-[collapsible=icon]:px-0 group-data-[collapsible=icon]:justify-center flex items-center gap-3 active:scale-[0.96] w-full h-full relative",
1439
1481
  children: [
1440
1482
  /* @__PURE__ */ e("div", { className: "absolute inset-0 bg-linear-to-tr from-primary/10 via-transparent to-primary/5 opacity-0 group-hover/new-chat:opacity-100 transition-opacity duration-700" }),
1441
- /* @__PURE__ */ e("div", { className: "relative size-8 rounded-xl bg-linear-to-br from-primary/20 to-primary/5 flex items-center justify-center shrink-0 group-hover/new-chat:from-primary/30 group-hover/new-chat:to-primary/10 transition-all duration-500 shadow-inner", children: /* @__PURE__ */ e(Ft, { className: "size-5! text-primary transition-all duration-700 group-hover/new-chat:rotate-180 group-hover/new-chat:scale-110" }) }),
1483
+ /* @__PURE__ */ e("div", { className: "relative size-8 rounded-xl bg-linear-to-br from-primary/20 to-primary/5 flex items-center justify-center shrink-0 group-hover/new-chat:from-primary/30 group-hover/new-chat:to-primary/10 transition-all duration-500 shadow-inner", children: /* @__PURE__ */ e(jt, { className: "size-5! text-primary transition-all duration-700 group-hover/new-chat:rotate-180 group-hover/new-chat:scale-110" }) }),
1442
1484
  /* @__PURE__ */ e("span", { className: "font-bold text-[0.95rem] group-data-[collapsible=icon]:hidden tracking-tight bg-clip-text text-foreground/90 group-hover/new-chat:text-foreground transition-colors", children: t("new_conversation") })
1443
1485
  ]
1444
1486
  }
1445
1487
  )
1446
1488
  }
1447
1489
  ) }) }),
1448
- D && /* @__PURE__ */ e(Ee, { className: "group-data-[collapsible=icon]:hidden mb-6 px-2", children: /* @__PURE__ */ r("div", { className: "relative group/search", children: [
1449
- /* @__PURE__ */ e(jt, { className: "absolute left-3 top-1/2 -translate-y-1/2 size-4 opacity-40 group-focus-within/search:opacity-70 transition-opacity" }),
1490
+ M && /* @__PURE__ */ e(Ae, { className: "group-data-[collapsible=icon]:hidden mb-6 px-2", children: /* @__PURE__ */ r("div", { className: "relative group/search", children: [
1491
+ /* @__PURE__ */ e(Ot, { className: "absolute left-3 top-1/2 -translate-y-1/2 size-4 opacity-40 group-focus-within/search:opacity-70 transition-opacity" }),
1450
1492
  /* @__PURE__ */ e(
1451
- W,
1493
+ X,
1452
1494
  {
1453
1495
  placeholder: t("search_conversations"),
1454
- value: L,
1455
- onChange: (s) => H(s.target.value),
1496
+ value: R,
1497
+ onChange: (o) => L(o.target.value),
1456
1498
  className: "pl-9 h-10 bg-accent/15 border border-border/40 focus-visible:ring-primary/20 rounded-xl transition-all"
1457
1499
  }
1458
1500
  )
1459
1501
  ] }) }),
1460
- D && /* @__PURE__ */ r(Ee, { className: "group-data-[collapsible=icon]:hidden", children: [
1461
- /* @__PURE__ */ r(Ae, { children: [
1462
- A.map((s, _) => {
1463
- const se = $ === s.id, Se = Te(s.firstMessage ?? ""), Xe = Se === "rtl";
1464
- return /* @__PURE__ */ e(Le, { className: "group/sidebar-menu-item relative", children: se ? /* @__PURE__ */ r("div", { className: "flex items-center gap-1 px-2 py-1.5 w-full", children: [
1502
+ M && /* @__PURE__ */ r(Ae, { className: "group-data-[collapsible=icon]:hidden", children: [
1503
+ /* @__PURE__ */ r(Ee, { children: [
1504
+ I.map((o, _) => {
1505
+ const oe = H === o.id, Se = Te(o.firstMessage ?? ""), Je = Se === "rtl";
1506
+ return /* @__PURE__ */ e(Le, { className: "group/sidebar-menu-item relative", children: oe ? /* @__PURE__ */ r("div", { className: "flex items-center gap-1 px-2 py-1.5 w-full", children: [
1465
1507
  /* @__PURE__ */ e(
1466
- W,
1508
+ X,
1467
1509
  {
1468
- ref: c,
1469
- value: y,
1470
- onChange: (le) => b(le.target.value),
1510
+ ref: n,
1511
+ value: b,
1512
+ onChange: (le) => d(le.target.value),
1471
1513
  onKeyDown: (le) => {
1472
- le.key === "Enter" && re(), le.key === "Escape" && ee();
1514
+ le.key === "Enter" && Y(), le.key === "Escape" && z();
1473
1515
  },
1474
1516
  className: "h-8 py-0 px-2 text-sm",
1475
- dir: Te(y)
1517
+ dir: Te(b)
1476
1518
  }
1477
1519
  ),
1478
- /* @__PURE__ */ e(Y, { size: "icon", variant: "ghost", className: "size-8 shrink-0 text-green-600 hover:text-green-700 hover:bg-green-50", onClick: re, children: /* @__PURE__ */ e(Ot, { className: "size-4" }) }),
1479
- /* @__PURE__ */ e(Y, { size: "icon", variant: "ghost", className: "size-8 shrink-0 text-destructive hover:bg-destructive/10", onClick: ee, children: /* @__PURE__ */ e($t, { className: "size-4" }) })
1520
+ /* @__PURE__ */ e(te, { size: "icon", variant: "ghost", className: "size-8 shrink-0 text-green-600 hover:text-green-700 hover:bg-green-50", onClick: Y, children: /* @__PURE__ */ e($t, { className: "size-4" }) }),
1521
+ /* @__PURE__ */ e(te, { size: "icon", variant: "ghost", className: "size-8 shrink-0 text-destructive hover:bg-destructive/10", onClick: z, children: /* @__PURE__ */ e(Ut, { className: "size-4" }) })
1480
1522
  ] }) : /* @__PURE__ */ r(ke, { children: [
1481
1523
  /* @__PURE__ */ e(
1482
- ze,
1524
+ Re,
1483
1525
  {
1484
1526
  asChild: !0,
1485
1527
  className: v("h-auto py-2.5 px-3", {
1486
- "bg-accent opacity-100 pointer-events-none": s.id === j,
1487
- "opacity-70 hover:opacity-100": s.id !== j
1528
+ "bg-accent opacity-100 pointer-events-none": o.id === U,
1529
+ "opacity-70 hover:opacity-100": o.id !== U
1488
1530
  }),
1489
1531
  children: /* @__PURE__ */ r(
1490
1532
  "a",
1491
1533
  {
1492
- href: be(n, s.id),
1493
- onClick: (le) => k(le, s.id),
1534
+ href: be(s, o.id),
1535
+ onClick: (le) => k(le, o.id),
1494
1536
  dir: Se,
1495
- className: v("flex flex-col gap-0.5 w-full overflow-hidden", Xe ? "items-end" : "items-start"),
1537
+ className: v("flex flex-col gap-0.5 w-full overflow-hidden", Je ? "items-end" : "items-start"),
1496
1538
  children: [
1497
- /* @__PURE__ */ e("span", { className: v("truncate w-full font-medium text-[0.9375rem]", o.language === "fa" ? "pl-16 text-right" : "pr-16 text-left"), children: s.firstMessage }),
1498
- /* @__PURE__ */ e("div", { className: v("text-[10px] opacity-40 w-full", o.language === "fa" ? "pl-16 text-right" : "pr-16 text-left"), children: i(s.timestamp) })
1539
+ /* @__PURE__ */ e("span", { className: v("truncate w-full font-medium text-[0.9375rem]", i.language === "fa" ? "pl-16 text-right" : "pr-16 text-left"), children: o.firstMessage }),
1540
+ /* @__PURE__ */ e("div", { className: v("text-[10px] opacity-40 w-full", i.language === "fa" ? "pl-16 text-right" : "pr-16 text-left"), children: l(o.timestamp) })
1499
1541
  ]
1500
1542
  }
1501
1543
  )
@@ -1503,44 +1545,44 @@ function Ma({ side: a = "left" }) {
1503
1545
  ),
1504
1546
  /* @__PURE__ */ r("div", { className: v(
1505
1547
  "absolute top-1/2 -translate-y-1/2 flex items-center gap-1 transition-all duration-200 z-10",
1506
- o.language === "fa" ? "left-2" : "right-1.5"
1548
+ i.language === "fa" ? "left-2" : "right-1.5"
1507
1549
  ), children: [
1508
- s.pinned && /* @__PURE__ */ e(Ie, { className: "size-3.5 text-primary opacity-70 md:absolute md:inset-0 md:m-auto md:group-hover/sidebar-menu-item:opacity-0 transition-opacity pointer-events-none" }),
1509
- /* @__PURE__ */ r(dt, { dir: o.language === "fa" ? "rtl" : "ltr", children: [
1510
- /* @__PURE__ */ e(ut, { asChild: !0, children: /* @__PURE__ */ e(
1511
- Y,
1550
+ o.pinned && /* @__PURE__ */ e(De, { className: "size-3.5 text-primary opacity-70 md:absolute md:inset-0 md:m-auto md:group-hover/sidebar-menu-item:opacity-0 transition-opacity pointer-events-none" }),
1551
+ /* @__PURE__ */ r(ut, { dir: i.language === "fa" ? "rtl" : "ltr", children: [
1552
+ /* @__PURE__ */ e(mt, { asChild: !0, children: /* @__PURE__ */ e(
1553
+ te,
1512
1554
  {
1513
1555
  variant: "ghost",
1514
1556
  size: "icon",
1515
1557
  className: "size-7 rounded-full opacity-100 md:opacity-0 md:group-hover/sidebar-menu-item:opacity-100 hover:bg-accent hover:text-accent-foreground data-[state=open]:opacity-100 transition-all",
1516
- children: /* @__PURE__ */ e(Ut, { className: "size-3.5" })
1558
+ children: /* @__PURE__ */ e(Bt, { className: "size-3.5" })
1517
1559
  }
1518
1560
  ) }),
1519
1561
  /* @__PURE__ */ r(
1520
- mt,
1562
+ ht,
1521
1563
  {
1522
1564
  align: "end",
1523
1565
  className: "min-w-[120px] p-1",
1524
1566
  children: [
1525
- x?.showPin !== !1 && /* @__PURE__ */ r(me, { onSelect: () => S(s), className: "cursor-pointer flex items-center gap-2", children: [
1526
- s.pinned ? /* @__PURE__ */ e(Bt, { className: "size-4" }) : /* @__PURE__ */ e(Ie, { className: "size-4" }),
1527
- /* @__PURE__ */ e("span", { children: s.pinned ? t("unpin_conversation") : t("pin_conversation") })
1567
+ y?.showPin !== !1 && /* @__PURE__ */ r(me, { onSelect: () => j(o), className: "cursor-pointer flex items-center gap-2", children: [
1568
+ o.pinned ? /* @__PURE__ */ e(Kt, { className: "size-4" }) : /* @__PURE__ */ e(De, { className: "size-4" }),
1569
+ /* @__PURE__ */ e("span", { children: o.pinned ? t("unpin_conversation") : t("pin_conversation") })
1528
1570
  ] }),
1529
- x?.showShare !== !1 && /* @__PURE__ */ r(me, { onSelect: () => M(s), className: "cursor-pointer flex items-center gap-2", children: [
1530
- /* @__PURE__ */ e(Kt, { className: "size-4" }),
1571
+ y?.showShare !== !1 && /* @__PURE__ */ r(me, { onSelect: () => S(o), className: "cursor-pointer flex items-center gap-2", children: [
1572
+ /* @__PURE__ */ e(Qt, { className: "size-4" }),
1531
1573
  /* @__PURE__ */ e("span", { children: t("share_conversation") })
1532
1574
  ] }),
1533
- (x?.showRename ?? !1) && /* @__PURE__ */ r(me, { onSelect: () => G(s), className: "cursor-pointer flex items-center gap-2", children: [
1575
+ (y?.showRename ?? !1) && /* @__PURE__ */ r(me, { onSelect: () => w(o), className: "cursor-pointer flex items-center gap-2", children: [
1534
1576
  /* @__PURE__ */ e(Ht, { className: "size-4" }),
1535
1577
  /* @__PURE__ */ e("span", { children: t("rename_conversation") })
1536
1578
  ] }),
1537
- (x?.showDelete ?? !1) && /* @__PURE__ */ r(
1579
+ (y?.showDelete ?? !1) && /* @__PURE__ */ r(
1538
1580
  me,
1539
1581
  {
1540
1582
  className: "text-destructive focus:text-destructive focus:bg-destructive/10 cursor-pointer flex items-center gap-2",
1541
- onSelect: () => ie(s),
1583
+ onSelect: () => Z(o),
1542
1584
  children: [
1543
- /* @__PURE__ */ e(Qt, { className: "size-4" }),
1585
+ /* @__PURE__ */ e(Vt, { className: "size-4" }),
1544
1586
  /* @__PURE__ */ e("span", { children: t("delete_conversation") })
1545
1587
  ]
1546
1588
  }
@@ -1552,51 +1594,51 @@ function Ma({ side: a = "left" }) {
1552
1594
  ] })
1553
1595
  ] }) }, _);
1554
1596
  }),
1555
- !w && P.length === 0 && !L && /* @__PURE__ */ e("div", { className: "px-4 py-8 text-center text-sm opacity-40", children: t("no_conversations") })
1597
+ !N && P.length === 0 && !R && /* @__PURE__ */ e("div", { className: "px-4 py-8 text-center text-sm opacity-40", children: t("no_conversations") })
1556
1598
  ] }),
1557
- /* @__PURE__ */ e("div", { ref: q, className: "h-4 w-full" }),
1558
- m && /* @__PURE__ */ r("div", { className: "flex flex-col items-center gap-2 p-4 pt-0 opacity-60", children: [
1599
+ /* @__PURE__ */ e("div", { ref: Q, className: "h-4 w-full" }),
1600
+ h && /* @__PURE__ */ r("div", { className: "flex flex-col items-center gap-2 p-4 pt-0 opacity-60", children: [
1559
1601
  /* @__PURE__ */ e("div", { className: "size-4 border-2 border-primary border-t-transparent rounded-full animate-spin" }),
1560
1602
  /* @__PURE__ */ e("span", { className: "text-[10px] uppercase tracking-wider font-medium", children: t("loading_more") })
1561
1603
  ] })
1562
1604
  ] })
1563
1605
  ] }) }),
1564
- /* @__PURE__ */ e(Na, {}),
1565
- /* @__PURE__ */ e(He, { open: V, onOpenChange: O, children: /* @__PURE__ */ r(
1566
- Qe,
1606
+ /* @__PURE__ */ e(ka, {}),
1607
+ /* @__PURE__ */ e(He, { open: W, onOpenChange: K, children: /* @__PURE__ */ r(
1608
+ Ve,
1567
1609
  {
1568
- onKeyDown: (s) => {
1569
- s.key === "Enter" && (s.preventDefault(), ne());
1610
+ onKeyDown: (o) => {
1611
+ o.key === "Enter" && (o.preventDefault(), se());
1570
1612
  },
1571
1613
  children: [
1572
- /* @__PURE__ */ r(ht, { children: [
1573
- /* @__PURE__ */ e(pt, { children: t("delete_confirm_title") }),
1574
- /* @__PURE__ */ e(gt, { children: t("delete_confirm_description") })
1614
+ /* @__PURE__ */ r(pt, { children: [
1615
+ /* @__PURE__ */ e(gt, { children: t("delete_confirm_title") }),
1616
+ /* @__PURE__ */ e(ft, { children: t("delete_confirm_description") })
1575
1617
  ] }),
1576
- /* @__PURE__ */ r(ft, { children: [
1618
+ /* @__PURE__ */ r(bt, { children: [
1577
1619
  /* @__PURE__ */ e(
1578
- Y,
1620
+ te,
1579
1621
  {
1580
1622
  variant: "outline",
1581
1623
  onClick: () => {
1582
- O(!1);
1624
+ K(!1);
1583
1625
  },
1584
1626
  children: t("cancel")
1585
1627
  }
1586
1628
  ),
1587
- /* @__PURE__ */ e(Y, { variant: "destructive", onClick: ne, autoFocus: !0, children: t("delete") })
1629
+ /* @__PURE__ */ e(te, { variant: "destructive", onClick: se, autoFocus: !0, children: t("delete") })
1588
1630
  ] })
1589
1631
  ]
1590
1632
  }
1591
1633
  ) })
1592
1634
  ] }) });
1593
1635
  }
1594
- function Va({ sidebar: a, header: t, components: o, classNames: u, disclaimer: l, welcome: d }) {
1595
- const { config: h } = je(), { history: p } = te(), m = h?.language === "fa" ? "right" : "left", w = p?.enabled ?? !0;
1596
- return /* @__PURE__ */ r(xa, { defaultOpen: w, children: [
1597
- a !== void 0 ? a : w ? /* @__PURE__ */ e(Ma, { side: m }) : null,
1636
+ function Ga({ sidebar: a, header: t, components: i, classNames: m, disclaimer: c, welcome: u }) {
1637
+ const { config: g } = je(), { history: f } = re(), h = g?.language === "fa" ? "right" : "left", N = f?.enabled ?? !0;
1638
+ return /* @__PURE__ */ r(ya, { defaultOpen: N, children: [
1639
+ a !== void 0 ? a : N ? /* @__PURE__ */ e(Ia, { side: h }) : null,
1598
1640
  /* @__PURE__ */ r("div", { className: "flex flex-col flex-1 h-dvh overflow-hidden relative", children: [
1599
- t !== void 0 ? t : /* @__PURE__ */ e(We, {}),
1641
+ t !== void 0 ? t : /* @__PURE__ */ e(Xe, {}),
1600
1642
  /* @__PURE__ */ e(
1601
1643
  "div",
1602
1644
  {
@@ -1605,12 +1647,12 @@ function Va({ sidebar: a, header: t, components: o, classNames: u, disclaimer: l
1605
1647
  "has-[.stick-to-bottom:empty]:overflow-visible has-[.stick-to-bottom:empty]:flex-initial transition-[flex] duration-200"
1606
1648
  ),
1607
1649
  children: /* @__PURE__ */ e(
1608
- sa,
1650
+ oa,
1609
1651
  {
1610
- components: o,
1611
- classNames: u,
1612
- disclaimer: l,
1613
- welcome: d
1652
+ components: i,
1653
+ classNames: m,
1654
+ disclaimer: c,
1655
+ welcome: u
1614
1656
  }
1615
1657
  )
1616
1658
  }
@@ -1618,111 +1660,111 @@ function Va({ sidebar: a, header: t, components: o, classNames: u, disclaimer: l
1618
1660
  ] })
1619
1661
  ] });
1620
1662
  }
1621
- function Ga({ children: a }) {
1622
- const [t, o] = T(null), u = Ve(), l = _e(), d = ue();
1623
- return F(() => {
1663
+ function Wa({ children: a }) {
1664
+ const [t, i] = T(null), m = Ge(), c = _e(), u = ue();
1665
+ return $(() => {
1624
1666
  (async () => {
1625
- const p = new URLSearchParams(u.search), m = p.get("token");
1626
- if (m)
1667
+ const f = new URLSearchParams(m.search), h = f.get("token");
1668
+ if (h)
1627
1669
  try {
1628
- E.setToken(m), await E.getBalance(), p.delete("token");
1629
- const x = p.toString(), C = u.pathname + (x ? `?${x}` : "");
1630
- l(C, { replace: !0 }), o(!0);
1670
+ D.setToken(h), await D.getBalance(), f.delete("token");
1671
+ const y = f.toString(), C = m.pathname + (y ? `?${y}` : "");
1672
+ c(C, { replace: !0 }), i(!0);
1631
1673
  return;
1632
- } catch (x) {
1633
- console.error("Error validating token from URL:", x), o(!1);
1674
+ } catch (y) {
1675
+ console.error("Error validating token from URL:", y), i(!1);
1634
1676
  return;
1635
1677
  }
1636
- if (!E.getToken()) {
1637
- o(!1);
1678
+ if (!D.getToken()) {
1679
+ i(!1);
1638
1680
  return;
1639
1681
  }
1640
1682
  try {
1641
- await E.getBalance(), o(!0);
1642
- } catch (x) {
1643
- console.error("Token validation failed:", x), x.status === 401 ? (E.clearToken(), d.clear(), o(!1)) : o(!0);
1683
+ await D.getBalance(), i(!0);
1684
+ } catch (y) {
1685
+ console.error("Token validation failed:", y), y.status === 401 ? (D.clearToken(), u.clear(), i(!1)) : i(!0);
1644
1686
  }
1645
1687
  })();
1646
- }, [u.search, l, u.pathname, d]), t === null ? /* @__PURE__ */ e("div", { className: "flex h-screen w-full items-center justify-center", children: /* @__PURE__ */ e("div", { className: "size-8 rounded-full border-4 border-primary border-t-transparent animate-spin" }) }) : t ? /* @__PURE__ */ e(ke, { children: a }) : /* @__PURE__ */ e(Jt, { to: "/login", replace: !0 });
1688
+ }, [m.search, c, m.pathname, u]), t === null ? /* @__PURE__ */ e("div", { className: "flex h-screen w-full items-center justify-center", children: /* @__PURE__ */ e("div", { className: "size-8 rounded-full border-4 border-primary border-t-transparent animate-spin" }) }) : t ? /* @__PURE__ */ e(ke, { children: a }) : /* @__PURE__ */ e(Yt, { to: "/login", replace: !0 });
1647
1689
  }
1648
- const Re = (a) => a.replace(/[^0-9]/g, "");
1649
- function Wa() {
1650
- const { t: a, i18n: t } = de(["login", "translation"]), { app: o } = te(), u = t.dir() === "rtl", l = u ? "text-right" : "text-left", d = _e(), h = ue(), [p, m] = T("login"), w = !!o?.disableSignup, x = !!o?.disableAuthPage, [C, n] = T(""), [D, P] = T(""), [j, U] = T(""), [I, f] = T(""), [q, g] = T(""), [B, V] = T(""), O = R(() => o?.userMetadataFields?.filter((c) => c.showInSignup) || [], [o?.userMetadataFields]), [z, K] = T(() => {
1651
- const c = {};
1652
- return O.forEach((k) => {
1653
- k.defaultValue !== void 0 && (c[k.key] = k.defaultValue);
1654
- }), c;
1690
+ const qe = (a) => a.replace(/[^0-9]/g, "");
1691
+ function Xa() {
1692
+ const { t: a, i18n: t } = de(["login", "translation"]), { app: i } = re(), m = t.dir() === "rtl", c = m ? "text-right" : "text-left", u = _e(), g = ue(), [f, h] = T("login"), N = !!i?.disableSignup, y = !!i?.disableAuthPage, [C, s] = T(""), [M, P] = T(""), [U, q] = T(""), [A, p] = T(""), [Q, x] = T(""), [B, W] = T(""), K = O(() => i?.userMetadataFields?.filter((n) => n.showInSignup) || [], [i?.userMetadataFields]), [E, V] = T(() => {
1693
+ const n = {};
1694
+ return K.forEach((k) => {
1695
+ k.defaultValue !== void 0 && (n[k.key] = k.defaultValue);
1696
+ }), n;
1655
1697
  });
1656
- F(() => {
1657
- const c = { ...z };
1698
+ $(() => {
1699
+ const n = { ...E };
1658
1700
  let k = !1;
1659
- O.forEach((A) => {
1660
- A.condition && !ge(A.condition, z) && c[A.key] !== void 0 && (delete c[A.key], k = !0);
1661
- }), k && K(c);
1662
- }, [z, O]);
1663
- const [L, H] = T(""), [$, N] = T(!1);
1664
- F(() => {
1665
- w && p === "register" && m("login");
1666
- }, [w, p]);
1667
- const y = async (c) => {
1668
- c.preventDefault(), H(""), N(!0);
1701
+ K.forEach((I) => {
1702
+ I.condition && !ge(I.condition, E) && n[I.key] !== void 0 && (delete n[I.key], k = !0);
1703
+ }), k && V(n);
1704
+ }, [E, K]);
1705
+ const [R, L] = T(""), [H, F] = T(!1);
1706
+ $(() => {
1707
+ N && f === "register" && h("login");
1708
+ }, [N, f]);
1709
+ const b = async (n) => {
1710
+ n.preventDefault(), L(""), F(!0);
1669
1711
  try {
1670
- await E.login(C, D), h.clear(), d("/");
1712
+ await D.login(C, M), g.clear(), u("/");
1671
1713
  } catch (k) {
1672
- H(ce(k, a));
1714
+ L(ce(k, a));
1673
1715
  } finally {
1674
- N(!1);
1716
+ F(!1);
1675
1717
  }
1676
- }, b = async (c) => {
1677
- c.preventDefault(), H(""), N(!0);
1718
+ }, d = async (n) => {
1719
+ n.preventDefault(), L(""), F(!0);
1678
1720
  try {
1679
- await E.register(j, I, q, B, z), h.clear(), d("/");
1721
+ await D.register(U, A, Q, B, E), g.clear(), u("/");
1680
1722
  } catch (k) {
1681
- H(ce(k, a));
1723
+ L(ce(k, a));
1682
1724
  } finally {
1683
- N(!1);
1725
+ F(!1);
1684
1726
  }
1685
1727
  };
1686
- return x ? /* @__PURE__ */ e("div", { className: "min-h-screen bg-background flex items-center justify-center p-4", dir: t.dir(), children: /* @__PURE__ */ r("div", { className: "w-full max-w-lg bg-card border border-border rounded-xl shadow-lg p-8 text-center space-y-4", children: [
1687
- /* @__PURE__ */ e("h1", { className: "text-2xl font-bold", children: o?.name }),
1728
+ return y ? /* @__PURE__ */ e("div", { className: "min-h-screen bg-background flex items-center justify-center p-4", dir: t.dir(), children: /* @__PURE__ */ r("div", { className: "w-full max-w-lg bg-card border border-border rounded-xl shadow-lg p-8 text-center space-y-4", children: [
1729
+ /* @__PURE__ */ e("h1", { className: "text-2xl font-bold", children: i?.name }),
1688
1730
  /* @__PURE__ */ e("p", { className: "text-muted-foreground", children: a("auth_page_disabled_title", "The sign-in page is currently disabled.") }),
1689
1731
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground/80", children: a("auth_page_disabled_description", "Please contact the administrator for access.") })
1690
1732
  ] }) }) : /* @__PURE__ */ e("div", { className: "min-h-screen bg-background flex flex-col items-center justify-center p-4", dir: t.dir(), children: /* @__PURE__ */ r("div", { className: "w-full max-w-md bg-card border border-border rounded-xl shadow-lg p-6", children: [
1691
- /* @__PURE__ */ e("div", { className: "text-center mb-6", children: /* @__PURE__ */ e("h1", { className: "text-2xl font-bold bg-gradient-to-r from-primary to-primary/60 bg-clip-text text-transparent", children: o?.name }) }),
1733
+ /* @__PURE__ */ e("div", { className: "text-center mb-6", children: /* @__PURE__ */ e("h1", { className: "text-2xl font-bold bg-gradient-to-r from-primary to-primary/60 bg-clip-text text-transparent", children: i?.name }) }),
1692
1734
  /* @__PURE__ */ r("div", { className: "flex bg-muted p-1 rounded-lg mb-6", children: [
1693
1735
  /* @__PURE__ */ e(
1694
1736
  "button",
1695
1737
  {
1696
1738
  type: "button",
1697
1739
  onClick: () => {
1698
- m("login"), H("");
1740
+ h("login"), L("");
1699
1741
  },
1700
- className: `flex-1 py-2 text-sm font-medium rounded-md transition-all ${p === "login" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
1742
+ className: `flex-1 py-2 text-sm font-medium rounded-md transition-all ${f === "login" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
1701
1743
  children: a("login_tab", "Login")
1702
1744
  }
1703
1745
  ),
1704
- !w && /* @__PURE__ */ e(
1746
+ !N && /* @__PURE__ */ e(
1705
1747
  "button",
1706
1748
  {
1707
1749
  type: "button",
1708
1750
  onClick: () => {
1709
- m("register"), H("");
1751
+ h("register"), L("");
1710
1752
  },
1711
- className: `flex-1 py-2 text-sm font-medium rounded-md transition-all ${p === "register" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
1753
+ className: `flex-1 py-2 text-sm font-medium rounded-md transition-all ${f === "register" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
1712
1754
  children: a("signup_tab", "Sign Up")
1713
1755
  }
1714
1756
  )
1715
1757
  ] }),
1716
- p === "login" && /* @__PURE__ */ r("form", { onSubmit: y, className: "space-y-4", children: [
1758
+ f === "login" && /* @__PURE__ */ r("form", { onSubmit: b, className: "space-y-4", children: [
1717
1759
  /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1718
- /* @__PURE__ */ e(Q, { htmlFor: "login-phone", children: a("phone", "Phone") }),
1760
+ /* @__PURE__ */ e(G, { htmlFor: "login-phone", children: a("phone", "Phone") }),
1719
1761
  /* @__PURE__ */ e(
1720
- W,
1762
+ X,
1721
1763
  {
1722
1764
  id: "login-phone",
1723
1765
  type: "tel",
1724
1766
  value: C,
1725
- onChange: (c) => n(Re(c.target.value)),
1767
+ onChange: (n) => s(qe(n.target.value)),
1726
1768
  required: !0,
1727
1769
  className: "text-left",
1728
1770
  placeholder: a("phone_placeholder", "Phone number"),
@@ -1731,14 +1773,14 @@ function Wa() {
1731
1773
  )
1732
1774
  ] }),
1733
1775
  /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1734
- /* @__PURE__ */ e(Q, { htmlFor: "login-pass", children: a("password", "Password") }),
1776
+ /* @__PURE__ */ e(G, { htmlFor: "login-pass", children: a("password", "Password") }),
1735
1777
  /* @__PURE__ */ e(
1736
- W,
1778
+ X,
1737
1779
  {
1738
1780
  id: "login-pass",
1739
1781
  type: "password",
1740
- value: D,
1741
- onChange: (c) => P(c.target.value),
1782
+ value: M,
1783
+ onChange: (n) => P(n.target.value),
1742
1784
  required: !0,
1743
1785
  className: "text-left",
1744
1786
  placeholder: "••••••••",
@@ -1746,27 +1788,27 @@ function Wa() {
1746
1788
  }
1747
1789
  )
1748
1790
  ] }),
1749
- L && /* @__PURE__ */ e("div", { className: "text-sm text-destructive", children: L }),
1791
+ R && /* @__PURE__ */ e("div", { className: "text-sm text-destructive", children: R }),
1750
1792
  /* @__PURE__ */ e(
1751
- Y,
1793
+ te,
1752
1794
  {
1753
1795
  type: "submit",
1754
- disabled: $,
1796
+ disabled: H,
1755
1797
  className: "w-full font-semibold",
1756
- children: $ ? a("logging_in", "Logging in...") : a("login_button", "Login")
1798
+ children: H ? a("logging_in", "Logging in...") : a("login_button", "Login")
1757
1799
  }
1758
1800
  )
1759
1801
  ] }),
1760
- !w && p === "register" && /* @__PURE__ */ r("form", { onSubmit: b, className: "space-y-4", children: [
1802
+ !N && f === "register" && /* @__PURE__ */ r("form", { onSubmit: d, className: "space-y-4", children: [
1761
1803
  /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1762
- /* @__PURE__ */ e(Q, { htmlFor: "reg-phone", children: a("phone", "Phone") }),
1804
+ /* @__PURE__ */ e(G, { htmlFor: "reg-phone", children: a("phone", "Phone") }),
1763
1805
  /* @__PURE__ */ e(
1764
- W,
1806
+ X,
1765
1807
  {
1766
1808
  id: "reg-phone",
1767
1809
  type: "tel",
1768
- value: j,
1769
- onChange: (c) => U(Re(c.target.value)),
1810
+ value: U,
1811
+ onChange: (n) => q(qe(n.target.value)),
1770
1812
  required: !0,
1771
1813
  className: "text-left",
1772
1814
  placeholder: a("phone_placeholder", "Phone number"),
@@ -1775,14 +1817,14 @@ function Wa() {
1775
1817
  )
1776
1818
  ] }),
1777
1819
  /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1778
- /* @__PURE__ */ e(Q, { htmlFor: "reg-pass", children: a("password", "Password") }),
1820
+ /* @__PURE__ */ e(G, { htmlFor: "reg-pass", children: a("password", "Password") }),
1779
1821
  /* @__PURE__ */ e(
1780
- W,
1822
+ X,
1781
1823
  {
1782
1824
  id: "reg-pass",
1783
1825
  type: "password",
1784
- value: I,
1785
- onChange: (c) => f(c.target.value),
1826
+ value: A,
1827
+ onChange: (n) => p(n.target.value),
1786
1828
  required: !0,
1787
1829
  className: "text-left",
1788
1830
  placeholder: "••••••••",
@@ -1792,128 +1834,128 @@ function Wa() {
1792
1834
  ] }),
1793
1835
  /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: [
1794
1836
  /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1795
- /* @__PURE__ */ e(Q, { htmlFor: "reg-name", children: a("name", "Name") }),
1837
+ /* @__PURE__ */ e(G, { htmlFor: "reg-name", children: a("name", "Name") }),
1796
1838
  /* @__PURE__ */ e(
1797
- W,
1839
+ X,
1798
1840
  {
1799
1841
  id: "reg-name",
1800
1842
  type: "text",
1801
- value: q,
1802
- onChange: (c) => g(c.target.value),
1843
+ value: Q,
1844
+ onChange: (n) => x(n.target.value),
1803
1845
  required: !0,
1804
- className: l,
1846
+ className: c,
1805
1847
  placeholder: a("name_placeholder", "First Name")
1806
1848
  }
1807
1849
  )
1808
1850
  ] }),
1809
1851
  /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1810
- /* @__PURE__ */ e(Q, { htmlFor: "reg-surname", children: a("surname", "Surname") }),
1852
+ /* @__PURE__ */ e(G, { htmlFor: "reg-surname", children: a("surname", "Surname") }),
1811
1853
  /* @__PURE__ */ e(
1812
- W,
1854
+ X,
1813
1855
  {
1814
1856
  id: "reg-surname",
1815
1857
  type: "text",
1816
1858
  value: B,
1817
- onChange: (c) => V(c.target.value),
1859
+ onChange: (n) => W(n.target.value),
1818
1860
  required: !0,
1819
- className: l,
1861
+ className: c,
1820
1862
  placeholder: a("surname_placeholder", "Last Name")
1821
1863
  }
1822
1864
  )
1823
1865
  ] })
1824
1866
  ] }),
1825
- O.map((c) => ge(c.condition, z) ? /* @__PURE__ */ r("div", { className: "space-y-3 animate-in fade-in slide-in-from-top-1 duration-200", children: [
1826
- /* @__PURE__ */ e(Q, { htmlFor: `signup-${c.key}`, children: a(c.label) }),
1827
- c.type === "select" ? /* @__PURE__ */ r(
1828
- ve,
1867
+ K.map((n) => ge(n.condition, E) ? /* @__PURE__ */ r("div", { className: "space-y-3 animate-in fade-in slide-in-from-top-1 duration-200", children: [
1868
+ /* @__PURE__ */ e(G, { htmlFor: `signup-${n.key}`, children: a(n.label) }),
1869
+ n.type === "select" ? /* @__PURE__ */ r(
1870
+ xe,
1829
1871
  {
1830
- value: String(z[c.key] || ""),
1831
- onValueChange: (k) => K({ ...z, [c.key]: k }),
1832
- required: c.required,
1833
- dir: u ? "rtl" : "ltr",
1872
+ value: String(E[n.key] || ""),
1873
+ onValueChange: (k) => V({ ...E, [n.key]: k }),
1874
+ required: n.required,
1875
+ dir: m ? "rtl" : "ltr",
1834
1876
  children: [
1835
- /* @__PURE__ */ e(xe, { className: v("bg-background", l), children: /* @__PURE__ */ e(ye, { placeholder: a(c.placeholder || "select_placeholder") }) }),
1836
- /* @__PURE__ */ e(we, { className: "rounded-xl", children: c.options?.map((k) => /* @__PURE__ */ e(pe, { value: String(k.value), children: a(k.label) }, String(k.value))) })
1877
+ /* @__PURE__ */ e(ve, { className: v("bg-background", c), children: /* @__PURE__ */ e(ye, { placeholder: a(n.placeholder || "select_placeholder") }) }),
1878
+ /* @__PURE__ */ e(we, { className: "rounded-xl", children: n.options?.map((k) => /* @__PURE__ */ e(pe, { value: String(k.value), children: a(k.label) }, String(k.value))) })
1837
1879
  ]
1838
1880
  }
1839
- ) : c.type === "checkbox" ? /* @__PURE__ */ r("div", { className: "flex items-center gap-2 py-2", children: [
1881
+ ) : n.type === "checkbox" ? /* @__PURE__ */ r("div", { className: "flex items-center gap-2 py-2", children: [
1840
1882
  /* @__PURE__ */ e(
1841
- bt,
1883
+ xt,
1842
1884
  {
1843
- id: `signup-${c.key}`,
1844
- checked: !!z[c.key],
1845
- onCheckedChange: (k) => K({ ...z, [c.key]: !!k }),
1846
- required: c.required
1885
+ id: `signup-${n.key}`,
1886
+ checked: !!E[n.key],
1887
+ onCheckedChange: (k) => V({ ...E, [n.key]: !!k }),
1888
+ required: n.required
1847
1889
  }
1848
1890
  ),
1849
- /* @__PURE__ */ e("label", { htmlFor: `signup-${c.key}`, className: "text-sm text-muted-foreground cursor-pointer select-none", children: a(c.placeholder || c.label) })
1891
+ /* @__PURE__ */ e("label", { htmlFor: `signup-${n.key}`, className: "text-sm text-muted-foreground cursor-pointer select-none", children: a(n.placeholder || n.label) })
1850
1892
  ] }) : /* @__PURE__ */ e(
1851
- W,
1893
+ X,
1852
1894
  {
1853
- id: `signup-${c.key}`,
1854
- type: c.type,
1855
- value: z[c.key] || "",
1856
- onChange: (k) => K({ ...z, [c.key]: k.target.value }),
1857
- required: c.required,
1858
- className: l,
1859
- placeholder: a(c.placeholder || "")
1895
+ id: `signup-${n.key}`,
1896
+ type: n.type,
1897
+ value: E[n.key] || "",
1898
+ onChange: (k) => V({ ...E, [n.key]: k.target.value }),
1899
+ required: n.required,
1900
+ className: c,
1901
+ placeholder: a(n.placeholder || "")
1860
1902
  }
1861
1903
  )
1862
- ] }, c.key) : null),
1863
- L && /* @__PURE__ */ e("div", { className: "text-sm text-destructive", children: L }),
1904
+ ] }, n.key) : null),
1905
+ R && /* @__PURE__ */ e("div", { className: "text-sm text-destructive", children: R }),
1864
1906
  /* @__PURE__ */ e(
1865
- Y,
1907
+ te,
1866
1908
  {
1867
1909
  type: "submit",
1868
- disabled: $,
1910
+ disabled: H,
1869
1911
  className: "w-full font-semibold",
1870
- children: $ ? a("signing_up", "Signing up...") : a("signup_button", "Sign Up")
1912
+ children: H ? a("signing_up", "Signing up...") : a("signup_button", "Sign Up")
1871
1913
  }
1872
1914
  )
1873
1915
  ] })
1874
1916
  ] }) });
1875
1917
  }
1876
1918
  function Da() {
1877
- const { shareId: a } = Yt(), [t, o] = T(null), [u, l] = T(!0), [d, h] = T(null), { MessageList: p } = te(), m = Z(/* @__PURE__ */ new Set());
1878
- return F(() => () => {
1879
- m.current.forEach((w) => URL.revokeObjectURL(w)), m.current.clear();
1880
- }, []), F(() => {
1919
+ const { shareId: a } = Zt(), [t, i] = T(null), [m, c] = T(!0), [u, g] = T(null), { MessageList: f } = re(), h = ae(/* @__PURE__ */ new Set());
1920
+ return $(() => () => {
1921
+ h.current.forEach((N) => URL.revokeObjectURL(N)), h.current.clear();
1922
+ }, []), $(() => {
1881
1923
  if (!a) return;
1882
1924
  (async () => {
1883
1925
  try {
1884
- l(!0);
1885
- const x = await E.getSharedThread(a);
1886
- x.items && (x.items = await Promise.all(
1887
- x.items.map(async (C) => {
1926
+ c(!0);
1927
+ const y = await D.getSharedThread(a);
1928
+ y.items && (y.items = await Promise.all(
1929
+ y.items.map(async (C) => {
1888
1930
  if (!C.parts) return C;
1889
- const n = await Promise.all(
1890
- C.parts.map(async (D) => {
1891
- if (D.type === "file" && D.object_name && !D.url)
1931
+ const s = await Promise.all(
1932
+ C.parts.map(async (M) => {
1933
+ if (M.type === "file" && M.object_name && !M.url)
1892
1934
  try {
1893
- const P = await E.getPublicAttachmentBlobUrl(D.object_name);
1894
- return m.current.add(P), { ...D, url: P };
1935
+ const P = await D.getPublicAttachmentBlobUrl(M.object_name);
1936
+ return h.current.add(P), { ...M, url: P };
1895
1937
  } catch (P) {
1896
- console.error("Failed to resolve shared attachment:", D.object_name, P);
1938
+ console.error("Failed to resolve shared attachment:", M.object_name, P);
1897
1939
  }
1898
- return D;
1940
+ return M;
1899
1941
  })
1900
1942
  );
1901
- return { ...C, parts: n };
1943
+ return { ...C, parts: s };
1902
1944
  })
1903
- )), o(x);
1904
- } catch (x) {
1905
- console.error("Failed to fetch shared chat:", x), h(x.message || "Failed to load shared chat");
1945
+ )), i(y);
1946
+ } catch (y) {
1947
+ console.error("Failed to fetch shared chat:", y), g(y.message || "Failed to load shared chat");
1906
1948
  } finally {
1907
- l(!1);
1949
+ c(!1);
1908
1950
  }
1909
1951
  })();
1910
- }, [a]), u ? /* @__PURE__ */ e("div", { className: "flex h-dvh items-center justify-center", children: /* @__PURE__ */ e(vt, {}) }) : d || !t ? /* @__PURE__ */ r("div", { className: "flex h-dvh flex-col items-center justify-center p-4 text-center", children: [
1952
+ }, [a]), m ? /* @__PURE__ */ e("div", { className: "flex h-dvh items-center justify-center", children: /* @__PURE__ */ e(vt, {}) }) : u || !t ? /* @__PURE__ */ r("div", { className: "flex h-dvh flex-col items-center justify-center p-4 text-center", children: [
1911
1953
  /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-destructive mb-2 font-display", children: "Shared Chat Not Found" }),
1912
- /* @__PURE__ */ e("p", { className: "text-muted-foreground max-w-md", children: d || "This shared conversation might have been deleted or the link is invalid." })
1954
+ /* @__PURE__ */ e("p", { className: "text-muted-foreground max-w-md", children: u || "This shared conversation might have been deleted or the link is invalid." })
1913
1955
  ] }) : /* @__PURE__ */ r("div", { className: "relative flex flex-col h-dvh overflow-hidden bg-background", children: [
1914
- /* @__PURE__ */ e(We, { hideActions: !0 }),
1915
- /* @__PURE__ */ e("div", { className: "flex-1 min-h-0 overflow-hidden relative flex flex-col", children: /* @__PURE__ */ e(
1916
- p,
1956
+ /* @__PURE__ */ e(Xe, { hideActions: !0 }),
1957
+ /* @__PURE__ */ e("div", { className: "flex-1 min-h-0 overflow-hidden relative flex flex-col", children: /* @__PURE__ */ e(Oe, { readonly: !0, children: /* @__PURE__ */ e(
1958
+ f,
1917
1959
  {
1918
1960
  messages: t.items || [],
1919
1961
  status: "ready",
@@ -1927,46 +1969,50 @@ function Da() {
1927
1969
  className: "pb-8",
1928
1970
  readonly: !0
1929
1971
  }
1930
- ) })
1972
+ ) }) })
1931
1973
  ] });
1932
1974
  }
1933
- function Xa() {
1975
+ function Ja() {
1934
1976
  return /* @__PURE__ */ e(Da, {});
1935
1977
  }
1936
1978
  export {
1937
- Ma as AppSidebar,
1938
- sa as Chat,
1939
- Va as ChatUI,
1940
- nr as FilePart,
1941
- Qa as GentiqProvider,
1942
- sr as MessageList,
1943
- or as Part,
1944
- ir as PromptInputArea,
1945
- lr as ReasoningPart,
1946
- Ga as RequireAuth,
1947
- ve as Select,
1979
+ Ia as AppSidebar,
1980
+ oa as Chat,
1981
+ Ga as ChatUI,
1982
+ sr as ChoiceQuestionPart,
1983
+ or as FilePart,
1984
+ Va as GentiqProvider,
1985
+ ir as MessageList,
1986
+ lr as Part,
1987
+ cr as PromptInputArea,
1988
+ dr as ReasoningPart,
1989
+ ur as ReferencePart,
1990
+ mr as Referenceable,
1991
+ Wa as RequireAuth,
1992
+ xe as Select,
1948
1993
  we as SelectContent,
1949
- cr as SelectGroup,
1994
+ hr as SelectGroup,
1950
1995
  pe as SelectItem,
1951
- dr as SelectLabel,
1952
- ur as SelectScrollDownButton,
1953
- mr as SelectScrollUpButton,
1954
- hr as SelectSeparator,
1955
- xe as SelectTrigger,
1996
+ pr as SelectLabel,
1997
+ gr as SelectScrollDownButton,
1998
+ fr as SelectScrollUpButton,
1999
+ br as SelectSeparator,
2000
+ ve as SelectTrigger,
1956
2001
  ye as SelectValue,
1957
- Sa as SettingsDialog,
1958
- Xa as SharedChatView,
1959
- xa as SidebarProvider,
1960
- pr as TextPart,
1961
- gr as ToolPart,
1962
- Za as Trans,
1963
- er as Translation,
1964
- Wa as UserLoginPage,
1965
- fr as WelcomeScreen,
1966
- te as useComponents,
1967
- ra as useGentiqChat,
1968
- br as useGentiqUser,
1969
- tr as useTranslation,
1970
- E as userAPI,
1971
- ar as withTranslation
2002
+ Pa as SettingsDialog,
2003
+ Ja as SharedChatView,
2004
+ ya as SidebarProvider,
2005
+ xr as TextPart,
2006
+ vr as ToolPart,
2007
+ er as Trans,
2008
+ tr as Translation,
2009
+ Xa as UserLoginPage,
2010
+ yr as WelcomeScreen,
2011
+ wr as useChatReferences,
2012
+ re as useComponents,
2013
+ na as useGentiqChat,
2014
+ Nr as useGentiqUser,
2015
+ ar as useTranslation,
2016
+ D as userAPI,
2017
+ rr as withTranslation
1972
2018
  };