gentiq 0.8.3 → 0.10.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/dist/{checkbox-hWwU3a5K.js → checkbox-BuMyz6YI.js} +1722 -1753
  2. package/dist/gentiq-admin.es.js +4479 -3091
  3. package/dist/gentiq-index.es.js +1975 -1381
  4. package/dist/gentiq.css +1 -1
  5. package/dist/src/App.d.ts +1 -1
  6. package/dist/src/ComponentsContext.d.ts +1 -1
  7. package/dist/src/Part.d.ts +2 -1
  8. package/dist/src/admin/components/ErrorBanner.d.ts +7 -0
  9. package/dist/src/admin/components/I18nPreview.d.ts +6 -0
  10. package/dist/src/admin/components/ModalCloseButton.d.ts +7 -0
  11. package/dist/src/admin/components/SectionHeader.d.ts +8 -0
  12. package/dist/src/admin/lib/api.d.ts +192 -22
  13. package/dist/src/admin/pages/settings/ChatSection.d.ts +12 -0
  14. package/dist/src/admin/pages/settings/FieldModeGrid.d.ts +14 -0
  15. package/dist/src/admin/pages/settings/GeneralSection.d.ts +11 -0
  16. package/dist/src/admin/pages/settings/JobsSection.d.ts +1 -0
  17. package/dist/src/admin/pages/settings/SettingsToggleCard.d.ts +10 -0
  18. package/dist/src/admin/pages/settings/TranslationEditor.d.ts +9 -0
  19. package/dist/src/admin/pages/settings/types.d.ts +12 -0
  20. package/dist/src/admin/pages/users/UserBulkBalanceModal.d.ts +11 -0
  21. package/dist/src/admin/pages/users/UserFormModal.d.ts +13 -0
  22. package/dist/src/admin/pages/users/UserRechargeModal.d.ts +10 -0
  23. package/dist/src/admin/pages/users/UserUsageDialog.d.ts +9 -0
  24. package/dist/src/admin/pages/users/UsersTable.d.ts +21 -0
  25. package/dist/src/components/PromptInputArea.d.ts +1 -1
  26. package/dist/src/components/ai-elements/Conversation.d.ts +10 -0
  27. package/dist/src/hooks/useGentiqAdmin.d.ts +39 -12
  28. package/dist/src/hooks/useGentiqChat.d.ts +3 -2
  29. package/dist/src/index.d.ts +4 -3
  30. package/dist/src/lib/GentiqApiContext.d.ts +12 -0
  31. package/dist/src/lib/api.d.ts +37 -17
  32. package/dist/src/lib/errors.d.ts +6 -5
  33. package/dist/src/lib/messageParts.d.ts +40 -0
  34. package/dist/src/locales/en.json.d.ts +520 -456
  35. package/dist/src/locales/fa.json.d.ts +519 -455
  36. package/dist/src/parts/FilePart.d.ts +1 -1
  37. package/dist/src/parts/ToolPart.d.ts +1 -1
  38. package/dist/src/types.d.ts +188 -14
  39. package/package.json +5 -5
  40. package/dist/src/components/ai-elements/Branch.d.ts +0 -20
  41. package/dist/src/components/ai-elements/Image.d.ts +0 -6
  42. package/dist/src/components/ai-elements/InlineCitation.d.ts +0 -38
  43. package/dist/src/components/ai-elements/Task.d.ts +0 -14
  44. package/dist/src/components/ai-elements/WebPreview.d.ts +0 -34
  45. package/dist/src/components/ui/carousel.d.ts +0 -19
@@ -1,513 +1,861 @@
1
- import { jsx as e, jsxs as r, Fragment as ke } from "react/jsx-runtime";
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-hWwU3a5K.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-hWwU3a5K.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
- import { nanoid as he } from "nanoid";
16
- import { Slot as ea } from "@radix-ui/react-slot";
17
- import { cva as ta } from "class-variance-authority";
1
+ import { jsx as e, jsxs as s, Fragment as _e } from "react/jsx-runtime";
2
+ import * as se from "react";
3
+ import { useState as _, useMemo as Q, useEffect as B, useRef as re, useCallback as ee, useLayoutEffect as et } from "react";
4
+ import { QueryClient as tt, QueryClientProvider as at, useQueryClient as he, useQuery as rt, useInfiniteQuery as nt } from "@tanstack/react-query";
5
+ import { I18nextProvider as st, useTranslation as ue } from "react-i18next";
6
+ import { Trans as or, Translation as ir, useTranslation as lr, withTranslation as cr } from "react-i18next";
7
+ import { G as be, g as ot, d as it, a as lt, C as je, T as ct, u as ne, b as Oe, c as oe, j as xe, e as ge, f as de, h as He, i as v, k as dt, l as Ue, m as Be, n as Ke, o as Qe, B as ae, p as Ve, q as ye, D as Ge, r as ut, s as We, L as X, I as Y, S as we, t as Ne, v as ke, w as Se, x as fe, y as ht, z as pt, A as Me, E as mt, F as gt, H as ft, J as pe, K as bt, M as yt, N as vt, O as xt, P as wt, Q as Nt } from "./checkbox-BuMyz6YI.js";
8
+ import { R as ur, U as hr, V as pr, W as mr, X as gr, Y as fr, Z as br, _ as yr, $ as vr, a0 as xr, a1 as wr, a2 as Nr, a3 as kr, a4 as Sr, a5 as Cr, a6 as _r, a7 as Tr, a8 as Pr } from "./checkbox-BuMyz6YI.js";
9
+ import { Loader2Icon as kt, OctagonXIcon as St, TriangleAlertIcon as Ct, InfoIcon as _t, CircleCheckIcon as Tt, XIcon as Pt, PanelLeftIcon as Et, Layers as Ae, User as Mt, ShieldCheck as At, Settings as Ce, Smartphone as It, Lock as Rt, Save as Dt, Sun as $t, Moon as Lt, Monitor as Ft, Zap as Ie, Globe as qt, Coins as zt, LogOut as jt, CirclePlus as Ot, Plus as Ht, Search as Ut, Check as Bt, X as Kt, Pin as Re, MoreVertical as Qt, PinOff as Vt, Share2 as Gt, Pencil as Wt, Trash as Jt } from "lucide-react";
10
+ import { useTheme as Xt } from "next-themes";
11
+ import { Toaster as Yt, toast as te } from "sonner";
12
+ import { useChat as Zt } from "@ai-sdk/react";
13
+ import { DefaultChatTransport as ea } from "ai";
14
+ import { useLocation as Je, useNavigate as Te, Navigate as ta, useParams as aa } from "react-router-dom";
15
+ import { nanoid as me } from "nanoid";
16
+ import { Slot as ra } from "@radix-ui/react-slot";
17
+ import { cva as na } from "class-variance-authority";
18
18
  import "@radix-ui/react-separator";
