gentiq 0.7.30 → 0.7.31

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