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.
- package/README.md +99 -0
- package/dist/{checkbox-XoTpU9VY.js → checkbox-BZPTGt7D.js} +2076 -1406
- package/dist/gentiq-admin.es.js +700 -668
- package/dist/gentiq-index.es.js +972 -926
- package/dist/gentiq.css +1 -1
- package/dist/src/ChatReferencesContext.d.ts +27 -0
- package/dist/src/ComponentsContext.d.ts +2 -1
- package/dist/src/components/PromptInputArea.d.ts +2 -1
- package/dist/src/hooks/useGentiqChat.d.ts +2 -1
- package/dist/src/index.d.ts +3 -0
- package/dist/src/locales/en.json.d.ts +7 -0
- package/dist/src/locales/fa.json.d.ts +7 -0
- package/dist/src/parts/ChoiceQuestionPart.d.ts +5 -0
- package/dist/src/parts/ReferencePart.d.ts +3 -0
- package/dist/src/parts/TextPart.d.ts +1 -1
- package/dist/src/parts/index.d.ts +2 -0
- package/dist/src/types.d.ts +114 -1
- package/package.json +1 -1
package/dist/gentiq-admin.es.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import { jsx as e, jsxs as r, Fragment as
|
|
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
|
|
4
|
-
import { useTranslation as
|
|
5
|
-
import { G as Ue, a as Ne,
|
|
6
|
-
import { useNavigate as
|
|
7
|
-
import { Share2 as
|
|
8
|
-
import { toast as
|
|
9
|
-
import * as
|
|
10
|
-
import { useQuery as we, useQueryClient as $e, useMutation as
|
|
11
|
-
const
|
|
12
|
-
class
|
|
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
|
|
29
|
+
const f = await fetch(`${He}${i}`, {
|
|
30
30
|
...o,
|
|
31
31
|
headers: d
|
|
32
32
|
});
|
|
33
|
-
if (!
|
|
34
|
-
const
|
|
35
|
-
if (
|
|
36
|
-
throw new Ue(
|
|
37
|
-
let
|
|
38
|
-
throw typeof
|
|
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:
|
|
41
|
+
message: b,
|
|
42
42
|
details: _
|
|
43
43
|
}
|
|
44
|
-
},
|
|
44
|
+
}, f.status);
|
|
45
45
|
}
|
|
46
|
-
return
|
|
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
|
|
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(
|
|
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,
|
|
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:
|
|
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,
|
|
89
|
-
const
|
|
90
|
-
return d &&
|
|
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 = "",
|
|
101
|
-
const
|
|
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:
|
|
105
|
-
sort_order:
|
|
104
|
+
sort_by: f,
|
|
105
|
+
sort_order: m
|
|
106
106
|
});
|
|
107
|
-
return d &&
|
|
107
|
+
return d && b.append("query", d), this.request(`/admin/users?${b.toString()}`);
|
|
108
108
|
}
|
|
109
|
-
async createUser(i, o, d,
|
|
110
|
-
const M =
|
|
111
|
-
tokens:
|
|
112
|
-
requests:
|
|
113
|
-
token_limit:
|
|
114
|
-
request_limit: N ||
|
|
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,
|
|
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:
|
|
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(`${
|
|
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
|
|
181
|
-
throw new Error(
|
|
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
|
|
187
|
-
function
|
|
188
|
-
const { t: i, i18n: o } =
|
|
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 (
|
|
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(
|
|
195
|
-
}, [
|
|
196
|
-
const K = Ce(() => d?.logo ? typeof d.logo == "string" ? d.logo :
|
|
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(
|
|
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
|
-
},
|
|
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:
|
|
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:
|
|
316
|
-
onChange: (h) =>
|
|
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
|
|
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
|
|
390
|
-
const { t, i18n: i } =
|
|
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
|
|
394
|
-
|
|
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 ? (
|
|
400
|
-
} catch (
|
|
401
|
-
$(
|
|
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
|
-
},
|
|
405
|
+
}, x = async (n) => {
|
|
406
406
|
N(n), A(!0), $("");
|
|
407
407
|
try {
|
|
408
|
-
const
|
|
409
|
-
B(
|
|
410
|
-
} catch (
|
|
411
|
-
$(
|
|
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
|
-
},
|
|
415
|
+
}, j = async (n, c) => {
|
|
416
416
|
n.stopPropagation();
|
|
417
417
|
try {
|
|
418
|
-
const
|
|
419
|
-
navigator.clipboard.writeText(
|
|
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
|
-
|
|
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
|
|
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(
|
|
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
|
-
},
|
|
450
|
-
const [
|
|
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: () =>
|
|
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 ${
|
|
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
|
-
|
|
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
|
-
] },
|
|
487
|
-
}, O = async (n,
|
|
486
|
+
] }, c);
|
|
487
|
+
}, O = async (n, c) => {
|
|
488
488
|
try {
|
|
489
|
-
const
|
|
490
|
-
G.href =
|
|
491
|
-
} catch (
|
|
492
|
-
console.error("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
|
-
},
|
|
495
|
-
/* @__PURE__ */ e("div", {
|
|
496
|
-
n.text
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
"
|
|
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
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
)
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
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) =>
|
|
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
|
-
(
|
|
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 &&
|
|
584
|
-
|
|
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: () =>
|
|
588
|
-
className: `p-2.5 cursor-pointer transition-all rounded-xl border ${
|
|
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 ${
|
|
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((
|
|
610
|
-
const
|
|
611
|
-
if (
|
|
612
|
-
const
|
|
613
|
-
return ` • ${
|
|
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 ` • ${
|
|
616
|
-
}).join("")}${n.user_info.metadata?.values !== void 0 && !d.some((
|
|
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((
|
|
632
|
-
const
|
|
633
|
-
return
|
|
634
|
-
}).map((
|
|
635
|
-
const
|
|
636
|
-
let G = String(
|
|
637
|
-
if (
|
|
638
|
-
const
|
|
639
|
-
|
|
640
|
-
} else
|
|
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
|
-
|
|
674
|
+
g > 0 && /* @__PURE__ */ e("span", { className: "opacity-30", children: "|" }),
|
|
643
675
|
G
|
|
644
|
-
] },
|
|
676
|
+
] }, c.key);
|
|
645
677
|
}),
|
|
646
|
-
n.user_info.metadata?.values !== void 0 && !d.some((
|
|
647
|
-
d.some((
|
|
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 :
|
|
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:
|
|
692
|
-
|
|
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) =>
|
|
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(
|
|
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:
|
|
703
|
-
const
|
|
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 ${
|
|
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 ${
|
|
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:
|
|
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
|
|
728
|
-
const { t, i18n: i } =
|
|
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
|
-
|
|
766
|
+
m(!0), N("");
|
|
735
767
|
try {
|
|
736
|
-
const
|
|
737
|
-
d(
|
|
738
|
-
const
|
|
739
|
-
|
|
740
|
-
} catch (
|
|
741
|
-
N(
|
|
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
|
-
|
|
775
|
+
m(!1);
|
|
744
776
|
}
|
|
745
777
|
}, W = async () => {
|
|
746
778
|
try {
|
|
747
|
-
const
|
|
748
|
-
R(
|
|
749
|
-
} catch (
|
|
750
|
-
console.error("Failed to load permissions",
|
|
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 (
|
|
757
|
-
|
|
788
|
+
const P = async (x) => {
|
|
789
|
+
x.preventDefault(), m(!0);
|
|
758
790
|
try {
|
|
759
791
|
await w.register(
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
792
|
+
C.username,
|
|
793
|
+
C.password,
|
|
794
|
+
C.name,
|
|
795
|
+
C.permissions
|
|
764
796
|
), B(!1), D({ username: "", password: "", name: "", permissions: [] }), K();
|
|
765
|
-
} catch (
|
|
766
|
-
N(
|
|
797
|
+
} catch (j) {
|
|
798
|
+
N(j instanceof Error ? j.message : t("error_loading"));
|
|
767
799
|
} finally {
|
|
768
|
-
|
|
800
|
+
m(!1);
|
|
769
801
|
}
|
|
770
|
-
}, ae = async (
|
|
771
|
-
if (
|
|
772
|
-
|
|
802
|
+
}, ae = async (x) => {
|
|
803
|
+
if (x.preventDefault(), !!M) {
|
|
804
|
+
m(!0);
|
|
773
805
|
try {
|
|
774
|
-
const
|
|
775
|
-
name:
|
|
776
|
-
permissions:
|
|
806
|
+
const j = {
|
|
807
|
+
name: C.name,
|
|
808
|
+
permissions: C.permissions
|
|
777
809
|
};
|
|
778
|
-
if (
|
|
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 =
|
|
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 (
|
|
788
|
-
N(
|
|
819
|
+
} catch (j) {
|
|
820
|
+
N(j instanceof Error ? j.message : t("error_loading"));
|
|
789
821
|
} finally {
|
|
790
|
-
|
|
822
|
+
m(!1);
|
|
791
823
|
}
|
|
792
824
|
}
|
|
793
|
-
},
|
|
825
|
+
}, Z = async (x) => {
|
|
794
826
|
if (confirm(t("admins.confirm_delete_admin")))
|
|
795
827
|
try {
|
|
796
|
-
await w.deleteAdmin(
|
|
797
|
-
} catch (
|
|
798
|
-
N(
|
|
828
|
+
await w.deleteAdmin(x), K();
|
|
829
|
+
} catch (j) {
|
|
830
|
+
N(j instanceof Error ? j.message : t("error_loading"));
|
|
799
831
|
}
|
|
800
|
-
}, h = (
|
|
801
|
-
A(
|
|
802
|
-
username:
|
|
832
|
+
}, h = (x) => {
|
|
833
|
+
A(x), D({
|
|
834
|
+
username: x.username,
|
|
803
835
|
password: "",
|
|
804
|
-
name:
|
|
805
|
-
permissions:
|
|
836
|
+
name: x.name,
|
|
837
|
+
permissions: x.permissions
|
|
806
838
|
}), B(!0);
|
|
807
|
-
}, E = (
|
|
808
|
-
D((
|
|
809
|
-
...
|
|
810
|
-
permissions:
|
|
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 = (
|
|
813
|
-
const
|
|
814
|
-
if (s !==
|
|
844
|
+
}, U = (x) => {
|
|
845
|
+
const j = `admins.perm_${x}`, s = t(j);
|
|
846
|
+
if (s !== j)
|
|
815
847
|
return s;
|
|
816
|
-
switch (
|
|
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
|
|
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
|
-
|
|
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:
|
|
860
|
-
onChange: (
|
|
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:
|
|
874
|
-
onChange: (
|
|
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:
|
|
887
|
-
onChange: (
|
|
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((
|
|
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:
|
|
902
|
-
onChange: () => E(
|
|
903
|
-
disabled:
|
|
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(
|
|
908
|
-
] },
|
|
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:
|
|
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(
|
|
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((
|
|
941
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-3 font-medium text-foreground", children:
|
|
942
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground font-mono", dir: "ltr", children:
|
|
943
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground", children: /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1.5", children:
|
|
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(
|
|
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
|
-
|
|
986
|
+
x.id !== k && /* @__PURE__ */ e(
|
|
955
987
|
"button",
|
|
956
988
|
{
|
|
957
|
-
onClick: () =>
|
|
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
|
-
] },
|
|
996
|
+
] }, x.id)) })
|
|
965
997
|
] }),
|
|
966
|
-
o.length === 0 && !
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
|
1000
|
-
function
|
|
1001
|
-
const { t, i18n: i } =
|
|
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 =
|
|
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 = ++
|
|
1019
|
-
|
|
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
|
-
|
|
1055
|
+
Zt,
|
|
1024
1056
|
y,
|
|
1025
1057
|
I,
|
|
1026
1058
|
V
|
|
1027
1059
|
);
|
|
1028
|
-
if (ee !==
|
|
1029
|
-
|
|
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 !==
|
|
1063
|
+
if (ee !== Z.current) return;
|
|
1032
1064
|
_(ne instanceof Error ? ne.message : t("error_loading"));
|
|
1033
1065
|
} finally {
|
|
1034
|
-
ee ===
|
|
1066
|
+
ee === Z.current && (b(!1), h.current = !1);
|
|
1035
1067
|
}
|
|
1036
|
-
},
|
|
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
|
-
|
|
1077
|
+
et();
|
|
1046
1078
|
}, []), Y(() => {
|
|
1047
|
-
P && !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
|
-
|
|
1087
|
+
Z.current += 1, h.current = !1, f([]), H(0), b(!0);
|
|
1056
1088
|
const a = setTimeout(() => {
|
|
1057
|
-
ke(!1, R,
|
|
1089
|
+
ke(!1, R, C, K);
|
|
1058
1090
|
}, 500);
|
|
1059
1091
|
return () => {
|
|
1060
|
-
clearTimeout(a),
|
|
1092
|
+
clearTimeout(a), Z.current += 1, h.current = !1;
|
|
1061
1093
|
};
|
|
1062
|
-
}, [R,
|
|
1063
|
-
const
|
|
1064
|
-
|
|
1065
|
-
},
|
|
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 = { ...
|
|
1069
|
-
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 && !
|
|
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
|
|
1111
|
+
const at = async (a) => {
|
|
1080
1112
|
a.preventDefault();
|
|
1081
|
-
const y =
|
|
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 (
|
|
1123
|
+
if (v.metadata)
|
|
1092
1124
|
try {
|
|
1093
|
-
ne = JSON.parse(
|
|
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
|
-
|
|
1132
|
+
b(!0);
|
|
1101
1133
|
try {
|
|
1102
1134
|
await w.createUser(
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
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
|
-
|
|
1148
|
+
b(!1);
|
|
1117
1149
|
}
|
|
1118
1150
|
}
|
|
1119
|
-
},
|
|
1151
|
+
}, st = async (a) => {
|
|
1120
1152
|
if (a.preventDefault(), !A) return;
|
|
1121
1153
|
let y = {};
|
|
1122
|
-
if (
|
|
1154
|
+
if (v.metadata)
|
|
1123
1155
|
try {
|
|
1124
|
-
y = JSON.parse(
|
|
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
|
-
|
|
1163
|
+
b(!0);
|
|
1132
1164
|
try {
|
|
1133
1165
|
const V = await w.updateUser(A.id, {
|
|
1134
|
-
phone:
|
|
1135
|
-
name:
|
|
1136
|
-
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
|
-
|
|
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
|
-
|
|
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
|
-
},
|
|
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 (!
|
|
1204
|
+
if (!v.rechargeEnabled)
|
|
1173
1205
|
return { enabled: !1 };
|
|
1174
|
-
const a = Number(
|
|
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:
|
|
1179
|
-
anchor_at:
|
|
1210
|
+
interval_unit: v.rechargeIntervalUnit,
|
|
1211
|
+
anchor_at: v.rechargeAnchorAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
1180
1212
|
};
|
|
1181
|
-
},
|
|
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
|
-
},
|
|
1224
|
+
}, ot = async (a, y, I, V) => {
|
|
1193
1225
|
if (U) {
|
|
1194
|
-
|
|
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
|
-
),
|
|
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
|
-
|
|
1238
|
+
b(!1);
|
|
1207
1239
|
}
|
|
1208
1240
|
}
|
|
1209
|
-
},
|
|
1241
|
+
}, lt = async (a) => {
|
|
1210
1242
|
if (a.preventDefault(), !U) return;
|
|
1211
|
-
const y = parseInt(
|
|
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
|
|
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
|
-
},
|
|
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),
|
|
1230
|
-
},
|
|
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
|
-
},
|
|
1254
|
-
|
|
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")),
|
|
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:
|
|
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(
|
|
1293
|
-
/* @__PURE__ */ r(
|
|
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(
|
|
1327
|
+
/* @__PURE__ */ e(Xe, { children: c ? `${c.name} ${c.surname}` : "" })
|
|
1296
1328
|
] }),
|
|
1297
|
-
|
|
1298
|
-
[t("users.input_tokens"),
|
|
1299
|
-
[t("users.output_tokens"),
|
|
1300
|
-
[t("users.total_tokens"),
|
|
1301
|
-
[t("users.requests_made"),
|
|
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
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1336
|
+
Ye(
|
|
1337
|
+
S.total_cost_microunits,
|
|
1338
|
+
S.currency,
|
|
1307
1339
|
J
|
|
1308
1340
|
)
|
|
1309
1341
|
],
|
|
1310
|
-
[t("users.renewals"),
|
|
1342
|
+
[t("users.renewals"), S.renewal_count.toLocaleString(J)],
|
|
1311
1343
|
[
|
|
1312
1344
|
t("users.unpriced_requests"),
|
|
1313
|
-
|
|
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 ?
|
|
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:
|
|
1336
|
-
onChange: (a) => te({ ...
|
|
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:
|
|
1352
|
-
onChange: (a) => te({ ...
|
|
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 ${
|
|
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:
|
|
1365
|
-
onChange: (a) => te({ ...
|
|
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 ${
|
|
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:
|
|
1383
|
-
onChange: (a) => te({ ...
|
|
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:
|
|
1397
|
-
onChange: (a) => te({ ...
|
|
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:
|
|
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:
|
|
1413
|
-
onChange: (a) => te({ ...
|
|
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:
|
|
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:
|
|
1427
|
-
onChange: (a) => te({ ...
|
|
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:
|
|
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:
|
|
1479
|
+
checked: v.rechargeEnabled,
|
|
1448
1480
|
onCheckedChange: (a) => te({
|
|
1449
|
-
...
|
|
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
|
-
|
|
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:
|
|
1469
|
-
onChange: (a) => te({ ...
|
|
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
|
-
|
|
1511
|
+
le,
|
|
1480
1512
|
{
|
|
1481
|
-
value:
|
|
1513
|
+
value: v.rechargeIntervalUnit,
|
|
1482
1514
|
onValueChange: (a) => te({
|
|
1483
|
-
...
|
|
1515
|
+
...v,
|
|
1484
1516
|
rechargeIntervalUnit: a
|
|
1485
1517
|
}),
|
|
1486
|
-
dir:
|
|
1518
|
+
dir: L ? "rtl" : "ltr",
|
|
1487
1519
|
children: [
|
|
1488
|
-
/* @__PURE__ */ e(
|
|
1489
|
-
/* @__PURE__ */ e(
|
|
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) =>
|
|
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
|
-
|
|
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:
|
|
1554
|
+
dir: L ? "rtl" : "ltr",
|
|
1523
1555
|
children: [
|
|
1524
|
-
/* @__PURE__ */ e(
|
|
1525
|
-
/* @__PURE__ */ e(
|
|
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
|
-
|
|
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 ${
|
|
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:
|
|
1561
|
-
onChange: (a) => te({ ...
|
|
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:
|
|
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(
|
|
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
|
-
|
|
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:
|
|
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:
|
|
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) =>
|
|
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:
|
|
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) =>
|
|
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:
|
|
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:
|
|
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(
|
|
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 && !
|
|
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 ${
|
|
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":
|
|
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: () =>
|
|
1748
|
+
onClick: () => tt(a),
|
|
1717
1749
|
className: "inline-flex items-center gap-1.5 hover:text-foreground transition-colors",
|
|
1718
|
-
title: t(
|
|
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
|
-
|
|
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: () =>
|
|
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(
|
|
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: () =>
|
|
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
|
-
|
|
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: () =>
|
|
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: () =>
|
|
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 && !
|
|
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
|
-
|
|
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
|
|
1844
|
-
const { t, i18n: i } =
|
|
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
|
-
(
|
|
1881
|
+
(T) => !!T[1]
|
|
1850
1882
|
);
|
|
1851
1883
|
if (s.length === 0) return;
|
|
1852
|
-
const u = new ResizeObserver((
|
|
1853
|
-
for (const O of
|
|
1854
|
-
const
|
|
1855
|
-
|
|
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
|
-
[
|
|
1889
|
+
[q]: O.contentRect.width
|
|
1858
1890
|
}));
|
|
1859
1891
|
}
|
|
1860
1892
|
});
|
|
1861
|
-
return s.forEach(([,
|
|
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
|
-
},
|
|
1866
|
-
const O = [],
|
|
1867
|
-
for (let
|
|
1868
|
-
const
|
|
1869
|
-
if (n.has(
|
|
1870
|
-
O.push(n.get(
|
|
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:
|
|
1873
|
-
|
|
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
|
|
1880
|
-
let
|
|
1911
|
+
const T = s.length, O = new Intl.DateTimeFormat($, { month: "short" });
|
|
1912
|
+
let q = [];
|
|
1881
1913
|
if (_ <= 14)
|
|
1882
|
-
|
|
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,
|
|
1885
|
-
for (let
|
|
1886
|
-
|
|
1887
|
-
|
|
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:
|
|
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
|
|
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:
|
|
1900
|
-
/* @__PURE__ */ e("span", { className: "text-[9px] text-gray-400 dark:text-gray-500 mt-1 leading-none whitespace-nowrap", children:
|
|
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
|
-
|
|
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:
|
|
1924
|
-
threads:
|
|
1925
|
-
messages:
|
|
1926
|
-
token_usage:
|
|
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
|
-
|
|
1974
|
+
m(!1);
|
|
1943
1975
|
}
|
|
1944
1976
|
};
|
|
1945
|
-
if (
|
|
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 (
|
|
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:
|
|
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,
|
|
1963
|
-
let
|
|
1964
|
-
return O <= 1.2 ?
|
|
1965
|
-
}, P = Math.max(...o.trends.threads.map((s) => s.count) || [1]), ae = Math.max(...o.trends.messages.map((s) => s.count) || [1]),
|
|
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),
|
|
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: (
|
|
2104
|
-
/* @__PURE__ */ e("span", { children: Math.floor((
|
|
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
|
|
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: `${
|
|
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:
|
|
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(
|
|
2140
|
-
/* @__PURE__ */ e("span", { children: xe(Math.floor((
|
|
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) /
|
|
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
|
-
(
|
|
2176
|
-
), u = s.reduce((
|
|
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
|
|
2179
|
-
return /* @__PURE__ */ r(
|
|
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:
|
|
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:
|
|
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:
|
|
2253
|
+
r: q,
|
|
2222
2254
|
fill: "transparent",
|
|
2223
2255
|
stroke: "url(#negGradient)",
|
|
2224
2256
|
strokeWidth: "10",
|
|
2225
|
-
strokeDasharray: `${
|
|
2257
|
+
strokeDasharray: `${c / 100 * z} ${z}`,
|
|
2226
2258
|
strokeDashoffset: -(n / 100 * z),
|
|
2227
|
-
strokeLinecap:
|
|
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
|
|
2240
|
-
(
|
|
2241
|
-
).reduce((
|
|
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
|
-
|
|
2278
|
+
q,
|
|
2247
2279
|
" ",
|
|
2248
2280
|
n
|
|
2249
2281
|
] })
|
|
@@ -2287,28 +2319,28 @@ function Qt() {
|
|
|
2287
2319
|
] })
|
|
2288
2320
|
] });
|
|
2289
2321
|
}
|
|
2290
|
-
function
|
|
2291
|
-
const { t, i18n: i } =
|
|
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
|
|
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:
|
|
2306
|
-
thread_actions_retry:
|
|
2307
|
-
history_enabled:
|
|
2308
|
-
history_show_delete:
|
|
2309
|
-
history_show_rename:
|
|
2310
|
-
history_show_share:
|
|
2311
|
-
history_show_pin:
|
|
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,
|
|
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
|
|
2328
|
-
if (
|
|
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
|
-
|
|
2331
|
-
J[
|
|
2332
|
-
}), u((
|
|
2333
|
-
...
|
|
2334
|
-
...
|
|
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 = { ...
|
|
2339
|
-
u(J),
|
|
2370
|
+
const J = { ...j, translations: i.store.data };
|
|
2371
|
+
u(J), L || w.updateSettings(J).catch(console.error);
|
|
2340
2372
|
}
|
|
2341
|
-
} catch (
|
|
2342
|
-
console.error("Failed to fetch settings",
|
|
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,
|
|
2379
|
+
}, [t, j, i.store.data]);
|
|
2348
2380
|
const z = async (l) => {
|
|
2349
|
-
if (l && l.preventDefault(), !
|
|
2381
|
+
if (l && l.preventDefault(), !q) {
|
|
2350
2382
|
$(t("app_settings.general.default_accent_invalid"));
|
|
2351
2383
|
return;
|
|
2352
2384
|
}
|
|
2353
|
-
R(!0),
|
|
2385
|
+
R(!0), C(""), $("");
|
|
2354
2386
|
try {
|
|
2355
2387
|
await w.updateSettings({
|
|
2356
2388
|
...s,
|
|
2357
2389
|
default_accent: O || null
|
|
2358
|
-
}),
|
|
2359
|
-
} catch (
|
|
2360
|
-
$(
|
|
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(),
|
|
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
|
-
|
|
2408
|
+
Z(JSON.stringify(l, null, 2)), E("");
|
|
2377
2409
|
}, [D, W, s.translations]);
|
|
2378
|
-
const
|
|
2379
|
-
|
|
2410
|
+
const c = (l) => {
|
|
2411
|
+
Z(l);
|
|
2380
2412
|
try {
|
|
2381
|
-
const
|
|
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]:
|
|
2420
|
+
[W]: L
|
|
2389
2421
|
}
|
|
2390
2422
|
}
|
|
2391
2423
|
})), E("");
|
|
2392
2424
|
} catch {
|
|
2393
2425
|
E("Invalid JSON format");
|
|
2394
2426
|
}
|
|
2395
|
-
},
|
|
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(
|
|
2430
|
+
/* @__PURE__ */ e(L, { className: "size-4 text-primary/60" }),
|
|
2399
2431
|
l
|
|
2400
2432
|
] }) })
|
|
2401
|
-
] }),
|
|
2433
|
+
] }), S = ({ value: l }) => {
|
|
2402
2434
|
if (!l || !l.includes(":") && !l.includes(".")) return null;
|
|
2403
|
-
const
|
|
2404
|
-
return
|
|
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:
|
|
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((
|
|
2414
|
-
...
|
|
2445
|
+
l && !s.translations?.[l] && (u((L) => ({
|
|
2446
|
+
...L,
|
|
2415
2447
|
translations: {
|
|
2416
|
-
...
|
|
2448
|
+
...L.translations,
|
|
2417
2449
|
[l]: {}
|
|
2418
2450
|
}
|
|
2419
2451
|
})), K(l));
|
|
2420
|
-
},
|
|
2452
|
+
}, ie = () => {
|
|
2421
2453
|
const l = prompt("Enter namespace (e.g. chat, admin):");
|
|
2422
|
-
l && !s.translations?.[D]?.[l] && (u((
|
|
2423
|
-
...
|
|
2454
|
+
l && !s.translations?.[D]?.[l] && (u((L) => ({
|
|
2455
|
+
...L,
|
|
2424
2456
|
translations: {
|
|
2425
|
-
...
|
|
2457
|
+
...L.translations,
|
|
2426
2458
|
[D]: {
|
|
2427
|
-
...
|
|
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:
|
|
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(
|
|
2450
|
-
/* @__PURE__ */ e(
|
|
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(
|
|
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(
|
|
2462
|
-
/* @__PURE__ */ r(
|
|
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(
|
|
2496
|
+
/* @__PURE__ */ e(Xe, { children: t("app_settings.reset_confirm_description") })
|
|
2465
2497
|
] }),
|
|
2466
|
-
/* @__PURE__ */ r(
|
|
2467
|
-
/* @__PURE__ */ e(
|
|
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 || !
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
2560
|
+
le,
|
|
2529
2561
|
{
|
|
2530
2562
|
value: s.language,
|
|
2531
2563
|
onValueChange: (l) => u({ ...s, language: l }),
|
|
2532
2564
|
children: [
|
|
2533
|
-
/* @__PURE__ */ e(
|
|
2534
|
-
/* @__PURE__ */ r(
|
|
2535
|
-
/* @__PURE__ */ e(
|
|
2536
|
-
/* @__PURE__ */ e(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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(
|
|
2564
|
-
/* @__PURE__ */ r(
|
|
2565
|
-
/* @__PURE__ */ e(
|
|
2566
|
-
/* @__PURE__ */ e(
|
|
2567
|
-
/* @__PURE__ */ e(
|
|
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:
|
|
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": !
|
|
2625
|
+
"aria-invalid": !q
|
|
2594
2626
|
}
|
|
2595
2627
|
)
|
|
2596
2628
|
] }),
|
|
2597
|
-
/* @__PURE__ */ e("p", { className: `text-[10px] ${
|
|
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(
|
|
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(
|
|
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(
|
|
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
|
-
|
|
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(
|
|
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
|
-
|
|
2855
|
+
le,
|
|
2824
2856
|
{
|
|
2825
2857
|
value: s[l.id],
|
|
2826
|
-
onValueChange: (
|
|
2827
|
-
dir:
|
|
2858
|
+
onValueChange: (L) => u({ ...s, [l.id]: L }),
|
|
2859
|
+
dir: T ? "rtl" : "ltr",
|
|
2828
2860
|
children: [
|
|
2829
|
-
/* @__PURE__ */ e(
|
|
2830
|
-
/* @__PURE__ */ r(
|
|
2831
|
-
/* @__PURE__ */ e(
|
|
2832
|
-
/* @__PURE__ */ e(
|
|
2833
|
-
/* @__PURE__ */ e(
|
|
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
|
-
|
|
2891
|
+
le,
|
|
2860
2892
|
{
|
|
2861
2893
|
value: s.settings_general_fields?.[l.id] || "editable",
|
|
2862
|
-
onValueChange: (
|
|
2894
|
+
onValueChange: (L) => u((J) => ({
|
|
2863
2895
|
...J,
|
|
2864
|
-
settings_general_fields: { ...J.settings_general_fields, [l.id]:
|
|
2896
|
+
settings_general_fields: { ...J.settings_general_fields, [l.id]: L }
|
|
2865
2897
|
})),
|
|
2866
|
-
dir:
|
|
2898
|
+
dir: T ? "rtl" : "ltr",
|
|
2867
2899
|
children: [
|
|
2868
|
-
/* @__PURE__ */ e(
|
|
2869
|
-
/* @__PURE__ */ r(
|
|
2870
|
-
/* @__PURE__ */ e(
|
|
2871
|
-
/* @__PURE__ */ e(
|
|
2872
|
-
/* @__PURE__ */ e(
|
|
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
|
-
|
|
2925
|
+
le,
|
|
2894
2926
|
{
|
|
2895
2927
|
value: s.settings_profile_fields?.[l.id] || "editable",
|
|
2896
|
-
onValueChange: (
|
|
2928
|
+
onValueChange: (L) => u((J) => ({
|
|
2897
2929
|
...J,
|
|
2898
|
-
settings_profile_fields: { ...J.settings_profile_fields, [l.id]:
|
|
2930
|
+
settings_profile_fields: { ...J.settings_profile_fields, [l.id]: L }
|
|
2899
2931
|
})),
|
|
2900
|
-
dir:
|
|
2932
|
+
dir: T ? "rtl" : "ltr",
|
|
2901
2933
|
children: [
|
|
2902
|
-
/* @__PURE__ */ e(
|
|
2903
|
-
/* @__PURE__ */ r(
|
|
2904
|
-
/* @__PURE__ */ e(
|
|
2905
|
-
/* @__PURE__ */ e(
|
|
2906
|
-
/* @__PURE__ */ e(
|
|
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
|
-
|
|
2956
|
+
le,
|
|
2925
2957
|
{
|
|
2926
2958
|
value: s.settings_account_fields?.[l.id] || "editable",
|
|
2927
|
-
onValueChange: (
|
|
2959
|
+
onValueChange: (L) => u((J) => ({
|
|
2928
2960
|
...J,
|
|
2929
|
-
settings_account_fields: { ...J.settings_account_fields, [l.id]:
|
|
2961
|
+
settings_account_fields: { ...J.settings_account_fields, [l.id]: L }
|
|
2930
2962
|
})),
|
|
2931
|
-
dir:
|
|
2963
|
+
dir: T ? "rtl" : "ltr",
|
|
2932
2964
|
children: [
|
|
2933
|
-
/* @__PURE__ */ e(
|
|
2934
|
-
/* @__PURE__ */ r(
|
|
2935
|
-
/* @__PURE__ */ e(
|
|
2936
|
-
/* @__PURE__ */ e(
|
|
2937
|
-
/* @__PURE__ */ e(
|
|
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(
|
|
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(
|
|
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(
|
|
2989
|
-
/* @__PURE__ */ e(
|
|
2990
|
-
/* @__PURE__ */ e(
|
|
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(
|
|
2994
|
-
/* @__PURE__ */ e(
|
|
2995
|
-
/* @__PURE__ */ e(
|
|
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(
|
|
3000
|
-
/* @__PURE__ */ e("button", { type: "button", onClick:
|
|
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(
|
|
3038
|
+
/* @__PURE__ */ e(Pt, { className: "size-3 text-muted-foreground/30" })
|
|
3007
3039
|
] }),
|
|
3008
3040
|
/* @__PURE__ */ e(
|
|
3009
|
-
|
|
3041
|
+
Re,
|
|
3010
3042
|
{
|
|
3011
3043
|
value: ae,
|
|
3012
|
-
onChange: (l) =>
|
|
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 } =
|
|
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(
|
|
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
|
|
3044
|
-
const { t: i } =
|
|
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
|
-
},
|
|
3078
|
+
}, m = () => {
|
|
3047
3079
|
switch (o) {
|
|
3048
3080
|
case "light":
|
|
3049
|
-
return /* @__PURE__ */ e(
|
|
3081
|
+
return /* @__PURE__ */ e(Vt, { className: "h-[1.2rem] w-[1.2rem]" });
|
|
3050
3082
|
case "dark":
|
|
3051
|
-
return /* @__PURE__ */ e(
|
|
3083
|
+
return /* @__PURE__ */ e(Jt, { className: "h-[1.2rem] w-[1.2rem]" });
|
|
3052
3084
|
case "system":
|
|
3053
|
-
return /* @__PURE__ */ e(
|
|
3085
|
+
return /* @__PURE__ */ e(Je, { className: "h-[1.2rem] w-[1.2rem]" });
|
|
3054
3086
|
default:
|
|
3055
|
-
return /* @__PURE__ */ e(
|
|
3087
|
+
return /* @__PURE__ */ e(Je, { className: "h-[1.2rem] w-[1.2rem]" });
|
|
3056
3088
|
}
|
|
3057
|
-
},
|
|
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:
|
|
3071
|
-
|
|
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:
|
|
3106
|
+
/* @__PURE__ */ e(Me, { children: b() })
|
|
3075
3107
|
] });
|
|
3076
3108
|
};
|
|
3077
|
-
function
|
|
3078
|
-
const o =
|
|
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(() =>
|
|
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
|
|
3105
|
-
|
|
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(
|
|
3116
|
-
localStorage.setItem("gentiq-admin-language", h),
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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:
|
|
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" ?
|
|
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(
|
|
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(
|
|
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: (
|
|
3230
|
+
children: (m.language?.split("-")[0] || "").toUpperCase()
|
|
3199
3231
|
}
|
|
3200
3232
|
) }) }),
|
|
3201
|
-
/* @__PURE__ */ e(Me, { side: "bottom", className: "text-xs", children:
|
|
3233
|
+
/* @__PURE__ */ e(Me, { side: "bottom", className: "text-xs", children: f("dashboard.language", "Change Language") })
|
|
3202
3234
|
]
|
|
3203
3235
|
}
|
|
3204
3236
|
),
|
|
3205
|
-
/* @__PURE__ */ e(
|
|
3206
|
-
|
|
3237
|
+
/* @__PURE__ */ e(wt, { align: "center", className: "min-w-[8rem]", children: ae.map((h) => /* @__PURE__ */ e(
|
|
3238
|
+
kt,
|
|
3207
3239
|
{
|
|
3208
|
-
onClick: () =>
|
|
3209
|
-
className: h ===
|
|
3210
|
-
children:
|
|
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(
|
|
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(
|
|
3257
|
+
children: /* @__PURE__ */ e(Bt, { className: "size-5" })
|
|
3226
3258
|
}
|
|
3227
3259
|
) }),
|
|
3228
|
-
/* @__PURE__ */ e(Me, { side: "bottom", className: "text-xs", children:
|
|
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(
|
|
3233
|
-
/* @__PURE__ */ e(ge, { path: "/", element: /* @__PURE__ */ e(
|
|
3234
|
-
/* @__PURE__ */ e(ge, { path: "/analytics", element: W("analytics") ? /* @__PURE__ */ e(
|
|
3235
|
-
/* @__PURE__ */ e(ge, { path: "/chat-history", element: W("chat_history") ? /* @__PURE__ */ e(
|
|
3236
|
-
/* @__PURE__ */ e(ge, { path: "/admins", element: W("admin_management") ? /* @__PURE__ */ e(
|
|
3237
|
-
/* @__PURE__ */ e(ge, { path: "/settings", element: W("settings") ? /* @__PURE__ */ e(
|
|
3238
|
-
/* @__PURE__ */ e(ge, { path: "/users", element: W("user_management") ? /* @__PURE__ */ 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(
|
|
3279
|
+
/* @__PURE__ */ e(ge, { path: "*", element: /* @__PURE__ */ e(Pe, { to: "/admin/analytics", replace: !0 }) })
|
|
3248
3280
|
] }) }) })
|
|
3249
3281
|
] });
|
|
3250
3282
|
}
|
|
3251
|
-
function
|
|
3283
|
+
function hr(t) {
|
|
3252
3284
|
const i = Ce(() => {
|
|
3253
|
-
const o =
|
|
3254
|
-
return o.use(
|
|
3255
|
-
resources:
|
|
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(
|
|
3297
|
+
return /* @__PURE__ */ e(gt, { i18n: i, children: /* @__PURE__ */ e(ar, { ...t }) });
|
|
3266
3298
|
}
|
|
3267
|
-
function
|
|
3268
|
-
const { app: o, i18n: d } = Ne(), { t:
|
|
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,
|
|
3272
|
-
|
|
3303
|
+
Object.entries($).forEach(([H, C]) => {
|
|
3304
|
+
m.addResourceBundle(k, H, C, !0, !0);
|
|
3273
3305
|
});
|
|
3274
|
-
}), !localStorage.getItem("gentiq-admin-language") && o?.language &&
|
|
3275
|
-
}, [d?.resources,
|
|
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 =
|
|
3282
|
-
}, [M,
|
|
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:
|
|
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
|
|
3289
|
-
function
|
|
3320
|
+
const pe = "gentiq_admin";
|
|
3321
|
+
function pr(t = 0, i = 100, o = "") {
|
|
3290
3322
|
return we({
|
|
3291
|
-
queryKey: [
|
|
3323
|
+
queryKey: [pe, "users", t, i, o],
|
|
3292
3324
|
queryFn: () => w.listUsers(t, i, o)
|
|
3293
3325
|
});
|
|
3294
3326
|
}
|
|
3295
|
-
function
|
|
3327
|
+
function gr() {
|
|
3296
3328
|
const t = $e(), i = () => {
|
|
3297
|
-
t.invalidateQueries({ queryKey: [
|
|
3298
|
-
}, o =
|
|
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 =
|
|
3333
|
+
}), d = he({
|
|
3302
3334
|
mutationFn: ({ userId: N, data: _ }) => w.updateUser(N, _),
|
|
3303
3335
|
onSuccess: i
|
|
3304
|
-
}),
|
|
3336
|
+
}), f = he({
|
|
3305
3337
|
mutationFn: (N) => w.deleteUser(N),
|
|
3306
3338
|
onSuccess: i
|
|
3307
|
-
}),
|
|
3339
|
+
}), m = he({
|
|
3308
3340
|
mutationFn: ({ userId: N, tokens: _, requests: B }) => w.updateUserBalance(N, _, B),
|
|
3309
3341
|
onSuccess: i
|
|
3310
|
-
}),
|
|
3342
|
+
}), b = he({
|
|
3311
3343
|
mutationFn: (N) => w.refreshUserToken(N)
|
|
3312
3344
|
});
|
|
3313
|
-
return { createUser: o, updateUser: d, deleteUser:
|
|
3345
|
+
return { createUser: o, updateUser: d, deleteUser: f, updateBalance: m, refreshToken: b };
|
|
3314
3346
|
}
|
|
3315
|
-
function
|
|
3347
|
+
function fr(t = 30) {
|
|
3316
3348
|
return we({
|
|
3317
|
-
queryKey: [
|
|
3349
|
+
queryKey: [pe, "analytics", t],
|
|
3318
3350
|
queryFn: () => w.getAnalytics(t)
|
|
3319
3351
|
});
|
|
3320
3352
|
}
|
|
3321
|
-
function
|
|
3353
|
+
function xr() {
|
|
3322
3354
|
return we({
|
|
3323
|
-
queryKey: [
|
|
3355
|
+
queryKey: [pe, "admins"],
|
|
3324
3356
|
queryFn: () => w.listAdmins()
|
|
3325
3357
|
});
|
|
3326
3358
|
}
|
|
3327
|
-
function
|
|
3359
|
+
function br() {
|
|
3328
3360
|
const t = $e(), i = () => {
|
|
3329
|
-
t.invalidateQueries({ queryKey: [
|
|
3330
|
-
}, o =
|
|
3331
|
-
mutationFn: (
|
|
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 =
|
|
3334
|
-
mutationFn: ({ adminId:
|
|
3365
|
+
}), d = he({
|
|
3366
|
+
mutationFn: ({ adminId: m, data: b }) => w.updateAdmin(m, b),
|
|
3335
3367
|
onSuccess: i
|
|
3336
|
-
}),
|
|
3337
|
-
mutationFn: (
|
|
3368
|
+
}), f = he({
|
|
3369
|
+
mutationFn: (m) => w.deleteAdmin(m),
|
|
3338
3370
|
onSuccess: i
|
|
3339
3371
|
});
|
|
3340
|
-
return { createAdmin: o, updateAdmin: d, deleteAdmin:
|
|
3372
|
+
return { createAdmin: o, updateAdmin: d, deleteAdmin: f };
|
|
3341
3373
|
}
|
|
3342
|
-
function
|
|
3374
|
+
function vr(t = 0, i = 50, o, d) {
|
|
3343
3375
|
return we({
|
|
3344
|
-
queryKey: [
|
|
3376
|
+
queryKey: [pe, "threads", t, i, o, d],
|
|
3345
3377
|
queryFn: () => w.listThreads(t, i, o, d)
|
|
3346
3378
|
});
|
|
3347
3379
|
}
|
|
3348
|
-
function
|
|
3380
|
+
function yr(t) {
|
|
3349
3381
|
return we({
|
|
3350
|
-
queryKey: [
|
|
3382
|
+
queryKey: [pe, "threadItems", t],
|
|
3351
3383
|
queryFn: () => w.getThreadItems(t),
|
|
3352
3384
|
enabled: !!t
|
|
3353
3385
|
});
|
|
3354
3386
|
}
|
|
3355
|
-
function
|
|
3387
|
+
function _r(t = 20, i) {
|
|
3356
3388
|
return we({
|
|
3357
|
-
queryKey: [
|
|
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
|
|
3395
|
+
function Nr() {
|
|
3364
3396
|
const t = $e();
|
|
3365
|
-
return { cancelJob:
|
|
3397
|
+
return { cancelJob: he({
|
|
3366
3398
|
mutationFn: (d) => w.cancelJob(d),
|
|
3367
3399
|
onSuccess: () => {
|
|
3368
|
-
t.invalidateQueries({ queryKey: [
|
|
3400
|
+
t.invalidateQueries({ queryKey: [pe, "jobs"] });
|
|
3369
3401
|
}
|
|
3370
3402
|
}) };
|
|
3371
3403
|
}
|
|
3372
|
-
function
|
|
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
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3384
|
-
|
|
3385
|
-
|
|
3386
|
-
|
|
3387
|
-
|
|
3388
|
-
|
|
3389
|
-
|
|
3390
|
-
|
|
3391
|
-
|
|
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
|
};
|