19
- import * as ie from "@radix-ui/react-dialog";
20
- const aa = ({ ...a }) => {
21
- const { theme: t = "system" } = Gt();
19
+ import * as le from "@radix-ui/react-dialog";
20
+ const sa = ({ ...a }) => {
21
+ const { theme: t = "system" } = Xt();
22
22
  return /* @__PURE__ */ e(
23
- Wt,
23
+ Yt,
24
24
  {
25
25
  theme: t,
26
26
  className: "toaster group",
27
27
  icons: {
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" })
28
+ success: /* @__PURE__ */ e(Tt, { className: "size-4" }),
29
+ info: /* @__PURE__ */ e(_t, { className: "size-4" }),
30
+ warning: /* @__PURE__ */ e(Ct, { className: "size-4" }),
31
+ error: /* @__PURE__ */ e(St, { className: "size-4" }),
32
+ loading: /* @__PURE__ */ e(kt, { className: "size-4 animate-spin" })
33
33
  },
34
34
  style: {
35
35
  "--normal-bg": "var(--popover)",
36
36
  "--normal-text": "var(--popover-foreground)",
37
37
  "--normal-border": "var(--border)",
38
- "--border-radius": "var(--radius)"
38
+ "--border-radius": "var(--radius)",
39
+ fontFamily: "var(--gentiq-font-family)"
39
40
  },
40
41
  ...a
41
42
  }
42
43
  );
44
+ }, oa = () => ({
45
+ api: {
46
+ basePath: "/api"
47
+ },
48
+ app: {
49
+ basePath: "/",
50
+ cacheNamespace: "gentiq"
51
+ }
52
+ }), ia = {
53
+ getToken: () => localStorage.getItem("token"),
54
+ setToken: (a) => localStorage.setItem("token", a),
55
+ clearToken: () => {
56
+ localStorage.removeItem("token");
57
+ },
58
+ getHeaders: () => {
59
+ const a = localStorage.getItem("token");
60
+ return a ? { Authorization: `Bearer ${a}` } : {};
61
+ }
43
62
  };
44
- function Va({
63
+ function la(a) {
64
+ let t = oa(), d = ia;
65
+ const o = {
66
+ /**
67
+ * Merge new config into this instance. Safe to call repeatedly (e.g. when
68
+ * the provider re-resolves config after fetching dynamic settings).
69
+ */
70
+ configure: (n) => {
71
+ if (t = {
72
+ ...t,
73
+ ...n,
74
+ api: n.api ? { ...t.api, ...n.api } : t.api,
75
+ app: n.app ? { ...t.app, ...n.app } : t.app
76
+ }, n.api?.authAdapter) {
77
+ const i = n.api.authAdapter;
78
+ d = {
79
+ ...i,
80
+ getHeaders: i.getHeaders || (() => {
81
+ const r = i.getToken();
82
+ return r ? { Authorization: `Bearer ${r}` } : {};
83
+ })
84
+ };
85
+ }
86
+ },
87
+ getConfig: () => t,
88
+ getToken: () => d.getToken(),
89
+ setToken: (n) => {
90
+ d.setToken(n);
91
+ },
92
+ clearToken: () => {
93
+ d.clearToken();
94
+ },
95
+ getHeaders: () => d.getHeaders(),
96
+ getEndpoint: (n, i, ...r) => {
97
+ const u = t.api?.endpoints?.[n];
98
+ return u ? typeof u == "function" ? u(...r) : u : typeof i == "function" ? i(...r) : i;
99
+ },
100
+ handleResponse: async (n, i = "Request failed") => {
101
+ if (!n.ok) {
102
+ const r = await n.json().catch(() => ({}));
103
+ if (r.error && (typeof r.error.code == "string" || typeof r.error.message == "string"))
104
+ throw new be(r, n.status);
105
+ let u = i, c = "error", y = null;
106
+ throw typeof r.detail == "string" ? u = r.detail : typeof r.message == "string" ? u = r.message : typeof r.error == "string" ? u = r.error : Array.isArray(r.detail) ? (u = "Validation failed", y = r.detail, c = "validation_error") : r.error && typeof r.error.message == "string" && (u = r.error.message), new be(
107
+ {
108
+ error: {
109
+ code: c,
110
+ message: u,
111
+ details: y
112
+ }
113
+ },
114
+ n.status
115
+ );
116
+ }
117
+ return n.json();
118
+ },
119
+ login: async (n, i) => {
120
+ const r = o.getEndpoint("login", "/public/auth/login"), u = await fetch(`${t.api?.basePath}${r}`, {
121
+ method: "POST",
122
+ headers: { "Content-Type": "application/json" },
123
+ body: JSON.stringify({ phone: n, password: i })
124
+ }), c = await o.handleResponse(u, "Login failed");
125
+ return c.token && o.setToken(c.token), c;
126
+ },
127
+ register: async (n, i, r, u, c) => {
128
+ const y = o.getEndpoint("register", "/public/auth/register"), k = await fetch(`${t.api?.basePath}${y}`, {
129
+ method: "POST",
130
+ headers: { "Content-Type": "application/json" },
131
+ body: JSON.stringify({ phone: n, password: i, name: r, surname: u, metadata: c })
132
+ }), g = await o.handleResponse(k, "Registration failed");
133
+ return g.token && o.setToken(g.token), g;
134
+ },
135
+ getBalance: async () => {
136
+ const n = o.getEndpoint("balance", "/users/balance"), i = await fetch(`${t.api?.basePath}${n}`, {
137
+ headers: {
138
+ ...d.getHeaders()
139
+ }
140
+ });
141
+ return o.handleResponse(i, "Failed to fetch balance");
142
+ },
143
+ getHistory: async (n = 0, i = 50) => {
144
+ const r = o.getEndpoint("threads", "/chat/threads"), u = await fetch(`${t.api?.basePath}${r}?skip=${n}&limit=${i}`, {
145
+ headers: {
146
+ ...d.getHeaders()
147
+ }
148
+ });
149
+ return o.handleResponse(u, "Failed to fetch chat history");
150
+ },
151
+ getThreadMessages: async (n) => {
152
+ if (!o.getToken()) throw new Error("No token found");
153
+ const r = o.getEndpoint(
154
+ "threadMessages",
155
+ (c) => `/chat/threads/${c.replace(/^\//, "")}`,
156
+ n
157
+ ), u = await fetch(`${t.api?.basePath}${r}`, {
158
+ headers: {
159
+ ...d.getHeaders()
160
+ }
161
+ });
162
+ return o.handleResponse(u, "Failed to fetch thread messages");
163
+ },
164
+ deleteThread: async (n) => {
165
+ if (!o.getToken()) throw new Error("No token found");
166
+ const r = o.getEndpoint(
167
+ "deleteThread",
168
+ (c) => `/chat/threads/${c.replace(/^\//, "")}`,
169
+ n
170
+ ), u = await fetch(`${t.api?.basePath}${r}`, {
171
+ method: "DELETE",
172
+ headers: {
173
+ ...d.getHeaders()
174
+ }
175
+ });
176
+ return o.handleResponse(u, "Failed to delete thread");
177
+ },
178
+ updateThreadTitle: async (n, i) => {
179
+ if (!o.getToken()) throw new Error("No token found");
180
+ const u = o.getEndpoint(
181
+ "updateThreadTitle",
182
+ (y) => `/chat/threads/${y.replace(/^\//, "")}`,
183
+ n
184
+ ), c = await fetch(`${t.api?.basePath}${u}`, {
185
+ method: "PATCH",
186
+ headers: {
187
+ "Content-Type": "application/json",
188
+ ...d.getHeaders()
189
+ },
190
+ body: JSON.stringify({ title: i })
191
+ });
192
+ return o.handleResponse(c, "Failed to update thread title");
193
+ },
194
+ /**
195
+ * Fetch an attachment from the Minio-backed proxy endpoint and return
196
+ * a local blob URL usable in <img src>. Caller should revoke via
197
+ * URL.revokeObjectURL when the component unmounts.
198
+ */
199
+ async getAttachmentBlobUrl(n) {
200
+ if (t.api?.attachmentResolver)
201
+ return t.api.attachmentResolver(n);
202
+ const i = o.getEndpoint(
203
+ "attachments",
204
+ (c) => `/chat/attachments/${c}`,
205
+ n
206
+ ), r = await fetch(`${t.api?.basePath}${i}`, {
207
+ headers: { ...d.getHeaders() }
208
+ });
209
+ if (!r.ok) return o.handleResponse(r, "Failed to fetch attachment");
210
+ const u = await r.blob();
211
+ return URL.createObjectURL(u);
212
+ },
213
+ /**
214
+ * Fetch an attachment from the public shared endpoint and return
215
+ * a local blob URL.
216
+ */
217
+ async getPublicAttachmentBlobUrl(n) {
218
+ const i = o.getEndpoint(
219
+ "sharedAttachments",
220
+ (c) => `/public/attachments/${c}`,
221
+ n
222
+ ), r = await fetch(`${t.api?.basePath}${i}`, {
223
+ headers: {
224
+ "Content-Type": "application/json"
225
+ }
226
+ });
227
+ if (!r.ok) return o.handleResponse(r, "Failed to fetch public attachment");
228
+ const u = await r.blob();
229
+ return URL.createObjectURL(u);
230
+ },
231
+ saveFeedback: async (n, i, r) => {
232
+ const u = o.getEndpoint("feedback", "/chat/feedback"), c = await fetch(`${t.api?.basePath}${u}`, {
233
+ method: "POST",
234
+ headers: {
235
+ "Content-Type": "application/json",
236
+ ...d.getHeaders()
237
+ },
238
+ body: JSON.stringify({
239
+ thread_id: n.replace(/^\//, ""),
240
+ message_id: i,
241
+ sentiment: r
242
+ })
243
+ });
244
+ return o.handleResponse(c, "Failed to save feedback");
245
+ },
246
+ getMe: async () => {
247
+ const n = o.getEndpoint("me", "/users/me"), i = await fetch(`${t.api?.basePath}${n}`, {
248
+ headers: {
249
+ ...d.getHeaders()
250
+ }
251
+ });
252
+ return o.handleResponse(i, "Failed to fetch user profile");
253
+ },
254
+ updateMe: async (n) => {
255
+ const i = o.getEndpoint("me", "/users/me"), r = await fetch(`${t.api?.basePath}${i}`, {
256
+ method: "PATCH",
257
+ headers: {
258
+ "Content-Type": "application/json",
259
+ ...d.getHeaders()
260
+ },
261
+ body: JSON.stringify(n)
262
+ });
263
+ return o.handleResponse(r, "Failed to update user profile");
264
+ },
265
+ pinThread: async (n, i) => {
266
+ if (!o.getToken()) throw new Error("No token found");
267
+ const u = o.getEndpoint(
268
+ "updateThreadTitle",
269
+ (y) => `/chat/threads/${y.replace(/^\//, "")}`,
270
+ n
271
+ ), c = await fetch(`${t.api?.basePath}${u}`, {
272
+ method: "PATCH",
273
+ headers: {
274
+ "Content-Type": "application/json",
275
+ ...d.getHeaders()
276
+ },
277
+ body: JSON.stringify({ pinned: i })
278
+ });
279
+ return o.handleResponse(c, "Failed to pin thread");
280
+ },
281
+ shareThread: async (n) => {
282
+ if (!o.getToken()) throw new Error("No token found");
283
+ const r = o.getEndpoint(
284
+ "shareThread",
285
+ (c) => `/chat/threads/${c.replace(/^\//, "")}/share`,
286
+ n
287
+ ), u = await fetch(`${t.api?.basePath}${r}`, {
288
+ method: "POST",
289
+ headers: {
290
+ ...d.getHeaders()
291
+ }
292
+ });
293
+ return o.handleResponse(u, "Failed to share thread");
294
+ },
295
+ getSharedThread: async (n) => {
296
+ const i = o.getEndpoint("sharedThread", (u) => `/public/shared/${u}`, n), r = await fetch(`${t.api?.basePath}${i}`, {
297
+ headers: {
298
+ "Content-Type": "application/json"
299
+ }
300
+ });
301
+ return o.handleResponse(r, "Failed to fetch shared thread");
302
+ },
303
+ getAppConfig: async () => {
304
+ const n = await fetch(`${t.api?.basePath}/config`);
305
+ return o.handleResponse(n, "Failed to fetch app configuration");
306
+ }
307
+ };
308
+ return a && o.configure(a), o;
309
+ }
310
+ function Za({
45
311
  children: a,
46
312
  api: t,
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
- settings: C
313
+ app: d,
314
+ i18n: o,
315
+ components: n,
316
+ history: i,
317
+ welcome: r,
318
+ threadActions: u,
319
+ composer: c,
320
+ theme: y,
321
+ disclaimer: k,
322
+ settings: g
57
323
  }) {
58
- const [s, M] = T(null), P = O(
59
- () => m?.instance ?? nt,
60
- // eslint-disable-next-line react-hooks/exhaustive-deps
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 = {
324
+ const [p, A] = _(null), P = Q(() => o?.instance ?? ot, [o?.instance]), I = t || {}, [E] = _(() => la({ api: I }));
325
+ B(() => {
326
+ E.getAppConfig().then((w) => A(w)).catch((w) => console.debug("Gentiq: No dynamic settings available or fetch failed", w));
327
+ }, [E]), B(() => {
328
+ p?.app_name && (document.title = P.t(p.app_name));
329
+ }, [p, P]);
330
+ const R = Q(() => {
331
+ const w = {
70
332
  basePath: "/",
71
333
  cacheNamespace: "gentiq",
72
- ...i
334
+ ...d
73
335
  };
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;
336
+ return p ? {
337
+ ...w,
338
+ name: (p.app_name ? P.t(p.app_name) : null) || w.name,
339
+ adminTitle: (p.admin_title ? P.t(p.admin_title) : null) || w.adminTitle,
340
+ version: p.app_version || w.version,
341
+ showSettings: p.show_settings ?? w.showSettings,
342
+ showVersionInSettings: p.show_version_in_settings ?? w.showVersionInSettings,
343
+ showToolDetails: p.show_tool_details ?? w.showToolDetails,
344
+ disableSignup: p.disable_signup ?? w.disableSignup,
345
+ disableAuthPage: p.disable_auth_page ?? w.disableAuthPage,
346
+ settingsGeneralMode: p.settings_general_mode || w.settingsGeneralMode,
347
+ settingsProfileMode: p.settings_profile_mode || w.settingsProfileMode,
348
+ settingsAccountMode: p.settings_account_mode || w.settingsAccountMode
349
+ } : w;
350
+ }, [d, p, P]), D = Q(() => {
351
+ if (!p) return r;
352
+ const w = typeof r?.greeting == "function" ? r.greeting : p.welcome_greeting || r?.greeting;
91
353
  return {
92
- ...g,
93
- greeting: d,
94
- subtitle: s.welcome_subtitle || g?.subtitle
354
+ ...r,
355
+ greeting: w,
356
+ subtitle: p.welcome_subtitle || r?.subtitle
95
357
  };
96
- }, [g, s]), p = O(() => {
97
- const d = s?.disclaimer || y;
98
- return d && P.t(d);
99
- }, [y, s, P]), Q = O(() => s ? {
358
+ }, [r, p]), T = Q(() => {
359
+ const w = p?.disclaimer || k;
360
+ return typeof w == "string" ? P.t(w) : w;
361
+ }, [k, p, P]), q = Q(() => p ? {
362
+ ...i,
363
+ enabled: p.history_enabled ?? i?.enabled,
364
+ showDelete: p.history_show_delete ?? i?.showDelete,
365
+ showRename: p.history_show_rename ?? i?.showRename,
366
+ showShare: p.history_show_share ?? i?.showShare,
367
+ showPin: p.history_show_pin ?? i?.showPin
368
+ } : i, [i, p]), x = Q(() => p ? {
100
369
  ...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,
370
+ feedback: p.thread_actions_feedback ?? u?.feedback,
371
+ retry: p.thread_actions_retry ?? u?.retry
372
+ } : u, [u, p]), V = Q(() => p ? {
373
+ ...c,
112
374
  attachments: {
113
- ...h?.attachments,
114
- enabled: s.composer_attachments ?? h?.attachments?.enabled
375
+ ...c?.attachments,
376
+ enabled: p.composer_attachments ?? c?.attachments?.enabled
115
377
  }
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
- ...C,
378
+ } : c, [c, p]), K = Q(
379
+ () => ({
380
+ ...y,
381
+ defaultTheme: p?.default_theme ?? y?.defaultTheme,
382
+ accent: p?.default_accent ?? y?.accent
383
+ }),
384
+ [y, p]
385
+ ), M = Q(() => p ? {
386
+ ...g,
122
387
  sections: {
123
- ...C?.sections,
388
+ ...g?.sections,
124
389
  general: {
125
- ...C?.sections?.general,
126
- mode: s.settings_general_mode || C?.sections?.general?.mode,
127
- enabled: C?.sections?.general?.enabled ?? !0,
390
+ ...g?.sections?.general,
391
+ mode: p.settings_general_mode || g?.sections?.general?.mode,
392
+ enabled: g?.sections?.general?.enabled ?? !0,
128
393
  fields: {
129
- ...C?.sections?.general?.fields,
130
- ...s.settings_general_fields
394
+ ...g?.sections?.general?.fields,
395
+ ...p.settings_general_fields
131
396
  }
132
397
  },
133
398
  profile: {
134
- ...C?.sections?.profile,
135
- mode: s.settings_profile_mode || C?.sections?.profile?.mode,
136
- enabled: C?.sections?.profile?.enabled ?? !0,
399
+ ...g?.sections?.profile,
400
+ mode: p.settings_profile_mode || g?.sections?.profile?.mode,
401
+ enabled: g?.sections?.profile?.enabled ?? !0,
137
402
  fields: {
138
- ...C?.sections?.profile?.fields,
139
- ...s.settings_profile_fields
403
+ ...g?.sections?.profile?.fields,
404
+ ...p.settings_profile_fields
140
405
  }
141
406
  },
142
407
  account: {
143
- ...C?.sections?.account,
144
- mode: s.settings_account_mode || C?.sections?.account?.mode,
145
- enabled: C?.sections?.account?.enabled ?? !0,
408
+ ...g?.sections?.account,
409
+ mode: p.settings_account_mode || g?.sections?.account?.mode,
410
+ enabled: g?.sections?.account?.enabled ?? !0,
146
411
  fields: {
147
- ...C?.sections?.account?.fields,
148
- ...s.settings_account_fields
412
+ ...g?.sections?.account?.fields,
413
+ ...p.settings_account_fields
149
414
  }
150
415
  }
151
416
  }
152
- } : C, [C, s]), E = O(() => new Ze({
153
- defaultOptions: {
154
- queries: {
155
- staleTime: 5e3,
156
- retry: 1
417
+ } : g, [g, p]), $ = Q(
418
+ () => new tt({
419
+ defaultOptions: {
420
+ queries: {
421
+ staleTime: 5e3,
422
+ retry: 1
423
+ }
157
424
  }
158
- }
159
- }), []);
160
- $(() => {
161
- D.init({
162
- api: U,
163
- app: q
425
+ }),
426
+ []
427
+ );
428
+ B(() => {
429
+ E.configure({
430
+ api: I,
431
+ app: R
164
432
  });
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);
433
+ }, [E, R]);
434
+ const G = re(null), F = o?.resources;
435
+ F !== G.current && (G.current = F, F && Object.entries(F).forEach(([w, m]) => {
436
+ Object.entries(m).forEach(([C, f]) => {
437
+ P.addResourceBundle(w, C, f, !0, !0);
170
438
  });
171
439
  }));
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);
440
+ const J = re(null), W = p?.translations;
441
+ W && W !== J.current && (J.current = W, Object.entries(W).forEach(([w, m]) => {
442
+ Object.entries(m).forEach(([C, f]) => {
443
+ P.addResourceBundle(w, C, f, !0, !0);
176
444
  });
177
445
  }));
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);
446
+ const j = re(null), L = o?.instance;
447
+ return L && L !== j.current && (j.current = L, Object.entries(it).forEach(([w, m]) => {
448
+ Object.entries(m).forEach(([C, f]) => {
449
+ L.hasResourceBundle(w, C) || L.addResourceBundle(w, C, f, !0, !1);
182
450
  });
183
- })), /* @__PURE__ */ e(rt, { i18n: P, children: /* @__PURE__ */ r(et, { client: E, children: [
184
- /* @__PURE__ */ r(
185
- Fe,
451
+ })), /* @__PURE__ */ e(st, { i18n: P, children: /* @__PURE__ */ s(at, { client: $, children: [
452
+ /* @__PURE__ */ e(lt, { api: E, children: /* @__PURE__ */ s(
453
+ je,
186
454
  {
187
- components: c,
188
- history: Q,
189
- welcome: A,
455
+ components: n,
456
+ history: q,
457
+ welcome: D,
190
458
  threadActions: x,
191
- composer: B,
192
- theme: W,
193
- disclaimer: p,
194
- app: q,
195
- i18n: m,
196
- settings: K,
459
+ composer: V,
460
+ theme: K,
461
+ disclaimer: T,
462
+ app: R,
463
+ i18n: o,
464
+ settings: M,
197
465
  children: [
198
- /* @__PURE__ */ e(ra, {}),
199
- /* @__PURE__ */ e(ot, { defaultTheme: "system", storageKey: "chatbot-theme", config: W, children: a })
466
+ /* @__PURE__ */ e(ca, {}),
467
+ /* @__PURE__ */ e(ct, { defaultTheme: "system", storageKey: "chatbot-theme", config: K, children: a })
200
468
  ]
201
469
  }
202
- ),
203
- /* @__PURE__ */ e(aa, { richColors: !0 })
470
+ ) }),
471
+ /* @__PURE__ */ e(sa, { richColors: !0 })
204
472
  ] }) });
205
473
  }
206
- function ra() {
207
- const { app: a } = re();
208
- return je(), $(() => {
474
+ function ca() {
475
+ const { app: a } = ne();
476
+ return Oe(), B(() => {
209
477
  a?.name && (document.title = a.name);
210
- }, [a?.name]), $(() => {
478
+ }, [a?.name]), B(() => {
211
479
  if (!a?.favicon) return;
212
480
  let t = document.querySelector("link[rel~='icon']");
213
481
  t || (t = document.createElement("link"), t.rel = "icon", document.head.appendChild(t)), t.href = a.favicon;
214
482
  }, [a?.favicon]), null;
215
483
  }
216
- function Ce() {
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;
484
+ function Pe() {
485
+ const a = Je(), t = Te(), n = oe().getConfig().app?.basePath || "/", i = Q(() => {
486
+ const u = a.pathname, c = u.endsWith("/") && u !== "/" ? u.slice(0, -1) : u, y = n.endsWith("/") && n !== "/" ? n.slice(0, -1) : n;
487
+ if (c === (y || "/")) return "/";
488
+ if (u.startsWith(y) && y !== "/") {
489
+ let k = u.slice(y.length);
490
+ return k.startsWith("/") || (k = "/" + k), k;
223
491
  }
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];
492
+ return y === "/" ? u : "/";
493
+ }, [a.pathname, n]), r = ee(
494
+ (u) => {
495
+ t(xe(n, u || "/"), { replace: !1 });
496
+ },
497
+ [t, n]
498
+ );
499
+ return [i, r];
229
500
  }
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();
501
+ function da({ onFinish: a } = {}) {
502
+ const { t } = ue(["chat", "errors"]), d = he(), o = oe(), n = o.getConfig(), i = n.app?.cacheNamespace || "gentiq", [r, u] = Pe(), [c, y] = _(() => me()), k = re(/* @__PURE__ */ new Set());
503
+ B(() => {
504
+ y((f) => r === "/" ? me() : f && r !== `/${f}` ? me() : f);
505
+ }, [r]);
506
+ const g = Q(() => r === "/" ? c : r.replace(/^\//, ""), [r, c]), p = ee((f) => (k.current.add(f), f), []), A = ee(() => {
507
+ k.current.forEach((f) => URL.revokeObjectURL(f)), k.current.clear();
237
508
  }, []);
238
- $(() => () => s(), [s]);
509
+ B(() => () => A(), [A]);
239
510
  const {
240
- data: M,
241
- isLoading: P,
242
- isError: U
243
- } = tt({
244
- queryKey: [c, "threadMessages", y],
511
+ data: P,
512
+ isLoading: I,
513
+ isError: E
514
+ } = rt({
515
+ queryKey: [i, "threadMessages", g],
245
516
  queryFn: async () => {
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
- if (S.type === "file" && S.object_name && !S.url)
517
+ if (r === "/") return [];
518
+ if (r === `/${c}`) return [];
519
+ const f = await o.getThreadMessages(g);
520
+ return !f.items || !Array.isArray(f.items) ? [] : await Promise.all(
521
+ f.items.map(async (S) => {
522
+ const Z = typeof S.content == "string" ? S.content : S.content?.text || JSON.stringify(S.content), z = [...Array.isArray(S.parts) && S.parts.length > 0 ? S.parts : [{ type: "text", text: Z }]].sort((b, l) => b.type === "file" && l.type !== "file" ? -1 : b.type !== "file" && l.type === "file" ? 1 : 0), U = await Promise.all(
523
+ z.map(async (b) => {
524
+ if (b.type === "file" && b.object_name && !b.url)
254
525
  try {
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 };
526
+ const l = await o.getAttachmentBlobUrl(b.object_name);
527
+ return {
528
+ ...b,
529
+ url: p(l),
530
+ mediaType: b.mediaType || b.media_type
531
+ };
532
+ } catch (l) {
533
+ return console.warn("Load attachment failed:", b.object_name, l), { ...b, mediaType: b.mediaType || b.media_type };
259
534
  }
260
- return S;
535
+ return b;
261
536
  })
262
537
  );
263
538
  return {
264
- id: d.id || he(),
265
- role: d.role,
266
- parts: j,
267
- metadata: { feedback: d.feedback }
539
+ id: S.id || me(),
540
+ role: S.role,
541
+ parts: U,
542
+ metadata: { feedback: S.feedback }
268
543
  };
269
544
  })
270
545
  );
271
546
  },
272
- enabled: u !== "/",
547
+ enabled: r !== "/",
273
548
  staleTime: 5e3
274
549
  // Keep history fresh for 5 seconds
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
- if (!S.ok) {
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
- error: {
290
- code: Y,
291
- message: z,
292
- details: Z
293
- }
294
- }, S.status);
550
+ }), R = Q(
551
+ () => new ea({
552
+ api: o.getEndpoint("chat", "/chat"),
553
+ fetch: async (f, O) => {
554
+ const S = new Headers(O?.headers), Z = o.getHeaders();
555
+ Object.entries(Z).forEach(([b, l]) => {
556
+ S.set(b, l);
557
+ }), S.set("X-Thread-Id", g);
558
+ const H = n.api?.basePath || "/api", z = typeof f == "string" && !f.startsWith("http") ? `${H}${f.startsWith("/") ? f : "/" + f}` : f, U = await fetch(z, { ...O, headers: S });
559
+ if (!U.ok) {
560
+ const b = await U.json().catch(() => ({}));
561
+ if (b.error && (typeof b.error.code == "string" || typeof b.error.message == "string"))
562
+ throw new be(b, U.status);
563
+ let l = U.statusText || `HTTP ${U.status}`, h = "error", N = null;
564
+ throw typeof b.detail == "string" ? l = b.detail : typeof b.message == "string" ? l = b.message : typeof b.error == "string" ? l = b.error : Array.isArray(b.detail) ? (l = "Validation failed", N = b.detail, h = "validation_error") : b.error && typeof b.error.message == "string" && (l = b.error.message), new be(
565
+ {
566
+ error: {
567
+ code: h,
568
+ message: l,
569
+ details: N
570
+ }
571
+ },
572
+ U.status
573
+ );
574
+ }
575
+ return U;
295
576
  }
296
- return S;
297
- }
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);
577
+ }),
578
+ [g, n.api?.basePath, o]
579
+ ), D = ee(() => {
580
+ M("ready"), d.invalidateQueries({ queryKey: [i, "conversations"] }), a?.();
581
+ }, [d, a, i]), T = Zt({
582
+ id: g,
583
+ onFinish: D,
584
+ transport: R
585
+ }), { setMessages: q, sendMessage: x, stop: V } = T, [K, M] = _("idle"), [$, G] = _(null), F = ee(() => {
586
+ G(null);
306
587
  }, []);
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");
588
+ B(() => {
589
+ P && (r === `/${c}` || (q(P), M("ready")));
590
+ }, [P, q, r, c]), B(() => {
591
+ r === "/" && (q([]), M("idle"));
592
+ }, [r, q]), B(() => {
593
+ if (r === "/") {
594
+ M("idle");
314
595
  return;
315
596
  }
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);
597
+ const f = r === `/${c}`;
598
+ I && !f ? M("loading-history") : E || $ || T.error ? M("error") : T.status === "streaming" || T.status === "submitted" ? M(T.status) : M("ready");
599
+ }, [
600
+ I,
601
+ E,
602
+ T.status,
603
+ $,
604
+ T.error,
605
+ r,
606
+ c
607
+ ]), B(() => () => {
608
+ V();
609
+ }, [g, V]);
610
+ const J = re(/* @__PURE__ */ new Set()), W = Q(
611
+ () => T.messages.filter((f) => f.role === "assistant"),
612
+ [T.messages]
613
+ );
614
+ B(() => {
615
+ let f = !1;
616
+ for (const O of W) {
617
+ if (J.current.has(O.id)) continue;
618
+ const S = O.parts.find((H) => H.type === "data-title");
619
+ (S ? ge(S) : void 0)?.data?.[0]?.title && (J.current.add(O.id), f = !0);
328
620
  }
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 : []];
621
+ f && d.invalidateQueries({ queryKey: [i, "conversations"] });
622
+ }, [W, d, i]);
623
+ const j = re(null), L = ee(
624
+ (f) => {
625
+ if (f.length === 0) return;
626
+ const O = f.map((S) => ({
627
+ type: "data-reference",
628
+ data: S
629
+ }));
630
+ q((S) => {
631
+ const Z = new Set(f.map((b) => b.id));
632
+ if (S.some(
633
+ (b) => b.parts.some(
634
+ (l) => l.type === "data-reference" && Z.has(ge(l).data?.id)
635
+ )
636
+ )) return S;
637
+ const z = [...S].reverse().findIndex(
638
+ (b) => b.role === "user" && !b.parts.some((l) => l.type === "data-reference")
639
+ );
640
+ if (z === -1) return S;
641
+ const U = S.length - 1 - z;
642
+ return S.map((b, l) => l !== U ? b : {
643
+ ...b,
644
+ metadata: {
645
+ ...b.metadata || {},
646
+ references: f
647
+ },
648
+ parts: [...O, ...b.parts]
372
649
  });
373
- }
374
- x("submitted"), W(null);
375
- try {
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");
385
- }
650
+ });
651
+ },
652
+ [q]
653
+ );
654
+ B(() => {
655
+ const f = j.current;
656
+ if (!f) return;
657
+ const O = new Set(f.map((H) => H.id));
658
+ if (T.messages.some(
659
+ (H) => H.parts.some(
660
+ (z) => z.type === "data-reference" && O.has(ge(z).data?.id)
661
+ )
662
+ )) {
663
+ j.current = null;
664
+ return;
386
665
  }
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(() => {
390
- if (B) return B;
391
- if (p.error) {
392
- const b = ce(p.error, t);
393
- return new Error(b);
666
+ T.messages.some(
667
+ (H) => H.role === "user" && !H.parts.some((z) => z.type === "data-reference")
668
+ ) && (L(f), j.current = null);
669
+ }, [T.messages, L]);
670
+ const w = ee(
671
+ async (f, O, S = []) => {
672
+ const Z = r === "/", H = f.trim();
673
+ if (!(!H && (!O || O.length === 0) && S.length === 0) && !(K === "loading-history" || K === "streaming" || K === "submitted")) {
674
+ if (V(), Z) {
675
+ u(`/${g}`);
676
+ const z = H || (S[0]?.excerpt ? `↳ ${S[0].excerpt}` : t("attach_file")), U = z.length > 30 ? z.slice(0, 30) + "..." : z;
677
+ d.setQueryData([i, "conversations"], (b) => {
678
+ const l = {
679
+ id: `/${g}`,
680
+ firstMessage: U,
681
+ timestamp: Date.now()
682
+ };
683
+ return !b || !Array.isArray(b.pages) ? {
684
+ pages: [{ threads: [l], nextSkip: 0, hasMore: !1 }],
685
+ pageParams: [0]
686
+ } : {
687
+ ...b,
688
+ pages: b.pages.map(
689
+ (h, N) => N === 0 ? { ...h, threads: [l, ...h.threads || []] } : h
690
+ )
691
+ };
692
+ });
693
+ }
694
+ M("submitted"), G(null), j.current = S.length > 0 ? S : null;
695
+ try {
696
+ S.length > 0 ? await x({ text: H, files: O }, { body: { references: S } }) : await x({ text: H, files: O });
697
+ } catch (z) {
698
+ console.error("Failed to send message:", z);
699
+ const U = de(z, t);
700
+ G(new Error(U)), M("error");
701
+ }
702
+ }
703
+ },
704
+ [
705
+ V,
706
+ x,
707
+ u,
708
+ r,
709
+ g,
710
+ t,
711
+ d,
712
+ K,
713
+ i
714
+ ]
715
+ ), m = ee(() => {
716
+ V(), M("ready"), d.invalidateQueries({ queryKey: [i, "conversations"] });
717
+ }, [V, d, i]), C = Q(() => {
718
+ if ($) return $;
719
+ if (T.error) {
720
+ const f = de(T.error, t);
721
+ return new Error(f);
394
722
  }
395
723
  return null;
396
- }, [B, p.error, t]);
397
- return O(() => ({
398
- ...p,
399
- sendMessage: L,
400
- stop: H,
401
- clearError: K,
402
- error: F,
403
- status: Q,
404
- // Cast to any to satisfy Chat.tsx expectations of AI SDK statuses
405
- isLoadingHistory: Q === "loading-history",
406
- isErrorHistory: Q === "error" || !!F || U,
407
- conversationId: u
408
- }), [p, L, H, K, F, Q, U, u]);
724
+ }, [$, T.error, t]);
725
+ return Q(
726
+ () => ({
727
+ ...T,
728
+ sendMessage: w,
729
+ stop: m,
730
+ clearError: F,
731
+ error: C,
732
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any -- ChatStatus is a superset of the AI SDK status union expected downstream
733
+ status: K,
734
+ isLoadingHistory: K === "loading-history",
735
+ isErrorHistory: K === "error" || !!C || E,
736
+ conversationId: r
737
+ }),
738
+ [T, w, m, F, C, K, E, r]
739
+ );
409
740
  }
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);
741
+ function ua({ classNames: a = {}, disclaimer: t }) {
742
+ const { t: d, i18n: o } = ue(["chat", "translation"]), n = da(), {
743
+ messages: i,
744
+ status: r,
745
+ regenerate: u,
746
+ error: c,
747
+ clearError: y,
748
+ stop: k,
749
+ isLoadingHistory: g,
750
+ conversationId: p,
751
+ sendMessage: A
752
+ } = n, { MessageList: P, PromptInput: I, composer: E, disclaimer: R } = ne(), D = t ?? R, T = o.exists("chat:disclaimer") ? d("chat:disclaimer") : null, q = typeof D == "string" ? d(D) : D ?? T, [x, V] = _(null), K = re(r);
753
+ et(() => {
754
+ c && y();
755
+ }, [p, y, c]);
756
+ const M = i[i.length - 1], $ = M?.role === "assistant" && (r === "ready" || M.parts.some((F) => F.type === "data-chat-finished"));
757
+ B(() => {
758
+ r === "error" && K.current !== "error" && x !== p ? V(p) : r === "submitted" && x !== null && V(null), K.current = r;
759
+ }, [r, p]);
760
+ const G = r === "error" && (p === "/" || x === p);
420
761
  return /* @__PURE__ */ e(
421
- Oe,
762
+ He,
422
763
  {
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: [
764
+ enabled: E?.references?.enabled ?? !0,
765
+ maxItems: E?.references?.maxItems,
766
+ maxExcerptLength: E?.references?.maxExcerptLength,
767
+ children: /* @__PURE__ */ s("div", { className: v("relative flex flex-col h-full overflow-hidden", a.container), children: [
427
768
  /* @__PURE__ */ e(
428
769
  P,
429
770
  {
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,
771
+ messages: i,
772
+ status: r,
773
+ isLoadingHistory: g,
774
+ error: G ? c : null,
775
+ conversationId: p,
776
+ regen: (F) => u({ messageId: F }),
777
+ onSuggestionClick: (F) => A(F),
778
+ chat: n,
438
779
  className: v("flex-1", a.messageList)
439
780
  }
440
781
  ),
441
- /* @__PURE__ */ r("div", { className: "absolute bottom-0 left-0 right-0 z-10 pointer-events-none flex flex-col items-stretch", children: [
782
+ /* @__PURE__ */ s("div", { className: "absolute bottom-0 left-0 right-0 z-10 pointer-events-none flex flex-col items-stretch", children: [
442
783
  /* @__PURE__ */ e(
443
- U,
784
+ I,
444
785
  {
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")
786
+ onSend: A,
787
+ status: r,
788
+ isLastMessageFinished: $,
789
+ stop: k,
790
+ isErrorVisible: G,
791
+ conversationId: p,
792
+ className: v(
793
+ "pointer-events-auto",
794
+ a.inputArea,
795
+ q && "pb-0 md:pb-0"
796
+ )
452
797
  }
453
798
  ),
454
- x && /* @__PURE__ */ r("div", { className: "relative py-1 px-4 flex justify-center items-center pointer-events-auto", children: [
799
+ q && /* @__PURE__ */ s("div", { className: "relative py-1 px-4 flex justify-center items-center pointer-events-auto", children: [
455
800
  /* @__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 })
801
+ /* @__PURE__ */ e("p", { className: "text-[10px] md:text-[11px] text-muted-foreground/60 select-none text-center leading-tight", children: q })
457
802
  ] })
458
803
  ] })
459
804
  ] })
460
805
  }
461
806
  );
462
807
  }
463
- const oa = ({
808
+ const ha = ({
464
809
  components: a,
465
810
  history: t,
466
- welcome: i,
467
- threadActions: m,
468
- composer: c,
469
- theme: u,
470
- disclaimer: g,
471
- ...f
811
+ welcome: d,
812
+ threadActions: o,
813
+ composer: n,
814
+ theme: i,
815
+ disclaimer: r,
816
+ ...u
472
817
  }) => {
473
- const h = re(), N = O(() => ({
474
- ...h,
475
- ...a,
476
- toolComponents: {
477
- ...h.toolComponents,
478
- ...a?.toolComponents
479
- },
480
- referenceAdapters: {
481
- ...h.referenceAdapters,
482
- ...a?.referenceAdapters
483
- }
484
- }), [h, a]);
818
+ const c = ne(), y = Q(
819
+ () => ({
820
+ ...c,
821
+ ...a,
822
+ toolComponents: {
823
+ ...c.toolComponents,
824
+ ...a?.toolComponents
825
+ },
826
+ referenceAdapters: {
827
+ ...c.referenceAdapters,
828
+ ...a?.referenceAdapters
829
+ }
830
+ }),
831
+ [c, a]
832
+ );
485
833
  return /* @__PURE__ */ e(
486
- Fe,
834
+ je,
487
835
  {
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 })
836
+ components: y,
837
+ history: t ?? c.history,
838
+ welcome: d ?? c.welcome,
839
+ threadActions: o ?? c.threadActions,
840
+ composer: n ?? c.composer,
841
+ theme: i ?? c.theme,
842
+ disclaimer: r ?? c.disclaimer,
843
+ app: c.app,
844
+ i18n: c.i18n,
845
+ settings: c.settings,
846
+ children: /* @__PURE__ */ e(ua, { ...u })
499
847
  }
500
848
  );
501
849
  };
502
- function ia({ ...a }) {
503
- return /* @__PURE__ */ e(ie.Root, { "data-slot": "sheet", ...a });
850
+ function pa({ ...a }) {
851
+ return /* @__PURE__ */ e(le.Root, { "data-slot": "sheet", ...a });
504
852
  }
505
- function la({ ...a }) {
506
- return /* @__PURE__ */ e(ie.Portal, { "data-slot": "sheet-portal", ...a });
853
+ function ma({ ...a }) {
854
+ return /* @__PURE__ */ e(le.Portal, { "data-slot": "sheet-portal", ...a });
507
855
  }
508
- function ca({ className: a, ...t }) {
856
+ function ga({ className: a, ...t }) {
509
857
  return /* @__PURE__ */ e(
510
- ie.Overlay,
858
+ le.Overlay,
511
859
  {
512
860
  "data-slot": "sheet-overlay",
513
861
  className: v(
@@ -518,31 +866,31 @@ function ca({ className: a, ...t }) {
518
866
  }
519
867
  );
520
868
  }
521
- function da({
869
+ function fa({
522
870
  className: a,
523
871
  children: t,
524
- side: i = "right",
525
- ...m
872
+ side: d = "right",
873
+ ...o
526
874
  }) {
527
- return /* @__PURE__ */ r(la, { children: [
528
- /* @__PURE__ */ e(ca, {}),
529
- /* @__PURE__ */ r(
530
- ie.Content,
875
+ return /* @__PURE__ */ s(ma, { children: [
876
+ /* @__PURE__ */ e(ga, {}),
877
+ /* @__PURE__ */ s(
878
+ le.Content,
531
879
  {
532
880
  "data-slot": "sheet-content",
533
881
  className: v(
534
882
  "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",
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",
883
+ d === "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",
884
+ d === "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",
885
+ d === "top" && "data-[state=closed]:slide-out-to-top data-[state=open]:slide-in-from-top inset-x-0 top-0 h-auto border-b",
886
+ d === "bottom" && "data-[state=closed]:slide-out-to-bottom data-[state=open]:slide-in-from-bottom inset-x-0 bottom-0 h-auto border-t",
539
887
  a
540
888
  ),
541
- ...m,
889
+ ...o,
542
890
  children: [
543
891
  t,
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" }),
892
+ /* @__PURE__ */ s(le.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: [
893
+ /* @__PURE__ */ e(Pt, { className: "size-4" }),
546
894
  /* @__PURE__ */ e("span", { className: "sr-only", children: "Close" })
547
895
  ] })
548
896
  ]
@@ -550,12 +898,12 @@ function da({
550
898
  )
551
899
  ] });
552
900
  }
553
- function ua({ className: a, ...t }) {
901
+ function ba({ className: a, ...t }) {
554
902
  return /* @__PURE__ */ e("div", { "data-slot": "sheet-header", className: v("flex flex-col gap-1.5 p-4", a), ...t });
555
903
  }
556
- function ma({ className: a, ...t }) {
904
+ function ya({ className: a, ...t }) {
557
905
  return /* @__PURE__ */ e(
558
- ie.Title,
906
+ le.Title,
559
907
  {
560
908
  "data-slot": "sheet-title",
561
909
  className: v("text-foreground font-semibold", a),
@@ -563,9 +911,9 @@ function ma({ className: a, ...t }) {
563
911
  }
564
912
  );
565
913
  }
566
- function ha({ className: a, ...t }) {
914
+ function va({ className: a, ...t }) {
567
915
  return /* @__PURE__ */ e(
568
- ie.Description,
916
+ le.Description,
569
917
  {
570
918
  "data-slot": "sheet-description",
571
919
  className: v("text-muted-foreground text-sm", a),
@@ -573,109 +921,109 @@ function ha({ className: a, ...t }) {
573
921
  }
574
922
  );
575
923
  }
576
- const pa = "sidebar_state", ga = 3600 * 24 * 7, fa = "19rem", ba = "18rem", xa = "3rem", va = "b", We = ne.createContext(null);
577
- function fe() {
578
- const a = ne.useContext(We);
924
+ const xa = "sidebar_state", wa = 3600 * 24 * 7, Na = "19rem", ka = "18rem", Sa = "3rem", Ca = "b", Xe = se.createContext(null);
925
+ function ve() {
926
+ const a = se.useContext(Xe);
579
927
  if (!a)
580
928
  throw new Error("useSidebar must be used within a SidebarProvider.");
581
929
  return a;
582
930
  }
583
- function ya({
931
+ function _a({
584
932
  defaultOpen: a = !0,
585
933
  open: t,
586
- onOpenChange: i,
587
- className: m,
588
- style: c,
589
- children: u,
590
- ...g
934
+ onOpenChange: d,
935
+ className: o,
936
+ style: n,
937
+ children: i,
938
+ ...r
591
939
  }) {
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}`;
940
+ const u = dt(), [c, y] = se.useState(!1), [k, g] = se.useState(a), p = t ?? k, A = se.useCallback(
941
+ (R) => {
942
+ const D = typeof R == "function" ? R(p) : R;
943
+ d ? d(D) : g(D), document.cookie = `${xa}=${D}; path=/; max-age=${wa}`;
596
944
  },
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());
945
+ [d, p]
946
+ ), P = se.useCallback(() => {
947
+ u ? y((R) => !R) : A((R) => !R);
948
+ }, [u, A, y]);
949
+ se.useEffect(() => {
950
+ const R = (D) => {
951
+ D.key === Ca && (D.metaKey || D.ctrlKey) && (D.preventDefault(), P());
604
952
  };
605
- return window.addEventListener("keydown", A), () => {
606
- window.removeEventListener("keydown", A);
953
+ return window.addEventListener("keydown", R), () => {
954
+ window.removeEventListener("keydown", R);
607
955
  };
608
956
  }, [P]);
609
- const U = s ? "expanded" : "collapsed", q = ne.useMemo(
957
+ const I = p ? "expanded" : "collapsed", E = se.useMemo(
610
958
  () => ({
611
- state: U,
612
- open: s,
613
- setOpen: M,
614
- isMobile: f,
615
- openMobile: h,
616
- setOpenMobile: N,
959
+ state: I,
960
+ open: p,
961
+ setOpen: A,
962
+ isMobile: u,
963
+ openMobile: c,
964
+ setOpenMobile: y,
617
965
  toggleSidebar: P
618
966
  }),
619
- [U, s, M, f, h, N, P]
967
+ [I, p, A, u, c, y, P]
620
968
  );
621
- return /* @__PURE__ */ e(We.Provider, { value: q, children: /* @__PURE__ */ e($e, { delayDuration: 0, children: /* @__PURE__ */ e(
969
+ return /* @__PURE__ */ e(Xe.Provider, { value: E, children: /* @__PURE__ */ e(Ue, { delayDuration: 0, children: /* @__PURE__ */ e(
622
970
  "div",
623
971
  {
624
972
  "data-slot": "sidebar-wrapper",
625
973
  style: {
626
- "--sidebar-width": fa,
627
- "--sidebar-width-icon": xa,
628
- ...c
974
+ "--sidebar-width": Na,
975
+ "--sidebar-width-icon": Sa,
976
+ ...n
629
977
  },
630
- className: v("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full", m),
631
- ...g,
632
- children: u
978
+ className: v("group/sidebar-wrapper has-data-[variant=inset]:bg-sidebar flex min-h-svh w-full", o),
979
+ ...r,
980
+ children: i
633
981
  }
634
982
  ) }) });
635
983
  }
636
- function wa({
984
+ function Ta({
637
985
  side: a = "left",
638
986
  variant: t = "sidebar",
639
- collapsible: i = "offcanvas",
640
- className: m,
641
- children: c,
642
- ...u
987
+ collapsible: d = "offcanvas",
988
+ className: o,
989
+ children: n,
990
+ ...i
643
991
  }) {
644
- const { isMobile: g, state: f, openMobile: h, setOpenMobile: N } = fe();
645
- return i === "none" ? /* @__PURE__ */ e(
992
+ const { isMobile: r, state: u, openMobile: c, setOpenMobile: y } = ve();
993
+ return d === "none" ? /* @__PURE__ */ e(
646
994
  "div",
647
995
  {
648
996
  "data-slot": "sidebar",
649
- className: v("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col", m),
650
- ...u,
651
- children: c
997
+ className: v("bg-sidebar text-sidebar-foreground flex h-full w-(--sidebar-width) flex-col", o),
998
+ ...i,
999
+ children: n
652
1000
  }
653
- ) : g ? /* @__PURE__ */ e(ia, { open: h, onOpenChange: N, ...u, children: /* @__PURE__ */ r(
654
- da,
1001
+ ) : r ? /* @__PURE__ */ e(pa, { open: c, onOpenChange: y, ...i, children: /* @__PURE__ */ s(
1002
+ fa,
655
1003
  {
656
- onOpenAutoFocus: (y) => y.preventDefault(),
1004
+ onOpenAutoFocus: (k) => k.preventDefault(),
657
1005
  "data-sidebar": "sidebar",
658
1006
  "data-slot": "sidebar",
659
1007
  "data-mobile": "true",
660
1008
  className: "bg-sidebar text-sidebar-foreground w-(--sidebar-width) p-0 [&>button]:hidden",
661
1009
  style: {
662
- "--sidebar-width": ba
1010
+ "--sidebar-width": ka
663
1011
  },
664
1012
  side: a,
665
1013
  children: [
666
- /* @__PURE__ */ r(ua, { className: "sr-only", children: [
667
- /* @__PURE__ */ e(ma, { children: "Sidebar" }),
668
- /* @__PURE__ */ e(ha, { children: "Displays the mobile sidebar." })
1014
+ /* @__PURE__ */ s(ba, { className: "sr-only", children: [
1015
+ /* @__PURE__ */ e(ya, { children: "Sidebar" }),
1016
+ /* @__PURE__ */ e(va, { children: "Displays the mobile sidebar." })
669
1017
  ] }),
670
- /* @__PURE__ */ e("div", { className: "flex h-full w-full flex-col", children: c })
1018
+ /* @__PURE__ */ e("div", { className: "flex h-full w-full flex-col", children: n })
671
1019
  ]
672
1020
  }
673
- ) }) : /* @__PURE__ */ r(
1021
+ ) }) : /* @__PURE__ */ s(
674
1022
  "div",
675
1023
  {
676
1024
  className: "group peer text-sidebar-foreground hidden md:block",
677
- "data-state": f,
678
- "data-collapsible": f === "collapsed" ? i : "",
1025
+ "data-state": u,
1026
+ "data-collapsible": u === "collapsed" ? d : "",
679
1027
  "data-variant": t,
680
1028
  "data-side": a,
681
1029
  "data-slot": "sidebar",
@@ -701,16 +1049,16 @@ function wa({
701
1049
  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)]",
702
1050
  // Adjust the padding for floating and inset variants.
703
1051
  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",
704
- m
1052
+ o
705
1053
  ),
706
- ...u,
1054
+ ...i,
707
1055
  children: /* @__PURE__ */ e(
708
1056
  "div",
709
1057
  {
710
1058
  "data-sidebar": "sidebar",
711
1059
  "data-slot": "sidebar-inner",
712
1060
  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",
713
- children: c
1061
+ children: n
714
1062
  }
715
1063
  )
716
1064
  }
@@ -719,28 +1067,28 @@ function wa({
719
1067
  }
720
1068
  );
721
1069
  }
722
- function Na({ className: a, onClick: t, ...i }) {
723
- const { toggleSidebar: m } = fe();
724
- return /* @__PURE__ */ r(
725
- te,
1070
+ function Pa({ className: a, onClick: t, ...d }) {
1071
+ const { toggleSidebar: o } = ve();
1072
+ return /* @__PURE__ */ s(
1073
+ ae,
726
1074
  {
727
1075
  "data-sidebar": "trigger",
728
1076
  "data-slot": "sidebar-trigger",
729
1077
  variant: "ghost",
730
1078
  size: "icon",
731
1079
  className: v("size-7", a),
732
- onClick: (c) => {
733
- t?.(c), m();
1080
+ onClick: (n) => {
1081
+ t?.(n), o();
734
1082
  },
735
- ...i,
1083
+ ...d,
736
1084
  children: [
737
- /* @__PURE__ */ e(St, {}),
1085
+ /* @__PURE__ */ e(Et, {}),
738
1086
  /* @__PURE__ */ e("span", { className: "sr-only", children: "Toggle Sidebar" })
739
1087
  ]
740
1088
  }
741
1089
  );
742
1090
  }
743
- function ka({ className: a, ...t }) {
1091
+ function Ea({ className: a, ...t }) {
744
1092
  return /* @__PURE__ */ e(
745
1093
  "div",
746
1094
  {
@@ -751,7 +1099,7 @@ function ka({ className: a, ...t }) {
751
1099
  }
752
1100
  );
753
1101
  }
754
- function _a({ className: a, ...t }) {
1102
+ function Ma({ className: a, ...t }) {
755
1103
  return /* @__PURE__ */ e(
756
1104
  "div",
757
1105
  {
@@ -765,7 +1113,7 @@ function _a({ className: a, ...t }) {
765
1113
  }
766
1114
  );
767
1115
  }
768
- function Ca({ className: a, ...t }) {
1116
+ function Aa({ className: a, ...t }) {
769
1117
  return /* @__PURE__ */ e(
770
1118
  "div",
771
1119
  {
@@ -776,7 +1124,7 @@ function Ca({ className: a, ...t }) {
776
1124
  }
777
1125
  );
778
1126
  }
779
- function Ae({ className: a, ...t }) {
1127
+ function De({ className: a, ...t }) {
780
1128
  return /* @__PURE__ */ e(
781
1129
  "div",
782
1130
  {
@@ -787,7 +1135,7 @@ function Ae({ className: a, ...t }) {
787
1135
  }
788
1136
  );
789
1137
  }
790
- function Ee({ className: a, ...t }) {
1138
+ function $e({ className: a, ...t }) {
791
1139
  return /* @__PURE__ */ e(
792
1140
  "ul",
793
1141
  {
@@ -809,7 +1157,7 @@ function Le({ className: a, ...t }) {
809
1157
  }
810
1158
  );
811
1159
  }
812
- const Sa = ta(
1160
+ const Ia = na(
813
1161
  "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",
814
1162
  {
815
1163
  variants: {
@@ -829,476 +1177,636 @@ const Sa = ta(
829
1177
  }
830
1178
  }
831
1179
  );
832
- function Re({
1180
+ function Fe({
833
1181
  asChild: a = !1,
834
1182
  isActive: t = !1,
835
- variant: i = "default",
836
- size: m = "default",
837
- tooltip: c,
838
- className: u,
839
- ...g
1183
+ variant: d = "default",
1184
+ size: o = "default",
1185
+ tooltip: n,
1186
+ className: i,
1187
+ ...r
840
1188
  }) {
841
- const f = a ? ea : "button", { isMobile: h, state: N } = fe(), y = /* @__PURE__ */ e(
842
- f,
1189
+ const u = a ? ra : "button", { isMobile: c, state: y } = ve(), k = /* @__PURE__ */ e(
1190
+ u,
843
1191
  {
844
1192
  "data-slot": "sidebar-menu-button",
845
1193
  "data-sidebar": "menu-button",
846
- "data-size": m,
1194
+ "data-size": o,
847
1195
  "data-active": t,
848
- className: v(Sa({ variant: i, size: m }), u),
849
- ...g
1196
+ className: v(Ia({ variant: d, size: o }), i),
1197
+ ...r
850
1198
  }
851
1199
  );
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;
1200
+ return n ? (typeof n == "string" && (n = {
1201
+ children: n
1202
+ }), /* @__PURE__ */ s(Be, { children: [
1203
+ /* @__PURE__ */ e(Ke, { asChild: !0, children: k }),
1204
+ /* @__PURE__ */ e(Qe, { side: "right", align: "center", hidden: y !== "collapsed" || c, ...n })
1205
+ ] })) : k;
858
1206
  }
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(() => [
861
- { id: "general", label: t("sections.general", "General"), icon: Me },
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];
866
- return (_?.mode ?? (_?.enabled === !1 ? "hidden" : "editable")) !== "hidden";
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 () => {
1207
+ function Ra({ trigger: a }) {
1208
+ const { t, i18n: d } = ue(["settings", "translation"]), { app: o, settings: n } = ne(), i = oe(), r = he(), { theme: u, setTheme: c, accent: y, setAccent: k, radius: g, setRadius: p } = Ve(), [A, P] = _(null), [I, E] = _(!1), R = re(null), D = Q(() => [
1209
+ { id: "general", label: t("sections.general", "General"), icon: Ae },
1210
+ { id: "profile", label: t("sections.profile", "Profile"), icon: Mt },
1211
+ { id: "account", label: t("sections.account", "Account"), icon: At }
1212
+ ].filter((h) => {
1213
+ const N = n?.sections?.[h.id];
1214
+ return (N?.mode ?? (N?.enabled === !1 ? "hidden" : "editable")) !== "hidden";
1215
+ }), [t, n]), [T, q] = _(D[0]?.id || "general"), x = ee(
1216
+ (l, h, N = "editable") => {
1217
+ const ie = n?.sections?.[l]?.fields;
1218
+ return ie && ie[h] || N;
1219
+ },
1220
+ [n]
1221
+ ), [V, K] = _(""), [M, $] = _(""), [G, F] = _(""), [J, W] = _(""), j = Q(
1222
+ () => o?.userMetadataFields?.filter((l) => l.showInProfile) || [],
1223
+ [o?.userMetadataFields]
1224
+ ), [L, w] = _({}), [m, C] = _(!1), f = d.language === "fa", O = f ? "text-right" : "text-left", S = ee(async () => {
871
1225
  try {
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);
1226
+ const l = await i.getMe();
1227
+ P(l), K(l.name || ""), $(l.surname || ""), F(l.phone || "");
1228
+ const h = {};
1229
+ j.forEach((N) => {
1230
+ h[N.key] = l.metadata?.[N.key] ?? N.defaultValue ?? "";
1231
+ }), w(h);
878
1232
  } catch (l) {
879
- console.error("Failed to fetch user:", l), ee.error(ce(l, t));
1233
+ console.error("Failed to fetch user:", l), te.error(de(l, t));
880
1234
  }
881
- }, [t, F]);
882
- $(() => {
883
- if (!P) {
884
- q.current = null;
1235
+ }, [t, j, i]);
1236
+ B(() => {
1237
+ if (!I) {
1238
+ R.current = null;
885
1239
  return;
886
1240
  }
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 () => {
896
- k(!0);
1241
+ (R.current === null || T === "account") && S(), R.current = T;
1242
+ }, [I, T, S]), B(() => {
1243
+ const l = { ...L };
1244
+ let h = !1;
1245
+ j.forEach((N) => {
1246
+ N.condition && !ye(N.condition, L) && l[N.key] !== void 0 && (delete l[N.key], h = !0);
1247
+ }), h && w(l);
1248
+ }, [L, j]);
1249
+ const Z = async () => {
1250
+ C(!0);
897
1251
  try {
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();
1252
+ const l = { name: V, surname: M, phone: G, metadata: L };
1253
+ J && (l.password = J);
1254
+ const h = await i.updateMe(l);
1255
+ r.setQueryData(ht(o?.cacheNamespace || "gentiq"), h), te.success(t("profile.success", "Profile updated successfully")), W(""), S();
905
1256
  } catch (l) {
906
- ee.error(ce(l, t));
1257
+ te.error(de(l, t));
907
1258
  } finally {
908
- k(!1);
1259
+ C(!1);
909
1260
  }
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" }) }) }),
1261
+ }, H = () => {
1262
+ window.confirm(t("account.logout_confirm", "Are you sure you want to logout?")) && (i.clearToken(), window.location.reload());
1263
+ }, z = (l) => {
1264
+ d.changeLanguage(l);
1265
+ }, U = A?.balance ? Math.max(0, Math.min(100, A.balance.tokens / (A.balance.token_limit || 1) * 100)) : 0, b = A?.balance ? Math.max(0, Math.min(100, A.balance.requests / (A.balance.request_limit || 1) * 100)) : 0;
1266
+ return /* @__PURE__ */ s(Ge, { open: I, onOpenChange: E, children: [
1267
+ /* @__PURE__ */ e(ut, { asChild: !0, children: a || /* @__PURE__ */ e(ae, { variant: "ghost", size: "icon", className: "rounded-full", children: /* @__PURE__ */ e(Ce, { className: "h-5 w-5" }) }) }),
917
1268
  /* @__PURE__ */ e(
918
- Ve,
1269
+ We,
919
1270
  {
920
- dir: I ? "rtl" : "ltr",
1271
+ dir: f ? "rtl" : "ltr",
921
1272
  className: v(
922
1273
  "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]",
923
- I && "rtl"
1274
+ f && "rtl"
924
1275
  ),
925
- children: /* @__PURE__ */ r("div", { className: "flex flex-col h-full w-full min-h-0 overflow-hidden", children: [
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: [
927
- /* @__PURE__ */ e("div", { className: "flex items-center justify-between px-4 sm:px-6 mb-2 sm:mb-4", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
928
- /* @__PURE__ */ e("div", { className: "bg-primary/10 p-1.5 rounded-lg", children: /* @__PURE__ */ e(Ne, { className: "h-5 w-5 text-primary" }) }),
1276
+ children: /* @__PURE__ */ s("div", { className: "flex flex-col h-full w-full min-h-0 overflow-hidden", children: [
1277
+ /* @__PURE__ */ s("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: [
1278
+ /* @__PURE__ */ e("div", { className: "flex items-center justify-between px-4 sm:px-6 mb-2 sm:mb-4", children: /* @__PURE__ */ s("div", { className: "flex items-center gap-2", children: [
1279
+ /* @__PURE__ */ e("div", { className: "bg-primary/10 p-1.5 rounded-lg", children: /* @__PURE__ */ e(Ce, { className: "h-5 w-5 text-primary" }) }),
929
1280
  /* @__PURE__ */ e("span", { className: "font-bold text-lg", children: t("title", "Settings") })
930
1281
  ] }) }),
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(
1282
+ /* @__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: D.map((l) => /* @__PURE__ */ s(
932
1283
  "button",
933
1284
  {
934
- onClick: () => Q(l.id),
1285
+ onClick: () => q(l.id),
935
1286
  className: v(
936
1287
  "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",
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"
1288
+ T === l.id ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border",
1289
+ n?.sections?.[l.id]?.mode === "faded" && "opacity-50 pointer-events-none select-none"
939
1290
  ),
940
1291
  children: [
941
- /* @__PURE__ */ e(l.icon, { className: v(
942
- "h-3.5 w-3.5 sm:h-4 sm:w-4 transition-transform",
943
- p === l.id && "scale-110"
944
- ) }),
1292
+ /* @__PURE__ */ e(
1293
+ l.icon,
1294
+ {
1295
+ className: v(
1296
+ "h-3.5 w-3.5 sm:h-4 sm:w-4 transition-transform",
1297
+ T === l.id && "scale-110"
1298
+ )
1299
+ }
1300
+ ),
945
1301
  l.label
946
1302
  ]
947
1303
  },
948
1304
  l.id
949
1305
  )) }) })
950
1306
  ] }),
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: [
952
- p === "profile" && /* @__PURE__ */ r("div", { className: "space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
953
- /* @__PURE__ */ r("div", { children: [
1307
+ /* @__PURE__ */ e("div", { className: "flex-1 relative min-h-0 h-full bg-background", children: /* @__PURE__ */ s("div", { className: "absolute inset-0 overflow-y-auto p-5 sm:p-8 pt-12 sm:pt-12 custom-scrollbar", children: [
1308
+ T === "profile" && /* @__PURE__ */ s("div", { className: "space-y-6 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1309
+ /* @__PURE__ */ s("div", { children: [
954
1310
  /* @__PURE__ */ e("h2", { className: "text-xl font-bold tracking-tight", children: t("profile.title", "Profile Information") }),
955
1311
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("profile.subtitle", "Update your personal details below.") })
956
1312
  ] }),
957
- /* @__PURE__ */ r("div", { className: "grid gap-6", children: [
958
- /* @__PURE__ */ r("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
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") }),
961
- /* @__PURE__ */ e(
962
- X,
963
- {
964
- id: "name",
965
- value: B,
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)
969
- }
970
- )
971
- ] }),
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") }),
974
- /* @__PURE__ */ e(
975
- X,
976
- {
977
- id: "surname",
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)
982
- }
983
- )
984
- ] })
985
- ] }),
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") }),
988
- /* @__PURE__ */ r("div", { className: "relative", children: [
989
- /* @__PURE__ */ e(Mt, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground left-3" }),
990
- /* @__PURE__ */ e(
991
- X,
992
- {
993
- id: "phone",
994
- value: V,
995
- onChange: (l) => R(l.target.value),
996
- disabled: x("profile", "phone") === "faded",
997
- className: "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary pl-10 pr-3 text-left",
998
- dir: "ltr"
999
- }
1000
- )
1001
- ] })
1002
- ] }),
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") }),
1005
- /* @__PURE__ */ r("div", { className: "relative", children: [
1006
- /* @__PURE__ */ e(It, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground left-3" }),
1007
- /* @__PURE__ */ e(
1008
- X,
1009
- {
1010
- id: "pass",
1011
- type: "password",
1012
- value: L,
1013
- onChange: (l) => H(l.target.value),
1014
- disabled: x("profile", "password") === "faded",
1015
- placeholder: t("profile.password_placeholder", "Leave empty to keep current"),
1016
- className: "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary pl-10 pr-3 text-left",
1017
- dir: "ltr"
1018
- }
1019
- )
1020
- ] })
1313
+ /* @__PURE__ */ s("div", { className: "grid gap-6", children: [
1314
+ /* @__PURE__ */ s("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-4", children: [
1315
+ x("profile", "name") !== "hidden" && /* @__PURE__ */ s(
1316
+ "div",
1317
+ {
1318
+ className: v(
1319
+ "flex flex-col gap-3",
1320
+ x("profile", "name") === "faded" && "opacity-50 pointer-events-none select-none"
1321
+ ),
1322
+ children: [
1323
+ /* @__PURE__ */ e(X, { htmlFor: "name", className: "px-1", children: t("profile.name", "First Name") }),
1324
+ /* @__PURE__ */ e(
1325
+ Y,
1326
+ {
1327
+ id: "name",
1328
+ value: V,
1329
+ onChange: (l) => K(l.target.value),
1330
+ disabled: x("profile", "name") === "faded",
1331
+ className: v(
1332
+ "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11",
1333
+ O
1334
+ )
1335
+ }
1336
+ )
1337
+ ]
1338
+ }
1339
+ ),
1340
+ x("profile", "surname") !== "hidden" && /* @__PURE__ */ s(
1341
+ "div",
1342
+ {
1343
+ className: v(
1344
+ "flex flex-col gap-3",
1345
+ x("profile", "surname") === "faded" && "opacity-50 pointer-events-none select-none"
1346
+ ),
1347
+ children: [
1348
+ /* @__PURE__ */ e(X, { htmlFor: "surname", className: "px-1", children: t("profile.surname", "Last Name") }),
1349
+ /* @__PURE__ */ e(
1350
+ Y,
1351
+ {
1352
+ id: "surname",
1353
+ value: M,
1354
+ onChange: (l) => $(l.target.value),
1355
+ disabled: x("profile", "surname") === "faded",
1356
+ className: v(
1357
+ "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11",
1358
+ O
1359
+ )
1360
+ }
1361
+ )
1362
+ ]
1363
+ }
1364
+ )
1021
1365
  ] }),
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,
1028
- {
1029
- value: String(b[l.key] || ""),
1030
- onValueChange: (_) => d({ ...b, [l.key]: _ }),
1031
- disabled: o === "faded",
1032
- dir: I ? "rtl" : "ltr",
1033
- children: [
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))) })
1036
- ]
1037
- }
1038
- ) : l.type === "checkbox" ? /* @__PURE__ */ r("div", { className: "flex items-center gap-3 px-1 py-1", children: [
1039
- /* @__PURE__ */ e(
1040
- "input",
1041
- {
1042
- id: `profile-${l.key}`,
1043
- type: "checkbox",
1044
- checked: !!b[l.key],
1045
- disabled: o === "faded",
1046
- onChange: (_) => d({ ...b, [l.key]: _.target.checked }),
1047
- className: "h-5 w-5 rounded-md border-border/50 bg-muted/30 text-primary focus:ring-primary transition-all cursor-pointer"
1048
- }
1366
+ x("profile", "phone") !== "hidden" && /* @__PURE__ */ s(
1367
+ "div",
1368
+ {
1369
+ className: v(
1370
+ "flex flex-col gap-3",
1371
+ x("profile", "phone") === "faded" && "opacity-50 pointer-events-none select-none"
1372
+ ),
1373
+ children: [
1374
+ /* @__PURE__ */ e(X, { htmlFor: "phone", className: "px-1 text-left", children: t("profile.phone", "Phone Number") }),
1375
+ /* @__PURE__ */ s("div", { className: "relative", children: [
1376
+ /* @__PURE__ */ e(It, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground left-3" }),
1377
+ /* @__PURE__ */ e(
1378
+ Y,
1379
+ {
1380
+ id: "phone",
1381
+ value: G,
1382
+ onChange: (l) => F(l.target.value),
1383
+ disabled: x("profile", "phone") === "faded",
1384
+ className: "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary pl-10 pr-3 text-left",
1385
+ dir: "ltr"
1386
+ }
1387
+ )
1388
+ ] })
1389
+ ]
1390
+ }
1391
+ ),
1392
+ x("profile", "password") !== "hidden" && /* @__PURE__ */ s(
1393
+ "div",
1394
+ {
1395
+ className: v(
1396
+ "flex flex-col gap-3",
1397
+ x("profile", "password") === "faded" && "opacity-50 pointer-events-none select-none"
1398
+ ),
1399
+ children: [
1400
+ /* @__PURE__ */ e(X, { htmlFor: "pass", className: "px-1 text-left", children: t("profile.password", "New Password") }),
1401
+ /* @__PURE__ */ s("div", { className: "relative", children: [
1402
+ /* @__PURE__ */ e(Rt, { className: "absolute top-1/2 -translate-y-1/2 h-4 w-4 text-muted-foreground left-3" }),
1403
+ /* @__PURE__ */ e(
1404
+ Y,
1405
+ {
1406
+ id: "pass",
1407
+ type: "password",
1408
+ value: J,
1409
+ onChange: (l) => W(l.target.value),
1410
+ disabled: x("profile", "password") === "faded",
1411
+ placeholder: t(
1412
+ "profile.password_placeholder",
1413
+ "Leave empty to keep current"
1414
+ ),
1415
+ className: "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary pl-10 pr-3 text-left",
1416
+ dir: "ltr"
1417
+ }
1418
+ )
1419
+ ] })
1420
+ ]
1421
+ }
1422
+ ),
1423
+ j.map((l) => {
1424
+ const h = x("profile", l.key, l.mode || "editable");
1425
+ return h === "hidden" || !ye(l.condition, L) ? null : /* @__PURE__ */ s(
1426
+ "div",
1427
+ {
1428
+ className: v(
1429
+ "flex flex-col gap-3 animate-in fade-in slide-in-from-top-1 duration-200",
1430
+ h === "faded" && "opacity-50 pointer-events-none select-none"
1049
1431
  ),
1050
- /* @__PURE__ */ e(G, { htmlFor: `profile-${l.key}`, className: "text-sm font-medium text-muted-foreground cursor-pointer", children: t(l.placeholder || l.label) })
1051
- ] }) : /* @__PURE__ */ e(
1052
- X,
1053
- {
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)
1061
- }
1062
- )
1063
- ] }, l.key);
1432
+ children: [
1433
+ /* @__PURE__ */ e(X, { htmlFor: `profile-${l.key}`, className: "px-1", children: t(l.label) }),
1434
+ l.type === "select" ? /* @__PURE__ */ s(
1435
+ we,
1436
+ {
1437
+ value: String(L[l.key] || ""),
1438
+ onValueChange: (N) => w({ ...L, [l.key]: N }),
1439
+ disabled: h === "faded",
1440
+ dir: f ? "rtl" : "ltr",
1441
+ children: [
1442
+ /* @__PURE__ */ e(Ne, { className: "bg-muted/30 border-border/50 rounded-xl focus:ring-primary h-11", children: /* @__PURE__ */ e(
1443
+ ke,
1444
+ {
1445
+ placeholder: t(l.placeholder || "profile.select_placeholder")
1446
+ }
1447
+ ) }),
1448
+ /* @__PURE__ */ e(Se, { className: "rounded-xl border-border/40 shadow-xl bg-background/95 backdrop-blur-md", children: l.options?.map((N) => /* @__PURE__ */ e(
1449
+ fe,
1450
+ {
1451
+ value: String(N.value),
1452
+ className: "rounded-lg focus:bg-primary/10",
1453
+ children: t(N.label)
1454
+ },
1455
+ String(N.value)
1456
+ )) })
1457
+ ]
1458
+ }
1459
+ ) : l.type === "checkbox" ? /* @__PURE__ */ s("div", { className: "flex items-center gap-3 px-1 py-1", children: [
1460
+ /* @__PURE__ */ e(
1461
+ "input",
1462
+ {
1463
+ id: `profile-${l.key}`,
1464
+ type: "checkbox",
1465
+ checked: !!L[l.key],
1466
+ disabled: h === "faded",
1467
+ onChange: (N) => w({ ...L, [l.key]: N.target.checked }),
1468
+ className: "h-5 w-5 rounded-md border-border/50 bg-muted/30 text-primary focus:ring-primary transition-all cursor-pointer"
1469
+ }
1470
+ ),
1471
+ /* @__PURE__ */ e(
1472
+ X,
1473
+ {
1474
+ htmlFor: `profile-${l.key}`,
1475
+ className: "text-sm font-medium text-muted-foreground cursor-pointer",
1476
+ children: t(l.placeholder || l.label)
1477
+ }
1478
+ )
1479
+ ] }) : /* @__PURE__ */ e(
1480
+ Y,
1481
+ {
1482
+ id: `profile-${l.key}`,
1483
+ type: l.type,
1484
+ value: L[l.key] || "",
1485
+ disabled: h === "faded",
1486
+ onChange: (N) => w({ ...L, [l.key]: N.target.value }),
1487
+ placeholder: t(l.placeholder || ""),
1488
+ className: v(
1489
+ "bg-muted/30 border-border/50 rounded-xl focus-visible:ring-primary h-11",
1490
+ O
1491
+ )
1492
+ }
1493
+ )
1494
+ ]
1495
+ },
1496
+ l.key
1497
+ );
1064
1498
  }),
1065
- /* @__PURE__ */ e("div", { className: "pt-4 flex justify-center", children: /* @__PURE__ */ r(
1066
- te,
1499
+ /* @__PURE__ */ e("div", { className: "pt-4 flex justify-center", children: /* @__PURE__ */ s(
1500
+ ae,
1067
1501
  {
1068
- onClick: w,
1069
- disabled: n,
1502
+ onClick: Z,
1503
+ disabled: m,
1070
1504
  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]",
1071
1505
  children: [
1072
1506
  /* @__PURE__ */ e(Dt, { className: "h-4 w-4" }),
1073
- n ? t("profile.saving", "Saving...") : t("profile.save", "Save Changes")
1507
+ m ? t("profile.saving", "Saving...") : t("profile.save", "Save Changes")
1074
1508
  ]
1075
1509
  }
1076
1510
  ) })
1077
1511
  ] })
1078
1512
  ] }),
1079
- p === "general" && /* @__PURE__ */ r("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1080
- /* @__PURE__ */ r("div", { children: [
1513
+ T === "general" && /* @__PURE__ */ s("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1514
+ /* @__PURE__ */ s("div", { children: [
1081
1515
  /* @__PURE__ */ e("h2", { className: "text-xl font-bold tracking-tight", children: t("general.title", "General Settings") }),
1082
1516
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("general.subtitle", "Configure look and feel and language.") })
1083
1517
  ] }),
1084
- /* @__PURE__ */ r("div", { className: "space-y-8", 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: [
1087
- /* @__PURE__ */ e(Me, { className: "h-4 w-4 text-primary" }),
1088
- t("general.theme", "Theme")
1089
- ] }),
1090
- /* @__PURE__ */ r("div", { className: "flex p-1 bg-muted/50 rounded-2xl border border-border/40 w-full", children: [
1091
- /* @__PURE__ */ r(
1092
- "button",
1093
- {
1094
- onClick: () => f("light"),
1095
- disabled: x("general", "theme") === "faded",
1096
- className: v(
1097
- "flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
1098
- g === "light" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1099
- ),
1100
- children: [
1101
- /* @__PURE__ */ e(At, { className: "h-4 w-4" }),
1102
- /* @__PURE__ */ e("span", { className: "text-sm font-medium", children: t("general.themes.light", "Light") })
1103
- ]
1104
- }
1105
- ),
1106
- /* @__PURE__ */ r(
1107
- "button",
1108
- {
1109
- onClick: () => f("dark"),
1110
- disabled: x("general", "theme") === "faded",
1111
- className: v(
1112
- "flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
1113
- g === "dark" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1114
- ),
1115
- children: [
1116
- /* @__PURE__ */ e(Et, { className: "h-4 w-4" }),
1117
- /* @__PURE__ */ e("span", { className: "text-sm font-medium", children: t("general.themes.dark", "Dark") })
1118
- ]
1119
- }
1518
+ /* @__PURE__ */ s("div", { className: "space-y-8", children: [
1519
+ x("general", "theme") !== "hidden" && /* @__PURE__ */ s(
1520
+ "div",
1521
+ {
1522
+ className: v(
1523
+ "space-y-3",
1524
+ x("general", "theme") === "faded" && "opacity-50 pointer-events-none select-none"
1120
1525
  ),
1121
- /* @__PURE__ */ r(
1122
- "button",
1123
- {
1124
- onClick: () => f("system"),
1125
- disabled: x("general", "theme") === "faded",
1126
- className: v(
1127
- "flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
1128
- g === "system" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1129
- ),
1130
- children: [
1131
- /* @__PURE__ */ e(Lt, { className: "h-4 w-4" }),
1132
- /* @__PURE__ */ e("span", { className: "text-sm font-medium", children: t("general.themes.system", "System") })
1133
- ]
1134
- }
1135
- )
1136
- ] })
1137
- ] }),
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" }),
1141
- t("general.accent", "Accent Color")
1142
- ] }),
1143
- /* @__PURE__ */ e("div", { className: "grid grid-cols-4 sm:grid-cols-8 gap-3 w-full", children: [
1144
- "oklch(0.623 0.214 259.815)",
1145
- // Blue
1146
- "oklch(0.585 0.233 277.117)",
1147
- // Indigo
1148
- "oklch(0.627 0.265 303.9)",
1149
- // Purple
1150
- "oklch(0.645 0.246 16.439)",
1151
- // Rose
1152
- "oklch(0.712 0.194 46.666)",
1153
- // Orange
1154
- "oklch(0.627 0.194 149.214)",
1155
- // Green
1156
- "oklch(0.633 0.145 182.903)",
1157
- // Teal
1158
- "oklch(0.552 0.016 285.938)"
1159
- // Slate
1160
- ].map((l) => {
1161
- const o = (h || "oklch(0.623 0.214 259.815)") === l;
1162
- return /* @__PURE__ */ e(
1163
- "button",
1164
- {
1165
- onClick: () => N(l),
1166
- disabled: x("general", "accent") === "faded",
1167
- className: v(
1168
- "h-8 w-8 rounded-full border-2 transition-all hover:scale-110 active:scale-95 shadow-sm",
1169
- o ? "border-foreground" : "border-transparent"
1526
+ children: [
1527
+ /* @__PURE__ */ s(X, { className: "text-sm font-semibold flex items-center gap-2", children: [
1528
+ /* @__PURE__ */ e(Ae, { className: "h-4 w-4 text-primary" }),
1529
+ t("general.theme", "Theme")
1530
+ ] }),
1531
+ /* @__PURE__ */ s("div", { className: "flex p-1 bg-muted/50 rounded-2xl border border-border/40 w-full", children: [
1532
+ /* @__PURE__ */ s(
1533
+ "button",
1534
+ {
1535
+ onClick: () => c("light"),
1536
+ disabled: x("general", "theme") === "faded",
1537
+ className: v(
1538
+ "flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
1539
+ u === "light" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1540
+ ),
1541
+ children: [
1542
+ /* @__PURE__ */ e($t, { className: "h-4 w-4" }),
1543
+ /* @__PURE__ */ e("span", { className: "text-sm font-medium", children: t("general.themes.light", "Light") })
1544
+ ]
1545
+ }
1170
1546
  ),
1171
- style: { backgroundColor: l }
1172
- },
1173
- l
1174
- );
1175
- }) })
1176
- ] }),
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: [
1179
- /* @__PURE__ */ e("div", { className: "h-4 w-4 rounded-md border-2 border-primary" }),
1180
- t("general.radius", "Rounded Corners")
1181
- ] }),
1182
- /* @__PURE__ */ e("div", { className: "flex p-1 bg-muted/50 rounded-2xl border border-border/40 w-full", children: [
1183
- { id: "sharp", value: "0.3rem" },
1184
- { id: "round", value: "1.25rem" }
1185
- ].map((l) => {
1186
- const o = (y || "1.25rem") === l.value;
1187
- return /* @__PURE__ */ e(
1188
- "button",
1189
- {
1190
- onClick: () => C(l.value),
1191
- disabled: x("general", "radius") === "faded",
1192
- className: v(
1193
- "flex-1 py-2 rounded-xl transition-all text-sm font-medium",
1194
- o ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1547
+ /* @__PURE__ */ s(
1548
+ "button",
1549
+ {
1550
+ onClick: () => c("dark"),
1551
+ disabled: x("general", "theme") === "faded",
1552
+ className: v(
1553
+ "flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
1554
+ u === "dark" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1555
+ ),
1556
+ children: [
1557
+ /* @__PURE__ */ e(Lt, { className: "h-4 w-4" }),
1558
+ /* @__PURE__ */ e("span", { className: "text-sm font-medium", children: t("general.themes.dark", "Dark") })
1559
+ ]
1560
+ }
1195
1561
  ),
1196
- children: t(`general.radius_levels.${l.id}`)
1197
- },
1198
- l.id
1199
- );
1200
- }) })
1201
- ] }),
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" }),
1205
- t("general.language", "Language")
1206
- ] }),
1207
- /* @__PURE__ */ r(
1208
- xe,
1209
- {
1210
- value: i.language,
1211
- onValueChange: Y,
1212
- disabled: x("general", "language") === "faded",
1213
- dir: I ? "rtl" : "ltr",
1214
- children: [
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") }) }),
1216
- /* @__PURE__ */ r(we, { className: "rounded-2xl border-border/40 shadow-xl bg-background/95 backdrop-blur-md", children: [
1217
- /* @__PURE__ */ e(pe, { value: "en", className: "rounded-xl focus:bg-primary/10", children: /* @__PURE__ */ r("span", { className: "flex items-center gap-2", children: [
1218
- /* @__PURE__ */ e("span", { className: "text-xs font-bold text-muted-foreground mr-1", children: "EN" }),
1219
- t("general.languages.en", "English")
1220
- ] }) }),
1221
- /* @__PURE__ */ e(pe, { value: "fa", className: "rounded-xl focus:bg-primary/10", children: /* @__PURE__ */ r("span", { className: "flex items-center gap-2", children: [
1222
- /* @__PURE__ */ e("span", { className: "text-xs font-bold text-muted-foreground mr-1", children: "FA" }),
1223
- t("general.languages.fa", "Persian")
1224
- ] }) })
1225
- ] })
1226
- ]
1227
- }
1228
- )
1229
- ] })
1562
+ /* @__PURE__ */ s(
1563
+ "button",
1564
+ {
1565
+ onClick: () => c("system"),
1566
+ disabled: x("general", "theme") === "faded",
1567
+ className: v(
1568
+ "flex-1 flex items-center justify-center gap-2 py-2.5 rounded-xl transition-all",
1569
+ u === "system" ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1570
+ ),
1571
+ children: [
1572
+ /* @__PURE__ */ e(Ft, { className: "h-4 w-4" }),
1573
+ /* @__PURE__ */ e("span", { className: "text-sm font-medium", children: t("general.themes.system", "System") })
1574
+ ]
1575
+ }
1576
+ )
1577
+ ] })
1578
+ ]
1579
+ }
1580
+ ),
1581
+ x("general", "accent") !== "hidden" && /* @__PURE__ */ s(
1582
+ "div",
1583
+ {
1584
+ className: v(
1585
+ "space-y-4",
1586
+ x("general", "accent") === "faded" && "opacity-50 pointer-events-none select-none"
1587
+ ),
1588
+ children: [
1589
+ /* @__PURE__ */ s(X, { className: "text-sm font-semibold flex items-center gap-2", children: [
1590
+ /* @__PURE__ */ e(Ie, { className: "h-4 w-4 text-primary" }),
1591
+ t("general.accent", "Accent Color")
1592
+ ] }),
1593
+ /* @__PURE__ */ e("div", { className: "grid grid-cols-4 sm:grid-cols-8 gap-3 w-full", children: [
1594
+ "oklch(0.623 0.214 259.815)",
1595
+ // Blue
1596
+ "oklch(0.585 0.233 277.117)",
1597
+ // Indigo
1598
+ "oklch(0.627 0.265 303.9)",
1599
+ // Purple
1600
+ "oklch(0.645 0.246 16.439)",
1601
+ // Rose
1602
+ "oklch(0.712 0.194 46.666)",
1603
+ // Orange
1604
+ "oklch(0.627 0.194 149.214)",
1605
+ // Green
1606
+ "oklch(0.633 0.145 182.903)",
1607
+ // Teal
1608
+ "oklch(0.552 0.016 285.938)"
1609
+ // Slate
1610
+ ].map((l) => {
1611
+ const h = (y || "oklch(0.623 0.214 259.815)") === l;
1612
+ return /* @__PURE__ */ e(
1613
+ "button",
1614
+ {
1615
+ onClick: () => k(l),
1616
+ disabled: x("general", "accent") === "faded",
1617
+ className: v(
1618
+ "h-8 w-8 rounded-full border-2 transition-all hover:scale-110 active:scale-95 shadow-sm",
1619
+ h ? "border-foreground" : "border-transparent"
1620
+ ),
1621
+ style: { backgroundColor: l }
1622
+ },
1623
+ l
1624
+ );
1625
+ }) })
1626
+ ]
1627
+ }
1628
+ ),
1629
+ x("general", "radius") !== "hidden" && /* @__PURE__ */ s(
1630
+ "div",
1631
+ {
1632
+ className: v(
1633
+ "space-y-4",
1634
+ x("general", "radius") === "faded" && "opacity-50 pointer-events-none select-none"
1635
+ ),
1636
+ children: [
1637
+ /* @__PURE__ */ s(X, { className: "text-sm font-semibold flex items-center gap-2", children: [
1638
+ /* @__PURE__ */ e("div", { className: "h-4 w-4 rounded-md border-2 border-primary" }),
1639
+ t("general.radius", "Rounded Corners")
1640
+ ] }),
1641
+ /* @__PURE__ */ e("div", { className: "flex p-1 bg-muted/50 rounded-2xl border border-border/40 w-full", children: [
1642
+ { id: "sharp", value: "0.3rem" },
1643
+ { id: "round", value: "1.25rem" }
1644
+ ].map((l) => {
1645
+ const h = (g || "1.25rem") === l.value;
1646
+ return /* @__PURE__ */ e(
1647
+ "button",
1648
+ {
1649
+ onClick: () => p(l.value),
1650
+ disabled: x("general", "radius") === "faded",
1651
+ className: v(
1652
+ "flex-1 py-2 rounded-xl transition-all text-sm font-medium",
1653
+ h ? "bg-background shadow-md text-primary" : "text-muted-foreground hover:text-foreground"
1654
+ ),
1655
+ children: t(`general.radius_levels.${l.id}`)
1656
+ },
1657
+ l.id
1658
+ );
1659
+ }) })
1660
+ ]
1661
+ }
1662
+ ),
1663
+ x("general", "language") !== "hidden" && /* @__PURE__ */ s(
1664
+ "div",
1665
+ {
1666
+ className: v(
1667
+ "space-y-3",
1668
+ x("general", "language") === "faded" && "opacity-50"
1669
+ ),
1670
+ children: [
1671
+ /* @__PURE__ */ s(X, { className: "text-sm font-semibold flex items-center gap-2", children: [
1672
+ /* @__PURE__ */ e(qt, { className: "h-4 w-4 text-primary" }),
1673
+ t("general.language", "Language")
1674
+ ] }),
1675
+ /* @__PURE__ */ s(
1676
+ we,
1677
+ {
1678
+ value: d.language,
1679
+ onValueChange: z,
1680
+ disabled: x("general", "language") === "faded",
1681
+ dir: f ? "rtl" : "ltr",
1682
+ children: [
1683
+ /* @__PURE__ */ e(Ne, { className: "w-full bg-muted/50 rounded-2xl border-border/40 h-11 focus:ring-primary/20", children: /* @__PURE__ */ e(
1684
+ ke,
1685
+ {
1686
+ placeholder: t("general.language_placeholder", "Select language")
1687
+ }
1688
+ ) }),
1689
+ /* @__PURE__ */ s(Se, { className: "rounded-2xl border-border/40 shadow-xl bg-background/95 backdrop-blur-md", children: [
1690
+ /* @__PURE__ */ e(fe, { value: "en", className: "rounded-xl focus:bg-primary/10", children: /* @__PURE__ */ s("span", { className: "flex items-center gap-2", children: [
1691
+ /* @__PURE__ */ e("span", { className: "text-xs font-bold text-muted-foreground mr-1", children: "EN" }),
1692
+ t("general.languages.en", "English")
1693
+ ] }) }),
1694
+ /* @__PURE__ */ e(fe, { value: "fa", className: "rounded-xl focus:bg-primary/10", children: /* @__PURE__ */ s("span", { className: "flex items-center gap-2", children: [
1695
+ /* @__PURE__ */ e("span", { className: "text-xs font-bold text-muted-foreground mr-1", children: "FA" }),
1696
+ t("general.languages.fa", "Persian")
1697
+ ] }) })
1698
+ ] })
1699
+ ]
1700
+ }
1701
+ )
1702
+ ]
1703
+ }
1704
+ )
1230
1705
  ] })
1231
1706
  ] }),
1232
- p === "account" && /* @__PURE__ */ r("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1233
- /* @__PURE__ */ r("div", { children: [
1707
+ T === "account" && /* @__PURE__ */ s("div", { className: "space-y-8 animate-in fade-in slide-in-from-bottom-4 duration-300", children: [
1708
+ /* @__PURE__ */ s("div", { children: [
1234
1709
  /* @__PURE__ */ e("h2", { className: "text-xl font-bold tracking-tight", children: t("account.title", "Account & Usage") }),
1235
1710
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("account.subtitle", "Monitor your quotas and manage your session.") })
1236
1711
  ] }),
1237
- /* @__PURE__ */ r("div", { className: "space-y-6", 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: [
1240
- /* @__PURE__ */ e(zt, { className: "h-4 w-4" }),
1241
- t("account.balance", "Current Balance")
1242
- ] }),
1243
- /* @__PURE__ */ r("div", { className: "space-y-5", children: [
1244
- /* @__PURE__ */ r("div", { className: "space-y-2", children: [
1245
- /* @__PURE__ */ r("div", { className: "flex justify-between text-sm mb-1", children: [
1246
- /* @__PURE__ */ e("span", { className: "font-medium text-muted-foreground", children: t("account.tokens", "Tokens") }),
1247
- /* @__PURE__ */ r("span", { className: "font-bold text-primary", children: [
1248
- Z.toLocaleString(i.language, { maximumFractionDigits: 0 }),
1249
- "%"
1250
- ] })
1712
+ /* @__PURE__ */ s("div", { className: "space-y-6", children: [
1713
+ x("account", "balance") !== "hidden" && /* @__PURE__ */ s(
1714
+ "div",
1715
+ {
1716
+ className: v(
1717
+ "p-6 bg-muted/30 rounded-3xl border border-border/40 space-y-6",
1718
+ x("account", "balance") === "faded" && "opacity-50"
1719
+ ),
1720
+ children: [
1721
+ /* @__PURE__ */ s(X, { className: "text-xs font-bold uppercase tracking-wider text-primary flex items-center gap-2", children: [
1722
+ /* @__PURE__ */ e(zt, { className: "h-4 w-4" }),
1723
+ t("account.balance", "Current Balance")
1251
1724
  ] }),
1252
- /* @__PURE__ */ e("div", { className: "h-2.5 w-full bg-muted/50 rounded-full overflow-hidden border border-border/20 p-0.5", dir: "ltr", children: /* @__PURE__ */ e(
1253
- "div",
1254
- {
1255
- className: v(
1256
- "h-full rounded-full transition-all duration-1000 shadow-sm",
1257
- Z > 60 ? "bg-emerald-500 shadow-emerald-500/20" : Z > 20 ? "bg-amber-500 shadow-amber-500/20" : "bg-destructive shadow-destructive/20"
1258
- ),
1259
- style: { width: `${Z}%` }
1260
- }
1261
- ) })
1262
- ] }),
1263
- /* @__PURE__ */ r("div", { className: "space-y-2", children: [
1264
- /* @__PURE__ */ r("div", { className: "flex justify-between text-sm mb-1", children: [
1265
- /* @__PURE__ */ r("span", { className: "font-medium text-muted-foreground flex items-center gap-1.5 focus:outline-none", children: [
1266
- /* @__PURE__ */ e(Ie, { className: "h-3.5 w-3.5 text-blue-500" }),
1267
- t("account.requests", "Requests")
1725
+ /* @__PURE__ */ s("div", { className: "space-y-5", children: [
1726
+ /* @__PURE__ */ s("div", { className: "space-y-2", children: [
1727
+ /* @__PURE__ */ s("div", { className: "flex justify-between text-sm mb-1", children: [
1728
+ /* @__PURE__ */ e("span", { className: "font-medium text-muted-foreground", children: t("account.tokens", "Tokens") }),
1729
+ /* @__PURE__ */ s("span", { className: "font-bold text-primary", children: [
1730
+ U.toLocaleString(d.language, {
1731
+ maximumFractionDigits: 0
1732
+ }),
1733
+ "%"
1734
+ ] })
1735
+ ] }),
1736
+ /* @__PURE__ */ e(
1737
+ "div",
1738
+ {
1739
+ className: "h-2.5 w-full bg-muted/50 rounded-full overflow-hidden border border-border/20 p-0.5",
1740
+ dir: "ltr",
1741
+ children: /* @__PURE__ */ e(
1742
+ "div",
1743
+ {
1744
+ className: v(
1745
+ "h-full rounded-full transition-all duration-1000 shadow-sm",
1746
+ U > 60 ? "bg-emerald-500 shadow-emerald-500/20" : U > 20 ? "bg-amber-500 shadow-amber-500/20" : "bg-destructive shadow-destructive/20"
1747
+ ),
1748
+ style: { width: `${U}%` }
1749
+ }
1750
+ )
1751
+ }
1752
+ )
1268
1753
  ] }),
1269
- /* @__PURE__ */ r("span", { className: "font-bold text-primary", children: [
1270
- se.toLocaleString(i.language, { maximumFractionDigits: 0 }),
1271
- "%"
1754
+ /* @__PURE__ */ s("div", { className: "space-y-2", children: [
1755
+ /* @__PURE__ */ s("div", { className: "flex justify-between text-sm mb-1", children: [
1756
+ /* @__PURE__ */ s("span", { className: "font-medium text-muted-foreground flex items-center gap-1.5 focus:outline-none", children: [
1757
+ /* @__PURE__ */ e(Ie, { className: "h-3.5 w-3.5 text-blue-500" }),
1758
+ t("account.requests", "Requests")
1759
+ ] }),
1760
+ /* @__PURE__ */ s("span", { className: "font-bold text-primary", children: [
1761
+ b.toLocaleString(d.language, {
1762
+ maximumFractionDigits: 0
1763
+ }),
1764
+ "%"
1765
+ ] })
1766
+ ] }),
1767
+ /* @__PURE__ */ e(
1768
+ "div",
1769
+ {
1770
+ className: "h-2.5 w-full bg-muted/50 rounded-full overflow-hidden border border-border/20 p-0.5",
1771
+ dir: "ltr",
1772
+ children: /* @__PURE__ */ e(
1773
+ "div",
1774
+ {
1775
+ className: v(
1776
+ "h-full rounded-full transition-all duration-1000 shadow-sm",
1777
+ b > 60 ? "bg-emerald-500 shadow-emerald-500/20" : b > 20 ? "bg-amber-500 shadow-amber-500/20" : "bg-destructive shadow-destructive/20"
1778
+ ),
1779
+ style: { width: `${b}%` }
1780
+ }
1781
+ )
1782
+ }
1783
+ )
1272
1784
  ] })
1273
- ] }),
1274
- /* @__PURE__ */ e("div", { className: "h-2.5 w-full bg-muted/50 rounded-full overflow-hidden border border-border/20 p-0.5", dir: "ltr", children: /* @__PURE__ */ e(
1275
- "div",
1276
- {
1277
- className: v(
1278
- "h-full rounded-full transition-all duration-1000 shadow-sm",
1279
- se > 60 ? "bg-emerald-500 shadow-emerald-500/20" : se > 20 ? "bg-amber-500 shadow-amber-500/20" : "bg-destructive shadow-destructive/20"
1280
- ),
1281
- style: { width: `${se}%` }
1282
- }
1283
- ) })
1284
- ] })
1285
- ] })
1286
- ] }),
1287
- /* @__PURE__ */ r("div", { className: "pt-2 flex flex-col gap-3", children: [
1288
- s?.balance?.updated_at && x("account", "balance") !== "hidden" && /* @__PURE__ */ r("p", { className: "text-xs text-muted-foreground px-1", children: [
1785
+ ] })
1786
+ ]
1787
+ }
1788
+ ),
1789
+ /* @__PURE__ */ s("div", { className: "pt-2 flex flex-col gap-3", children: [
1790
+ A?.balance?.updated_at && x("account", "balance") !== "hidden" && /* @__PURE__ */ s("p", { className: "text-xs text-muted-foreground px-1", children: [
1289
1791
  t("account.last_recharge", "Last balance update on"),
1290
- ": ",
1291
- new Date(s.balance?.updated_at || "").toLocaleDateString(i.language)
1792
+ ":",
1793
+ " ",
1794
+ new Date(A.balance?.updated_at || "").toLocaleDateString(
1795
+ d.language
1796
+ )
1292
1797
  ] }),
1293
- x("account", "logout") !== "hidden" && /* @__PURE__ */ r(
1294
- te,
1798
+ x("account", "logout") !== "hidden" && /* @__PURE__ */ s(
1799
+ ae,
1295
1800
  {
1296
1801
  variant: "destructive",
1297
- onClick: z,
1802
+ onClick: H,
1298
1803
  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"),
1804
+ className: v(
1805
+ "rounded-2xl gap-2 font-bold h-12 shadow-lg shadow-destructive/10 transition-all active:scale-[0.98]",
1806
+ x("account", "logout") === "faded" && "opacity-50 pointer-events-none"
1807
+ ),
1300
1808
  children: [
1301
- /* @__PURE__ */ e(qt, { className: "h-4 w-4" }),
1809
+ /* @__PURE__ */ e(jt, { className: "h-4 w-4" }),
1302
1810
  t("account.logout", "Logout from Account")
1303
1811
  ]
1304
1812
  }
@@ -1307,62 +1815,64 @@ function Pa({ trigger: a }) {
1307
1815
  ] })
1308
1816
  ] })
1309
1817
  ] }) }),
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: [
1311
- "v",
1312
- m.version
1313
- ] }) }) })
1818
+ o?.showVersionInSettings !== !1 && o?.version && x("general", "version") !== "hidden" && /* @__PURE__ */ e(
1819
+ "div",
1820
+ {
1821
+ className: v(
1822
+ "shrink-0 border-t border-border/30 px-5 sm:px-8 py-3 flex justify-center bg-background/80",
1823
+ x("general", "version", "faded") === "faded" && "opacity-70"
1824
+ ),
1825
+ children: /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground text-center", dir: "ltr", children: /* @__PURE__ */ s("span", { className: "font-mono text-foreground/75", children: [
1826
+ "v",
1827
+ o.version
1828
+ ] }) })
1829
+ }
1830
+ )
1314
1831
  ] })
1315
1832
  }
1316
1833
  )
1317
1834
  ] });
1318
1835
  }
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") {
1323
- const C = window.matchMedia("(prefers-color-scheme: dark)").matches;
1324
- h(C ? "dark" : "light");
1836
+ function Ye({ hideActions: a = !1 }) {
1837
+ const [, t] = Pe(), { t: d } = ue(["sidebar", "chat"]), { history: o, app: n } = ne(), { theme: i } = Ve(), r = !a && (o?.enabled ?? !0), [u, c] = _("light");
1838
+ B(() => {
1839
+ if (i === "system") {
1840
+ const g = window.matchMedia("(prefers-color-scheme: dark)").matches;
1841
+ c(g ? "dark" : "light");
1325
1842
  } else
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";
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: [
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" }) }),
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(
1332
- "img",
1333
- {
1334
- src: N,
1335
- alt: y,
1336
- className: "size-8 object-contain"
1337
- }
1338
- ) }) }),
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: [
1340
- /* @__PURE__ */ r(Ue, { children: [
1341
- /* @__PURE__ */ e(Be, { asChild: !0, children: /* @__PURE__ */ e(
1843
+ c(i);
1844
+ }, [i]);
1845
+ const y = Q(() => n?.logo ? typeof n.logo == "string" ? n.logo : u === "dark" ? n.logo.dark : n.logo.light : pt, [n?.logo, u]), k = n?.name || "Gentiq";
1846
+ return /* @__PURE__ */ s("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: [
1847
+ /* @__PURE__ */ e("div", { className: "flex items-center gap-1.5 md:gap-2 min-w-[36px] md:min-w-[80px]", children: r && /* @__PURE__ */ e(Pa, { className: "hover:bg-accent/60 transition-all duration-200 hover:scale-105 active:scale-95 rounded-lg size-9" }) }),
1848
+ /* @__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("img", { src: y, alt: k, className: "size-8 object-contain" }) }) }),
1849
+ /* @__PURE__ */ e("div", { className: "flex items-center gap-1.5 min-w-[36px] md:min-w-[80px] justify-end", children: !a && /* @__PURE__ */ s(_e, { children: [
1850
+ /* @__PURE__ */ s(Be, { children: [
1851
+ /* @__PURE__ */ e(Ke, { asChild: !0, children: /* @__PURE__ */ e(
1342
1852
  "button",
1343
1853
  {
1344
1854
  type: "button",
1345
1855
  className: v(
1346
1856
  "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",
1347
- g && "md:hidden"
1857
+ r && "md:hidden"
1348
1858
  ),
1349
1859
  onClick: () => {
1350
1860
  t("/");
1351
1861
  },
1352
- children: /* @__PURE__ */ e(Ft, { className: "size-5" })
1862
+ children: /* @__PURE__ */ e(Ot, { className: "size-5" })
1353
1863
  }
1354
1864
  ) }),
1355
- /* @__PURE__ */ e(Ke, { side: "bottom", className: "text-xs", children: i("new_chat") })
1865
+ /* @__PURE__ */ e(Qe, { side: "bottom", className: "text-xs", children: d("new_chat") })
1356
1866
  ] }),
1357
- c?.showSettings !== !1 && /* @__PURE__ */ e(
1358
- Pa,
1867
+ n?.showSettings !== !1 && /* @__PURE__ */ e(
1868
+ Ra,
1359
1869
  {
1360
1870
  trigger: /* @__PURE__ */ e(
1361
1871
  "button",
1362
1872
  {
1363
1873
  type: "button",
1364
1874
  className: "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",
1365
- children: /* @__PURE__ */ e(Ne, { className: "size-5" })
1875
+ children: /* @__PURE__ */ e(Ce, { className: "size-5" })
1366
1876
  }
1367
1877
  )
1368
1878
  }
@@ -1370,275 +1880,342 @@ function Xe({ hideActions: a = !1 }) {
1370
1880
  ] }) })
1371
1881
  ] });
1372
1882
  }
1373
- const ze = 20;
1374
- function Ta() {
1375
- const t = D.getConfig().app?.cacheNamespace || "gentiq";
1376
- return at({
1377
- queryKey: [t, "conversations"],
1378
- queryFn: async ({ pageParam: i = 0 }) => {
1379
- const m = await D.getHistory(i, ze);
1883
+ const qe = 20;
1884
+ function Da() {
1885
+ const a = oe(), d = a.getConfig().app?.cacheNamespace || "gentiq";
1886
+ return nt({
1887
+ queryKey: [d, "conversations"],
1888
+ queryFn: async ({ pageParam: o = 0 }) => {
1889
+ const n = await a.getHistory(o, qe);
1380
1890
  return {
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
1891
+ threads: n.threads.map((i) => ({
1892
+ id: `/${i.id}`,
1893
+ firstMessage: i.title || i.firstMessage || "Chat",
1894
+ timestamp: new Date(i.created_at).getTime(),
1895
+ pinned: !!i.pinned
1386
1896
  })),
1387
- nextSkip: i + ze,
1388
- hasMore: i + m.threads.length < (m.total_count ?? 0)
1897
+ nextSkip: o + qe,
1898
+ hasMore: o + n.threads.length < (n.total_count ?? 0)
1389
1899
  };
1390
1900
  },
1391
1901
  initialPageParam: 0,
1392
- getNextPageParam: (i) => i.hasMore ? i.nextSkip : void 0,
1902
+ getNextPageParam: (o) => o.hasMore ? o.nextSkip : void 0,
1393
1903
  staleTime: 1e3 * 60 * 5
1394
1904
  // 5 minutes
1395
1905
  });
1396
1906
  }
1397
- async function Ma(a, t, i, m) {
1398
- const u = D.getConfig().app?.cacheNamespace || "gentiq";
1907
+ async function $a(a, t, d, o, n) {
1908
+ const r = a.getConfig().app?.cacheNamespace || "gentiq";
1399
1909
  try {
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");
1910
+ await a.deleteThread(t), d.invalidateQueries({ queryKey: [r, "conversations"] }), n === t && o("/");
1911
+ } catch (u) {
1912
+ console.error("Failed to delete conversation:", u), te.error("Failed to delete conversation");
1403
1913
  }
1404
1914
  }
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(
1415
- (_) => {
1416
- _[0].isIntersecting && g();
1915
+ function La({ side: a = "left" }) {
1916
+ const { t, i18n: d } = ue(["sidebar", "translation"]), { setOpenMobile: o, isMobile: n } = ve(), { data: i, fetchNextPage: r, hasNextPage: u, isFetchingNextPage: c, isLoading: y } = Da(), { history: k, app: g } = ne(), p = g?.basePath || "/", A = k?.enabled ?? !1, P = i?.pages.flatMap((h) => h.threads) ?? [], [I, E] = Pe(), R = he(), D = re(null), T = ee(
1917
+ (h) => {
1918
+ D.current && (D.current.disconnect(), D.current = null), h && u && !c && (D.current = new IntersectionObserver(
1919
+ (N) => {
1920
+ N[0].isIntersecting && r();
1417
1921
  },
1418
1922
  {
1419
1923
  threshold: 0,
1420
1924
  rootMargin: "100px"
1421
1925
  }
1422
- ), p.current.observe(o));
1926
+ ), D.current.observe(h));
1423
1927
  },
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) => {
1928
+ [u, r, c]
1929
+ ), q = oe(), V = q.getConfig().app?.cacheNamespace || "gentiq", [K, M] = _(!1), [$, G] = _(null), [F, J] = _(""), [W, j] = _(null), [L, w] = _(""), m = re(null), C = ee(
1930
+ (h, N) => {
1931
+ h.button !== 0 || h.metaKey || h.ctrlKey || (h.preventDefault(), E(N), n && o(!1));
1932
+ },
1933
+ [E, n, o]
1934
+ ), f = P.filter((h) => h.firstMessage?.toLowerCase().includes(F.toLowerCase())).sort((h, N) => h.pinned && !N.pinned ? -1 : !h.pinned && N.pinned ? 1 : N.timestamp - h.timestamp), O = async (h) => {
1430
1935
  try {
1431
- await D.pinThread(o.id.replace(/^\//, ""), !o.pinned), A.invalidateQueries({ queryKey: [B, "conversations"] }), ee.success(o.pinned ? t("unpinned_success") : t("pinned_success"));
1936
+ await q.pinThread(h.id.replace(/^\//, ""), !h.pinned), R.invalidateQueries({ queryKey: [V, "conversations"] }), te.success(h.pinned ? t("unpinned_success") : t("pinned_success"));
1432
1937
  } catch {
1433
- ee.error(t("pin_failed"));
1938
+ te.error(t("pin_failed"));
1434
1939
  }
1435
- }, S = async (o) => {
1940
+ }, S = async (h) => {
1436
1941
  try {
1437
- const _ = await D.shareThread(o.id.replace(/^\//, "")), oe = `${window.location.origin}${_.url}`;
1438
- navigator.clipboard.writeText(oe), ee.success(t("share_success"), {
1942
+ const N = await q.shareThread(h.id.replace(/^\//, "")), ie = `${window.location.origin}${N.url}`;
1943
+ navigator.clipboard.writeText(ie), te.success(t("share_success"), {
1439
1944
  description: t("share_description")
1440
1945
  });
1441
1946
  } catch {
1442
- ee.error(t("share_failed"));
1947
+ te.error(t("share_failed"));
1443
1948
  }
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()))
1949
+ }, Z = (h) => {
1950
+ j(h.id), w(h.firstMessage ?? ""), setTimeout(() => m.current?.focus(), 0);
1951
+ }, H = (h) => {
1952
+ h?.preventDefault(), h?.stopPropagation(), j(null), w("");
1953
+ }, z = async (h) => {
1954
+ if (h?.preventDefault(), h && "stopPropagation" in h && h.stopPropagation(), !(!W || !L.trim()))
1450
1955
  try {
1451
- await D.updateThreadTitle(H, b), A.invalidateQueries({ queryKey: [B, "conversations"] }), F(null), ee.success(t("rename_success"));
1956
+ await q.updateThreadTitle(W, L), R.invalidateQueries({ queryKey: [V, "conversations"] }), j(null), te.success(t("rename_success"));
1452
1957
  } catch {
1453
- ee.error(t("rename_failed"));
1958
+ te.error(t("rename_failed"));
1454
1959
  }
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, {
1960
+ }, U = (h) => {
1961
+ G(h), M(!0);
1962
+ }, b = () => {
1963
+ $ && ($a(
1964
+ q,
1965
+ $.id,
1966
+ R,
1967
+ E,
1968
+ I
1969
+ ), M(!1), G(null), te.success(t("chat_deleted_success")));
1970
+ }, l = (h) => new Intl.DateTimeFormat(d.language, {
1460
1971
  year: "numeric",
1461
1972
  month: "short",
1462
1973
  day: "numeric",
1463
1974
  hour: "2-digit",
1464
1975
  minute: "2-digit",
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,
1976
+ calendar: d.language === "fa" ? "persian" : "gregory"
1977
+ }).format(new Date(h));
1978
+ return /* @__PURE__ */ e(Ue, { children: /* @__PURE__ */ s(Ta, { collapsible: "icon", side: a, children: [
1979
+ /* @__PURE__ */ e(Ma, { className: "custom-scrollbar", children: /* @__PURE__ */ s(Aa, { children: [
1980
+ /* @__PURE__ */ e($e, { 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(
1981
+ Fe,
1471
1982
  {
1472
1983
  asChild: !0,
1473
1984
  tooltip: t("tooltip_new_conversation"),
1474
1985
  className: "h-[52px] rounded-2xl bg-white/40 dark:bg-white/5 border border-border/40 hover:border-primary/50 hover:bg-white/90 dark:hover:bg-white/10 text-foreground shadow-[0_4px_12px_-4px_rgba(0,0,0,0.1)] hover:shadow-[0_12px_30px_-10px_var(--glow)] transition-all duration-500 group-data-[collapsible=icon]:size-10 group-data-[collapsible=icon]:p-0! mb-2 group/new-chat overflow-hidden backdrop-blur-md group-data-[collapsible=icon]:mx-auto",
1475
- children: /* @__PURE__ */ r(
1986
+ children: /* @__PURE__ */ s(
1476
1987
  "a",
1477
1988
  {
1478
- href: be(s, "/"),
1479
- onClick: (o) => k(o, "/"),
1989
+ href: xe(p, "/"),
1990
+ onClick: (h) => C(h, "/"),
1480
1991
  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",
1481
1992
  children: [
1482
1993
  /* @__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" }),
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" }) }),
1994
+ /* @__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(Ht, { className: "size-5! text-primary transition-all duration-700 group-hover/new-chat:rotate-180 group-hover/new-chat:scale-110" }) }),
1484
1995
  /* @__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") })
1485
1996
  ]
1486
1997
  }
1487
1998
  )
1488
1999
  }
1489
2000
  ) }) }),
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" }),
2001
+ A && /* @__PURE__ */ e(De, { className: "group-data-[collapsible=icon]:hidden mb-6 px-2", children: /* @__PURE__ */ s("div", { className: "relative group/search", children: [
2002
+ /* @__PURE__ */ e(Ut, { className: "absolute left-3 top-1/2 -translate-y-1/2 size-4 opacity-40 group-focus-within/search:opacity-70 transition-opacity" }),
1492
2003
  /* @__PURE__ */ e(
1493
- X,
2004
+ Y,
1494
2005
  {
1495
2006
  placeholder: t("search_conversations"),
1496
- value: R,
1497
- onChange: (o) => L(o.target.value),
2007
+ value: F,
2008
+ onChange: (h) => J(h.target.value),
1498
2009
  className: "pl-9 h-10 bg-accent/15 border border-border/40 focus-visible:ring-primary/20 rounded-xl transition-all"
1499
2010
  }
1500
2011
  )
1501
2012
  ] }) }),
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: [
2013
+ A && /* @__PURE__ */ s(De, { className: "group-data-[collapsible=icon]:hidden", children: [
2014
+ /* @__PURE__ */ s($e, { children: [
2015
+ f.map((h, N) => {
2016
+ const ie = W === h.id, Ee = Me(h.firstMessage ?? ""), Ze = Ee === "rtl";
2017
+ return /* @__PURE__ */ e(Le, { className: "group/sidebar-menu-item relative", children: ie ? /* @__PURE__ */ s("div", { className: "flex items-center gap-1 px-2 py-1.5 w-full", children: [
1507
2018
  /* @__PURE__ */ e(
1508
- X,
2019
+ Y,
1509
2020
  {
1510
- ref: n,
1511
- value: b,
1512
- onChange: (le) => d(le.target.value),
1513
- onKeyDown: (le) => {
1514
- le.key === "Enter" && Y(), le.key === "Escape" && z();
2021
+ ref: m,
2022
+ value: L,
2023
+ onChange: (ce) => w(ce.target.value),
2024
+ onKeyDown: (ce) => {
2025
+ ce.key === "Enter" && z(), ce.key === "Escape" && H();
1515
2026
  },
1516
2027
  className: "h-8 py-0 px-2 text-sm",
1517
- dir: Te(b)
2028
+ dir: Me(L)
2029
+ }
2030
+ ),
2031
+ /* @__PURE__ */ e(
2032
+ ae,
2033
+ {
2034
+ size: "icon",
2035
+ variant: "ghost",
2036
+ className: "size-8 shrink-0 text-green-600 hover:text-green-700 hover:bg-green-50",
2037
+ onClick: z,
2038
+ children: /* @__PURE__ */ e(Bt, { className: "size-4" })
1518
2039
  }
1519
2040
  ),
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" }) })
1522
- ] }) : /* @__PURE__ */ r(ke, { children: [
1523
2041
  /* @__PURE__ */ e(
1524
- Re,
2042
+ ae,
2043
+ {
2044
+ size: "icon",
2045
+ variant: "ghost",
2046
+ className: "size-8 shrink-0 text-destructive hover:bg-destructive/10",
2047
+ onClick: H,
2048
+ children: /* @__PURE__ */ e(Kt, { className: "size-4" })
2049
+ }
2050
+ )
2051
+ ] }) : /* @__PURE__ */ s(_e, { children: [
2052
+ /* @__PURE__ */ e(
2053
+ Fe,
1525
2054
  {
1526
2055
  asChild: !0,
1527
2056
  className: v("h-auto py-2.5 px-3", {
1528
- "bg-accent opacity-100 pointer-events-none": o.id === U,
1529
- "opacity-70 hover:opacity-100": o.id !== U
2057
+ "bg-accent opacity-100 pointer-events-none": h.id === I,
2058
+ "opacity-70 hover:opacity-100": h.id !== I
1530
2059
  }),
1531
- children: /* @__PURE__ */ r(
2060
+ children: /* @__PURE__ */ s(
1532
2061
  "a",
1533
2062
  {
1534
- href: be(s, o.id),
1535
- onClick: (le) => k(le, o.id),
1536
- dir: Se,
1537
- className: v("flex flex-col gap-0.5 w-full overflow-hidden", Je ? "items-end" : "items-start"),
2063
+ href: xe(p, h.id),
2064
+ onClick: (ce) => C(ce, h.id),
2065
+ dir: Ee,
2066
+ className: v(
2067
+ "flex flex-col gap-0.5 w-full overflow-hidden",
2068
+ Ze ? "items-end" : "items-start"
2069
+ ),
1538
2070
  children: [
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) })
2071
+ /* @__PURE__ */ e(
2072
+ "span",
2073
+ {
2074
+ className: v(
2075
+ "truncate w-full font-medium text-[0.9375rem]",
2076
+ d.language === "fa" ? "pl-16 text-right" : "pr-16 text-left"
2077
+ ),
2078
+ children: h.firstMessage
2079
+ }
2080
+ ),
2081
+ /* @__PURE__ */ e(
2082
+ "div",
2083
+ {
2084
+ className: v(
2085
+ "text-[10px] opacity-40 w-full",
2086
+ d.language === "fa" ? "pl-16 text-right" : "pr-16 text-left"
2087
+ ),
2088
+ children: l(h.timestamp)
2089
+ }
2090
+ )
1541
2091
  ]
1542
2092
  }
1543
2093
  )
1544
2094
  }
1545
2095
  ),
1546
- /* @__PURE__ */ r("div", { className: v(
1547
- "absolute top-1/2 -translate-y-1/2 flex items-center gap-1 transition-all duration-200 z-10",
1548
- i.language === "fa" ? "left-2" : "right-1.5"
1549
- ), children: [
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,
1554
- {
1555
- variant: "ghost",
1556
- size: "icon",
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",
1558
- children: /* @__PURE__ */ e(Bt, { className: "size-3.5" })
1559
- }
1560
- ) }),
1561
- /* @__PURE__ */ r(
1562
- ht,
1563
- {
1564
- align: "end",
1565
- className: "min-w-[120px] p-1",
1566
- children: [
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") })
1570
- ] }),
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" }),
1573
- /* @__PURE__ */ e("span", { children: t("share_conversation") })
1574
- ] }),
1575
- (y?.showRename ?? !1) && /* @__PURE__ */ r(me, { onSelect: () => w(o), className: "cursor-pointer flex items-center gap-2", children: [
1576
- /* @__PURE__ */ e(Ht, { className: "size-4" }),
1577
- /* @__PURE__ */ e("span", { children: t("rename_conversation") })
1578
- ] }),
1579
- (y?.showDelete ?? !1) && /* @__PURE__ */ r(
1580
- me,
2096
+ /* @__PURE__ */ s(
2097
+ "div",
2098
+ {
2099
+ className: v(
2100
+ "absolute top-1/2 -translate-y-1/2 flex items-center gap-1 transition-all duration-200 z-10",
2101
+ d.language === "fa" ? "left-2" : "right-1.5"
2102
+ ),
2103
+ children: [
2104
+ h.pinned && /* @__PURE__ */ e(Re, { 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" }),
2105
+ /* @__PURE__ */ s(mt, { dir: d.language === "fa" ? "rtl" : "ltr", children: [
2106
+ /* @__PURE__ */ e(gt, { asChild: !0, children: /* @__PURE__ */ e(
2107
+ ae,
2108
+ {
2109
+ variant: "ghost",
2110
+ size: "icon",
2111
+ 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",
2112
+ children: /* @__PURE__ */ e(Qt, { className: "size-3.5" })
2113
+ }
2114
+ ) }),
2115
+ /* @__PURE__ */ s(ft, { align: "end", className: "min-w-[120px] p-1", children: [
2116
+ k?.showPin !== !1 && /* @__PURE__ */ s(
2117
+ pe,
2118
+ {
2119
+ onSelect: () => O(h),
2120
+ className: "cursor-pointer flex items-center gap-2",
2121
+ children: [
2122
+ h.pinned ? /* @__PURE__ */ e(Vt, { className: "size-4" }) : /* @__PURE__ */ e(Re, { className: "size-4" }),
2123
+ /* @__PURE__ */ e("span", { children: h.pinned ? t("unpin_conversation") : t("pin_conversation") })
2124
+ ]
2125
+ }
2126
+ ),
2127
+ k?.showShare !== !1 && /* @__PURE__ */ s(
2128
+ pe,
2129
+ {
2130
+ onSelect: () => S(h),
2131
+ className: "cursor-pointer flex items-center gap-2",
2132
+ children: [
2133
+ /* @__PURE__ */ e(Gt, { className: "size-4" }),
2134
+ /* @__PURE__ */ e("span", { children: t("share_conversation") })
2135
+ ]
2136
+ }
2137
+ ),
2138
+ (k?.showRename ?? !1) && /* @__PURE__ */ s(
2139
+ pe,
2140
+ {
2141
+ onSelect: () => Z(h),
2142
+ className: "cursor-pointer flex items-center gap-2",
2143
+ children: [
2144
+ /* @__PURE__ */ e(Wt, { className: "size-4" }),
2145
+ /* @__PURE__ */ e("span", { children: t("rename_conversation") })
2146
+ ]
2147
+ }
2148
+ ),
2149
+ (k?.showDelete ?? !1) && /* @__PURE__ */ s(
2150
+ pe,
1581
2151
  {
1582
2152
  className: "text-destructive focus:text-destructive focus:bg-destructive/10 cursor-pointer flex items-center gap-2",
1583
- onSelect: () => Z(o),
2153
+ onSelect: () => U(h),
1584
2154
  children: [
1585
- /* @__PURE__ */ e(Vt, { className: "size-4" }),
2155
+ /* @__PURE__ */ e(Jt, { className: "size-4" }),
1586
2156
  /* @__PURE__ */ e("span", { children: t("delete_conversation") })
1587
2157
  ]
1588
2158
  }
1589
2159
  )
1590
- ]
1591
- }
1592
- )
1593
- ] })
1594
- ] })
1595
- ] }) }, _);
2160
+ ] })
2161
+ ] })
2162
+ ]
2163
+ }
2164
+ )
2165
+ ] }) }, N);
1596
2166
  }),
1597
- !N && P.length === 0 && !R && /* @__PURE__ */ e("div", { className: "px-4 py-8 text-center text-sm opacity-40", children: t("no_conversations") })
2167
+ !y && P.length === 0 && !F && /* @__PURE__ */ e("div", { className: "px-4 py-8 text-center text-sm opacity-40", children: t("no_conversations") })
1598
2168
  ] }),
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: [
2169
+ /* @__PURE__ */ e("div", { ref: T, className: "h-4 w-full" }),
2170
+ c && /* @__PURE__ */ s("div", { className: "flex flex-col items-center gap-2 p-4 pt-0 opacity-60", children: [
1601
2171
  /* @__PURE__ */ e("div", { className: "size-4 border-2 border-primary border-t-transparent rounded-full animate-spin" }),
1602
2172
  /* @__PURE__ */ e("span", { className: "text-[10px] uppercase tracking-wider font-medium", children: t("loading_more") })
1603
2173
  ] })
1604
2174
  ] })
1605
2175
  ] }) }),
1606
- /* @__PURE__ */ e(ka, {}),
1607
- /* @__PURE__ */ e(He, { open: W, onOpenChange: K, children: /* @__PURE__ */ r(
1608
- Ve,
2176
+ /* @__PURE__ */ e(Ea, {}),
2177
+ /* @__PURE__ */ e(Ge, { open: K, onOpenChange: M, children: /* @__PURE__ */ s(
2178
+ We,
1609
2179
  {
1610
- onKeyDown: (o) => {
1611
- o.key === "Enter" && (o.preventDefault(), se());
2180
+ onKeyDown: (h) => {
2181
+ h.key === "Enter" && (h.preventDefault(), b());
1612
2182
  },
1613
2183
  children: [
1614
- /* @__PURE__ */ r(pt, { children: [
1615
- /* @__PURE__ */ e(gt, { children: t("delete_confirm_title") }),
1616
- /* @__PURE__ */ e(ft, { children: t("delete_confirm_description") })
2184
+ /* @__PURE__ */ s(bt, { children: [
2185
+ /* @__PURE__ */ e(yt, { children: t("delete_confirm_title") }),
2186
+ /* @__PURE__ */ e(vt, { children: t("delete_confirm_description") })
1617
2187
  ] }),
1618
- /* @__PURE__ */ r(bt, { children: [
2188
+ /* @__PURE__ */ s(xt, { children: [
1619
2189
  /* @__PURE__ */ e(
1620
- te,
2190
+ ae,
1621
2191
  {
1622
2192
  variant: "outline",
1623
2193
  onClick: () => {
1624
- K(!1);
2194
+ M(!1);
1625
2195
  },
1626
2196
  children: t("cancel")
1627
2197
  }
1628
2198
  ),
1629
- /* @__PURE__ */ e(te, { variant: "destructive", onClick: se, autoFocus: !0, children: t("delete") })
2199
+ /* @__PURE__ */ e(ae, { variant: "destructive", onClick: b, autoFocus: !0, children: t("delete") })
1630
2200
  ] })
1631
2201
  ]
1632
2202
  }
1633
2203
  ) })
1634
2204
  ] }) });
1635
2205
  }
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,
1640
- /* @__PURE__ */ r("div", { className: "flex flex-col flex-1 h-dvh overflow-hidden relative", children: [
1641
- t !== void 0 ? t : /* @__PURE__ */ e(Xe, {}),
2206
+ function er({
2207
+ sidebar: a,
2208
+ header: t,
2209
+ components: d,
2210
+ classNames: o,
2211
+ disclaimer: n,
2212
+ welcome: i
2213
+ }) {
2214
+ const { config: r } = Oe(), { history: u } = ne(), c = r?.language === "fa" ? "right" : "left", y = u?.enabled ?? !0;
2215
+ return /* @__PURE__ */ s(_a, { defaultOpen: y, children: [
2216
+ a !== void 0 ? a : y ? /* @__PURE__ */ e(La, { side: c }) : null,
2217
+ /* @__PURE__ */ s("div", { className: "flex flex-col flex-1 h-dvh overflow-hidden relative", children: [
2218
+ t !== void 0 ? t : /* @__PURE__ */ e(Ye, {}),
1642
2219
  /* @__PURE__ */ e(
1643
2220
  "div",
1644
2221
  {
@@ -1647,12 +2224,12 @@ function Ga({ sidebar: a, header: t, components: i, classNames: m, disclaimer: c
1647
2224
  "has-[.stick-to-bottom:empty]:overflow-visible has-[.stick-to-bottom:empty]:flex-initial transition-[flex] duration-200"
1648
2225
  ),
1649
2226
  children: /* @__PURE__ */ e(
1650
- oa,
2227
+ ha,
1651
2228
  {
1652
- components: i,
1653
- classNames: m,
1654
- disclaimer: c,
1655
- welcome: u
2229
+ components: d,
2230
+ classNames: o,
2231
+ disclaimer: n,
2232
+ welcome: i
1656
2233
  }
1657
2234
  )
1658
2235
  }
@@ -1660,302 +2237,318 @@ function Ga({ sidebar: a, header: t, components: i, classNames: m, disclaimer: c
1660
2237
  ] })
1661
2238
  ] });
1662
2239
  }
1663
- function Wa({ children: a }) {
1664
- const [t, i] = T(null), m = Ge(), c = _e(), u = ue();
1665
- return $(() => {
2240
+ function tr({ children: a }) {
2241
+ const [t, d] = _(null), o = Je(), n = Te(), i = he(), r = oe();
2242
+ return B(() => {
1666
2243
  (async () => {
1667
- const f = new URLSearchParams(m.search), h = f.get("token");
1668
- if (h)
2244
+ const c = new URLSearchParams(o.search), y = c.get("token");
2245
+ if (y)
1669
2246
  try {
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);
2247
+ r.setToken(y), await r.getBalance(), c.delete("token");
2248
+ const g = c.toString(), p = o.pathname + (g ? `?${g}` : "");
2249
+ n(p, { replace: !0 }), d(!0);
1673
2250
  return;
1674
- } catch (y) {
1675
- console.error("Error validating token from URL:", y), i(!1);
2251
+ } catch (g) {
2252
+ console.error("Error validating token from URL:", g), d(!1);
1676
2253
  return;
1677
2254
  }
1678
- if (!D.getToken()) {
1679
- i(!1);
2255
+ if (!r.getToken()) {
2256
+ d(!1);
1680
2257
  return;
1681
2258
  }
1682
2259
  try {
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);
2260
+ await r.getBalance(), d(!0);
2261
+ } catch (g) {
2262
+ console.error("Token validation failed:", g), g?.status === 401 ? (r.clearToken(), i.clear(), d(!1)) : d(!0);
1686
2263
  }
1687
2264
  })();
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 });
2265
+ }, [o.search, n, o.pathname, i, r]), 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(_e, { children: a }) : /* @__PURE__ */ e(ta, { to: "/login", replace: !0 });
1689
2266
  }
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;
2267
+ const ze = (a) => a.replace(/[^0-9]/g, "");
2268
+ function ar() {
2269
+ const { t: a, i18n: t } = ue(["login", "translation"]), { app: d } = ne(), o = oe(), n = t.dir() === "rtl", i = n ? "text-right" : "text-left", r = Te(), u = he(), [c, y] = _("login"), k = !!d?.disableSignup, g = !!d?.disableAuthPage, [p, A] = _(""), [P, I] = _(""), [E, R] = _(""), [D, T] = _(""), [q, x] = _(""), [V, K] = _(""), M = Q(
2270
+ () => d?.userMetadataFields?.filter((m) => m.showInSignup) || [],
2271
+ [d?.userMetadataFields]
2272
+ ), [$, G] = _(() => {
2273
+ const m = {};
2274
+ return M.forEach((C) => {
2275
+ C.defaultValue !== void 0 && (m[C.key] = C.defaultValue);
2276
+ }), m;
1697
2277
  });
1698
- $(() => {
1699
- const n = { ...E };
1700
- let k = !1;
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);
2278
+ B(() => {
2279
+ const m = { ...$ };
2280
+ let C = !1;
2281
+ M.forEach((f) => {
2282
+ f.condition && !ye(f.condition, $) && m[f.key] !== void 0 && (delete m[f.key], C = !0);
2283
+ }), C && G(m);
2284
+ }, [$, M]);
2285
+ const [F, J] = _(""), [W, j] = _(!1);
2286
+ B(() => {
2287
+ k && c === "register" && y("login");
2288
+ }, [k, c]);
2289
+ const L = async (m) => {
2290
+ m.preventDefault(), J(""), j(!0);
1711
2291
  try {
1712
- await D.login(C, M), g.clear(), u("/");
1713
- } catch (k) {
1714
- L(ce(k, a));
2292
+ await o.login(p, P), u.clear(), r("/");
2293
+ } catch (C) {
2294
+ J(de(C, a));
1715
2295
  } finally {
1716
- F(!1);
2296
+ j(!1);
1717
2297
  }
1718
- }, d = async (n) => {
1719
- n.preventDefault(), L(""), F(!0);
2298
+ }, w = async (m) => {
2299
+ m.preventDefault(), J(""), j(!0);
1720
2300
  try {
1721
- await D.register(U, A, Q, B, E), g.clear(), u("/");
1722
- } catch (k) {
1723
- L(ce(k, a));
2301
+ await o.register(E, D, q, V, $), u.clear(), r("/");
2302
+ } catch (C) {
2303
+ J(de(C, a));
1724
2304
  } finally {
1725
- F(!1);
2305
+ j(!1);
1726
2306
  }
1727
2307
  };
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 }),
1730
- /* @__PURE__ */ e("p", { className: "text-muted-foreground", children: a("auth_page_disabled_title", "The sign-in page is currently disabled.") }),
1731
- /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground/80", children: a("auth_page_disabled_description", "Please contact the administrator for access.") })
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: [
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 }) }),
1734
- /* @__PURE__ */ r("div", { className: "flex bg-muted p-1 rounded-lg mb-6", children: [
1735
- /* @__PURE__ */ e(
1736
- "button",
1737
- {
1738
- type: "button",
1739
- onClick: () => {
1740
- h("login"), L("");
1741
- },
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"}`,
1743
- children: a("login_tab", "Login")
1744
- }
1745
- ),
1746
- !N && /* @__PURE__ */ e(
1747
- "button",
1748
- {
1749
- type: "button",
1750
- onClick: () => {
1751
- h("register"), L("");
1752
- },
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"}`,
1754
- children: a("signup_tab", "Sign Up")
1755
- }
1756
- )
1757
- ] }),
1758
- f === "login" && /* @__PURE__ */ r("form", { onSubmit: b, className: "space-y-4", children: [
1759
- /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1760
- /* @__PURE__ */ e(G, { htmlFor: "login-phone", children: a("phone", "Phone") }),
1761
- /* @__PURE__ */ e(
1762
- X,
1763
- {
1764
- id: "login-phone",
1765
- type: "tel",
1766
- value: C,
1767
- onChange: (n) => s(qe(n.target.value)),
1768
- required: !0,
1769
- className: "text-left",
1770
- placeholder: a("phone_placeholder", "Phone number"),
1771
- dir: "ltr"
1772
- }
1773
- )
1774
- ] }),
1775
- /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1776
- /* @__PURE__ */ e(G, { htmlFor: "login-pass", children: a("password", "Password") }),
1777
- /* @__PURE__ */ e(
1778
- X,
1779
- {
1780
- id: "login-pass",
1781
- type: "password",
1782
- value: M,
1783
- onChange: (n) => P(n.target.value),
1784
- required: !0,
1785
- className: "text-left",
1786
- placeholder: "••••••••",
1787
- dir: "ltr"
1788
- }
1789
- )
1790
- ] }),
1791
- R && /* @__PURE__ */ e("div", { className: "text-sm text-destructive", children: R }),
1792
- /* @__PURE__ */ e(
1793
- te,
1794
- {
1795
- type: "submit",
1796
- disabled: H,
1797
- className: "w-full font-semibold",
1798
- children: H ? a("logging_in", "Logging in...") : a("login_button", "Login")
1799
- }
1800
- )
1801
- ] }),
1802
- !N && f === "register" && /* @__PURE__ */ r("form", { onSubmit: d, className: "space-y-4", children: [
1803
- /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1804
- /* @__PURE__ */ e(G, { htmlFor: "reg-phone", children: a("phone", "Phone") }),
1805
- /* @__PURE__ */ e(
1806
- X,
1807
- {
1808
- id: "reg-phone",
1809
- type: "tel",
1810
- value: U,
1811
- onChange: (n) => q(qe(n.target.value)),
1812
- required: !0,
1813
- className: "text-left",
1814
- placeholder: a("phone_placeholder", "Phone number"),
1815
- dir: "ltr"
1816
- }
1817
- )
1818
- ] }),
1819
- /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1820
- /* @__PURE__ */ e(G, { htmlFor: "reg-pass", children: a("password", "Password") }),
1821
- /* @__PURE__ */ e(
1822
- X,
1823
- {
1824
- id: "reg-pass",
1825
- type: "password",
1826
- value: A,
1827
- onChange: (n) => p(n.target.value),
1828
- required: !0,
1829
- className: "text-left",
1830
- placeholder: "••••••••",
1831
- dir: "ltr"
1832
- }
1833
- )
1834
- ] }),
1835
- /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: [
1836
- /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1837
- /* @__PURE__ */ e(G, { htmlFor: "reg-name", children: a("name", "Name") }),
2308
+ return g ? /* @__PURE__ */ e(
2309
+ "div",
2310
+ {
2311
+ className: "min-h-screen bg-background flex items-center justify-center p-4",
2312
+ dir: t.dir(),
2313
+ children: /* @__PURE__ */ s("div", { className: "w-full max-w-lg bg-card border border-border rounded-xl shadow-lg p-8 text-center space-y-4", children: [
2314
+ /* @__PURE__ */ e("h1", { className: "text-2xl font-bold", children: d?.name }),
2315
+ /* @__PURE__ */ e("p", { className: "text-muted-foreground", children: a("auth_page_disabled_title", "The sign-in page is currently disabled.") }),
2316
+ /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground/80", children: a("auth_page_disabled_description", "Please contact the administrator for access.") })
2317
+ ] })
2318
+ }
2319
+ ) : /* @__PURE__ */ e(
2320
+ "div",
2321
+ {
2322
+ className: "min-h-screen bg-background flex flex-col items-center justify-center p-4",
2323
+ dir: t.dir(),
2324
+ children: /* @__PURE__ */ s("div", { className: "w-full max-w-md bg-card border border-border rounded-xl shadow-lg p-6", children: [
2325
+ /* @__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: d?.name }) }),
2326
+ /* @__PURE__ */ s("div", { className: "flex bg-muted p-1 rounded-lg mb-6", children: [
1838
2327
  /* @__PURE__ */ e(
1839
- X,
2328
+ "button",
1840
2329
  {
1841
- id: "reg-name",
1842
- type: "text",
1843
- value: Q,
1844
- onChange: (n) => x(n.target.value),
1845
- required: !0,
1846
- className: c,
1847
- placeholder: a("name_placeholder", "First Name")
2330
+ type: "button",
2331
+ onClick: () => {
2332
+ y("login"), J("");
2333
+ },
2334
+ className: `flex-1 py-2 text-sm font-medium rounded-md transition-all ${c === "login" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
2335
+ children: a("login_tab", "Login")
1848
2336
  }
1849
- )
1850
- ] }),
1851
- /* @__PURE__ */ r("div", { className: "space-y-3", children: [
1852
- /* @__PURE__ */ e(G, { htmlFor: "reg-surname", children: a("surname", "Surname") }),
1853
- /* @__PURE__ */ e(
1854
- X,
2337
+ ),
2338
+ !k && /* @__PURE__ */ e(
2339
+ "button",
1855
2340
  {
1856
- id: "reg-surname",
1857
- type: "text",
1858
- value: B,
1859
- onChange: (n) => W(n.target.value),
1860
- required: !0,
1861
- className: c,
1862
- placeholder: a("surname_placeholder", "Last Name")
2341
+ type: "button",
2342
+ onClick: () => {
2343
+ y("register"), J("");
2344
+ },
2345
+ className: `flex-1 py-2 text-sm font-medium rounded-md transition-all ${c === "register" ? "bg-background shadow-sm text-foreground" : "text-muted-foreground hover:text-foreground"}`,
2346
+ children: a("signup_tab", "Sign Up")
1863
2347
  }
1864
2348
  )
1865
- ] })
1866
- ] }),
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,
1871
- {
1872
- value: String(E[n.key] || ""),
1873
- onValueChange: (k) => V({ ...E, [n.key]: k }),
1874
- required: n.required,
1875
- dir: m ? "rtl" : "ltr",
1876
- children: [
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))) })
1879
- ]
1880
- }
1881
- ) : n.type === "checkbox" ? /* @__PURE__ */ r("div", { className: "flex items-center gap-2 py-2", children: [
1882
- /* @__PURE__ */ e(
1883
- xt,
2349
+ ] }),
2350
+ c === "login" && /* @__PURE__ */ s("form", { onSubmit: L, className: "space-y-4", children: [
2351
+ /* @__PURE__ */ s("div", { className: "space-y-3", children: [
2352
+ /* @__PURE__ */ e(X, { htmlFor: "login-phone", children: a("phone", "Phone") }),
2353
+ /* @__PURE__ */ e(
2354
+ Y,
2355
+ {
2356
+ id: "login-phone",
2357
+ type: "tel",
2358
+ value: p,
2359
+ onChange: (m) => A(ze(m.target.value)),
2360
+ required: !0,
2361
+ className: "text-left",
2362
+ placeholder: a("phone_placeholder", "Phone number"),
2363
+ dir: "ltr"
2364
+ }
2365
+ )
2366
+ ] }),
2367
+ /* @__PURE__ */ s("div", { className: "space-y-3", children: [
2368
+ /* @__PURE__ */ e(X, { htmlFor: "login-pass", children: a("password", "Password") }),
2369
+ /* @__PURE__ */ e(
2370
+ Y,
2371
+ {
2372
+ id: "login-pass",
2373
+ type: "password",
2374
+ value: P,
2375
+ onChange: (m) => I(m.target.value),
2376
+ required: !0,
2377
+ className: "text-left",
2378
+ placeholder: "••••••••",
2379
+ dir: "ltr"
2380
+ }
2381
+ )
2382
+ ] }),
2383
+ F && /* @__PURE__ */ e("div", { className: "text-sm text-destructive", children: F }),
2384
+ /* @__PURE__ */ e(ae, { type: "submit", disabled: W, className: "w-full font-semibold", children: W ? a("logging_in", "Logging in...") : a("login_button", "Login") })
2385
+ ] }),
2386
+ !k && c === "register" && /* @__PURE__ */ s("form", { onSubmit: w, className: "space-y-4", children: [
2387
+ /* @__PURE__ */ s("div", { className: "space-y-3", children: [
2388
+ /* @__PURE__ */ e(X, { htmlFor: "reg-phone", children: a("phone", "Phone") }),
2389
+ /* @__PURE__ */ e(
2390
+ Y,
2391
+ {
2392
+ id: "reg-phone",
2393
+ type: "tel",
2394
+ value: E,
2395
+ onChange: (m) => R(ze(m.target.value)),
2396
+ required: !0,
2397
+ className: "text-left",
2398
+ placeholder: a("phone_placeholder", "Phone number"),
2399
+ dir: "ltr"
2400
+ }
2401
+ )
2402
+ ] }),
2403
+ /* @__PURE__ */ s("div", { className: "space-y-3", children: [
2404
+ /* @__PURE__ */ e(X, { htmlFor: "reg-pass", children: a("password", "Password") }),
2405
+ /* @__PURE__ */ e(
2406
+ Y,
2407
+ {
2408
+ id: "reg-pass",
2409
+ type: "password",
2410
+ value: D,
2411
+ onChange: (m) => T(m.target.value),
2412
+ required: !0,
2413
+ className: "text-left",
2414
+ placeholder: "••••••••",
2415
+ dir: "ltr"
2416
+ }
2417
+ )
2418
+ ] }),
2419
+ /* @__PURE__ */ s("div", { className: "grid grid-cols-2 gap-4", children: [
2420
+ /* @__PURE__ */ s("div", { className: "space-y-3", children: [
2421
+ /* @__PURE__ */ e(X, { htmlFor: "reg-name", children: a("name", "Name") }),
2422
+ /* @__PURE__ */ e(
2423
+ Y,
2424
+ {
2425
+ id: "reg-name",
2426
+ type: "text",
2427
+ value: q,
2428
+ onChange: (m) => x(m.target.value),
2429
+ required: !0,
2430
+ className: i,
2431
+ placeholder: a("name_placeholder", "First Name")
2432
+ }
2433
+ )
2434
+ ] }),
2435
+ /* @__PURE__ */ s("div", { className: "space-y-3", children: [
2436
+ /* @__PURE__ */ e(X, { htmlFor: "reg-surname", children: a("surname", "Surname") }),
2437
+ /* @__PURE__ */ e(
2438
+ Y,
2439
+ {
2440
+ id: "reg-surname",
2441
+ type: "text",
2442
+ value: V,
2443
+ onChange: (m) => K(m.target.value),
2444
+ required: !0,
2445
+ className: i,
2446
+ placeholder: a("surname_placeholder", "Last Name")
2447
+ }
2448
+ )
2449
+ ] })
2450
+ ] }),
2451
+ M.map((m) => ye(m.condition, $) ? /* @__PURE__ */ s(
2452
+ "div",
1884
2453
  {
1885
- id: `signup-${n.key}`,
1886
- checked: !!E[n.key],
1887
- onCheckedChange: (k) => V({ ...E, [n.key]: !!k }),
1888
- required: n.required
1889
- }
1890
- ),
1891
- /* @__PURE__ */ e("label", { htmlFor: `signup-${n.key}`, className: "text-sm text-muted-foreground cursor-pointer select-none", children: a(n.placeholder || n.label) })
1892
- ] }) : /* @__PURE__ */ e(
1893
- X,
1894
- {
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 || "")
1902
- }
1903
- )
1904
- ] }, n.key) : null),
1905
- R && /* @__PURE__ */ e("div", { className: "text-sm text-destructive", children: R }),
1906
- /* @__PURE__ */ e(
1907
- te,
1908
- {
1909
- type: "submit",
1910
- disabled: H,
1911
- className: "w-full font-semibold",
1912
- children: H ? a("signing_up", "Signing up...") : a("signup_button", "Sign Up")
1913
- }
1914
- )
1915
- ] })
1916
- ] }) });
2454
+ className: "space-y-3 animate-in fade-in slide-in-from-top-1 duration-200",
2455
+ children: [
2456
+ /* @__PURE__ */ e(X, { htmlFor: `signup-${m.key}`, children: a(m.label) }),
2457
+ m.type === "select" ? /* @__PURE__ */ s(
2458
+ we,
2459
+ {
2460
+ value: String($[m.key] || ""),
2461
+ onValueChange: (C) => G({ ...$, [m.key]: C }),
2462
+ required: m.required,
2463
+ dir: n ? "rtl" : "ltr",
2464
+ children: [
2465
+ /* @__PURE__ */ e(Ne, { className: v("bg-background", i), children: /* @__PURE__ */ e(ke, { placeholder: a(m.placeholder || "select_placeholder") }) }),
2466
+ /* @__PURE__ */ e(Se, { className: "rounded-xl", children: m.options?.map((C) => /* @__PURE__ */ e(fe, { value: String(C.value), children: a(C.label) }, String(C.value))) })
2467
+ ]
2468
+ }
2469
+ ) : m.type === "checkbox" ? /* @__PURE__ */ s("div", { className: "flex items-center gap-2 py-2", children: [
2470
+ /* @__PURE__ */ e(
2471
+ wt,
2472
+ {
2473
+ id: `signup-${m.key}`,
2474
+ checked: !!$[m.key],
2475
+ onCheckedChange: (C) => G({ ...$, [m.key]: !!C }),
2476
+ required: m.required
2477
+ }
2478
+ ),
2479
+ /* @__PURE__ */ e(
2480
+ "label",
2481
+ {
2482
+ htmlFor: `signup-${m.key}`,
2483
+ className: "text-sm text-muted-foreground cursor-pointer select-none",
2484
+ children: a(m.placeholder || m.label)
2485
+ }
2486
+ )
2487
+ ] }) : /* @__PURE__ */ e(
2488
+ Y,
2489
+ {
2490
+ id: `signup-${m.key}`,
2491
+ type: m.type,
2492
+ value: $[m.key] || "",
2493
+ onChange: (C) => G({ ...$, [m.key]: C.target.value }),
2494
+ required: m.required,
2495
+ className: i,
2496
+ placeholder: a(m.placeholder || "")
2497
+ }
2498
+ )
2499
+ ]
2500
+ },
2501
+ m.key
2502
+ ) : null),
2503
+ F && /* @__PURE__ */ e("div", { className: "text-sm text-destructive", children: F }),
2504
+ /* @__PURE__ */ e(ae, { type: "submit", disabled: W, className: "w-full font-semibold", children: W ? a("signing_up", "Signing up...") : a("signup_button", "Sign Up") })
2505
+ ] })
2506
+ ] })
2507
+ }
2508
+ );
1917
2509
  }
1918
- function Da() {
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
- }, []), $(() => {
2510
+ function Fa() {
2511
+ const { shareId: a } = aa(), [t, d] = _(null), [o, n] = _(!0), [i, r] = _(null), { MessageList: u } = ne(), c = oe(), y = re(/* @__PURE__ */ new Set());
2512
+ return B(() => () => {
2513
+ y.current.forEach((k) => URL.revokeObjectURL(k)), y.current.clear();
2514
+ }, []), B(() => {
1923
2515
  if (!a) return;
1924
2516
  (async () => {
1925
2517
  try {
1926
- c(!0);
1927
- const y = await D.getSharedThread(a);
1928
- y.items && (y.items = await Promise.all(
1929
- y.items.map(async (C) => {
1930
- if (!C.parts) return C;
1931
- const s = await Promise.all(
1932
- C.parts.map(async (M) => {
1933
- if (M.type === "file" && M.object_name && !M.url)
2518
+ n(!0);
2519
+ const g = await c.getSharedThread(a);
2520
+ g.items && (g.items = await Promise.all(
2521
+ g.items.map(async (p) => {
2522
+ if (!p.parts) return p;
2523
+ const A = await Promise.all(
2524
+ p.parts.map(async (P) => {
2525
+ const I = ge(P);
2526
+ if (I.type === "file" && I.object_name && !I.url)
1934
2527
  try {
1935
- const P = await D.getPublicAttachmentBlobUrl(M.object_name);
1936
- return h.current.add(P), { ...M, url: P };
1937
- } catch (P) {
1938
- console.error("Failed to resolve shared attachment:", M.object_name, P);
2528
+ const E = await c.getPublicAttachmentBlobUrl(I.object_name);
2529
+ return y.current.add(E), { ...I, url: E };
2530
+ } catch (E) {
2531
+ console.error("Failed to resolve shared attachment:", I.object_name, E);
1939
2532
  }
1940
- return M;
2533
+ return I;
1941
2534
  })
1942
2535
  );
1943
- return { ...C, parts: s };
2536
+ return { ...p, parts: A };
1944
2537
  })
1945
- )), i(y);
1946
- } catch (y) {
1947
- console.error("Failed to fetch shared chat:", y), g(y.message || "Failed to load shared chat");
2538
+ )), d(g);
2539
+ } catch (g) {
2540
+ console.error("Failed to fetch shared chat:", g), r(g instanceof Error ? g.message : "Failed to load shared chat");
1948
2541
  } finally {
1949
- c(!1);
2542
+ n(!1);
1950
2543
  }
1951
2544
  })();
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: [
2545
+ }, [a, c]), o ? /* @__PURE__ */ e("div", { className: "flex h-dvh items-center justify-center", children: /* @__PURE__ */ e(Nt, {}) }) : i || !t ? /* @__PURE__ */ s("div", { className: "flex h-dvh flex-col items-center justify-center p-4 text-center", children: [
1953
2546
  /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-destructive mb-2 font-display", children: "Shared Chat Not Found" }),
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." })
1955
- ] }) : /* @__PURE__ */ r("div", { className: "relative flex flex-col h-dvh overflow-hidden bg-background", children: [
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,
2547
+ /* @__PURE__ */ e("p", { className: "text-muted-foreground max-w-md", children: i || "This shared conversation might have been deleted or the link is invalid." })
2548
+ ] }) : /* @__PURE__ */ s("div", { className: "relative flex flex-col h-dvh overflow-hidden bg-background", children: [
2549
+ /* @__PURE__ */ e(Ye, { hideActions: !0 }),
2550
+ /* @__PURE__ */ e("div", { className: "flex-1 min-h-0 overflow-hidden relative flex flex-col", children: /* @__PURE__ */ e(He, { readonly: !0, children: /* @__PURE__ */ e(
2551
+ u,
1959
2552
  {
1960
2553
  messages: t.items || [],
1961
2554
  status: "ready",
@@ -1972,47 +2565,48 @@ function Da() {
1972
2565
  ) }) })
1973
2566
  ] });
1974
2567
  }
1975
- function Ja() {
1976
- return /* @__PURE__ */ e(Da, {});
2568
+ function rr() {
2569
+ return /* @__PURE__ */ e(Fa, {});
1977
2570
  }
1978
2571
  export {
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,
1993
- we as SelectContent,
1994
- hr as SelectGroup,
1995
- pe as SelectItem,
1996
- pr as SelectLabel,
1997
- gr as SelectScrollDownButton,
1998
- fr as SelectScrollUpButton,
1999
- br as SelectSeparator,
2000
- ve as SelectTrigger,
2001
- ye as SelectValue,
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
2572
+ La as AppSidebar,
2573
+ ha as Chat,
2574
+ er as ChatUI,
2575
+ ur as ChoiceQuestionPart,
2576
+ hr as FilePart,
2577
+ Za as GentiqProvider,
2578
+ pr as MessageList,
2579
+ mr as Part,
2580
+ gr as PromptInputArea,
2581
+ fr as ReasoningPart,
2582
+ br as ReferencePart,
2583
+ yr as Referenceable,
2584
+ tr as RequireAuth,
2585
+ we as Select,
2586
+ Se as SelectContent,
2587
+ vr as SelectGroup,
2588
+ fe as SelectItem,
2589
+ xr as SelectLabel,
2590
+ wr as SelectScrollDownButton,
2591
+ Nr as SelectScrollUpButton,
2592
+ kr as SelectSeparator,
2593
+ Ne as SelectTrigger,
2594
+ ke as SelectValue,
2595
+ Ra as SettingsDialog,
2596
+ rr as SharedChatView,
2597
+ _a as SidebarProvider,
2598
+ Sr as TextPart,
2599
+ Cr as ToolPart,
2600
+ or as Trans,
2601
+ ir as Translation,
2602
+ ar as UserLoginPage,
2603
+ _r as WelcomeScreen,
2604
+ la as createGentiqApi,
2605
+ Tr as useChatReferences,
2606
+ ne as useComponents,
2607
+ oe as useGentiqApi,
2608
+ da as useGentiqChat,
2609
+ Pr as useGentiqUser,
2610
+ lr as useTranslation,
2611
+ cr as withTranslation
2018
2612
  };