gentiq 0.8.1 → 0.8.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,15 +1,15 @@
1
- import { jsx as e, jsxs as r, Fragment as mt } from "react/jsx-runtime";
1
+ import { jsx as e, jsxs as r, Fragment as ut } from "react/jsx-runtime";
2
2
  import { useState as p, useEffect as Y, useMemo as Ce, useRef as Le } from "react";
3
- import ut from "i18next";
4
- import { useTranslation as me, initReactI18next as ht, I18nextProvider as pt } from "react-i18next";
5
- import { G as Ue, a as Ne, m as De, w as He, e as Te, n as Oe, D as We, p as Ge, F as Ke, H as Ze, J as Qe, S as oe, q as le, r as de, s as ce, t as Z, M as gt, o as ft, K as xt, a2 as bt, B as Se, L as X, I as fe, a3 as Fe, i as Ae, k as Ie, l as Me, y as vt, z as yt, A as _t, E as Nt, a4 as wt, d as kt, T as St } from "./checkbox-XoTpU9VY.js";
6
- import { useNavigate as Ct, useLocation as Lt, Routes as qt, Route as ge, Navigate as Re } from "react-router-dom";
7
- import { Share2 as jt, Info as Tt, ArrowUpDown as At, ArrowUp as It, ArrowDown as Mt, RefreshCcw as Pe, Globe as je, Palette as Dt, Keyboard as $t, Wallet as Et, Languages as Ut, Plus as Ot, Hash as Ft, ShieldAlert as Rt, Monitor as ze, Moon as Pt, Sun as zt, LogOut as Jt } from "lucide-react";
8
- import { toast as Je } from "sonner";
9
- import * as Ve from "@radix-ui/react-switch";
10
- import { useQuery as we, useQueryClient as $e, useMutation as ue } from "@tanstack/react-query";
11
- const Be = "/api";
12
- class Vt {
3
+ import ht from "i18next";
4
+ import { useTranslation as ue, initReactI18next as pt, I18nextProvider as gt } from "react-i18next";
5
+ import { G as Ue, a as Ne, n as De, x as We, a7 as ft, P as Oe, f as Te, o as Fe, D as Ge, q as Ke, H as Qe, J as Ze, K as Xe, S as le, r as de, s as ce, t as me, v as Q, N as xt, p as bt, M as vt, a8 as yt, B as Se, L as X, I as fe, a9 as Re, k as Ae, l as Ie, m as Me, z as _t, A as Nt, E as wt, F as kt, aa as St, d as Ct, T as Lt } from "./checkbox-BZPTGt7D.js";
6
+ import { useNavigate as qt, useLocation as jt, Routes as Tt, Route as ge, Navigate as Pe } from "react-router-dom";
7
+ import { Share2 as At, Info as It, ArrowUpDown as Mt, ArrowUp as Dt, ArrowDown as $t, RefreshCcw as ze, Globe as je, Palette as Et, Keyboard as Ut, Wallet as Ot, Languages as Ft, Plus as Rt, Hash as Pt, ShieldAlert as zt, Monitor as Je, Moon as Jt, Sun as Vt, LogOut as Bt } from "lucide-react";
8
+ import { toast as Ve } from "sonner";
9
+ import * as Be from "@radix-ui/react-switch";
10
+ import { useQuery as we, useQueryClient as $e, useMutation as he } from "@tanstack/react-query";
11
+ const He = "/api";
12
+ class Ht {
13
13
  token = null;
14
14
  constructor() {
15
15
  this.token = localStorage.getItem("admin_token");
@@ -26,24 +26,24 @@ class Vt {
26
26
  async request(i, o = {}) {
27
27
  const d = new Headers(o.headers);
28
28
  d.has("Content-Type") || d.set("Content-Type", "application/json"), this.token && d.set("Authorization", `Bearer ${this.token}`);
29
- const g = await fetch(`${Be}${i}`, {
29
+ const f = await fetch(`${He}${i}`, {
30
30
  ...o,
31
31
  headers: d
32
32
  });
33
- if (!g.ok) {
34
- const c = await g.json().catch(() => ({}));
35
- if (c.error && (typeof c.error.code == "string" || typeof c.error.message == "string"))
36
- throw new Ue(c, g.status);
37
- let x = `HTTP ${g.status}`, N = "error", _ = null;
38
- throw typeof c.detail == "string" ? x = c.detail : typeof c.message == "string" ? x = c.message : typeof c.error == "string" ? x = c.error : Array.isArray(c.detail) ? (x = "Validation failed", _ = c.detail, N = "validation_error") : c.error && typeof c.error.message == "string" && (x = c.error.message), new Ue({
33
+ if (!f.ok) {
34
+ const m = await f.json().catch(() => ({}));
35
+ if (m.error && (typeof m.error.code == "string" || typeof m.error.message == "string"))
36
+ throw new Ue(m, f.status);
37
+ let b = `HTTP ${f.status}`, N = "error", _ = null;
38
+ throw typeof m.detail == "string" ? b = m.detail : typeof m.message == "string" ? b = m.message : typeof m.error == "string" ? b = m.error : Array.isArray(m.detail) ? (b = "Validation failed", _ = m.detail, N = "validation_error") : m.error && typeof m.error.message == "string" && (b = m.error.message), new Ue({
39
39
  error: {
40
40
  code: N,
41
- message: x,
41
+ message: b,
42
42
  details: _
43
43
  }
44
- }, g.status);
44
+ }, f.status);
45
45
  }
46
- return g.json();
46
+ return f.json();
47
47
  }
48
48
  async login(i, o) {
49
49
  const d = await this.request("/admin/login", {
@@ -51,21 +51,21 @@ class Vt {
51
51
  body: JSON.stringify({ username: i, password: o })
52
52
  });
53
53
  this.setToken(d.token);
54
- const g = {
54
+ const f = {
55
55
  admin_id: d.admin_id,
56
56
  username: d.username,
57
57
  name: d.name,
58
58
  permissions: d.permissions
59
59
  };
60
- return localStorage.setItem("admin_info", JSON.stringify(g)), d;
60
+ return localStorage.setItem("admin_info", JSON.stringify(f)), d;
61
61
  }
62
62
  async checkSetupStatus() {
63
63
  return this.request("/admin/setup-status");
64
64
  }
65
- async register(i, o, d, g) {
65
+ async register(i, o, d, f) {
66
66
  return this.request("/admin/admins", {
67
67
  method: "POST",
68
- body: JSON.stringify({ username: i, password: o, name: d, permissions: g })
68
+ body: JSON.stringify({ username: i, password: o, name: d, permissions: f })
69
69
  });
70
70
  }
71
71
  async listAdmins() {
@@ -85,9 +85,9 @@ class Vt {
85
85
  async listPermissions() {
86
86
  return this.request("/admin/permissions");
87
87
  }
88
- async listThreads(i = 0, o = 50, d, g) {
89
- const c = new URLSearchParams({ skip: i.toString(), limit: o.toString() });
90
- return d && c.append("query", d), g && c.append("feedback", g), this.request(`/admin/chat-history/threads?${c}`);
88
+ async listThreads(i = 0, o = 50, d, f) {
89
+ const m = new URLSearchParams({ skip: i.toString(), limit: o.toString() });
90
+ return d && m.append("query", d), f && m.append("feedback", f), this.request(`/admin/chat-history/threads?${m}`);
91
91
  }
92
92
  async getThreadItems(i) {
93
93
  return this.request(`/admin/chat-history/threads/${i}/items`);
@@ -97,21 +97,21 @@ class Vt {
97
97
  method: "POST"
98
98
  });
99
99
  }
100
- async listUsers(i = 0, o = 100, d = "", g = "name", c = "asc") {
101
- const x = new URLSearchParams({
100
+ async listUsers(i = 0, o = 100, d = "", f = "name", m = "asc") {
101
+ const b = new URLSearchParams({
102
102
  skip: i.toString(),
103
103
  limit: o.toString(),
104
- sort_by: g,
105
- sort_order: c
104
+ sort_by: f,
105
+ sort_order: m
106
106
  });
107
- return d && x.append("query", d), this.request(`/admin/users?${x.toString()}`);
107
+ return d && b.append("query", d), this.request(`/admin/users?${b.toString()}`);
108
108
  }
109
- async createUser(i, o, d, g, c, x, N, _, B) {
110
- const M = g !== void 0 || c !== void 0 || x !== void 0 || N !== void 0 ? {
111
- tokens: g || 0,
112
- requests: c || 0,
113
- token_limit: x || g || 0,
114
- request_limit: N || c || 0
109
+ async createUser(i, o, d, f, m, b, N, _, B) {
110
+ const M = f !== void 0 || m !== void 0 || b !== void 0 || N !== void 0 ? {
111
+ tokens: f || 0,
112
+ requests: m || 0,
113
+ token_limit: b || f || 0,
114
+ request_limit: N || m || 0
115
115
  } : void 0;
116
116
  return this.request("/admin/users", {
117
117
  method: "POST",
@@ -129,10 +129,10 @@ class Vt {
129
129
  method: "DELETE"
130
130
  });
131
131
  }
132
- async updateUserBalance(i, o, d, g, c) {
132
+ async updateUserBalance(i, o, d, f, m) {
133
133
  return this.request(`/admin/users/${i}/balance`, {
134
134
  method: "POST",
135
- body: JSON.stringify({ tokens: o, requests: d, token_limit: g, request_limit: c })
135
+ body: JSON.stringify({ tokens: o, requests: d, token_limit: f, request_limit: m })
136
136
  });
137
137
  }
138
138
  async refreshUserToken(i) {
@@ -172,41 +172,41 @@ class Vt {
172
172
  async getAttachmentBlob(i) {
173
173
  const o = {};
174
174
  this.token && (o.Authorization = `Bearer ${this.token}`);
175
- const d = await fetch(`${Be}/admin/chat-history/attachments/${i}`, {
175
+ const d = await fetch(`${He}/admin/chat-history/attachments/${i}`, {
176
176
  method: "GET",
177
177
  headers: o
178
178
  });
179
179
  if (!d.ok) {
180
- const g = await d.json().catch(() => ({ error: "Request failed" }));
181
- throw new Error(g.error || `HTTP ${d.status}`);
180
+ const f = await d.json().catch(() => ({ error: "Request failed" }));
181
+ throw new Error(f.error || `HTTP ${d.status}`);
182
182
  }
183
183
  return d.blob();
184
184
  }
185
185
  }
186
- const w = new Vt();
187
- function Bt({ onLoginSuccess: t }) {
188
- const { t: i, i18n: o } = me(["admin", "translation"]), { app: d } = Ne(), { theme: g } = De(), [c, x] = p(""), [N, _] = p(""), [B, M] = p(""), [A, F] = p(""), [R, k] = p(!1), [$, H] = p(null), [S, D] = p("light");
186
+ const w = new Ht();
187
+ function Wt({ onLoginSuccess: t }) {
188
+ const { t: i, i18n: o } = ue(["admin", "translation"]), { app: d } = Ne(), { theme: f } = De(), [m, b] = p(""), [N, _] = p(""), [B, M] = p(""), [A, F] = p(""), [R, k] = p(!1), [$, H] = p(null), [C, D] = p("light");
189
189
  Y(() => {
190
- if (g === "system") {
190
+ if (f === "system") {
191
191
  const h = window.matchMedia("(prefers-color-scheme: dark)").matches;
192
192
  D(h ? "dark" : "light");
193
193
  } else
194
- D(g);
195
- }, [g]);
196
- const K = Ce(() => d?.logo ? typeof d.logo == "string" ? d.logo : S === "dark" ? d.logo.dark : d.logo.light : He, [d?.logo, S]), W = d?.adminTitle || d?.name, P = o.language === "fa";
194
+ D(f);
195
+ }, [f]);
196
+ const K = Ce(() => d?.logo ? typeof d.logo == "string" ? d.logo : C === "dark" ? d.logo.dark : d.logo.light : We, [d?.logo, C]), W = d?.adminTitle || d?.name, P = o.language === "fa";
197
197
  Y(() => {
198
198
  w.checkSetupStatus().then((h) => H(h.needs_setup)).catch(() => H(!1));
199
199
  }, []);
200
200
  const ae = async (h) => {
201
201
  h.preventDefault(), F(""), k(!0);
202
202
  try {
203
- await w.login(c, N), t();
203
+ await w.login(m, N), t();
204
204
  } catch (E) {
205
205
  F(E instanceof Error ? E.message : i("login.error"));
206
206
  } finally {
207
207
  k(!1);
208
208
  }
209
- }, Q = async (h) => {
209
+ }, Z = async (h) => {
210
210
  if (h.preventDefault(), F(""), N !== B) {
211
211
  F(i("login.passwords_mismatch"));
212
212
  return;
@@ -243,7 +243,7 @@ function Bt({ onLoginSuccess: t }) {
243
243
  ] }),
244
244
  $ ? (
245
245
  /* ---- SETUP FORM ---- */
246
- /* @__PURE__ */ r("form", { onSubmit: Q, className: "space-y-7", children: [
246
+ /* @__PURE__ */ r("form", { onSubmit: Z, className: "space-y-7", children: [
247
247
  /* @__PURE__ */ r("div", { children: [
248
248
  /* @__PURE__ */ e("label", { className: "block text-xs font-bold text-muted-foreground uppercase tracking-widest mb-3.5 mx-1", children: i("login.username") }),
249
249
  /* @__PURE__ */ e(
@@ -312,8 +312,8 @@ function Bt({ onLoginSuccess: t }) {
312
312
  {
313
313
  id: "username",
314
314
  type: "text",
315
- value: c,
316
- onChange: (h) => x(h.target.value),
315
+ value: m,
316
+ onChange: (h) => b(h.target.value),
317
317
  required: !0,
318
318
  className: "w-full px-5 py-3.5 rounded-2xl border-0 bg-card text-foreground placeholder-muted-foreground focus:ring-2 focus:ring-primary/20 transition-all text-sm shadow-sm text-left",
319
319
  placeholder: i("login.username_placeholder"),
@@ -357,7 +357,7 @@ function Bt({ onLoginSuccess: t }) {
357
357
  ] })
358
358
  ] });
359
359
  }
360
- function Xe(t, i, o) {
360
+ function Ye(t, i, o) {
361
361
  const d = (t || 0) / 1e6;
362
362
  try {
363
363
  return new Intl.NumberFormat(o, {
@@ -386,41 +386,41 @@ function xe(t, i, o) {
386
386
  })}`;
387
387
  }
388
388
  }
389
- function Ht() {
390
- const { t, i18n: i } = me(["admin", "translation"]), { app: o } = Ne(), d = o?.userMetadataFields || [], [g, c] = p([]), [x, N] = p(null), [_, B] = p([]), [M, A] = p(!1), [F, R] = p(!1), [k, $] = p(""), [H, S] = p(""), [D, K] = p(""), [W, P] = p(0), [ae, Q] = p(!0), h = i.language === "fa", E = h ? "fa-IR" : "en-US", U = async (n = !1) => {
389
+ function Gt() {
390
+ const { t, i18n: i } = ue(["admin", "translation"]), { app: o } = Ne(), d = o?.userMetadataFields || [], [f, m] = p([]), [b, N] = p(null), [_, B] = p([]), [M, A] = p(!1), [F, R] = p(!1), [k, $] = p(""), [H, C] = p(""), [D, K] = p(""), [W, P] = p(0), [ae, Z] = p(!0), h = i.language === "fa", E = h ? "fa-IR" : "en-US", U = async (n = !1) => {
391
391
  n ? R(!0) : (A(!0), P(0)), $("");
392
392
  try {
393
- const m = n ? W + 50 : 0, v = await w.listThreads(
394
- m,
393
+ const c = n ? W + 50 : 0, g = await w.listThreads(
394
+ c,
395
395
  50,
396
396
  H || void 0,
397
397
  D || void 0
398
398
  );
399
- n ? (c((L) => [...L, ...v.threads]), P(m)) : (c(v.threads), P(0)), Q(v.threads.length === 50);
400
- } catch (m) {
401
- $(m instanceof Error ? m.message : t("error_loading"));
399
+ n ? (m((S) => [...S, ...g.threads]), P(c)) : (m(g.threads), P(0)), Z(g.threads.length === 50);
400
+ } catch (c) {
401
+ $(c instanceof Error ? c.message : t("error_loading"));
402
402
  } finally {
403
403
  A(!1), R(!1);
404
404
  }
405
- }, f = async (n) => {
405
+ }, x = async (n) => {
406
406
  N(n), A(!0), $("");
407
407
  try {
408
- const m = await w.getThreadItems(n.id);
409
- B(m.items);
410
- } catch (m) {
411
- $(m instanceof Error ? m.message : t("error_loading"));
408
+ const c = await w.getThreadItems(n.id);
409
+ B(c.items);
410
+ } catch (c) {
411
+ $(c instanceof Error ? c.message : t("error_loading"));
412
412
  } finally {
413
413
  A(!1);
414
414
  }
415
- }, q = async (n, m) => {
415
+ }, j = async (n, c) => {
416
416
  n.stopPropagation();
417
417
  try {
418
- const v = await w.shareThread(m.id), L = `${window.location.origin}${v.url}`;
419
- navigator.clipboard.writeText(L), Je.success(t("sidebar.share_success"), {
418
+ const g = await w.shareThread(c.id), S = `${window.location.origin}${g.url}`;
419
+ navigator.clipboard.writeText(S), Ve.success(t("sidebar.share_success"), {
420
420
  description: t("sidebar.share_description")
421
421
  });
422
422
  } catch {
423
- Je.error(t("sidebar.share_failed"));
423
+ Ve.error(t("sidebar.share_failed"));
424
424
  }
425
425
  };
426
426
  Y(() => {
@@ -430,14 +430,14 @@ function Ht() {
430
430
  return () => clearTimeout(n);
431
431
  }, [H, D]);
432
432
  const s = (n) => {
433
- const m = new Date(n);
433
+ const c = new Date(n);
434
434
  return new Intl.DateTimeFormat(h ? "fa-IR" : "en-US", {
435
435
  year: "numeric",
436
436
  month: "long",
437
437
  day: "numeric",
438
438
  hour: "2-digit",
439
439
  minute: "2-digit"
440
- }).format(m);
440
+ }).format(c);
441
441
  }, u = (n) => {
442
442
  if (typeof n == "string")
443
443
  try {
@@ -446,20 +446,20 @@ function Ht() {
446
446
  return n;
447
447
  }
448
448
  return JSON.stringify(n, null, 2);
449
- }, j = ({ part: n, idx: m }) => {
450
- const [v, L] = p(!1), G = n.tool_name || (n.type && n.type.startsWith("tool-") ? n.type.slice(5) : "tool");
449
+ }, T = ({ part: n, idx: c }) => {
450
+ const [g, S] = p(!1), G = n.tool_name || (n.type && n.type.startsWith("tool-") ? n.type.slice(5) : "tool");
451
451
  return /* @__PURE__ */ r("div", { dir: "ltr", className: "my-2 border border-border/50 rounded-xl overflow-hidden bg-muted/20 text-left", children: [
452
452
  /* @__PURE__ */ r(
453
453
  "div",
454
454
  {
455
- onClick: () => L(!v),
455
+ onClick: () => S(!g),
456
456
  className: "px-2.5 py-1.5 bg-muted/50 border-b border-border/50 flex items-center justify-between cursor-pointer hover:bg-accent transition-colors",
457
457
  children: [
458
458
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
459
459
  /* @__PURE__ */ e(
460
460
  "svg",
461
461
  {
462
- className: `w-3 h-3 text-gray-400 transition-transform ${v ? "rotate-180" : ""}`,
462
+ className: `w-3 h-3 text-gray-400 transition-transform ${g ? "rotate-180" : ""}`,
463
463
  fill: "none",
464
464
  viewBox: "0 0 24 24",
465
465
  stroke: "currentColor",
@@ -473,7 +473,7 @@ function Ht() {
473
473
  ]
474
474
  }
475
475
  ),
476
- v && /* @__PURE__ */ r("div", { className: "p-2.5 space-y-2.5 animate-in fade-in slide-in-from-top-1 duration-200", children: [
476
+ g && /* @__PURE__ */ r("div", { className: "p-2.5 space-y-2.5 animate-in fade-in slide-in-from-top-1 duration-200", children: [
477
477
  /* @__PURE__ */ r("div", { children: [
478
478
  /* @__PURE__ */ e("div", { className: "text-[10px] uppercase font-bold text-muted-foreground mb-1", children: "Input" }),
479
479
  /* @__PURE__ */ e("pre", { className: "text-xs bg-black/5 dark:bg-black/20 p-2 rounded-lg overflow-x-auto", children: u(n.input) })
@@ -483,37 +483,69 @@ function Ht() {
483
483
  /* @__PURE__ */ e("pre", { className: `text-xs p-2 rounded-lg overflow-x-auto ${n.error_text || n.errorText ? "bg-destructive/10 text-destructive" : "bg-primary/5 text-foreground/80"}`, children: u(n.output || n.error_text || n.errorText) })
484
484
  ] })
485
485
  ] })
486
- ] }, m);
487
- }, O = async (n, m) => {
486
+ ] }, c);
487
+ }, O = async (n, c) => {
488
488
  try {
489
- const v = await w.getAttachmentBlob(n), L = window.URL.createObjectURL(v), G = document.createElement("a");
490
- G.href = L, G.download = m || n.split("/").pop() || "download", document.body.appendChild(G), G.click(), window.URL.revokeObjectURL(L), document.body.removeChild(G);
491
- } catch (v) {
492
- console.error("Download failed:", v), $(v instanceof Error ? v.message : "Download failed");
489
+ const g = await w.getAttachmentBlob(n), S = window.URL.createObjectURL(g), G = document.createElement("a");
490
+ G.href = S, G.download = c || n.split("/").pop() || "download", document.body.appendChild(G), G.click(), window.URL.revokeObjectURL(S), document.body.removeChild(G);
491
+ } catch (g) {
492
+ console.error("Download failed:", g), $(g instanceof Error ? g.message : "Download failed");
493
493
  }
494
- }, C = (n, m) => typeof n == "string" ? /* @__PURE__ */ e("div", { children: n }, m) : n.type === "text" ? /* @__PURE__ */ e("div", { className: "whitespace-pre-wrap", dir: "auto", children: n.text }, m) : n.type === "reasoning" ? /* @__PURE__ */ r("div", { className: "my-2 p-2.5 bg-muted/40 rounded-lg border border-border text-xs italic text-muted-foreground", dir: "auto", children: [
495
- /* @__PURE__ */ e("div", { className: "font-bold mb-1 uppercase tracking-tighter opacity-70", children: "Reasoning" }),
496
- n.text
497
- ] }, m) : n.type === "dynamic-tool" || n.type && n.type.startsWith("tool-") || n.tool_call_id ? /* @__PURE__ */ e(j, { part: n, idx: m }, m) : n.type === "file" ? /* @__PURE__ */ r("div", { className: "my-2 flex items-center justify-between p-2.5 bg-muted/40 rounded-xl border border-border group hover:border-primary/30 transition-all", children: [
498
- /* @__PURE__ */ r("div", { className: "flex items-center gap-3 overflow-hidden", children: [
499
- /* @__PURE__ */ e("div", { className: "flex-shrink-0 w-8 h-8 flex items-center justify-center bg-primary/10 rounded-lg text-primary", children: /* @__PURE__ */ e("span", { className: "text-xl", children: "📎" }) }),
500
- /* @__PURE__ */ r("div", { className: "flex flex-col min-w-0", children: [
501
- /* @__PURE__ */ e("span", { className: "text-sm text-foreground font-medium truncate", title: n.filename || "File", children: n.filename || t("chat_history.unnamed_file") }),
502
- /* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground uppercase tracking-wider font-bold", children: n.media_type || n.mime_type || n.mediaType || "file" })
503
- ] })
504
- ] }),
505
- n.object_name && /* @__PURE__ */ e(
506
- "button",
494
+ }, q = (n, c) => {
495
+ if (typeof n == "string") return /* @__PURE__ */ e("div", { children: n }, c);
496
+ if (n.type === "text") {
497
+ const g = ft(n.text);
498
+ return g ? /* @__PURE__ */ e(
499
+ Oe,
500
+ {
501
+ part: { type: "data-choice-question", data: g },
502
+ message: { id: `admin-choice-${c}`, role: "assistant", parts: [n] },
503
+ disabled: !0
504
+ },
505
+ c
506
+ ) : /* @__PURE__ */ e("div", { className: "whitespace-pre-wrap", dir: "auto", children: n.text }, c);
507
+ }
508
+ if (n.type === "reasoning")
509
+ return /* @__PURE__ */ r("div", { className: "my-2 p-2.5 bg-muted/40 rounded-lg border border-border text-xs italic text-muted-foreground", dir: "auto", children: [
510
+ /* @__PURE__ */ e("div", { className: "font-bold mb-1 uppercase tracking-tighter opacity-70", children: "Reasoning" }),
511
+ n.text
512
+ ] }, c);
513
+ if (n.type === "data-reference") {
514
+ const g = n.data || n.reference;
515
+ return /* @__PURE__ */ r("div", { className: "my-2 p-2.5 bg-primary/5 rounded-lg border border-primary/15 text-xs", dir: "auto", children: [
516
+ /* @__PURE__ */ e("div", { className: "font-bold mb-1 uppercase tracking-tighter text-primary/80", children: g?.label || t("chat.reference", "Reference") }),
517
+ /* @__PURE__ */ e("div", { className: "text-muted-foreground line-clamp-3", children: g?.excerpt || t("chat.source_unavailable", "Source unavailable") })
518
+ ] }, c);
519
+ }
520
+ return n.type === "data-choice-question" ? /* @__PURE__ */ e(
521
+ Oe,
507
522
  {
508
- onClick: () => O(n.object_name, n.filename),
509
- className: "flex-shrink-0 p-2 hover:bg-card rounded-lg border border-transparent hover:border-border transition-all text-muted-foreground hover:text-primary",
510
- title: t("chat_history.download_file", "Download File"),
511
- children: /* @__PURE__ */ e("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" }) })
512
- }
513
- )
514
- ] }, m) : /* @__PURE__ */ e("div", { className: "my-2 p-2 bg-muted/40 rounded-lg border border-border text-xs font-mono opacity-60", children: JSON.stringify(n) }, m), z = (n) => {
515
- const { scrollTop: m, scrollHeight: v, clientHeight: L } = n.currentTarget;
516
- v - m <= L + 50 && !F && ae && U(!0);
523
+ part: n,
524
+ message: { id: `admin-choice-${c}`, role: "assistant", parts: [n] },
525
+ disabled: !0
526
+ },
527
+ c
528
+ ) : n.type === "dynamic-tool" || n.type && n.type.startsWith("tool-") || n.tool_call_id ? /* @__PURE__ */ e(T, { part: n, idx: c }, c) : n.type === "file" ? /* @__PURE__ */ r("div", { className: "my-2 flex items-center justify-between p-2.5 bg-muted/40 rounded-xl border border-border group hover:border-primary/30 transition-all", children: [
529
+ /* @__PURE__ */ r("div", { className: "flex items-center gap-3 overflow-hidden", children: [
530
+ /* @__PURE__ */ e("div", { className: "flex-shrink-0 w-8 h-8 flex items-center justify-center bg-primary/10 rounded-lg text-primary", children: /* @__PURE__ */ e("span", { className: "text-xl", children: "📎" }) }),
531
+ /* @__PURE__ */ r("div", { className: "flex flex-col min-w-0", children: [
532
+ /* @__PURE__ */ e("span", { className: "text-sm text-foreground font-medium truncate", title: n.filename || "File", children: n.filename || t("chat_history.unnamed_file") }),
533
+ /* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground uppercase tracking-wider font-bold", children: n.media_type || n.mime_type || n.mediaType || "file" })
534
+ ] })
535
+ ] }),
536
+ n.object_name && /* @__PURE__ */ e(
537
+ "button",
538
+ {
539
+ onClick: () => O(n.object_name, n.filename),
540
+ className: "flex-shrink-0 p-2 hover:bg-card rounded-lg border border-transparent hover:border-border transition-all text-muted-foreground hover:text-primary",
541
+ title: t("chat_history.download_file", "Download File"),
542
+ children: /* @__PURE__ */ e("svg", { className: "w-4 h-4", fill: "none", viewBox: "0 0 24 24", stroke: "currentColor", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", strokeWidth: 2, d: "M4 16v1a3 3 0 003 3h10a3 3 0 003-3v-1m-4-4l-4 4m0 0l-4-4m4 4V4" }) })
543
+ }
544
+ )
545
+ ] }, c) : /* @__PURE__ */ e("div", { className: "my-2 p-2 bg-muted/40 rounded-lg border border-border text-xs font-mono opacity-60", children: JSON.stringify(n) }, c);
546
+ }, z = (n) => {
547
+ const { scrollTop: c, scrollHeight: g, clientHeight: S } = n.currentTarget;
548
+ g - c <= S + 50 && !F && ae && U(!0);
517
549
  };
518
550
  return /* @__PURE__ */ r("div", { className: "p-5 h-full flex flex-col gap-4 overflow-hidden", dir: h ? "rtl" : "ltr", children: [
519
551
  /* @__PURE__ */ r("div", { className: "flex flex-col gap-3", children: [
@@ -533,7 +565,7 @@ function Ht() {
533
565
  {
534
566
  type: "text",
535
567
  value: H,
536
- onChange: (n) => S(n.target.value),
568
+ onChange: (n) => C(n.target.value),
537
569
  placeholder: t("chat_history.search_placeholder"),
538
570
  className: "flex-1 px-4 py-2.5 border-0 rounded-xl glass-surface text-foreground placeholder-muted-foreground focus:ring-2 focus:ring-primary/20 transition-all text-sm shadow-sm"
539
571
  }
@@ -572,7 +604,7 @@ function Ht() {
572
604
  /* @__PURE__ */ e("div", { className: "px-5 py-2.5 border-b border-border/30", children: /* @__PURE__ */ r("h2", { className: "text-sm font-medium text-muted-foreground uppercase tracking-wide", children: [
573
605
  t("chat_history.threads_list"),
574
606
  " (",
575
- (g.length || 0).toLocaleString(E),
607
+ (f.length || 0).toLocaleString(E),
576
608
  ")"
577
609
  ] }) }),
578
610
  /* @__PURE__ */ e(
@@ -580,18 +612,18 @@ function Ht() {
580
612
  {
581
613
  className: "flex-1 overflow-y-auto p-2 custom-scrollbar",
582
614
  onScroll: z,
583
- children: M && g.length === 0 ? /* @__PURE__ */ e("div", { className: "p-8 text-center text-muted-foreground text-sm", children: t("chat_history.no_threads") }) : /* @__PURE__ */ r("div", { className: "space-y-1", children: [
584
- g.map((n) => /* @__PURE__ */ r(
615
+ children: M && f.length === 0 ? /* @__PURE__ */ e("div", { className: "p-8 text-center text-muted-foreground text-sm", children: t("chat_history.no_threads") }) : /* @__PURE__ */ r("div", { className: "space-y-1", children: [
616
+ f.map((n) => /* @__PURE__ */ r(
585
617
  "div",
586
618
  {
587
- onClick: () => f(n),
588
- className: `p-2.5 cursor-pointer transition-all rounded-xl border ${x?.id === n.id ? "bg-card border-border shadow-sm" : "border-transparent hover:bg-muted/50"}`,
619
+ onClick: () => x(n),
620
+ className: `p-2.5 cursor-pointer transition-all rounded-xl border ${b?.id === n.id ? "bg-card border-border shadow-sm" : "border-transparent hover:bg-muted/50"}`,
589
621
  children: [
590
622
  /* @__PURE__ */ r("div", { className: "flex justify-between items-start mb-1.5 gap-4", children: [
591
623
  /* @__PURE__ */ e(
592
624
  "h3",
593
625
  {
594
- className: `font-medium text-sm truncate flex-1 ${x?.id === n.id ? "text-primary" : "text-foreground"}`,
626
+ className: `font-medium text-sm truncate flex-1 ${b?.id === n.id ? "text-primary" : "text-foreground"}`,
595
627
  title: n.title || t("chat_history.no_thread_title"),
596
628
  children: n.title || t("chat_history.no_thread_title")
597
629
  }
@@ -606,14 +638,14 @@ function Ht() {
606
638
  "div",
607
639
  {
608
640
  className: "flex flex-col gap-0.5 min-w-0",
609
- title: `${n.user_info.name} ${n.user_info.surname} ${n.user_info.phone ? ` • ${n.user_info.phone}` : ""}${d.filter((m) => n.user_info?.metadata?.[m.key] !== void 0 && n.user_info?.metadata?.[m.key] !== "").map((m) => {
610
- const v = n.user_info?.metadata?.[m.key];
611
- if (m.type === "select") {
612
- const L = m.options?.find((G) => String(G.value) === String(v));
613
- return ` • ${L ? t(L.label) : v}`;
641
+ title: `${n.user_info.name} ${n.user_info.surname} ${n.user_info.phone ? ` • ${n.user_info.phone}` : ""}${d.filter((c) => n.user_info?.metadata?.[c.key] !== void 0 && n.user_info?.metadata?.[c.key] !== "").map((c) => {
642
+ const g = n.user_info?.metadata?.[c.key];
643
+ if (c.type === "select") {
644
+ const S = c.options?.find((G) => String(G.value) === String(g));
645
+ return ` • ${S ? t(S.label) : g}`;
614
646
  }
615
- return ` • ${v}`;
616
- }).join("")}${n.user_info.metadata?.values !== void 0 && !d.some((m) => m.key === "values") ? ` • ${n.user_info.metadata.values}` : ""}`,
647
+ return ` • ${g}`;
648
+ }).join("")}${n.user_info.metadata?.values !== void 0 && !d.some((c) => c.key === "values") ? ` • ${n.user_info.metadata.values}` : ""}`,
617
649
  children: [
618
650
  /* @__PURE__ */ r("div", { className: "font-medium text-foreground truncate flex items-center gap-1.5", children: [
619
651
  /* @__PURE__ */ r("span", { children: [
@@ -628,23 +660,23 @@ function Ht() {
628
660
  ] })
629
661
  ] }),
630
662
  /* @__PURE__ */ r("div", { className: "text-[10px] text-muted-foreground/70 truncate flex items-center gap-1", children: [
631
- d.filter((m) => {
632
- const v = n.user_info?.metadata?.[m.key];
633
- return v != null && v !== "";
634
- }).map((m, v) => {
635
- const L = n.user_info?.metadata?.[m.key];
636
- let G = String(L);
637
- if (m.type === "select") {
638
- const pe = m.options?.find((l) => String(l.value) === String(L));
639
- pe && (G = t(pe.label));
640
- } else m.type === "checkbox" && (G = L ? "✓" : "✗");
663
+ d.filter((c) => {
664
+ const g = n.user_info?.metadata?.[c.key];
665
+ return g != null && g !== "";
666
+ }).map((c, g) => {
667
+ const S = n.user_info?.metadata?.[c.key];
668
+ let G = String(S);
669
+ if (c.type === "select") {
670
+ const ie = c.options?.find((l) => String(l.value) === String(S));
671
+ ie && (G = t(ie.label));
672
+ } else c.type === "checkbox" && (G = S ? "✓" : "✗");
641
673
  return /* @__PURE__ */ r("span", { className: "flex items-center gap-1", children: [
642
- v > 0 && /* @__PURE__ */ e("span", { className: "opacity-30", children: "|" }),
674
+ g > 0 && /* @__PURE__ */ e("span", { className: "opacity-30", children: "|" }),
643
675
  G
644
- ] }, m.key);
676
+ ] }, c.key);
645
677
  }),
646
- n.user_info.metadata?.values !== void 0 && !d.some((m) => m.key === "values") && /* @__PURE__ */ r("span", { className: "flex items-center gap-1", children: [
647
- d.some((m) => n.user_info?.metadata?.[m.key] !== void 0) && /* @__PURE__ */ e("span", { className: "opacity-30", children: "|" }),
678
+ n.user_info.metadata?.values !== void 0 && !d.some((c) => c.key === "values") && /* @__PURE__ */ r("span", { className: "flex items-center gap-1", children: [
679
+ d.some((c) => n.user_info?.metadata?.[c.key] !== void 0) && /* @__PURE__ */ e("span", { className: "opacity-30", children: "|" }),
648
680
  String(n.user_info.metadata.values)
649
681
  ] })
650
682
  ] })
@@ -660,7 +692,7 @@ function Ht() {
660
692
  "span",
661
693
  {
662
694
  className: "inline-flex items-center gap-1 bg-muted/30 px-2 py-0.5 rounded-md text-[9px] text-muted-foreground",
663
- title: n.metadata.usage.cost_incomplete || n.metadata.usage.total_cost_microunits === void 0 ? void 0 : Xe(
695
+ title: n.metadata.usage.cost_incomplete || n.metadata.usage.total_cost_microunits === void 0 ? void 0 : Ye(
664
696
  n.metadata.usage.total_cost_microunits || 0,
665
697
  n.metadata.usage.currency || "USD",
666
698
  E
@@ -688,30 +720,30 @@ function Ht() {
688
720
  ] }),
689
721
  /* @__PURE__ */ r("div", { className: "glass-surface rounded-2xl shadow-sm overflow-hidden flex flex-col", children: [
690
722
  /* @__PURE__ */ r("div", { className: "px-5 py-2.5 border-b border-border/30 flex items-center justify-between gap-4", children: [
691
- /* @__PURE__ */ e("h2", { className: "text-sm font-medium text-muted-foreground uppercase tracking-wide truncate", children: x ? t("chat_history.messages_for", { title: x.title || t("chat_history.no_thread_title") }) : t("chat_history.messages") }),
692
- x && /* @__PURE__ */ e(
723
+ /* @__PURE__ */ e("h2", { className: "text-sm font-medium text-muted-foreground uppercase tracking-wide truncate", children: b ? t("chat_history.messages_for", { title: b.title || t("chat_history.no_thread_title") }) : t("chat_history.messages") }),
724
+ b && /* @__PURE__ */ e(
693
725
  "button",
694
726
  {
695
- onClick: (n) => q(n, x),
727
+ onClick: (n) => j(n, b),
696
728
  className: "flex-shrink-0 w-8 h-8 rounded-full bg-primary/10 text-primary flex items-center justify-center hover:bg-primary/20 transition-all shadow-sm",
697
729
  title: t("sidebar.share_conversation"),
698
- children: /* @__PURE__ */ e(jt, { className: "w-4 h-4" })
730
+ children: /* @__PURE__ */ e(At, { className: "w-4 h-4" })
699
731
  }
700
732
  )
701
733
  ] }),
702
- /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto p-4 custom-scrollbar", children: x ? M ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground text-sm", children: t("chat_history.loading_messages") }) : _.length === 0 ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground text-sm", children: t("chat_history.empty_thread") }) : /* @__PURE__ */ e("div", { className: "space-y-6", children: _.map((n) => {
703
- const m = n.role === "user", v = n.role === "assistant";
734
+ /* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto p-4 custom-scrollbar", children: b ? M ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground text-sm", children: t("chat_history.loading_messages") }) : _.length === 0 ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground text-sm", children: t("chat_history.empty_thread") }) : /* @__PURE__ */ e("div", { className: "space-y-6", children: _.map((n) => {
735
+ const c = n.role === "user", g = n.role === "assistant", S = n.parts || [], ie = S.some((l) => l?.type === "data-choice-question") ? S.filter((l) => l?.type !== "text") : S;
704
736
  return /* @__PURE__ */ r(
705
737
  "div",
706
738
  {
707
- className: `p-3.5 rounded-2xl transition-all relative ${m ? "bg-primary/10 ms-12 rounded-te-sm" : v ? "glass shadow-sm me-12 rounded-ts-sm" : "bg-muted/30 border border-border/50"}`,
739
+ className: `p-3.5 rounded-2xl transition-all relative ${c ? "bg-primary/10 ms-12 rounded-te-sm" : g ? "glass shadow-sm me-12 rounded-ts-sm" : "bg-muted/30 border border-border/50"}`,
708
740
  children: [
709
741
  n.feedback && /* @__PURE__ */ e("div", { className: "absolute -bottom-2 -left-2 flex items-center justify-center w-8 h-8 rounded-full shadow-md bg-card border border-border animate-in fade-in zoom-in duration-300 z-10", children: /* @__PURE__ */ e("span", { className: "text-base", children: n.feedback === "like" ? "👍" : "👎" }) }),
710
742
  /* @__PURE__ */ r("div", { className: "flex justify-between items-center mb-1.5", children: [
711
- /* @__PURE__ */ e("span", { className: `text-[10px] font-bold uppercase tracking-wider ${m || v ? "text-primary" : "text-muted-foreground"}`, children: m ? x?.user_info?.name ? `${x.user_info.name} ${x.user_info.surname || ""}`.trim() : t("chat_history.user_label") : v ? t("chat_history.assistant_label") : `${n.role}` }),
743
+ /* @__PURE__ */ e("span", { className: `text-[10px] font-bold uppercase tracking-wider ${c || g ? "text-primary" : "text-muted-foreground"}`, children: c ? b?.user_info?.name ? `${b.user_info.name} ${b.user_info.surname || ""}`.trim() : t("chat_history.user_label") : g ? t("chat_history.assistant_label") : `${n.role}` }),
712
744
  /* @__PURE__ */ e("span", { className: "text-[10px] text-muted-foreground", children: s(n.created_at) })
713
745
  ] }),
714
- /* @__PURE__ */ e("div", { className: "text-sm text-foreground leading-relaxed", dir: "auto", children: n.parts && n.parts.length > 0 ? n.parts.map((L, G) => C(L, G)) : typeof n.content == "object" ? /* @__PURE__ */ e("pre", { className: "text-xs font-mono bg-muted/40 p-2.5 rounded-xl", dir: "ltr", children: JSON.stringify(n.content, null, 2) }) : n.content })
746
+ /* @__PURE__ */ e("div", { className: "text-sm text-foreground leading-relaxed", dir: "auto", children: ie.length > 0 ? ie.map((l, L) => q(l, L)) : typeof n.content == "object" ? /* @__PURE__ */ e("pre", { className: "text-xs font-mono bg-muted/40 p-2.5 rounded-xl", dir: "ltr", children: JSON.stringify(n.content, null, 2) }) : n.content })
715
747
  ]
716
748
  },
717
749
  n.id
@@ -724,96 +756,96 @@ function Ht() {
724
756
  ] })
725
757
  ] });
726
758
  }
727
- function Wt() {
728
- const { t, i18n: i } = me(["admin", "translation"]), [o, d] = p([]), [g, c] = p(!1), [x, N] = p(""), [_, B] = p(!1), [M, A] = p(null), [F, R] = p([]), [k, $] = p(null), H = i.language === "fa", [S, D] = p({
759
+ function Kt() {
760
+ const { t, i18n: i } = ue(["admin", "translation"]), [o, d] = p([]), [f, m] = p(!1), [b, N] = p(""), [_, B] = p(!1), [M, A] = p(null), [F, R] = p([]), [k, $] = p(null), H = i.language === "fa", [C, D] = p({
729
761
  username: "",
730
762
  password: "",
731
763
  name: "",
732
764
  permissions: []
733
765
  }), K = async () => {
734
- c(!0), N("");
766
+ m(!0), N("");
735
767
  try {
736
- const f = await w.listAdmins();
737
- d(f.admins || []);
738
- const q = localStorage.getItem("admin_info");
739
- q && $(JSON.parse(q).admin_id);
740
- } catch (f) {
741
- N(f instanceof Error ? f.message : t("error_loading"));
768
+ const x = await w.listAdmins();
769
+ d(x.admins || []);
770
+ const j = localStorage.getItem("admin_info");
771
+ j && $(JSON.parse(j).admin_id);
772
+ } catch (x) {
773
+ N(x instanceof Error ? x.message : t("error_loading"));
742
774
  } finally {
743
- c(!1);
775
+ m(!1);
744
776
  }
745
777
  }, W = async () => {
746
778
  try {
747
- const f = await w.listPermissions();
748
- R(f.permissions);
749
- } catch (f) {
750
- console.error("Failed to load permissions", f);
779
+ const x = await w.listPermissions();
780
+ R(x.permissions);
781
+ } catch (x) {
782
+ console.error("Failed to load permissions", x);
751
783
  }
752
784
  };
753
785
  Y(() => {
754
786
  K(), W();
755
787
  }, []);
756
- const P = async (f) => {
757
- f.preventDefault(), c(!0);
788
+ const P = async (x) => {
789
+ x.preventDefault(), m(!0);
758
790
  try {
759
791
  await w.register(
760
- S.username,
761
- S.password,
762
- S.name,
763
- S.permissions
792
+ C.username,
793
+ C.password,
794
+ C.name,
795
+ C.permissions
764
796
  ), B(!1), D({ username: "", password: "", name: "", permissions: [] }), K();
765
- } catch (q) {
766
- N(q instanceof Error ? q.message : t("error_loading"));
797
+ } catch (j) {
798
+ N(j instanceof Error ? j.message : t("error_loading"));
767
799
  } finally {
768
- c(!1);
800
+ m(!1);
769
801
  }
770
- }, ae = async (f) => {
771
- if (f.preventDefault(), !!M) {
772
- c(!0);
802
+ }, ae = async (x) => {
803
+ if (x.preventDefault(), !!M) {
804
+ m(!0);
773
805
  try {
774
- const q = {
775
- name: S.name,
776
- permissions: S.permissions
806
+ const j = {
807
+ name: C.name,
808
+ permissions: C.permissions
777
809
  };
778
- if (S.password && (q.password = S.password), await w.updateAdmin(M.id, q), M.id === k) {
810
+ if (C.password && (j.password = C.password), await w.updateAdmin(M.id, j), M.id === k) {
779
811
  const s = localStorage.getItem("admin_info");
780
812
  if (s) {
781
813
  const u = JSON.parse(s);
782
- u.name = S.name, u.permissions = S.permissions, localStorage.setItem("admin_info", JSON.stringify(u)), window.location.reload();
814
+ u.name = C.name, u.permissions = C.permissions, localStorage.setItem("admin_info", JSON.stringify(u)), window.location.reload();
783
815
  return;
784
816
  }
785
817
  }
786
818
  A(null), D({ username: "", password: "", name: "", permissions: [] }), K();
787
- } catch (q) {
788
- N(q instanceof Error ? q.message : t("error_loading"));
819
+ } catch (j) {
820
+ N(j instanceof Error ? j.message : t("error_loading"));
789
821
  } finally {
790
- c(!1);
822
+ m(!1);
791
823
  }
792
824
  }
793
- }, Q = async (f) => {
825
+ }, Z = async (x) => {
794
826
  if (confirm(t("admins.confirm_delete_admin")))
795
827
  try {
796
- await w.deleteAdmin(f), K();
797
- } catch (q) {
798
- N(q instanceof Error ? q.message : t("error_loading"));
828
+ await w.deleteAdmin(x), K();
829
+ } catch (j) {
830
+ N(j instanceof Error ? j.message : t("error_loading"));
799
831
  }
800
- }, h = (f) => {
801
- A(f), D({
802
- username: f.username,
832
+ }, h = (x) => {
833
+ A(x), D({
834
+ username: x.username,
803
835
  password: "",
804
- name: f.name,
805
- permissions: f.permissions
836
+ name: x.name,
837
+ permissions: x.permissions
806
838
  }), B(!0);
807
- }, E = (f) => {
808
- D((q) => ({
809
- ...q,
810
- permissions: q.permissions.includes(f) ? q.permissions.filter((s) => s !== f) : [...q.permissions, f]
839
+ }, E = (x) => {
840
+ D((j) => ({
841
+ ...j,
842
+ permissions: j.permissions.includes(x) ? j.permissions.filter((s) => s !== x) : [...j.permissions, x]
811
843
  }));
812
- }, U = (f) => {
813
- const q = `admins.perm_${f}`, s = t(q);
814
- if (s !== q)
844
+ }, U = (x) => {
845
+ const j = `admins.perm_${x}`, s = t(j);
846
+ if (s !== j)
815
847
  return s;
816
- switch (f) {
848
+ switch (x) {
817
849
  case "chat_history":
818
850
  return t("admins.perm_chat_history");
819
851
  case "admin_management":
@@ -825,7 +857,7 @@ function Wt() {
825
857
  case "settings":
826
858
  return t("admins.perm_settings");
827
859
  default:
828
- return f;
860
+ return x;
829
861
  }
830
862
  };
831
863
  return /* @__PURE__ */ r("div", { className: "h-full flex flex-col p-5 overflow-hidden gap-4", dir: H ? "rtl" : "ltr", children: [
@@ -845,7 +877,7 @@ function Wt() {
845
877
  )
846
878
  ] })
847
879
  ] }),
848
- x && /* @__PURE__ */ e("div", { className: "bg-destructive/10 border border-destructive/20 text-destructive px-4 py-3 rounded-xl text-sm backdrop-blur-sm flex-shrink-0", children: x }),
880
+ b && /* @__PURE__ */ e("div", { className: "bg-destructive/10 border border-destructive/20 text-destructive px-4 py-3 rounded-xl text-sm backdrop-blur-sm flex-shrink-0", children: b }),
849
881
  _ && /* @__PURE__ */ e("div", { className: "fixed inset-0 bg-background/20 backdrop-blur-md flex items-center justify-center z-50 p-4", children: /* @__PURE__ */ r("div", { className: "bg-card rounded-2xl border border-border w-full max-w-md shadow-2xl overflow-hidden", children: [
850
882
  /* @__PURE__ */ e("div", { className: "px-6 py-5 border-b border-border bg-muted/20", children: /* @__PURE__ */ e("h3", { className: "text-lg font-bold text-foreground", children: t(M ? "admins.edit_admin" : "admins.add_admin") }) }),
851
883
  /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: M ? ae : P, className: "space-y-5", children: [
@@ -856,8 +888,8 @@ function Wt() {
856
888
  {
857
889
  type: "text",
858
890
  disabled: !!M,
859
- value: S.username,
860
- onChange: (f) => D({ ...S, username: f.target.value }),
891
+ value: C.username,
892
+ onChange: (x) => D({ ...C, username: x.target.value }),
861
893
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground disabled:opacity-50 focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm font-mono dir-ltr",
862
894
  required: !0,
863
895
  dir: "ltr"
@@ -870,8 +902,8 @@ function Wt() {
870
902
  "input",
871
903
  {
872
904
  type: "text",
873
- value: S.name,
874
- onChange: (f) => D({ ...S, name: f.target.value }),
905
+ value: C.name,
906
+ onChange: (x) => D({ ...C, name: x.target.value }),
875
907
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm",
876
908
  required: !0
877
909
  }
@@ -883,8 +915,8 @@ function Wt() {
883
915
  "input",
884
916
  {
885
917
  type: "password",
886
- value: S.password,
887
- onChange: (f) => D({ ...S, password: f.target.value }),
918
+ value: C.password,
919
+ onChange: (x) => D({ ...C, password: x.target.value }),
888
920
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm font-mono dir-ltr",
889
921
  required: !M,
890
922
  dir: "ltr"
@@ -893,19 +925,19 @@ function Wt() {
893
925
  ] }),
894
926
  /* @__PURE__ */ r("div", { children: [
895
927
  /* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: t("admins.permissions") }),
896
- /* @__PURE__ */ e("div", { className: "space-y-3 p-4 bg-muted/30 rounded-xl border border-border", children: F.map((f) => /* @__PURE__ */ r("label", { className: "flex items-center gap-3 cursor-pointer group", children: [
928
+ /* @__PURE__ */ e("div", { className: "space-y-3 p-4 bg-muted/30 rounded-xl border border-border", children: F.map((x) => /* @__PURE__ */ r("label", { className: "flex items-center gap-3 cursor-pointer group", children: [
897
929
  /* @__PURE__ */ e("div", { className: "relative flex items-center", children: /* @__PURE__ */ e(
898
930
  "input",
899
931
  {
900
932
  type: "checkbox",
901
- checked: S.permissions.includes(f),
902
- onChange: () => E(f),
903
- disabled: S.username === "admin" && f === "admin_management",
933
+ checked: C.permissions.includes(x),
934
+ onChange: () => E(x),
935
+ disabled: C.username === "admin" && x === "admin_management",
904
936
  className: "peer h-4 w-4 rounded border-input text-primary focus:ring-ring transition-all disabled:opacity-50"
905
937
  }
906
938
  ) }),
907
- /* @__PURE__ */ e("span", { className: "text-sm text-foreground/70 group-hover:text-foreground transition-colors select-none", children: U(f) })
908
- ] }, f)) })
939
+ /* @__PURE__ */ e("span", { className: "text-sm text-foreground/70 group-hover:text-foreground transition-colors select-none", children: U(x) })
940
+ ] }, x)) })
909
941
  ] }),
910
942
  /* @__PURE__ */ r("div", { className: "flex gap-3 pt-4", children: [
911
943
  /* @__PURE__ */ e(
@@ -921,9 +953,9 @@ function Wt() {
921
953
  "button",
922
954
  {
923
955
  type: "submit",
924
- disabled: g,
956
+ disabled: f,
925
957
  className: "flex-1 px-4 py-3 bg-primary text-primary-foreground rounded-xl text-sm font-bold hover:opacity-90 transition-all shadow-md hover:shadow-lg disabled:opacity-50",
926
- children: t(g ? "saving" : "save")
958
+ children: t(f ? "saving" : "save")
927
959
  }
928
960
  )
929
961
  ] })
@@ -937,37 +969,37 @@ function Wt() {
937
969
  /* @__PURE__ */ e("th", { className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50", children: t("admins.permissions") }),
938
970
  /* @__PURE__ */ e("th", { className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50", children: t("users.actions") })
939
971
  ] }) }),
940
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-border", children: o.map((f) => /* @__PURE__ */ r("tr", { className: "hover:bg-muted/30 transition-colors text-xs border-b border-border/50", children: [
941
- /* @__PURE__ */ e("td", { className: "px-4 py-3 font-medium text-foreground", children: f.name }),
942
- /* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground font-mono", dir: "ltr", children: f.username }),
943
- /* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground", children: /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1.5", children: f.permissions.map((q) => /* @__PURE__ */ e("span", { className: "px-2 py-0.5 bg-muted/50 text-foreground/80 rounded text-[10px] border border-border/50", children: U(q) }, q)) }) }),
972
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-border", children: o.map((x) => /* @__PURE__ */ r("tr", { className: "hover:bg-muted/30 transition-colors text-xs border-b border-border/50", children: [
973
+ /* @__PURE__ */ e("td", { className: "px-4 py-3 font-medium text-foreground", children: x.name }),
974
+ /* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground font-mono", dir: "ltr", children: x.username }),
975
+ /* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground", children: /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1.5", children: x.permissions.map((j) => /* @__PURE__ */ e("span", { className: "px-2 py-0.5 bg-muted/50 text-foreground/80 rounded text-[10px] border border-border/50", children: U(j) }, j)) }) }),
944
976
  /* @__PURE__ */ e("td", { className: "px-4 py-3", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5", children: [
945
977
  /* @__PURE__ */ e(
946
978
  "button",
947
979
  {
948
- onClick: () => h(f),
980
+ onClick: () => h(x),
949
981
  className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
950
982
  title: t("edit"),
951
983
  children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "w-4 h-4", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" }) })
952
984
  }
953
985
  ),
954
- f.id !== k && /* @__PURE__ */ e(
986
+ x.id !== k && /* @__PURE__ */ e(
955
987
  "button",
956
988
  {
957
- onClick: () => Q(f.id),
989
+ onClick: () => Z(x.id),
958
990
  className: "p-2 text-destructive hover:text-destructive/80 hover:bg-destructive/10 rounded-xl transition-all",
959
991
  title: t("delete"),
960
992
  children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "w-4 h-4", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" }) })
961
993
  }
962
994
  )
963
995
  ] }) })
964
- ] }, f.id)) })
996
+ ] }, x.id)) })
965
997
  ] }),
966
- o.length === 0 && !g && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-2", children: [
998
+ o.length === 0 && !f && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-2", children: [
967
999
  /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1, stroke: "currentColor", className: "w-12 h-12 opacity-20", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M18 18.72a9.094 9.094 0 0 0 3.741-.479 3 3 0 0 0-4.682-2.72m.94 3.198.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0 1 12 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 0 1 6 18.719m12 0a5.971 5.971 0 0 0-.941-3.197m0 0A5.995 5.995 0 0 0 12 12.75a5.995 5.995 0 0 0-5.058 2.772m0 0a3 3 0 0 0-4.681 2.72 8.986 8.986 0 0 0 3.74.477m.94-3.197a5.971 5.971 0 0 0-.94 3.197M15 6.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm6 3a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Zm-13.5 0a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Z" }) }),
968
1000
  t("admins.no_admins")
969
1001
  ] }),
970
- g && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-3", children: [
1002
+ f && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-3", children: [
971
1003
  /* @__PURE__ */ e("div", { className: "w-8 h-8 border-2 border-primary/20 border-t-primary rounded-full animate-spin" }),
972
1004
  /* @__PURE__ */ e("span", { children: t("loading") })
973
1005
  ] })
@@ -976,7 +1008,7 @@ function Wt() {
976
1008
  }
977
1009
  function re({ className: t, ...i }) {
978
1010
  return /* @__PURE__ */ e(
979
- Ve.Root,
1011
+ Be.Root,
980
1012
  {
981
1013
  "data-slot": "switch",
982
1014
  className: Te(
@@ -985,7 +1017,7 @@ function re({ className: t, ...i }) {
985
1017
  ),
986
1018
  ...i,
987
1019
  children: /* @__PURE__ */ e(
988
- Ve.Thumb,
1020
+ Be.Thumb,
989
1021
  {
990
1022
  "data-slot": "switch-thumb",
991
1023
  className: Te(
@@ -996,9 +1028,9 @@ function re({ className: t, ...i }) {
996
1028
  }
997
1029
  );
998
1030
  }
999
- const Gt = (t) => t.replace(/[^0-9]/g, ""), Kt = 25;
1000
- function Zt() {
1001
- const { t, i18n: i } = me(["admin", "translation"]), { app: o } = Ne(), [d, g] = p([]), [c, x] = p(!1), [N, _] = p(""), [B, M] = p(!1), [A, F] = p(null), [R, k] = p(""), [$, H] = p(0), [S, D] = p("name"), [K, W] = p("asc"), [P, ae] = p(null), Q = Le(0), h = Le(!1), E = Ce(() => o?.userMetadataFields || [], [o?.userMetadataFields]), [U, f] = p(null), [q, s] = p(""), [u, j] = p(""), [O, C] = p(""), [z, n] = p(""), [m, v] = p(null), [L, G] = p(null), [pe, l] = p(!1), T = i.language === "fa", J = T ? "fa-IR" : "en-US", ie = T ? "text-right" : "text-left", [b, te] = p({
1031
+ const Qt = (t) => t.replace(/[^0-9]/g, ""), Zt = 25;
1032
+ function Xt() {
1033
+ const { t, i18n: i } = ue(["admin", "translation"]), { app: o } = Ne(), [d, f] = p([]), [m, b] = p(!1), [N, _] = p(""), [B, M] = p(!1), [A, F] = p(null), [R, k] = p(""), [$, H] = p(0), [C, D] = p("name"), [K, W] = p("asc"), [P, ae] = p(null), Z = Le(0), h = Le(!1), E = Ce(() => o?.userMetadataFields || [], [o?.userMetadataFields]), [U, x] = p(null), [j, s] = p(""), [u, T] = p(""), [O, q] = p(""), [z, n] = p(""), [c, g] = p(null), [S, G] = p(null), [ie, l] = p(!1), L = i.language === "fa", J = L ? "fa-IR" : "en-US", oe = L ? "text-right" : "text-left", [v, te] = p({
1002
1034
  phone: "",
1003
1035
  name: "",
1004
1036
  surname: "",
@@ -1012,28 +1044,28 @@ function Zt() {
1012
1044
  rechargeIntervalValue: "1",
1013
1045
  rechargeIntervalUnit: "month",
1014
1046
  rechargeAnchorAt: ""
1015
- }), [se, be] = p({}), ke = async (a = !1, y = R, I = S, V = K) => {
1047
+ }), [se, be] = p({}), ke = async (a = !1, y = R, I = C, V = K) => {
1016
1048
  if (h.current) return;
1017
1049
  h.current = !0;
1018
- const ee = ++Q.current;
1019
- x(!0), _("");
1050
+ const ee = ++Z.current;
1051
+ b(!0), _("");
1020
1052
  try {
1021
1053
  const ne = await w.listUsers(
1022
1054
  a ? d.length : 0,
1023
- Kt,
1055
+ Zt,
1024
1056
  y,
1025
1057
  I,
1026
1058
  V
1027
1059
  );
1028
- if (ee !== Q.current) return;
1029
- g((ve) => a ? [...ve, ...ne.users || []] : ne.users || []), H(ne.count || 0);
1060
+ if (ee !== Z.current) return;
1061
+ f((ve) => a ? [...ve, ...ne.users || []] : ne.users || []), H(ne.count || 0);
1030
1062
  } catch (ne) {
1031
- if (ee !== Q.current) return;
1063
+ if (ee !== Z.current) return;
1032
1064
  _(ne instanceof Error ? ne.message : t("error_loading"));
1033
1065
  } finally {
1034
- ee === Q.current && (x(!1), h.current = !1);
1066
+ ee === Z.current && (b(!1), h.current = !1);
1035
1067
  }
1036
- }, Ye = async () => {
1068
+ }, et = async () => {
1037
1069
  try {
1038
1070
  const a = await w.getSettings();
1039
1071
  ae(a);
@@ -1042,9 +1074,9 @@ function Zt() {
1042
1074
  }
1043
1075
  };
1044
1076
  Y(() => {
1045
- Ye();
1077
+ et();
1046
1078
  }, []), Y(() => {
1047
- P && !A && !b.tokens && !b.requests && te((a) => ({
1079
+ P && !A && !v.tokens && !v.requests && te((a) => ({
1048
1080
  ...a,
1049
1081
  tokens: P.initial_balance_tokens?.toString() || "",
1050
1082
  requests: P.initial_balance_requests?.toString() || "",
@@ -1052,33 +1084,33 @@ function Zt() {
1052
1084
  requestsLimit: P.initial_balance_requests?.toString() || ""
1053
1085
  }));
1054
1086
  }, [P]), Y(() => {
1055
- Q.current += 1, h.current = !1, g([]), H(0), x(!0);
1087
+ Z.current += 1, h.current = !1, f([]), H(0), b(!0);
1056
1088
  const a = setTimeout(() => {
1057
- ke(!1, R, S, K);
1089
+ ke(!1, R, C, K);
1058
1090
  }, 500);
1059
1091
  return () => {
1060
- clearTimeout(a), Q.current += 1, h.current = !1;
1092
+ clearTimeout(a), Z.current += 1, h.current = !1;
1061
1093
  };
1062
- }, [R, S, K]);
1063
- const et = (a) => {
1064
- S === a ? W((y) => y === "asc" ? "desc" : "asc") : (D(a), W("asc"));
1065
- }, tt = (a) => S !== a ? /* @__PURE__ */ e(At, { className: "w-3.5 h-3.5 opacity-50" }) : K === "asc" ? /* @__PURE__ */ e(It, { className: "w-3.5 h-3.5" }) : /* @__PURE__ */ e(Mt, { className: "w-3.5 h-3.5" });
1094
+ }, [R, C, K]);
1095
+ const tt = (a) => {
1096
+ C === a ? W((y) => y === "asc" ? "desc" : "asc") : (D(a), W("asc"));
1097
+ }, rt = (a) => C !== a ? /* @__PURE__ */ e(Mt, { className: "w-3.5 h-3.5 opacity-50" }) : K === "asc" ? /* @__PURE__ */ e(Dt, { className: "w-3.5 h-3.5" }) : /* @__PURE__ */ e($t, { className: "w-3.5 h-3.5" });
1066
1098
  Y(() => {
1067
1099
  try {
1068
- const y = { ...b.metadata ? JSON.parse(b.metadata) : {}, ...se }, I = JSON.stringify(y, null, 2);
1069
- I !== b.metadata && te((V) => ({ ...V, metadata: I }));
1100
+ const y = { ...v.metadata ? JSON.parse(v.metadata) : {}, ...se }, I = JSON.stringify(y, null, 2);
1101
+ I !== v.metadata && te((V) => ({ ...V, metadata: I }));
1070
1102
  } catch {
1071
1103
  }
1072
1104
  }, [se]), Y(() => {
1073
1105
  const a = { ...se };
1074
1106
  let y = !1;
1075
1107
  E.forEach((I) => {
1076
- I.condition && !Oe(I.condition, se) && a[I.key] !== void 0 && (delete a[I.key], y = !0);
1108
+ I.condition && !Fe(I.condition, se) && a[I.key] !== void 0 && (delete a[I.key], y = !0);
1077
1109
  }), y && be(a);
1078
1110
  }, [se, E]);
1079
- const rt = async (a) => {
1111
+ const at = async (a) => {
1080
1112
  a.preventDefault();
1081
- const y = b.tokens ? parseInt(b.tokens) : 0, I = b.requests ? parseInt(b.requests) : 0, V = b.tokensLimit ? parseInt(b.tokensLimit) : y, ee = b.requestsLimit ? parseInt(b.requestsLimit) : I;
1113
+ const y = v.tokens ? parseInt(v.tokens) : 0, I = v.requests ? parseInt(v.requests) : 0, V = v.tokensLimit ? parseInt(v.tokensLimit) : y, ee = v.requestsLimit ? parseInt(v.requestsLimit) : I;
1082
1114
  if (y > V) {
1083
1115
  _(t("users.tokens_exceed_limit", "Tokens cannot exceed limit"));
1084
1116
  return;
@@ -1088,62 +1120,62 @@ function Zt() {
1088
1120
  return;
1089
1121
  }
1090
1122
  let ne = {};
1091
- if (b.metadata)
1123
+ if (v.metadata)
1092
1124
  try {
1093
- ne = JSON.parse(b.metadata);
1125
+ ne = JSON.parse(v.metadata);
1094
1126
  } catch {
1095
1127
  _(t("users.invalid_json", "Invalid JSON format"));
1096
1128
  return;
1097
1129
  }
1098
1130
  const ve = Ee();
1099
1131
  if (ve) {
1100
- x(!0);
1132
+ b(!0);
1101
1133
  try {
1102
1134
  await w.createUser(
1103
- b.phone,
1104
- b.name,
1105
- b.surname,
1106
- b.tokens ? parseInt(b.tokens) : void 0,
1107
- b.requests ? parseInt(b.requests) : void 0,
1108
- b.tokensLimit ? parseInt(b.tokensLimit) : void 0,
1109
- b.requestsLimit ? parseInt(b.requestsLimit) : void 0,
1135
+ v.phone,
1136
+ v.name,
1137
+ v.surname,
1138
+ v.tokens ? parseInt(v.tokens) : void 0,
1139
+ v.requests ? parseInt(v.requests) : void 0,
1140
+ v.tokensLimit ? parseInt(v.tokensLimit) : void 0,
1141
+ v.requestsLimit ? parseInt(v.requestsLimit) : void 0,
1110
1142
  ne,
1111
1143
  ve
1112
1144
  ), M(!1), qe(), ke();
1113
1145
  } catch (ye) {
1114
1146
  _(ye instanceof Error ? ye.message : t("error_loading"));
1115
1147
  } finally {
1116
- x(!1);
1148
+ b(!1);
1117
1149
  }
1118
1150
  }
1119
- }, at = async (a) => {
1151
+ }, st = async (a) => {
1120
1152
  if (a.preventDefault(), !A) return;
1121
1153
  let y = {};
1122
- if (b.metadata)
1154
+ if (v.metadata)
1123
1155
  try {
1124
- y = JSON.parse(b.metadata);
1156
+ y = JSON.parse(v.metadata);
1125
1157
  } catch {
1126
1158
  _(t("users.invalid_json", "Invalid JSON format"));
1127
1159
  return;
1128
1160
  }
1129
1161
  const I = Ee();
1130
1162
  if (I) {
1131
- x(!0);
1163
+ b(!0);
1132
1164
  try {
1133
1165
  const V = await w.updateUser(A.id, {
1134
- phone: b.phone,
1135
- name: b.name,
1136
- surname: b.surname,
1166
+ phone: v.phone,
1167
+ name: v.name,
1168
+ surname: v.surname,
1137
1169
  metadata: y,
1138
1170
  recharge_policy: I
1139
1171
  }), ee = V.user.recharge_policy;
1140
1172
  if (!(ee?.enabled === I.enabled && (!I.enabled || ee.interval_value === I.interval_value && ee.interval_unit === I.interval_unit)))
1141
1173
  throw new Error(t("users.recharge_policy_not_saved"));
1142
- Q.current += 1, h.current = !1, g((ve) => ve.map((ye) => ye.id === V.user.id ? V.user : ye)), F(null), M(!1), qe();
1174
+ Z.current += 1, h.current = !1, f((ve) => ve.map((ye) => ye.id === V.user.id ? V.user : ye)), F(null), M(!1), qe();
1143
1175
  } catch (V) {
1144
1176
  _(V instanceof Error ? V.message : t("error_loading"));
1145
1177
  } finally {
1146
- x(!1);
1178
+ b(!1);
1147
1179
  }
1148
1180
  }
1149
1181
  }, qe = () => {
@@ -1161,7 +1193,7 @@ function Zt() {
1161
1193
  rechargeIntervalUnit: "month",
1162
1194
  rechargeAnchorAt: ""
1163
1195
  }), be({});
1164
- }, st = async (a) => {
1196
+ }, nt = async (a) => {
1165
1197
  if (confirm(t("users.confirm_delete_user")))
1166
1198
  try {
1167
1199
  await w.deleteUser(a), ke();
@@ -1169,16 +1201,16 @@ function Zt() {
1169
1201
  _(y instanceof Error ? y.message : t("error_loading"));
1170
1202
  }
1171
1203
  }, Ee = () => {
1172
- if (!b.rechargeEnabled)
1204
+ if (!v.rechargeEnabled)
1173
1205
  return { enabled: !1 };
1174
- const a = Number(b.rechargeIntervalValue);
1206
+ const a = Number(v.rechargeIntervalValue);
1175
1207
  return !Number.isInteger(a) || a <= 0 ? (_(t("users.recharge_interval_invalid")), null) : {
1176
1208
  enabled: !0,
1177
1209
  interval_value: a,
1178
- interval_unit: b.rechargeIntervalUnit,
1179
- anchor_at: b.rechargeAnchorAt || (/* @__PURE__ */ new Date()).toISOString()
1210
+ interval_unit: v.rechargeIntervalUnit,
1211
+ anchor_at: v.rechargeAnchorAt || (/* @__PURE__ */ new Date()).toISOString()
1180
1212
  };
1181
- }, nt = async (a) => {
1213
+ }, it = async (a) => {
1182
1214
  try {
1183
1215
  const I = (await w.refreshUserToken(a.id))?.user?.token;
1184
1216
  if (!I) {
@@ -1189,9 +1221,9 @@ function Zt() {
1189
1221
  } catch (y) {
1190
1222
  _(y instanceof Error ? y.message : t("error_loading"));
1191
1223
  }
1192
- }, it = async (a, y, I, V) => {
1224
+ }, ot = async (a, y, I, V) => {
1193
1225
  if (U) {
1194
- x(!0);
1226
+ b(!0);
1195
1227
  try {
1196
1228
  await w.updateUserBalance(
1197
1229
  U.id,
@@ -1199,16 +1231,16 @@ function Zt() {
1199
1231
  y,
1200
1232
  I,
1201
1233
  V
1202
- ), f(null), s(""), j(""), C(""), n(""), ke();
1234
+ ), x(null), s(""), T(""), q(""), n(""), ke();
1203
1235
  } catch (ee) {
1204
1236
  _(ee instanceof Error ? ee.message : t("error_loading"));
1205
1237
  } finally {
1206
- x(!1);
1238
+ b(!1);
1207
1239
  }
1208
1240
  }
1209
- }, ot = async (a) => {
1241
+ }, lt = async (a) => {
1210
1242
  if (a.preventDefault(), !U) return;
1211
- const y = parseInt(q) || 0, I = parseInt(u) || 0, V = O ? parseInt(O) : U.balance?.token_limit || 0, ee = z ? parseInt(z) : U.balance?.request_limit || 0;
1243
+ const y = parseInt(j) || 0, I = parseInt(u) || 0, V = O ? parseInt(O) : U.balance?.token_limit || 0, ee = z ? parseInt(z) : U.balance?.request_limit || 0;
1212
1244
  if (y > V) {
1213
1245
  _(t("users.tokens_exceed_limit", "Tokens cannot exceed limit"));
1214
1246
  return;
@@ -1217,17 +1249,17 @@ function Zt() {
1217
1249
  _(t("users.requests_exceed_limit", "Requests cannot exceed limit"));
1218
1250
  return;
1219
1251
  }
1220
- await it(
1252
+ await ot(
1221
1253
  y,
1222
1254
  I,
1223
1255
  O ? parseInt(O) : void 0,
1224
1256
  z ? parseInt(z) : void 0
1225
1257
  );
1226
- }, lt = () => {
1258
+ }, dt = () => {
1227
1259
  if (!U) return;
1228
1260
  const a = O || String(U.balance?.token_limit || 0), y = z || String(U.balance?.request_limit || 0);
1229
- s(a), j(y);
1230
- }, dt = (a) => {
1261
+ s(a), T(y);
1262
+ }, ct = (a) => {
1231
1263
  F(a);
1232
1264
  const y = a.metadata ? JSON.stringify(a.metadata, null, 2) : "";
1233
1265
  if (te({
@@ -1250,17 +1282,17 @@ function Zt() {
1250
1282
  }), be(I);
1251
1283
  }
1252
1284
  M(!0);
1253
- }, ct = async (a) => {
1254
- v(a), G(null), l(!0);
1285
+ }, mt = async (a) => {
1286
+ g(a), G(null), l(!0);
1255
1287
  try {
1256
1288
  G(await w.getUserUsageSummary(a.id));
1257
1289
  } catch (y) {
1258
- _(y instanceof Error ? y.message : t("error_loading")), v(null);
1290
+ _(y instanceof Error ? y.message : t("error_loading")), g(null);
1259
1291
  } finally {
1260
1292
  l(!1);
1261
1293
  }
1262
1294
  };
1263
- return /* @__PURE__ */ r("div", { className: "h-full flex flex-col p-5 overflow-hidden gap-4", dir: T ? "rtl" : "ltr", children: [
1295
+ return /* @__PURE__ */ r("div", { className: "h-full flex flex-col p-5 overflow-hidden gap-4", dir: L ? "rtl" : "ltr", children: [
1264
1296
  /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-center justify-between gap-3 flex-shrink-0", children: [
1265
1297
  /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-foreground tracking-tight whitespace-nowrap", children: t("users.title") }),
1266
1298
  /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row items-center gap-2 flex-1 max-w-4xl justify-end", children: [
@@ -1289,28 +1321,28 @@ function Zt() {
1289
1321
  ] })
1290
1322
  ] })
1291
1323
  ] }),
1292
- /* @__PURE__ */ e(We, { open: !!m, onOpenChange: (a) => !a && v(null), children: /* @__PURE__ */ r(Ge, { children: [
1293
- /* @__PURE__ */ r(Ke, { children: [
1324
+ /* @__PURE__ */ e(Ge, { open: !!c, onOpenChange: (a) => !a && g(null), children: /* @__PURE__ */ r(Ke, { children: [
1325
+ /* @__PURE__ */ r(Qe, { children: [
1294
1326
  /* @__PURE__ */ e(Ze, { children: t("users.usage_summary") }),
1295
- /* @__PURE__ */ e(Qe, { children: m ? `${m.name} ${m.surname}` : "" })
1327
+ /* @__PURE__ */ e(Xe, { children: c ? `${c.name} ${c.surname}` : "" })
1296
1328
  ] }),
1297
- pe ? /* @__PURE__ */ e("div", { className: "py-10 flex justify-center", children: /* @__PURE__ */ e("div", { className: "w-8 h-8 border-2 border-primary/20 border-t-primary rounded-full animate-spin" }) }) : L ? /* @__PURE__ */ e("div", { className: "grid grid-cols-2 gap-3", children: [
1298
- [t("users.input_tokens"), L.input_tokens.toLocaleString(J)],
1299
- [t("users.output_tokens"), L.output_tokens.toLocaleString(J)],
1300
- [t("users.total_tokens"), L.total_tokens.toLocaleString(J)],
1301
- [t("users.requests_made"), L.requests.toLocaleString(J)],
1329
+ ie ? /* @__PURE__ */ e("div", { className: "py-10 flex justify-center", children: /* @__PURE__ */ e("div", { className: "w-8 h-8 border-2 border-primary/20 border-t-primary rounded-full animate-spin" }) }) : S ? /* @__PURE__ */ e("div", { className: "grid grid-cols-2 gap-3", children: [
1330
+ [t("users.input_tokens"), S.input_tokens.toLocaleString(J)],
1331
+ [t("users.output_tokens"), S.output_tokens.toLocaleString(J)],
1332
+ [t("users.total_tokens"), S.total_tokens.toLocaleString(J)],
1333
+ [t("users.requests_made"), S.requests.toLocaleString(J)],
1302
1334
  [
1303
1335
  t("users.total_cost"),
1304
- Xe(
1305
- L.total_cost_microunits,
1306
- L.currency,
1336
+ Ye(
1337
+ S.total_cost_microunits,
1338
+ S.currency,
1307
1339
  J
1308
1340
  )
1309
1341
  ],
1310
- [t("users.renewals"), L.renewal_count.toLocaleString(J)],
1342
+ [t("users.renewals"), S.renewal_count.toLocaleString(J)],
1311
1343
  [
1312
1344
  t("users.unpriced_requests"),
1313
- L.unpriced_requests.toLocaleString(J)
1345
+ S.unpriced_requests.toLocaleString(J)
1314
1346
  ]
1315
1347
  ].map(([a, y]) => /* @__PURE__ */ r("div", { className: "rounded-xl border border-border bg-muted/20 p-4", children: [
1316
1348
  /* @__PURE__ */ e("p", { className: "text-[10px] uppercase tracking-wider text-muted-foreground", children: a }),
@@ -1323,7 +1355,7 @@ function Zt() {
1323
1355
  ] }),
1324
1356
  B && /* @__PURE__ */ e("div", { className: "fixed inset-0 bg-background/20 backdrop-blur-md flex items-center justify-center z-50 p-4", children: /* @__PURE__ */ r("div", { className: "bg-card rounded-2xl border border-border w-full max-w-xl shadow-2xl overflow-hidden", children: [
1325
1357
  /* @__PURE__ */ e("div", { className: "px-6 py-5 border-b border-border bg-muted/20", children: /* @__PURE__ */ e("h3", { className: "text-lg font-bold text-foreground", children: t(A ? "users.edit_user" : "users.add_user") }) }),
1326
- /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: A ? at : rt, children: [
1358
+ /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: A ? st : at, children: [
1327
1359
  /* @__PURE__ */ r("div", { className: "space-y-6 max-h-[60vh] overflow-y-auto px-1 custom-scrollbar", children: [
1328
1360
  /* @__PURE__ */ r("div", { className: "space-y-4", children: [
1329
1361
  /* @__PURE__ */ r("div", { children: [
@@ -1332,8 +1364,8 @@ function Zt() {
1332
1364
  "input",
1333
1365
  {
1334
1366
  type: "text",
1335
- value: b.phone,
1336
- onChange: (a) => te({ ...b, phone: Gt(a.target.value) }),
1367
+ value: v.phone,
1368
+ onChange: (a) => te({ ...v, phone: Qt(a.target.value) }),
1337
1369
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
1338
1370
  placeholder: t("users.phone_placeholder"),
1339
1371
  required: !0,
@@ -1348,9 +1380,9 @@ function Zt() {
1348
1380
  "input",
1349
1381
  {
1350
1382
  type: "text",
1351
- value: b.name,
1352
- onChange: (a) => te({ ...b, name: a.target.value }),
1353
- className: `w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm ${ie}`,
1383
+ value: v.name,
1384
+ onChange: (a) => te({ ...v, name: a.target.value }),
1385
+ className: `w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm ${oe}`,
1354
1386
  required: !0
1355
1387
  }
1356
1388
  )
@@ -1361,9 +1393,9 @@ function Zt() {
1361
1393
  "input",
1362
1394
  {
1363
1395
  type: "text",
1364
- value: b.surname,
1365
- onChange: (a) => te({ ...b, surname: a.target.value }),
1366
- className: `w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm ${ie}`,
1396
+ value: v.surname,
1397
+ onChange: (a) => te({ ...v, surname: a.target.value }),
1398
+ className: `w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm ${oe}`,
1367
1399
  required: !0
1368
1400
  }
1369
1401
  )
@@ -1379,8 +1411,8 @@ function Zt() {
1379
1411
  "input",
1380
1412
  {
1381
1413
  type: "number",
1382
- value: b.tokens,
1383
- onChange: (a) => te({ ...b, tokens: a.target.value }),
1414
+ value: v.tokens,
1415
+ onChange: (a) => te({ ...v, tokens: a.target.value }),
1384
1416
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
1385
1417
  dir: "ltr",
1386
1418
  placeholder: "0"
@@ -1393,11 +1425,11 @@ function Zt() {
1393
1425
  "input",
1394
1426
  {
1395
1427
  type: "number",
1396
- value: b.tokensLimit,
1397
- onChange: (a) => te({ ...b, tokensLimit: a.target.value }),
1428
+ value: v.tokensLimit,
1429
+ onChange: (a) => te({ ...v, tokensLimit: a.target.value }),
1398
1430
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
1399
1431
  dir: "ltr",
1400
- placeholder: b.tokens || String(P?.initial_balance_tokens ?? "250000")
1432
+ placeholder: v.tokens || String(P?.initial_balance_tokens ?? "250000")
1401
1433
  }
1402
1434
  )
1403
1435
  ] })
@@ -1409,11 +1441,11 @@ function Zt() {
1409
1441
  "input",
1410
1442
  {
1411
1443
  type: "number",
1412
- value: b.requests,
1413
- onChange: (a) => te({ ...b, requests: a.target.value }),
1444
+ value: v.requests,
1445
+ onChange: (a) => te({ ...v, requests: a.target.value }),
1414
1446
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
1415
1447
  dir: "ltr",
1416
- placeholder: b.requests || String(P?.initial_balance_requests ?? "0")
1448
+ placeholder: v.requests || String(P?.initial_balance_requests ?? "0")
1417
1449
  }
1418
1450
  )
1419
1451
  ] }),
@@ -1423,11 +1455,11 @@ function Zt() {
1423
1455
  "input",
1424
1456
  {
1425
1457
  type: "number",
1426
- value: b.requestsLimit,
1427
- onChange: (a) => te({ ...b, requestsLimit: a.target.value }),
1458
+ value: v.requestsLimit,
1459
+ onChange: (a) => te({ ...v, requestsLimit: a.target.value }),
1428
1460
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
1429
1461
  dir: "ltr",
1430
- placeholder: b.requests || String(P?.initial_balance_requests ?? "100")
1462
+ placeholder: v.requests || String(P?.initial_balance_requests ?? "100")
1431
1463
  }
1432
1464
  )
1433
1465
  ] })
@@ -1444,9 +1476,9 @@ function Zt() {
1444
1476
  re,
1445
1477
  {
1446
1478
  id: "admin-recharge-enabled",
1447
- checked: b.rechargeEnabled,
1479
+ checked: v.rechargeEnabled,
1448
1480
  onCheckedChange: (a) => te({
1449
- ...b,
1481
+ ...v,
1450
1482
  rechargeEnabled: a
1451
1483
  }),
1452
1484
  "aria-label": t("users.auto_recharge")
@@ -1455,7 +1487,7 @@ function Zt() {
1455
1487
  /* @__PURE__ */ e("label", { htmlFor: "admin-recharge-enabled", className: "text-sm text-foreground cursor-pointer", children: t("users.enabled") })
1456
1488
  ] })
1457
1489
  ] }),
1458
- b.rechargeEnabled && /* @__PURE__ */ r("div", { className: "space-y-4 rounded-xl border border-border/60 bg-muted/15 p-4", children: [
1490
+ v.rechargeEnabled && /* @__PURE__ */ r("div", { className: "space-y-4 rounded-xl border border-border/60 bg-muted/15 p-4", children: [
1459
1491
  /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: [
1460
1492
  /* @__PURE__ */ r("div", { children: [
1461
1493
  /* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: t("users.recharge_interval") }),
@@ -1465,8 +1497,8 @@ function Zt() {
1465
1497
  type: "number",
1466
1498
  min: "1",
1467
1499
  step: "1",
1468
- value: b.rechargeIntervalValue,
1469
- onChange: (a) => te({ ...b, rechargeIntervalValue: a.target.value }),
1500
+ value: v.rechargeIntervalValue,
1501
+ onChange: (a) => te({ ...v, rechargeIntervalValue: a.target.value }),
1470
1502
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
1471
1503
  required: !0,
1472
1504
  dir: "ltr"
@@ -1476,17 +1508,17 @@ function Zt() {
1476
1508
  /* @__PURE__ */ r("div", { children: [
1477
1509
  /* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: t("users.recharge_unit") }),
1478
1510
  /* @__PURE__ */ r(
1479
- oe,
1511
+ le,
1480
1512
  {
1481
- value: b.rechargeIntervalUnit,
1513
+ value: v.rechargeIntervalUnit,
1482
1514
  onValueChange: (a) => te({
1483
- ...b,
1515
+ ...v,
1484
1516
  rechargeIntervalUnit: a
1485
1517
  }),
1486
- dir: T ? "rtl" : "ltr",
1518
+ dir: L ? "rtl" : "ltr",
1487
1519
  children: [
1488
- /* @__PURE__ */ e(le, { className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground transition-all text-sm h-[46px]", children: /* @__PURE__ */ e(de, {}) }),
1489
- /* @__PURE__ */ e(ce, { className: "rounded-xl border-border bg-card", children: ["minute", "hour", "day", "week", "month"].map((a) => /* @__PURE__ */ e(Z, { value: a, children: t(`users.recharge_unit_${a}`) }, a)) })
1520
+ /* @__PURE__ */ e(de, { className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground transition-all text-sm h-[46px]", children: /* @__PURE__ */ e(ce, {}) }),
1521
+ /* @__PURE__ */ e(me, { className: "rounded-xl border-border bg-card", children: ["minute", "hour", "day", "week", "month"].map((a) => /* @__PURE__ */ e(Q, { value: a, children: t(`users.recharge_unit_${a}`) }, a)) })
1490
1522
  ]
1491
1523
  }
1492
1524
  )
@@ -1507,27 +1539,27 @@ function Zt() {
1507
1539
  ] }),
1508
1540
  E.length > 0 && /* @__PURE__ */ r("div", { className: "border-t border-border/50 pt-4 mt-4 space-y-4", children: [
1509
1541
  /* @__PURE__ */ e("h4", { className: "text-sm font-bold text-foreground/70", children: t("users.custom_fields") }),
1510
- /* @__PURE__ */ e("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: E.map((a) => Oe(a.condition, se) ? /* @__PURE__ */ r("div", { className: "animate-in fade-in slide-in-from-top-1 duration-200", children: [
1542
+ /* @__PURE__ */ e("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: E.map((a) => Fe(a.condition, se) ? /* @__PURE__ */ r("div", { className: "animate-in fade-in slide-in-from-top-1 duration-200", children: [
1511
1543
  /* @__PURE__ */ r("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: [
1512
1544
  t(a.label),
1513
1545
  " ",
1514
1546
  a.required && /* @__PURE__ */ e("span", { className: "text-destructive", children: "*" })
1515
1547
  ] }),
1516
1548
  a.type === "select" ? /* @__PURE__ */ r(
1517
- oe,
1549
+ le,
1518
1550
  {
1519
1551
  value: String(se[a.key] || ""),
1520
1552
  onValueChange: (y) => be({ ...se, [a.key]: y }),
1521
1553
  required: a.required,
1522
- dir: T ? "rtl" : "ltr",
1554
+ dir: L ? "rtl" : "ltr",
1523
1555
  children: [
1524
- /* @__PURE__ */ e(le, { className: Te("w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground transition-all text-sm h-[46px]", ie), children: /* @__PURE__ */ e(de, { placeholder: t(a.placeholder || "select_placeholder") }) }),
1525
- /* @__PURE__ */ e(ce, { className: "rounded-xl border-border bg-card", children: a.options?.map((y) => /* @__PURE__ */ e(Z, { value: String(y.value), children: t(y.label) }, String(y.value))) })
1556
+ /* @__PURE__ */ e(de, { className: Te("w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground transition-all text-sm h-[46px]", oe), children: /* @__PURE__ */ e(ce, { placeholder: t(a.placeholder || "select_placeholder") }) }),
1557
+ /* @__PURE__ */ e(me, { className: "rounded-xl border-border bg-card", children: a.options?.map((y) => /* @__PURE__ */ e(Q, { value: String(y.value), children: t(y.label) }, String(y.value))) })
1526
1558
  ]
1527
1559
  }
1528
1560
  ) : a.type === "checkbox" ? /* @__PURE__ */ r("div", { className: "flex items-center gap-3 h-[46px] px-1", children: [
1529
1561
  /* @__PURE__ */ e(
1530
- gt,
1562
+ xt,
1531
1563
  {
1532
1564
  id: `admin-md-${a.key}`,
1533
1565
  checked: !!se[a.key],
@@ -1542,7 +1574,7 @@ function Zt() {
1542
1574
  type: a.type,
1543
1575
  value: se[a.key] || "",
1544
1576
  onChange: (y) => be({ ...se, [a.key]: y.target.value }),
1545
- className: `w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm ${ie}`,
1577
+ className: `w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm ${oe}`,
1546
1578
  placeholder: t(a.placeholder || ""),
1547
1579
  required: a.required
1548
1580
  }
@@ -1557,8 +1589,8 @@ function Zt() {
1557
1589
  /* @__PURE__ */ e(
1558
1590
  "textarea",
1559
1591
  {
1560
- value: b.metadata,
1561
- onChange: (a) => te({ ...b, metadata: a.target.value }),
1592
+ value: v.metadata,
1593
+ onChange: (a) => te({ ...v, metadata: a.target.value }),
1562
1594
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-xs font-mono min-h-[100px] custom-scrollbar",
1563
1595
  placeholder: '{ "key": "value" }',
1564
1596
  dir: "ltr"
@@ -1582,9 +1614,9 @@ function Zt() {
1582
1614
  "button",
1583
1615
  {
1584
1616
  type: "submit",
1585
- disabled: c,
1617
+ disabled: m,
1586
1618
  className: "flex-1 px-4 py-3 bg-primary text-primary-foreground rounded-xl text-sm font-bold hover:opacity-90 transition-all shadow-md hover:shadow-lg disabled:opacity-50",
1587
- children: t(c ? "saving" : "save")
1619
+ children: t(m ? "saving" : "save")
1588
1620
  }
1589
1621
  )
1590
1622
  ] })
@@ -1601,14 +1633,14 @@ function Zt() {
1601
1633
  "button",
1602
1634
  {
1603
1635
  onClick: () => {
1604
- f(null), _("");
1636
+ x(null), _("");
1605
1637
  },
1606
1638
  className: "text-muted-foreground hover:text-foreground transition-colors",
1607
1639
  children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 2, stroke: "currentColor", className: "w-5 h-5", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M6 18L18 6M6 6l12 12" }) })
1608
1640
  }
1609
1641
  )
1610
1642
  ] }),
1611
- /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: ot, children: [
1643
+ /* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: lt, children: [
1612
1644
  /* @__PURE__ */ r("div", { className: "space-y-4", children: [
1613
1645
  /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: [
1614
1646
  /* @__PURE__ */ r("div", { children: [
@@ -1617,7 +1649,7 @@ function Zt() {
1617
1649
  "input",
1618
1650
  {
1619
1651
  type: "number",
1620
- value: q,
1652
+ value: j,
1621
1653
  onChange: (a) => s(a.target.value),
1622
1654
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
1623
1655
  required: !0,
@@ -1632,10 +1664,10 @@ function Zt() {
1632
1664
  {
1633
1665
  type: "number",
1634
1666
  value: O,
1635
- onChange: (a) => C(a.target.value),
1667
+ onChange: (a) => q(a.target.value),
1636
1668
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
1637
1669
  dir: "ltr",
1638
- placeholder: q
1670
+ placeholder: j
1639
1671
  }
1640
1672
  )
1641
1673
  ] })
@@ -1648,7 +1680,7 @@ function Zt() {
1648
1680
  {
1649
1681
  type: "number",
1650
1682
  value: u,
1651
- onChange: (a) => j(a.target.value),
1683
+ onChange: (a) => T(a.target.value),
1652
1684
  className: "w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
1653
1685
  required: !0,
1654
1686
  dir: "ltr"
@@ -1676,7 +1708,7 @@ function Zt() {
1676
1708
  "button",
1677
1709
  {
1678
1710
  type: "button",
1679
- onClick: lt,
1711
+ onClick: dt,
1680
1712
  className: "flex-1 px-4 py-3 bg-secondary text-secondary-foreground border border-border rounded-xl text-sm font-medium hover:bg-secondary/80 transition-colors",
1681
1713
  children: t("users.full_charge")
1682
1714
  }
@@ -1685,9 +1717,9 @@ function Zt() {
1685
1717
  "button",
1686
1718
  {
1687
1719
  type: "submit",
1688
- disabled: c,
1720
+ disabled: m,
1689
1721
  className: "flex-1 px-4 py-3 bg-primary text-primary-foreground rounded-xl text-sm font-bold hover:opacity-90 transition-all shadow-md hover:shadow-lg disabled:opacity-50",
1690
- children: t(c ? "users.updating" : "users.update_balance")
1722
+ children: t(m ? "users.updating" : "users.update_balance")
1691
1723
  }
1692
1724
  )
1693
1725
  ] })
@@ -1699,26 +1731,26 @@ function Zt() {
1699
1731
  className: "overflow-auto flex-1 min-h-0 custom-scrollbar",
1700
1732
  onScroll: (a) => {
1701
1733
  const y = a.currentTarget;
1702
- y.scrollHeight - y.scrollTop - y.clientHeight < 160 && !c && d.length < $ && ke(!0);
1734
+ y.scrollHeight - y.scrollTop - y.clientHeight < 160 && !m && d.length < $ && ke(!0);
1703
1735
  },
1704
1736
  children: [
1705
- /* @__PURE__ */ r("table", { className: `w-full ${T ? "text-right" : "text-left"} border-collapse`, children: [
1737
+ /* @__PURE__ */ r("table", { className: `w-full ${L ? "text-right" : "text-left"} border-collapse`, children: [
1706
1738
  /* @__PURE__ */ e("thead", { className: "bg-muted/30 sticky top-0 z-10 backdrop-blur-md", children: /* @__PURE__ */ r("tr", { children: [
1707
1739
  ["phone", "name", "surname"].map((a) => /* @__PURE__ */ e(
1708
1740
  "th",
1709
1741
  {
1710
1742
  className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50",
1711
- "aria-sort": S === a ? K === "asc" ? "ascending" : "descending" : "none",
1743
+ "aria-sort": C === a ? K === "asc" ? "ascending" : "descending" : "none",
1712
1744
  children: /* @__PURE__ */ r(
1713
1745
  "button",
1714
1746
  {
1715
1747
  type: "button",
1716
- onClick: () => et(a),
1748
+ onClick: () => tt(a),
1717
1749
  className: "inline-flex items-center gap-1.5 hover:text-foreground transition-colors",
1718
- title: t(S === a && K === "asc" ? "users.sort_descending" : "users.sort_ascending"),
1750
+ title: t(C === a && K === "asc" ? "users.sort_descending" : "users.sort_ascending"),
1719
1751
  children: [
1720
1752
  /* @__PURE__ */ e("span", { children: t(`users.${a}`) }),
1721
- tt(a)
1753
+ rt(a)
1722
1754
  ]
1723
1755
  }
1724
1756
  )
@@ -1780,16 +1812,16 @@ function Zt() {
1780
1812
  /* @__PURE__ */ e(
1781
1813
  "button",
1782
1814
  {
1783
- onClick: () => ct(a),
1815
+ onClick: () => mt(a),
1784
1816
  className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
1785
1817
  title: t("users.usage_summary"),
1786
- children: /* @__PURE__ */ e(Tt, { className: "w-4 h-4" })
1818
+ children: /* @__PURE__ */ e(It, { className: "w-4 h-4" })
1787
1819
  }
1788
1820
  ),
1789
1821
  /* @__PURE__ */ e(
1790
1822
  "button",
1791
1823
  {
1792
- onClick: () => dt(a),
1824
+ onClick: () => ct(a),
1793
1825
  className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
1794
1826
  title: t("edit"),
1795
1827
  children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "w-4 h-4", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "m16.862 4.487 1.687-1.688a1.875 1.875 0 1 1 2.652 2.652L10.582 16.07a4.5 4.5 0 0 1-1.897 1.13L6 18l.8-2.685a4.5 4.5 0 0 1 1.13-1.897l8.932-8.931Zm0 0L19.5 7.125M18 14v4.75A2.25 2.25 0 0 1 15.75 21H5.25A2.25 2.25 0 0 1 3 18.75V8.25A2.25 2.25 0 0 1 5.25 6H10" }) })
@@ -1799,7 +1831,7 @@ function Zt() {
1799
1831
  "button",
1800
1832
  {
1801
1833
  onClick: () => {
1802
- f(a), s(String(a.balance?.tokens || 0)), j(String(a.balance?.requests || 0)), C(String(a.balance?.token_limit || 0)), n(String(a.balance?.request_limit || 0)), _("");
1834
+ x(a), s(String(a.balance?.tokens || 0)), T(String(a.balance?.requests || 0)), q(String(a.balance?.token_limit || 0)), n(String(a.balance?.request_limit || 0)), _("");
1803
1835
  },
1804
1836
  className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
1805
1837
  title: t("users.recharge"),
@@ -1809,7 +1841,7 @@ function Zt() {
1809
1841
  /* @__PURE__ */ e(
1810
1842
  "button",
1811
1843
  {
1812
- onClick: () => nt(a),
1844
+ onClick: () => it(a),
1813
1845
  className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
1814
1846
  title: t("users.copy_token"),
1815
1847
  children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "w-4 h-4", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M15.75 5.25a3 3 0 0 1 3 3m3 0a6 6 0 0 1-7.029 5.912c-.563-.097-1.159.026-1.563.43L10.5 17.25H8.25v2.25H6v2.25H2.25v-2.818c0-.597.237-1.17.659-1.591l6.499-6.499c.404-.404.527-1 .43-1.563A6 6 0 1 1 21.75 8.25Z" }) })
@@ -1818,7 +1850,7 @@ function Zt() {
1818
1850
  /* @__PURE__ */ e(
1819
1851
  "button",
1820
1852
  {
1821
- onClick: () => st(a.id),
1853
+ onClick: () => nt(a.id),
1822
1854
  className: "p-2 text-destructive hover:text-destructive/80 hover:bg-destructive/10 rounded-xl transition-all",
1823
1855
  title: t("delete"),
1824
1856
  children: /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/svg", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1.5, stroke: "currentColor", className: "w-4 h-4", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "m14.74 9-.346 9m-4.788 0L9.26 9m9.968-3.21c.342.052.682.107 1.022.166m-1.022-.165L18.16 19.673a2.25 2.25 0 0 1-2.244 2.077H8.084a2.25 2.25 0 0 1-2.244-2.077L4.772 5.79m14.456 0a48.108 48.108 0 0 0-3.478-.397m-12 .562c.34-.059.68-.114 1.022-.165m0 0a48.11 48.11 0 0 1 3.478-.397m7.5 0v-.916c0-1.18-.91-2.164-2.09-2.201a51.964 51.964 0 0 0-3.32 0c-1.18.037-2.09 1.022-2.09 2.201v.916m7.5 0a48.667 48.667 0 0 0-7.5 0" }) })
@@ -1827,11 +1859,11 @@ function Zt() {
1827
1859
  ] }) })
1828
1860
  ] }, a.id)) })
1829
1861
  ] }),
1830
- d.length === 0 && !c && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-2", children: [
1862
+ d.length === 0 && !m && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-2", children: [
1831
1863
  /* @__PURE__ */ e("svg", { xmlns: "http://www.w3.org/2000/xl", fill: "none", viewBox: "0 0 24 24", strokeWidth: 1, stroke: "currentColor", className: "w-12 h-12 opacity-20", children: /* @__PURE__ */ e("path", { strokeLinecap: "round", strokeLinejoin: "round", d: "M18 18.72a9.094 9.094 0 0 0 3.741-.479 3 3 0 0 0-4.682-2.72m.94 3.198.001.031c0 .225-.012.447-.037.666A11.944 11.944 0 0 1 12 21c-2.17 0-4.207-.576-5.963-1.584A6.062 6.062 0 0 1 6 18.719m12 0a5.971 5.971 0 0 0-.941-3.197m0 0A5.995 5.995 0 0 0 12 12.75a5.995 5.995 0 0 0-5.058 2.772m0 0a3 3 0 0 0-4.681 2.72 8.986 8.986 0 0 0 3.74.477m.94-3.197a5.971 5.971 0 0 0-.94 3.197M15 6.75a3 3 0 1 1-6 0 3 3 0 0 1 6 0Zm6 3a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Zm-13.5 0a2.25 2.25 0 1 1-4.5 0 2.25 2.25 0 0 1 4.5 0Z" }) }),
1832
1864
  t("users.no_users")
1833
1865
  ] }),
1834
- c && /* @__PURE__ */ r("div", { className: `${d.length > 0 ? "p-5" : "p-12"} text-center text-muted-foreground text-sm flex flex-col items-center gap-3`, children: [
1866
+ m && /* @__PURE__ */ r("div", { className: `${d.length > 0 ? "p-5" : "p-12"} text-center text-muted-foreground text-sm flex flex-col items-center gap-3`, children: [
1835
1867
  /* @__PURE__ */ e("div", { className: "w-8 h-8 border-2 border-primary/20 border-t-primary rounded-full animate-spin" }),
1836
1868
  /* @__PURE__ */ e("span", { children: t("loading") })
1837
1869
  ] })
@@ -1840,71 +1872,71 @@ function Zt() {
1840
1872
  ) })
1841
1873
  ] });
1842
1874
  }
1843
- function Qt() {
1844
- const { t, i18n: i } = me(["admin", "translation"]), [o, d] = p(null), [g, c] = p(!0), [x, N] = p(""), [_, B] = p(30), [M, A] = p({}), F = Le({}), R = i.language === "fa", k = R ? "fa-IR" : "en-US", $ = R ? "fa-IR-u-ca-persian" : "en-US";
1875
+ function Yt() {
1876
+ const { t, i18n: i } = ue(["admin", "translation"]), [o, d] = p(null), [f, m] = p(!0), [b, N] = p(""), [_, B] = p(30), [M, A] = p({}), F = Le({}), R = i.language === "fa", k = R ? "fa-IR" : "en-US", $ = R ? "fa-IR-u-ca-persian" : "en-US";
1845
1877
  Y(() => {
1846
1878
  K();
1847
1879
  }, [_]), Y(() => {
1848
1880
  const s = Object.entries(F.current).filter(
1849
- (j) => !!j[1]
1881
+ (T) => !!T[1]
1850
1882
  );
1851
1883
  if (s.length === 0) return;
1852
- const u = new ResizeObserver((j) => {
1853
- for (const O of j) {
1854
- const C = O.target.dataset.chartId;
1855
- C && A((z) => ({
1884
+ const u = new ResizeObserver((T) => {
1885
+ for (const O of T) {
1886
+ const q = O.target.dataset.chartId;
1887
+ q && A((z) => ({
1856
1888
  ...z,
1857
- [C]: O.contentRect.width
1889
+ [q]: O.contentRect.width
1858
1890
  }));
1859
1891
  }
1860
1892
  });
1861
- return s.forEach(([, j]) => u.observe(j)), () => u.disconnect();
1893
+ return s.forEach(([, T]) => u.observe(T)), () => u.disconnect();
1862
1894
  }, [o]);
1863
1895
  const H = (s) => (u) => {
1864
1896
  F.current[s] = u;
1865
- }, S = (s, u, j) => {
1866
- const O = [], C = /* @__PURE__ */ new Date(), z = s || [], n = new Map(z.map((m) => [m.date, m]));
1867
- for (let m = u - 1; m >= 0; m--) {
1868
- const L = new Date(C.getTime() - m * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
1869
- if (n.has(L))
1870
- O.push(n.get(L));
1897
+ }, C = (s, u, T) => {
1898
+ const O = [], q = /* @__PURE__ */ new Date(), z = s || [], n = new Map(z.map((c) => [c.date, c]));
1899
+ for (let c = u - 1; c >= 0; c--) {
1900
+ const S = new Date(q.getTime() - c * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
1901
+ if (n.has(S))
1902
+ O.push(n.get(S));
1871
1903
  else {
1872
- const G = { date: L };
1873
- j.forEach((pe) => G[pe] = 0), O.push(G);
1904
+ const G = { date: S };
1905
+ T.forEach((ie) => G[ie] = 0), O.push(G);
1874
1906
  }
1875
1907
  }
1876
1908
  return O;
1877
1909
  }, D = (s, u = 0) => {
1878
1910
  if (!s || s.length === 0) return null;
1879
- const j = s.length, O = new Intl.DateTimeFormat($, { month: "short" });
1880
- let C = [];
1911
+ const T = s.length, O = new Intl.DateTimeFormat($, { month: "short" });
1912
+ let q = [];
1881
1913
  if (_ <= 14)
1882
- C = Array.from({ length: j }, (z, n) => n);
1914
+ q = Array.from({ length: T }, (z, n) => n);
1883
1915
  else {
1884
- const z = R ? 45 : 35, n = u > 0 ? Math.floor(u / z) : 6, m = Math.max(1, Math.ceil(j / Math.max(1, n)));
1885
- for (let v = 0; v < j; v += m)
1886
- C.push(v);
1887
- C.length > 0 && C[C.length - 1] !== j - 1 && (j - 1 - C[C.length - 1] > m / 2 ? C.push(j - 1) : C[C.length - 1] = j - 1);
1916
+ const z = R ? 45 : 35, n = u > 0 ? Math.floor(u / z) : 6, c = Math.max(1, Math.ceil(T / Math.max(1, n)));
1917
+ for (let g = 0; g < T; g += c)
1918
+ q.push(g);
1919
+ q.length > 0 && q[q.length - 1] !== T - 1 && (T - 1 - q[q.length - 1] > c / 2 ? q.push(T - 1) : q[q.length - 1] = T - 1);
1888
1920
  }
1889
- return /* @__PURE__ */ e("div", { className: "relative w-full h-8 mt-2", dir: R ? "rtl" : "ltr", children: C.map((z) => {
1921
+ return /* @__PURE__ */ e("div", { className: "relative w-full h-8 mt-2", dir: R ? "rtl" : "ltr", children: q.map((z) => {
1890
1922
  const n = s[z];
1891
1923
  if (!n) return null;
1892
- const m = new Date(n.date), v = m.toLocaleDateString($, { day: "numeric" }), L = O.format(m), G = j > 1 ? z / (j - 1) * 100 : 50;
1924
+ const c = new Date(n.date), g = c.toLocaleDateString($, { day: "numeric" }), S = O.format(c), G = T > 1 ? z / (T - 1) * 100 : 50;
1893
1925
  return /* @__PURE__ */ r(
1894
1926
  "div",
1895
1927
  {
1896
1928
  className: "absolute top-0 transform -translate-x-1/2 flex flex-col items-center",
1897
1929
  style: { left: `${G}%` },
1898
1930
  children: [
1899
- /* @__PURE__ */ e("span", { className: "text-[10px] text-gray-600 dark:text-gray-400 font-medium leading-none", children: v }),
1900
- /* @__PURE__ */ e("span", { className: "text-[9px] text-gray-400 dark:text-gray-500 mt-1 leading-none whitespace-nowrap", children: L })
1931
+ /* @__PURE__ */ e("span", { className: "text-[10px] text-gray-600 dark:text-gray-400 font-medium leading-none", children: g }),
1932
+ /* @__PURE__ */ e("span", { className: "text-[9px] text-gray-400 dark:text-gray-500 mt-1 leading-none whitespace-nowrap", children: S })
1901
1933
  ]
1902
1934
  },
1903
1935
  z
1904
1936
  );
1905
1937
  }) });
1906
1938
  }, K = async () => {
1907
- c(!0), N("");
1939
+ m(!0), N("");
1908
1940
  try {
1909
1941
  const s = await w.getAnalytics(_), u = {
1910
1942
  ...s,
@@ -1920,10 +1952,10 @@ function Qt() {
1920
1952
  },
1921
1953
  trends: {
1922
1954
  ...s.trends || {},
1923
- users: S(s.trends?.users, _, ["count"]),
1924
- threads: S(s.trends?.threads, _, ["count"]),
1925
- messages: S(s.trends?.messages, _, ["count"]),
1926
- token_usage: S(
1955
+ users: C(s.trends?.users, _, ["count"]),
1956
+ threads: C(s.trends?.threads, _, ["count"]),
1957
+ messages: C(s.trends?.messages, _, ["count"]),
1958
+ token_usage: C(
1927
1959
  s.trends?.token_usage,
1928
1960
  _,
1929
1961
  ["input_tokens", "output_tokens", "requests", "cost_microunits", "unpriced_requests"]
@@ -1939,14 +1971,14 @@ function Qt() {
1939
1971
  } catch (s) {
1940
1972
  N(s instanceof Error ? s.message : t("analytics.error_loading"));
1941
1973
  } finally {
1942
- c(!1);
1974
+ m(!1);
1943
1975
  }
1944
1976
  };
1945
- if (g)
1977
+ if (f)
1946
1978
  return /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground", children: t("analytics.loading_analytics") });
1947
- if (x)
1979
+ if (b)
1948
1980
  return /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center", children: /* @__PURE__ */ r("div", { className: "text-center", children: [
1949
- /* @__PURE__ */ e("div", { className: "text-destructive mb-4", children: x }),
1981
+ /* @__PURE__ */ e("div", { className: "text-destructive mb-4", children: b }),
1950
1982
  /* @__PURE__ */ e(
1951
1983
  "button",
1952
1984
  {
@@ -1959,12 +1991,12 @@ function Qt() {
1959
1991
  if (!o) return null;
1960
1992
  const W = (s) => {
1961
1993
  if (s <= 0) return 10;
1962
- const u = s * 1.15, j = Math.pow(10, Math.floor(Math.log10(u))), O = u / j;
1963
- let C;
1964
- return O <= 1.2 ? C = 0.2 : O <= 2.5 ? C = 0.5 : O <= 5 ? C = 1 : C = 2, Math.ceil(u / (C * j)) * (C * j);
1965
- }, P = Math.max(...o.trends.threads.map((s) => s.count) || [1]), ae = Math.max(...o.trends.messages.map((s) => s.count) || [1]), Q = Math.max(
1994
+ const u = s * 1.15, T = Math.pow(10, Math.floor(Math.log10(u))), O = u / T;
1995
+ let q;
1996
+ return O <= 1.2 ? q = 0.2 : O <= 2.5 ? q = 0.5 : O <= 5 ? q = 1 : q = 2, Math.ceil(u / (q * T)) * (q * T);
1997
+ }, P = Math.max(...o.trends.threads.map((s) => s.count) || [1]), ae = Math.max(...o.trends.messages.map((s) => s.count) || [1]), Z = Math.max(
1966
1998
  ...o.trends.token_usage.map((s) => (s.input_tokens || 0) + (s.output_tokens || 0)) || [1]
1967
- ), h = Math.max(...o.trends.token_usage.map((s) => s.cost_microunits) || [1]), E = W(P), U = W(ae), f = W(Q), q = W(h);
1999
+ ), h = Math.max(...o.trends.token_usage.map((s) => s.cost_microunits) || [1]), E = W(P), U = W(ae), x = W(Z), j = W(h);
1968
2000
  return /* @__PURE__ */ r("div", { className: "h-full overflow-auto p-5 flex flex-col gap-5", dir: R ? "rtl" : "ltr", children: [
1969
2001
  /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-center justify-between gap-3", children: [
1970
2002
  /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-foreground tracking-tight whitespace-nowrap", children: t("analytics.title") }),
@@ -2100,8 +2132,8 @@ function Qt() {
2100
2132
  /* @__PURE__ */ r("div", { className: "h-64 flex flex-col", ref: H("token-usage"), "data-chart-id": "token-usage", children: [
2101
2133
  /* @__PURE__ */ r("div", { className: "flex-1 flex gap-2 min-h-0", dir: "ltr", children: [
2102
2134
  /* @__PURE__ */ r("div", { className: "flex flex-col justify-between text-[10px] text-muted-foreground pt-6 text-right min-w-[24px]", children: [
2103
- /* @__PURE__ */ e("span", { children: (f || 0).toLocaleString(k) }),
2104
- /* @__PURE__ */ e("span", { children: Math.floor((f || 0) / 2).toLocaleString(k) }),
2135
+ /* @__PURE__ */ e("span", { children: (x || 0).toLocaleString(k) }),
2136
+ /* @__PURE__ */ e("span", { children: Math.floor((x || 0) / 2).toLocaleString(k) }),
2105
2137
  /* @__PURE__ */ e("span", { children: "0" })
2106
2138
  ] }),
2107
2139
  /* @__PURE__ */ r("div", { className: "flex-1 relative flex items-end justify-between pt-6 border-b border-border/30", children: [
@@ -2110,14 +2142,14 @@ function Qt() {
2110
2142
  /* @__PURE__ */ e("div", { className: "absolute top-[calc(50%-4px)] left-0 right-0 border-t border-border/30 w-full" })
2111
2143
  ] }),
2112
2144
  o.trends.token_usage.length > 0 ? o.trends.token_usage.map((s, u) => {
2113
- const j = (s.input_tokens || 0) + (s.output_tokens || 0);
2145
+ const T = (s.input_tokens || 0) + (s.output_tokens || 0);
2114
2146
  return /* @__PURE__ */ e("div", { className: "w-1.5 group relative flex flex-col justify-end h-full", children: /* @__PURE__ */ e(
2115
2147
  "div",
2116
2148
  {
2117
2149
  className: "bg-primary/80 w-full rounded-t-lg transition-all group-hover:bg-primary relative",
2118
- style: { height: `${j / f * 100}%` },
2150
+ style: { height: `${T / x * 100}%` },
2119
2151
  children: /* @__PURE__ */ r("div", { className: "absolute bottom-full mb-1 left-1/2 -translate-x-1/2 opacity-0 group-hover:opacity-100 transition-opacity bg-card px-2 py-1 rounded border border-border shadow-sm z-20 pointer-events-none flex flex-col items-center", children: [
2120
- /* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children: j.toLocaleString(k) }),
2152
+ /* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children: T.toLocaleString(k) }),
2121
2153
  /* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(s.date).toLocaleDateString($, { month: "short", day: "numeric" }) })
2122
2154
  ] })
2123
2155
  }
@@ -2136,8 +2168,8 @@ function Qt() {
2136
2168
  /* @__PURE__ */ r("div", { className: "h-64 flex flex-col", ref: H("cost"), "data-chart-id": "cost", children: [
2137
2169
  /* @__PURE__ */ r("div", { className: "flex-1 flex gap-2 min-h-0", dir: "ltr", children: [
2138
2170
  /* @__PURE__ */ r("div", { className: "flex flex-col justify-between text-[10px] text-muted-foreground pt-6 text-right min-w-[70px]", children: [
2139
- /* @__PURE__ */ e("span", { children: xe(q || 0, o.overview.currency, k) }),
2140
- /* @__PURE__ */ e("span", { children: xe(Math.floor((q || 0) / 2), o.overview.currency, k) }),
2171
+ /* @__PURE__ */ e("span", { children: xe(j || 0, o.overview.currency, k) }),
2172
+ /* @__PURE__ */ e("span", { children: xe(Math.floor((j || 0) / 2), o.overview.currency, k) }),
2141
2173
  /* @__PURE__ */ e("span", { children: xe(0, o.overview.currency, k) })
2142
2174
  ] }),
2143
2175
  /* @__PURE__ */ r("div", { className: "flex-1 relative flex items-end justify-between pt-6 border-b border-border/30", children: [
@@ -2149,7 +2181,7 @@ function Qt() {
2149
2181
  "div",
2150
2182
  {
2151
2183
  className: "bg-emerald-500/80 w-full rounded-t-lg transition-all group-hover:bg-emerald-500 relative",
2152
- style: { height: `${(s.cost_microunits || 0) / q * 100}%` },
2184
+ style: { height: `${(s.cost_microunits || 0) / j * 100}%` },
2153
2185
  children: /* @__PURE__ */ r("div", { className: "absolute bottom-full mb-1 left-1/2 -translate-x-1/2 opacity-0 group-hover:opacity-100 transition-opacity bg-card px-2 py-1 rounded border border-border shadow-sm z-20 pointer-events-none flex flex-col items-center", children: [
2154
2186
  /* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-emerald-500 leading-none mb-0.5", children: xe(s.cost_microunits || 0, o.overview.currency, k) }),
2155
2187
  /* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(s.date).toLocaleDateString($, { month: "short", day: "numeric" }) })
@@ -2172,17 +2204,17 @@ function Qt() {
2172
2204
  /* @__PURE__ */ r("div", { className: "relative w-56 h-56 lg:w-60 lg:h-60", children: [
2173
2205
  /* @__PURE__ */ e("svg", { viewBox: "0 0 100 100", className: "w-full h-full -rotate-90 drop-shadow-md", children: (() => {
2174
2206
  const s = o.distributions.feedback_sentiment.filter(
2175
- (v) => v.sentiment === "positive" || v.sentiment === "negative"
2176
- ), u = s.reduce((v, L) => v + L.count, 0);
2207
+ (g) => g.sentiment === "positive" || g.sentiment === "negative"
2208
+ ), u = s.reduce((g, S) => g + S.count, 0);
2177
2209
  if (u === 0) return null;
2178
- const j = s.find((v) => v.sentiment === "positive")?.count || 0, O = s.find((v) => v.sentiment === "negative")?.count || 0, C = 40, z = 2 * Math.PI * C, n = j / u * 100, m = O / u * 100;
2179
- return /* @__PURE__ */ r(mt, { children: [
2210
+ const T = s.find((g) => g.sentiment === "positive")?.count || 0, O = s.find((g) => g.sentiment === "negative")?.count || 0, q = 40, z = 2 * Math.PI * q, n = T / u * 100, c = O / u * 100;
2211
+ return /* @__PURE__ */ r(ut, { children: [
2180
2212
  /* @__PURE__ */ e(
2181
2213
  "circle",
2182
2214
  {
2183
2215
  cx: "50",
2184
2216
  cy: "50",
2185
- r: C,
2217
+ r: q,
2186
2218
  fill: "transparent",
2187
2219
  stroke: "currentColor",
2188
2220
  strokeWidth: "10",
@@ -2204,7 +2236,7 @@ function Qt() {
2204
2236
  {
2205
2237
  cx: "50",
2206
2238
  cy: "50",
2207
- r: C,
2239
+ r: q,
2208
2240
  fill: "transparent",
2209
2241
  stroke: "url(#posGradient)",
2210
2242
  strokeWidth: "10",
@@ -2218,13 +2250,13 @@ function Qt() {
2218
2250
  {
2219
2251
  cx: "50",
2220
2252
  cy: "50",
2221
- r: C,
2253
+ r: q,
2222
2254
  fill: "transparent",
2223
2255
  stroke: "url(#negGradient)",
2224
2256
  strokeWidth: "10",
2225
- strokeDasharray: `${m / 100 * z} ${z}`,
2257
+ strokeDasharray: `${c / 100 * z} ${z}`,
2226
2258
  strokeDashoffset: -(n / 100 * z),
2227
- strokeLinecap: m > 0 ? "round" : "butt",
2259
+ strokeLinecap: c > 0 ? "round" : "butt",
2228
2260
  className: "transition-all duration-1000 ease-out drop-shadow-sm"
2229
2261
  }
2230
2262
  )
@@ -2236,14 +2268,14 @@ function Qt() {
2236
2268
  ] })
2237
2269
  ] }),
2238
2270
  /* @__PURE__ */ e("div", { className: "flex flex-col gap-4 min-w-[140px]", children: [...o.distributions.feedback_sentiment].filter((s) => s.sentiment === "positive" || s.sentiment === "negative").sort((s, u) => s.sentiment === "positive" ? -1 : 1).map((s) => {
2239
- const j = o.distributions.feedback_sentiment.filter(
2240
- (m) => m.sentiment === "positive" || m.sentiment === "negative"
2241
- ).reduce((m, v) => m + v.count, 0), O = j > 0 ? s.count / j * 100 : 0, C = s.sentiment === "positive" ? t("analytics.positive") : t("analytics.negative"), z = s.sentiment === "positive" ? "bg-primary" : "bg-destructive", n = s.sentiment === "positive" ? "👍" : "👎";
2271
+ const T = o.distributions.feedback_sentiment.filter(
2272
+ (c) => c.sentiment === "positive" || c.sentiment === "negative"
2273
+ ).reduce((c, g) => c + g.count, 0), O = T > 0 ? s.count / T * 100 : 0, q = s.sentiment === "positive" ? t("analytics.positive") : t("analytics.negative"), z = s.sentiment === "positive" ? "bg-primary" : "bg-destructive", n = s.sentiment === "positive" ? "👍" : "👎";
2242
2274
  return /* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-6 group", children: [
2243
2275
  /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
2244
2276
  /* @__PURE__ */ e("div", { className: `w-3 h-3 rounded-full ${z} shadow-sm group-hover:scale-110 transition-transform` }),
2245
2277
  /* @__PURE__ */ r("span", { className: "text-sm text-muted-foreground font-medium", children: [
2246
- C,
2278
+ q,
2247
2279
  " ",
2248
2280
  n
2249
2281
  ] })
@@ -2287,28 +2319,28 @@ function Qt() {
2287
2319
  ] })
2288
2320
  ] });
2289
2321
  }
2290
- function Xt() {
2291
- const { t, i18n: i } = me(["admin", "translation", "settings"]), { app: o, welcome: d, disclaimer: g, history: c, threadActions: x, composer: N, theme: _, settings: B } = Ne(), [M, A] = p(!1), [F, R] = p(!1), [k, $] = p(""), [H, S] = p(""), [D, K] = p("fa"), [W, P] = p("translation"), [ae, Q] = p("{}"), [h, E] = p(""), [U, f] = p(!1), q = Ce(() => ({
2322
+ function er() {
2323
+ const { t, i18n: i } = ue(["admin", "translation", "settings"]), { app: o, welcome: d, disclaimer: f, history: m, threadActions: b, composer: N, theme: _, settings: B } = Ne(), [M, A] = p(!1), [F, R] = p(!1), [k, $] = p(""), [H, C] = p(""), [D, K] = p("fa"), [W, P] = p("translation"), [ae, Z] = p("{}"), [h, E] = p(""), [U, x] = p(!1), j = Ce(() => ({
2292
2324
  app_name: o?.name || "Gentiq",
2293
2325
  admin_title: o?.adminTitle || "",
2294
2326
  default_theme: _?.defaultTheme || "system",
2295
2327
  default_accent: _?.accent || "oklch(0.623 0.214 259.815)",
2296
2328
  welcome_greeting: typeof d?.greeting == "string" ? d.greeting : "",
2297
2329
  welcome_subtitle: d?.subtitle || "",
2298
- disclaimer: typeof g == "string" ? g : "",
2330
+ disclaimer: typeof f == "string" ? f : "",
2299
2331
  show_tool_details: o?.showToolDetails ?? !0,
2300
2332
  show_settings: o?.showSettings ?? !0,
2301
2333
  show_version_in_settings: o?.showVersionInSettings ?? !0,
2302
2334
  disable_signup: o?.disableSignup ?? !1,
2303
2335
  disable_auth_page: o?.disableAuthPage ?? !1,
2304
2336
  composer_attachments: N?.attachments?.enabled ?? !0,
2305
- thread_actions_feedback: x?.feedback ?? !0,
2306
- thread_actions_retry: x?.retry ?? !0,
2307
- history_enabled: c?.enabled ?? !0,
2308
- history_show_delete: c?.showDelete ?? !0,
2309
- history_show_rename: c?.showRename ?? !0,
2310
- history_show_share: c?.showShare ?? !0,
2311
- history_show_pin: c?.showPin ?? !0,
2337
+ thread_actions_feedback: b?.feedback ?? !0,
2338
+ thread_actions_retry: b?.retry ?? !0,
2339
+ history_enabled: m?.enabled ?? !0,
2340
+ history_show_delete: m?.showDelete ?? !0,
2341
+ history_show_rename: m?.showRename ?? !0,
2342
+ history_show_share: m?.showShare ?? !0,
2343
+ history_show_pin: m?.showPin ?? !0,
2312
2344
  settings_general_mode: o?.settingsGeneralMode || "editable",
2313
2345
  settings_profile_mode: o?.settingsProfileMode || "editable",
2314
2346
  settings_account_mode: o?.settingsAccountMode || "editable",
@@ -2319,52 +2351,52 @@ function Xt() {
2319
2351
  initial_balance_tokens: 25e4,
2320
2352
  initial_balance_requests: 100,
2321
2353
  translations: {}
2322
- }), [o, d, g, c, x, N, _, i.language, B]), [s, u] = p(q), j = i.language === "fa", O = (s.default_accent || "").trim(), C = !O || typeof CSS < "u" && CSS.supports("color", O);
2354
+ }), [o, d, f, m, b, N, _, i.language, B]), [s, u] = p(j), T = i.language === "fa", O = (s.default_accent || "").trim(), q = !O || typeof CSS < "u" && CSS.supports("color", O);
2323
2355
  Y(() => {
2324
2356
  (async () => {
2325
2357
  A(!0);
2326
2358
  try {
2327
- const T = await w.getSettings();
2328
- if (T && Object.keys(T).length > 0) {
2359
+ const L = await w.getSettings();
2360
+ if (L && Object.keys(L).length > 0) {
2329
2361
  const J = JSON.parse(JSON.stringify(i.store.data));
2330
- T.translations && Object.keys(T.translations).forEach((ie) => {
2331
- J[ie] || (J[ie] = {}), Object.assign(J[ie], T.translations[ie]);
2332
- }), u((ie) => ({
2333
- ...ie,
2334
- ...T,
2362
+ L.translations && Object.keys(L.translations).forEach((oe) => {
2363
+ J[oe] || (J[oe] = {}), Object.assign(J[oe], L.translations[oe]);
2364
+ }), u((oe) => ({
2365
+ ...oe,
2366
+ ...L,
2335
2367
  translations: J
2336
2368
  }));
2337
2369
  } else {
2338
- const J = { ...q, translations: i.store.data };
2339
- u(J), T || w.updateSettings(J).catch(console.error);
2370
+ const J = { ...j, translations: i.store.data };
2371
+ u(J), L || w.updateSettings(J).catch(console.error);
2340
2372
  }
2341
- } catch (T) {
2342
- console.error("Failed to fetch settings", T), $(t("app_settings.save_error"));
2373
+ } catch (L) {
2374
+ console.error("Failed to fetch settings", L), $(t("app_settings.save_error"));
2343
2375
  } finally {
2344
2376
  A(!1);
2345
2377
  }
2346
2378
  })();
2347
- }, [t, q, i.store.data]);
2379
+ }, [t, j, i.store.data]);
2348
2380
  const z = async (l) => {
2349
- if (l && l.preventDefault(), !C) {
2381
+ if (l && l.preventDefault(), !q) {
2350
2382
  $(t("app_settings.general.default_accent_invalid"));
2351
2383
  return;
2352
2384
  }
2353
- R(!0), S(""), $("");
2385
+ R(!0), C(""), $("");
2354
2386
  try {
2355
2387
  await w.updateSettings({
2356
2388
  ...s,
2357
2389
  default_accent: O || null
2358
- }), S(t("app_settings.save_success")), setTimeout(() => S(""), 3e3);
2359
- } catch (T) {
2360
- $(T instanceof Error ? T.message : t("app_settings.save_error"));
2390
+ }), C(t("app_settings.save_success")), setTimeout(() => C(""), 3e3);
2391
+ } catch (L) {
2392
+ $(L instanceof Error ? L.message : t("app_settings.save_error"));
2361
2393
  } finally {
2362
2394
  R(!1);
2363
2395
  }
2364
2396
  }, n = async () => {
2365
2397
  A(!0), $("");
2366
2398
  try {
2367
- await w.resetSettings(), f(!1), window.location.reload();
2399
+ await w.resetSettings(), x(!1), window.location.reload();
2368
2400
  } catch (l) {
2369
2401
  $(l instanceof Error ? l.message : t("app_settings.save_error"));
2370
2402
  } finally {
@@ -2373,58 +2405,58 @@ function Xt() {
2373
2405
  };
2374
2406
  Y(() => {
2375
2407
  const l = s.translations?.[D]?.[W] || {};
2376
- Q(JSON.stringify(l, null, 2)), E("");
2408
+ Z(JSON.stringify(l, null, 2)), E("");
2377
2409
  }, [D, W, s.translations]);
2378
- const m = (l) => {
2379
- Q(l);
2410
+ const c = (l) => {
2411
+ Z(l);
2380
2412
  try {
2381
- const T = JSON.parse(l);
2413
+ const L = JSON.parse(l);
2382
2414
  u((J) => ({
2383
2415
  ...J,
2384
2416
  translations: {
2385
2417
  ...J.translations,
2386
2418
  [D]: {
2387
2419
  ...J.translations?.[D],
2388
- [W]: T
2420
+ [W]: L
2389
2421
  }
2390
2422
  }
2391
2423
  })), E("");
2392
2424
  } catch {
2393
2425
  E("Invalid JSON format");
2394
2426
  }
2395
- }, v = ({ title: l, icon: T }) => /* @__PURE__ */ r("div", { className: "relative py-12", children: [
2427
+ }, g = ({ title: l, icon: L }) => /* @__PURE__ */ r("div", { className: "relative py-12", children: [
2396
2428
  /* @__PURE__ */ e("div", { className: "absolute inset-0 flex items-center", "aria-hidden": "true", children: /* @__PURE__ */ e("div", { className: "w-full border-t border-border/60" }) }),
2397
2429
  /* @__PURE__ */ e("div", { className: "relative flex justify-center", children: /* @__PURE__ */ r("span", { className: "bg-background px-6 text-sm font-bold text-muted-foreground uppercase tracking-[0.2em] flex items-center gap-3", children: [
2398
- /* @__PURE__ */ e(T, { className: "size-4 text-primary/60" }),
2430
+ /* @__PURE__ */ e(L, { className: "size-4 text-primary/60" }),
2399
2431
  l
2400
2432
  ] }) })
2401
- ] }), L = ({ value: l }) => {
2433
+ ] }), S = ({ value: l }) => {
2402
2434
  if (!l || !l.includes(":") && !l.includes(".")) return null;
2403
- const T = t(l);
2404
- return T === l ? null : /* @__PURE__ */ r("div", { className: "mt-1.5 px-3 py-1 bg-primary/5 rounded-lg border border-primary/10 inline-flex items-center gap-2", children: [
2435
+ const L = t(l);
2436
+ return L === l ? null : /* @__PURE__ */ r("div", { className: "mt-1.5 px-3 py-1 bg-primary/5 rounded-lg border border-primary/10 inline-flex items-center gap-2", children: [
2405
2437
  /* @__PURE__ */ r("span", { className: "text-[10px] font-bold text-primary/60 uppercase tracking-tighter", children: [
2406
2438
  t("app_settings.preview", { defaultValue: "Preview" }),
2407
2439
  ":"
2408
2440
  ] }),
2409
- /* @__PURE__ */ e("span", { className: "text-[11px] font-medium text-foreground/70", children: T })
2441
+ /* @__PURE__ */ e("span", { className: "text-[11px] font-medium text-foreground/70", children: L })
2410
2442
  ] });
2411
2443
  }, G = () => {
2412
2444
  const l = prompt("Enter language code (e.g. en, fa, fr):");
2413
- l && !s.translations?.[l] && (u((T) => ({
2414
- ...T,
2445
+ l && !s.translations?.[l] && (u((L) => ({
2446
+ ...L,
2415
2447
  translations: {
2416
- ...T.translations,
2448
+ ...L.translations,
2417
2449
  [l]: {}
2418
2450
  }
2419
2451
  })), K(l));
2420
- }, pe = () => {
2452
+ }, ie = () => {
2421
2453
  const l = prompt("Enter namespace (e.g. chat, admin):");
2422
- l && !s.translations?.[D]?.[l] && (u((T) => ({
2423
- ...T,
2454
+ l && !s.translations?.[D]?.[l] && (u((L) => ({
2455
+ ...L,
2424
2456
  translations: {
2425
- ...T.translations,
2457
+ ...L.translations,
2426
2458
  [D]: {
2427
- ...T.translations?.[D],
2459
+ ...L.translations?.[D],
2428
2460
  [l]: {}
2429
2461
  }
2430
2462
  }
@@ -2433,7 +2465,7 @@ function Xt() {
2433
2465
  return M ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center", children: /* @__PURE__ */ r("div", { className: "flex flex-col items-center gap-3", children: [
2434
2466
  /* @__PURE__ */ e("div", { className: "w-10 h-10 border-3 border-primary/20 border-t-primary rounded-full animate-spin" }),
2435
2467
  /* @__PURE__ */ e("span", { className: "text-sm text-muted-foreground font-medium", children: t("loading") })
2436
- ] }) }) : /* @__PURE__ */ r("div", { className: "h-full flex flex-col overflow-hidden", dir: j ? "rtl" : "ltr", children: [
2468
+ ] }) }) : /* @__PURE__ */ r("div", { className: "h-full flex flex-col overflow-hidden", dir: T ? "rtl" : "ltr", children: [
2437
2469
  /* @__PURE__ */ r("div", { className: "px-8 py-6 border-b border-border bg-background/50 backdrop-blur-md z-20 flex items-center justify-between flex-shrink-0", children: [
2438
2470
  /* @__PURE__ */ r("div", { className: "flex flex-col gap-1", children: [
2439
2471
  /* @__PURE__ */ r("div", { className: "flex items-baseline gap-3 flex-wrap", children: [
@@ -2446,25 +2478,25 @@ function Xt() {
2446
2478
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("app_settings.subtitle") })
2447
2479
  ] }),
2448
2480
  /* @__PURE__ */ r("div", { className: "flex items-center gap-4", children: [
2449
- /* @__PURE__ */ r(We, { open: U, onOpenChange: f, children: [
2450
- /* @__PURE__ */ e(ft, { asChild: !0, children: /* @__PURE__ */ r(
2481
+ /* @__PURE__ */ r(Ge, { open: U, onOpenChange: x, children: [
2482
+ /* @__PURE__ */ e(bt, { asChild: !0, children: /* @__PURE__ */ r(
2451
2483
  "button",
2452
2484
  {
2453
2485
  type: "button",
2454
2486
  className: "px-4 py-2 bg-muted/20 text-muted-foreground hover:bg-muted/40 rounded-xl text-xs font-bold transition-all flex items-center gap-2 border border-border/50",
2455
2487
  children: [
2456
- /* @__PURE__ */ e(Pe, { className: "size-3.5" }),
2488
+ /* @__PURE__ */ e(ze, { className: "size-3.5" }),
2457
2489
  t("app_settings.reset_button", { defaultValue: "Reset to Defaults" })
2458
2490
  ]
2459
2491
  }
2460
2492
  ) }),
2461
- /* @__PURE__ */ r(Ge, { children: [
2462
- /* @__PURE__ */ r(Ke, { children: [
2493
+ /* @__PURE__ */ r(Ke, { children: [
2494
+ /* @__PURE__ */ r(Qe, { children: [
2463
2495
  /* @__PURE__ */ e(Ze, { children: t("app_settings.reset_confirm_title") }),
2464
- /* @__PURE__ */ e(Qe, { children: t("app_settings.reset_confirm_description") })
2496
+ /* @__PURE__ */ e(Xe, { children: t("app_settings.reset_confirm_description") })
2465
2497
  ] }),
2466
- /* @__PURE__ */ r(xt, { children: [
2467
- /* @__PURE__ */ e(bt, { asChild: !0, children: /* @__PURE__ */ e(Se, { variant: "ghost", children: t("cancel") }) }),
2498
+ /* @__PURE__ */ r(vt, { children: [
2499
+ /* @__PURE__ */ e(yt, { asChild: !0, children: /* @__PURE__ */ e(Se, { variant: "ghost", children: t("cancel") }) }),
2468
2500
  /* @__PURE__ */ e(Se, { variant: "destructive", onClick: n, children: t("app_settings.reset_button") })
2469
2501
  ] })
2470
2502
  ] })
@@ -2474,7 +2506,7 @@ function Xt() {
2474
2506
  {
2475
2507
  type: "submit",
2476
2508
  form: "settings-form",
2477
- disabled: F || !C,
2509
+ disabled: F || !q,
2478
2510
  className: "px-8 py-2.5 bg-primary text-primary-foreground rounded-xl text-sm font-bold hover:opacity-90 transition-all shadow-md hover:shadow-lg disabled:opacity-50 flex items-center gap-2",
2479
2511
  children: [
2480
2512
  F && /* @__PURE__ */ e("div", { className: "w-4 h-4 border-2 border-primary-foreground/20 border-t-primary-foreground rounded-full animate-spin" }),
@@ -2488,7 +2520,7 @@ function Xt() {
2488
2520
  (k || H) && /* @__PURE__ */ e("div", { className: `mb-12 px-4 py-3 rounded-xl text-sm border animate-in fade-in slide-in-from-top-1 duration-300 ${k ? "bg-destructive/10 border-destructive/20 text-destructive" : "bg-green-500/10 border-green-500/20 text-green-600 dark:text-green-400"}`, children: k || H }),
2489
2521
  /* @__PURE__ */ r("form", { id: "settings-form", onSubmit: z, className: "space-y-16 animate-in fade-in slide-in-from-bottom-2 duration-500", children: [
2490
2522
  /* @__PURE__ */ r("section", { children: [
2491
- /* @__PURE__ */ e(v, { title: t("app_settings.sections.general"), icon: je }),
2523
+ /* @__PURE__ */ e(g, { title: t("app_settings.sections.general"), icon: je }),
2492
2524
  /* @__PURE__ */ r("div", { className: "p-2 space-y-10", children: [
2493
2525
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-10", children: [
2494
2526
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
@@ -2504,7 +2536,7 @@ function Xt() {
2504
2536
  dir: "auto"
2505
2537
  }
2506
2538
  ),
2507
- /* @__PURE__ */ e(L, { value: s.app_name })
2539
+ /* @__PURE__ */ e(S, { value: s.app_name })
2508
2540
  ] }),
2509
2541
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2510
2542
  /* @__PURE__ */ e(X, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.general.admin_title") }),
@@ -2519,33 +2551,33 @@ function Xt() {
2519
2551
  dir: "auto"
2520
2552
  }
2521
2553
  ),
2522
- /* @__PURE__ */ e(L, { value: s.admin_title || "" })
2554
+ /* @__PURE__ */ e(S, { value: s.admin_title || "" })
2523
2555
  ] })
2524
2556
  ] }),
2525
2557
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2526
2558
  /* @__PURE__ */ e(X, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.general.language") }),
2527
2559
  /* @__PURE__ */ r(
2528
- oe,
2560
+ le,
2529
2561
  {
2530
2562
  value: s.language,
2531
2563
  onValueChange: (l) => u({ ...s, language: l }),
2532
2564
  children: [
2533
- /* @__PURE__ */ e(le, { className: "bg-muted/20 border-transparent focus:bg-background h-11 w-full flex-row-reverse justify-end gap-3", children: /* @__PURE__ */ e(de, {}) }),
2534
- /* @__PURE__ */ r(ce, { children: [
2535
- /* @__PURE__ */ e(Z, { value: "fa", children: "فارسی (Persian)" }),
2536
- /* @__PURE__ */ e(Z, { value: "en", children: "English" })
2565
+ /* @__PURE__ */ e(de, { className: "bg-muted/20 border-transparent focus:bg-background h-11 w-full flex-row-reverse justify-end gap-3", children: /* @__PURE__ */ e(ce, {}) }),
2566
+ /* @__PURE__ */ r(me, { children: [
2567
+ /* @__PURE__ */ e(Q, { value: "fa", children: "فارسی (Persian)" }),
2568
+ /* @__PURE__ */ e(Q, { value: "en", children: "English" })
2537
2569
  ] })
2538
2570
  ]
2539
2571
  }
2540
2572
  ),
2541
2573
  /* @__PURE__ */ r("p", { className: "mt-3 text-[10px] text-muted-foreground/50 italic flex items-center gap-1.5 ml-1", children: [
2542
- /* @__PURE__ */ e(Pe, { className: "size-3" }),
2574
+ /* @__PURE__ */ e(ze, { className: "size-3" }),
2543
2575
  t("app_settings.general.language_help")
2544
2576
  ] })
2545
2577
  ] }),
2546
2578
  /* @__PURE__ */ r("div", { className: "space-y-5 rounded-2xl border border-border/50 bg-muted/10 p-5", children: [
2547
2579
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
2548
- /* @__PURE__ */ e(Dt, { className: "size-4 text-primary" }),
2580
+ /* @__PURE__ */ e(Et, { className: "size-4 text-primary" }),
2549
2581
  /* @__PURE__ */ r("div", { children: [
2550
2582
  /* @__PURE__ */ e("h3", { className: "text-sm font-bold text-foreground/80", children: t("app_settings.general.appearance") }),
2551
2583
  /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground", children: t("app_settings.general.appearance_help") })
@@ -2555,16 +2587,16 @@ function Xt() {
2555
2587
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2556
2588
  /* @__PURE__ */ e(X, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.general.default_theme") }),
2557
2589
  /* @__PURE__ */ r(
2558
- oe,
2590
+ le,
2559
2591
  {
2560
2592
  value: s.default_theme || "system",
2561
2593
  onValueChange: (l) => u({ ...s, default_theme: l }),
2562
2594
  children: [
2563
- /* @__PURE__ */ e(le, { className: "bg-muted/20 border-transparent focus:bg-background h-11 w-full", children: /* @__PURE__ */ e(de, {}) }),
2564
- /* @__PURE__ */ r(ce, { children: [
2565
- /* @__PURE__ */ e(Z, { value: "system", children: t("settings:general.themes.system") }),
2566
- /* @__PURE__ */ e(Z, { value: "light", children: t("settings:general.themes.light") }),
2567
- /* @__PURE__ */ e(Z, { value: "dark", children: t("settings:general.themes.dark") })
2595
+ /* @__PURE__ */ e(de, { className: "bg-muted/20 border-transparent focus:bg-background h-11 w-full", children: /* @__PURE__ */ e(ce, {}) }),
2596
+ /* @__PURE__ */ r(me, { children: [
2597
+ /* @__PURE__ */ e(Q, { value: "system", children: t("settings:general.themes.system") }),
2598
+ /* @__PURE__ */ e(Q, { value: "light", children: t("settings:general.themes.light") }),
2599
+ /* @__PURE__ */ e(Q, { value: "dark", children: t("settings:general.themes.dark") })
2568
2600
  ] })
2569
2601
  ]
2570
2602
  }
@@ -2577,7 +2609,7 @@ function Xt() {
2577
2609
  "div",
2578
2610
  {
2579
2611
  className: "size-10 shrink-0 rounded-xl border border-border shadow-sm",
2580
- style: { backgroundColor: C && O ? O : "transparent" },
2612
+ style: { backgroundColor: q && O ? O : "transparent" },
2581
2613
  "aria-label": t("app_settings.general.default_accent_preview")
2582
2614
  }
2583
2615
  ),
@@ -2590,18 +2622,18 @@ function Xt() {
2590
2622
  className: "bg-muted/20 border-transparent focus:bg-background h-11 font-mono",
2591
2623
  placeholder: "oklch(0.623 0.214 259.815)",
2592
2624
  dir: "ltr",
2593
- "aria-invalid": !C
2625
+ "aria-invalid": !q
2594
2626
  }
2595
2627
  )
2596
2628
  ] }),
2597
- /* @__PURE__ */ e("p", { className: `text-[10px] ${C ? "text-muted-foreground/60" : "text-destructive"}`, children: t(C ? "app_settings.general.default_accent_help" : "app_settings.general.default_accent_invalid") })
2629
+ /* @__PURE__ */ e("p", { className: `text-[10px] ${q ? "text-muted-foreground/60" : "text-destructive"}`, children: t(q ? "app_settings.general.default_accent_help" : "app_settings.general.default_accent_invalid") })
2598
2630
  ] })
2599
2631
  ] })
2600
2632
  ] })
2601
2633
  ] })
2602
2634
  ] }),
2603
2635
  /* @__PURE__ */ r("section", { children: [
2604
- /* @__PURE__ */ e(v, { title: t("app_settings.sections.chat"), icon: $t }),
2636
+ /* @__PURE__ */ e(g, { title: t("app_settings.sections.chat"), icon: Ut }),
2605
2637
  /* @__PURE__ */ r("div", { className: "p-2 space-y-10", children: [
2606
2638
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-10", children: [
2607
2639
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
@@ -2617,7 +2649,7 @@ function Xt() {
2617
2649
  dir: "auto"
2618
2650
  }
2619
2651
  ),
2620
- /* @__PURE__ */ e(L, { value: s.welcome_greeting || "" })
2652
+ /* @__PURE__ */ e(S, { value: s.welcome_greeting || "" })
2621
2653
  ] }),
2622
2654
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2623
2655
  /* @__PURE__ */ e(X, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.chat.welcome_subtitle") }),
@@ -2631,13 +2663,13 @@ function Xt() {
2631
2663
  dir: "auto"
2632
2664
  }
2633
2665
  ),
2634
- /* @__PURE__ */ e(L, { value: s.welcome_subtitle || "" })
2666
+ /* @__PURE__ */ e(S, { value: s.welcome_subtitle || "" })
2635
2667
  ] })
2636
2668
  ] }),
2637
2669
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
2638
2670
  /* @__PURE__ */ e(X, { className: "text-xs font-bold uppercase tracking-widest text-muted-foreground/60 ml-1", children: t("app_settings.chat.disclaimer") }),
2639
2671
  /* @__PURE__ */ e(
2640
- Fe,
2672
+ Re,
2641
2673
  {
2642
2674
  value: s.disclaimer || "",
2643
2675
  onChange: (l) => u({ ...s, disclaimer: l.target.value }),
@@ -2645,7 +2677,7 @@ function Xt() {
2645
2677
  dir: "auto"
2646
2678
  }
2647
2679
  ),
2648
- /* @__PURE__ */ e(L, { value: s.disclaimer || "" })
2680
+ /* @__PURE__ */ e(S, { value: s.disclaimer || "" })
2649
2681
  ] }),
2650
2682
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-6 pt-2", children: [
2651
2683
  /* @__PURE__ */ r("div", { className: "p-5 border border-border/40 rounded-2xl flex items-center justify-between hover:bg-muted/5 transition-colors", children: [
@@ -2820,17 +2852,17 @@ function Xt() {
2820
2852
  ].map((l) => /* @__PURE__ */ r("div", { className: "p-4 border border-border/40 rounded-2xl space-y-3 bg-muted/5", children: [
2821
2853
  /* @__PURE__ */ e(X, { className: "text-[10px] font-bold uppercase tracking-wider text-muted-foreground/70", children: t(l.label) }),
2822
2854
  /* @__PURE__ */ r(
2823
- oe,
2855
+ le,
2824
2856
  {
2825
2857
  value: s[l.id],
2826
- onValueChange: (T) => u({ ...s, [l.id]: T }),
2827
- dir: j ? "rtl" : "ltr",
2858
+ onValueChange: (L) => u({ ...s, [l.id]: L }),
2859
+ dir: T ? "rtl" : "ltr",
2828
2860
  children: [
2829
- /* @__PURE__ */ e(le, { className: "bg-background border-transparent h-9 text-xs", children: /* @__PURE__ */ e(de, {}) }),
2830
- /* @__PURE__ */ r(ce, { children: [
2831
- /* @__PURE__ */ e(Z, { value: "editable", children: t("app_settings.chat.mode_editable") }),
2832
- /* @__PURE__ */ e(Z, { value: "faded", children: t("app_settings.chat.mode_faded") }),
2833
- /* @__PURE__ */ e(Z, { value: "hidden", children: t("app_settings.chat.mode_hidden") })
2861
+ /* @__PURE__ */ e(de, { className: "bg-background border-transparent h-9 text-xs", children: /* @__PURE__ */ e(ce, {}) }),
2862
+ /* @__PURE__ */ r(me, { children: [
2863
+ /* @__PURE__ */ e(Q, { value: "editable", children: t("app_settings.chat.mode_editable") }),
2864
+ /* @__PURE__ */ e(Q, { value: "faded", children: t("app_settings.chat.mode_faded") }),
2865
+ /* @__PURE__ */ e(Q, { value: "hidden", children: t("app_settings.chat.mode_hidden") })
2834
2866
  ] })
2835
2867
  ]
2836
2868
  }
@@ -2856,20 +2888,20 @@ function Xt() {
2856
2888
  ].map((l) => /* @__PURE__ */ r("div", { className: "p-3 border border-border/40 rounded-xl space-y-2 bg-muted/5", children: [
2857
2889
  /* @__PURE__ */ e(X, { className: "text-[10px] font-medium text-muted-foreground/70", children: l.label }),
2858
2890
  /* @__PURE__ */ r(
2859
- oe,
2891
+ le,
2860
2892
  {
2861
2893
  value: s.settings_general_fields?.[l.id] || "editable",
2862
- onValueChange: (T) => u((J) => ({
2894
+ onValueChange: (L) => u((J) => ({
2863
2895
  ...J,
2864
- settings_general_fields: { ...J.settings_general_fields, [l.id]: T }
2896
+ settings_general_fields: { ...J.settings_general_fields, [l.id]: L }
2865
2897
  })),
2866
- dir: j ? "rtl" : "ltr",
2898
+ dir: T ? "rtl" : "ltr",
2867
2899
  children: [
2868
- /* @__PURE__ */ e(le, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(de, {}) }),
2869
- /* @__PURE__ */ r(ce, { children: [
2870
- /* @__PURE__ */ e(Z, { value: "editable", className: "text-[10px]", children: t("app_settings.chat.mode_editable") }),
2871
- /* @__PURE__ */ e(Z, { value: "faded", className: "text-[10px]", children: t("app_settings.chat.mode_faded") }),
2872
- /* @__PURE__ */ e(Z, { value: "hidden", className: "text-[10px]", children: t("app_settings.chat.mode_hidden") })
2900
+ /* @__PURE__ */ e(de, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(ce, {}) }),
2901
+ /* @__PURE__ */ r(me, { children: [
2902
+ /* @__PURE__ */ e(Q, { value: "editable", className: "text-[10px]", children: t("app_settings.chat.mode_editable") }),
2903
+ /* @__PURE__ */ e(Q, { value: "faded", className: "text-[10px]", children: t("app_settings.chat.mode_faded") }),
2904
+ /* @__PURE__ */ e(Q, { value: "hidden", className: "text-[10px]", children: t("app_settings.chat.mode_hidden") })
2873
2905
  ] })
2874
2906
  ]
2875
2907
  }
@@ -2890,20 +2922,20 @@ function Xt() {
2890
2922
  ].map((l) => /* @__PURE__ */ r("div", { className: "p-3 border border-border/40 rounded-xl space-y-2 bg-muted/5", children: [
2891
2923
  /* @__PURE__ */ e(X, { className: "text-[10px] font-medium text-muted-foreground/70", children: l.label }),
2892
2924
  /* @__PURE__ */ r(
2893
- oe,
2925
+ le,
2894
2926
  {
2895
2927
  value: s.settings_profile_fields?.[l.id] || "editable",
2896
- onValueChange: (T) => u((J) => ({
2928
+ onValueChange: (L) => u((J) => ({
2897
2929
  ...J,
2898
- settings_profile_fields: { ...J.settings_profile_fields, [l.id]: T }
2930
+ settings_profile_fields: { ...J.settings_profile_fields, [l.id]: L }
2899
2931
  })),
2900
- dir: j ? "rtl" : "ltr",
2932
+ dir: T ? "rtl" : "ltr",
2901
2933
  children: [
2902
- /* @__PURE__ */ e(le, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(de, {}) }),
2903
- /* @__PURE__ */ r(ce, { children: [
2904
- /* @__PURE__ */ e(Z, { value: "editable", className: "text-[10px]", children: t("app_settings.chat.mode_editable") }),
2905
- /* @__PURE__ */ e(Z, { value: "faded", className: "text-[10px]", children: t("app_settings.chat.mode_faded") }),
2906
- /* @__PURE__ */ e(Z, { value: "hidden", className: "text-[10px]", children: t("app_settings.chat.mode_hidden") })
2934
+ /* @__PURE__ */ e(de, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(ce, {}) }),
2935
+ /* @__PURE__ */ r(me, { children: [
2936
+ /* @__PURE__ */ e(Q, { value: "editable", className: "text-[10px]", children: t("app_settings.chat.mode_editable") }),
2937
+ /* @__PURE__ */ e(Q, { value: "faded", className: "text-[10px]", children: t("app_settings.chat.mode_faded") }),
2938
+ /* @__PURE__ */ e(Q, { value: "hidden", className: "text-[10px]", children: t("app_settings.chat.mode_hidden") })
2907
2939
  ] })
2908
2940
  ]
2909
2941
  }
@@ -2921,20 +2953,20 @@ function Xt() {
2921
2953
  ].map((l) => /* @__PURE__ */ r("div", { className: "p-3 border border-border/40 rounded-xl space-y-2 bg-muted/5", children: [
2922
2954
  /* @__PURE__ */ e(X, { className: "text-[10px] font-medium text-muted-foreground/70", children: l.label }),
2923
2955
  /* @__PURE__ */ r(
2924
- oe,
2956
+ le,
2925
2957
  {
2926
2958
  value: s.settings_account_fields?.[l.id] || "editable",
2927
- onValueChange: (T) => u((J) => ({
2959
+ onValueChange: (L) => u((J) => ({
2928
2960
  ...J,
2929
- settings_account_fields: { ...J.settings_account_fields, [l.id]: T }
2961
+ settings_account_fields: { ...J.settings_account_fields, [l.id]: L }
2930
2962
  })),
2931
- dir: j ? "rtl" : "ltr",
2963
+ dir: T ? "rtl" : "ltr",
2932
2964
  children: [
2933
- /* @__PURE__ */ e(le, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(de, {}) }),
2934
- /* @__PURE__ */ r(ce, { children: [
2935
- /* @__PURE__ */ e(Z, { value: "editable", className: "text-[10px]", children: t("app_settings.chat.mode_editable") }),
2936
- /* @__PURE__ */ e(Z, { value: "faded", className: "text-[10px]", children: t("app_settings.chat.mode_faded") }),
2937
- /* @__PURE__ */ e(Z, { value: "hidden", className: "text-[10px]", children: t("app_settings.chat.mode_hidden") })
2965
+ /* @__PURE__ */ e(de, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(ce, {}) }),
2966
+ /* @__PURE__ */ r(me, { children: [
2967
+ /* @__PURE__ */ e(Q, { value: "editable", className: "text-[10px]", children: t("app_settings.chat.mode_editable") }),
2968
+ /* @__PURE__ */ e(Q, { value: "faded", className: "text-[10px]", children: t("app_settings.chat.mode_faded") }),
2969
+ /* @__PURE__ */ e(Q, { value: "hidden", className: "text-[10px]", children: t("app_settings.chat.mode_hidden") })
2938
2970
  ] })
2939
2971
  ]
2940
2972
  }
@@ -2946,7 +2978,7 @@ function Xt() {
2946
2978
  ] })
2947
2979
  ] }),
2948
2980
  /* @__PURE__ */ r("section", { children: [
2949
- /* @__PURE__ */ e(v, { title: t("app_settings.sections.user_billing"), icon: Et }),
2981
+ /* @__PURE__ */ e(g, { title: t("app_settings.sections.user_billing"), icon: Ot }),
2950
2982
  /* @__PURE__ */ r("div", { className: "p-2 space-y-10", children: [
2951
2983
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-10", children: [
2952
2984
  /* @__PURE__ */ r("div", { className: "space-y-2", children: [
@@ -2980,36 +3012,36 @@ function Xt() {
2980
3012
  ] })
2981
3013
  ] }),
2982
3014
  /* @__PURE__ */ r("section", { children: [
2983
- /* @__PURE__ */ e(v, { title: t("app_settings.translations_management"), icon: Ut }),
3015
+ /* @__PURE__ */ e(g, { title: t("app_settings.translations_management"), icon: Ft }),
2984
3016
  /* @__PURE__ */ r("div", { className: "border border-border/60 rounded-2xl overflow-hidden bg-background", children: [
2985
3017
  /* @__PURE__ */ r("div", { className: "p-6 border-b border-border/50 bg-muted/5 flex flex-col sm:flex-row items-center gap-4", children: [
2986
3018
  /* @__PURE__ */ r("div", { className: "flex-1 flex items-center gap-4 p-1.5 bg-background border border-border/60 rounded-xl w-full", children: [
2987
3019
  /* @__PURE__ */ e("div", { className: "p-2 px-3 bg-muted/20 rounded-lg border border-border/40 ml-1", children: /* @__PURE__ */ e(je, { className: "size-4 text-muted-foreground" }) }),
2988
- /* @__PURE__ */ r(oe, { value: D, onValueChange: K, children: [
2989
- /* @__PURE__ */ e(le, { size: "sm", className: "border-none shadow-none bg-transparent h-8 font-black uppercase tracking-wider", children: /* @__PURE__ */ e(de, {}) }),
2990
- /* @__PURE__ */ e(ce, { children: Object.keys(s.translations || {}).sort().map((l) => /* @__PURE__ */ e(Z, { value: l, children: l.toUpperCase() }, l)) })
3020
+ /* @__PURE__ */ r(le, { value: D, onValueChange: K, children: [
3021
+ /* @__PURE__ */ e(de, { size: "sm", className: "border-none shadow-none bg-transparent h-8 font-black uppercase tracking-wider", children: /* @__PURE__ */ e(ce, {}) }),
3022
+ /* @__PURE__ */ e(me, { children: Object.keys(s.translations || {}).sort().map((l) => /* @__PURE__ */ e(Q, { value: l, children: l.toUpperCase() }, l)) })
2991
3023
  ] }),
2992
3024
  /* @__PURE__ */ e("div", { className: "w-px h-6 bg-border/60" }),
2993
- /* @__PURE__ */ r(oe, { value: W, onValueChange: P, children: [
2994
- /* @__PURE__ */ e(le, { size: "sm", className: "border-none shadow-none bg-transparent h-8 flex-1 font-bold", children: /* @__PURE__ */ e(de, {}) }),
2995
- /* @__PURE__ */ e(ce, { children: Object.keys(s.translations?.[D] || {}).sort().map((l) => /* @__PURE__ */ e(Z, { value: l, children: l }, l)) })
3025
+ /* @__PURE__ */ r(le, { value: W, onValueChange: P, children: [
3026
+ /* @__PURE__ */ e(de, { size: "sm", className: "border-none shadow-none bg-transparent h-8 flex-1 font-bold", children: /* @__PURE__ */ e(ce, {}) }),
3027
+ /* @__PURE__ */ e(me, { children: Object.keys(s.translations?.[D] || {}).sort().map((l) => /* @__PURE__ */ e(Q, { value: l, children: l }, l)) })
2996
3028
  ] })
2997
3029
  ] }),
2998
3030
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
2999
- /* @__PURE__ */ e("button", { type: "button", onClick: G, title: "Add Language", className: "p-2.5 hover:bg-muted/30 rounded-xl transition-all border border-border/40", children: /* @__PURE__ */ e(Ot, { className: "size-4" }) }),
3000
- /* @__PURE__ */ e("button", { type: "button", onClick: pe, title: "Add Namespace", className: "p-2.5 hover:bg-muted/30 rounded-xl transition-all border border-border/40", children: /* @__PURE__ */ e(je, { className: "size-4" }) })
3031
+ /* @__PURE__ */ e("button", { type: "button", onClick: G, title: "Add Language", className: "p-2.5 hover:bg-muted/30 rounded-xl transition-all border border-border/40", children: /* @__PURE__ */ e(Rt, { className: "size-4" }) }),
3032
+ /* @__PURE__ */ e("button", { type: "button", onClick: ie, title: "Add Namespace", className: "p-2.5 hover:bg-muted/30 rounded-xl transition-all border border-border/40", children: /* @__PURE__ */ e(je, { className: "size-4" }) })
3001
3033
  ] })
3002
3034
  ] }),
3003
3035
  /* @__PURE__ */ r("div", { className: "relative p-6", children: [
3004
3036
  /* @__PURE__ */ r("div", { className: "absolute top-8 right-10 flex items-center gap-2", children: [
3005
3037
  /* @__PURE__ */ e("span", { className: "text-[10px] font-bold text-muted-foreground/40 uppercase tracking-widest", children: "JSON EDITOR" }),
3006
- /* @__PURE__ */ e(Ft, { className: "size-3 text-muted-foreground/30" })
3038
+ /* @__PURE__ */ e(Pt, { className: "size-3 text-muted-foreground/30" })
3007
3039
  ] }),
3008
3040
  /* @__PURE__ */ e(
3009
- Fe,
3041
+ Re,
3010
3042
  {
3011
3043
  value: ae,
3012
- onChange: (l) => m(l.target.value),
3044
+ onChange: (l) => c(l.target.value),
3013
3045
  dir: "ltr",
3014
3046
  className: `w-full min-h-[500px] bg-muted/5 font-mono text-[13px] p-8 rounded-xl border focus:ring-1 focus:outline-none leading-relaxed resize-y text-left ${h ? "border-destructive/40 focus:ring-destructive/20" : "border-border/40 focus:ring-primary/20"}`,
3015
3047
  spellCheck: !1
@@ -3031,30 +3063,30 @@ function Xt() {
3031
3063
  ] });
3032
3064
  }
3033
3065
  function _e() {
3034
- const { t, i18n: i } = me(["admin"]), o = i.language === "fa";
3066
+ const { t, i18n: i } = ue(["admin"]), o = i.language === "fa";
3035
3067
  return /* @__PURE__ */ r("div", { className: "h-full flex flex-col items-center justify-center p-6 text-center gap-4 animate-in fade-in duration-500", dir: o ? "rtl" : "ltr", children: [
3036
- /* @__PURE__ */ e("div", { className: "bg-destructive/10 p-4 rounded-2xl border border-destructive/20 relative", children: /* @__PURE__ */ e(Rt, { className: "size-10 text-destructive/70" }) }),
3068
+ /* @__PURE__ */ e("div", { className: "bg-destructive/10 p-4 rounded-2xl border border-destructive/20 relative", children: /* @__PURE__ */ e(zt, { className: "size-10 text-destructive/70" }) }),
3037
3069
  /* @__PURE__ */ r("div", { className: "space-y-1 max-w-sm", children: [
3038
3070
  /* @__PURE__ */ e("h3", { className: "text-lg font-bold text-foreground tracking-tight", children: t("errors.access_denied_title", "Access Denied") }),
3039
3071
  /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground leading-relaxed", children: t("errors.access_denied_message", "You don't have permission to access this page.") })
3040
3072
  ] })
3041
3073
  ] });
3042
3074
  }
3043
- const Yt = ({ className: t }) => {
3044
- const { t: i } = me(["theme"]), { theme: o, setTheme: d } = De(), g = () => {
3075
+ const tr = ({ className: t }) => {
3076
+ const { t: i } = ue(["theme"]), { theme: o, setTheme: d } = De(), f = () => {
3045
3077
  d(o === "system" ? "light" : o === "light" ? "dark" : "system");
3046
- }, c = () => {
3078
+ }, m = () => {
3047
3079
  switch (o) {
3048
3080
  case "light":
3049
- return /* @__PURE__ */ e(zt, { className: "h-[1.2rem] w-[1.2rem]" });
3081
+ return /* @__PURE__ */ e(Vt, { className: "h-[1.2rem] w-[1.2rem]" });
3050
3082
  case "dark":
3051
- return /* @__PURE__ */ e(Pt, { className: "h-[1.2rem] w-[1.2rem]" });
3083
+ return /* @__PURE__ */ e(Jt, { className: "h-[1.2rem] w-[1.2rem]" });
3052
3084
  case "system":
3053
- return /* @__PURE__ */ e(ze, { className: "h-[1.2rem] w-[1.2rem]" });
3085
+ return /* @__PURE__ */ e(Je, { className: "h-[1.2rem] w-[1.2rem]" });
3054
3086
  default:
3055
- return /* @__PURE__ */ e(ze, { className: "h-[1.2rem] w-[1.2rem]" });
3087
+ return /* @__PURE__ */ e(Je, { className: "h-[1.2rem] w-[1.2rem]" });
3056
3088
  }
3057
- }, x = () => {
3089
+ }, b = () => {
3058
3090
  switch (o) {
3059
3091
  case "light":
3060
3092
  return i("dark");
@@ -3067,15 +3099,15 @@ const Yt = ({ className: t }) => {
3067
3099
  }
3068
3100
  };
3069
3101
  return /* @__PURE__ */ r(Ae, { children: [
3070
- /* @__PURE__ */ e(Ie, { asChild: !0, children: /* @__PURE__ */ r(Se, { variant: "ghost", size: "icon", onClick: g, className: t, children: [
3071
- c(),
3102
+ /* @__PURE__ */ e(Ie, { asChild: !0, children: /* @__PURE__ */ r(Se, { variant: "ghost", size: "icon", onClick: f, className: t, children: [
3103
+ m(),
3072
3104
  /* @__PURE__ */ e("span", { className: "sr-only", children: i("toggle") })
3073
3105
  ] }) }),
3074
- /* @__PURE__ */ e(Me, { children: x() })
3106
+ /* @__PURE__ */ e(Me, { children: b() })
3075
3107
  ] });
3076
3108
  };
3077
- function er({ extraPages: t = [], disabledPages: i = [] }) {
3078
- const o = Ct(), d = Lt(), { t: g, i18n: c } = me(["admin", "settings", "translation"]), { app: x } = Ne(), { theme: N } = De(), [_, B] = p([]), [M, A] = p(!1), F = Le(!1), [R, k] = p("light");
3109
+ function rr({ extraPages: t = [], disabledPages: i = [] }) {
3110
+ const o = qt(), d = jt(), { t: f, i18n: m } = ue(["admin", "settings", "translation"]), { app: b } = Ne(), { theme: N } = De(), [_, B] = p([]), [M, A] = p(!1), F = Le(!1), [R, k] = p("light");
3079
3111
  Y(() => {
3080
3112
  if (N === "system") {
3081
3113
  const h = window.matchMedia("(prefers-color-scheme: dark)").matches;
@@ -3083,7 +3115,7 @@ function er({ extraPages: t = [], disabledPages: i = [] }) {
3083
3115
  } else
3084
3116
  k(N);
3085
3117
  }, [N]);
3086
- const $ = Ce(() => x?.logo ? typeof x.logo == "string" ? x.logo : R === "dark" ? x.logo.dark : x.logo.light : He, [x?.logo, R]), H = x?.adminTitle || x?.name, S = c.language === "fa";
3118
+ const $ = Ce(() => b?.logo ? typeof b.logo == "string" ? b.logo : R === "dark" ? b.logo.dark : b.logo.light : We, [b?.logo, R]), H = b?.adminTitle || b?.name, C = m.language === "fa";
3087
3119
  Y(() => {
3088
3120
  const h = localStorage.getItem("admin_info");
3089
3121
  if (h)
@@ -3101,8 +3133,8 @@ function er({ extraPages: t = [], disabledPages: i = [] }) {
3101
3133
  else if (U.includes("settings") && !i.includes("settings"))
3102
3134
  o("/admin/settings", { replace: !0 });
3103
3135
  else {
3104
- const f = t.find((q) => !q.permission || U.includes(q.permission));
3105
- f && o(`/admin/${f.path}`, { replace: !0 });
3136
+ const x = t.find((j) => !j.permission || U.includes(j.permission));
3137
+ x && o(`/admin/${x.path}`, { replace: !0 });
3106
3138
  }
3107
3139
  } catch (E) {
3108
3140
  console.error("Failed to parse admin_info", E);
@@ -3112,10 +3144,10 @@ function er({ extraPages: t = [], disabledPages: i = [] }) {
3112
3144
  }, [o, d.pathname]);
3113
3145
  const D = () => {
3114
3146
  w.clearToken(), window.location.reload();
3115
- }, K = (h) => _.includes(h), W = (h) => _.includes(h) && !i.includes(h), P = Object.keys(c.services?.resourceStore?.data || {}).filter((h) => h !== "dev"), ae = P.length > 0 ? P : ["en", "fa"], Q = (h) => {
3116
- localStorage.setItem("gentiq-admin-language", h), c.changeLanguage(h), A(!1), document.activeElement instanceof HTMLElement && document.activeElement.blur();
3147
+ }, K = (h) => _.includes(h), W = (h) => _.includes(h) && !i.includes(h), P = Object.keys(m.services?.resourceStore?.data || {}).filter((h) => h !== "dev"), ae = P.length > 0 ? P : ["en", "fa"], Z = (h) => {
3148
+ localStorage.setItem("gentiq-admin-language", h), m.changeLanguage(h), A(!1), document.activeElement instanceof HTMLElement && document.activeElement.blur();
3117
3149
  };
3118
- return /* @__PURE__ */ r("div", { className: "min-h-screen bg-background overflow-hidden flex flex-col", dir: S ? "rtl" : "ltr", children: [
3150
+ return /* @__PURE__ */ r("div", { className: "min-h-screen bg-background overflow-hidden flex flex-col", dir: C ? "rtl" : "ltr", children: [
3119
3151
  /* @__PURE__ */ e("header", { className: "glass border-b border-border sticky top-0 z-50", children: /* @__PURE__ */ e("div", { className: "px-8", children: /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-stretch justify-between min-h-[72px] gap-y-4", children: [
3120
3152
  /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-stretch gap-x-12", children: [
3121
3153
  /* @__PURE__ */ r("div", { className: "flex items-center gap-3 py-4 md:py-0", children: [
@@ -3128,7 +3160,7 @@ function er({ extraPages: t = [], disabledPages: i = [] }) {
3128
3160
  {
3129
3161
  onClick: () => o("/admin/analytics"),
3130
3162
  className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${d.pathname === "/admin/analytics" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
3131
- children: g("dashboard.tabs.analytics")
3163
+ children: f("dashboard.tabs.analytics")
3132
3164
  }
3133
3165
  ),
3134
3166
  !i.includes("chat_history") && /* @__PURE__ */ e(
@@ -3136,7 +3168,7 @@ function er({ extraPages: t = [], disabledPages: i = [] }) {
3136
3168
  {
3137
3169
  onClick: () => o("/admin/chat-history"),
3138
3170
  className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${d.pathname === "/admin/chat-history" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
3139
- children: g("dashboard.tabs.chat_history")
3171
+ children: f("dashboard.tabs.chat_history")
3140
3172
  }
3141
3173
  ),
3142
3174
  !i.includes("user_management") && /* @__PURE__ */ e(
@@ -3144,7 +3176,7 @@ function er({ extraPages: t = [], disabledPages: i = [] }) {
3144
3176
  {
3145
3177
  onClick: () => o("/admin/users"),
3146
3178
  className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${d.pathname === "/admin/users" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
3147
- children: g("dashboard.tabs.users")
3179
+ children: f("dashboard.tabs.users")
3148
3180
  }
3149
3181
  ),
3150
3182
  !i.includes("admin_management") && /* @__PURE__ */ e(
@@ -3152,7 +3184,7 @@ function er({ extraPages: t = [], disabledPages: i = [] }) {
3152
3184
  {
3153
3185
  onClick: () => o("/admin/admins"),
3154
3186
  className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${d.pathname === "/admin/admins" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
3155
- children: g("dashboard.tabs.admins")
3187
+ children: f("dashboard.tabs.admins")
3156
3188
  }
3157
3189
  ),
3158
3190
  !i.includes("settings") && /* @__PURE__ */ e(
@@ -3160,7 +3192,7 @@ function er({ extraPages: t = [], disabledPages: i = [] }) {
3160
3192
  {
3161
3193
  onClick: () => o("/admin/settings"),
3162
3194
  className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${d.pathname === "/admin/settings" ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
3163
- children: g("dashboard.tabs.settings")
3195
+ children: f("dashboard.tabs.settings")
3164
3196
  }
3165
3197
  ),
3166
3198
  t.map((h) => /* @__PURE__ */ e(
@@ -3168,14 +3200,14 @@ function er({ extraPages: t = [], disabledPages: i = [] }) {
3168
3200
  {
3169
3201
  onClick: () => o(`/admin/${h.path}`),
3170
3202
  className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${d.pathname === `/admin/${h.path}` ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
3171
- children: typeof h.label == "string" ? g(h.label) : h.label
3203
+ children: typeof h.label == "string" ? f(h.label) : h.label
3172
3204
  },
3173
3205
  `tab-${h.path}`
3174
3206
  ))
3175
3207
  ] })
3176
3208
  ] }),
3177
3209
  /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5 py-4 md:py-0", children: [
3178
- /* @__PURE__ */ r(vt, { onOpenChange: (h) => {
3210
+ /* @__PURE__ */ r(_t, { onOpenChange: (h) => {
3179
3211
  h ? A(!1) : (F.current = !0, setTimeout(() => {
3180
3212
  F.current = !1;
3181
3213
  }, 200));
@@ -3188,31 +3220,31 @@ function er({ extraPages: t = [], disabledPages: i = [] }) {
3188
3220
  h && F.current || A(h);
3189
3221
  },
3190
3222
  children: [
3191
- /* @__PURE__ */ e(Ie, { asChild: !0, children: /* @__PURE__ */ e(yt, { asChild: !0, children: /* @__PURE__ */ e(
3223
+ /* @__PURE__ */ e(Ie, { asChild: !0, children: /* @__PURE__ */ e(Nt, { asChild: !0, children: /* @__PURE__ */ e(
3192
3224
  Se,
3193
3225
  {
3194
3226
  variant: "ghost",
3195
3227
  size: "icon",
3196
3228
  className: "font-bold text-xs text-muted-foreground hover:bg-muted",
3197
3229
  onPointerDown: () => A(!1),
3198
- children: (c.language?.split("-")[0] || "").toUpperCase()
3230
+ children: (m.language?.split("-")[0] || "").toUpperCase()
3199
3231
  }
3200
3232
  ) }) }),
3201
- /* @__PURE__ */ e(Me, { side: "bottom", className: "text-xs", children: g("dashboard.language", "Change Language") })
3233
+ /* @__PURE__ */ e(Me, { side: "bottom", className: "text-xs", children: f("dashboard.language", "Change Language") })
3202
3234
  ]
3203
3235
  }
3204
3236
  ),
3205
- /* @__PURE__ */ e(_t, { align: "center", className: "min-w-[8rem]", children: ae.map((h) => /* @__PURE__ */ e(
3206
- Nt,
3237
+ /* @__PURE__ */ e(wt, { align: "center", className: "min-w-[8rem]", children: ae.map((h) => /* @__PURE__ */ e(
3238
+ kt,
3207
3239
  {
3208
- onClick: () => Q(h),
3209
- className: h === c.language ? "bg-primary/10" : "",
3210
- children: g(`general.languages.${h}`, h.toUpperCase())
3240
+ onClick: () => Z(h),
3241
+ className: h === m.language ? "bg-primary/10" : "",
3242
+ children: f(`general.languages.${h}`, h.toUpperCase())
3211
3243
  },
3212
3244
  h
3213
3245
  )) })
3214
3246
  ] }),
3215
- /* @__PURE__ */ e(Yt, { className: "size-9 !bg-transparent hover:bg-muted text-muted-foreground" }),
3247
+ /* @__PURE__ */ e(tr, { className: "size-9 !bg-transparent hover:bg-muted text-muted-foreground" }),
3216
3248
  /* @__PURE__ */ e("div", { className: "w-px h-5 bg-border mx-1" }),
3217
3249
  /* @__PURE__ */ r(Ae, { children: [
3218
3250
  /* @__PURE__ */ e(Ie, { asChild: !0, children: /* @__PURE__ */ e(
@@ -3222,20 +3254,20 @@ function er({ extraPages: t = [], disabledPages: i = [] }) {
3222
3254
  size: "icon",
3223
3255
  className: "hover:bg-destructive/10 hover:scale-105 active:scale-95 text-muted-foreground hover:text-destructive",
3224
3256
  onClick: D,
3225
- children: /* @__PURE__ */ e(Jt, { className: "size-5" })
3257
+ children: /* @__PURE__ */ e(Bt, { className: "size-5" })
3226
3258
  }
3227
3259
  ) }),
3228
- /* @__PURE__ */ e(Me, { side: "bottom", className: "text-xs", children: g("dashboard.logout") })
3260
+ /* @__PURE__ */ e(Me, { side: "bottom", className: "text-xs", children: f("dashboard.logout") })
3229
3261
  ] })
3230
3262
  ] })
3231
3263
  ] }) }) }),
3232
- /* @__PURE__ */ e("main", { className: "flex-1 overflow-hidden relative", children: /* @__PURE__ */ e("div", { className: "absolute inset-0 overflow-hidden", children: /* @__PURE__ */ r(qt, { children: [
3233
- /* @__PURE__ */ e(ge, { path: "/", element: /* @__PURE__ */ e(Re, { to: "/admin/analytics", replace: !0 }) }),
3234
- /* @__PURE__ */ e(ge, { path: "/analytics", element: W("analytics") ? /* @__PURE__ */ e(Qt, {}) : /* @__PURE__ */ e(_e, {}) }),
3235
- /* @__PURE__ */ e(ge, { path: "/chat-history", element: W("chat_history") ? /* @__PURE__ */ e(Ht, {}) : /* @__PURE__ */ e(_e, {}) }),
3236
- /* @__PURE__ */ e(ge, { path: "/admins", element: W("admin_management") ? /* @__PURE__ */ e(Wt, {}) : /* @__PURE__ */ e(_e, {}) }),
3237
- /* @__PURE__ */ e(ge, { path: "/settings", element: W("settings") ? /* @__PURE__ */ e(Xt, {}) : /* @__PURE__ */ e(_e, {}) }),
3238
- /* @__PURE__ */ e(ge, { path: "/users", element: W("user_management") ? /* @__PURE__ */ e(Zt, {}) : /* @__PURE__ */ e(_e, {}) }),
3264
+ /* @__PURE__ */ e("main", { className: "flex-1 overflow-hidden relative", children: /* @__PURE__ */ e("div", { className: "absolute inset-0 overflow-hidden", children: /* @__PURE__ */ r(Tt, { children: [
3265
+ /* @__PURE__ */ e(ge, { path: "/", element: /* @__PURE__ */ e(Pe, { to: "/admin/analytics", replace: !0 }) }),
3266
+ /* @__PURE__ */ e(ge, { path: "/analytics", element: W("analytics") ? /* @__PURE__ */ e(Yt, {}) : /* @__PURE__ */ e(_e, {}) }),
3267
+ /* @__PURE__ */ e(ge, { path: "/chat-history", element: W("chat_history") ? /* @__PURE__ */ e(Gt, {}) : /* @__PURE__ */ e(_e, {}) }),
3268
+ /* @__PURE__ */ e(ge, { path: "/admins", element: W("admin_management") ? /* @__PURE__ */ e(Kt, {}) : /* @__PURE__ */ e(_e, {}) }),
3269
+ /* @__PURE__ */ e(ge, { path: "/settings", element: W("settings") ? /* @__PURE__ */ e(er, {}) : /* @__PURE__ */ e(_e, {}) }),
3270
+ /* @__PURE__ */ e(ge, { path: "/users", element: W("user_management") ? /* @__PURE__ */ e(Xt, {}) : /* @__PURE__ */ e(_e, {}) }),
3239
3271
  t.map((h) => /* @__PURE__ */ e(
3240
3272
  ge,
3241
3273
  {
@@ -3244,15 +3276,15 @@ function er({ extraPages: t = [], disabledPages: i = [] }) {
3244
3276
  },
3245
3277
  `route-${h.path}`
3246
3278
  )),
3247
- /* @__PURE__ */ e(ge, { path: "*", element: /* @__PURE__ */ e(Re, { to: "/admin/analytics", replace: !0 }) })
3279
+ /* @__PURE__ */ e(ge, { path: "*", element: /* @__PURE__ */ e(Pe, { to: "/admin/analytics", replace: !0 }) })
3248
3280
  ] }) }) })
3249
3281
  ] });
3250
3282
  }
3251
- function mr(t) {
3283
+ function hr(t) {
3252
3284
  const i = Ce(() => {
3253
- const o = ut.createInstance();
3254
- return o.use(wt).use(ht).init({
3255
- resources: kt,
3285
+ const o = ht.createInstance();
3286
+ return o.use(St).use(pt).init({
3287
+ resources: Ct,
3256
3288
  fallbackLng: "en",
3257
3289
  interpolation: { escapeValue: !1 },
3258
3290
  detection: {
@@ -3262,114 +3294,114 @@ function mr(t) {
3262
3294
  }
3263
3295
  }), o;
3264
3296
  }, []);
3265
- return /* @__PURE__ */ e(pt, { i18n: i, children: /* @__PURE__ */ e(tr, { ...t }) });
3297
+ return /* @__PURE__ */ e(gt, { i18n: i, children: /* @__PURE__ */ e(ar, { ...t }) });
3266
3298
  }
3267
- function tr({ extraPages: t, disabledPages: i = [] }) {
3268
- const { app: o, i18n: d } = Ne(), { t: g, i18n: c } = me(["admin", "translation"]), [x, N] = p(!1), [_, B] = p(!0), [M, A] = p(!1);
3299
+ function ar({ extraPages: t, disabledPages: i = [] }) {
3300
+ const { app: o, i18n: d } = Ne(), { t: f, i18n: m } = ue(["admin", "translation"]), [b, N] = p(!1), [_, B] = p(!0), [M, A] = p(!1);
3269
3301
  Y(() => {
3270
3302
  d?.resources && Object.entries(d.resources).forEach(([k, $]) => {
3271
- Object.entries($).forEach(([H, S]) => {
3272
- c.addResourceBundle(k, H, S, !0, !0);
3303
+ Object.entries($).forEach(([H, C]) => {
3304
+ m.addResourceBundle(k, H, C, !0, !0);
3273
3305
  });
3274
- }), !localStorage.getItem("gentiq-admin-language") && o?.language && c.language !== o.language && c.changeLanguage(o.language), A(!0);
3275
- }, [d?.resources, c, o?.language]), Y(() => {
3306
+ }), !localStorage.getItem("gentiq-admin-language") && o?.language && m.language !== o.language && m.changeLanguage(o.language), A(!0);
3307
+ }, [d?.resources, m, o?.language]), Y(() => {
3276
3308
  const R = w.getToken();
3277
3309
  return N(!!R), B(!1), document.body.classList.add("admin-theme-root"), () => {
3278
3310
  document.body.classList.remove("admin-theme-root");
3279
3311
  };
3280
3312
  }, []), Y(() => {
3281
- M && (document.documentElement.dir = c.language === "fa" ? "rtl" : "ltr", document.documentElement.lang = c.language);
3282
- }, [M, c.language]);
3313
+ M && (document.documentElement.dir = m.language === "fa" ? "rtl" : "ltr", document.documentElement.lang = m.language);
3314
+ }, [M, m.language]);
3283
3315
  const F = () => {
3284
3316
  N(!0);
3285
3317
  };
3286
- return _ || !M ? /* @__PURE__ */ e("div", { className: "min-h-screen bg-background flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "text-muted-foreground", children: g("loading") }) }) : /* @__PURE__ */ e(St, { storageKey: "gentiq-admin-theme", children: x ? /* @__PURE__ */ e(er, { extraPages: t, disabledPages: i }) : /* @__PURE__ */ e(Bt, { onLoginSuccess: F }) });
3318
+ return _ || !M ? /* @__PURE__ */ e("div", { className: "min-h-screen bg-background flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "text-muted-foreground", children: f("loading") }) }) : /* @__PURE__ */ e(Lt, { storageKey: "gentiq-admin-theme", children: b ? /* @__PURE__ */ e(rr, { extraPages: t, disabledPages: i }) : /* @__PURE__ */ e(Wt, { onLoginSuccess: F }) });
3287
3319
  }
3288
- const he = "gentiq_admin";
3289
- function ur(t = 0, i = 100, o = "") {
3320
+ const pe = "gentiq_admin";
3321
+ function pr(t = 0, i = 100, o = "") {
3290
3322
  return we({
3291
- queryKey: [he, "users", t, i, o],
3323
+ queryKey: [pe, "users", t, i, o],
3292
3324
  queryFn: () => w.listUsers(t, i, o)
3293
3325
  });
3294
3326
  }
3295
- function hr() {
3327
+ function gr() {
3296
3328
  const t = $e(), i = () => {
3297
- t.invalidateQueries({ queryKey: [he, "users"] });
3298
- }, o = ue({
3329
+ t.invalidateQueries({ queryKey: [pe, "users"] });
3330
+ }, o = he({
3299
3331
  mutationFn: (N) => w.createUser(N.phone, N.name, N.surname, N.tokens, N.requests),
3300
3332
  onSuccess: i
3301
- }), d = ue({
3333
+ }), d = he({
3302
3334
  mutationFn: ({ userId: N, data: _ }) => w.updateUser(N, _),
3303
3335
  onSuccess: i
3304
- }), g = ue({
3336
+ }), f = he({
3305
3337
  mutationFn: (N) => w.deleteUser(N),
3306
3338
  onSuccess: i
3307
- }), c = ue({
3339
+ }), m = he({
3308
3340
  mutationFn: ({ userId: N, tokens: _, requests: B }) => w.updateUserBalance(N, _, B),
3309
3341
  onSuccess: i
3310
- }), x = ue({
3342
+ }), b = he({
3311
3343
  mutationFn: (N) => w.refreshUserToken(N)
3312
3344
  });
3313
- return { createUser: o, updateUser: d, deleteUser: g, updateBalance: c, refreshToken: x };
3345
+ return { createUser: o, updateUser: d, deleteUser: f, updateBalance: m, refreshToken: b };
3314
3346
  }
3315
- function pr(t = 30) {
3347
+ function fr(t = 30) {
3316
3348
  return we({
3317
- queryKey: [he, "analytics", t],
3349
+ queryKey: [pe, "analytics", t],
3318
3350
  queryFn: () => w.getAnalytics(t)
3319
3351
  });
3320
3352
  }
3321
- function gr() {
3353
+ function xr() {
3322
3354
  return we({
3323
- queryKey: [he, "admins"],
3355
+ queryKey: [pe, "admins"],
3324
3356
  queryFn: () => w.listAdmins()
3325
3357
  });
3326
3358
  }
3327
- function fr() {
3359
+ function br() {
3328
3360
  const t = $e(), i = () => {
3329
- t.invalidateQueries({ queryKey: [he, "admins"] });
3330
- }, o = ue({
3331
- mutationFn: (c) => w.register(c.username, c.password, c.name, c.permissions),
3361
+ t.invalidateQueries({ queryKey: [pe, "admins"] });
3362
+ }, o = he({
3363
+ mutationFn: (m) => w.register(m.username, m.password, m.name, m.permissions),
3332
3364
  onSuccess: i
3333
- }), d = ue({
3334
- mutationFn: ({ adminId: c, data: x }) => w.updateAdmin(c, x),
3365
+ }), d = he({
3366
+ mutationFn: ({ adminId: m, data: b }) => w.updateAdmin(m, b),
3335
3367
  onSuccess: i
3336
- }), g = ue({
3337
- mutationFn: (c) => w.deleteAdmin(c),
3368
+ }), f = he({
3369
+ mutationFn: (m) => w.deleteAdmin(m),
3338
3370
  onSuccess: i
3339
3371
  });
3340
- return { createAdmin: o, updateAdmin: d, deleteAdmin: g };
3372
+ return { createAdmin: o, updateAdmin: d, deleteAdmin: f };
3341
3373
  }
3342
- function xr(t = 0, i = 50, o, d) {
3374
+ function vr(t = 0, i = 50, o, d) {
3343
3375
  return we({
3344
- queryKey: [he, "threads", t, i, o, d],
3376
+ queryKey: [pe, "threads", t, i, o, d],
3345
3377
  queryFn: () => w.listThreads(t, i, o, d)
3346
3378
  });
3347
3379
  }
3348
- function br(t) {
3380
+ function yr(t) {
3349
3381
  return we({
3350
- queryKey: [he, "threadItems", t],
3382
+ queryKey: [pe, "threadItems", t],
3351
3383
  queryFn: () => w.getThreadItems(t),
3352
3384
  enabled: !!t
3353
3385
  });
3354
3386
  }
3355
- function vr(t = 20, i) {
3387
+ function _r(t = 20, i) {
3356
3388
  return we({
3357
- queryKey: [he, "jobs", t, i],
3389
+ queryKey: [pe, "jobs", t, i],
3358
3390
  queryFn: () => w.listJobs(t, i),
3359
3391
  refetchInterval: 5e3
3360
3392
  // Auto-refresh jobs every 5 seconds
3361
3393
  });
3362
3394
  }
3363
- function yr() {
3395
+ function Nr() {
3364
3396
  const t = $e();
3365
- return { cancelJob: ue({
3397
+ return { cancelJob: he({
3366
3398
  mutationFn: (d) => w.cancelJob(d),
3367
3399
  onSuccess: () => {
3368
- t.invalidateQueries({ queryKey: [he, "jobs"] });
3400
+ t.invalidateQueries({ queryKey: [pe, "jobs"] });
3369
3401
  }
3370
3402
  }) };
3371
3403
  }
3372
- function _r() {
3404
+ function wr() {
3373
3405
  return {
3374
3406
  login: async (t, i) => w.login(t, i),
3375
3407
  logout: () => w.clearToken(),
@@ -3378,15 +3410,15 @@ function _r() {
3378
3410
  };
3379
3411
  }
3380
3412
  export {
3381
- mr as AdminPanel,
3382
- gr as useAdminAdmins,
3383
- fr as useAdminAdminsMutations,
3384
- pr as useAdminAnalytics,
3385
- _r as useAdminAuth,
3386
- vr as useAdminJobs,
3387
- yr as useAdminJobsMutations,
3388
- br as useAdminThreadItems,
3389
- xr as useAdminThreads,
3390
- ur as useAdminUsers,
3391
- hr as useAdminUsersMutations
3413
+ hr as AdminPanel,
3414
+ xr as useAdminAdmins,
3415
+ br as useAdminAdminsMutations,
3416
+ fr as useAdminAnalytics,
3417
+ wr as useAdminAuth,
3418
+ _r as useAdminJobs,
3419
+ Nr as useAdminJobsMutations,
3420
+ yr as useAdminThreadItems,
3421
+ vr as useAdminThreads,
3422
+ pr as useAdminUsers,
3423
+ gr as useAdminUsersMutations
3392
3424
  };