gentiq 0.11.0 → 0.12.0-beta.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/dist/{checkbox-Bo_Q86i6.js → checkbox-DOit9Yho.js} +154 -152
- package/dist/gentiq-admin.es.js +1069 -1053
- package/dist/gentiq-index.es.js +1150 -1117
- package/dist/src/admin/lib/api.d.ts +6 -2
- package/dist/src/admin/pages/users/UsersTable.d.ts +1 -1
- package/dist/src/hooks/useGentiqAdmin.d.ts +1 -1
- package/dist/src/lib/api.d.ts +4 -2
- package/dist/src/lib/errors.d.ts +2 -0
- package/dist/src/locales/en.json.d.ts +15 -3
- package/dist/src/locales/fa.json.d.ts +15 -3
- package/dist/src/types.d.ts +19 -4
- package/package.json +1 -1
package/dist/gentiq-admin.es.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { jsx as e, jsxs as r, Fragment as at } from "react/jsx-runtime";
|
|
2
|
-
import { useState as
|
|
2
|
+
import { useState as _, useEffect as H, useMemo as pe, useRef as nt } from "react";
|
|
3
3
|
import mt from "i18next";
|
|
4
|
-
import { useTranslation as
|
|
5
|
-
import { G as Qe, u as
|
|
4
|
+
import { useTranslation as P, initReactI18next as ht, I18nextProvider as pt } from "react-i18next";
|
|
5
|
+
import { G as Qe, u as me, p as Ue, z as st, S as X, t as Y, v as ee, w as te, x as O, i as Se, q as Ge, P as Ce, D as Le, s as je, K as Te, M as Ae, N as Ie, L as z, I as se, aa as De, ab as qe, B as ne, O as Be, ac as ze, r as gt, m as Ee, n as Fe, o as Pe, E as ft, F as bt, H as xt, J as vt, ad as yt, d as _t, T as Nt } from "./checkbox-DOit9Yho.js";
|
|
6
6
|
import { useNavigate as wt, useLocation as kt, Routes as Ct, Route as ue, Navigate as Ze } from "react-router-dom";
|
|
7
7
|
import { Share2 as St, Bot as Xe, Sparkles as Lt, User as qt, Info as jt, ArrowUpDown as Tt, ArrowUp as At, ArrowDown as It, UsersRound as Dt, Globe as Je, RefreshCcw as ot, Palette as Rt, Keyboard as Mt, Wrench as $t, Play as Ve, History as Ot, Terminal as Et, ChevronDown as it, Loader2 as He, AlertTriangle as Ft, Ban as Pt, Plus as Jt, Hash as Ut, Wallet as Bt, Languages as zt, ShieldAlert as Vt, Monitor as Ye, Moon as Ht, Sun as Wt, LogOut as Kt } from "lucide-react";
|
|
8
|
-
import { toast as
|
|
8
|
+
import { toast as ve } from "sonner";
|
|
9
9
|
import { useQuery as oe, useQueryClient as we, useMutation as ae, keepPreviousData as Qt } from "@tanstack/react-query";
|
|
10
10
|
import * as et from "@radix-ui/react-switch";
|
|
11
11
|
const tt = "/api";
|
|
@@ -34,13 +34,13 @@ class Gt {
|
|
|
34
34
|
const n = await o.json().catch(() => ({}));
|
|
35
35
|
if (n.error && (typeof n.error.code == "string" || typeof n.error.message == "string"))
|
|
36
36
|
throw new Qe(n, o.status);
|
|
37
|
-
let d = `HTTP ${o.status}`, g = "error",
|
|
38
|
-
throw typeof n.detail == "string" ? d = n.detail : typeof n.message == "string" ? d = n.message : typeof n.error == "string" ? d = n.error : Array.isArray(n.detail) ? (d = "Validation failed",
|
|
37
|
+
let d = `HTTP ${o.status}`, g = "error", k = null;
|
|
38
|
+
throw typeof n.detail == "string" ? d = n.detail : typeof n.message == "string" ? d = n.message : typeof n.error == "string" ? d = n.error : Array.isArray(n.detail) ? (d = "Validation failed", k = n.detail, g = "validation_error") : n.error && typeof n.error.message == "string" && (d = n.error.message), new Qe(
|
|
39
39
|
{
|
|
40
40
|
error: {
|
|
41
41
|
code: g,
|
|
42
42
|
message: d,
|
|
43
|
-
details:
|
|
43
|
+
details: k
|
|
44
44
|
}
|
|
45
45
|
},
|
|
46
46
|
o.status
|
|
@@ -114,8 +114,8 @@ class Gt {
|
|
|
114
114
|
});
|
|
115
115
|
return l && g.append("query", l), this.request(`/admin/users?${g.toString()}`);
|
|
116
116
|
}
|
|
117
|
-
async createUser(a, s, l, o, n, d, g,
|
|
118
|
-
const
|
|
117
|
+
async createUser(a, s, l, o, n, d, g, k, L, N = "human", x, h) {
|
|
118
|
+
const v = o !== void 0 || n !== void 0 || d !== void 0 || g !== void 0 ? {
|
|
119
119
|
tokens: o || 0,
|
|
120
120
|
requests: n || 0,
|
|
121
121
|
token_limit: d || o || 0,
|
|
@@ -124,13 +124,15 @@ class Gt {
|
|
|
124
124
|
return this.request("/admin/users", {
|
|
125
125
|
method: "POST",
|
|
126
126
|
body: JSON.stringify({
|
|
127
|
+
username: x || void 0,
|
|
128
|
+
email: h || void 0,
|
|
127
129
|
phone: a || void 0,
|
|
128
130
|
name: s,
|
|
129
131
|
surname: l || void 0,
|
|
130
|
-
balance:
|
|
131
|
-
metadata:
|
|
132
|
-
recharge_policy:
|
|
133
|
-
type:
|
|
132
|
+
balance: v,
|
|
133
|
+
metadata: k,
|
|
134
|
+
recharge_policy: L,
|
|
135
|
+
type: N
|
|
134
136
|
})
|
|
135
137
|
});
|
|
136
138
|
}
|
|
@@ -241,57 +243,57 @@ class Gt {
|
|
|
241
243
|
return l.blob();
|
|
242
244
|
}
|
|
243
245
|
}
|
|
244
|
-
const
|
|
246
|
+
const I = new Gt();
|
|
245
247
|
function Zt({ onLoginSuccess: t }) {
|
|
246
|
-
const { t: a, i18n: s } =
|
|
248
|
+
const { t: a, i18n: s } = P(["admin", "translation"]), { app: l } = me(), { theme: o } = Ue(), [n, d] = _(""), [g, k] = _(""), [L, N] = _(""), [x, h] = _(""), [v, i] = _(!1), [b, j] = _(null), [y, E] = _("light");
|
|
247
249
|
H(() => {
|
|
248
250
|
if (o === "system") {
|
|
249
|
-
const
|
|
250
|
-
|
|
251
|
+
const f = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
252
|
+
E(f ? "dark" : "light");
|
|
251
253
|
} else
|
|
252
|
-
|
|
254
|
+
E(o);
|
|
253
255
|
}, [o]);
|
|
254
|
-
const
|
|
256
|
+
const p = pe(() => l?.logo ? typeof l.logo == "string" ? l.logo : y === "dark" ? l.logo.dark : l.logo.light : st, [l?.logo, y]), C = l?.adminTitle || l?.name, m = s.language === "fa";
|
|
255
257
|
H(() => {
|
|
256
|
-
|
|
258
|
+
I.checkSetupStatus().then((f) => j(f.needs_setup)).catch(() => j(!1));
|
|
257
259
|
}, []);
|
|
258
|
-
const
|
|
259
|
-
|
|
260
|
+
const w = async (f) => {
|
|
261
|
+
f.preventDefault(), h(""), i(!0);
|
|
260
262
|
try {
|
|
261
|
-
await
|
|
262
|
-
} catch (
|
|
263
|
-
|
|
263
|
+
await I.login(n, g), t();
|
|
264
|
+
} catch (M) {
|
|
265
|
+
h(M instanceof Error ? M.message : a("login.error"));
|
|
264
266
|
} finally {
|
|
265
|
-
|
|
267
|
+
i(!1);
|
|
266
268
|
}
|
|
267
|
-
},
|
|
268
|
-
if (
|
|
269
|
-
|
|
269
|
+
}, T = async (f) => {
|
|
270
|
+
if (f.preventDefault(), h(""), g !== L) {
|
|
271
|
+
h(a("login.passwords_mismatch"));
|
|
270
272
|
return;
|
|
271
273
|
}
|
|
272
274
|
if (g.length < 4) {
|
|
273
|
-
|
|
275
|
+
h(a("login.password_too_short"));
|
|
274
276
|
return;
|
|
275
277
|
}
|
|
276
|
-
|
|
278
|
+
i(!0);
|
|
277
279
|
try {
|
|
278
|
-
await
|
|
280
|
+
await I.register("admin", g, "Admin", [
|
|
279
281
|
"chat_history",
|
|
280
282
|
"admin_management",
|
|
281
283
|
"user_management",
|
|
282
284
|
"analytics"
|
|
283
|
-
]), await
|
|
284
|
-
} catch (
|
|
285
|
-
|
|
285
|
+
]), await I.login("admin", g), t();
|
|
286
|
+
} catch (M) {
|
|
287
|
+
h(M instanceof Error ? M.message : a("login.error"));
|
|
286
288
|
} finally {
|
|
287
|
-
|
|
289
|
+
i(!1);
|
|
288
290
|
}
|
|
289
291
|
};
|
|
290
|
-
return
|
|
292
|
+
return b === null ? /* @__PURE__ */ e("div", { className: "min-h-screen bg-background flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "w-6 h-6 border-2 border-border border-t-primary rounded-full animate-spin" }) }) : /* @__PURE__ */ r(
|
|
291
293
|
"div",
|
|
292
294
|
{
|
|
293
295
|
className: "min-h-screen bg-background flex items-center justify-center p-4 relative overflow-hidden",
|
|
294
|
-
dir:
|
|
296
|
+
dir: m ? "rtl" : "ltr",
|
|
295
297
|
children: [
|
|
296
298
|
/* @__PURE__ */ e("div", { className: "absolute top-[-10%] right-[-10%] w-[50%] h-[50%] bg-primary/10 rounded-full blur-3xl animate-pulse" }),
|
|
297
299
|
/* @__PURE__ */ e("div", { className: "absolute bottom-[-10%] left-[-10%] w-[40%] h-[40%] bg-primary/5 dark:bg-primary/10 rounded-full blur-3xl" }),
|
|
@@ -299,14 +301,14 @@ function Zt({ onLoginSuccess: t }) {
|
|
|
299
301
|
/* @__PURE__ */ r("div", { className: "glass rounded-3xl p-10 shadow-2xl", children: [
|
|
300
302
|
/* @__PURE__ */ r("div", { className: "text-center mb-10", children: [
|
|
301
303
|
/* @__PURE__ */ r("div", { className: "flex flex-col items-center gap-4 mb-6", children: [
|
|
302
|
-
/* @__PURE__ */ e("img", { src:
|
|
303
|
-
/* @__PURE__ */ e("h1", { className: "text-3xl font-black bg-gradient-to-l from-primary to-primary/60 bg-clip-text text-transparent", children:
|
|
304
|
+
/* @__PURE__ */ e("img", { src: p, alt: C, className: "size-16 object-contain" }),
|
|
305
|
+
/* @__PURE__ */ e("h1", { className: "text-3xl font-black bg-gradient-to-l from-primary to-primary/60 bg-clip-text text-transparent", children: b ? a("login.setup_title") : C })
|
|
304
306
|
] }),
|
|
305
|
-
|
|
307
|
+
b && /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground mt-3", children: a("login.setup_description") })
|
|
306
308
|
] }),
|
|
307
|
-
|
|
309
|
+
b ? (
|
|
308
310
|
/* ---- SETUP FORM ---- */
|
|
309
|
-
/* @__PURE__ */ r("form", { onSubmit:
|
|
311
|
+
/* @__PURE__ */ r("form", { onSubmit: T, className: "space-y-7", children: [
|
|
310
312
|
/* @__PURE__ */ r("div", { children: [
|
|
311
313
|
/* @__PURE__ */ e("label", { className: "block text-xs font-bold text-muted-foreground uppercase tracking-widest mb-3.5 mx-1", children: a("login.username") }),
|
|
312
314
|
/* @__PURE__ */ e(
|
|
@@ -334,7 +336,7 @@ function Zt({ onLoginSuccess: t }) {
|
|
|
334
336
|
id: "setup-password",
|
|
335
337
|
type: "password",
|
|
336
338
|
value: g,
|
|
337
|
-
onChange: (
|
|
339
|
+
onChange: (f) => k(f.target.value),
|
|
338
340
|
required: !0,
|
|
339
341
|
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",
|
|
340
342
|
placeholder: a("login.set_password_placeholder"),
|
|
@@ -356,8 +358,8 @@ function Zt({ onLoginSuccess: t }) {
|
|
|
356
358
|
{
|
|
357
359
|
id: "setup-confirm",
|
|
358
360
|
type: "password",
|
|
359
|
-
value:
|
|
360
|
-
onChange: (
|
|
361
|
+
value: L,
|
|
362
|
+
onChange: (f) => N(f.target.value),
|
|
361
363
|
required: !0,
|
|
362
364
|
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",
|
|
363
365
|
placeholder: a("login.confirm_password_placeholder"),
|
|
@@ -370,9 +372,9 @@ function Zt({ onLoginSuccess: t }) {
|
|
|
370
372
|
"button",
|
|
371
373
|
{
|
|
372
374
|
type: "submit",
|
|
373
|
-
disabled:
|
|
375
|
+
disabled: v,
|
|
374
376
|
className: "w-full bg-primary text-primary-foreground font-bold py-4 px-6 rounded-2xl hover:opacity-90 transition-all text-sm shadow-lg hover:shadow-xl disabled:opacity-50 active:scale-[0.98]",
|
|
375
|
-
children:
|
|
377
|
+
children: v ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center gap-2", children: [
|
|
376
378
|
/* @__PURE__ */ e("div", { className: "w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin" }),
|
|
377
379
|
/* @__PURE__ */ e("span", { children: a("login.setting_up") })
|
|
378
380
|
] }) : a("login.create_admin")
|
|
@@ -381,7 +383,7 @@ function Zt({ onLoginSuccess: t }) {
|
|
|
381
383
|
] })
|
|
382
384
|
) : (
|
|
383
385
|
/* ---- LOGIN FORM ---- */
|
|
384
|
-
/* @__PURE__ */ r("form", { onSubmit:
|
|
386
|
+
/* @__PURE__ */ r("form", { onSubmit: w, className: "space-y-7", children: [
|
|
385
387
|
/* @__PURE__ */ r("div", { children: [
|
|
386
388
|
/* @__PURE__ */ e(
|
|
387
389
|
"label",
|
|
@@ -397,7 +399,7 @@ function Zt({ onLoginSuccess: t }) {
|
|
|
397
399
|
id: "username",
|
|
398
400
|
type: "text",
|
|
399
401
|
value: n,
|
|
400
|
-
onChange: (
|
|
402
|
+
onChange: (f) => d(f.target.value),
|
|
401
403
|
required: !0,
|
|
402
404
|
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",
|
|
403
405
|
placeholder: a("login.username_placeholder"),
|
|
@@ -420,7 +422,7 @@ function Zt({ onLoginSuccess: t }) {
|
|
|
420
422
|
id: "password",
|
|
421
423
|
type: "password",
|
|
422
424
|
value: g,
|
|
423
|
-
onChange: (
|
|
425
|
+
onChange: (f) => k(f.target.value),
|
|
424
426
|
required: !0,
|
|
425
427
|
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",
|
|
426
428
|
placeholder: a("login.password_placeholder"),
|
|
@@ -433,9 +435,9 @@ function Zt({ onLoginSuccess: t }) {
|
|
|
433
435
|
"button",
|
|
434
436
|
{
|
|
435
437
|
type: "submit",
|
|
436
|
-
disabled:
|
|
438
|
+
disabled: v,
|
|
437
439
|
className: "w-full bg-primary text-primary-foreground font-bold py-4 px-6 rounded-2xl hover:opacity-90 transition-all text-sm shadow-lg hover:shadow-xl disabled:opacity-50 active:scale-[0.98]",
|
|
438
|
-
children:
|
|
440
|
+
children: v ? /* @__PURE__ */ r("div", { className: "flex items-center justify-center gap-2", children: [
|
|
439
441
|
/* @__PURE__ */ e("div", { className: "w-4 h-4 border-2 border-current border-t-transparent rounded-full animate-spin" }),
|
|
440
442
|
/* @__PURE__ */ e("span", { children: a("login.logging_in") })
|
|
441
443
|
] }) : a("login.submit")
|
|
@@ -454,7 +456,7 @@ const re = "gentiq_admin";
|
|
|
454
456
|
function Xt(t = 0, a = 100, s = "", l = "name", o = "asc", n = "human") {
|
|
455
457
|
return oe({
|
|
456
458
|
queryKey: [re, "users", t, a, s, l, o, n],
|
|
457
|
-
queryFn: () =>
|
|
459
|
+
queryFn: () => I.listUsers(t, a, s, l, o, n),
|
|
458
460
|
// Infinite scroll grows `limit`, which changes the query key. Keep the previous
|
|
459
461
|
// (smaller) page mounted while the larger one loads so the list never collapses to
|
|
460
462
|
// empty — otherwise the scroll container resets to the top on every "load more".
|
|
@@ -465,7 +467,7 @@ function Yt() {
|
|
|
465
467
|
const t = we(), a = () => {
|
|
466
468
|
t.invalidateQueries({ queryKey: [re, "users"] });
|
|
467
469
|
}, s = ae({
|
|
468
|
-
mutationFn: (g) =>
|
|
470
|
+
mutationFn: (g) => I.createUser(
|
|
469
471
|
g.phone,
|
|
470
472
|
g.name,
|
|
471
473
|
g.surname,
|
|
@@ -481,50 +483,50 @@ function Yt() {
|
|
|
481
483
|
}), l = ae({
|
|
482
484
|
mutationFn: ({
|
|
483
485
|
userId: g,
|
|
484
|
-
data:
|
|
485
|
-
}) =>
|
|
486
|
+
data: k
|
|
487
|
+
}) => I.updateUser(g, k),
|
|
486
488
|
onSuccess: a
|
|
487
489
|
}), o = ae({
|
|
488
|
-
mutationFn: (g) =>
|
|
490
|
+
mutationFn: (g) => I.deleteUser(g),
|
|
489
491
|
onSuccess: a
|
|
490
492
|
}), n = ae({
|
|
491
493
|
mutationFn: ({
|
|
492
494
|
userId: g,
|
|
493
|
-
tokens:
|
|
494
|
-
requests:
|
|
495
|
-
}) =>
|
|
495
|
+
tokens: k,
|
|
496
|
+
requests: L
|
|
497
|
+
}) => I.updateUserBalance(g, k, L),
|
|
496
498
|
onSuccess: a
|
|
497
499
|
}), d = ae({
|
|
498
|
-
mutationFn: (g) =>
|
|
500
|
+
mutationFn: (g) => I.refreshUserToken(g)
|
|
499
501
|
});
|
|
500
502
|
return { createUser: s, updateUser: l, deleteUser: o, updateBalance: n, refreshToken: d };
|
|
501
503
|
}
|
|
502
504
|
function er(t = 30, a = "human") {
|
|
503
505
|
return oe({
|
|
504
506
|
queryKey: [re, "analytics", t, a],
|
|
505
|
-
queryFn: () =>
|
|
507
|
+
queryFn: () => I.getAnalytics(t, a)
|
|
506
508
|
});
|
|
507
509
|
}
|
|
508
510
|
function tr() {
|
|
509
511
|
return oe({
|
|
510
512
|
queryKey: [re, "admins"],
|
|
511
|
-
queryFn: () =>
|
|
513
|
+
queryFn: () => I.listAdmins()
|
|
512
514
|
});
|
|
513
515
|
}
|
|
514
516
|
function rr() {
|
|
515
517
|
const t = we(), a = () => {
|
|
516
518
|
t.invalidateQueries({ queryKey: [re, "admins"] });
|
|
517
519
|
}, s = ae({
|
|
518
|
-
mutationFn: (n) =>
|
|
520
|
+
mutationFn: (n) => I.register(n.username, n.password, n.name, n.permissions),
|
|
519
521
|
onSuccess: a
|
|
520
522
|
}), l = ae({
|
|
521
523
|
mutationFn: ({
|
|
522
524
|
adminId: n,
|
|
523
525
|
data: d
|
|
524
|
-
}) =>
|
|
526
|
+
}) => I.updateAdmin(n, d),
|
|
525
527
|
onSuccess: a
|
|
526
528
|
}), o = ae({
|
|
527
|
-
mutationFn: (n) =>
|
|
529
|
+
mutationFn: (n) => I.deleteAdmin(n),
|
|
528
530
|
onSuccess: a
|
|
529
531
|
});
|
|
530
532
|
return { createAdmin: s, updateAdmin: l, deleteAdmin: o };
|
|
@@ -532,20 +534,20 @@ function rr() {
|
|
|
532
534
|
function ar(t = 0, a = 50, s, l, o = "human") {
|
|
533
535
|
return oe({
|
|
534
536
|
queryKey: [re, "threads", t, a, s, l, o],
|
|
535
|
-
queryFn: () =>
|
|
537
|
+
queryFn: () => I.listThreads(t, a, s, l, o)
|
|
536
538
|
});
|
|
537
539
|
}
|
|
538
540
|
function nr(t) {
|
|
539
541
|
return oe({
|
|
540
542
|
queryKey: [re, "threadItems", t],
|
|
541
|
-
queryFn: () =>
|
|
543
|
+
queryFn: () => I.getThreadItems(t),
|
|
542
544
|
enabled: !!t
|
|
543
545
|
});
|
|
544
546
|
}
|
|
545
547
|
function Vr(t = 20, a) {
|
|
546
548
|
return oe({
|
|
547
549
|
queryKey: [re, "jobs", t, a],
|
|
548
|
-
queryFn: () =>
|
|
550
|
+
queryFn: () => I.listJobs(t, a),
|
|
549
551
|
refetchInterval: 5e3
|
|
550
552
|
// Auto-refresh jobs every 5 seconds
|
|
551
553
|
});
|
|
@@ -553,7 +555,7 @@ function Vr(t = 20, a) {
|
|
|
553
555
|
function Hr() {
|
|
554
556
|
const t = we();
|
|
555
557
|
return { cancelJob: ae({
|
|
556
|
-
mutationFn: (l) =>
|
|
558
|
+
mutationFn: (l) => I.cancelJob(l),
|
|
557
559
|
onSuccess: () => {
|
|
558
560
|
t.invalidateQueries({ queryKey: [re, "jobs"] });
|
|
559
561
|
}
|
|
@@ -562,14 +564,14 @@ function Hr() {
|
|
|
562
564
|
function sr(t = !0) {
|
|
563
565
|
return oe({
|
|
564
566
|
queryKey: [re, "registeredJobs"],
|
|
565
|
-
queryFn: () =>
|
|
567
|
+
queryFn: () => I.listRegisteredJobs(),
|
|
566
568
|
enabled: t
|
|
567
569
|
});
|
|
568
570
|
}
|
|
569
571
|
function or(t = {}, a = !0) {
|
|
570
572
|
return oe({
|
|
571
573
|
queryKey: [re, "jobRuns", t],
|
|
572
|
-
queryFn: () =>
|
|
574
|
+
queryFn: () => I.listJobRuns(t),
|
|
573
575
|
refetchInterval: 3e3,
|
|
574
576
|
// Auto-refresh so running jobs update live
|
|
575
577
|
enabled: a
|
|
@@ -578,34 +580,34 @@ function or(t = {}, a = !0) {
|
|
|
578
580
|
function ir(t, a = !1) {
|
|
579
581
|
return oe({
|
|
580
582
|
queryKey: [re, "jobRun", t],
|
|
581
|
-
queryFn: () =>
|
|
583
|
+
queryFn: () => I.getJobRun(t),
|
|
582
584
|
enabled: !!t,
|
|
583
585
|
refetchInterval: a ? 2e3 : !1
|
|
584
586
|
});
|
|
585
587
|
}
|
|
586
588
|
function We() {
|
|
587
589
|
const t = we(), a = () => t.invalidateQueries({ queryKey: [re, "jobRuns"] }), s = ae({
|
|
588
|
-
mutationFn: (n) =>
|
|
590
|
+
mutationFn: (n) => I.runRegisteredJob(n.jobId, {
|
|
589
591
|
params: n.params,
|
|
590
592
|
dry_run: n.dry_run,
|
|
591
593
|
confirm: n.confirm
|
|
592
594
|
}),
|
|
593
595
|
onSuccess: a
|
|
594
596
|
}), l = ae({
|
|
595
|
-
mutationFn: (n) =>
|
|
597
|
+
mutationFn: (n) => I.runRawJob(n),
|
|
596
598
|
onSuccess: a
|
|
597
599
|
}), o = ae({
|
|
598
|
-
mutationFn: (n) =>
|
|
600
|
+
mutationFn: (n) => I.cancelJobRun(n),
|
|
599
601
|
onSuccess: a
|
|
600
602
|
});
|
|
601
603
|
return { runRegisteredJob: s, runRawJob: l, cancelJobRun: o };
|
|
602
604
|
}
|
|
603
605
|
function Wr() {
|
|
604
606
|
return {
|
|
605
|
-
login: async (t, a) =>
|
|
606
|
-
logout: () =>
|
|
607
|
-
getToken: () =>
|
|
608
|
-
isAuthenticated: !!
|
|
607
|
+
login: async (t, a) => I.login(t, a),
|
|
608
|
+
logout: () => I.clearToken(),
|
|
609
|
+
getToken: () => I.getToken(),
|
|
610
|
+
isAuthenticated: !!I.getToken()
|
|
609
611
|
};
|
|
610
612
|
}
|
|
611
613
|
function lt(t, a, s) {
|
|
@@ -621,7 +623,7 @@ function lt(t, a, s) {
|
|
|
621
623
|
return `${a} ${l.toLocaleString(s, { maximumFractionDigits: 6 })}`;
|
|
622
624
|
}
|
|
623
625
|
}
|
|
624
|
-
function
|
|
626
|
+
function he(t, a, s) {
|
|
625
627
|
const l = (t || 0) / 1e6;
|
|
626
628
|
try {
|
|
627
629
|
return new Intl.NumberFormat(s, {
|
|
@@ -663,48 +665,48 @@ function rt({ kind: t }) {
|
|
|
663
665
|
);
|
|
664
666
|
}
|
|
665
667
|
function dr() {
|
|
666
|
-
const { t, i18n: a } =
|
|
668
|
+
const { t, i18n: a } = P(["admin", "translation"]), { app: s } = me(), l = s?.userMetadataFields || [], [o, n] = _(null), [d, g] = _(""), [k, L] = _(""), [N, x] = _(""), [h, v] = _("human"), [i, b] = _(0), [j, y] = _([]), [E, p] = _(!0), [C, m] = _(""), w = a.language === "fa", T = w ? "fa-IR" : "en-US";
|
|
667
669
|
H(() => {
|
|
668
|
-
const c = setTimeout(() =>
|
|
670
|
+
const c = setTimeout(() => L(d), 500);
|
|
669
671
|
return () => clearTimeout(c);
|
|
670
672
|
}, [d]);
|
|
671
|
-
const
|
|
672
|
-
|
|
673
|
+
const f = ar(
|
|
674
|
+
i,
|
|
673
675
|
50,
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
),
|
|
676
|
+
k || void 0,
|
|
677
|
+
N || void 0,
|
|
678
|
+
h
|
|
679
|
+
), M = nr(o?.id ?? "");
|
|
678
680
|
H(() => {
|
|
679
|
-
|
|
680
|
-
}, [
|
|
681
|
-
const c =
|
|
682
|
-
c && (
|
|
683
|
-
}, [
|
|
684
|
-
const
|
|
681
|
+
b(0), y([]), p(!0);
|
|
682
|
+
}, [k, N, h]), H(() => {
|
|
683
|
+
const c = f.data?.threads;
|
|
684
|
+
c && (y((q) => i === 0 ? c : [...q, ...c]), p(c.length === 50));
|
|
685
|
+
}, [f.data, i]);
|
|
686
|
+
const F = M.data?.items ?? [], K = f.isLoading, S = f.isFetching && i > 0, u = M.isLoading, A = C || (f.error instanceof Error ? f.error.message : "") || (M.error instanceof Error ? M.error.message : "") || (f.error || M.error ? t("error_loading") : ""), D = (c) => {
|
|
685
687
|
n(c);
|
|
686
|
-
},
|
|
687
|
-
|
|
688
|
-
},
|
|
688
|
+
}, Q = () => {
|
|
689
|
+
b((c) => c + 50);
|
|
690
|
+
}, $ = async (c, q) => {
|
|
689
691
|
c.stopPropagation();
|
|
690
692
|
try {
|
|
691
|
-
const
|
|
692
|
-
navigator.clipboard.writeText(U),
|
|
693
|
+
const R = await I.shareThread(q.id), U = `${window.location.origin}${R.url}`;
|
|
694
|
+
navigator.clipboard.writeText(U), ve.success(t("sidebar:share_success"), {
|
|
693
695
|
description: t("sidebar:share_description")
|
|
694
696
|
});
|
|
695
697
|
} catch {
|
|
696
|
-
|
|
698
|
+
ve.error(t("sidebar:share_failed"));
|
|
697
699
|
}
|
|
698
700
|
}, B = (c) => {
|
|
699
|
-
const
|
|
700
|
-
return new Intl.DateTimeFormat(
|
|
701
|
+
const q = new Date(c);
|
|
702
|
+
return new Intl.DateTimeFormat(w ? "fa-IR" : "en-US", {
|
|
701
703
|
year: "numeric",
|
|
702
704
|
month: "long",
|
|
703
705
|
day: "numeric",
|
|
704
706
|
hour: "2-digit",
|
|
705
707
|
minute: "2-digit"
|
|
706
|
-
}).format(
|
|
707
|
-
},
|
|
708
|
+
}).format(q);
|
|
709
|
+
}, G = (c) => {
|
|
708
710
|
if (typeof c == "string")
|
|
709
711
|
try {
|
|
710
712
|
return JSON.stringify(JSON.parse(c), null, 2);
|
|
@@ -712,8 +714,8 @@ function dr() {
|
|
|
712
714
|
return c;
|
|
713
715
|
}
|
|
714
716
|
return JSON.stringify(c, null, 2);
|
|
715
|
-
}, W = ({ part: c, idx:
|
|
716
|
-
const [
|
|
717
|
+
}, W = ({ part: c, idx: q }) => {
|
|
718
|
+
const [R, U] = _(!1), Z = c.tool_name || (c.type && c.type.startsWith("tool-") ? c.type.slice(5) : "tool");
|
|
717
719
|
return /* @__PURE__ */ r(
|
|
718
720
|
"div",
|
|
719
721
|
{
|
|
@@ -723,14 +725,14 @@ function dr() {
|
|
|
723
725
|
/* @__PURE__ */ r(
|
|
724
726
|
"div",
|
|
725
727
|
{
|
|
726
|
-
onClick: () => U(!
|
|
728
|
+
onClick: () => U(!R),
|
|
727
729
|
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",
|
|
728
730
|
children: [
|
|
729
731
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
730
732
|
/* @__PURE__ */ e(
|
|
731
733
|
"svg",
|
|
732
734
|
{
|
|
733
|
-
className: `w-3 h-3 text-gray-400 transition-transform ${
|
|
735
|
+
className: `w-3 h-3 text-gray-400 transition-transform ${R ? "rotate-180" : ""}`,
|
|
734
736
|
fill: "none",
|
|
735
737
|
viewBox: "0 0 24 24",
|
|
736
738
|
stroke: "currentColor",
|
|
@@ -746,7 +748,7 @@ function dr() {
|
|
|
746
748
|
}
|
|
747
749
|
),
|
|
748
750
|
/* @__PURE__ */ e("span", { className: "text-[10px] font-bold uppercase tracking-widest text-muted-foreground", children: "Tool" }),
|
|
749
|
-
/* @__PURE__ */ e("span", { className: "text-xs font-semibold", children:
|
|
751
|
+
/* @__PURE__ */ e("span", { className: "text-xs font-semibold", children: Z })
|
|
750
752
|
] }),
|
|
751
753
|
/* @__PURE__ */ e(
|
|
752
754
|
"span",
|
|
@@ -758,10 +760,10 @@ function dr() {
|
|
|
758
760
|
]
|
|
759
761
|
}
|
|
760
762
|
),
|
|
761
|
-
|
|
763
|
+
R && /* @__PURE__ */ r("div", { className: "p-2.5 space-y-2.5 animate-in fade-in slide-in-from-top-1 duration-200", children: [
|
|
762
764
|
/* @__PURE__ */ r("div", { children: [
|
|
763
765
|
/* @__PURE__ */ e("div", { className: "text-[10px] uppercase font-bold text-muted-foreground mb-1", children: "Input" }),
|
|
764
|
-
/* @__PURE__ */ e("pre", { className: "text-xs bg-black/5 dark:bg-black/20 p-2 rounded-lg overflow-x-auto", children:
|
|
766
|
+
/* @__PURE__ */ e("pre", { className: "text-xs bg-black/5 dark:bg-black/20 p-2 rounded-lg overflow-x-auto", children: G(c.input) })
|
|
765
767
|
] }),
|
|
766
768
|
(c.output || c.error_text || c.errorText) && /* @__PURE__ */ r("div", { children: [
|
|
767
769
|
/* @__PURE__ */ e("div", { className: "text-[10px] uppercase font-bold text-muted-foreground mb-1", children: c.error_text || c.errorText ? "Error" : "Output" }),
|
|
@@ -769,26 +771,26 @@ function dr() {
|
|
|
769
771
|
"pre",
|
|
770
772
|
{
|
|
771
773
|
className: `text-xs p-2 rounded-lg overflow-x-auto ${c.error_text || c.errorText ? "bg-destructive/10 text-destructive" : "bg-primary/5 text-foreground/80"}`,
|
|
772
|
-
children:
|
|
774
|
+
children: G(c.output || c.error_text || c.errorText)
|
|
773
775
|
}
|
|
774
776
|
)
|
|
775
777
|
] })
|
|
776
778
|
] })
|
|
777
779
|
]
|
|
778
780
|
},
|
|
779
|
-
|
|
781
|
+
q
|
|
780
782
|
);
|
|
781
|
-
}, V = async (c,
|
|
783
|
+
}, V = async (c, q) => {
|
|
782
784
|
try {
|
|
783
|
-
const
|
|
784
|
-
|
|
785
|
-
} catch (
|
|
786
|
-
console.error("Download failed:",
|
|
785
|
+
const R = await I.getAttachmentBlob(c), U = window.URL.createObjectURL(R), Z = document.createElement("a");
|
|
786
|
+
Z.href = U, Z.download = q || c.split("/").pop() || "download", document.body.appendChild(Z), Z.click(), window.URL.revokeObjectURL(U), document.body.removeChild(Z);
|
|
787
|
+
} catch (R) {
|
|
788
|
+
console.error("Download failed:", R), m(R instanceof Error ? R.message : "Download failed");
|
|
787
789
|
}
|
|
788
|
-
}, de = (c,
|
|
789
|
-
if (typeof c == "string") return /* @__PURE__ */ e("div", { children: c },
|
|
790
|
+
}, de = (c, q) => {
|
|
791
|
+
if (typeof c == "string") return /* @__PURE__ */ e("div", { children: c }, q);
|
|
790
792
|
if (c.type === "text")
|
|
791
|
-
return /* @__PURE__ */ e("div", { className: "whitespace-pre-wrap", dir: "auto", children: c.text },
|
|
793
|
+
return /* @__PURE__ */ e("div", { className: "whitespace-pre-wrap", dir: "auto", children: c.text }, q);
|
|
792
794
|
if (c.type === "reasoning")
|
|
793
795
|
return /* @__PURE__ */ r(
|
|
794
796
|
"div",
|
|
@@ -800,24 +802,24 @@ function dr() {
|
|
|
800
802
|
c.text
|
|
801
803
|
]
|
|
802
804
|
},
|
|
803
|
-
|
|
805
|
+
q
|
|
804
806
|
);
|
|
805
807
|
if (c.type === "data-reference") {
|
|
806
|
-
const
|
|
808
|
+
const R = c.data || c.reference;
|
|
807
809
|
return /* @__PURE__ */ r(
|
|
808
810
|
"div",
|
|
809
811
|
{
|
|
810
812
|
className: "my-2 p-2.5 bg-primary/5 rounded-lg border border-primary/15 text-xs",
|
|
811
813
|
dir: "auto",
|
|
812
814
|
children: [
|
|
813
|
-
/* @__PURE__ */ e("div", { className: "font-bold mb-1 uppercase tracking-tighter text-primary/80", children:
|
|
814
|
-
/* @__PURE__ */ e("div", { className: "text-muted-foreground line-clamp-3", children:
|
|
815
|
+
/* @__PURE__ */ e("div", { className: "font-bold mb-1 uppercase tracking-tighter text-primary/80", children: R?.label || t("chat.reference", "Reference") }),
|
|
816
|
+
/* @__PURE__ */ e("div", { className: "text-muted-foreground line-clamp-3", children: R?.excerpt || t("chat.source_unavailable", "Source unavailable") })
|
|
815
817
|
]
|
|
816
818
|
},
|
|
817
|
-
|
|
819
|
+
q
|
|
818
820
|
);
|
|
819
821
|
}
|
|
820
|
-
return c.type === "data-choice-question" ? /* @__PURE__ */ e("pre", { className: "text-xs font-mono bg-muted/40 p-2.5 rounded-xl", dir: "ltr", children: JSON.stringify(c.data ?? c, null, 2) },
|
|
822
|
+
return c.type === "data-choice-question" ? /* @__PURE__ */ e("pre", { className: "text-xs font-mono bg-muted/40 p-2.5 rounded-xl", dir: "ltr", children: JSON.stringify(c.data ?? c, null, 2) }, q) : c.type === "dynamic-tool" || c.type && c.type.startsWith("tool-") || c.tool_call_id ? /* @__PURE__ */ e(W, { part: c, idx: q }, q) : c.type === "file" ? /* @__PURE__ */ r(
|
|
821
823
|
"div",
|
|
822
824
|
{
|
|
823
825
|
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",
|
|
@@ -855,23 +857,23 @@ function dr() {
|
|
|
855
857
|
)
|
|
856
858
|
]
|
|
857
859
|
},
|
|
858
|
-
|
|
860
|
+
q
|
|
859
861
|
) : /* @__PURE__ */ e(
|
|
860
862
|
"div",
|
|
861
863
|
{
|
|
862
864
|
className: "my-2 p-2 bg-muted/40 rounded-lg border border-border text-xs font-mono opacity-60",
|
|
863
865
|
children: JSON.stringify(c)
|
|
864
866
|
},
|
|
865
|
-
|
|
867
|
+
q
|
|
866
868
|
);
|
|
867
|
-
},
|
|
868
|
-
const
|
|
869
|
-
return
|
|
869
|
+
}, ge = (c) => {
|
|
870
|
+
const q = c.parts || [];
|
|
871
|
+
return q.length > 0 ? q.map((R, U) => de(R, U)) : typeof c.content == "object" ? /* @__PURE__ */ e("pre", { className: "text-xs font-mono bg-muted/40 p-2.5 rounded-xl", dir: "ltr", children: JSON.stringify(c.content, null, 2) }) : c.content;
|
|
870
872
|
}, Re = (c) => {
|
|
871
|
-
const { scrollTop:
|
|
872
|
-
|
|
873
|
+
const { scrollTop: q, scrollHeight: R, clientHeight: U } = c.currentTarget;
|
|
874
|
+
R - q <= U + 50 && !S && E && Q();
|
|
873
875
|
};
|
|
874
|
-
return /* @__PURE__ */ r("div", { className: "p-5 h-full flex flex-col gap-4 overflow-hidden", dir:
|
|
876
|
+
return /* @__PURE__ */ r("div", { className: "p-5 h-full flex flex-col gap-4 overflow-hidden", dir: w ? "rtl" : "ltr", children: [
|
|
875
877
|
/* @__PURE__ */ r("div", { className: "flex flex-col gap-3", children: [
|
|
876
878
|
/* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-center justify-between gap-4", children: [
|
|
877
879
|
/* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-foreground tracking-tight whitespace-nowrap", children: t("chat_history.title") }),
|
|
@@ -880,7 +882,7 @@ function dr() {
|
|
|
880
882
|
"form",
|
|
881
883
|
{
|
|
882
884
|
onSubmit: (c) => {
|
|
883
|
-
c.preventDefault(),
|
|
885
|
+
c.preventDefault(), L(d);
|
|
884
886
|
},
|
|
885
887
|
className: "flex-1 min-w-[16rem] flex gap-2",
|
|
886
888
|
children: [
|
|
@@ -908,16 +910,16 @@ function dr() {
|
|
|
908
910
|
/* @__PURE__ */ r(
|
|
909
911
|
X,
|
|
910
912
|
{
|
|
911
|
-
value:
|
|
913
|
+
value: N || "all",
|
|
912
914
|
onValueChange: (c) => x(c === "all" ? "" : c),
|
|
913
|
-
dir:
|
|
915
|
+
dir: w ? "rtl" : "ltr",
|
|
914
916
|
children: [
|
|
915
917
|
/* @__PURE__ */ e(Y, { className: "min-w-[160px] px-4 py-2 h-auto text-sm font-medium rounded-xl glass-surface border-0 text-foreground shadow-sm", children: /* @__PURE__ */ e(ee, {}) }),
|
|
916
918
|
/* @__PURE__ */ r(te, { className: "rounded-xl border-border bg-card", children: [
|
|
917
|
-
/* @__PURE__ */ e(
|
|
918
|
-
/* @__PURE__ */ e(
|
|
919
|
-
/* @__PURE__ */ e(
|
|
920
|
-
/* @__PURE__ */ e(
|
|
919
|
+
/* @__PURE__ */ e(O, { value: "all", children: t("chat_history.all_feedbacks", "All Feedbacks") }),
|
|
920
|
+
/* @__PURE__ */ e(O, { value: "liked", children: t("chat_history.liked_feedbacks", "Liked 👍") }),
|
|
921
|
+
/* @__PURE__ */ e(O, { value: "disliked", children: t("chat_history.disliked_feedbacks", "Disliked 👎") }),
|
|
922
|
+
/* @__PURE__ */ e(O, { value: "any", children: t("chat_history.any_feedback", "With Feedback") })
|
|
921
923
|
] })
|
|
922
924
|
]
|
|
923
925
|
}
|
|
@@ -925,32 +927,32 @@ function dr() {
|
|
|
925
927
|
/* @__PURE__ */ r(
|
|
926
928
|
X,
|
|
927
929
|
{
|
|
928
|
-
value:
|
|
929
|
-
onValueChange: (c) =>
|
|
930
|
-
dir:
|
|
930
|
+
value: h,
|
|
931
|
+
onValueChange: (c) => v(c),
|
|
932
|
+
dir: w ? "rtl" : "ltr",
|
|
931
933
|
children: [
|
|
932
934
|
/* @__PURE__ */ e(Y, { className: "min-w-[140px] px-4 py-2 h-auto text-sm font-medium rounded-xl glass-surface border-0 text-foreground shadow-sm", children: /* @__PURE__ */ e(ee, {}) }),
|
|
933
|
-
/* @__PURE__ */ e(te, { className: "rounded-xl border-border bg-card", children: ["human", "service", "all"].map((c) => /* @__PURE__ */ e(
|
|
935
|
+
/* @__PURE__ */ e(te, { className: "rounded-xl border-border bg-card", children: ["human", "service", "all"].map((c) => /* @__PURE__ */ e(O, { value: c, children: t(`chat_history.source_${c}`) }, c)) })
|
|
934
936
|
]
|
|
935
937
|
}
|
|
936
938
|
)
|
|
937
939
|
] })
|
|
938
940
|
] }),
|
|
939
|
-
|
|
941
|
+
A && /* @__PURE__ */ e("div", { className: "bg-destructive/10 border border-destructive/20 text-destructive px-4 py-3 rounded-xl text-sm backdrop-blur-sm", children: A })
|
|
940
942
|
] }),
|
|
941
943
|
/* @__PURE__ */ r("div", { className: "grid grid-cols-1 lg:grid-cols-[380px_1fr] gap-4 flex-1 min-h-0", children: [
|
|
942
944
|
/* @__PURE__ */ r("div", { className: "glass-surface rounded-2xl shadow-sm overflow-hidden flex flex-col min-w-0", children: [
|
|
943
945
|
/* @__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: [
|
|
944
946
|
t("chat_history.threads_list"),
|
|
945
947
|
" (",
|
|
946
|
-
(
|
|
948
|
+
(j.length || 0).toLocaleString(T),
|
|
947
949
|
")"
|
|
948
950
|
] }) }),
|
|
949
|
-
/* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto p-2 custom-scrollbar", onScroll: Re, children:
|
|
950
|
-
|
|
951
|
+
/* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto p-2 custom-scrollbar", onScroll: Re, children: K && j.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: [
|
|
952
|
+
j.map((c) => /* @__PURE__ */ r(
|
|
951
953
|
"div",
|
|
952
954
|
{
|
|
953
|
-
onClick: () =>
|
|
955
|
+
onClick: () => D(c),
|
|
954
956
|
className: `p-2.5 cursor-pointer transition-all rounded-xl border ${o?.id === c.id ? "bg-card border-border shadow-sm" : "border-transparent hover:bg-muted/50"}`,
|
|
955
957
|
children: [
|
|
956
958
|
/* @__PURE__ */ r("div", { className: "flex justify-between items-start mb-1.5 gap-4", children: [
|
|
@@ -981,19 +983,19 @@ function dr() {
|
|
|
981
983
|
{
|
|
982
984
|
className: "flex flex-col gap-0.5 min-w-0",
|
|
983
985
|
title: `${[c.user_info.name, c.user_info.surname].filter(Boolean).join(" ")}${c.user_info.phone ? ` • ${c.user_info.phone}` : ""}${l.filter(
|
|
984
|
-
(
|
|
985
|
-
).map((
|
|
986
|
-
const
|
|
987
|
-
if (
|
|
988
|
-
const U =
|
|
989
|
-
(
|
|
986
|
+
(q) => c.user_info?.metadata?.[q.key] !== void 0 && c.user_info?.metadata?.[q.key] !== ""
|
|
987
|
+
).map((q) => {
|
|
988
|
+
const R = c.user_info?.metadata?.[q.key];
|
|
989
|
+
if (q.type === "select") {
|
|
990
|
+
const U = q.options?.find(
|
|
991
|
+
(Z) => String(Z.value) === String(R)
|
|
990
992
|
);
|
|
991
|
-
return ` • ${U ? t(U.label) :
|
|
993
|
+
return ` • ${U ? t(U.label) : R}`;
|
|
992
994
|
}
|
|
993
|
-
return ` • ${
|
|
995
|
+
return ` • ${R}`;
|
|
994
996
|
}).join(
|
|
995
997
|
""
|
|
996
|
-
)}${c.user_info.metadata?.values !== void 0 && !l.some((
|
|
998
|
+
)}${c.user_info.metadata?.values !== void 0 && !l.some((q) => q.key === "values") ? ` • ${c.user_info.metadata.values}` : ""}`,
|
|
997
999
|
children: [
|
|
998
1000
|
/* @__PURE__ */ r("div", { className: "font-medium text-foreground truncate flex items-center gap-1.5", children: [
|
|
999
1001
|
/* @__PURE__ */ e("span", { children: [c.user_info.name, c.user_info.surname].filter(Boolean).join(" ") }),
|
|
@@ -1004,26 +1006,26 @@ function dr() {
|
|
|
1004
1006
|
] })
|
|
1005
1007
|
] }),
|
|
1006
1008
|
/* @__PURE__ */ r("div", { className: "text-[10px] text-muted-foreground/70 truncate flex items-center gap-1", children: [
|
|
1007
|
-
l.filter((
|
|
1008
|
-
const
|
|
1009
|
-
return
|
|
1010
|
-
}).map((
|
|
1011
|
-
const U = c.user_info?.metadata?.[
|
|
1012
|
-
let
|
|
1013
|
-
if (
|
|
1014
|
-
const
|
|
1009
|
+
l.filter((q) => {
|
|
1010
|
+
const R = c.user_info?.metadata?.[q.key];
|
|
1011
|
+
return R != null && R !== "";
|
|
1012
|
+
}).map((q, R) => {
|
|
1013
|
+
const U = c.user_info?.metadata?.[q.key];
|
|
1014
|
+
let Z = String(U);
|
|
1015
|
+
if (q.type === "select") {
|
|
1016
|
+
const fe = q.options?.find(
|
|
1015
1017
|
(ye) => String(ye.value) === String(U)
|
|
1016
1018
|
);
|
|
1017
|
-
|
|
1018
|
-
} else
|
|
1019
|
+
fe && (Z = t(fe.label));
|
|
1020
|
+
} else q.type === "checkbox" && (Z = U ? "✓" : "✗");
|
|
1019
1021
|
return /* @__PURE__ */ r("span", { className: "flex items-center gap-1", children: [
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
] },
|
|
1022
|
+
R > 0 && /* @__PURE__ */ e("span", { className: "opacity-30", children: "|" }),
|
|
1023
|
+
Z
|
|
1024
|
+
] }, q.key);
|
|
1023
1025
|
}),
|
|
1024
|
-
c.user_info.metadata?.values !== void 0 && !l.some((
|
|
1026
|
+
c.user_info.metadata?.values !== void 0 && !l.some((q) => q.key === "values") && /* @__PURE__ */ r("span", { className: "flex items-center gap-1", children: [
|
|
1025
1027
|
l.some(
|
|
1026
|
-
(
|
|
1028
|
+
(q) => c.user_info?.metadata?.[q.key] !== void 0
|
|
1027
1029
|
) && /* @__PURE__ */ e("span", { className: "opacity-30", children: "|" }),
|
|
1028
1030
|
String(c.user_info.metadata.values)
|
|
1029
1031
|
] })
|
|
@@ -1033,11 +1035,11 @@ function dr() {
|
|
|
1033
1035
|
),
|
|
1034
1036
|
c.metadata?.usage && /* @__PURE__ */ r("div", { className: "flex gap-2 mt-2 pt-2 border-border/30", children: [
|
|
1035
1037
|
/* @__PURE__ */ e("span", { className: "inline-flex items-center gap-1 bg-muted/30 px-2 py-0.5 rounded-md text-[9px] text-muted-foreground", children: t("chat_history.input_tokens", {
|
|
1036
|
-
value: (c.metadata.usage.cumulative_input_tokens ?? c.metadata.usage.input_tokens ?? 0).toLocaleString(
|
|
1038
|
+
value: (c.metadata.usage.cumulative_input_tokens ?? c.metadata.usage.input_tokens ?? 0).toLocaleString(T)
|
|
1037
1039
|
}) }),
|
|
1038
1040
|
/* @__PURE__ */ e("span", { className: "inline-flex items-center gap-1 bg-muted/30 px-2 py-0.5 rounded-md text-[9px] text-muted-foreground", children: t("chat_history.output_tokens", {
|
|
1039
1041
|
value: (c.metadata.usage.output_tokens || 0).toLocaleString(
|
|
1040
|
-
|
|
1042
|
+
T
|
|
1041
1043
|
)
|
|
1042
1044
|
}) }),
|
|
1043
1045
|
/* @__PURE__ */ e(
|
|
@@ -1047,13 +1049,13 @@ function dr() {
|
|
|
1047
1049
|
title: c.metadata.usage.cost_incomplete || c.metadata.usage.total_cost_microunits === void 0 ? void 0 : lt(
|
|
1048
1050
|
c.metadata.usage.total_cost_microunits || 0,
|
|
1049
1051
|
c.metadata.usage.currency || "USD",
|
|
1050
|
-
|
|
1052
|
+
T
|
|
1051
1053
|
),
|
|
1052
1054
|
children: c.metadata.usage.cost_incomplete || c.metadata.usage.total_cost_microunits === void 0 ? t("chat_history.unpriced") : t("chat_history.cost", {
|
|
1053
|
-
value:
|
|
1055
|
+
value: he(
|
|
1054
1056
|
c.metadata.usage.total_cost_microunits || 0,
|
|
1055
1057
|
c.metadata.usage.currency || "USD",
|
|
1056
|
-
|
|
1058
|
+
T
|
|
1057
1059
|
)
|
|
1058
1060
|
})
|
|
1059
1061
|
}
|
|
@@ -1065,7 +1067,7 @@ function dr() {
|
|
|
1065
1067
|
},
|
|
1066
1068
|
c.id
|
|
1067
1069
|
)),
|
|
1068
|
-
|
|
1070
|
+
S && /* @__PURE__ */ e("div", { className: "p-4 text-center text-muted-foreground text-xs", children: t("loading_more") })
|
|
1069
1071
|
] }) })
|
|
1070
1072
|
] }),
|
|
1071
1073
|
/* @__PURE__ */ r("div", { className: "glass-surface rounded-2xl shadow-sm overflow-hidden flex flex-col", children: [
|
|
@@ -1076,14 +1078,14 @@ function dr() {
|
|
|
1076
1078
|
o && /* @__PURE__ */ e(
|
|
1077
1079
|
"button",
|
|
1078
1080
|
{
|
|
1079
|
-
onClick: (c) =>
|
|
1081
|
+
onClick: (c) => $(c, o),
|
|
1080
1082
|
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",
|
|
1081
1083
|
title: t("sidebar:share_conversation"),
|
|
1082
1084
|
children: /* @__PURE__ */ e(St, { className: "w-4 h-4" })
|
|
1083
1085
|
}
|
|
1084
1086
|
)
|
|
1085
1087
|
] }),
|
|
1086
|
-
/* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto p-4 custom-scrollbar", children: o ?
|
|
1088
|
+
/* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto p-4 custom-scrollbar", children: o ? u ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground text-sm", children: t("chat_history.loading_messages") }) : F.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-4", children: lr(F).map((c) => {
|
|
1087
1089
|
if (c.kind === "subagent") {
|
|
1088
1090
|
const ye = c.items[c.items.length - 1];
|
|
1089
1091
|
return /* @__PURE__ */ r(
|
|
@@ -1099,38 +1101,38 @@ function dr() {
|
|
|
1099
1101
|
] }),
|
|
1100
1102
|
/* @__PURE__ */ e("span", { className: "ms-auto text-[10px] text-muted-foreground", children: B(ye.created_at) })
|
|
1101
1103
|
] }),
|
|
1102
|
-
/* @__PURE__ */ e("div", { className: "rounded-xl border border-dashed border-border/70 bg-muted/20 divide-y divide-border/40 overflow-hidden", children: c.items.map((
|
|
1103
|
-
/* @__PURE__ */ e("span", { className: "inline-block mb-1.5 text-[9px] font-bold uppercase tracking-wider text-muted-foreground px-1.5 py-0.5 rounded bg-muted", children:
|
|
1104
|
+
/* @__PURE__ */ e("div", { className: "rounded-xl border border-dashed border-border/70 bg-muted/20 divide-y divide-border/40 overflow-hidden", children: c.items.map((be) => /* @__PURE__ */ r("div", { className: "p-3", children: [
|
|
1105
|
+
/* @__PURE__ */ e("span", { className: "inline-block mb-1.5 text-[9px] font-bold uppercase tracking-wider text-muted-foreground px-1.5 py-0.5 rounded bg-muted", children: be.role }),
|
|
1104
1106
|
/* @__PURE__ */ e(
|
|
1105
1107
|
"div",
|
|
1106
1108
|
{
|
|
1107
1109
|
className: "text-sm text-foreground/90 leading-relaxed",
|
|
1108
1110
|
dir: "auto",
|
|
1109
|
-
children:
|
|
1111
|
+
children: ge(be)
|
|
1110
1112
|
}
|
|
1111
1113
|
)
|
|
1112
|
-
] },
|
|
1114
|
+
] }, be.id)) })
|
|
1113
1115
|
]
|
|
1114
1116
|
},
|
|
1115
1117
|
`subagent-${c.items[0].id}`
|
|
1116
1118
|
);
|
|
1117
1119
|
}
|
|
1118
|
-
const
|
|
1120
|
+
const q = c.item, R = q.role === "user", U = q.role === "assistant", Z = R ? "user" : U ? "assistant" : "other", fe = R ? o?.user_info?.name ? `${o.user_info.name} ${o.user_info.surname || ""}`.trim() : t("chat_history.user_label") : U ? t("chat_history.assistant_label") : q.role;
|
|
1119
1121
|
return /* @__PURE__ */ r(
|
|
1120
1122
|
"div",
|
|
1121
1123
|
{
|
|
1122
|
-
className: `relative rounded-2xl border p-3.5 transition-all ${
|
|
1124
|
+
className: `relative rounded-2xl border p-3.5 transition-all ${R ? "border-primary/20 bg-primary/5" : U ? "border-border bg-card/60 shadow-sm" : "border-border/50 bg-muted/30"}`,
|
|
1123
1125
|
children: [
|
|
1124
|
-
|
|
1126
|
+
q.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: q.feedback === "like" ? "👍" : "👎" }) }),
|
|
1125
1127
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2 mb-2", children: [
|
|
1126
|
-
/* @__PURE__ */ e(rt, { kind:
|
|
1127
|
-
/* @__PURE__ */ e("span", { className: "text-xs font-semibold text-foreground", children:
|
|
1128
|
-
/* @__PURE__ */ e("span", { className: "ms-auto text-[10px] text-muted-foreground", children: B(
|
|
1128
|
+
/* @__PURE__ */ e(rt, { kind: Z }),
|
|
1129
|
+
/* @__PURE__ */ e("span", { className: "text-xs font-semibold text-foreground", children: fe }),
|
|
1130
|
+
/* @__PURE__ */ e("span", { className: "ms-auto text-[10px] text-muted-foreground", children: B(q.created_at) })
|
|
1129
1131
|
] }),
|
|
1130
|
-
/* @__PURE__ */ e("div", { className: "text-sm text-foreground leading-relaxed ps-9", dir: "auto", children:
|
|
1132
|
+
/* @__PURE__ */ e("div", { className: "text-sm text-foreground leading-relaxed ps-9", dir: "auto", children: ge(q) })
|
|
1131
1133
|
]
|
|
1132
1134
|
},
|
|
1133
|
-
|
|
1135
|
+
q.id
|
|
1134
1136
|
);
|
|
1135
1137
|
}) }) : /* @__PURE__ */ r("div", { className: "h-full flex flex-col items-center justify-center text-muted-foreground", children: [
|
|
1136
1138
|
/* @__PURE__ */ e(
|
|
@@ -1158,78 +1160,78 @@ function dr() {
|
|
|
1158
1160
|
] });
|
|
1159
1161
|
}
|
|
1160
1162
|
function cr() {
|
|
1161
|
-
const { t, i18n: a } =
|
|
1163
|
+
const { t, i18n: a } = P(["admin", "translation"]), [s, l] = _(""), [o, n] = _(!1), [d, g] = _(null), [k, L] = _(null), N = a.language === "fa", x = tr(), h = x.data?.admins || [], v = x.isLoading, { createAdmin: i, updateAdmin: b, deleteAdmin: j } = rr(), E = oe({
|
|
1162
1164
|
queryKey: ["gentiq_admin", "permissions"],
|
|
1163
|
-
queryFn: () =>
|
|
1164
|
-
}).data?.permissions || [],
|
|
1165
|
+
queryFn: () => I.listPermissions()
|
|
1166
|
+
}).data?.permissions || [], p = s || (x.error ? x.error instanceof Error ? x.error.message : t("error_loading") : ""), [C, m] = _({
|
|
1165
1167
|
username: "",
|
|
1166
1168
|
password: "",
|
|
1167
1169
|
name: "",
|
|
1168
1170
|
permissions: []
|
|
1169
1171
|
});
|
|
1170
1172
|
H(() => {
|
|
1171
|
-
const
|
|
1172
|
-
|
|
1173
|
+
const S = localStorage.getItem("admin_info");
|
|
1174
|
+
S && L(JSON.parse(S).admin_id);
|
|
1173
1175
|
}, []);
|
|
1174
|
-
const
|
|
1175
|
-
|
|
1176
|
+
const w = async (S) => {
|
|
1177
|
+
S.preventDefault(), l("");
|
|
1176
1178
|
try {
|
|
1177
|
-
await
|
|
1178
|
-
username:
|
|
1179
|
-
password:
|
|
1180
|
-
name:
|
|
1181
|
-
permissions:
|
|
1182
|
-
}), n(!1),
|
|
1183
|
-
} catch (
|
|
1184
|
-
l(
|
|
1179
|
+
await i.mutateAsync({
|
|
1180
|
+
username: C.username,
|
|
1181
|
+
password: C.password,
|
|
1182
|
+
name: C.name,
|
|
1183
|
+
permissions: C.permissions
|
|
1184
|
+
}), n(!1), m({ username: "", password: "", name: "", permissions: [] });
|
|
1185
|
+
} catch (u) {
|
|
1186
|
+
l(u instanceof Error ? u.message : t("error_loading"));
|
|
1185
1187
|
}
|
|
1186
|
-
},
|
|
1187
|
-
if (
|
|
1188
|
+
}, T = async (S) => {
|
|
1189
|
+
if (S.preventDefault(), !!d) {
|
|
1188
1190
|
l("");
|
|
1189
1191
|
try {
|
|
1190
|
-
const
|
|
1191
|
-
name:
|
|
1192
|
-
permissions:
|
|
1192
|
+
const u = {
|
|
1193
|
+
name: C.name,
|
|
1194
|
+
permissions: C.permissions
|
|
1193
1195
|
};
|
|
1194
|
-
if (
|
|
1195
|
-
const
|
|
1196
|
-
if (
|
|
1197
|
-
const
|
|
1198
|
-
|
|
1196
|
+
if (C.password && (u.password = C.password), await b.mutateAsync({ adminId: d.id, data: u }), d.id === k) {
|
|
1197
|
+
const A = localStorage.getItem("admin_info");
|
|
1198
|
+
if (A) {
|
|
1199
|
+
const D = JSON.parse(A);
|
|
1200
|
+
D.name = C.name, D.permissions = C.permissions, localStorage.setItem("admin_info", JSON.stringify(D)), window.location.reload();
|
|
1199
1201
|
return;
|
|
1200
1202
|
}
|
|
1201
1203
|
}
|
|
1202
|
-
g(null),
|
|
1203
|
-
} catch (
|
|
1204
|
-
l(
|
|
1204
|
+
g(null), m({ username: "", password: "", name: "", permissions: [] });
|
|
1205
|
+
} catch (u) {
|
|
1206
|
+
l(u instanceof Error ? u.message : t("error_loading"));
|
|
1205
1207
|
}
|
|
1206
1208
|
}
|
|
1207
|
-
},
|
|
1209
|
+
}, f = async (S) => {
|
|
1208
1210
|
if (confirm(t("admins.confirm_delete_admin"))) {
|
|
1209
1211
|
l("");
|
|
1210
1212
|
try {
|
|
1211
|
-
await
|
|
1212
|
-
} catch (
|
|
1213
|
-
l(
|
|
1213
|
+
await j.mutateAsync(S);
|
|
1214
|
+
} catch (u) {
|
|
1215
|
+
l(u instanceof Error ? u.message : t("error_loading"));
|
|
1214
1216
|
}
|
|
1215
1217
|
}
|
|
1216
|
-
},
|
|
1217
|
-
g(
|
|
1218
|
-
username:
|
|
1218
|
+
}, M = (S) => {
|
|
1219
|
+
g(S), m({
|
|
1220
|
+
username: S.username,
|
|
1219
1221
|
password: "",
|
|
1220
|
-
name:
|
|
1221
|
-
permissions:
|
|
1222
|
+
name: S.name,
|
|
1223
|
+
permissions: S.permissions
|
|
1222
1224
|
}), n(!0);
|
|
1223
|
-
},
|
|
1224
|
-
|
|
1225
|
-
...
|
|
1226
|
-
permissions:
|
|
1225
|
+
}, F = (S) => {
|
|
1226
|
+
m((u) => ({
|
|
1227
|
+
...u,
|
|
1228
|
+
permissions: u.permissions.includes(S) ? u.permissions.filter((A) => A !== S) : [...u.permissions, S]
|
|
1227
1229
|
}));
|
|
1228
|
-
},
|
|
1229
|
-
const
|
|
1230
|
-
if (
|
|
1231
|
-
return
|
|
1232
|
-
switch (
|
|
1230
|
+
}, K = (S) => {
|
|
1231
|
+
const u = `admins.perm_${S}`, A = t(u);
|
|
1232
|
+
if (A !== u)
|
|
1233
|
+
return A;
|
|
1234
|
+
switch (S) {
|
|
1233
1235
|
case "chat_history":
|
|
1234
1236
|
return t("admins.perm_chat_history");
|
|
1235
1237
|
case "admin_management":
|
|
@@ -1241,19 +1243,19 @@ function cr() {
|
|
|
1241
1243
|
case "settings":
|
|
1242
1244
|
return t("admins.perm_settings");
|
|
1243
1245
|
default:
|
|
1244
|
-
return
|
|
1246
|
+
return S;
|
|
1245
1247
|
}
|
|
1246
1248
|
};
|
|
1247
|
-
return /* @__PURE__ */ r("div", { className: "h-full flex flex-col p-5 overflow-hidden gap-4", dir:
|
|
1249
|
+
return /* @__PURE__ */ r("div", { className: "h-full flex flex-col p-5 overflow-hidden gap-4", dir: N ? "rtl" : "ltr", children: [
|
|
1248
1250
|
/* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-center justify-between gap-3 flex-shrink-0", children: [
|
|
1249
1251
|
/* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-foreground tracking-tight whitespace-nowrap", children: t("admins.title") }),
|
|
1250
1252
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
1251
|
-
/* @__PURE__ */ e("div", { className: "glass-surface px-4 py-2.5 rounded-xl text-xs font-medium text-muted-foreground border border-border shadow-sm", children: t("admins.admin_count", { count:
|
|
1253
|
+
/* @__PURE__ */ e("div", { className: "glass-surface px-4 py-2.5 rounded-xl text-xs font-medium text-muted-foreground border border-border shadow-sm", children: t("admins.admin_count", { count: h.length }) }),
|
|
1252
1254
|
/* @__PURE__ */ e(
|
|
1253
1255
|
"button",
|
|
1254
1256
|
{
|
|
1255
1257
|
onClick: () => {
|
|
1256
|
-
g(null),
|
|
1258
|
+
g(null), m({ username: "", password: "", name: "", permissions: [] }), n(!0);
|
|
1257
1259
|
},
|
|
1258
1260
|
className: "px-4 py-2.5 bg-primary text-primary-foreground rounded-xl text-sm font-semibold hover:opacity-90 transition-all shadow-sm hover:shadow-md whitespace-nowrap",
|
|
1259
1261
|
children: t("admins.add_admin")
|
|
@@ -1261,13 +1263,13 @@ function cr() {
|
|
|
1261
1263
|
)
|
|
1262
1264
|
] })
|
|
1263
1265
|
] }),
|
|
1264
|
-
|
|
1266
|
+
p && /* @__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: p }),
|
|
1265
1267
|
o && /* @__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: [
|
|
1266
1268
|
/* @__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(d ? "admins.edit_admin" : "admins.add_admin") }) }),
|
|
1267
1269
|
/* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r(
|
|
1268
1270
|
"form",
|
|
1269
1271
|
{
|
|
1270
|
-
onSubmit: d ?
|
|
1272
|
+
onSubmit: d ? T : w,
|
|
1271
1273
|
className: "space-y-5",
|
|
1272
1274
|
children: [
|
|
1273
1275
|
/* @__PURE__ */ r("div", { children: [
|
|
@@ -1277,8 +1279,8 @@ function cr() {
|
|
|
1277
1279
|
{
|
|
1278
1280
|
type: "text",
|
|
1279
1281
|
disabled: !!d,
|
|
1280
|
-
value:
|
|
1281
|
-
onChange: (
|
|
1282
|
+
value: C.username,
|
|
1283
|
+
onChange: (S) => m({ ...C, username: S.target.value }),
|
|
1282
1284
|
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",
|
|
1283
1285
|
required: !0,
|
|
1284
1286
|
dir: "ltr"
|
|
@@ -1291,8 +1293,8 @@ function cr() {
|
|
|
1291
1293
|
"input",
|
|
1292
1294
|
{
|
|
1293
1295
|
type: "text",
|
|
1294
|
-
value:
|
|
1295
|
-
onChange: (
|
|
1296
|
+
value: C.name,
|
|
1297
|
+
onChange: (S) => m({ ...C, name: S.target.value }),
|
|
1296
1298
|
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",
|
|
1297
1299
|
required: !0
|
|
1298
1300
|
}
|
|
@@ -1304,8 +1306,8 @@ function cr() {
|
|
|
1304
1306
|
"input",
|
|
1305
1307
|
{
|
|
1306
1308
|
type: "password",
|
|
1307
|
-
value:
|
|
1308
|
-
onChange: (
|
|
1309
|
+
value: C.password,
|
|
1310
|
+
onChange: (S) => m({ ...C, password: S.target.value }),
|
|
1309
1311
|
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",
|
|
1310
1312
|
required: !d,
|
|
1311
1313
|
dir: "ltr"
|
|
@@ -1314,19 +1316,19 @@ function cr() {
|
|
|
1314
1316
|
] }),
|
|
1315
1317
|
/* @__PURE__ */ r("div", { children: [
|
|
1316
1318
|
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: t("admins.permissions") }),
|
|
1317
|
-
/* @__PURE__ */ e("div", { className: "space-y-3 p-4 bg-muted/30 rounded-xl border border-border", children:
|
|
1319
|
+
/* @__PURE__ */ e("div", { className: "space-y-3 p-4 bg-muted/30 rounded-xl border border-border", children: E.map((S) => /* @__PURE__ */ r("label", { className: "flex items-center gap-3 cursor-pointer group", children: [
|
|
1318
1320
|
/* @__PURE__ */ e("div", { className: "relative flex items-center", children: /* @__PURE__ */ e(
|
|
1319
1321
|
"input",
|
|
1320
1322
|
{
|
|
1321
1323
|
type: "checkbox",
|
|
1322
|
-
checked:
|
|
1323
|
-
onChange: () =>
|
|
1324
|
-
disabled:
|
|
1324
|
+
checked: C.permissions.includes(S),
|
|
1325
|
+
onChange: () => F(S),
|
|
1326
|
+
disabled: C.username === "admin" && S === "admin_management",
|
|
1325
1327
|
className: "peer h-4 w-4 rounded border-input text-primary focus:ring-ring transition-all disabled:opacity-50"
|
|
1326
1328
|
}
|
|
1327
1329
|
) }),
|
|
1328
|
-
/* @__PURE__ */ e("span", { className: "text-sm text-foreground/70 group-hover:text-foreground transition-colors select-none", children:
|
|
1329
|
-
] },
|
|
1330
|
+
/* @__PURE__ */ e("span", { className: "text-sm text-foreground/70 group-hover:text-foreground transition-colors select-none", children: K(S) })
|
|
1331
|
+
] }, S)) })
|
|
1330
1332
|
] }),
|
|
1331
1333
|
/* @__PURE__ */ r("div", { className: "flex gap-3 pt-4", children: [
|
|
1332
1334
|
/* @__PURE__ */ e(
|
|
@@ -1342,9 +1344,9 @@ function cr() {
|
|
|
1342
1344
|
"button",
|
|
1343
1345
|
{
|
|
1344
1346
|
type: "submit",
|
|
1345
|
-
disabled:
|
|
1347
|
+
disabled: i.isPending || b.isPending,
|
|
1346
1348
|
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",
|
|
1347
|
-
children:
|
|
1349
|
+
children: i.isPending || b.isPending ? t("saving") : t("save")
|
|
1348
1350
|
}
|
|
1349
1351
|
)
|
|
1350
1352
|
] })
|
|
@@ -1353,33 +1355,33 @@ function cr() {
|
|
|
1353
1355
|
) })
|
|
1354
1356
|
] }) }),
|
|
1355
1357
|
/* @__PURE__ */ e("div", { className: "glass-surface border border-border rounded-2xl overflow-hidden shadow-sm flex-1 flex flex-col", children: /* @__PURE__ */ r("div", { className: "overflow-x-auto flex-1", children: [
|
|
1356
|
-
/* @__PURE__ */ r("table", { className: `w-full ${
|
|
1358
|
+
/* @__PURE__ */ r("table", { className: `w-full ${N ? "text-right" : "text-left"} border-collapse`, children: [
|
|
1357
1359
|
/* @__PURE__ */ e("thead", { className: "bg-muted/30 sticky top-0 z-10 backdrop-blur-md", children: /* @__PURE__ */ r("tr", { children: [
|
|
1358
1360
|
/* @__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.name") }),
|
|
1359
1361
|
/* @__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.username") }),
|
|
1360
1362
|
/* @__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") }),
|
|
1361
1363
|
/* @__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") })
|
|
1362
1364
|
] }) }),
|
|
1363
|
-
/* @__PURE__ */ e("tbody", { className: "divide-y divide-border", children:
|
|
1365
|
+
/* @__PURE__ */ e("tbody", { className: "divide-y divide-border", children: h.map((S) => /* @__PURE__ */ r(
|
|
1364
1366
|
"tr",
|
|
1365
1367
|
{
|
|
1366
1368
|
className: "hover:bg-muted/30 transition-colors text-xs border-b border-border/50",
|
|
1367
1369
|
children: [
|
|
1368
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-3 font-medium text-foreground", children:
|
|
1369
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground font-mono", dir: "ltr", children:
|
|
1370
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground", children: /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1.5", children:
|
|
1370
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-3 font-medium text-foreground", children: S.name }),
|
|
1371
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground font-mono", dir: "ltr", children: S.username }),
|
|
1372
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground", children: /* @__PURE__ */ e("div", { className: "flex flex-wrap gap-1.5", children: S.permissions.map((u) => /* @__PURE__ */ e(
|
|
1371
1373
|
"span",
|
|
1372
1374
|
{
|
|
1373
1375
|
className: "px-2 py-0.5 bg-muted/50 text-foreground/80 rounded text-[10px] border border-border/50",
|
|
1374
|
-
children:
|
|
1376
|
+
children: K(u)
|
|
1375
1377
|
},
|
|
1376
|
-
|
|
1378
|
+
u
|
|
1377
1379
|
)) }) }),
|
|
1378
1380
|
/* @__PURE__ */ e("td", { className: "px-4 py-3", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-1.5", children: [
|
|
1379
1381
|
/* @__PURE__ */ e(
|
|
1380
1382
|
"button",
|
|
1381
1383
|
{
|
|
1382
|
-
onClick: () =>
|
|
1384
|
+
onClick: () => M(S),
|
|
1383
1385
|
className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
|
|
1384
1386
|
title: t("edit"),
|
|
1385
1387
|
children: /* @__PURE__ */ e(
|
|
@@ -1403,10 +1405,10 @@ function cr() {
|
|
|
1403
1405
|
)
|
|
1404
1406
|
}
|
|
1405
1407
|
),
|
|
1406
|
-
|
|
1408
|
+
S.id !== k && /* @__PURE__ */ e(
|
|
1407
1409
|
"button",
|
|
1408
1410
|
{
|
|
1409
|
-
onClick: () =>
|
|
1411
|
+
onClick: () => f(S.id),
|
|
1410
1412
|
className: "p-2 text-destructive hover:text-destructive/80 hover:bg-destructive/10 rounded-xl transition-all",
|
|
1411
1413
|
title: t("delete"),
|
|
1412
1414
|
children: /* @__PURE__ */ e(
|
|
@@ -1433,10 +1435,10 @@ function cr() {
|
|
|
1433
1435
|
] }) })
|
|
1434
1436
|
]
|
|
1435
1437
|
},
|
|
1436
|
-
|
|
1438
|
+
S.id
|
|
1437
1439
|
)) })
|
|
1438
1440
|
] }),
|
|
1439
|
-
|
|
1441
|
+
h.length === 0 && !v && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-2", children: [
|
|
1440
1442
|
/* @__PURE__ */ e(
|
|
1441
1443
|
"svg",
|
|
1442
1444
|
{
|
|
@@ -1458,7 +1460,7 @@ function cr() {
|
|
|
1458
1460
|
),
|
|
1459
1461
|
t("admins.no_admins")
|
|
1460
1462
|
] }),
|
|
1461
|
-
|
|
1463
|
+
v && /* @__PURE__ */ r("div", { className: "p-12 text-center text-muted-foreground text-sm flex flex-col items-center gap-3", children: [
|
|
1462
1464
|
/* @__PURE__ */ e("div", { className: "w-8 h-8 border-2 border-primary/20 border-t-primary rounded-full animate-spin" }),
|
|
1463
1465
|
/* @__PURE__ */ e("span", { children: t("loading") })
|
|
1464
1466
|
] })
|
|
@@ -1491,25 +1493,25 @@ function mr({
|
|
|
1491
1493
|
sortOrder: n,
|
|
1492
1494
|
onSort: d,
|
|
1493
1495
|
onLoadMore: g,
|
|
1494
|
-
onUsage:
|
|
1495
|
-
onEdit:
|
|
1496
|
-
onRecharge:
|
|
1496
|
+
onUsage: k,
|
|
1497
|
+
onEdit: L,
|
|
1498
|
+
onRecharge: N,
|
|
1497
1499
|
onCopyToken: x,
|
|
1498
|
-
onDelete:
|
|
1500
|
+
onDelete: h
|
|
1499
1501
|
}) {
|
|
1500
|
-
const { t:
|
|
1502
|
+
const { t: v, i18n: i } = P(["admin", "translation"]), { app: b } = me(), j = i.language === "fa", y = b?.identityField ?? "username", E = (p) => o !== p ? /* @__PURE__ */ e(Tt, { className: "w-3.5 h-3.5 opacity-50" }) : n === "asc" ? /* @__PURE__ */ e(At, { className: "w-3.5 h-3.5" }) : /* @__PURE__ */ e(It, { className: "w-3.5 h-3.5" });
|
|
1501
1503
|
return /* @__PURE__ */ e("div", { className: "glass-surface border border-border rounded-2xl overflow-hidden shadow-sm flex-1 flex flex-col", children: /* @__PURE__ */ r(
|
|
1502
1504
|
"div",
|
|
1503
1505
|
{
|
|
1504
1506
|
className: "overflow-auto flex-1 min-h-0 custom-scrollbar",
|
|
1505
1507
|
onScroll: (p) => {
|
|
1506
|
-
const
|
|
1507
|
-
|
|
1508
|
+
const C = p.currentTarget;
|
|
1509
|
+
C.scrollHeight - C.scrollTop - C.clientHeight < 160 && !a && t.length < s && g();
|
|
1508
1510
|
},
|
|
1509
1511
|
children: [
|
|
1510
|
-
/* @__PURE__ */ r("table", { className: `w-full ${
|
|
1512
|
+
/* @__PURE__ */ r("table", { className: `w-full ${j ? "text-right" : "text-left"} border-collapse`, children: [
|
|
1511
1513
|
/* @__PURE__ */ e("thead", { className: "bg-muted/30 sticky top-0 z-10 backdrop-blur-md", children: /* @__PURE__ */ r("tr", { children: [
|
|
1512
|
-
[
|
|
1514
|
+
[y, "name", "surname"].map((p) => /* @__PURE__ */ e(
|
|
1513
1515
|
"th",
|
|
1514
1516
|
{
|
|
1515
1517
|
className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50",
|
|
@@ -1520,12 +1522,12 @@ function mr({
|
|
|
1520
1522
|
type: "button",
|
|
1521
1523
|
onClick: () => d(p),
|
|
1522
1524
|
className: "inline-flex items-center gap-1.5 hover:text-foreground transition-colors",
|
|
1523
|
-
title:
|
|
1525
|
+
title: v(
|
|
1524
1526
|
o === p && n === "asc" ? "users.sort_descending" : "users.sort_ascending"
|
|
1525
1527
|
),
|
|
1526
1528
|
children: [
|
|
1527
|
-
/* @__PURE__ */ e("span", { children:
|
|
1528
|
-
|
|
1529
|
+
/* @__PURE__ */ e("span", { children: v(`users.${p}`) }),
|
|
1530
|
+
E(p)
|
|
1529
1531
|
]
|
|
1530
1532
|
}
|
|
1531
1533
|
)
|
|
@@ -1536,39 +1538,39 @@ function mr({
|
|
|
1536
1538
|
"th",
|
|
1537
1539
|
{
|
|
1538
1540
|
className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50",
|
|
1539
|
-
children:
|
|
1541
|
+
children: v(p.label)
|
|
1540
1542
|
},
|
|
1541
1543
|
p.key
|
|
1542
1544
|
)),
|
|
1543
|
-
/* @__PURE__ */ e("th", { className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50 w-[120px]", children:
|
|
1544
|
-
/* @__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:
|
|
1545
|
+
/* @__PURE__ */ e("th", { className: "px-4 py-3.5 text-[11px] font-bold text-muted-foreground uppercase tracking-widest border-b border-border/50 w-[120px]", children: v("users.balance") }),
|
|
1546
|
+
/* @__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: v("users.actions") })
|
|
1545
1547
|
] }) }),
|
|
1546
1548
|
/* @__PURE__ */ e("tbody", { className: "divide-y divide-border", children: t.map((p) => /* @__PURE__ */ r(
|
|
1547
1549
|
"tr",
|
|
1548
1550
|
{
|
|
1549
1551
|
className: "hover:bg-muted/30 transition-colors text-xs border-b border-border/50",
|
|
1550
1552
|
children: [
|
|
1551
|
-
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground font-mono", dir: "ltr", children: p.phone || /* @__PURE__ */ e("span", { className: "text-muted-foreground/50", children: "—" }) }),
|
|
1553
|
+
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground font-mono", dir: "ltr", children: p[y] || p.phone || /* @__PURE__ */ e("span", { className: "text-muted-foreground/50", children: "—" }) }),
|
|
1552
1554
|
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground", children: /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1.5", children: [
|
|
1553
1555
|
p.name,
|
|
1554
1556
|
p.type === "service" && /* @__PURE__ */ e("span", { className: "text-[10px] px-1.5 py-0.5 rounded-md bg-primary/10 text-primary font-medium uppercase tracking-wide", children: "API" })
|
|
1555
1557
|
] }) }),
|
|
1556
1558
|
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground/80", children: p.surname || /* @__PURE__ */ e("span", { className: "text-muted-foreground/50", children: "—" }) }),
|
|
1557
|
-
l.map((
|
|
1558
|
-
const
|
|
1559
|
-
let
|
|
1560
|
-
if (
|
|
1561
|
-
const
|
|
1562
|
-
|
|
1559
|
+
l.map((C) => {
|
|
1560
|
+
const m = p.metadata?.[C.key];
|
|
1561
|
+
let w = String(m ?? "");
|
|
1562
|
+
if (C.type === "select" && m !== void 0) {
|
|
1563
|
+
const T = C.options?.find((f) => String(f.value) === String(m));
|
|
1564
|
+
T && (w = v(T.label));
|
|
1563
1565
|
}
|
|
1564
|
-
return /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground/80", children:
|
|
1566
|
+
return /* @__PURE__ */ e("td", { className: "px-4 py-3 text-foreground/80", children: C.type === "checkbox" ? m ? /* @__PURE__ */ e("span", { className: "text-emerald-500 font-bold", children: "✓" }) : /* @__PURE__ */ e("span", { className: "text-muted-foreground opacity-30", children: "✗" }) : w }, C.key);
|
|
1565
1567
|
}),
|
|
1566
1568
|
/* @__PURE__ */ e("td", { className: "px-4 py-3 text-muted-foreground w-[120px]", children: p.balance ? /* @__PURE__ */ r("div", { className: "flex flex-col gap-3 min-w-0 py-1", children: [
|
|
1567
1569
|
/* @__PURE__ */ r("div", { className: "space-y-1", children: [
|
|
1568
1570
|
/* @__PURE__ */ r("div", { className: "flex justify-between text-[10px] font-semibold", children: [
|
|
1569
|
-
/* @__PURE__ */ e("span", { className: "text-muted-foreground", children:
|
|
1571
|
+
/* @__PURE__ */ e("span", { className: "text-muted-foreground", children: v("users.tokens_label") }),
|
|
1570
1572
|
/* @__PURE__ */ r("span", { className: "text-foreground", children: [
|
|
1571
|
-
(p.balance.token_limit > 0 ? Math.round(p.balance.tokens / p.balance.token_limit * 100) : 0).toLocaleString(
|
|
1573
|
+
(p.balance.token_limit > 0 ? Math.round(p.balance.tokens / p.balance.token_limit * 100) : 0).toLocaleString(i.language),
|
|
1572
1574
|
"%"
|
|
1573
1575
|
] })
|
|
1574
1576
|
] }),
|
|
@@ -1584,11 +1586,11 @@ function mr({
|
|
|
1584
1586
|
] }),
|
|
1585
1587
|
/* @__PURE__ */ r("div", { className: "space-y-1", children: [
|
|
1586
1588
|
/* @__PURE__ */ r("div", { className: "flex justify-between text-[10px] font-semibold", children: [
|
|
1587
|
-
/* @__PURE__ */ e("span", { className: "text-muted-foreground", children:
|
|
1589
|
+
/* @__PURE__ */ e("span", { className: "text-muted-foreground", children: v("users.requests_label") }),
|
|
1588
1590
|
/* @__PURE__ */ r("span", { className: "text-foreground", children: [
|
|
1589
1591
|
(p.balance.request_limit > 0 ? Math.round(
|
|
1590
1592
|
p.balance.requests / p.balance.request_limit * 100
|
|
1591
|
-
) : 0).toLocaleString(
|
|
1593
|
+
) : 0).toLocaleString(i.language),
|
|
1592
1594
|
"%"
|
|
1593
1595
|
] })
|
|
1594
1596
|
] }),
|
|
@@ -1607,18 +1609,18 @@ function mr({
|
|
|
1607
1609
|
/* @__PURE__ */ e(
|
|
1608
1610
|
"button",
|
|
1609
1611
|
{
|
|
1610
|
-
onClick: () =>
|
|
1612
|
+
onClick: () => k(p),
|
|
1611
1613
|
className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
|
|
1612
|
-
title:
|
|
1614
|
+
title: v("users.usage_summary"),
|
|
1613
1615
|
children: /* @__PURE__ */ e(jt, { className: "w-4 h-4" })
|
|
1614
1616
|
}
|
|
1615
1617
|
),
|
|
1616
1618
|
/* @__PURE__ */ e(
|
|
1617
1619
|
"button",
|
|
1618
1620
|
{
|
|
1619
|
-
onClick: () =>
|
|
1621
|
+
onClick: () => L(p),
|
|
1620
1622
|
className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
|
|
1621
|
-
title:
|
|
1623
|
+
title: v("edit"),
|
|
1622
1624
|
children: /* @__PURE__ */ e(
|
|
1623
1625
|
"svg",
|
|
1624
1626
|
{
|
|
@@ -1643,9 +1645,9 @@ function mr({
|
|
|
1643
1645
|
/* @__PURE__ */ e(
|
|
1644
1646
|
"button",
|
|
1645
1647
|
{
|
|
1646
|
-
onClick: () =>
|
|
1648
|
+
onClick: () => N(p),
|
|
1647
1649
|
className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
|
|
1648
|
-
title:
|
|
1650
|
+
title: v("users.recharge"),
|
|
1649
1651
|
children: /* @__PURE__ */ e(
|
|
1650
1652
|
"svg",
|
|
1651
1653
|
{
|
|
@@ -1672,7 +1674,7 @@ function mr({
|
|
|
1672
1674
|
{
|
|
1673
1675
|
onClick: () => x(p),
|
|
1674
1676
|
className: "p-2 text-muted-foreground hover:text-primary hover:bg-primary/10 rounded-xl transition-all",
|
|
1675
|
-
title:
|
|
1677
|
+
title: v("users.copy_token"),
|
|
1676
1678
|
children: /* @__PURE__ */ e(
|
|
1677
1679
|
"svg",
|
|
1678
1680
|
{
|
|
@@ -1697,9 +1699,9 @@ function mr({
|
|
|
1697
1699
|
/* @__PURE__ */ e(
|
|
1698
1700
|
"button",
|
|
1699
1701
|
{
|
|
1700
|
-
onClick: () =>
|
|
1702
|
+
onClick: () => h(p.id),
|
|
1701
1703
|
className: "p-2 text-destructive hover:text-destructive/80 hover:bg-destructive/10 rounded-xl transition-all",
|
|
1702
|
-
title:
|
|
1704
|
+
title: v("delete"),
|
|
1703
1705
|
children: /* @__PURE__ */ e(
|
|
1704
1706
|
"svg",
|
|
1705
1707
|
{
|
|
@@ -1747,7 +1749,7 @@ function mr({
|
|
|
1747
1749
|
)
|
|
1748
1750
|
}
|
|
1749
1751
|
),
|
|
1750
|
-
|
|
1752
|
+
v("users.no_users")
|
|
1751
1753
|
] }),
|
|
1752
1754
|
a && /* @__PURE__ */ r(
|
|
1753
1755
|
"div",
|
|
@@ -1755,7 +1757,7 @@ function mr({
|
|
|
1755
1757
|
className: `${t.length > 0 ? "p-5" : "p-12"} text-center text-muted-foreground text-sm flex flex-col items-center gap-3`,
|
|
1756
1758
|
children: [
|
|
1757
1759
|
/* @__PURE__ */ e("div", { className: "w-8 h-8 border-2 border-primary/20 border-t-primary rounded-full animate-spin" }),
|
|
1758
|
-
/* @__PURE__ */ e("span", { children:
|
|
1760
|
+
/* @__PURE__ */ e("span", { children: v("loading") })
|
|
1759
1761
|
]
|
|
1760
1762
|
}
|
|
1761
1763
|
)
|
|
@@ -1819,9 +1821,11 @@ function pr({
|
|
|
1819
1821
|
onSaved: o,
|
|
1820
1822
|
onError: n
|
|
1821
1823
|
}) {
|
|
1822
|
-
const { t: d, i18n: g } =
|
|
1824
|
+
const { t: d, i18n: g } = P(["admin", "translation"]), { app: k } = me(), L = g.language === "fa", N = L ? "text-right" : "text-left", x = k?.identityField ?? "username", [h, v] = _(!1), [i, b] = _(
|
|
1823
1825
|
() => t ? {
|
|
1824
1826
|
accountType: t.type ?? "human",
|
|
1827
|
+
username: t.username ?? "",
|
|
1828
|
+
email: t.email ?? "",
|
|
1825
1829
|
phone: t.phone ?? "",
|
|
1826
1830
|
name: t.name,
|
|
1827
1831
|
surname: t.surname,
|
|
@@ -1836,6 +1840,8 @@ function pr({
|
|
|
1836
1840
|
rechargeAnchorAt: t.recharge_policy?.anchor_at ?? ""
|
|
1837
1841
|
} : {
|
|
1838
1842
|
accountType: "human",
|
|
1843
|
+
username: "",
|
|
1844
|
+
email: "",
|
|
1839
1845
|
phone: "",
|
|
1840
1846
|
name: "",
|
|
1841
1847
|
surname: "",
|
|
@@ -1849,62 +1855,62 @@ function pr({
|
|
|
1849
1855
|
rechargeIntervalUnit: "month",
|
|
1850
1856
|
rechargeAnchorAt: ""
|
|
1851
1857
|
}
|
|
1852
|
-
), [
|
|
1858
|
+
), [j, y] = _(() => {
|
|
1853
1859
|
if (!t?.metadata) return {};
|
|
1854
|
-
const
|
|
1855
|
-
return s.forEach((
|
|
1856
|
-
t.metadata?.[
|
|
1857
|
-
}),
|
|
1860
|
+
const m = {};
|
|
1861
|
+
return s.forEach((w) => {
|
|
1862
|
+
t.metadata?.[w.key] !== void 0 ? m[w.key] = t.metadata[w.key] : w.defaultValue !== void 0 && (m[w.key] = w.defaultValue);
|
|
1863
|
+
}), m;
|
|
1858
1864
|
});
|
|
1859
1865
|
H(() => {
|
|
1860
1866
|
try {
|
|
1861
|
-
const
|
|
1862
|
-
|
|
1867
|
+
const w = { ...i.metadata ? JSON.parse(i.metadata) : {}, ...j }, T = JSON.stringify(w, null, 2);
|
|
1868
|
+
T !== i.metadata && b((f) => ({ ...f, metadata: T }));
|
|
1863
1869
|
} catch {
|
|
1864
1870
|
}
|
|
1865
|
-
}, [
|
|
1866
|
-
const
|
|
1867
|
-
let
|
|
1868
|
-
s.forEach((
|
|
1869
|
-
|
|
1870
|
-
}),
|
|
1871
|
-
}, [
|
|
1872
|
-
const
|
|
1871
|
+
}, [j]), H(() => {
|
|
1872
|
+
const m = { ...j };
|
|
1873
|
+
let w = !1;
|
|
1874
|
+
s.forEach((T) => {
|
|
1875
|
+
T.condition && !Ge(T.condition, j) && m[T.key] !== void 0 && (delete m[T.key], w = !0);
|
|
1876
|
+
}), w && y(m);
|
|
1877
|
+
}, [j, s]);
|
|
1878
|
+
const E = () => {
|
|
1873
1879
|
if (!i.rechargeEnabled)
|
|
1874
1880
|
return { enabled: !1 };
|
|
1875
|
-
const
|
|
1876
|
-
return !Number.isInteger(
|
|
1881
|
+
const m = Number(i.rechargeIntervalValue);
|
|
1882
|
+
return !Number.isInteger(m) || m <= 0 ? (n(d("users.recharge_interval_invalid")), null) : {
|
|
1877
1883
|
enabled: !0,
|
|
1878
|
-
interval_value:
|
|
1884
|
+
interval_value: m,
|
|
1879
1885
|
interval_unit: i.rechargeIntervalUnit,
|
|
1880
1886
|
// When blank, default to the next round boundary of the interval in the admin's
|
|
1881
1887
|
// local time (e.g. next local midnight for daily) rather than the request time.
|
|
1882
1888
|
anchor_at: i.rechargeAnchorAt ? new Date(i.rechargeAnchorAt).toISOString() : dt(i.rechargeIntervalUnit)
|
|
1883
1889
|
};
|
|
1884
|
-
}, p = async (
|
|
1885
|
-
|
|
1886
|
-
const
|
|
1887
|
-
if (
|
|
1890
|
+
}, p = async (m) => {
|
|
1891
|
+
m.preventDefault();
|
|
1892
|
+
const w = i.tokens ? parseInt(i.tokens) : 0, T = i.requests ? parseInt(i.requests) : 0, f = i.tokensLimit ? parseInt(i.tokensLimit) : w, M = i.requestsLimit ? parseInt(i.requestsLimit) : T;
|
|
1893
|
+
if (w > f) {
|
|
1888
1894
|
n(d("users.tokens_exceed_limit", "Tokens cannot exceed limit"));
|
|
1889
1895
|
return;
|
|
1890
1896
|
}
|
|
1891
|
-
if (
|
|
1897
|
+
if (T > M) {
|
|
1892
1898
|
n(d("users.requests_exceed_limit", "Requests cannot exceed limit"));
|
|
1893
1899
|
return;
|
|
1894
1900
|
}
|
|
1895
|
-
let
|
|
1901
|
+
let F = {};
|
|
1896
1902
|
if (i.metadata)
|
|
1897
1903
|
try {
|
|
1898
|
-
|
|
1904
|
+
F = JSON.parse(i.metadata);
|
|
1899
1905
|
} catch {
|
|
1900
1906
|
n(d("users.invalid_json", "Invalid JSON format"));
|
|
1901
1907
|
return;
|
|
1902
1908
|
}
|
|
1903
|
-
const
|
|
1904
|
-
if (
|
|
1905
|
-
|
|
1909
|
+
const K = E();
|
|
1910
|
+
if (K) {
|
|
1911
|
+
v(!0);
|
|
1906
1912
|
try {
|
|
1907
|
-
await
|
|
1913
|
+
await I.createUser(
|
|
1908
1914
|
i.phone || null,
|
|
1909
1915
|
i.name,
|
|
1910
1916
|
i.surname || null,
|
|
@@ -1912,44 +1918,48 @@ function pr({
|
|
|
1912
1918
|
i.requests ? parseInt(i.requests) : void 0,
|
|
1913
1919
|
i.tokensLimit ? parseInt(i.tokensLimit) : void 0,
|
|
1914
1920
|
i.requestsLimit ? parseInt(i.requestsLimit) : void 0,
|
|
1915
|
-
|
|
1916
|
-
|
|
1917
|
-
i.accountType
|
|
1921
|
+
F,
|
|
1922
|
+
K,
|
|
1923
|
+
i.accountType,
|
|
1924
|
+
i.username || null,
|
|
1925
|
+
i.email || null
|
|
1918
1926
|
), o();
|
|
1919
|
-
} catch (
|
|
1920
|
-
n(
|
|
1927
|
+
} catch (S) {
|
|
1928
|
+
n(S instanceof Error ? S.message : d("error_loading"));
|
|
1921
1929
|
} finally {
|
|
1922
|
-
|
|
1930
|
+
v(!1);
|
|
1923
1931
|
}
|
|
1924
1932
|
}
|
|
1925
|
-
},
|
|
1926
|
-
if (
|
|
1927
|
-
let
|
|
1933
|
+
}, C = async (m) => {
|
|
1934
|
+
if (m.preventDefault(), !t) return;
|
|
1935
|
+
let w = {};
|
|
1928
1936
|
if (i.metadata)
|
|
1929
1937
|
try {
|
|
1930
|
-
|
|
1938
|
+
w = JSON.parse(i.metadata);
|
|
1931
1939
|
} catch {
|
|
1932
1940
|
n(d("users.invalid_json", "Invalid JSON format"));
|
|
1933
1941
|
return;
|
|
1934
1942
|
}
|
|
1935
|
-
const
|
|
1936
|
-
if (
|
|
1937
|
-
|
|
1943
|
+
const T = E();
|
|
1944
|
+
if (T) {
|
|
1945
|
+
v(!0);
|
|
1938
1946
|
try {
|
|
1939
|
-
const
|
|
1947
|
+
const M = (await I.updateUser(t.id, {
|
|
1948
|
+
username: i.username || void 0,
|
|
1949
|
+
email: i.email || void 0,
|
|
1940
1950
|
phone: i.phone || void 0,
|
|
1941
1951
|
name: i.name,
|
|
1942
1952
|
surname: i.surname || void 0,
|
|
1943
|
-
metadata:
|
|
1944
|
-
recharge_policy:
|
|
1953
|
+
metadata: w,
|
|
1954
|
+
recharge_policy: T
|
|
1945
1955
|
})).user.recharge_policy;
|
|
1946
|
-
if (!(
|
|
1956
|
+
if (!(M?.enabled === T.enabled && (!T.enabled || M.interval_value === T.interval_value && M.interval_unit === T.interval_unit)))
|
|
1947
1957
|
throw new Error(d("users.recharge_policy_not_saved"));
|
|
1948
1958
|
o();
|
|
1949
|
-
} catch (
|
|
1950
|
-
n(
|
|
1959
|
+
} catch (f) {
|
|
1960
|
+
n(f instanceof Error ? f.message : d("error_loading"));
|
|
1951
1961
|
} finally {
|
|
1952
|
-
|
|
1962
|
+
v(!1);
|
|
1953
1963
|
}
|
|
1954
1964
|
}
|
|
1955
1965
|
};
|
|
@@ -1962,7 +1972,7 @@ function pr({
|
|
|
1962
1972
|
"aria-labelledby": "user-form-modal-title",
|
|
1963
1973
|
children: /* @__PURE__ */ r("div", { className: "bg-card rounded-2xl border border-border w-full max-w-xl shadow-2xl overflow-hidden", children: [
|
|
1964
1974
|
/* @__PURE__ */ e("div", { className: "px-6 py-5 border-b border-border bg-muted/20", children: /* @__PURE__ */ e("h3", { id: "user-form-modal-title", className: "text-lg font-bold text-foreground", children: d(t ? "users.edit_user" : "users.add_user") }) }),
|
|
1965
|
-
/* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: t ?
|
|
1975
|
+
/* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: t ? C : p, children: [
|
|
1966
1976
|
/* @__PURE__ */ r("div", { className: "space-y-6 max-h-[60vh] overflow-y-auto px-1 custom-scrollbar", children: [
|
|
1967
1977
|
/* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
1968
1978
|
!t && /* @__PURE__ */ r("div", { children: [
|
|
@@ -1971,41 +1981,47 @@ function pr({
|
|
|
1971
1981
|
X,
|
|
1972
1982
|
{
|
|
1973
1983
|
value: i.accountType,
|
|
1974
|
-
onValueChange: (
|
|
1975
|
-
dir:
|
|
1984
|
+
onValueChange: (m) => b({ ...i, accountType: m }),
|
|
1985
|
+
dir: L ? "rtl" : "ltr",
|
|
1976
1986
|
children: [
|
|
1977
1987
|
/* @__PURE__ */ e(Y, { 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(ee, {}) }),
|
|
1978
1988
|
/* @__PURE__ */ r(te, { className: "rounded-xl border-border bg-card", children: [
|
|
1979
|
-
/* @__PURE__ */ e(
|
|
1980
|
-
/* @__PURE__ */ e(
|
|
1989
|
+
/* @__PURE__ */ e(O, { value: "human", children: d("users.account_type_human") }),
|
|
1990
|
+
/* @__PURE__ */ e(O, { value: "service", children: d("users.account_type_service") })
|
|
1981
1991
|
] })
|
|
1982
1992
|
]
|
|
1983
1993
|
}
|
|
1984
1994
|
),
|
|
1985
1995
|
i.accountType === "service" && /* @__PURE__ */ e("p", { className: "mt-2 text-xs text-muted-foreground", children: d("users.account_type_service_help") })
|
|
1986
1996
|
] }),
|
|
1987
|
-
|
|
1988
|
-
|
|
1989
|
-
|
|
1990
|
-
|
|
1991
|
-
|
|
1992
|
-
|
|
1993
|
-
|
|
1994
|
-
|
|
1995
|
-
|
|
1996
|
-
|
|
1997
|
-
|
|
1998
|
-
|
|
1999
|
-
|
|
2000
|
-
|
|
2001
|
-
|
|
2002
|
-
|
|
2003
|
-
|
|
2004
|
-
|
|
2005
|
-
|
|
2006
|
-
|
|
2007
|
-
|
|
2008
|
-
|
|
1997
|
+
["username", "email", "phone"].map((m) => {
|
|
1998
|
+
const T = m === x && i.accountType === "human";
|
|
1999
|
+
return /* @__PURE__ */ r("div", { children: [
|
|
2000
|
+
/* @__PURE__ */ r("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: [
|
|
2001
|
+
d(`users.${m}`),
|
|
2002
|
+
!T && /* @__PURE__ */ r("span", { className: "ml-1 normal-case text-muted-foreground/60", children: [
|
|
2003
|
+
"(",
|
|
2004
|
+
d("users.optional"),
|
|
2005
|
+
")"
|
|
2006
|
+
] })
|
|
2007
|
+
] }),
|
|
2008
|
+
/* @__PURE__ */ e(
|
|
2009
|
+
"input",
|
|
2010
|
+
{
|
|
2011
|
+
type: m === "email" ? "email" : "text",
|
|
2012
|
+
value: i[m],
|
|
2013
|
+
onChange: (f) => b({
|
|
2014
|
+
...i,
|
|
2015
|
+
[m]: m === "phone" ? hr(f.target.value) : f.target.value
|
|
2016
|
+
}),
|
|
2017
|
+
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",
|
|
2018
|
+
placeholder: d(`users.${m}_placeholder`, ""),
|
|
2019
|
+
required: T,
|
|
2020
|
+
dir: "ltr"
|
|
2021
|
+
}
|
|
2022
|
+
)
|
|
2023
|
+
] }, m);
|
|
2024
|
+
}),
|
|
2009
2025
|
i.accountType === "service" ? (
|
|
2010
2026
|
// A service account is an integration, not a person: a single service name, no surname.
|
|
2011
2027
|
/* @__PURE__ */ r("div", { children: [
|
|
@@ -2015,8 +2031,8 @@ function pr({
|
|
|
2015
2031
|
{
|
|
2016
2032
|
type: "text",
|
|
2017
2033
|
value: i.name,
|
|
2018
|
-
onChange: (
|
|
2019
|
-
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 ${
|
|
2034
|
+
onChange: (m) => b({ ...i, name: m.target.value }),
|
|
2035
|
+
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 ${N}`,
|
|
2020
2036
|
placeholder: d("users.service_name_placeholder"),
|
|
2021
2037
|
required: !0
|
|
2022
2038
|
}
|
|
@@ -2030,8 +2046,8 @@ function pr({
|
|
|
2030
2046
|
{
|
|
2031
2047
|
type: "text",
|
|
2032
2048
|
value: i.name,
|
|
2033
|
-
onChange: (
|
|
2034
|
-
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 ${
|
|
2049
|
+
onChange: (m) => b({ ...i, name: m.target.value }),
|
|
2050
|
+
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 ${N}`,
|
|
2035
2051
|
required: !0
|
|
2036
2052
|
}
|
|
2037
2053
|
)
|
|
@@ -2043,8 +2059,8 @@ function pr({
|
|
|
2043
2059
|
{
|
|
2044
2060
|
type: "text",
|
|
2045
2061
|
value: i.surname ?? "",
|
|
2046
|
-
onChange: (
|
|
2047
|
-
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 ${
|
|
2062
|
+
onChange: (m) => b({ ...i, surname: m.target.value }),
|
|
2063
|
+
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 ${N}`,
|
|
2048
2064
|
required: !0
|
|
2049
2065
|
}
|
|
2050
2066
|
)
|
|
@@ -2061,7 +2077,7 @@ function pr({
|
|
|
2061
2077
|
{
|
|
2062
2078
|
type: "number",
|
|
2063
2079
|
value: i.tokens,
|
|
2064
|
-
onChange: (
|
|
2080
|
+
onChange: (m) => b({ ...i, tokens: m.target.value }),
|
|
2065
2081
|
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",
|
|
2066
2082
|
dir: "ltr",
|
|
2067
2083
|
placeholder: "0"
|
|
@@ -2075,7 +2091,7 @@ function pr({
|
|
|
2075
2091
|
{
|
|
2076
2092
|
type: "number",
|
|
2077
2093
|
value: i.tokensLimit,
|
|
2078
|
-
onChange: (
|
|
2094
|
+
onChange: (m) => b({ ...i, tokensLimit: m.target.value }),
|
|
2079
2095
|
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",
|
|
2080
2096
|
dir: "ltr",
|
|
2081
2097
|
placeholder: i.tokens || String(a?.initial_balance_tokens ?? "250000")
|
|
@@ -2091,7 +2107,7 @@ function pr({
|
|
|
2091
2107
|
{
|
|
2092
2108
|
type: "number",
|
|
2093
2109
|
value: i.requests,
|
|
2094
|
-
onChange: (
|
|
2110
|
+
onChange: (m) => b({ ...i, requests: m.target.value }),
|
|
2095
2111
|
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",
|
|
2096
2112
|
dir: "ltr",
|
|
2097
2113
|
placeholder: i.requests || String(a?.initial_balance_requests ?? "0")
|
|
@@ -2105,7 +2121,7 @@ function pr({
|
|
|
2105
2121
|
{
|
|
2106
2122
|
type: "number",
|
|
2107
2123
|
value: i.requestsLimit,
|
|
2108
|
-
onChange: (
|
|
2124
|
+
onChange: (m) => b({ ...i, requestsLimit: m.target.value }),
|
|
2109
2125
|
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",
|
|
2110
2126
|
dir: "ltr",
|
|
2111
2127
|
placeholder: i.requests || String(a?.initial_balance_requests ?? "100")
|
|
@@ -2126,9 +2142,9 @@ function pr({
|
|
|
2126
2142
|
{
|
|
2127
2143
|
id: "admin-recharge-enabled",
|
|
2128
2144
|
checked: i.rechargeEnabled,
|
|
2129
|
-
onCheckedChange: (
|
|
2145
|
+
onCheckedChange: (m) => b({
|
|
2130
2146
|
...i,
|
|
2131
|
-
rechargeEnabled:
|
|
2147
|
+
rechargeEnabled: m
|
|
2132
2148
|
}),
|
|
2133
2149
|
"aria-label": d("users.auto_recharge")
|
|
2134
2150
|
}
|
|
@@ -2154,7 +2170,7 @@ function pr({
|
|
|
2154
2170
|
min: "1",
|
|
2155
2171
|
step: "1",
|
|
2156
2172
|
value: i.rechargeIntervalValue,
|
|
2157
|
-
onChange: (
|
|
2173
|
+
onChange: (m) => b({ ...i, rechargeIntervalValue: m.target.value }),
|
|
2158
2174
|
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",
|
|
2159
2175
|
required: !0,
|
|
2160
2176
|
dir: "ltr"
|
|
@@ -2167,14 +2183,14 @@ function pr({
|
|
|
2167
2183
|
X,
|
|
2168
2184
|
{
|
|
2169
2185
|
value: i.rechargeIntervalUnit,
|
|
2170
|
-
onValueChange: (
|
|
2186
|
+
onValueChange: (m) => b({
|
|
2171
2187
|
...i,
|
|
2172
|
-
rechargeIntervalUnit:
|
|
2188
|
+
rechargeIntervalUnit: m
|
|
2173
2189
|
}),
|
|
2174
|
-
dir:
|
|
2190
|
+
dir: L ? "rtl" : "ltr",
|
|
2175
2191
|
children: [
|
|
2176
2192
|
/* @__PURE__ */ e(Y, { 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(ee, {}) }),
|
|
2177
|
-
/* @__PURE__ */ e(te, { className: "rounded-xl border-border bg-card", children: ["minute", "hour", "day", "week", "month"].map((
|
|
2193
|
+
/* @__PURE__ */ e(te, { className: "rounded-xl border-border bg-card", children: ["minute", "hour", "day", "week", "month"].map((m) => /* @__PURE__ */ e(O, { value: m, children: d(`users.recharge_unit_${m}`) }, m)) })
|
|
2178
2194
|
]
|
|
2179
2195
|
}
|
|
2180
2196
|
)
|
|
@@ -2199,83 +2215,83 @@ function pr({
|
|
|
2199
2215
|
] }),
|
|
2200
2216
|
s.length > 0 && /* @__PURE__ */ r("div", { className: "border-t border-border/50 pt-4 mt-4 space-y-4", children: [
|
|
2201
2217
|
/* @__PURE__ */ e("h4", { className: "text-sm font-bold text-foreground/70", children: d("users.custom_fields") }),
|
|
2202
|
-
/* @__PURE__ */ e("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: s.map((
|
|
2218
|
+
/* @__PURE__ */ e("div", { className: "grid grid-cols-1 md:grid-cols-2 gap-4", children: s.map((m) => Ge(m.condition, j) ? /* @__PURE__ */ r(
|
|
2203
2219
|
"div",
|
|
2204
2220
|
{
|
|
2205
2221
|
className: "animate-in fade-in slide-in-from-top-1 duration-200",
|
|
2206
2222
|
children: [
|
|
2207
2223
|
/* @__PURE__ */ r("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider mb-3", children: [
|
|
2208
|
-
d(
|
|
2224
|
+
d(m.label),
|
|
2209
2225
|
" ",
|
|
2210
|
-
|
|
2226
|
+
m.required && /* @__PURE__ */ e("span", { className: "text-destructive", children: "*" })
|
|
2211
2227
|
] }),
|
|
2212
|
-
|
|
2228
|
+
m.type === "select" ? /* @__PURE__ */ r(
|
|
2213
2229
|
X,
|
|
2214
2230
|
{
|
|
2215
|
-
value: String(
|
|
2216
|
-
onValueChange: (
|
|
2217
|
-
...
|
|
2218
|
-
[
|
|
2231
|
+
value: String(j[m.key] || ""),
|
|
2232
|
+
onValueChange: (w) => y({
|
|
2233
|
+
...j,
|
|
2234
|
+
[m.key]: w
|
|
2219
2235
|
}),
|
|
2220
|
-
required:
|
|
2221
|
-
dir:
|
|
2236
|
+
required: m.required,
|
|
2237
|
+
dir: L ? "rtl" : "ltr",
|
|
2222
2238
|
children: [
|
|
2223
2239
|
/* @__PURE__ */ e(
|
|
2224
2240
|
Y,
|
|
2225
2241
|
{
|
|
2226
2242
|
className: Se(
|
|
2227
2243
|
"w-full px-4 py-3 bg-input/50 border border-border rounded-xl text-foreground transition-all text-sm h-[46px]",
|
|
2228
|
-
|
|
2244
|
+
N
|
|
2229
2245
|
),
|
|
2230
2246
|
children: /* @__PURE__ */ e(
|
|
2231
2247
|
ee,
|
|
2232
2248
|
{
|
|
2233
|
-
placeholder: d(
|
|
2249
|
+
placeholder: d(m.placeholder || "select_placeholder")
|
|
2234
2250
|
}
|
|
2235
2251
|
)
|
|
2236
2252
|
}
|
|
2237
2253
|
),
|
|
2238
|
-
/* @__PURE__ */ e(te, { className: "rounded-xl border-border bg-card", children:
|
|
2254
|
+
/* @__PURE__ */ e(te, { className: "rounded-xl border-border bg-card", children: m.options?.map((w) => /* @__PURE__ */ e(O, { value: String(w.value), children: d(w.label) }, String(w.value))) })
|
|
2239
2255
|
]
|
|
2240
2256
|
}
|
|
2241
|
-
) :
|
|
2257
|
+
) : m.type === "checkbox" ? /* @__PURE__ */ r("div", { className: "flex items-center gap-3 h-[46px] px-1", children: [
|
|
2242
2258
|
/* @__PURE__ */ e(
|
|
2243
2259
|
Ce,
|
|
2244
2260
|
{
|
|
2245
|
-
id: `admin-md-${
|
|
2246
|
-
checked: !!
|
|
2247
|
-
onCheckedChange: (
|
|
2248
|
-
...
|
|
2249
|
-
[
|
|
2261
|
+
id: `admin-md-${m.key}`,
|
|
2262
|
+
checked: !!j[m.key],
|
|
2263
|
+
onCheckedChange: (w) => y({
|
|
2264
|
+
...j,
|
|
2265
|
+
[m.key]: !!w
|
|
2250
2266
|
}),
|
|
2251
|
-
required:
|
|
2267
|
+
required: m.required
|
|
2252
2268
|
}
|
|
2253
2269
|
),
|
|
2254
2270
|
/* @__PURE__ */ e(
|
|
2255
2271
|
"label",
|
|
2256
2272
|
{
|
|
2257
|
-
htmlFor: `admin-md-${
|
|
2273
|
+
htmlFor: `admin-md-${m.key}`,
|
|
2258
2274
|
className: "text-sm text-foreground/80 cursor-pointer select-none",
|
|
2259
|
-
children: d(
|
|
2275
|
+
children: d(m.placeholder || m.label)
|
|
2260
2276
|
}
|
|
2261
2277
|
)
|
|
2262
2278
|
] }) : /* @__PURE__ */ e(
|
|
2263
2279
|
"input",
|
|
2264
2280
|
{
|
|
2265
|
-
type:
|
|
2266
|
-
value:
|
|
2267
|
-
onChange: (
|
|
2268
|
-
...
|
|
2269
|
-
[
|
|
2281
|
+
type: m.type,
|
|
2282
|
+
value: j[m.key] || "",
|
|
2283
|
+
onChange: (w) => y({
|
|
2284
|
+
...j,
|
|
2285
|
+
[m.key]: w.target.value
|
|
2270
2286
|
}),
|
|
2271
|
-
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 ${
|
|
2272
|
-
placeholder: d(
|
|
2273
|
-
required:
|
|
2287
|
+
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 ${N}`,
|
|
2288
|
+
placeholder: d(m.placeholder || ""),
|
|
2289
|
+
required: m.required
|
|
2274
2290
|
}
|
|
2275
2291
|
)
|
|
2276
2292
|
]
|
|
2277
2293
|
},
|
|
2278
|
-
|
|
2294
|
+
m.key
|
|
2279
2295
|
) : null) })
|
|
2280
2296
|
] }),
|
|
2281
2297
|
/* @__PURE__ */ r("div", { className: "border-t border-border/50 pt-4 mt-4", children: [
|
|
@@ -2287,7 +2303,7 @@ function pr({
|
|
|
2287
2303
|
"textarea",
|
|
2288
2304
|
{
|
|
2289
2305
|
value: i.metadata,
|
|
2290
|
-
onChange: (
|
|
2306
|
+
onChange: (m) => b({ ...i, metadata: m.target.value }),
|
|
2291
2307
|
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",
|
|
2292
2308
|
placeholder: '{ "key": "value" }',
|
|
2293
2309
|
dir: "ltr"
|
|
@@ -2309,9 +2325,9 @@ function pr({
|
|
|
2309
2325
|
"button",
|
|
2310
2326
|
{
|
|
2311
2327
|
type: "submit",
|
|
2312
|
-
disabled:
|
|
2328
|
+
disabled: h,
|
|
2313
2329
|
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",
|
|
2314
|
-
children: d(
|
|
2330
|
+
children: d(h ? "saving" : "save")
|
|
2315
2331
|
}
|
|
2316
2332
|
)
|
|
2317
2333
|
] })
|
|
@@ -2344,30 +2360,30 @@ function ct({ onClick: t, label: a = "Close" }) {
|
|
|
2344
2360
|
);
|
|
2345
2361
|
}
|
|
2346
2362
|
function gr({ user: t, onClose: a, onSaved: s, onError: l }) {
|
|
2347
|
-
const { t: o } =
|
|
2348
|
-
|
|
2349
|
-
},
|
|
2350
|
-
|
|
2351
|
-
const
|
|
2352
|
-
if (
|
|
2363
|
+
const { t: o } = P(["admin", "translation"]), [n, d] = _(!1), [g, k] = _(String(t.balance?.tokens || 0)), [L, N] = _(String(t.balance?.requests || 0)), [x, h] = _(String(t.balance?.token_limit || 0)), [v, i] = _(String(t.balance?.request_limit || 0)), b = () => {
|
|
2364
|
+
k(x || String(t.balance?.token_limit || 0)), N(v || String(t.balance?.request_limit || 0));
|
|
2365
|
+
}, j = async (y) => {
|
|
2366
|
+
y.preventDefault();
|
|
2367
|
+
const E = parseInt(g) || 0, p = parseInt(L) || 0, C = x ? parseInt(x) : t.balance?.token_limit || 0, m = v ? parseInt(v) : t.balance?.request_limit || 0;
|
|
2368
|
+
if (E > C) {
|
|
2353
2369
|
l(o("users.tokens_exceed_limit", "Tokens cannot exceed limit"));
|
|
2354
2370
|
return;
|
|
2355
2371
|
}
|
|
2356
|
-
if (
|
|
2372
|
+
if (p > m) {
|
|
2357
2373
|
l(o("users.requests_exceed_limit", "Requests cannot exceed limit"));
|
|
2358
2374
|
return;
|
|
2359
2375
|
}
|
|
2360
2376
|
d(!0);
|
|
2361
2377
|
try {
|
|
2362
|
-
await
|
|
2378
|
+
await I.updateUserBalance(
|
|
2363
2379
|
t.id,
|
|
2364
|
-
|
|
2365
|
-
|
|
2380
|
+
E,
|
|
2381
|
+
p,
|
|
2366
2382
|
x ? parseInt(x) : void 0,
|
|
2367
|
-
|
|
2383
|
+
v ? parseInt(v) : void 0
|
|
2368
2384
|
), s();
|
|
2369
|
-
} catch (
|
|
2370
|
-
l(
|
|
2385
|
+
} catch (w) {
|
|
2386
|
+
l(w instanceof Error ? w.message : o("error_loading"));
|
|
2371
2387
|
} finally {
|
|
2372
2388
|
d(!1);
|
|
2373
2389
|
}
|
|
@@ -2388,7 +2404,7 @@ function gr({ user: t, onClose: a, onSaved: s, onError: l }) {
|
|
|
2388
2404
|
] }),
|
|
2389
2405
|
/* @__PURE__ */ e(ct, { onClick: a })
|
|
2390
2406
|
] }),
|
|
2391
|
-
/* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit:
|
|
2407
|
+
/* @__PURE__ */ e("div", { className: "p-8", children: /* @__PURE__ */ r("form", { onSubmit: j, children: [
|
|
2392
2408
|
/* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
2393
2409
|
/* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-4", children: [
|
|
2394
2410
|
/* @__PURE__ */ r("div", { children: [
|
|
@@ -2398,7 +2414,7 @@ function gr({ user: t, onClose: a, onSaved: s, onError: l }) {
|
|
|
2398
2414
|
{
|
|
2399
2415
|
type: "number",
|
|
2400
2416
|
value: g,
|
|
2401
|
-
onChange: (
|
|
2417
|
+
onChange: (y) => k(y.target.value),
|
|
2402
2418
|
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",
|
|
2403
2419
|
required: !0,
|
|
2404
2420
|
dir: "ltr"
|
|
@@ -2412,7 +2428,7 @@ function gr({ user: t, onClose: a, onSaved: s, onError: l }) {
|
|
|
2412
2428
|
{
|
|
2413
2429
|
type: "number",
|
|
2414
2430
|
value: x,
|
|
2415
|
-
onChange: (
|
|
2431
|
+
onChange: (y) => h(y.target.value),
|
|
2416
2432
|
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",
|
|
2417
2433
|
dir: "ltr",
|
|
2418
2434
|
placeholder: g
|
|
@@ -2427,8 +2443,8 @@ function gr({ user: t, onClose: a, onSaved: s, onError: l }) {
|
|
|
2427
2443
|
"input",
|
|
2428
2444
|
{
|
|
2429
2445
|
type: "number",
|
|
2430
|
-
value:
|
|
2431
|
-
onChange: (
|
|
2446
|
+
value: L,
|
|
2447
|
+
onChange: (y) => N(y.target.value),
|
|
2432
2448
|
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",
|
|
2433
2449
|
required: !0,
|
|
2434
2450
|
dir: "ltr"
|
|
@@ -2441,11 +2457,11 @@ function gr({ user: t, onClose: a, onSaved: s, onError: l }) {
|
|
|
2441
2457
|
"input",
|
|
2442
2458
|
{
|
|
2443
2459
|
type: "number",
|
|
2444
|
-
value:
|
|
2445
|
-
onChange: (
|
|
2460
|
+
value: v,
|
|
2461
|
+
onChange: (y) => i(y.target.value),
|
|
2446
2462
|
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",
|
|
2447
2463
|
dir: "ltr",
|
|
2448
|
-
placeholder:
|
|
2464
|
+
placeholder: L
|
|
2449
2465
|
}
|
|
2450
2466
|
)
|
|
2451
2467
|
] })
|
|
@@ -2456,7 +2472,7 @@ function gr({ user: t, onClose: a, onSaved: s, onError: l }) {
|
|
|
2456
2472
|
"button",
|
|
2457
2473
|
{
|
|
2458
2474
|
type: "button",
|
|
2459
|
-
onClick:
|
|
2475
|
+
onClick: b,
|
|
2460
2476
|
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",
|
|
2461
2477
|
children: o("users.full_charge")
|
|
2462
2478
|
}
|
|
@@ -2499,81 +2515,81 @@ function br({
|
|
|
2499
2515
|
onApplied: l,
|
|
2500
2516
|
onError: o
|
|
2501
2517
|
}) {
|
|
2502
|
-
const { t: n, i18n: d } =
|
|
2503
|
-
let
|
|
2504
|
-
if (
|
|
2518
|
+
const { t: n, i18n: d } = P(["admin", "translation"]), g = d.language === "fa", [k, L] = _(!1), [N, x] = _(null), [h, v] = _(fr), i = () => {
|
|
2519
|
+
let p = {};
|
|
2520
|
+
if (h.metadata.trim())
|
|
2505
2521
|
try {
|
|
2506
|
-
|
|
2522
|
+
p = JSON.parse(h.metadata);
|
|
2507
2523
|
} catch {
|
|
2508
2524
|
return o(n("users.invalid_json", "Invalid JSON format")), null;
|
|
2509
2525
|
}
|
|
2510
|
-
const
|
|
2511
|
-
Object.entries(
|
|
2512
|
-
Array.isArray(
|
|
2526
|
+
const C = {};
|
|
2527
|
+
Object.entries(p).forEach(([w, T]) => {
|
|
2528
|
+
Array.isArray(T) ? C[w] = T : T !== "" && T !== void 0 && T !== null && (C[w] = [T]);
|
|
2513
2529
|
});
|
|
2514
|
-
const
|
|
2530
|
+
const m = h.userIds.split(/[\s,]+/).map((w) => w.trim()).filter(Boolean);
|
|
2515
2531
|
return {
|
|
2516
|
-
query:
|
|
2517
|
-
user_ids:
|
|
2518
|
-
metadata_in: Object.keys(
|
|
2532
|
+
query: h.useCurrentSearch && t || void 0,
|
|
2533
|
+
user_ids: m.length > 0 ? m : void 0,
|
|
2534
|
+
metadata_in: Object.keys(C).length > 0 ? C : void 0
|
|
2519
2535
|
};
|
|
2520
|
-
},
|
|
2521
|
-
const
|
|
2522
|
-
return
|
|
2523
|
-
operation:
|
|
2524
|
-
tokens:
|
|
2525
|
-
requests:
|
|
2526
|
-
token_limit:
|
|
2527
|
-
request_limit:
|
|
2528
|
-
filters:
|
|
2529
|
-
dry_run:
|
|
2536
|
+
}, b = (p) => {
|
|
2537
|
+
const C = i();
|
|
2538
|
+
return C ? {
|
|
2539
|
+
operation: h.operation,
|
|
2540
|
+
tokens: h.tokens === "" ? void 0 : Number(h.tokens),
|
|
2541
|
+
requests: h.requests === "" ? void 0 : Number(h.requests),
|
|
2542
|
+
token_limit: h.tokenLimit === "" ? void 0 : Number(h.tokenLimit),
|
|
2543
|
+
request_limit: h.requestLimit === "" ? void 0 : Number(h.requestLimit),
|
|
2544
|
+
filters: C,
|
|
2545
|
+
dry_run: p
|
|
2530
2546
|
} : null;
|
|
2531
|
-
},
|
|
2532
|
-
const
|
|
2533
|
-
if (!
|
|
2534
|
-
if (!
|
|
2547
|
+
}, j = (p) => {
|
|
2548
|
+
const C = i();
|
|
2549
|
+
if (!C) return null;
|
|
2550
|
+
if (!h.renewalEnabled)
|
|
2535
2551
|
return {
|
|
2536
2552
|
recharge_policy: { enabled: !1 },
|
|
2537
|
-
filters:
|
|
2538
|
-
dry_run:
|
|
2553
|
+
filters: C,
|
|
2554
|
+
dry_run: p
|
|
2539
2555
|
};
|
|
2540
|
-
const
|
|
2541
|
-
return !Number.isInteger(
|
|
2556
|
+
const m = Number(h.renewalIntervalValue);
|
|
2557
|
+
return !Number.isInteger(m) || m <= 0 ? (o(n("users.recharge_interval_invalid")), null) : {
|
|
2542
2558
|
recharge_policy: {
|
|
2543
2559
|
enabled: !0,
|
|
2544
|
-
interval_value:
|
|
2545
|
-
interval_unit:
|
|
2560
|
+
interval_value: m,
|
|
2561
|
+
interval_unit: h.renewalIntervalUnit,
|
|
2546
2562
|
// When blank, default to the next round boundary of the interval in the admin's
|
|
2547
2563
|
// local time (e.g. next local midnight for daily) rather than the request time.
|
|
2548
|
-
anchor_at:
|
|
2564
|
+
anchor_at: h.renewalAnchorAt ? new Date(h.renewalAnchorAt).toISOString() : dt(h.renewalIntervalUnit)
|
|
2549
2565
|
},
|
|
2550
|
-
filters:
|
|
2551
|
-
dry_run:
|
|
2566
|
+
filters: C,
|
|
2567
|
+
dry_run: p
|
|
2552
2568
|
};
|
|
2553
|
-
},
|
|
2554
|
-
if (
|
|
2555
|
-
const
|
|
2556
|
-
return
|
|
2569
|
+
}, y = async () => {
|
|
2570
|
+
if (h.applyRenewal && !h.applyBalance) {
|
|
2571
|
+
const m = j(!0);
|
|
2572
|
+
return m ? (await I.bulkUpdateUserRenewal(m)).matched : null;
|
|
2557
2573
|
}
|
|
2558
|
-
const
|
|
2559
|
-
return
|
|
2560
|
-
},
|
|
2561
|
-
if (
|
|
2574
|
+
const p = b(!0);
|
|
2575
|
+
return p ? (await I.bulkUpdateUserBalance(p)).matched : null;
|
|
2576
|
+
}, E = async (p) => {
|
|
2577
|
+
if (p.preventDefault(), !h.applyBalance && !h.applyRenewal) {
|
|
2562
2578
|
o(n("users.bulk_select_change"));
|
|
2563
2579
|
return;
|
|
2564
2580
|
}
|
|
2565
|
-
const
|
|
2566
|
-
if (!(
|
|
2567
|
-
|
|
2581
|
+
const C = h.applyBalance ? b(!1) : null, m = h.applyRenewal ? j(!1) : null;
|
|
2582
|
+
if (!(h.applyBalance && !C) && !(h.applyRenewal && !m)) {
|
|
2583
|
+
L(!0);
|
|
2568
2584
|
try {
|
|
2569
|
-
const
|
|
2570
|
-
if (
|
|
2571
|
-
const
|
|
2572
|
-
x((
|
|
2573
|
-
} catch (
|
|
2574
|
-
o(
|
|
2585
|
+
const w = await y();
|
|
2586
|
+
if (w === null || (x(w), !confirm(n("users.bulk_balance_confirm", { count: w })))) return;
|
|
2587
|
+
const f = C ? await I.bulkUpdateUserBalance(C) : null, M = m ? await I.bulkUpdateUserRenewal(m) : null;
|
|
2588
|
+
x((M || f)?.matched ?? null), l();
|
|
2589
|
+
} catch (w) {
|
|
2590
|
+
o(w instanceof Error ? w.message : n("error_loading"));
|
|
2575
2591
|
} finally {
|
|
2576
|
-
|
|
2592
|
+
L(!1);
|
|
2577
2593
|
}
|
|
2578
2594
|
}
|
|
2579
2595
|
};
|
|
@@ -2592,16 +2608,16 @@ function br({
|
|
|
2592
2608
|
] }),
|
|
2593
2609
|
/* @__PURE__ */ e(ct, { onClick: s })
|
|
2594
2610
|
] }),
|
|
2595
|
-
/* @__PURE__ */ r("form", { onSubmit:
|
|
2611
|
+
/* @__PURE__ */ r("form", { onSubmit: E, className: "flex min-h-0 flex-1 flex-col", children: [
|
|
2596
2612
|
/* @__PURE__ */ r("div", { className: "min-h-0 flex-1 overflow-y-auto px-5 py-4 space-y-4 custom-scrollbar", children: [
|
|
2597
2613
|
/* @__PURE__ */ r("div", { className: "grid grid-cols-1 sm:grid-cols-2 gap-3", children: [
|
|
2598
2614
|
/* @__PURE__ */ r("label", { className: "flex items-center gap-3 rounded-lg border border-border bg-muted/10 px-3 py-2.5 text-sm text-foreground cursor-pointer", children: [
|
|
2599
2615
|
/* @__PURE__ */ e(
|
|
2600
2616
|
Ce,
|
|
2601
2617
|
{
|
|
2602
|
-
checked:
|
|
2603
|
-
onCheckedChange: (
|
|
2604
|
-
|
|
2618
|
+
checked: h.applyBalance,
|
|
2619
|
+
onCheckedChange: (p) => {
|
|
2620
|
+
v({ ...h, applyBalance: !!p }), x(null);
|
|
2605
2621
|
}
|
|
2606
2622
|
}
|
|
2607
2623
|
),
|
|
@@ -2611,9 +2627,9 @@ function br({
|
|
|
2611
2627
|
/* @__PURE__ */ e(
|
|
2612
2628
|
Ce,
|
|
2613
2629
|
{
|
|
2614
|
-
checked:
|
|
2615
|
-
onCheckedChange: (
|
|
2616
|
-
|
|
2630
|
+
checked: h.applyRenewal,
|
|
2631
|
+
onCheckedChange: (p) => {
|
|
2632
|
+
v({ ...h, applyRenewal: !!p }), x(null);
|
|
2617
2633
|
}
|
|
2618
2634
|
}
|
|
2619
2635
|
),
|
|
@@ -2626,20 +2642,20 @@ function br({
|
|
|
2626
2642
|
/* @__PURE__ */ r(
|
|
2627
2643
|
X,
|
|
2628
2644
|
{
|
|
2629
|
-
value:
|
|
2630
|
-
onValueChange: (
|
|
2631
|
-
|
|
2632
|
-
...
|
|
2633
|
-
operation:
|
|
2645
|
+
value: h.operation,
|
|
2646
|
+
onValueChange: (p) => {
|
|
2647
|
+
v({
|
|
2648
|
+
...h,
|
|
2649
|
+
operation: p
|
|
2634
2650
|
}), x(null);
|
|
2635
2651
|
},
|
|
2636
2652
|
dir: g ? "rtl" : "ltr",
|
|
2637
2653
|
children: [
|
|
2638
2654
|
/* @__PURE__ */ e(Y, { className: "w-full px-3 bg-input/50 border border-border rounded-lg text-foreground transition-all text-sm h-10", children: /* @__PURE__ */ e(ee, {}) }),
|
|
2639
2655
|
/* @__PURE__ */ r(te, { className: "rounded-lg border-border bg-card", children: [
|
|
2640
|
-
/* @__PURE__ */ e(
|
|
2641
|
-
/* @__PURE__ */ e(
|
|
2642
|
-
/* @__PURE__ */ e(
|
|
2656
|
+
/* @__PURE__ */ e(O, { value: "add", children: n("users.bulk_operation_add") }),
|
|
2657
|
+
/* @__PURE__ */ e(O, { value: "set", children: n("users.bulk_operation_set") }),
|
|
2658
|
+
/* @__PURE__ */ e(O, { value: "full_charge", children: n("users.bulk_operation_full_charge") })
|
|
2643
2659
|
] })
|
|
2644
2660
|
]
|
|
2645
2661
|
}
|
|
@@ -2650,29 +2666,29 @@ function br({
|
|
|
2650
2666
|
Ce,
|
|
2651
2667
|
{
|
|
2652
2668
|
id: "bulk-use-search",
|
|
2653
|
-
checked:
|
|
2654
|
-
onCheckedChange: (
|
|
2655
|
-
|
|
2669
|
+
checked: h.useCurrentSearch,
|
|
2670
|
+
onCheckedChange: (p) => {
|
|
2671
|
+
v({ ...h, useCurrentSearch: !!p }), x(null);
|
|
2656
2672
|
}
|
|
2657
2673
|
}
|
|
2658
2674
|
),
|
|
2659
2675
|
/* @__PURE__ */ e("label", { htmlFor: "bulk-use-search", className: "text-sm text-foreground cursor-pointer", children: n("users.bulk_use_current_search") })
|
|
2660
2676
|
] })
|
|
2661
2677
|
] }),
|
|
2662
|
-
|
|
2678
|
+
h.applyBalance && /* @__PURE__ */ r("div", { className: "grid grid-cols-2 lg:grid-cols-4 gap-3", children: [
|
|
2663
2679
|
/* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
|
|
2664
2680
|
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider", children: n("users.token_count") }),
|
|
2665
2681
|
/* @__PURE__ */ e(
|
|
2666
2682
|
"input",
|
|
2667
2683
|
{
|
|
2668
2684
|
type: "number",
|
|
2669
|
-
value:
|
|
2670
|
-
onChange: (
|
|
2671
|
-
|
|
2685
|
+
value: h.tokens,
|
|
2686
|
+
onChange: (p) => {
|
|
2687
|
+
v({ ...h, tokens: p.target.value }), x(null);
|
|
2672
2688
|
},
|
|
2673
2689
|
className: "w-full h-10 px-3 bg-input/50 border border-border rounded-lg text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
|
|
2674
|
-
disabled:
|
|
2675
|
-
required:
|
|
2690
|
+
disabled: h.operation === "full_charge",
|
|
2691
|
+
required: h.operation === "set",
|
|
2676
2692
|
dir: "ltr"
|
|
2677
2693
|
}
|
|
2678
2694
|
)
|
|
@@ -2683,13 +2699,13 @@ function br({
|
|
|
2683
2699
|
"input",
|
|
2684
2700
|
{
|
|
2685
2701
|
type: "number",
|
|
2686
|
-
value:
|
|
2687
|
-
onChange: (
|
|
2688
|
-
|
|
2702
|
+
value: h.requests,
|
|
2703
|
+
onChange: (p) => {
|
|
2704
|
+
v({ ...h, requests: p.target.value }), x(null);
|
|
2689
2705
|
},
|
|
2690
2706
|
className: "w-full h-10 px-3 bg-input/50 border border-border rounded-lg text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
|
|
2691
|
-
disabled:
|
|
2692
|
-
required:
|
|
2707
|
+
disabled: h.operation === "full_charge",
|
|
2708
|
+
required: h.operation === "set",
|
|
2693
2709
|
dir: "ltr"
|
|
2694
2710
|
}
|
|
2695
2711
|
)
|
|
@@ -2700,9 +2716,9 @@ function br({
|
|
|
2700
2716
|
"input",
|
|
2701
2717
|
{
|
|
2702
2718
|
type: "number",
|
|
2703
|
-
value:
|
|
2704
|
-
onChange: (
|
|
2705
|
-
|
|
2719
|
+
value: h.tokenLimit,
|
|
2720
|
+
onChange: (p) => {
|
|
2721
|
+
v({ ...h, tokenLimit: p.target.value }), x(null);
|
|
2706
2722
|
},
|
|
2707
2723
|
className: "w-full h-10 px-3 bg-input/50 border border-border rounded-lg text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
|
|
2708
2724
|
dir: "ltr"
|
|
@@ -2715,9 +2731,9 @@ function br({
|
|
|
2715
2731
|
"input",
|
|
2716
2732
|
{
|
|
2717
2733
|
type: "number",
|
|
2718
|
-
value:
|
|
2719
|
-
onChange: (
|
|
2720
|
-
|
|
2734
|
+
value: h.requestLimit,
|
|
2735
|
+
onChange: (p) => {
|
|
2736
|
+
v({ ...h, requestLimit: p.target.value }), x(null);
|
|
2721
2737
|
},
|
|
2722
2738
|
className: "w-full h-10 px-3 bg-input/50 border border-border rounded-lg text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
|
|
2723
2739
|
dir: "ltr"
|
|
@@ -2725,7 +2741,7 @@ function br({
|
|
|
2725
2741
|
)
|
|
2726
2742
|
] })
|
|
2727
2743
|
] }),
|
|
2728
|
-
|
|
2744
|
+
h.applyRenewal && /* @__PURE__ */ r("div", { className: "space-y-3 rounded-lg border border-border/60 bg-muted/10 p-3", children: [
|
|
2729
2745
|
/* @__PURE__ */ r("div", { className: "flex items-center justify-between gap-3", children: [
|
|
2730
2746
|
/* @__PURE__ */ r("div", { children: [
|
|
2731
2747
|
/* @__PURE__ */ e("h4", { className: "text-sm font-bold text-foreground/80", children: n("users.bulk_renewal_policy") }),
|
|
@@ -2735,16 +2751,16 @@ function br({
|
|
|
2735
2751
|
/* @__PURE__ */ e(
|
|
2736
2752
|
le,
|
|
2737
2753
|
{
|
|
2738
|
-
checked:
|
|
2739
|
-
onCheckedChange: (
|
|
2740
|
-
|
|
2754
|
+
checked: h.renewalEnabled,
|
|
2755
|
+
onCheckedChange: (p) => {
|
|
2756
|
+
v({ ...h, renewalEnabled: p }), x(null);
|
|
2741
2757
|
}
|
|
2742
2758
|
}
|
|
2743
2759
|
),
|
|
2744
2760
|
/* @__PURE__ */ e("span", { className: "text-sm text-foreground", children: n("users.enabled") })
|
|
2745
2761
|
] })
|
|
2746
2762
|
] }),
|
|
2747
|
-
|
|
2763
|
+
h.renewalEnabled && /* @__PURE__ */ r("div", { className: "grid grid-cols-1 md:grid-cols-3 gap-3", children: [
|
|
2748
2764
|
/* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
|
|
2749
2765
|
/* @__PURE__ */ e("label", { className: "block text-xs font-medium text-muted-foreground uppercase tracking-wider", children: n("users.recharge_interval") }),
|
|
2750
2766
|
/* @__PURE__ */ e(
|
|
@@ -2753,9 +2769,9 @@ function br({
|
|
|
2753
2769
|
type: "number",
|
|
2754
2770
|
min: "1",
|
|
2755
2771
|
step: "1",
|
|
2756
|
-
value:
|
|
2757
|
-
onChange: (
|
|
2758
|
-
|
|
2772
|
+
value: h.renewalIntervalValue,
|
|
2773
|
+
onChange: (p) => {
|
|
2774
|
+
v({ ...h, renewalIntervalValue: p.target.value }), x(null);
|
|
2759
2775
|
},
|
|
2760
2776
|
className: "w-full h-10 px-3 bg-input/50 border border-border rounded-lg text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
|
|
2761
2777
|
required: !0,
|
|
@@ -2768,17 +2784,17 @@ function br({
|
|
|
2768
2784
|
/* @__PURE__ */ r(
|
|
2769
2785
|
X,
|
|
2770
2786
|
{
|
|
2771
|
-
value:
|
|
2772
|
-
onValueChange: (
|
|
2773
|
-
|
|
2774
|
-
...
|
|
2775
|
-
renewalIntervalUnit:
|
|
2787
|
+
value: h.renewalIntervalUnit,
|
|
2788
|
+
onValueChange: (p) => {
|
|
2789
|
+
v({
|
|
2790
|
+
...h,
|
|
2791
|
+
renewalIntervalUnit: p
|
|
2776
2792
|
}), x(null);
|
|
2777
2793
|
},
|
|
2778
2794
|
dir: g ? "rtl" : "ltr",
|
|
2779
2795
|
children: [
|
|
2780
2796
|
/* @__PURE__ */ e(Y, { className: "w-full px-3 bg-input/50 border border-border rounded-lg text-foreground transition-all text-sm h-10", children: /* @__PURE__ */ e(ee, {}) }),
|
|
2781
|
-
/* @__PURE__ */ e(te, { className: "rounded-lg border-border bg-card", children: ["minute", "hour", "day", "week", "month"].map((
|
|
2797
|
+
/* @__PURE__ */ e(te, { className: "rounded-lg border-border bg-card", children: ["minute", "hour", "day", "week", "month"].map((p) => /* @__PURE__ */ e(O, { value: p, children: n(`users.recharge_unit_${p}`) }, p)) })
|
|
2782
2798
|
]
|
|
2783
2799
|
}
|
|
2784
2800
|
)
|
|
@@ -2789,9 +2805,9 @@ function br({
|
|
|
2789
2805
|
"input",
|
|
2790
2806
|
{
|
|
2791
2807
|
type: "datetime-local",
|
|
2792
|
-
value:
|
|
2793
|
-
onChange: (
|
|
2794
|
-
|
|
2808
|
+
value: h.renewalAnchorAt,
|
|
2809
|
+
onChange: (p) => {
|
|
2810
|
+
v({ ...h, renewalAnchorAt: p.target.value }), x(null);
|
|
2795
2811
|
},
|
|
2796
2812
|
className: "w-full h-10 px-3 bg-input/50 border border-border rounded-lg text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-sm text-left",
|
|
2797
2813
|
dir: "ltr"
|
|
@@ -2806,9 +2822,9 @@ function br({
|
|
|
2806
2822
|
/* @__PURE__ */ e(
|
|
2807
2823
|
"textarea",
|
|
2808
2824
|
{
|
|
2809
|
-
value:
|
|
2810
|
-
onChange: (
|
|
2811
|
-
|
|
2825
|
+
value: h.userIds,
|
|
2826
|
+
onChange: (p) => {
|
|
2827
|
+
v({ ...h, userIds: p.target.value }), x(null);
|
|
2812
2828
|
},
|
|
2813
2829
|
className: "w-full px-3 py-2 bg-input/50 border border-border rounded-lg text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-xs font-mono min-h-[58px]",
|
|
2814
2830
|
placeholder: "user_abc, user_xyz",
|
|
@@ -2821,9 +2837,9 @@ function br({
|
|
|
2821
2837
|
/* @__PURE__ */ e(
|
|
2822
2838
|
"textarea",
|
|
2823
2839
|
{
|
|
2824
|
-
value:
|
|
2825
|
-
onChange: (
|
|
2826
|
-
|
|
2840
|
+
value: h.metadata,
|
|
2841
|
+
onChange: (p) => {
|
|
2842
|
+
v({ ...h, metadata: p.target.value }), x(null);
|
|
2827
2843
|
},
|
|
2828
2844
|
className: "w-full px-3 py-2 bg-input/50 border border-border rounded-lg text-foreground focus:ring-2 focus:ring-ring focus:border-transparent transition-all text-xs font-mono min-h-[58px]",
|
|
2829
2845
|
placeholder: '{ "grade": ["10", "11"], "major": ["math", "science"] }',
|
|
@@ -2834,20 +2850,20 @@ function br({
|
|
|
2834
2850
|
n("users.bulk_available_metadata"),
|
|
2835
2851
|
":",
|
|
2836
2852
|
" ",
|
|
2837
|
-
a.map((
|
|
2853
|
+
a.map((p) => p.key).join(", ")
|
|
2838
2854
|
] })
|
|
2839
2855
|
] })
|
|
2840
2856
|
] })
|
|
2841
2857
|
] }),
|
|
2842
2858
|
/* @__PURE__ */ r("div", { className: "shrink-0 border-t border-border bg-card/95 px-5 py-3 flex flex-col sm:flex-row items-center justify-between gap-3", children: [
|
|
2843
|
-
/* @__PURE__ */ e("div", { className: "text-sm text-muted-foreground", children:
|
|
2859
|
+
/* @__PURE__ */ e("div", { className: "text-sm text-muted-foreground", children: N === null ? n("users.bulk_preview_empty") : n("users.bulk_preview_count", { count: N }) }),
|
|
2844
2860
|
/* @__PURE__ */ e("div", { className: "flex gap-3 w-full sm:w-auto", children: /* @__PURE__ */ e(
|
|
2845
2861
|
"button",
|
|
2846
2862
|
{
|
|
2847
2863
|
type: "submit",
|
|
2848
|
-
disabled:
|
|
2864
|
+
disabled: k,
|
|
2849
2865
|
className: "flex-1 sm:flex-none px-5 py-2.5 bg-primary text-primary-foreground rounded-lg text-sm font-bold hover:opacity-90 transition-all shadow-md disabled:opacity-50",
|
|
2850
|
-
children: n(
|
|
2866
|
+
children: n(k ? "users.updating" : "users.apply_bulk_balance")
|
|
2851
2867
|
}
|
|
2852
2868
|
) })
|
|
2853
2869
|
] })
|
|
@@ -2857,25 +2873,25 @@ function br({
|
|
|
2857
2873
|
);
|
|
2858
2874
|
}
|
|
2859
2875
|
function xr({ user: t, onClose: a, onError: s }) {
|
|
2860
|
-
const { t: l, i18n: o } =
|
|
2876
|
+
const { t: l, i18n: o } = P(["admin", "translation"]), n = o.language === "fa" ? "fa-IR" : "en-US", [d, g] = _(null), [k, L] = _(!1);
|
|
2861
2877
|
return H(() => {
|
|
2862
2878
|
if (!t) return;
|
|
2863
|
-
let
|
|
2864
|
-
return g(null),
|
|
2865
|
-
|
|
2879
|
+
let N = !1;
|
|
2880
|
+
return g(null), L(!0), I.getUserUsageSummary(t.id).then((x) => {
|
|
2881
|
+
N || g(x);
|
|
2866
2882
|
}).catch((x) => {
|
|
2867
|
-
|
|
2883
|
+
N || (s(x instanceof Error ? x.message : l("error_loading")), a());
|
|
2868
2884
|
}).finally(() => {
|
|
2869
|
-
|
|
2885
|
+
N || L(!1);
|
|
2870
2886
|
}), () => {
|
|
2871
|
-
|
|
2887
|
+
N = !0;
|
|
2872
2888
|
};
|
|
2873
|
-
}, [t]), /* @__PURE__ */ e(Le, { open: !!t, onOpenChange: (
|
|
2889
|
+
}, [t]), /* @__PURE__ */ e(Le, { open: !!t, onOpenChange: (N) => !N && a(), children: /* @__PURE__ */ r(je, { children: [
|
|
2874
2890
|
/* @__PURE__ */ r(Te, { children: [
|
|
2875
2891
|
/* @__PURE__ */ e(Ae, { children: l("users.usage_summary") }),
|
|
2876
2892
|
/* @__PURE__ */ e(Ie, { children: t ? `${t.name} ${t.surname}` : "" })
|
|
2877
2893
|
] }),
|
|
2878
|
-
|
|
2894
|
+
k ? /* @__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" }) }) : d ? /* @__PURE__ */ e("div", { className: "grid grid-cols-2 gap-3", children: [
|
|
2879
2895
|
[l("users.input_tokens"), d.input_tokens.toLocaleString(n)],
|
|
2880
2896
|
[l("users.output_tokens"), d.output_tokens.toLocaleString(n)],
|
|
2881
2897
|
[l("users.total_tokens"), d.total_tokens.toLocaleString(n)],
|
|
@@ -2886,42 +2902,42 @@ function xr({ user: t, onClose: a, onError: s }) {
|
|
|
2886
2902
|
],
|
|
2887
2903
|
[l("users.renewals"), d.renewal_count.toLocaleString(n)],
|
|
2888
2904
|
[l("users.unpriced_requests"), d.unpriced_requests.toLocaleString(n)]
|
|
2889
|
-
].map(([
|
|
2890
|
-
/* @__PURE__ */ e("p", { className: "text-[10px] uppercase tracking-wider text-muted-foreground", children:
|
|
2905
|
+
].map(([N, x]) => /* @__PURE__ */ r("div", { className: "rounded-xl border border-border bg-muted/20 p-4", children: [
|
|
2906
|
+
/* @__PURE__ */ e("p", { className: "text-[10px] uppercase tracking-wider text-muted-foreground", children: N }),
|
|
2891
2907
|
/* @__PURE__ */ e("p", { className: "mt-1 text-lg font-semibold text-foreground", children: x })
|
|
2892
|
-
] },
|
|
2908
|
+
] }, N)) }) : null
|
|
2893
2909
|
] }) });
|
|
2894
2910
|
}
|
|
2895
2911
|
const Me = 25;
|
|
2896
2912
|
function vr() {
|
|
2897
|
-
const { t, i18n: a } =
|
|
2898
|
-
data:
|
|
2913
|
+
const { t, i18n: a } = P(["admin", "translation"]), { app: s } = me(), l = we(), o = a.language === "fa", [n, d] = _(""), [g, k] = _(""), [L, N] = _(""), [x, h] = _("name"), [v, i] = _("asc"), [b, j] = _("human"), [y, E] = _(null), [p, C] = _(Me), [m, w] = _(!1), [T, f] = _(null), [M, F] = _(null), [K, S] = _(null), [u, A] = _(!1), D = Yt(), Q = () => l.invalidateQueries({ queryKey: ["gentiq_admin", "users"] }), {
|
|
2914
|
+
data: $,
|
|
2899
2915
|
isLoading: B,
|
|
2900
|
-
isFetching:
|
|
2916
|
+
isFetching: G,
|
|
2901
2917
|
error: W
|
|
2902
|
-
} = Xt(0,
|
|
2918
|
+
} = Xt(0, p, L, x, v, b), V = $?.users ?? [], de = $?.count ?? 0, ge = B || G, Re = W ? W instanceof Error ? W.message : t("error_loading") : "", c = n || Re, q = pe(() => s?.userMetadataFields || [], [s?.userMetadataFields]);
|
|
2903
2919
|
H(() => {
|
|
2904
|
-
|
|
2920
|
+
I.getSettings().then(E).catch((J) => console.error("Failed to load app settings", J));
|
|
2905
2921
|
}, []), H(() => {
|
|
2906
2922
|
const J = setTimeout(() => {
|
|
2907
|
-
|
|
2923
|
+
N(g);
|
|
2908
2924
|
}, 500);
|
|
2909
2925
|
return () => clearTimeout(J);
|
|
2910
2926
|
}, [g]), H(() => {
|
|
2911
|
-
|
|
2912
|
-
}, [
|
|
2913
|
-
const
|
|
2914
|
-
x === J ?
|
|
2927
|
+
C(Me);
|
|
2928
|
+
}, [L, x, v, b]);
|
|
2929
|
+
const R = (J) => {
|
|
2930
|
+
x === J ? i((ce) => ce === "asc" ? "desc" : "asc") : (h(J), i("asc"));
|
|
2915
2931
|
}, U = async (J) => {
|
|
2916
2932
|
if (confirm(t("users.confirm_delete_user")))
|
|
2917
2933
|
try {
|
|
2918
|
-
await
|
|
2934
|
+
await D.deleteUser.mutateAsync(J);
|
|
2919
2935
|
} catch (ce) {
|
|
2920
2936
|
d(ce instanceof Error ? ce.message : t("error_loading"));
|
|
2921
2937
|
}
|
|
2922
|
-
},
|
|
2938
|
+
}, Z = async (J) => {
|
|
2923
2939
|
try {
|
|
2924
|
-
const Ke = (await
|
|
2940
|
+
const Ke = (await I.refreshUserToken(J.id))?.user?.token;
|
|
2925
2941
|
if (!Ke) {
|
|
2926
2942
|
d(t("users.no_token"));
|
|
2927
2943
|
return;
|
|
@@ -2930,12 +2946,12 @@ function vr() {
|
|
|
2930
2946
|
} catch (ce) {
|
|
2931
2947
|
d(ce instanceof Error ? ce.message : t("error_loading"));
|
|
2932
2948
|
}
|
|
2933
|
-
}, ge = () => {
|
|
2934
|
-
v(null), q(!0);
|
|
2935
|
-
}, ye = (J) => {
|
|
2936
|
-
v(J), q(!0);
|
|
2937
2949
|
}, fe = () => {
|
|
2938
|
-
|
|
2950
|
+
f(null), w(!0);
|
|
2951
|
+
}, ye = (J) => {
|
|
2952
|
+
f(J), w(!0);
|
|
2953
|
+
}, be = () => {
|
|
2954
|
+
w(!1), f(null);
|
|
2939
2955
|
};
|
|
2940
2956
|
return /* @__PURE__ */ r("div", { className: "h-full flex flex-col p-5 overflow-hidden gap-4", dir: o ? "rtl" : "ltr", children: [
|
|
2941
2957
|
/* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-center justify-between gap-3 flex-shrink-0", children: [
|
|
@@ -2946,7 +2962,7 @@ function vr() {
|
|
|
2946
2962
|
{
|
|
2947
2963
|
type: "text",
|
|
2948
2964
|
value: g,
|
|
2949
|
-
onChange: (J) =>
|
|
2965
|
+
onChange: (J) => k(J.target.value),
|
|
2950
2966
|
placeholder: t("chat_history.search_placeholder"),
|
|
2951
2967
|
className: "w-full 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"
|
|
2952
2968
|
}
|
|
@@ -2955,12 +2971,12 @@ function vr() {
|
|
|
2955
2971
|
/* @__PURE__ */ r(
|
|
2956
2972
|
X,
|
|
2957
2973
|
{
|
|
2958
|
-
value:
|
|
2959
|
-
onValueChange: (J) =>
|
|
2974
|
+
value: b,
|
|
2975
|
+
onValueChange: (J) => j(J),
|
|
2960
2976
|
dir: o ? "rtl" : "ltr",
|
|
2961
2977
|
children: [
|
|
2962
2978
|
/* @__PURE__ */ e(Y, { className: "min-w-[140px] px-4 py-2 h-auto text-sm font-medium rounded-xl glass-surface border-0 text-foreground shadow-sm", children: /* @__PURE__ */ e(ee, {}) }),
|
|
2963
|
-
/* @__PURE__ */ e(te, { className: "rounded-xl border-border bg-card", children: ["human", "service", "all"].map((J) => /* @__PURE__ */ e(
|
|
2979
|
+
/* @__PURE__ */ e(te, { className: "rounded-xl border-border bg-card", children: ["human", "service", "all"].map((J) => /* @__PURE__ */ e(O, { value: J, children: t(`users.source_${J}`) }, J)) })
|
|
2964
2980
|
]
|
|
2965
2981
|
}
|
|
2966
2982
|
),
|
|
@@ -2968,7 +2984,7 @@ function vr() {
|
|
|
2968
2984
|
/* @__PURE__ */ r(
|
|
2969
2985
|
"button",
|
|
2970
2986
|
{
|
|
2971
|
-
onClick: () =>
|
|
2987
|
+
onClick: () => A(!0),
|
|
2972
2988
|
className: "px-4 py-2.5 bg-secondary text-secondary-foreground border border-border rounded-xl text-sm font-semibold hover:bg-secondary/80 transition-all shadow-sm whitespace-nowrap inline-flex items-center gap-2",
|
|
2973
2989
|
children: [
|
|
2974
2990
|
/* @__PURE__ */ e(Dt, { className: "w-4 h-4" }),
|
|
@@ -2979,7 +2995,7 @@ function vr() {
|
|
|
2979
2995
|
/* @__PURE__ */ e(
|
|
2980
2996
|
"button",
|
|
2981
2997
|
{
|
|
2982
|
-
onClick:
|
|
2998
|
+
onClick: fe,
|
|
2983
2999
|
className: "px-4 py-2.5 bg-primary text-primary-foreground rounded-xl text-sm font-semibold hover:opacity-90 transition-all shadow-sm hover:shadow-md whitespace-nowrap",
|
|
2984
3000
|
children: t("users.add_user")
|
|
2985
3001
|
}
|
|
@@ -2987,44 +3003,44 @@ function vr() {
|
|
|
2987
3003
|
] })
|
|
2988
3004
|
] })
|
|
2989
3005
|
] }),
|
|
2990
|
-
/* @__PURE__ */ e(xr, { user:
|
|
3006
|
+
/* @__PURE__ */ e(xr, { user: K, onClose: () => S(null), onError: d }),
|
|
2991
3007
|
c && /* @__PURE__ */ e(ur, { message: c, onDismiss: () => d("") }),
|
|
2992
|
-
|
|
3008
|
+
u && /* @__PURE__ */ e(
|
|
2993
3009
|
br,
|
|
2994
3010
|
{
|
|
2995
3011
|
searchQuery: g,
|
|
2996
|
-
userMetadataFields:
|
|
3012
|
+
userMetadataFields: q,
|
|
2997
3013
|
onClose: () => {
|
|
2998
|
-
|
|
3014
|
+
A(!1), d("");
|
|
2999
3015
|
},
|
|
3000
3016
|
onApplied: () => {
|
|
3001
|
-
|
|
3017
|
+
A(!1), Q();
|
|
3002
3018
|
},
|
|
3003
3019
|
onError: d
|
|
3004
3020
|
}
|
|
3005
3021
|
),
|
|
3006
|
-
|
|
3022
|
+
m && /* @__PURE__ */ e(
|
|
3007
3023
|
pr,
|
|
3008
3024
|
{
|
|
3009
|
-
editingUser:
|
|
3010
|
-
appSettings:
|
|
3011
|
-
userMetadataFields:
|
|
3012
|
-
onClose:
|
|
3025
|
+
editingUser: T,
|
|
3026
|
+
appSettings: y,
|
|
3027
|
+
userMetadataFields: q,
|
|
3028
|
+
onClose: be,
|
|
3013
3029
|
onSaved: () => {
|
|
3014
|
-
|
|
3030
|
+
Q(), be();
|
|
3015
3031
|
},
|
|
3016
3032
|
onError: d
|
|
3017
3033
|
}
|
|
3018
3034
|
),
|
|
3019
|
-
|
|
3035
|
+
M && /* @__PURE__ */ e(
|
|
3020
3036
|
gr,
|
|
3021
3037
|
{
|
|
3022
|
-
user:
|
|
3038
|
+
user: M,
|
|
3023
3039
|
onClose: () => {
|
|
3024
|
-
|
|
3040
|
+
F(null), d("");
|
|
3025
3041
|
},
|
|
3026
3042
|
onSaved: () => {
|
|
3027
|
-
|
|
3043
|
+
Q(), F(null);
|
|
3028
3044
|
},
|
|
3029
3045
|
onError: d
|
|
3030
3046
|
}
|
|
@@ -3033,19 +3049,19 @@ function vr() {
|
|
|
3033
3049
|
mr,
|
|
3034
3050
|
{
|
|
3035
3051
|
users: V,
|
|
3036
|
-
loading:
|
|
3052
|
+
loading: ge,
|
|
3037
3053
|
totalCount: de,
|
|
3038
|
-
userMetadataFields:
|
|
3054
|
+
userMetadataFields: q,
|
|
3039
3055
|
sortBy: x,
|
|
3040
|
-
sortOrder:
|
|
3041
|
-
onSort:
|
|
3042
|
-
onLoadMore: () =>
|
|
3043
|
-
onUsage:
|
|
3056
|
+
sortOrder: v,
|
|
3057
|
+
onSort: R,
|
|
3058
|
+
onLoadMore: () => C((J) => J + Me),
|
|
3059
|
+
onUsage: S,
|
|
3044
3060
|
onEdit: ye,
|
|
3045
3061
|
onRecharge: (J) => {
|
|
3046
|
-
|
|
3062
|
+
F(J), d("");
|
|
3047
3063
|
},
|
|
3048
|
-
onCopyToken:
|
|
3064
|
+
onCopyToken: Z,
|
|
3049
3065
|
onDelete: U
|
|
3050
3066
|
}
|
|
3051
3067
|
)
|
|
@@ -3054,28 +3070,28 @@ function vr() {
|
|
|
3054
3070
|
function ke(t, a, s) {
|
|
3055
3071
|
const l = [], o = /* @__PURE__ */ new Date(), n = t || [], d = new Map(n.map((g) => [g.date, g]));
|
|
3056
3072
|
for (let g = a - 1; g >= 0; g--) {
|
|
3057
|
-
const
|
|
3058
|
-
if (d.has(
|
|
3059
|
-
l.push(d.get(
|
|
3073
|
+
const L = new Date(o.getTime() - g * 24 * 60 * 60 * 1e3).toISOString().split("T")[0];
|
|
3074
|
+
if (d.has(L))
|
|
3075
|
+
l.push(d.get(L));
|
|
3060
3076
|
else {
|
|
3061
|
-
const
|
|
3062
|
-
s.forEach((x) =>
|
|
3077
|
+
const N = { date: L };
|
|
3078
|
+
s.forEach((x) => N[x] = 0), l.push(N);
|
|
3063
3079
|
}
|
|
3064
3080
|
}
|
|
3065
3081
|
return l;
|
|
3066
3082
|
}
|
|
3067
3083
|
function yr() {
|
|
3068
|
-
const { t, i18n: a } =
|
|
3084
|
+
const { t, i18n: a } = P(["admin", "translation"]), [s, l] = _(30), [o, n] = _("human"), {
|
|
3069
3085
|
data: d,
|
|
3070
3086
|
isLoading: g,
|
|
3071
|
-
error:
|
|
3072
|
-
refetch:
|
|
3073
|
-
} = er(s, o), [
|
|
3087
|
+
error: k,
|
|
3088
|
+
refetch: L
|
|
3089
|
+
} = er(s, o), [N, x] = _({}), h = nt({}), v = a.language === "fa", i = v ? "fa-IR" : "en-US", b = v ? "fa-IR-u-ca-persian" : "en-US", j = k ? k instanceof Error ? k.message : t("analytics.error_loading") : "", y = pe(() => {
|
|
3074
3090
|
if (!d) return null;
|
|
3075
|
-
const
|
|
3091
|
+
const u = d;
|
|
3076
3092
|
return {
|
|
3077
|
-
...
|
|
3078
|
-
overview:
|
|
3093
|
+
...u,
|
|
3094
|
+
overview: u.overview || {
|
|
3079
3095
|
total_users: 0,
|
|
3080
3096
|
total_threads: 0,
|
|
3081
3097
|
total_messages: 0,
|
|
@@ -3086,11 +3102,11 @@ function yr() {
|
|
|
3086
3102
|
currency: "USD"
|
|
3087
3103
|
},
|
|
3088
3104
|
trends: {
|
|
3089
|
-
...
|
|
3090
|
-
users: ke(
|
|
3091
|
-
threads: ke(
|
|
3092
|
-
messages: ke(
|
|
3093
|
-
token_usage: ke(
|
|
3105
|
+
...u.trends || {},
|
|
3106
|
+
users: ke(u.trends?.users, s, ["count"]),
|
|
3107
|
+
threads: ke(u.trends?.threads, s, ["count"]),
|
|
3108
|
+
messages: ke(u.trends?.messages, s, ["count"]),
|
|
3109
|
+
token_usage: ke(u.trends?.token_usage, s, [
|
|
3094
3110
|
"input_tokens",
|
|
3095
3111
|
"output_tokens",
|
|
3096
3112
|
"requests",
|
|
@@ -3099,51 +3115,51 @@ function yr() {
|
|
|
3099
3115
|
])
|
|
3100
3116
|
},
|
|
3101
3117
|
distributions: {
|
|
3102
|
-
...
|
|
3103
|
-
feedback_sentiment:
|
|
3118
|
+
...u.distributions || {},
|
|
3119
|
+
feedback_sentiment: u.distributions?.feedback_sentiment || []
|
|
3104
3120
|
},
|
|
3105
|
-
active_users:
|
|
3121
|
+
active_users: u.active_users || []
|
|
3106
3122
|
};
|
|
3107
3123
|
}, [d, s]);
|
|
3108
3124
|
H(() => {
|
|
3109
|
-
const
|
|
3110
|
-
(
|
|
3125
|
+
const u = Object.entries(h.current).filter(
|
|
3126
|
+
(D) => !!D[1]
|
|
3111
3127
|
);
|
|
3112
|
-
if (
|
|
3113
|
-
const
|
|
3114
|
-
for (const
|
|
3115
|
-
const
|
|
3116
|
-
|
|
3128
|
+
if (u.length === 0) return;
|
|
3129
|
+
const A = new ResizeObserver((D) => {
|
|
3130
|
+
for (const Q of D) {
|
|
3131
|
+
const $ = Q.target.dataset.chartId;
|
|
3132
|
+
$ && x((B) => ({
|
|
3117
3133
|
...B,
|
|
3118
|
-
[
|
|
3134
|
+
[$]: Q.contentRect.width
|
|
3119
3135
|
}));
|
|
3120
3136
|
}
|
|
3121
3137
|
});
|
|
3122
|
-
return
|
|
3123
|
-
}, [
|
|
3124
|
-
const
|
|
3125
|
-
|
|
3126
|
-
},
|
|
3127
|
-
if (!
|
|
3128
|
-
const
|
|
3129
|
-
let
|
|
3138
|
+
return u.forEach(([, D]) => A.observe(D)), () => A.disconnect();
|
|
3139
|
+
}, [y]);
|
|
3140
|
+
const E = (u) => (A) => {
|
|
3141
|
+
h.current[u] = A;
|
|
3142
|
+
}, p = (u, A = 0) => {
|
|
3143
|
+
if (!u || u.length === 0) return null;
|
|
3144
|
+
const D = u.length, Q = new Intl.DateTimeFormat(b, { month: "short" });
|
|
3145
|
+
let $ = [];
|
|
3130
3146
|
if (s <= 14)
|
|
3131
|
-
|
|
3147
|
+
$ = Array.from({ length: D }, (B, G) => G);
|
|
3132
3148
|
else {
|
|
3133
|
-
const B =
|
|
3134
|
-
for (let V = 0; V <
|
|
3135
|
-
|
|
3136
|
-
|
|
3149
|
+
const B = v ? 45 : 35, G = A > 0 ? Math.floor(A / B) : 6, W = Math.max(1, Math.ceil(D / Math.max(1, G)));
|
|
3150
|
+
for (let V = 0; V < D; V += W)
|
|
3151
|
+
$.push(V);
|
|
3152
|
+
$.length > 0 && $[$.length - 1] !== D - 1 && (D - 1 - $[$.length - 1] > W / 2 ? $.push(D - 1) : $[$.length - 1] = D - 1);
|
|
3137
3153
|
}
|
|
3138
|
-
return /* @__PURE__ */ e("div", { className: "relative w-full h-8 mt-2", dir:
|
|
3139
|
-
const
|
|
3140
|
-
if (!
|
|
3141
|
-
const W = new Date(
|
|
3154
|
+
return /* @__PURE__ */ e("div", { className: "relative w-full h-8 mt-2", dir: v ? "rtl" : "ltr", children: $.map((B) => {
|
|
3155
|
+
const G = u[B];
|
|
3156
|
+
if (!G) return null;
|
|
3157
|
+
const W = new Date(G.date), V = W.toLocaleDateString(b, { day: "numeric" }), de = Q.format(W), ge = D > 1 ? B / (D - 1) * 100 : 50;
|
|
3142
3158
|
return /* @__PURE__ */ r(
|
|
3143
3159
|
"div",
|
|
3144
3160
|
{
|
|
3145
3161
|
className: "absolute top-0 transform -translate-x-1/2 flex flex-col items-center",
|
|
3146
|
-
style: { left: `${
|
|
3162
|
+
style: { left: `${ge}%` },
|
|
3147
3163
|
children: [
|
|
3148
3164
|
/* @__PURE__ */ e("span", { className: "text-[10px] text-gray-600 dark:text-gray-400 font-medium leading-none", children: V }),
|
|
3149
3165
|
/* @__PURE__ */ e("span", { className: "text-[9px] text-gray-400 dark:text-gray-500 mt-1 leading-none whitespace-nowrap", children: de })
|
|
@@ -3155,30 +3171,30 @@ function yr() {
|
|
|
3155
3171
|
};
|
|
3156
3172
|
if (g)
|
|
3157
3173
|
return /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center text-muted-foreground", children: t("analytics.loading_analytics") });
|
|
3158
|
-
if (
|
|
3174
|
+
if (j)
|
|
3159
3175
|
return /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center", children: /* @__PURE__ */ r("div", { className: "text-center", children: [
|
|
3160
|
-
/* @__PURE__ */ e("div", { className: "text-destructive mb-4", children:
|
|
3176
|
+
/* @__PURE__ */ e("div", { className: "text-destructive mb-4", children: j }),
|
|
3161
3177
|
/* @__PURE__ */ e(
|
|
3162
3178
|
"button",
|
|
3163
3179
|
{
|
|
3164
|
-
onClick: () =>
|
|
3180
|
+
onClick: () => L(),
|
|
3165
3181
|
className: "px-4 py-2 bg-primary text-primary-foreground rounded-lg text-sm font-medium hover:opacity-90 transition-colors",
|
|
3166
3182
|
children: t("retry")
|
|
3167
3183
|
}
|
|
3168
3184
|
)
|
|
3169
3185
|
] }) });
|
|
3170
|
-
if (!
|
|
3171
|
-
const
|
|
3172
|
-
if (
|
|
3173
|
-
const
|
|
3174
|
-
let
|
|
3175
|
-
return
|
|
3176
|
-
},
|
|
3177
|
-
...
|
|
3178
|
-
),
|
|
3179
|
-
...
|
|
3180
|
-
),
|
|
3181
|
-
return /* @__PURE__ */ r("div", { className: "h-full overflow-auto p-5 flex flex-col gap-5", dir:
|
|
3186
|
+
if (!y) return null;
|
|
3187
|
+
const C = (u) => {
|
|
3188
|
+
if (u <= 0) return 10;
|
|
3189
|
+
const A = u * 1.15, D = Math.pow(10, Math.floor(Math.log10(A))), Q = A / D;
|
|
3190
|
+
let $;
|
|
3191
|
+
return Q <= 1.2 ? $ = 0.2 : Q <= 2.5 ? $ = 0.5 : Q <= 5 ? $ = 1 : $ = 2, Math.ceil(A / ($ * D)) * ($ * D);
|
|
3192
|
+
}, m = Math.max(...y.trends.threads.map((u) => u.count) || [1]), w = Math.max(...y.trends.messages.map((u) => u.count) || [1]), T = Math.max(
|
|
3193
|
+
...y.trends.token_usage.map((u) => (u.input_tokens || 0) + (u.output_tokens || 0)) || [1]
|
|
3194
|
+
), f = Math.max(
|
|
3195
|
+
...y.trends.token_usage.map((u) => u.cost_microunits) || [1]
|
|
3196
|
+
), M = C(m), F = C(w), K = C(T), S = C(f);
|
|
3197
|
+
return /* @__PURE__ */ r("div", { className: "h-full overflow-auto p-5 flex flex-col gap-5", dir: v ? "rtl" : "ltr", children: [
|
|
3182
3198
|
/* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-center justify-between gap-3", children: [
|
|
3183
3199
|
/* @__PURE__ */ r("div", { className: "flex flex-col gap-1", children: [
|
|
3184
3200
|
/* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-foreground tracking-tight whitespace-nowrap", children: t("analytics.title") }),
|
|
@@ -3189,26 +3205,26 @@ function yr() {
|
|
|
3189
3205
|
X,
|
|
3190
3206
|
{
|
|
3191
3207
|
value: o,
|
|
3192
|
-
onValueChange: (
|
|
3193
|
-
dir:
|
|
3208
|
+
onValueChange: (u) => n(u),
|
|
3209
|
+
dir: v ? "rtl" : "ltr",
|
|
3194
3210
|
children: [
|
|
3195
3211
|
/* @__PURE__ */ e(Y, { className: "min-w-[140px] px-4 py-2 h-auto text-sm font-medium rounded-xl bg-muted/50 border border-border/50 text-foreground shadow-sm", children: /* @__PURE__ */ e(ee, {}) }),
|
|
3196
|
-
/* @__PURE__ */ e(te, { className: "rounded-xl border-border bg-card", children: ["human", "service", "all"].map((
|
|
3212
|
+
/* @__PURE__ */ e(te, { className: "rounded-xl border-border bg-card", children: ["human", "service", "all"].map((u) => /* @__PURE__ */ e(O, { value: u, children: t(`analytics.source_${u}`) }, u)) })
|
|
3197
3213
|
]
|
|
3198
3214
|
}
|
|
3199
3215
|
),
|
|
3200
3216
|
/* @__PURE__ */ r("div", { className: "inline-flex items-center gap-1 p-1 ps-3 rounded-xl bg-muted/50 border border-border/50 shadow-sm", children: [
|
|
3201
3217
|
/* @__PURE__ */ e("span", { className: "text-xs font-medium text-muted-foreground me-1", children: t("analytics.time_range_label") }),
|
|
3202
|
-
[7, 14, 30, 90].map((
|
|
3218
|
+
[7, 14, 30, 90].map((u) => /* @__PURE__ */ e(
|
|
3203
3219
|
"button",
|
|
3204
3220
|
{
|
|
3205
|
-
onClick: () => l(
|
|
3206
|
-
title: t("analytics.days", { count:
|
|
3207
|
-
"aria-pressed": s ===
|
|
3208
|
-
className: `px-3 py-1.5 text-sm font-medium rounded-lg transition-all ${s ===
|
|
3209
|
-
children:
|
|
3221
|
+
onClick: () => l(u),
|
|
3222
|
+
title: t("analytics.days", { count: u }),
|
|
3223
|
+
"aria-pressed": s === u,
|
|
3224
|
+
className: `px-3 py-1.5 text-sm font-medium rounded-lg transition-all ${s === u ? "bg-primary text-primary-foreground shadow-sm" : "text-muted-foreground hover:text-foreground"}`,
|
|
3225
|
+
children: u.toLocaleString(i)
|
|
3210
3226
|
},
|
|
3211
|
-
|
|
3227
|
+
u
|
|
3212
3228
|
)),
|
|
3213
3229
|
/* @__PURE__ */ e("span", { className: "text-xs font-medium text-muted-foreground ms-1 me-1", children: t("analytics.days_unit") })
|
|
3214
3230
|
] })
|
|
@@ -3218,7 +3234,7 @@ function yr() {
|
|
|
3218
3234
|
/* @__PURE__ */ e("div", { className: "glass-surface rounded-2xl shadow-sm hover:shadow-md transition-shadow p-4", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
|
|
3219
3235
|
/* @__PURE__ */ r("div", { children: [
|
|
3220
3236
|
/* @__PURE__ */ e("p", { className: "text-[11px] uppercase tracking-widest font-bold text-muted-foreground/80 mb-1", children: t("analytics.total_users") }),
|
|
3221
|
-
/* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (
|
|
3237
|
+
/* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (y.overview.total_users || 0).toLocaleString(i) })
|
|
3222
3238
|
] }),
|
|
3223
3239
|
/* @__PURE__ */ e("div", { className: "w-10 h-10 bg-primary/10 rounded-xl flex items-center justify-center", children: /* @__PURE__ */ e(
|
|
3224
3240
|
"svg",
|
|
@@ -3242,7 +3258,7 @@ function yr() {
|
|
|
3242
3258
|
/* @__PURE__ */ e("div", { className: "glass-surface rounded-2xl shadow-sm hover:shadow-md transition-shadow p-4", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
|
|
3243
3259
|
/* @__PURE__ */ r("div", { children: [
|
|
3244
3260
|
/* @__PURE__ */ e("p", { className: "text-[11px] uppercase tracking-widest font-bold text-muted-foreground/80 mb-1", children: t("analytics.total_threads") }),
|
|
3245
|
-
/* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (
|
|
3261
|
+
/* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (y.overview.total_threads || 0).toLocaleString(i) })
|
|
3246
3262
|
] }),
|
|
3247
3263
|
/* @__PURE__ */ e("div", { className: "w-10 h-10 bg-primary/10 rounded-xl flex items-center justify-center", children: /* @__PURE__ */ e(
|
|
3248
3264
|
"svg",
|
|
@@ -3266,7 +3282,7 @@ function yr() {
|
|
|
3266
3282
|
/* @__PURE__ */ e("div", { className: "glass-surface rounded-2xl shadow-sm hover:shadow-md transition-shadow p-4", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
|
|
3267
3283
|
/* @__PURE__ */ r("div", { children: [
|
|
3268
3284
|
/* @__PURE__ */ e("p", { className: "text-[11px] uppercase tracking-widest font-bold text-muted-foreground/80 mb-1", children: t("analytics.total_messages") }),
|
|
3269
|
-
/* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (
|
|
3285
|
+
/* @__PURE__ */ e("p", { className: "text-2xl font-light text-foreground", children: (y.overview.total_messages || 0).toLocaleString(i) })
|
|
3270
3286
|
] }),
|
|
3271
3287
|
/* @__PURE__ */ e("div", { className: "w-10 h-10 bg-primary/10 rounded-xl flex items-center justify-center", children: /* @__PURE__ */ e(
|
|
3272
3288
|
"svg",
|
|
@@ -3293,11 +3309,11 @@ function yr() {
|
|
|
3293
3309
|
/* @__PURE__ */ r("div", { className: "grid grid-cols-3 gap-3", children: [
|
|
3294
3310
|
/* @__PURE__ */ r("div", { children: [
|
|
3295
3311
|
/* @__PURE__ */ e("p", { className: "text-[9px] text-muted-foreground", children: t("analytics.input") }),
|
|
3296
|
-
/* @__PURE__ */ e("p", { className: "text-sm font-medium text-foreground", children: (
|
|
3312
|
+
/* @__PURE__ */ e("p", { className: "text-sm font-medium text-foreground", children: (y.overview.total_input_tokens || 0).toLocaleString(i) })
|
|
3297
3313
|
] }),
|
|
3298
3314
|
/* @__PURE__ */ r("div", { children: [
|
|
3299
3315
|
/* @__PURE__ */ e("p", { className: "text-[9px] text-muted-foreground", children: t("analytics.output") }),
|
|
3300
|
-
/* @__PURE__ */ e("p", { className: "text-sm font-medium text-foreground", children: (
|
|
3316
|
+
/* @__PURE__ */ e("p", { className: "text-sm font-medium text-foreground", children: (y.overview.total_output_tokens || 0).toLocaleString(i) })
|
|
3301
3317
|
] }),
|
|
3302
3318
|
/* @__PURE__ */ r("div", { children: [
|
|
3303
3319
|
/* @__PURE__ */ e("p", { className: "text-[9px] text-muted-foreground", children: t("analytics.cost") }),
|
|
@@ -3305,15 +3321,15 @@ function yr() {
|
|
|
3305
3321
|
"p",
|
|
3306
3322
|
{
|
|
3307
3323
|
className: "text-sm font-medium text-foreground",
|
|
3308
|
-
title:
|
|
3309
|
-
|
|
3310
|
-
|
|
3311
|
-
|
|
3324
|
+
title: he(
|
|
3325
|
+
y.overview.total_cost_microunits,
|
|
3326
|
+
y.overview.currency,
|
|
3327
|
+
i
|
|
3312
3328
|
),
|
|
3313
|
-
children:
|
|
3314
|
-
|
|
3315
|
-
|
|
3316
|
-
|
|
3329
|
+
children: he(
|
|
3330
|
+
y.overview.total_cost_microunits,
|
|
3331
|
+
y.overview.currency,
|
|
3332
|
+
i
|
|
3317
3333
|
)
|
|
3318
3334
|
}
|
|
3319
3335
|
)
|
|
@@ -3347,13 +3363,13 @@ function yr() {
|
|
|
3347
3363
|
"div",
|
|
3348
3364
|
{
|
|
3349
3365
|
className: "h-64 flex flex-col",
|
|
3350
|
-
ref:
|
|
3366
|
+
ref: E("threads"),
|
|
3351
3367
|
"data-chart-id": "threads",
|
|
3352
3368
|
children: [
|
|
3353
3369
|
/* @__PURE__ */ r("div", { className: "flex-1 flex gap-2 min-h-0", dir: "ltr", children: [
|
|
3354
3370
|
/* @__PURE__ */ r("div", { className: "flex flex-col justify-between text-[10px] text-muted-foreground pt-6 text-right min-w-[24px]", children: [
|
|
3355
|
-
/* @__PURE__ */ e("span", { children: (
|
|
3356
|
-
/* @__PURE__ */ e("span", { children: Math.floor((
|
|
3371
|
+
/* @__PURE__ */ e("span", { children: (M || 0).toLocaleString(i) }),
|
|
3372
|
+
/* @__PURE__ */ e("span", { children: Math.floor((M || 0) / 2).toLocaleString(i) }),
|
|
3357
3373
|
/* @__PURE__ */ e("span", { children: "0" })
|
|
3358
3374
|
] }),
|
|
3359
3375
|
/* @__PURE__ */ r("div", { className: "flex-1 relative flex items-end justify-between pt-6 border-b border-border/30", children: [
|
|
@@ -3361,7 +3377,7 @@ function yr() {
|
|
|
3361
3377
|
/* @__PURE__ */ e("div", { className: "absolute top-6 left-0 right-0 border-t border-border/30 w-full" }),
|
|
3362
3378
|
/* @__PURE__ */ e("div", { className: "absolute top-[calc(50%-4px)] left-0 right-0 border-t border-border/30 w-full" })
|
|
3363
3379
|
] }),
|
|
3364
|
-
|
|
3380
|
+
y.trends.threads.length > 0 ? y.trends.threads.map((u, A) => /* @__PURE__ */ e(
|
|
3365
3381
|
"div",
|
|
3366
3382
|
{
|
|
3367
3383
|
className: "w-1.5 group relative flex flex-col justify-end h-full",
|
|
@@ -3369,10 +3385,10 @@ function yr() {
|
|
|
3369
3385
|
"div",
|
|
3370
3386
|
{
|
|
3371
3387
|
className: "bg-primary/80 w-full rounded-t-lg transition-all group-hover:bg-primary relative",
|
|
3372
|
-
style: { height: `${
|
|
3388
|
+
style: { height: `${u.count / M * 100}%` },
|
|
3373
3389
|
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: [
|
|
3374
|
-
/* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children:
|
|
3375
|
-
/* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(
|
|
3390
|
+
/* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children: u.count.toLocaleString(i) }),
|
|
3391
|
+
/* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(u.date).toLocaleDateString(b, {
|
|
3376
3392
|
month: "short",
|
|
3377
3393
|
day: "numeric"
|
|
3378
3394
|
}) })
|
|
@@ -3380,13 +3396,13 @@ function yr() {
|
|
|
3380
3396
|
}
|
|
3381
3397
|
)
|
|
3382
3398
|
},
|
|
3383
|
-
|
|
3399
|
+
A
|
|
3384
3400
|
)) : /* @__PURE__ */ e("p", { className: "w-full text-center text-muted-foreground py-8", children: t("no_data") })
|
|
3385
3401
|
] })
|
|
3386
3402
|
] }),
|
|
3387
3403
|
/* @__PURE__ */ r("div", { className: "flex gap-2", dir: "ltr", children: [
|
|
3388
3404
|
/* @__PURE__ */ e("div", { className: "min-w-[24px] invisible" }),
|
|
3389
|
-
|
|
3405
|
+
p(y.trends.threads, N.threads)
|
|
3390
3406
|
] })
|
|
3391
3407
|
]
|
|
3392
3408
|
}
|
|
@@ -3398,13 +3414,13 @@ function yr() {
|
|
|
3398
3414
|
"div",
|
|
3399
3415
|
{
|
|
3400
3416
|
className: "h-64 flex flex-col",
|
|
3401
|
-
ref:
|
|
3417
|
+
ref: E("messages"),
|
|
3402
3418
|
"data-chart-id": "messages",
|
|
3403
3419
|
children: [
|
|
3404
3420
|
/* @__PURE__ */ r("div", { className: "flex-1 flex gap-2 min-h-0", dir: "ltr", children: [
|
|
3405
3421
|
/* @__PURE__ */ r("div", { className: "flex flex-col justify-between text-[10px] text-muted-foreground pt-6 text-right min-w-[24px]", children: [
|
|
3406
|
-
/* @__PURE__ */ e("span", { children: (
|
|
3407
|
-
/* @__PURE__ */ e("span", { children: Math.floor((
|
|
3422
|
+
/* @__PURE__ */ e("span", { children: (F || 0).toLocaleString(i) }),
|
|
3423
|
+
/* @__PURE__ */ e("span", { children: Math.floor((F || 0) / 2).toLocaleString(i) }),
|
|
3408
3424
|
/* @__PURE__ */ e("span", { children: "0" })
|
|
3409
3425
|
] }),
|
|
3410
3426
|
/* @__PURE__ */ r("div", { className: "flex-1 relative flex items-end justify-between pt-6 border-b border-border/30", children: [
|
|
@@ -3412,7 +3428,7 @@ function yr() {
|
|
|
3412
3428
|
/* @__PURE__ */ e("div", { className: "absolute top-6 left-0 right-0 border-t border-border/30 w-full" }),
|
|
3413
3429
|
/* @__PURE__ */ e("div", { className: "absolute top-[calc(50%-4px)] left-0 right-0 border-t border-border/30 w-full" })
|
|
3414
3430
|
] }),
|
|
3415
|
-
|
|
3431
|
+
y.trends.messages.length > 0 ? y.trends.messages.map((u, A) => /* @__PURE__ */ e(
|
|
3416
3432
|
"div",
|
|
3417
3433
|
{
|
|
3418
3434
|
className: "w-1.5 group relative flex flex-col justify-end h-full",
|
|
@@ -3420,10 +3436,10 @@ function yr() {
|
|
|
3420
3436
|
"div",
|
|
3421
3437
|
{
|
|
3422
3438
|
className: "bg-primary/80 w-full rounded-t-lg transition-all group-hover:bg-primary relative",
|
|
3423
|
-
style: { height: `${
|
|
3439
|
+
style: { height: `${u.count / F * 100}%` },
|
|
3424
3440
|
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: [
|
|
3425
|
-
/* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children:
|
|
3426
|
-
/* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(
|
|
3441
|
+
/* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children: u.count.toLocaleString(i) }),
|
|
3442
|
+
/* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(u.date).toLocaleDateString(b, {
|
|
3427
3443
|
month: "short",
|
|
3428
3444
|
day: "numeric"
|
|
3429
3445
|
}) })
|
|
@@ -3431,13 +3447,13 @@ function yr() {
|
|
|
3431
3447
|
}
|
|
3432
3448
|
)
|
|
3433
3449
|
},
|
|
3434
|
-
|
|
3450
|
+
A
|
|
3435
3451
|
)) : /* @__PURE__ */ e("p", { className: "w-full text-center text-muted-foreground py-8", children: t("no_data") })
|
|
3436
3452
|
] })
|
|
3437
3453
|
] }),
|
|
3438
3454
|
/* @__PURE__ */ r("div", { className: "flex gap-2", dir: "ltr", children: [
|
|
3439
3455
|
/* @__PURE__ */ e("div", { className: "min-w-[24px] invisible" }),
|
|
3440
|
-
|
|
3456
|
+
p(y.trends.messages, N.messages)
|
|
3441
3457
|
] })
|
|
3442
3458
|
]
|
|
3443
3459
|
}
|
|
@@ -3449,13 +3465,13 @@ function yr() {
|
|
|
3449
3465
|
"div",
|
|
3450
3466
|
{
|
|
3451
3467
|
className: "h-64 flex flex-col",
|
|
3452
|
-
ref:
|
|
3468
|
+
ref: E("token-usage"),
|
|
3453
3469
|
"data-chart-id": "token-usage",
|
|
3454
3470
|
children: [
|
|
3455
3471
|
/* @__PURE__ */ r("div", { className: "flex-1 flex gap-2 min-h-0", dir: "ltr", children: [
|
|
3456
3472
|
/* @__PURE__ */ r("div", { className: "flex flex-col justify-between text-[10px] text-muted-foreground pt-6 text-right min-w-[24px]", children: [
|
|
3457
|
-
/* @__PURE__ */ e("span", { children: (
|
|
3458
|
-
/* @__PURE__ */ e("span", { children: Math.floor((
|
|
3473
|
+
/* @__PURE__ */ e("span", { children: (K || 0).toLocaleString(i) }),
|
|
3474
|
+
/* @__PURE__ */ e("span", { children: Math.floor((K || 0) / 2).toLocaleString(i) }),
|
|
3459
3475
|
/* @__PURE__ */ e("span", { children: "0" })
|
|
3460
3476
|
] }),
|
|
3461
3477
|
/* @__PURE__ */ r("div", { className: "flex-1 relative flex items-end justify-between pt-6 border-b border-border/30", children: [
|
|
@@ -3463,8 +3479,8 @@ function yr() {
|
|
|
3463
3479
|
/* @__PURE__ */ e("div", { className: "absolute top-6 left-0 right-0 border-t border-border/30 w-full" }),
|
|
3464
3480
|
/* @__PURE__ */ e("div", { className: "absolute top-[calc(50%-4px)] left-0 right-0 border-t border-border/30 w-full" })
|
|
3465
3481
|
] }),
|
|
3466
|
-
|
|
3467
|
-
const
|
|
3482
|
+
y.trends.token_usage.length > 0 ? y.trends.token_usage.map((u, A) => {
|
|
3483
|
+
const D = (u.input_tokens || 0) + (u.output_tokens || 0);
|
|
3468
3484
|
return /* @__PURE__ */ e(
|
|
3469
3485
|
"div",
|
|
3470
3486
|
{
|
|
@@ -3473,10 +3489,10 @@ function yr() {
|
|
|
3473
3489
|
"div",
|
|
3474
3490
|
{
|
|
3475
3491
|
className: "bg-primary/80 w-full rounded-t-lg transition-all group-hover:bg-primary relative",
|
|
3476
|
-
style: { height: `${
|
|
3492
|
+
style: { height: `${D / K * 100}%` },
|
|
3477
3493
|
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: [
|
|
3478
|
-
/* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children:
|
|
3479
|
-
/* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(
|
|
3494
|
+
/* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-primary leading-none mb-0.5", children: D.toLocaleString(i) }),
|
|
3495
|
+
/* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(u.date).toLocaleDateString(b, {
|
|
3480
3496
|
month: "short",
|
|
3481
3497
|
day: "numeric"
|
|
3482
3498
|
}) })
|
|
@@ -3484,14 +3500,14 @@ function yr() {
|
|
|
3484
3500
|
}
|
|
3485
3501
|
)
|
|
3486
3502
|
},
|
|
3487
|
-
|
|
3503
|
+
A
|
|
3488
3504
|
);
|
|
3489
3505
|
}) : /* @__PURE__ */ e("p", { className: "w-full text-center text-muted-foreground py-8", children: t("no_data") })
|
|
3490
3506
|
] })
|
|
3491
3507
|
] }),
|
|
3492
3508
|
/* @__PURE__ */ r("div", { className: "flex gap-2", dir: "ltr", children: [
|
|
3493
3509
|
/* @__PURE__ */ e("div", { className: "min-w-[24px] invisible" }),
|
|
3494
|
-
|
|
3510
|
+
p(y.trends.token_usage, N["token-usage"])
|
|
3495
3511
|
] })
|
|
3496
3512
|
]
|
|
3497
3513
|
}
|
|
@@ -3503,29 +3519,29 @@ function yr() {
|
|
|
3503
3519
|
"div",
|
|
3504
3520
|
{
|
|
3505
3521
|
className: "h-64 flex flex-col",
|
|
3506
|
-
ref:
|
|
3522
|
+
ref: E("cost"),
|
|
3507
3523
|
"data-chart-id": "cost",
|
|
3508
3524
|
children: [
|
|
3509
3525
|
/* @__PURE__ */ r("div", { className: "flex-1 flex gap-2 min-h-0", dir: "ltr", children: [
|
|
3510
3526
|
/* @__PURE__ */ r("div", { className: "flex flex-col justify-between text-[10px] text-muted-foreground pt-6 text-right min-w-[70px]", children: [
|
|
3511
|
-
/* @__PURE__ */ e("span", { children:
|
|
3512
|
-
|
|
3513
|
-
|
|
3514
|
-
|
|
3527
|
+
/* @__PURE__ */ e("span", { children: he(
|
|
3528
|
+
S || 0,
|
|
3529
|
+
y.overview.currency,
|
|
3530
|
+
i
|
|
3515
3531
|
) }),
|
|
3516
|
-
/* @__PURE__ */ e("span", { children:
|
|
3517
|
-
Math.floor((
|
|
3518
|
-
|
|
3519
|
-
|
|
3532
|
+
/* @__PURE__ */ e("span", { children: he(
|
|
3533
|
+
Math.floor((S || 0) / 2),
|
|
3534
|
+
y.overview.currency,
|
|
3535
|
+
i
|
|
3520
3536
|
) }),
|
|
3521
|
-
/* @__PURE__ */ e("span", { children:
|
|
3537
|
+
/* @__PURE__ */ e("span", { children: he(0, y.overview.currency, i) })
|
|
3522
3538
|
] }),
|
|
3523
3539
|
/* @__PURE__ */ r("div", { className: "flex-1 relative flex items-end justify-between pt-6 border-b border-border/30", children: [
|
|
3524
3540
|
/* @__PURE__ */ r("div", { className: "absolute inset-0 pt-6 pointer-events-none", children: [
|
|
3525
3541
|
/* @__PURE__ */ e("div", { className: "absolute top-6 left-0 right-0 border-t border-border/30 w-full" }),
|
|
3526
3542
|
/* @__PURE__ */ e("div", { className: "absolute top-[calc(50%-4px)] left-0 right-0 border-t border-border/30 w-full" })
|
|
3527
3543
|
] }),
|
|
3528
|
-
|
|
3544
|
+
y.trends.token_usage.length > 0 ? y.trends.token_usage.map((u, A) => /* @__PURE__ */ e(
|
|
3529
3545
|
"div",
|
|
3530
3546
|
{
|
|
3531
3547
|
className: "w-1.5 group relative flex flex-col justify-end h-full",
|
|
@@ -3534,15 +3550,15 @@ function yr() {
|
|
|
3534
3550
|
{
|
|
3535
3551
|
className: "bg-emerald-500/80 w-full rounded-t-lg transition-all group-hover:bg-emerald-500 relative",
|
|
3536
3552
|
style: {
|
|
3537
|
-
height: `${(
|
|
3553
|
+
height: `${(u.cost_microunits || 0) / S * 100}%`
|
|
3538
3554
|
},
|
|
3539
3555
|
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: [
|
|
3540
|
-
/* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-emerald-500 leading-none mb-0.5", children:
|
|
3541
|
-
|
|
3542
|
-
|
|
3543
|
-
|
|
3556
|
+
/* @__PURE__ */ e("span", { className: "text-[10px] font-medium text-emerald-500 leading-none mb-0.5", children: he(
|
|
3557
|
+
u.cost_microunits || 0,
|
|
3558
|
+
y.overview.currency,
|
|
3559
|
+
i
|
|
3544
3560
|
) }),
|
|
3545
|
-
/* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(
|
|
3561
|
+
/* @__PURE__ */ e("span", { className: "text-[9px] text-muted-foreground leading-none whitespace-nowrap", children: new Date(u.date).toLocaleDateString(b, {
|
|
3546
3562
|
month: "short",
|
|
3547
3563
|
day: "numeric"
|
|
3548
3564
|
}) })
|
|
@@ -3550,13 +3566,13 @@ function yr() {
|
|
|
3550
3566
|
}
|
|
3551
3567
|
)
|
|
3552
3568
|
},
|
|
3553
|
-
|
|
3569
|
+
A
|
|
3554
3570
|
)) : /* @__PURE__ */ e("p", { className: "w-full text-center text-muted-foreground py-8", children: t("no_data") })
|
|
3555
3571
|
] })
|
|
3556
3572
|
] }),
|
|
3557
3573
|
/* @__PURE__ */ r("div", { className: "flex gap-2", dir: "ltr", children: [
|
|
3558
3574
|
/* @__PURE__ */ e("div", { className: "min-w-[70px] invisible" }),
|
|
3559
|
-
|
|
3575
|
+
p(y.trends.token_usage, N.cost)
|
|
3560
3576
|
] })
|
|
3561
3577
|
]
|
|
3562
3578
|
}
|
|
@@ -3566,21 +3582,21 @@ function yr() {
|
|
|
3566
3582
|
/* @__PURE__ */ r("div", { className: "grid grid-cols-1 lg:grid-cols-2 gap-5", children: [
|
|
3567
3583
|
/* @__PURE__ */ r("div", { className: "glass-surface rounded-2xl shadow-sm p-7", children: [
|
|
3568
3584
|
/* @__PURE__ */ e("h3", { className: "text-[11px] font-bold text-muted-foreground/80 mb-6 uppercase tracking-widest", children: t("analytics.feedback") }),
|
|
3569
|
-
/* @__PURE__ */ e("div", { className: "h-64 flex flex-col justify-center", children:
|
|
3585
|
+
/* @__PURE__ */ e("div", { className: "h-64 flex flex-col justify-center", children: y.distributions.feedback_sentiment.length > 0 ? /* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row items-center justify-center gap-8 lg:gap-12", children: [
|
|
3570
3586
|
/* @__PURE__ */ r("div", { className: "relative w-56 h-56 lg:w-60 lg:h-60", children: [
|
|
3571
3587
|
/* @__PURE__ */ e("svg", { viewBox: "0 0 100 100", className: "w-full h-full -rotate-90 drop-shadow-md", children: (() => {
|
|
3572
|
-
const
|
|
3588
|
+
const u = y.distributions.feedback_sentiment.filter(
|
|
3573
3589
|
(V) => V.sentiment === "positive" || V.sentiment === "negative"
|
|
3574
|
-
),
|
|
3575
|
-
if (
|
|
3576
|
-
const
|
|
3590
|
+
), A = u.reduce((V, de) => V + de.count, 0);
|
|
3591
|
+
if (A === 0) return null;
|
|
3592
|
+
const D = u.find((V) => V.sentiment === "positive")?.count || 0, Q = u.find((V) => V.sentiment === "negative")?.count || 0, $ = 40, B = 2 * Math.PI * $, G = D / A * 100, W = Q / A * 100;
|
|
3577
3593
|
return /* @__PURE__ */ r(at, { children: [
|
|
3578
3594
|
/* @__PURE__ */ e(
|
|
3579
3595
|
"circle",
|
|
3580
3596
|
{
|
|
3581
3597
|
cx: "50",
|
|
3582
3598
|
cy: "50",
|
|
3583
|
-
r:
|
|
3599
|
+
r: $,
|
|
3584
3600
|
fill: "transparent",
|
|
3585
3601
|
stroke: "currentColor",
|
|
3586
3602
|
strokeWidth: "10",
|
|
@@ -3602,12 +3618,12 @@ function yr() {
|
|
|
3602
3618
|
{
|
|
3603
3619
|
cx: "50",
|
|
3604
3620
|
cy: "50",
|
|
3605
|
-
r:
|
|
3621
|
+
r: $,
|
|
3606
3622
|
fill: "transparent",
|
|
3607
3623
|
stroke: "url(#posGradient)",
|
|
3608
3624
|
strokeWidth: "10",
|
|
3609
|
-
strokeDasharray: `${
|
|
3610
|
-
strokeLinecap:
|
|
3625
|
+
strokeDasharray: `${G / 100 * B} ${B}`,
|
|
3626
|
+
strokeLinecap: G > 0 ? "round" : "butt",
|
|
3611
3627
|
className: "transition-all duration-1000 ease-out drop-shadow-sm"
|
|
3612
3628
|
}
|
|
3613
3629
|
),
|
|
@@ -3616,12 +3632,12 @@ function yr() {
|
|
|
3616
3632
|
{
|
|
3617
3633
|
cx: "50",
|
|
3618
3634
|
cy: "50",
|
|
3619
|
-
r:
|
|
3635
|
+
r: $,
|
|
3620
3636
|
fill: "transparent",
|
|
3621
3637
|
stroke: "url(#negGradient)",
|
|
3622
3638
|
strokeWidth: "10",
|
|
3623
3639
|
strokeDasharray: `${W / 100 * B} ${B}`,
|
|
3624
|
-
strokeDashoffset: -(
|
|
3640
|
+
strokeDashoffset: -(G / 100 * B),
|
|
3625
3641
|
strokeLinecap: W > 0 ? "round" : "butt",
|
|
3626
3642
|
className: "transition-all duration-1000 ease-out drop-shadow-sm"
|
|
3627
3643
|
}
|
|
@@ -3629,16 +3645,16 @@ function yr() {
|
|
|
3629
3645
|
] });
|
|
3630
3646
|
})() }),
|
|
3631
3647
|
/* @__PURE__ */ r("div", { className: "absolute inset-0 flex flex-col items-center justify-center pointer-events-none", children: [
|
|
3632
|
-
/* @__PURE__ */ e("span", { className: "text-3xl lg:text-4xl font-light text-foreground", children:
|
|
3648
|
+
/* @__PURE__ */ e("span", { className: "text-3xl lg:text-4xl font-light text-foreground", children: y.distributions.feedback_sentiment.filter((u) => u.sentiment === "positive" || u.sentiment === "negative").reduce((u, A) => u + (A.count || 0), 0).toLocaleString(i) }),
|
|
3633
3649
|
/* @__PURE__ */ e("span", { className: "text-xs text-muted-foreground uppercase tracking-widest mt-1", children: t("analytics.total_feedback") })
|
|
3634
3650
|
] })
|
|
3635
3651
|
] }),
|
|
3636
|
-
/* @__PURE__ */ e("div", { className: "flex flex-col gap-4 min-w-[140px]", children: [...
|
|
3637
|
-
(
|
|
3638
|
-
).sort((
|
|
3639
|
-
const
|
|
3652
|
+
/* @__PURE__ */ e("div", { className: "flex flex-col gap-4 min-w-[140px]", children: [...y.distributions.feedback_sentiment].filter(
|
|
3653
|
+
(u) => u.sentiment === "positive" || u.sentiment === "negative"
|
|
3654
|
+
).sort((u, A) => u.sentiment === "positive" ? -1 : 1).map((u) => {
|
|
3655
|
+
const D = y.distributions.feedback_sentiment.filter(
|
|
3640
3656
|
(W) => W.sentiment === "positive" || W.sentiment === "negative"
|
|
3641
|
-
).reduce((W, V) => W + V.count, 0),
|
|
3657
|
+
).reduce((W, V) => W + V.count, 0), Q = D > 0 ? u.count / D * 100 : 0, $ = u.sentiment === "positive" ? t("analytics.positive") : t("analytics.negative"), B = u.sentiment === "positive" ? "bg-primary" : "bg-destructive", G = u.sentiment === "positive" ? "👍" : "👎";
|
|
3642
3658
|
return /* @__PURE__ */ r(
|
|
3643
3659
|
"div",
|
|
3644
3660
|
{
|
|
@@ -3652,50 +3668,50 @@ function yr() {
|
|
|
3652
3668
|
}
|
|
3653
3669
|
),
|
|
3654
3670
|
/* @__PURE__ */ r("span", { className: "text-sm text-muted-foreground font-medium", children: [
|
|
3655
|
-
|
|
3671
|
+
$,
|
|
3656
3672
|
" ",
|
|
3657
|
-
|
|
3673
|
+
G
|
|
3658
3674
|
] })
|
|
3659
3675
|
] }),
|
|
3660
3676
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
3661
3677
|
/* @__PURE__ */ r("span", { className: "text-sm font-semibold text-foreground bg-muted/50 px-2.5 py-1 rounded-lg min-w-[50px] text-center", children: [
|
|
3662
|
-
(
|
|
3678
|
+
(Q || 0).toLocaleString(i, {
|
|
3663
3679
|
maximumFractionDigits: 0
|
|
3664
3680
|
}),
|
|
3665
3681
|
"%"
|
|
3666
3682
|
] }),
|
|
3667
3683
|
/* @__PURE__ */ r("span", { className: "text-[13px] font-normal text-muted-foreground w-12 text-right", children: [
|
|
3668
3684
|
"(",
|
|
3669
|
-
(
|
|
3685
|
+
(u.count || 0).toLocaleString(i),
|
|
3670
3686
|
")"
|
|
3671
3687
|
] })
|
|
3672
3688
|
] })
|
|
3673
3689
|
]
|
|
3674
3690
|
},
|
|
3675
|
-
|
|
3691
|
+
u.sentiment
|
|
3676
3692
|
);
|
|
3677
3693
|
}) })
|
|
3678
3694
|
] }) : /* @__PURE__ */ e("p", { className: "text-center text-muted-foreground py-8", children: t("no_data") }) })
|
|
3679
3695
|
] }),
|
|
3680
3696
|
/* @__PURE__ */ r("div", { className: "glass-surface rounded-2xl shadow-sm p-7", children: [
|
|
3681
3697
|
/* @__PURE__ */ e("h3", { className: "text-[11px] font-bold text-muted-foreground/80 mb-6 uppercase tracking-widest", children: t("analytics.active_users") }),
|
|
3682
|
-
/* @__PURE__ */ e("div", { className: "h-64 overflow-y-auto pr-1", children: /* @__PURE__ */ e("div", { className: "space-y-2.5", children:
|
|
3698
|
+
/* @__PURE__ */ e("div", { className: "h-64 overflow-y-auto pr-1", children: /* @__PURE__ */ e("div", { className: "space-y-2.5", children: y.active_users.length > 0 ? y.active_users.slice(0, 5).map((u) => /* @__PURE__ */ r(
|
|
3683
3699
|
"div",
|
|
3684
3700
|
{
|
|
3685
3701
|
className: "flex items-center justify-between p-3 bg-muted/30 rounded-xl hover:bg-muted/50 transition-colors",
|
|
3686
3702
|
children: [
|
|
3687
3703
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
|
|
3688
|
-
/* @__PURE__ */ e("div", { className: "w-9 h-9 rounded-full bg-primary/10 flex items-center justify-center text-primary text-sm font-medium", children:
|
|
3689
|
-
/* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("p", { className: "text-sm font-medium text-foreground", children:
|
|
3704
|
+
/* @__PURE__ */ e("div", { className: "w-9 h-9 rounded-full bg-primary/10 flex items-center justify-center text-primary text-sm font-medium", children: u.name.charAt(0) }),
|
|
3705
|
+
/* @__PURE__ */ e("div", { children: /* @__PURE__ */ e("p", { className: "text-sm font-medium text-foreground", children: u.name }) })
|
|
3690
3706
|
] }),
|
|
3691
3707
|
/* @__PURE__ */ r("div", { className: "text-sm font-semibold text-primary", children: [
|
|
3692
|
-
(
|
|
3708
|
+
(u.thread_count || 0).toLocaleString(i),
|
|
3693
3709
|
" ",
|
|
3694
3710
|
t("analytics.threads")
|
|
3695
3711
|
] })
|
|
3696
3712
|
]
|
|
3697
3713
|
},
|
|
3698
|
-
|
|
3714
|
+
u.user_id
|
|
3699
3715
|
)) : /* @__PURE__ */ e("p", { className: "text-center text-muted-foreground py-8", children: t("no_data") }) }) })
|
|
3700
3716
|
] })
|
|
3701
3717
|
] })
|
|
@@ -3711,7 +3727,7 @@ function Ne({ title: t, icon: a }) {
|
|
|
3711
3727
|
] });
|
|
3712
3728
|
}
|
|
3713
3729
|
function _e({ value: t }) {
|
|
3714
|
-
const { t: a } =
|
|
3730
|
+
const { t: a } = P(["admin", "translation", "settings"]);
|
|
3715
3731
|
if (!t || !t.includes(":") && !t.includes(".")) return null;
|
|
3716
3732
|
const s = a(t);
|
|
3717
3733
|
return s === t ? 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: [
|
|
@@ -3728,7 +3744,7 @@ function _r({
|
|
|
3728
3744
|
accentValue: s,
|
|
3729
3745
|
accentIsValid: l
|
|
3730
3746
|
}) {
|
|
3731
|
-
const { t: o } =
|
|
3747
|
+
const { t: o } = P(["admin", "translation", "settings"]);
|
|
3732
3748
|
return /* @__PURE__ */ r("section", { children: [
|
|
3733
3749
|
/* @__PURE__ */ e(Ne, { title: o("app_settings.sections.general"), icon: Je }),
|
|
3734
3750
|
/* @__PURE__ */ r("div", { className: "p-2 space-y-10", children: [
|
|
@@ -3774,8 +3790,8 @@ function _r({
|
|
|
3774
3790
|
children: [
|
|
3775
3791
|
/* @__PURE__ */ e(Y, { className: "bg-muted/20 border-transparent focus:bg-background h-11 w-full flex-row-reverse justify-end gap-3", children: /* @__PURE__ */ e(ee, {}) }),
|
|
3776
3792
|
/* @__PURE__ */ r(te, { children: [
|
|
3777
|
-
/* @__PURE__ */ e(
|
|
3778
|
-
/* @__PURE__ */ e(
|
|
3793
|
+
/* @__PURE__ */ e(O, { value: "fa", children: "فارسی (Persian)" }),
|
|
3794
|
+
/* @__PURE__ */ e(O, { value: "en", children: "English" })
|
|
3779
3795
|
] })
|
|
3780
3796
|
]
|
|
3781
3797
|
}
|
|
@@ -3807,9 +3823,9 @@ function _r({
|
|
|
3807
3823
|
children: [
|
|
3808
3824
|
/* @__PURE__ */ e(Y, { className: "bg-muted/20 border-transparent focus:bg-background h-11 w-full", children: /* @__PURE__ */ e(ee, {}) }),
|
|
3809
3825
|
/* @__PURE__ */ r(te, { children: [
|
|
3810
|
-
/* @__PURE__ */ e(
|
|
3811
|
-
/* @__PURE__ */ e(
|
|
3812
|
-
/* @__PURE__ */ e(
|
|
3826
|
+
/* @__PURE__ */ e(O, { value: "system", children: o("settings:general.themes.system") }),
|
|
3827
|
+
/* @__PURE__ */ e(O, { value: "light", children: o("settings:general.themes.light") }),
|
|
3828
|
+
/* @__PURE__ */ e(O, { value: "dark", children: o("settings:general.themes.dark") })
|
|
3813
3829
|
] })
|
|
3814
3830
|
]
|
|
3815
3831
|
}
|
|
@@ -3885,7 +3901,7 @@ function $e({
|
|
|
3885
3901
|
onChange: l,
|
|
3886
3902
|
columns: o = 4
|
|
3887
3903
|
}) {
|
|
3888
|
-
const { t: n, i18n: d } =
|
|
3904
|
+
const { t: n, i18n: d } = P(["admin"]), g = d.language === "fa";
|
|
3889
3905
|
return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
|
|
3890
3906
|
/* @__PURE__ */ r("h4", { className: "text-xs font-bold uppercase tracking-wider text-muted-foreground/50 flex items-center gap-2", children: [
|
|
3891
3907
|
/* @__PURE__ */ e("div", { className: "w-1 h-1 rounded-full bg-primary/40" }),
|
|
@@ -3895,31 +3911,31 @@ function $e({
|
|
|
3895
3911
|
"div",
|
|
3896
3912
|
{
|
|
3897
3913
|
className: `grid grid-cols-1 gap-4 ${o === 2 ? "sm:grid-cols-2" : "sm:grid-cols-4"}`,
|
|
3898
|
-
children: a.map((
|
|
3914
|
+
children: a.map((k) => /* @__PURE__ */ r(
|
|
3899
3915
|
"div",
|
|
3900
3916
|
{
|
|
3901
3917
|
className: "p-3 border border-border/40 rounded-xl space-y-2 bg-muted/5",
|
|
3902
3918
|
children: [
|
|
3903
|
-
/* @__PURE__ */ e(z, { className: "text-[10px] font-medium text-muted-foreground/70", children:
|
|
3919
|
+
/* @__PURE__ */ e(z, { className: "text-[10px] font-medium text-muted-foreground/70", children: k.label }),
|
|
3904
3920
|
/* @__PURE__ */ r(
|
|
3905
3921
|
X,
|
|
3906
3922
|
{
|
|
3907
|
-
value: s?.[
|
|
3908
|
-
onValueChange: (
|
|
3923
|
+
value: s?.[k.id] || "editable",
|
|
3924
|
+
onValueChange: (L) => l(k.id, L),
|
|
3909
3925
|
dir: g ? "rtl" : "ltr",
|
|
3910
3926
|
children: [
|
|
3911
3927
|
/* @__PURE__ */ e(Y, { className: "bg-background border-transparent h-8 text-[10px]", children: /* @__PURE__ */ e(ee, {}) }),
|
|
3912
3928
|
/* @__PURE__ */ r(te, { children: [
|
|
3913
|
-
/* @__PURE__ */ e(
|
|
3914
|
-
/* @__PURE__ */ e(
|
|
3915
|
-
/* @__PURE__ */ e(
|
|
3929
|
+
/* @__PURE__ */ e(O, { value: "editable", className: "text-[10px]", children: n("app_settings.chat.mode_editable") }),
|
|
3930
|
+
/* @__PURE__ */ e(O, { value: "faded", className: "text-[10px]", children: n("app_settings.chat.mode_faded") }),
|
|
3931
|
+
/* @__PURE__ */ e(O, { value: "hidden", className: "text-[10px]", children: n("app_settings.chat.mode_hidden") })
|
|
3916
3932
|
] })
|
|
3917
3933
|
]
|
|
3918
3934
|
}
|
|
3919
3935
|
)
|
|
3920
3936
|
]
|
|
3921
3937
|
},
|
|
3922
|
-
|
|
3938
|
+
k.id
|
|
3923
3939
|
))
|
|
3924
3940
|
}
|
|
3925
3941
|
)
|
|
@@ -3931,7 +3947,7 @@ function Nr({
|
|
|
3931
3947
|
userMetadataFields: s,
|
|
3932
3948
|
isRtl: l
|
|
3933
3949
|
}) {
|
|
3934
|
-
const { t: o } =
|
|
3950
|
+
const { t: o } = P(["admin", "translation", "settings"]);
|
|
3935
3951
|
return /* @__PURE__ */ r("section", { children: [
|
|
3936
3952
|
/* @__PURE__ */ e(Ne, { title: o("app_settings.sections.chat"), icon: Mt }),
|
|
3937
3953
|
/* @__PURE__ */ r("div", { className: "p-2 space-y-10", children: [
|
|
@@ -4130,9 +4146,9 @@ function Nr({
|
|
|
4130
4146
|
children: [
|
|
4131
4147
|
/* @__PURE__ */ e(Y, { className: "bg-background border-transparent h-9 text-xs", children: /* @__PURE__ */ e(ee, {}) }),
|
|
4132
4148
|
/* @__PURE__ */ r(te, { children: [
|
|
4133
|
-
/* @__PURE__ */ e(
|
|
4134
|
-
/* @__PURE__ */ e(
|
|
4135
|
-
/* @__PURE__ */ e(
|
|
4149
|
+
/* @__PURE__ */ e(O, { value: "editable", children: o("app_settings.chat.mode_editable") }),
|
|
4150
|
+
/* @__PURE__ */ e(O, { value: "faded", children: o("app_settings.chat.mode_faded") }),
|
|
4151
|
+
/* @__PURE__ */ e(O, { value: "hidden", children: o("app_settings.chat.mode_hidden") })
|
|
4136
4152
|
] })
|
|
4137
4153
|
]
|
|
4138
4154
|
}
|
|
@@ -4232,28 +4248,28 @@ function kr(t) {
|
|
|
4232
4248
|
}
|
|
4233
4249
|
}
|
|
4234
4250
|
function Cr({ job: t, onClose: a }) {
|
|
4235
|
-
const { t: s } =
|
|
4236
|
-
const
|
|
4237
|
-
for (const
|
|
4238
|
-
const
|
|
4239
|
-
|
|
4251
|
+
const { t: s } = P(["admin"]), { runRegisteredJob: l } = We(), [o, n] = _(() => {
|
|
4252
|
+
const i = {};
|
|
4253
|
+
for (const b of t.params) {
|
|
4254
|
+
const j = b.default, y = typeof j == "string" || typeof j == "number" || typeof j == "boolean";
|
|
4255
|
+
i[b.name] = y ? String(j) : b.type === "bool" ? "false" : "";
|
|
4240
4256
|
}
|
|
4241
|
-
return
|
|
4242
|
-
}), [d, g] =
|
|
4243
|
-
const
|
|
4244
|
-
for (const
|
|
4245
|
-
const
|
|
4246
|
-
|
|
4257
|
+
return i;
|
|
4258
|
+
}), [d, g] = _(!1), [k, L] = _(""), N = t.danger === "destructive", x = !N || k.trim() === t.name, h = (i, b) => n((j) => ({ ...j, [i]: b })), v = async () => {
|
|
4259
|
+
const i = {};
|
|
4260
|
+
for (const b of t.params) {
|
|
4261
|
+
const j = o[b.name];
|
|
4262
|
+
b.type === "bool" ? i[b.name] = j === "true" : j !== "" && (i[b.name] = j);
|
|
4247
4263
|
}
|
|
4248
4264
|
try {
|
|
4249
4265
|
await l.mutateAsync({
|
|
4250
4266
|
jobId: t.id,
|
|
4251
|
-
params:
|
|
4267
|
+
params: i,
|
|
4252
4268
|
dry_run: d,
|
|
4253
|
-
confirm:
|
|
4254
|
-
}),
|
|
4255
|
-
} catch (
|
|
4256
|
-
|
|
4269
|
+
confirm: N ? k : void 0
|
|
4270
|
+
}), ve.success(s("jobs.run_started", { name: t.name })), a();
|
|
4271
|
+
} catch (b) {
|
|
4272
|
+
ve.error(b instanceof Error ? b.message : s("jobs.run_failed"));
|
|
4257
4273
|
}
|
|
4258
4274
|
};
|
|
4259
4275
|
return (
|
|
@@ -4275,47 +4291,47 @@ function Cr({ job: t, onClose: a }) {
|
|
|
4275
4291
|
t.description && /* @__PURE__ */ e(Ie, { children: t.description })
|
|
4276
4292
|
] }),
|
|
4277
4293
|
/* @__PURE__ */ r("div", { className: "space-y-4 py-2", children: [
|
|
4278
|
-
t.params.map((
|
|
4294
|
+
t.params.map((i) => /* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
|
|
4279
4295
|
/* @__PURE__ */ r(z, { className: "text-xs font-bold text-muted-foreground", children: [
|
|
4280
|
-
|
|
4281
|
-
|
|
4296
|
+
i.label || i.name,
|
|
4297
|
+
i.required && /* @__PURE__ */ e("span", { className: "text-destructive ml-1", children: "*" })
|
|
4282
4298
|
] }),
|
|
4283
|
-
|
|
4299
|
+
i.type === "bool" ? /* @__PURE__ */ e("div", { className: "flex items-center gap-2", children: /* @__PURE__ */ e(
|
|
4284
4300
|
le,
|
|
4285
4301
|
{
|
|
4286
|
-
checked: o[
|
|
4287
|
-
onCheckedChange: (
|
|
4302
|
+
checked: o[i.name] === "true",
|
|
4303
|
+
onCheckedChange: (b) => h(i.name, b ? "true" : "false")
|
|
4288
4304
|
}
|
|
4289
|
-
) }) :
|
|
4305
|
+
) }) : i.choices && i.choices.length > 0 ? /* @__PURE__ */ r(
|
|
4290
4306
|
"select",
|
|
4291
4307
|
{
|
|
4292
|
-
value: o[
|
|
4293
|
-
onChange: (
|
|
4308
|
+
value: o[i.name],
|
|
4309
|
+
onChange: (b) => h(i.name, b.target.value),
|
|
4294
4310
|
className: "w-full h-10 rounded-md border border-input bg-muted/20 px-3 text-sm",
|
|
4295
4311
|
children: [
|
|
4296
4312
|
/* @__PURE__ */ e("option", { value: "", children: "—" }),
|
|
4297
|
-
|
|
4313
|
+
i.choices.map((b) => /* @__PURE__ */ e("option", { value: b, children: b }, b))
|
|
4298
4314
|
]
|
|
4299
4315
|
}
|
|
4300
|
-
) :
|
|
4316
|
+
) : i.type === "text" ? /* @__PURE__ */ e(
|
|
4301
4317
|
De,
|
|
4302
4318
|
{
|
|
4303
|
-
value: o[
|
|
4304
|
-
onChange: (
|
|
4319
|
+
value: o[i.name],
|
|
4320
|
+
onChange: (b) => h(i.name, b.target.value),
|
|
4305
4321
|
className: "bg-muted/20 font-mono text-xs",
|
|
4306
4322
|
rows: 4
|
|
4307
4323
|
}
|
|
4308
4324
|
) : /* @__PURE__ */ e(
|
|
4309
4325
|
se,
|
|
4310
4326
|
{
|
|
4311
|
-
type:
|
|
4312
|
-
value: o[
|
|
4313
|
-
onChange: (
|
|
4327
|
+
type: i.type === "int" || i.type === "float" ? "number" : "text",
|
|
4328
|
+
value: o[i.name],
|
|
4329
|
+
onChange: (b) => h(i.name, b.target.value),
|
|
4314
4330
|
className: "bg-muted/20 border-transparent"
|
|
4315
4331
|
}
|
|
4316
4332
|
),
|
|
4317
|
-
|
|
4318
|
-
] },
|
|
4333
|
+
i.help && /* @__PURE__ */ e("p", { className: "text-[11px] text-muted-foreground/70", children: i.help })
|
|
4334
|
+
] }, i.name)),
|
|
4319
4335
|
t.supports_dry_run && /* @__PURE__ */ r("div", { className: "flex items-center justify-between rounded-xl border border-border/40 p-3", children: [
|
|
4320
4336
|
/* @__PURE__ */ r("div", { children: [
|
|
4321
4337
|
/* @__PURE__ */ e("p", { className: "text-sm font-medium", children: s("jobs.dry_run") }),
|
|
@@ -4323,7 +4339,7 @@ function Cr({ job: t, onClose: a }) {
|
|
|
4323
4339
|
] }),
|
|
4324
4340
|
/* @__PURE__ */ e(le, { checked: d, onCheckedChange: g })
|
|
4325
4341
|
] }),
|
|
4326
|
-
|
|
4342
|
+
N && /* @__PURE__ */ r("div", { className: "space-y-1.5", children: [
|
|
4327
4343
|
/* @__PURE__ */ r(z, { className: "text-xs font-bold text-destructive flex items-center gap-1.5", children: [
|
|
4328
4344
|
/* @__PURE__ */ e(Ft, { className: "size-3.5" }),
|
|
4329
4345
|
s("jobs.confirm_destructive", { name: t.name })
|
|
@@ -4331,8 +4347,8 @@ function Cr({ job: t, onClose: a }) {
|
|
|
4331
4347
|
/* @__PURE__ */ e(
|
|
4332
4348
|
se,
|
|
4333
4349
|
{
|
|
4334
|
-
value:
|
|
4335
|
-
onChange: (
|
|
4350
|
+
value: k,
|
|
4351
|
+
onChange: (i) => L(i.target.value),
|
|
4336
4352
|
placeholder: t.name,
|
|
4337
4353
|
className: "border-destructive/30"
|
|
4338
4354
|
}
|
|
@@ -4344,8 +4360,8 @@ function Cr({ job: t, onClose: a }) {
|
|
|
4344
4360
|
/* @__PURE__ */ r(
|
|
4345
4361
|
ne,
|
|
4346
4362
|
{
|
|
4347
|
-
variant:
|
|
4348
|
-
onClick:
|
|
4363
|
+
variant: N ? "destructive" : "default",
|
|
4364
|
+
onClick: v,
|
|
4349
4365
|
disabled: !x || l.isPending,
|
|
4350
4366
|
children: [
|
|
4351
4367
|
l.isPending ? /* @__PURE__ */ e(He, { className: "size-4 animate-spin" }) : /* @__PURE__ */ e(Ve, { className: "size-4" }),
|
|
@@ -4360,7 +4376,7 @@ function Cr({ job: t, onClose: a }) {
|
|
|
4360
4376
|
);
|
|
4361
4377
|
}
|
|
4362
4378
|
function Sr({ run: t }) {
|
|
4363
|
-
const { t: a } =
|
|
4379
|
+
const { t: a } = P(["admin"]), s = t.params && Object.keys(t.params).length > 0;
|
|
4364
4380
|
return /* @__PURE__ */ r("div", { className: "space-y-3 pt-3", dir: "ltr", children: [
|
|
4365
4381
|
(s || t.code) && /* @__PURE__ */ r("div", { children: [
|
|
4366
4382
|
/* @__PURE__ */ e(z, { className: "text-xs font-bold text-muted-foreground", children: a("jobs.inputs") }),
|
|
@@ -4382,7 +4398,7 @@ ${a("jobs.output_truncated")}` : ""
|
|
|
4382
4398
|
] });
|
|
4383
4399
|
}
|
|
4384
4400
|
function Lr({ summary: t }) {
|
|
4385
|
-
const { t: a, i18n: s } =
|
|
4401
|
+
const { t: a, i18n: s } = P(["admin"]), [l, o] = _(!1), n = t.status === "queued" || t.status === "processing", { data: d } = ir(l ? t.id : null, n), { cancelJobRun: g } = We(), k = d ?? t, L = new Intl.DateTimeFormat(s.language === "fa" ? "fa-IR" : void 0, {
|
|
4386
4402
|
dateStyle: "short",
|
|
4387
4403
|
timeStyle: "short"
|
|
4388
4404
|
});
|
|
@@ -4391,7 +4407,7 @@ function Lr({ summary: t }) {
|
|
|
4391
4407
|
"button",
|
|
4392
4408
|
{
|
|
4393
4409
|
type: "button",
|
|
4394
|
-
onClick: () => o((
|
|
4410
|
+
onClick: () => o((N) => !N),
|
|
4395
4411
|
className: "w-full flex items-center justify-between gap-3 p-3 text-start hover:bg-muted/10 transition-all",
|
|
4396
4412
|
children: [
|
|
4397
4413
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2 min-w-0", children: [
|
|
@@ -4401,30 +4417,30 @@ function Lr({ summary: t }) {
|
|
|
4401
4417
|
className: `size-3.5 text-muted-foreground/60 shrink-0 transition-transform ${l ? "" : "-rotate-90"}`
|
|
4402
4418
|
}
|
|
4403
4419
|
),
|
|
4404
|
-
/* @__PURE__ */ e(qe, { variant: "outline", className: kr(
|
|
4405
|
-
/* @__PURE__ */ e("span", { className: "text-sm truncate", children:
|
|
4406
|
-
|
|
4420
|
+
/* @__PURE__ */ e(qe, { variant: "outline", className: kr(k.status), children: a(`jobs.status.${k.status}`) }),
|
|
4421
|
+
/* @__PURE__ */ e("span", { className: "text-sm truncate", children: k.name }),
|
|
4422
|
+
k.dry_run && /* @__PURE__ */ r("span", { className: "text-[10px] text-muted-foreground/60", children: [
|
|
4407
4423
|
"(",
|
|
4408
4424
|
a("jobs.dry_run"),
|
|
4409
4425
|
")"
|
|
4410
4426
|
] })
|
|
4411
4427
|
] }),
|
|
4412
4428
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-3 text-[11px] text-muted-foreground/60 shrink-0", children: [
|
|
4413
|
-
|
|
4414
|
-
/* @__PURE__ */ e("span", { dir: "ltr", children:
|
|
4429
|
+
k.triggered_by_username && /* @__PURE__ */ e("span", { children: k.triggered_by_username }),
|
|
4430
|
+
/* @__PURE__ */ e("span", { dir: "ltr", children: L.format(new Date(k.created_at)) })
|
|
4415
4431
|
] })
|
|
4416
4432
|
]
|
|
4417
4433
|
}
|
|
4418
4434
|
),
|
|
4419
4435
|
l && /* @__PURE__ */ e("div", { className: "px-3 pb-3", children: d ? /* @__PURE__ */ r(at, { children: [
|
|
4420
|
-
/* @__PURE__ */ e(Sr, { run:
|
|
4436
|
+
/* @__PURE__ */ e(Sr, { run: k }),
|
|
4421
4437
|
n && /* @__PURE__ */ r(
|
|
4422
4438
|
ne,
|
|
4423
4439
|
{
|
|
4424
4440
|
variant: "outline",
|
|
4425
4441
|
size: "sm",
|
|
4426
4442
|
className: "mt-3",
|
|
4427
|
-
onClick: () => g.mutate(
|
|
4443
|
+
onClick: () => g.mutate(k.id),
|
|
4428
4444
|
disabled: g.isPending,
|
|
4429
4445
|
children: [
|
|
4430
4446
|
/* @__PURE__ */ e(Pt, { className: "size-3.5" }),
|
|
@@ -4439,7 +4455,7 @@ function Lr({ summary: t }) {
|
|
|
4439
4455
|
] });
|
|
4440
4456
|
}
|
|
4441
4457
|
function qr({ runs: t }) {
|
|
4442
|
-
const { t: a } =
|
|
4458
|
+
const { t: a } = P(["admin"]);
|
|
4443
4459
|
return /* @__PURE__ */ r(je, { className: "max-w-2xl", children: [
|
|
4444
4460
|
/* @__PURE__ */ r(Te, { children: [
|
|
4445
4461
|
/* @__PURE__ */ e(Ae, { children: a("jobs.history") }),
|
|
@@ -4450,11 +4466,11 @@ function qr({ runs: t }) {
|
|
|
4450
4466
|
] });
|
|
4451
4467
|
}
|
|
4452
4468
|
function jr() {
|
|
4453
|
-
const { t } =
|
|
4469
|
+
const { t } = P(["admin"]), { runRawJob: a } = We(), [s, l] = _(!1), [o, n] = _(""), [d, g] = _(""), k = o.trim() !== "" && d.trim() === Oe, L = async () => {
|
|
4454
4470
|
try {
|
|
4455
|
-
await a.mutateAsync({ code: o, confirm_phrase: d }),
|
|
4456
|
-
} catch (
|
|
4457
|
-
|
|
4471
|
+
await a.mutateAsync({ code: o, confirm_phrase: d }), ve.success(t("jobs.run_started", { name: "Raw Python" })), n(""), g("");
|
|
4472
|
+
} catch (N) {
|
|
4473
|
+
ve.error(N instanceof Error ? N.message : t("jobs.run_failed"));
|
|
4458
4474
|
}
|
|
4459
4475
|
};
|
|
4460
4476
|
return /* @__PURE__ */ r("div", { className: "rounded-2xl border border-destructive/30 bg-destructive/5 overflow-hidden", children: [
|
|
@@ -4462,7 +4478,7 @@ function jr() {
|
|
|
4462
4478
|
"button",
|
|
4463
4479
|
{
|
|
4464
4480
|
type: "button",
|
|
4465
|
-
onClick: () => l((
|
|
4481
|
+
onClick: () => l((N) => !N),
|
|
4466
4482
|
className: "w-full flex items-center justify-between gap-2 p-4 text-start",
|
|
4467
4483
|
children: [
|
|
4468
4484
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
@@ -4485,7 +4501,7 @@ function jr() {
|
|
|
4485
4501
|
{
|
|
4486
4502
|
dir: "ltr",
|
|
4487
4503
|
value: o,
|
|
4488
|
-
onChange: (
|
|
4504
|
+
onChange: (N) => n(N.target.value),
|
|
4489
4505
|
rows: 8,
|
|
4490
4506
|
spellCheck: !1,
|
|
4491
4507
|
placeholder: `print("hello")
|
|
@@ -4500,7 +4516,7 @@ result = {"ok": True}`,
|
|
|
4500
4516
|
{
|
|
4501
4517
|
dir: "ltr",
|
|
4502
4518
|
value: d,
|
|
4503
|
-
onChange: (
|
|
4519
|
+
onChange: (N) => g(N.target.value),
|
|
4504
4520
|
placeholder: Oe,
|
|
4505
4521
|
className: "border-destructive/30 text-left"
|
|
4506
4522
|
}
|
|
@@ -4510,8 +4526,8 @@ result = {"ok": True}`,
|
|
|
4510
4526
|
ne,
|
|
4511
4527
|
{
|
|
4512
4528
|
variant: "destructive",
|
|
4513
|
-
onClick:
|
|
4514
|
-
disabled: !
|
|
4529
|
+
onClick: L,
|
|
4530
|
+
disabled: !k || a.isPending,
|
|
4515
4531
|
children: [
|
|
4516
4532
|
a.isPending ? /* @__PURE__ */ e(He, { className: "size-4 animate-spin" }) : /* @__PURE__ */ e(Ve, { className: "size-4" }),
|
|
4517
4533
|
t("jobs.raw.run")
|
|
@@ -4522,78 +4538,78 @@ result = {"ok": True}`,
|
|
|
4522
4538
|
] });
|
|
4523
4539
|
}
|
|
4524
4540
|
function Tr() {
|
|
4525
|
-
const { t } =
|
|
4541
|
+
const { t } = P(["admin"]), a = pe(() => wr(), []), s = a.includes("jobs"), l = a.includes("dangerous_jobs"), { data: o } = sr(s), { data: n } = or({ limit: 50 }, s), [d, g] = _(null), [k, L] = _(!1);
|
|
4526
4542
|
if (!s) return null;
|
|
4527
|
-
const
|
|
4543
|
+
const N = o?.jobs || [], x = n?.runs || [];
|
|
4528
4544
|
return /* @__PURE__ */ r("section", { children: [
|
|
4529
4545
|
/* @__PURE__ */ e(Ne, { title: t("jobs.section_title"), icon: $t }),
|
|
4530
4546
|
/* @__PURE__ */ r("div", { className: "p-2 space-y-8", children: [
|
|
4531
4547
|
/* @__PURE__ */ r("div", { className: "space-y-3 text-left", dir: "ltr", children: [
|
|
4532
|
-
|
|
4533
|
-
|
|
4548
|
+
N.length === 0 && /* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground/70 italic", children: t("jobs.no_jobs") }),
|
|
4549
|
+
N.map((h) => /* @__PURE__ */ r(
|
|
4534
4550
|
"div",
|
|
4535
4551
|
{
|
|
4536
4552
|
className: "flex items-center justify-between gap-4 rounded-2xl border border-border/40 p-4 hover:bg-muted/5 transition-all",
|
|
4537
4553
|
children: [
|
|
4538
4554
|
/* @__PURE__ */ r("div", { className: "min-w-0", children: [
|
|
4539
4555
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
4540
|
-
/* @__PURE__ */ e("p", { className: "text-sm font-bold truncate", children:
|
|
4541
|
-
/* @__PURE__ */ e(qe, { variant: "outline", className: ut(
|
|
4556
|
+
/* @__PURE__ */ e("p", { className: "text-sm font-bold truncate", children: h.name }),
|
|
4557
|
+
/* @__PURE__ */ e(qe, { variant: "outline", className: ut(h.danger), children: t(`jobs.danger.${h.danger}`) })
|
|
4542
4558
|
] }),
|
|
4543
|
-
|
|
4559
|
+
h.description && /* @__PURE__ */ e("p", { className: "text-xs text-muted-foreground/70 mt-0.5 line-clamp-2", children: h.description })
|
|
4544
4560
|
] }),
|
|
4545
|
-
/* @__PURE__ */ r(ne, { variant: "outline", size: "sm", onClick: () => g(
|
|
4561
|
+
/* @__PURE__ */ r(ne, { variant: "outline", size: "sm", onClick: () => g(h), children: [
|
|
4546
4562
|
/* @__PURE__ */ e(Ve, { className: "size-3.5" }),
|
|
4547
4563
|
t("jobs.run")
|
|
4548
4564
|
] })
|
|
4549
4565
|
]
|
|
4550
4566
|
},
|
|
4551
|
-
|
|
4567
|
+
h.id
|
|
4552
4568
|
))
|
|
4553
4569
|
] }),
|
|
4554
|
-
/* @__PURE__ */ e("div", { children: /* @__PURE__ */ r(ne, { variant: "outline", size: "sm", onClick: () =>
|
|
4570
|
+
/* @__PURE__ */ e("div", { children: /* @__PURE__ */ r(ne, { variant: "outline", size: "sm", onClick: () => L(!0), children: [
|
|
4555
4571
|
/* @__PURE__ */ e(Ot, { className: "size-3.5" }),
|
|
4556
4572
|
t("jobs.view_history"),
|
|
4557
4573
|
x.length > 0 && /* @__PURE__ */ e(qe, { variant: "secondary", className: "ml-1", children: x.length })
|
|
4558
4574
|
] }) }),
|
|
4559
4575
|
l && /* @__PURE__ */ e(jr, {})
|
|
4560
4576
|
] }),
|
|
4561
|
-
/* @__PURE__ */ e(Le, { open: !!d, onOpenChange: (
|
|
4562
|
-
/* @__PURE__ */ e(Le, { open:
|
|
4577
|
+
/* @__PURE__ */ e(Le, { open: !!d, onOpenChange: (h) => !h && g(null), children: d && /* @__PURE__ */ e(Cr, { job: d, onClose: () => g(null) }) }),
|
|
4578
|
+
/* @__PURE__ */ e(Le, { open: k, onOpenChange: L, children: k && /* @__PURE__ */ e(qr, { runs: x }) })
|
|
4563
4579
|
] });
|
|
4564
4580
|
}
|
|
4565
4581
|
function Ar({ translations: t, onChange: a }) {
|
|
4566
|
-
const { t: s } =
|
|
4582
|
+
const { t: s } = P(["admin"]), [l, o] = _("fa"), [n, d] = _("translation"), [g, k] = _("{}"), [L, N] = _("");
|
|
4567
4583
|
H(() => {
|
|
4568
|
-
const
|
|
4569
|
-
|
|
4584
|
+
const i = t?.[l]?.[n] || {};
|
|
4585
|
+
k(JSON.stringify(i, null, 2)), N("");
|
|
4570
4586
|
}, [l, n, t]);
|
|
4571
|
-
const x = (
|
|
4572
|
-
|
|
4587
|
+
const x = (i) => {
|
|
4588
|
+
k(i);
|
|
4573
4589
|
try {
|
|
4574
|
-
const
|
|
4590
|
+
const b = JSON.parse(i);
|
|
4575
4591
|
a({
|
|
4576
4592
|
...t,
|
|
4577
4593
|
[l]: {
|
|
4578
4594
|
...t?.[l],
|
|
4579
|
-
[n]:
|
|
4595
|
+
[n]: b
|
|
4580
4596
|
}
|
|
4581
|
-
}),
|
|
4597
|
+
}), N("");
|
|
4582
4598
|
} catch {
|
|
4583
|
-
|
|
4599
|
+
N("Invalid JSON format");
|
|
4584
4600
|
}
|
|
4585
|
-
},
|
|
4586
|
-
const
|
|
4587
|
-
|
|
4588
|
-
},
|
|
4589
|
-
const
|
|
4590
|
-
|
|
4601
|
+
}, h = () => {
|
|
4602
|
+
const i = prompt("Enter language code (e.g. en, fa, fr):");
|
|
4603
|
+
i && !t?.[i] && (a({ ...t, [i]: {} }), o(i));
|
|
4604
|
+
}, v = () => {
|
|
4605
|
+
const i = prompt("Enter namespace (e.g. chat, admin):");
|
|
4606
|
+
i && !t?.[l]?.[i] && (a({
|
|
4591
4607
|
...t,
|
|
4592
4608
|
[l]: {
|
|
4593
4609
|
...t?.[l],
|
|
4594
|
-
[
|
|
4610
|
+
[i]: {}
|
|
4595
4611
|
}
|
|
4596
|
-
}), d(
|
|
4612
|
+
}), d(i));
|
|
4597
4613
|
};
|
|
4598
4614
|
return /* @__PURE__ */ r("div", { className: "border border-border/60 rounded-2xl overflow-hidden bg-background", children: [
|
|
4599
4615
|
/* @__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: [
|
|
@@ -4608,7 +4624,7 @@ function Ar({ translations: t, onChange: a }) {
|
|
|
4608
4624
|
children: /* @__PURE__ */ e(ee, {})
|
|
4609
4625
|
}
|
|
4610
4626
|
),
|
|
4611
|
-
/* @__PURE__ */ e(te, { children: Object.keys(t || {}).sort().map((
|
|
4627
|
+
/* @__PURE__ */ e(te, { children: Object.keys(t || {}).sort().map((i) => /* @__PURE__ */ e(O, { value: i, children: i.toUpperCase() }, i)) })
|
|
4612
4628
|
] }),
|
|
4613
4629
|
/* @__PURE__ */ e("div", { className: "w-px h-6 bg-border/60" }),
|
|
4614
4630
|
/* @__PURE__ */ r(X, { value: n, onValueChange: d, children: [
|
|
@@ -4620,7 +4636,7 @@ function Ar({ translations: t, onChange: a }) {
|
|
|
4620
4636
|
children: /* @__PURE__ */ e(ee, {})
|
|
4621
4637
|
}
|
|
4622
4638
|
),
|
|
4623
|
-
/* @__PURE__ */ e(te, { children: Object.keys(t?.[l] || {}).sort().map((
|
|
4639
|
+
/* @__PURE__ */ e(te, { children: Object.keys(t?.[l] || {}).sort().map((i) => /* @__PURE__ */ e(O, { value: i, children: i }, i)) })
|
|
4624
4640
|
] })
|
|
4625
4641
|
] }),
|
|
4626
4642
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
|
|
@@ -4628,7 +4644,7 @@ function Ar({ translations: t, onChange: a }) {
|
|
|
4628
4644
|
"button",
|
|
4629
4645
|
{
|
|
4630
4646
|
type: "button",
|
|
4631
|
-
onClick:
|
|
4647
|
+
onClick: h,
|
|
4632
4648
|
title: "Add Language",
|
|
4633
4649
|
className: "p-2.5 hover:bg-muted/30 rounded-xl transition-all border border-border/40",
|
|
4634
4650
|
children: /* @__PURE__ */ e(Jt, { className: "size-4" })
|
|
@@ -4638,7 +4654,7 @@ function Ar({ translations: t, onChange: a }) {
|
|
|
4638
4654
|
"button",
|
|
4639
4655
|
{
|
|
4640
4656
|
type: "button",
|
|
4641
|
-
onClick:
|
|
4657
|
+
onClick: v,
|
|
4642
4658
|
title: "Add Namespace",
|
|
4643
4659
|
className: "p-2.5 hover:bg-muted/30 rounded-xl transition-all border border-border/40",
|
|
4644
4660
|
children: /* @__PURE__ */ e(Je, { className: "size-4" })
|
|
@@ -4655,15 +4671,15 @@ function Ar({ translations: t, onChange: a }) {
|
|
|
4655
4671
|
De,
|
|
4656
4672
|
{
|
|
4657
4673
|
value: g,
|
|
4658
|
-
onChange: (
|
|
4674
|
+
onChange: (i) => x(i.target.value),
|
|
4659
4675
|
dir: "ltr",
|
|
4660
|
-
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 ${
|
|
4676
|
+
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 ${L ? "border-destructive/40 focus:ring-destructive/20" : "border-border/40 focus:ring-primary/20"}`,
|
|
4661
4677
|
spellCheck: !1
|
|
4662
4678
|
}
|
|
4663
4679
|
),
|
|
4664
|
-
|
|
4680
|
+
L && /* @__PURE__ */ r("div", { className: "mt-2 text-[11px] text-destructive font-bold flex items-center gap-2 px-2", children: [
|
|
4665
4681
|
/* @__PURE__ */ e("div", { className: "size-1.5 rounded-full bg-destructive animate-pulse" }),
|
|
4666
|
-
|
|
4682
|
+
L
|
|
4667
4683
|
] })
|
|
4668
4684
|
] }),
|
|
4669
4685
|
/* @__PURE__ */ e("div", { className: "p-6 bg-muted/5 border-t border-border/40 flex items-center justify-between", children: /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
|
|
@@ -4673,21 +4689,21 @@ function Ar({ translations: t, onChange: a }) {
|
|
|
4673
4689
|
] });
|
|
4674
4690
|
}
|
|
4675
4691
|
function Ir() {
|
|
4676
|
-
const { t, i18n: a } =
|
|
4692
|
+
const { t, i18n: a } = P(["admin", "translation", "settings"]), {
|
|
4677
4693
|
app: s,
|
|
4678
4694
|
welcome: l,
|
|
4679
4695
|
disclaimer: o,
|
|
4680
4696
|
history: n,
|
|
4681
4697
|
threadActions: d,
|
|
4682
4698
|
composer: g,
|
|
4683
|
-
theme:
|
|
4684
|
-
settings:
|
|
4685
|
-
} =
|
|
4699
|
+
theme: k,
|
|
4700
|
+
settings: L
|
|
4701
|
+
} = me(), [N, x] = _(!1), [h, v] = _(!1), [i, b] = _(""), [j, y] = _(""), [E, p] = _(!1), C = pe(
|
|
4686
4702
|
() => ({
|
|
4687
4703
|
app_name: s?.name || "Gentiq",
|
|
4688
4704
|
admin_title: s?.adminTitle || "",
|
|
4689
|
-
default_theme:
|
|
4690
|
-
default_accent:
|
|
4705
|
+
default_theme: k?.defaultTheme || "system",
|
|
4706
|
+
default_accent: k?.accent || "oklch(0.623 0.214 259.815)",
|
|
4691
4707
|
welcome_greeting: typeof l?.greeting == "string" ? l.greeting : "",
|
|
4692
4708
|
welcome_subtitle: l?.subtitle || "",
|
|
4693
4709
|
disclaimer: typeof o == "string" ? o : "",
|
|
@@ -4707,9 +4723,9 @@ function Ir() {
|
|
|
4707
4723
|
settings_general_mode: s?.settingsGeneralMode || "editable",
|
|
4708
4724
|
settings_profile_mode: s?.settingsProfileMode || "editable",
|
|
4709
4725
|
settings_account_mode: s?.settingsAccountMode || "editable",
|
|
4710
|
-
settings_general_fields:
|
|
4711
|
-
settings_profile_fields:
|
|
4712
|
-
settings_account_fields:
|
|
4726
|
+
settings_general_fields: L?.sections?.general?.fields || {},
|
|
4727
|
+
settings_profile_fields: L?.sections?.profile?.fields || {},
|
|
4728
|
+
settings_account_fields: L?.sections?.account?.fields || {},
|
|
4713
4729
|
language: a.language || "fa",
|
|
4714
4730
|
initial_balance_tokens: 25e4,
|
|
4715
4731
|
initial_balance_requests: 100,
|
|
@@ -4722,74 +4738,74 @@ function Ir() {
|
|
|
4722
4738
|
n,
|
|
4723
4739
|
d,
|
|
4724
4740
|
g,
|
|
4725
|
-
|
|
4741
|
+
k,
|
|
4726
4742
|
a.language,
|
|
4727
|
-
|
|
4743
|
+
L
|
|
4728
4744
|
]
|
|
4729
|
-
), [
|
|
4745
|
+
), [m, w] = _(C), T = a.language === "fa", f = (m.default_accent || "").trim(), M = !f || typeof CSS < "u" && CSS.supports("color", f);
|
|
4730
4746
|
H(() => {
|
|
4731
4747
|
(async () => {
|
|
4732
4748
|
x(!0);
|
|
4733
4749
|
try {
|
|
4734
|
-
const
|
|
4735
|
-
if (
|
|
4736
|
-
const
|
|
4737
|
-
|
|
4738
|
-
|
|
4739
|
-
}),
|
|
4740
|
-
...
|
|
4741
|
-
...
|
|
4750
|
+
const u = await I.getSettings();
|
|
4751
|
+
if (u && Object.keys(u).length > 0) {
|
|
4752
|
+
const A = JSON.parse(JSON.stringify(a.store.data));
|
|
4753
|
+
u.translations && Object.keys(u.translations).forEach((D) => {
|
|
4754
|
+
A[D] || (A[D] = {}), Object.assign(A[D], u.translations[D]);
|
|
4755
|
+
}), w((D) => ({
|
|
4756
|
+
...D,
|
|
4757
|
+
...u,
|
|
4742
4758
|
// The backend types these field maps as Record<string, unknown>; they
|
|
4743
4759
|
// are really SettingsFieldMode maps for this editor.
|
|
4744
|
-
settings_general_fields:
|
|
4745
|
-
settings_profile_fields:
|
|
4746
|
-
settings_account_fields:
|
|
4747
|
-
translations:
|
|
4760
|
+
settings_general_fields: u.settings_general_fields ?? D.settings_general_fields,
|
|
4761
|
+
settings_profile_fields: u.settings_profile_fields ?? D.settings_profile_fields,
|
|
4762
|
+
settings_account_fields: u.settings_account_fields ?? D.settings_account_fields,
|
|
4763
|
+
translations: A
|
|
4748
4764
|
}));
|
|
4749
4765
|
} else {
|
|
4750
|
-
const
|
|
4751
|
-
...
|
|
4766
|
+
const A = {
|
|
4767
|
+
...C,
|
|
4752
4768
|
translations: a.store.data
|
|
4753
4769
|
};
|
|
4754
|
-
|
|
4770
|
+
w(A), u || I.updateSettings(A).catch(console.error);
|
|
4755
4771
|
}
|
|
4756
|
-
} catch (
|
|
4757
|
-
console.error("Failed to fetch settings",
|
|
4772
|
+
} catch (u) {
|
|
4773
|
+
console.error("Failed to fetch settings", u), b(t("app_settings.save_error"));
|
|
4758
4774
|
} finally {
|
|
4759
4775
|
x(!1);
|
|
4760
4776
|
}
|
|
4761
4777
|
})();
|
|
4762
|
-
}, [t,
|
|
4763
|
-
const
|
|
4764
|
-
if (
|
|
4765
|
-
|
|
4778
|
+
}, [t, C, a.store.data]);
|
|
4779
|
+
const F = async (S) => {
|
|
4780
|
+
if (S && S.preventDefault(), !M) {
|
|
4781
|
+
b(t("app_settings.general.default_accent_invalid"));
|
|
4766
4782
|
return;
|
|
4767
4783
|
}
|
|
4768
|
-
|
|
4784
|
+
v(!0), y(""), b("");
|
|
4769
4785
|
try {
|
|
4770
|
-
await
|
|
4771
|
-
...
|
|
4772
|
-
default_accent:
|
|
4773
|
-
}),
|
|
4774
|
-
} catch (
|
|
4775
|
-
|
|
4786
|
+
await I.updateSettings({
|
|
4787
|
+
...m,
|
|
4788
|
+
default_accent: f || null
|
|
4789
|
+
}), y(t("app_settings.save_success")), setTimeout(() => y(""), 3e3);
|
|
4790
|
+
} catch (u) {
|
|
4791
|
+
b(u instanceof Error ? u.message : t("app_settings.save_error"));
|
|
4776
4792
|
} finally {
|
|
4777
|
-
|
|
4793
|
+
v(!1);
|
|
4778
4794
|
}
|
|
4779
|
-
},
|
|
4780
|
-
x(!0),
|
|
4795
|
+
}, K = async () => {
|
|
4796
|
+
x(!0), b("");
|
|
4781
4797
|
try {
|
|
4782
|
-
await
|
|
4783
|
-
} catch (
|
|
4784
|
-
|
|
4798
|
+
await I.resetSettings(), p(!1), window.location.reload();
|
|
4799
|
+
} catch (S) {
|
|
4800
|
+
b(S instanceof Error ? S.message : t("app_settings.save_error"));
|
|
4785
4801
|
} finally {
|
|
4786
4802
|
x(!1);
|
|
4787
4803
|
}
|
|
4788
4804
|
};
|
|
4789
|
-
return
|
|
4805
|
+
return N ? /* @__PURE__ */ e("div", { className: "h-full flex items-center justify-center", children: /* @__PURE__ */ r("div", { className: "flex flex-col items-center gap-3", children: [
|
|
4790
4806
|
/* @__PURE__ */ e("div", { className: "w-10 h-10 border-3 border-primary/20 border-t-primary rounded-full animate-spin" }),
|
|
4791
4807
|
/* @__PURE__ */ e("span", { className: "text-sm text-muted-foreground font-medium", children: t("loading") })
|
|
4792
|
-
] }) }) : /* @__PURE__ */ r("div", { className: "h-full flex flex-col overflow-hidden", dir:
|
|
4808
|
+
] }) }) : /* @__PURE__ */ r("div", { className: "h-full flex flex-col overflow-hidden", dir: T ? "rtl" : "ltr", children: [
|
|
4793
4809
|
/* @__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: [
|
|
4794
4810
|
/* @__PURE__ */ r("div", { className: "flex flex-col gap-1", children: [
|
|
4795
4811
|
/* @__PURE__ */ r("div", { className: "flex items-baseline gap-3 flex-wrap", children: [
|
|
@@ -4802,7 +4818,7 @@ function Ir() {
|
|
|
4802
4818
|
/* @__PURE__ */ e("p", { className: "text-sm text-muted-foreground", children: t("app_settings.subtitle") })
|
|
4803
4819
|
] }),
|
|
4804
4820
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-4", children: [
|
|
4805
|
-
/* @__PURE__ */ r(Le, { open:
|
|
4821
|
+
/* @__PURE__ */ r(Le, { open: E, onOpenChange: p, children: [
|
|
4806
4822
|
/* @__PURE__ */ e(gt, { asChild: !0, children: /* @__PURE__ */ r(
|
|
4807
4823
|
"button",
|
|
4808
4824
|
{
|
|
@@ -4821,7 +4837,7 @@ function Ir() {
|
|
|
4821
4837
|
] }),
|
|
4822
4838
|
/* @__PURE__ */ r(Be, { children: [
|
|
4823
4839
|
/* @__PURE__ */ e(ze, { asChild: !0, children: /* @__PURE__ */ e(ne, { variant: "ghost", children: t("cancel") }) }),
|
|
4824
|
-
/* @__PURE__ */ e(ne, { variant: "destructive", onClick:
|
|
4840
|
+
/* @__PURE__ */ e(ne, { variant: "destructive", onClick: K, children: t("app_settings.reset_button") })
|
|
4825
4841
|
] })
|
|
4826
4842
|
] })
|
|
4827
4843
|
] }),
|
|
@@ -4830,47 +4846,47 @@ function Ir() {
|
|
|
4830
4846
|
{
|
|
4831
4847
|
type: "submit",
|
|
4832
4848
|
form: "settings-form",
|
|
4833
|
-
disabled:
|
|
4849
|
+
disabled: h || !M,
|
|
4834
4850
|
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",
|
|
4835
4851
|
children: [
|
|
4836
|
-
|
|
4837
|
-
t(
|
|
4852
|
+
h && /* @__PURE__ */ e("div", { className: "w-4 h-4 border-2 border-primary-foreground/20 border-t-primary-foreground rounded-full animate-spin" }),
|
|
4853
|
+
t(h ? "saving" : "app_settings.save")
|
|
4838
4854
|
]
|
|
4839
4855
|
}
|
|
4840
4856
|
)
|
|
4841
4857
|
] })
|
|
4842
4858
|
] }),
|
|
4843
4859
|
/* @__PURE__ */ e("div", { className: "flex-1 overflow-y-auto custom-scrollbar", children: /* @__PURE__ */ r("div", { className: "max-w-4xl mx-auto py-10 px-8", children: [
|
|
4844
|
-
(
|
|
4860
|
+
(i || j) && /* @__PURE__ */ e(
|
|
4845
4861
|
"div",
|
|
4846
4862
|
{
|
|
4847
|
-
className: `mb-12 px-4 py-3 rounded-xl text-sm border animate-in fade-in slide-in-from-top-1 duration-300 ${
|
|
4848
|
-
children:
|
|
4863
|
+
className: `mb-12 px-4 py-3 rounded-xl text-sm border animate-in fade-in slide-in-from-top-1 duration-300 ${i ? "bg-destructive/10 border-destructive/20 text-destructive" : "bg-green-500/10 border-green-500/20 text-green-600 dark:text-green-400"}`,
|
|
4864
|
+
children: i || j
|
|
4849
4865
|
}
|
|
4850
4866
|
),
|
|
4851
4867
|
/* @__PURE__ */ r(
|
|
4852
4868
|
"form",
|
|
4853
4869
|
{
|
|
4854
4870
|
id: "settings-form",
|
|
4855
|
-
onSubmit:
|
|
4871
|
+
onSubmit: F,
|
|
4856
4872
|
className: "space-y-16 animate-in fade-in slide-in-from-bottom-2 duration-500",
|
|
4857
4873
|
children: [
|
|
4858
4874
|
/* @__PURE__ */ e(
|
|
4859
4875
|
_r,
|
|
4860
4876
|
{
|
|
4861
|
-
settings:
|
|
4862
|
-
setSettings:
|
|
4863
|
-
accentValue:
|
|
4864
|
-
accentIsValid:
|
|
4877
|
+
settings: m,
|
|
4878
|
+
setSettings: w,
|
|
4879
|
+
accentValue: f,
|
|
4880
|
+
accentIsValid: M
|
|
4865
4881
|
}
|
|
4866
4882
|
),
|
|
4867
4883
|
/* @__PURE__ */ e(
|
|
4868
4884
|
Nr,
|
|
4869
4885
|
{
|
|
4870
|
-
settings:
|
|
4871
|
-
setSettings:
|
|
4886
|
+
settings: m,
|
|
4887
|
+
setSettings: w,
|
|
4872
4888
|
userMetadataFields: s?.userMetadataFields || [],
|
|
4873
|
-
isRtl:
|
|
4889
|
+
isRtl: T
|
|
4874
4890
|
}
|
|
4875
4891
|
),
|
|
4876
4892
|
/* @__PURE__ */ r("section", { children: [
|
|
@@ -4883,10 +4899,10 @@ function Ir() {
|
|
|
4883
4899
|
se,
|
|
4884
4900
|
{
|
|
4885
4901
|
type: "number",
|
|
4886
|
-
value:
|
|
4887
|
-
onChange: (
|
|
4888
|
-
...
|
|
4889
|
-
initial_balance_tokens: parseInt(
|
|
4902
|
+
value: m.initial_balance_tokens ?? "",
|
|
4903
|
+
onChange: (S) => w({
|
|
4904
|
+
...m,
|
|
4905
|
+
initial_balance_tokens: parseInt(S.target.value) || 0
|
|
4890
4906
|
}),
|
|
4891
4907
|
className: "bg-muted/20 border-transparent focus:bg-background h-11",
|
|
4892
4908
|
placeholder: "250000"
|
|
@@ -4899,10 +4915,10 @@ function Ir() {
|
|
|
4899
4915
|
se,
|
|
4900
4916
|
{
|
|
4901
4917
|
type: "number",
|
|
4902
|
-
value:
|
|
4903
|
-
onChange: (
|
|
4904
|
-
...
|
|
4905
|
-
initial_balance_requests: parseInt(
|
|
4918
|
+
value: m.initial_balance_requests ?? "",
|
|
4919
|
+
onChange: (S) => w({
|
|
4920
|
+
...m,
|
|
4921
|
+
initial_balance_requests: parseInt(S.target.value) || 0
|
|
4906
4922
|
}),
|
|
4907
4923
|
className: "bg-muted/20 border-transparent focus:bg-background h-11",
|
|
4908
4924
|
placeholder: "100"
|
|
@@ -4918,8 +4934,8 @@ function Ir() {
|
|
|
4918
4934
|
/* @__PURE__ */ e(
|
|
4919
4935
|
Ar,
|
|
4920
4936
|
{
|
|
4921
|
-
translations:
|
|
4922
|
-
onChange: (
|
|
4937
|
+
translations: m.translations,
|
|
4938
|
+
onChange: (S) => w((u) => ({ ...u, translations: S }))
|
|
4923
4939
|
}
|
|
4924
4940
|
)
|
|
4925
4941
|
] })
|
|
@@ -4930,8 +4946,8 @@ function Ir() {
|
|
|
4930
4946
|
] }) })
|
|
4931
4947
|
] });
|
|
4932
4948
|
}
|
|
4933
|
-
function
|
|
4934
|
-
const { t, i18n: a } =
|
|
4949
|
+
function xe() {
|
|
4950
|
+
const { t, i18n: a } = P(["admin"]), s = a.language === "fa";
|
|
4935
4951
|
return /* @__PURE__ */ r(
|
|
4936
4952
|
"div",
|
|
4937
4953
|
{
|
|
@@ -4948,7 +4964,7 @@ function be() {
|
|
|
4948
4964
|
);
|
|
4949
4965
|
}
|
|
4950
4966
|
const Dr = ({ className: t }) => {
|
|
4951
|
-
const { t: a } =
|
|
4967
|
+
const { t: a } = P(["theme"]), { theme: s, setTheme: l } = Ue(), o = () => {
|
|
4952
4968
|
l(s === "system" ? "light" : s === "light" ? "dark" : "system");
|
|
4953
4969
|
}, n = () => {
|
|
4954
4970
|
switch (s) {
|
|
@@ -4982,61 +4998,61 @@ const Dr = ({ className: t }) => {
|
|
|
4982
4998
|
] });
|
|
4983
4999
|
};
|
|
4984
5000
|
function Rr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
4985
|
-
const s = wt(), l = kt(), { t: o, i18n: n } =
|
|
5001
|
+
const s = wt(), l = kt(), { t: o, i18n: n } = P(["admin", "settings", "translation"]), { app: d } = me(), { theme: g } = Ue(), [k, L] = _([]), [N, x] = _(!1), h = nt(!1), [v, i] = _("light");
|
|
4986
5002
|
H(() => {
|
|
4987
5003
|
if (g === "system") {
|
|
4988
|
-
const
|
|
4989
|
-
|
|
5004
|
+
const f = window.matchMedia("(prefers-color-scheme: dark)").matches;
|
|
5005
|
+
i(f ? "dark" : "light");
|
|
4990
5006
|
} else
|
|
4991
|
-
|
|
5007
|
+
i(g);
|
|
4992
5008
|
}, [g]);
|
|
4993
|
-
const
|
|
5009
|
+
const b = pe(() => d?.logo ? typeof d.logo == "string" ? d.logo : v === "dark" ? d.logo.dark : d.logo.light : st, [d?.logo, v]), j = d?.adminTitle || d?.name, y = n.language === "fa";
|
|
4994
5010
|
H(() => {
|
|
4995
|
-
const
|
|
4996
|
-
if (
|
|
5011
|
+
const f = localStorage.getItem("admin_info");
|
|
5012
|
+
if (f)
|
|
4997
5013
|
try {
|
|
4998
|
-
const
|
|
4999
|
-
if (
|
|
5000
|
-
if (
|
|
5014
|
+
const F = JSON.parse(f).permissions || [];
|
|
5015
|
+
if (L(F), l.pathname === "/admin" || l.pathname === "/admin/")
|
|
5016
|
+
if (F.includes("analytics") && !a.includes("analytics"))
|
|
5001
5017
|
s("/admin/analytics", { replace: !0 });
|
|
5002
|
-
else if (
|
|
5018
|
+
else if (F.includes("chat_history") && !a.includes("chat_history"))
|
|
5003
5019
|
s("/admin/chat-history", { replace: !0 });
|
|
5004
|
-
else if (
|
|
5020
|
+
else if (F.includes("user_management") && !a.includes("user_management"))
|
|
5005
5021
|
s("/admin/users", { replace: !0 });
|
|
5006
|
-
else if (
|
|
5022
|
+
else if (F.includes("admin_management") && !a.includes("admin_management"))
|
|
5007
5023
|
s("/admin/admins", { replace: !0 });
|
|
5008
|
-
else if (
|
|
5024
|
+
else if (F.includes("settings") && !a.includes("settings"))
|
|
5009
5025
|
s("/admin/settings", { replace: !0 });
|
|
5010
5026
|
else {
|
|
5011
|
-
const
|
|
5012
|
-
(
|
|
5027
|
+
const K = t.find(
|
|
5028
|
+
(S) => !S.permission || F.includes(S.permission)
|
|
5013
5029
|
);
|
|
5014
|
-
|
|
5030
|
+
K && s(`/admin/${K.path}`, { replace: !0 });
|
|
5015
5031
|
}
|
|
5016
|
-
} catch (
|
|
5017
|
-
console.error("Failed to parse admin_info",
|
|
5032
|
+
} catch (M) {
|
|
5033
|
+
console.error("Failed to parse admin_info", M);
|
|
5018
5034
|
}
|
|
5019
5035
|
else
|
|
5020
5036
|
console.warn("DashboardPage: No adminInfo found in localStorage");
|
|
5021
5037
|
}, [s, l.pathname]);
|
|
5022
|
-
const
|
|
5023
|
-
|
|
5024
|
-
},
|
|
5025
|
-
(
|
|
5026
|
-
),
|
|
5027
|
-
localStorage.setItem("gentiq-admin-language",
|
|
5038
|
+
const E = () => {
|
|
5039
|
+
I.clearToken(), window.location.reload();
|
|
5040
|
+
}, p = (f) => k.includes(f), C = (f) => k.includes(f) && !a.includes(f), m = Object.keys(n.services?.resourceStore?.data || {}).filter(
|
|
5041
|
+
(f) => f !== "dev"
|
|
5042
|
+
), w = m.length > 0 ? m : ["en", "fa"], T = (f) => {
|
|
5043
|
+
localStorage.setItem("gentiq-admin-language", f), n.changeLanguage(f), x(!1), document.activeElement instanceof HTMLElement && document.activeElement.blur();
|
|
5028
5044
|
};
|
|
5029
5045
|
return /* @__PURE__ */ r(
|
|
5030
5046
|
"div",
|
|
5031
5047
|
{
|
|
5032
5048
|
className: "min-h-screen bg-background overflow-hidden flex flex-col",
|
|
5033
|
-
dir:
|
|
5049
|
+
dir: y ? "rtl" : "ltr",
|
|
5034
5050
|
children: [
|
|
5035
5051
|
/* @__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: [
|
|
5036
5052
|
/* @__PURE__ */ r("div", { className: "flex flex-col md:flex-row md:items-stretch gap-x-12", children: [
|
|
5037
5053
|
/* @__PURE__ */ r("div", { className: "flex items-center gap-3 py-4 md:py-0", children: [
|
|
5038
|
-
/* @__PURE__ */ e("img", { src:
|
|
5039
|
-
/* @__PURE__ */ e("h1", { className: "text-2xl font-black bg-gradient-to-l from-primary to-primary/60 bg-clip-text text-transparent", children:
|
|
5054
|
+
/* @__PURE__ */ e("img", { src: b, alt: j, className: "size-8 object-contain" }),
|
|
5055
|
+
/* @__PURE__ */ e("h1", { className: "text-2xl font-black bg-gradient-to-l from-primary to-primary/60 bg-clip-text text-transparent", children: j })
|
|
5040
5056
|
] }),
|
|
5041
5057
|
/* @__PURE__ */ r("nav", { className: "flex items-stretch gap-8", children: [
|
|
5042
5058
|
!a.includes("analytics") && /* @__PURE__ */ e(
|
|
@@ -5079,14 +5095,14 @@ function Rr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
|
5079
5095
|
children: o("dashboard.tabs.settings")
|
|
5080
5096
|
}
|
|
5081
5097
|
),
|
|
5082
|
-
t.map((
|
|
5098
|
+
t.map((f) => /* @__PURE__ */ e(
|
|
5083
5099
|
"button",
|
|
5084
5100
|
{
|
|
5085
|
-
onClick: () => s(`/admin/${
|
|
5086
|
-
className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${l.pathname === `/admin/${
|
|
5087
|
-
children: typeof
|
|
5101
|
+
onClick: () => s(`/admin/${f.path}`),
|
|
5102
|
+
className: `flex items-center text-base font-medium transition-all border-b-2 px-1 ${l.pathname === `/admin/${f.path}` ? "border-primary text-primary" : "border-transparent text-muted-foreground hover:text-foreground hover:border-border"}`,
|
|
5103
|
+
children: typeof f.label == "string" ? o(f.label) : f.label
|
|
5088
5104
|
},
|
|
5089
|
-
`tab-${
|
|
5105
|
+
`tab-${f.path}`
|
|
5090
5106
|
))
|
|
5091
5107
|
] })
|
|
5092
5108
|
] }),
|
|
@@ -5094,18 +5110,18 @@ function Rr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
|
5094
5110
|
/* @__PURE__ */ r(
|
|
5095
5111
|
ft,
|
|
5096
5112
|
{
|
|
5097
|
-
onOpenChange: (
|
|
5098
|
-
|
|
5099
|
-
|
|
5113
|
+
onOpenChange: (f) => {
|
|
5114
|
+
f ? x(!1) : (h.current = !0, setTimeout(() => {
|
|
5115
|
+
h.current = !1;
|
|
5100
5116
|
}, 200));
|
|
5101
5117
|
},
|
|
5102
5118
|
children: [
|
|
5103
5119
|
/* @__PURE__ */ r(
|
|
5104
5120
|
Ee,
|
|
5105
5121
|
{
|
|
5106
|
-
open:
|
|
5107
|
-
onOpenChange: (
|
|
5108
|
-
|
|
5122
|
+
open: N,
|
|
5123
|
+
onOpenChange: (f) => {
|
|
5124
|
+
f && h.current || x(f);
|
|
5109
5125
|
},
|
|
5110
5126
|
children: [
|
|
5111
5127
|
/* @__PURE__ */ e(Fe, { asChild: !0, children: /* @__PURE__ */ e(bt, { asChild: !0, children: /* @__PURE__ */ e(
|
|
@@ -5122,14 +5138,14 @@ function Rr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
|
5122
5138
|
]
|
|
5123
5139
|
}
|
|
5124
5140
|
),
|
|
5125
|
-
/* @__PURE__ */ e(xt, { align: "center", className: "min-w-[8rem]", children:
|
|
5141
|
+
/* @__PURE__ */ e(xt, { align: "center", className: "min-w-[8rem]", children: w.map((f) => /* @__PURE__ */ e(
|
|
5126
5142
|
vt,
|
|
5127
5143
|
{
|
|
5128
|
-
onClick: () =>
|
|
5129
|
-
className:
|
|
5130
|
-
children: o(`general.languages.${
|
|
5144
|
+
onClick: () => T(f),
|
|
5145
|
+
className: f === n.language ? "bg-primary/10" : "",
|
|
5146
|
+
children: o(`general.languages.${f}`, f.toUpperCase())
|
|
5131
5147
|
},
|
|
5132
|
-
|
|
5148
|
+
f
|
|
5133
5149
|
)) })
|
|
5134
5150
|
]
|
|
5135
5151
|
}
|
|
@@ -5143,7 +5159,7 @@ function Rr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
|
5143
5159
|
variant: "ghost",
|
|
5144
5160
|
size: "icon",
|
|
5145
5161
|
className: "hover:bg-destructive/10 hover:scale-105 active:scale-95 text-muted-foreground hover:text-destructive",
|
|
5146
|
-
onClick:
|
|
5162
|
+
onClick: E,
|
|
5147
5163
|
children: /* @__PURE__ */ e(Kt, { className: "size-5" })
|
|
5148
5164
|
}
|
|
5149
5165
|
) }),
|
|
@@ -5157,44 +5173,44 @@ function Rr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
|
5157
5173
|
ue,
|
|
5158
5174
|
{
|
|
5159
5175
|
path: "/analytics",
|
|
5160
|
-
element:
|
|
5176
|
+
element: C("analytics") ? /* @__PURE__ */ e(yr, {}) : /* @__PURE__ */ e(xe, {})
|
|
5161
5177
|
}
|
|
5162
5178
|
),
|
|
5163
5179
|
/* @__PURE__ */ e(
|
|
5164
5180
|
ue,
|
|
5165
5181
|
{
|
|
5166
5182
|
path: "/chat-history",
|
|
5167
|
-
element:
|
|
5183
|
+
element: C("chat_history") ? /* @__PURE__ */ e(dr, {}) : /* @__PURE__ */ e(xe, {})
|
|
5168
5184
|
}
|
|
5169
5185
|
),
|
|
5170
5186
|
/* @__PURE__ */ e(
|
|
5171
5187
|
ue,
|
|
5172
5188
|
{
|
|
5173
5189
|
path: "/admins",
|
|
5174
|
-
element:
|
|
5190
|
+
element: C("admin_management") ? /* @__PURE__ */ e(cr, {}) : /* @__PURE__ */ e(xe, {})
|
|
5175
5191
|
}
|
|
5176
5192
|
),
|
|
5177
5193
|
/* @__PURE__ */ e(
|
|
5178
5194
|
ue,
|
|
5179
5195
|
{
|
|
5180
5196
|
path: "/settings",
|
|
5181
|
-
element:
|
|
5197
|
+
element: C("settings") ? /* @__PURE__ */ e(Ir, {}) : /* @__PURE__ */ e(xe, {})
|
|
5182
5198
|
}
|
|
5183
5199
|
),
|
|
5184
5200
|
/* @__PURE__ */ e(
|
|
5185
5201
|
ue,
|
|
5186
5202
|
{
|
|
5187
5203
|
path: "/users",
|
|
5188
|
-
element:
|
|
5204
|
+
element: C("user_management") ? /* @__PURE__ */ e(vr, {}) : /* @__PURE__ */ e(xe, {})
|
|
5189
5205
|
}
|
|
5190
5206
|
),
|
|
5191
|
-
t.map((
|
|
5207
|
+
t.map((f) => /* @__PURE__ */ e(
|
|
5192
5208
|
ue,
|
|
5193
5209
|
{
|
|
5194
|
-
path: `/${
|
|
5195
|
-
element:
|
|
5210
|
+
path: `/${f.path}`,
|
|
5211
|
+
element: f.permission && !p(f.permission) ? /* @__PURE__ */ e(xe, {}) : f.element
|
|
5196
5212
|
},
|
|
5197
|
-
`route-${
|
|
5213
|
+
`route-${f.path}`
|
|
5198
5214
|
)),
|
|
5199
5215
|
/* @__PURE__ */ e(ue, { path: "*", element: /* @__PURE__ */ e(Ze, { to: "/admin/analytics", replace: !0 }) })
|
|
5200
5216
|
] }) }) })
|
|
@@ -5203,7 +5219,7 @@ function Rr({ extraPages: t = [], disabledPages: a = [] }) {
|
|
|
5203
5219
|
);
|
|
5204
5220
|
}
|
|
5205
5221
|
function Kr(t) {
|
|
5206
|
-
const a =
|
|
5222
|
+
const a = pe(() => {
|
|
5207
5223
|
const s = mt.createInstance();
|
|
5208
5224
|
return s.use(yt).use(ht).init({
|
|
5209
5225
|
resources: _t,
|
|
@@ -5219,25 +5235,25 @@ function Kr(t) {
|
|
|
5219
5235
|
return /* @__PURE__ */ e(pt, { i18n: a, children: /* @__PURE__ */ e(Mr, { ...t }) });
|
|
5220
5236
|
}
|
|
5221
5237
|
function Mr({ extraPages: t, disabledPages: a = [] }) {
|
|
5222
|
-
const { app: s, i18n: l } =
|
|
5238
|
+
const { app: s, i18n: l } = me(), { t: o, i18n: n } = P(["admin", "translation"]), [d, g] = _(!1), [k, L] = _(!0), [N, x] = _(!1);
|
|
5223
5239
|
H(() => {
|
|
5224
|
-
l?.resources && Object.entries(l.resources).forEach(([
|
|
5225
|
-
Object.entries(
|
|
5226
|
-
n.addResourceBundle(
|
|
5240
|
+
l?.resources && Object.entries(l.resources).forEach(([i, b]) => {
|
|
5241
|
+
Object.entries(b).forEach(([j, y]) => {
|
|
5242
|
+
n.addResourceBundle(i, j, y, !0, !0);
|
|
5227
5243
|
});
|
|
5228
5244
|
}), !localStorage.getItem("gentiq-admin-language") && s?.language && n.language !== s.language && n.changeLanguage(s.language), x(!0);
|
|
5229
5245
|
}, [l?.resources, n, s?.language]), H(() => {
|
|
5230
|
-
const
|
|
5231
|
-
return g(!!
|
|
5246
|
+
const v = I.getToken();
|
|
5247
|
+
return g(!!v), L(!1), document.body.classList.add("admin-theme-root"), () => {
|
|
5232
5248
|
document.body.classList.remove("admin-theme-root");
|
|
5233
5249
|
};
|
|
5234
5250
|
}, []), H(() => {
|
|
5235
|
-
|
|
5236
|
-
}, [
|
|
5237
|
-
const
|
|
5251
|
+
N && (document.documentElement.dir = n.language === "fa" ? "rtl" : "ltr", document.documentElement.lang = n.language);
|
|
5252
|
+
}, [N, n.language]);
|
|
5253
|
+
const h = () => {
|
|
5238
5254
|
g(!0);
|
|
5239
5255
|
};
|
|
5240
|
-
return
|
|
5256
|
+
return k || !N ? /* @__PURE__ */ e("div", { className: "min-h-screen bg-background flex items-center justify-center", children: /* @__PURE__ */ e("div", { className: "text-muted-foreground", children: o("loading") }) }) : /* @__PURE__ */ e(Nt, { storageKey: "gentiq-admin-theme", children: d ? /* @__PURE__ */ e(Rr, { extraPages: t, disabledPages: a }) : /* @__PURE__ */ e(Zt, { onLoginSuccess: h }) });
|
|
5241
5257
|
}
|
|
5242
5258
|
export {
|
|
5243
5259
|
Kr as AdminPanel,
|