gentiq 0.7.28 → 0.7.30

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