@lambda-development/erp-core 0.8.5 → 0.8.6

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/index.js CHANGED
@@ -1,8 +1,8 @@
1
- import { jsx as t, jsxs as r, Fragment as Pe } from "react/jsx-runtime";
1
+ import { jsx as t, jsxs as r, Fragment as Ae } from "react/jsx-runtime";
2
2
  import { useState as w, useEffect as ae, useCallback as Le, useContext as un, createContext as mn, useRef as ie, useMemo as be, useLayoutEffect as Cn, StrictMode as Qa } from "react";
3
3
  import { createRoot as Ja } from "react-dom/client";
4
- import { useQueryClient as Ze, useQuery as ce, useMutation as de, QueryClientProvider as Za, QueryClient as Xa } from "@tanstack/react-query";
5
- import { NavLink as $t, useLocation as Nt, useNavigate as Me, Outlet as er, Navigate as tr, Link as De, useSearchParams as Vt, useParams as yt, createBrowserRouter as nr, RouterProvider as ar } from "react-router-dom";
4
+ import { useQueryClient as Qe, useQuery as de, useMutation as ue, QueryClientProvider as Za, QueryClient as Xa } from "@tanstack/react-query";
5
+ import { NavLink as $t, useLocation as Nt, useNavigate as Fe, Outlet as er, Navigate as tr, Link as Ce, useSearchParams as Vt, useParams as ft, createBrowserRouter as nr, RouterProvider as ar } from "react-router-dom";
6
6
  import { useTranslation as ne, initReactI18next as rr } from "react-i18next";
7
7
  import { BookOpen as sr, ShoppingCart as ia, CreditCard as ir, FileText as pn, Package as oa, BarChart3 as or, Forklift as lr, Database as cr, Settings as dr, MessageCircle as ur, ChevronDown as At, ChevronRight as Pt, Plus as la, Trash2 as ca, LineChart as mr, ArrowLeft as pr, TrendingUp as hr, ArrowDownRight as gr, ArrowUpRight as fr, Wallet as yr, Receipt as Sn, ChevronLeft as br, Info as vr, SlidersHorizontal as xr, ChevronUp as Nr, ChevronsUpDown as wr } from "lucide-react";
8
8
  import { createColumnHelper as da, useReactTable as ua, getCoreRowModel as ma, flexRender as qt } from "@tanstack/react-table";
@@ -10,14 +10,14 @@ import { createPortal as pa } from "react-dom";
10
10
  import { ResponsiveContainer as kr, LineChart as Cr, CartesianGrid as Dn, XAxis as An, YAxis as Pn, Tooltip as Gt, Line as Sr, PieChart as Dr, Pie as Ar, Cell as Pr, BarChart as _r, Bar as Tr } from "recharts";
11
11
  import ha from "i18next";
12
12
  import { default as Vl } from "i18next";
13
- let gt = "/api";
13
+ let ht = "/api";
14
14
  function Tl(e) {
15
- gt = e.replace(/\/+$/, "");
15
+ ht = e.replace(/\/+$/, "");
16
16
  }
17
17
  function Rr(e) {
18
- return new URL(`${gt}${e}`, window.location.origin).toString();
18
+ return new URL(`${ht}${e}`, window.location.origin).toString();
19
19
  }
20
- class Qe extends Error {
20
+ class He extends Error {
21
21
  constructor(n, a) {
22
22
  super(a), this.status = n;
23
23
  }
@@ -38,16 +38,16 @@ function Ir(e) {
38
38
  return String(e);
39
39
  }
40
40
  async function L(e, n) {
41
- const a = await fetch(`${gt}${e}`, {
41
+ const a = await fetch(`${ht}${e}`, {
42
42
  headers: { "Content-Type": "application/json" },
43
43
  credentials: "include",
44
44
  ...n
45
45
  });
46
46
  if (!a.ok) {
47
47
  if (a.status === 401 && !e.startsWith("/auth/"))
48
- throw window.location.href = "/login", new Qe(401, "Session expired");
48
+ throw window.location.href = "/login", new He(401, "Session expired");
49
49
  const s = await a.json().catch(() => ({ detail: a.statusText }));
50
- throw new Qe(a.status, Ir(s.detail));
50
+ throw new He(a.status, Ir(s.detail));
51
51
  }
52
52
  return a.json();
53
53
  }
@@ -65,20 +65,20 @@ const B = {
65
65
  uploadChatAttachment: async (e, n) => {
66
66
  const a = new FormData();
67
67
  a.append("file", n), a.append("session_id", e);
68
- const s = await fetch(`${gt}/chat/attachments`, {
68
+ const s = await fetch(`${ht}/chat/attachments`, {
69
69
  method: "POST",
70
70
  credentials: "include",
71
71
  body: a
72
72
  });
73
73
  if (!s.ok) {
74
74
  if (s.status === 401)
75
- throw window.location.href = "/login", new Qe(401, "Session expired");
75
+ throw window.location.href = "/login", new He(401, "Session expired");
76
76
  const o = await s.json().catch(() => ({ detail: s.statusText }));
77
- throw new Qe(s.status, o.detail || "Upload failed");
77
+ throw new He(s.status, o.detail || "Upload failed");
78
78
  }
79
79
  return s.json();
80
80
  },
81
- getChatAttachmentUrl: (e) => `${gt}/chat/attachments/${encodeURIComponent(e)}`,
81
+ getChatAttachmentUrl: (e) => `${ht}/chat/attachments/${encodeURIComponent(e)}`,
82
82
  // Chat
83
83
  createChatSession: () => L(
84
84
  "/chat/sessions",
@@ -120,21 +120,21 @@ const B = {
120
120
  uploadProposalAppendix: async (e, n) => {
121
121
  const a = new FormData();
122
122
  a.append("file", n);
123
- const s = await fetch(`${gt}/proposals/${encodeURIComponent(e)}/appendix`, {
123
+ const s = await fetch(`${ht}/proposals/${encodeURIComponent(e)}/appendix`, {
124
124
  method: "POST",
125
125
  credentials: "include",
126
126
  body: a
127
127
  });
128
128
  if (!s.ok) {
129
129
  if (s.status === 401)
130
- throw window.location.href = "/login", new Qe(401, "Session expired");
130
+ throw window.location.href = "/login", new He(401, "Session expired");
131
131
  const o = await s.json().catch(() => ({ detail: s.statusText }));
132
- throw new Qe(s.status, o.detail || "Upload failed");
132
+ throw new He(s.status, o.detail || "Upload failed");
133
133
  }
134
134
  return s.json();
135
135
  },
136
136
  deleteProposalAppendix: (e) => L(`/proposals/${encodeURIComponent(e)}/appendix`, { method: "DELETE" }),
137
- proposalPdfUrl: (e) => `${gt}/documents/proposal/${encodeURIComponent(e)}/pdf`,
137
+ proposalPdfUrl: (e) => `${ht}/documents/proposal/${encodeURIComponent(e)}/pdf`,
138
138
  // Masters
139
139
  listMasters: (e, n) => L(
140
140
  `/masters/${e}${Oe(n)}`
@@ -358,111 +358,111 @@ function In(e) {
358
358
  function Lr() {
359
359
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `req-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
360
360
  }
361
- function ct(e) {
361
+ function lt(e) {
362
362
  if (!e) return 0;
363
363
  const n = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(e) ? e.replace(" ", "T") : e, a = new Date(n).getTime();
364
364
  return Number.isNaN(a) ? 0 : a;
365
365
  }
366
366
  function Or({ children: e }) {
367
- const n = Ze(), [a, s] = w([]), [o, i] = w({}), [c, l] = w({}), [p, u] = w({}), [h, d] = w({}), [b, v] = w({}), [N, y] = w({}), [k, S] = w({}), [f, g] = w(null), [m, D] = w("connecting"), [T, V] = w(0), X = ie(null), P = ie(null), O = ie(/* @__PURE__ */ new Map()), Z = ie(null), x = ie({}), W = ie({}), A = ie(null);
367
+ const n = Qe(), [a, s] = w([]), [o, i] = w({}), [c, l] = w({}), [p, u] = w({}), [h, d] = w({}), [b, v] = w({}), [N, y] = w({}), [k, D] = w({}), [f, g] = w(null), [m, A] = w("connecting"), [T, V] = w(0), X = ie(null), _ = ie(null), O = ie(/* @__PURE__ */ new Map()), J = ie(null), x = ie({}), G = ie({}), P = ie(null);
368
368
  function R(I) {
369
- for (const Q of O.current.values())
370
- Q.reject(new Error(I));
369
+ for (const W of O.current.values())
370
+ W.reject(new Error(I));
371
371
  O.current.clear();
372
372
  }
373
- function q(I, Q) {
373
+ function q(I, W) {
374
374
  i((ee) => ({
375
375
  ...ee,
376
- [I]: Q(ee[I] ?? [])
376
+ [I]: W(ee[I] ?? [])
377
377
  }));
378
378
  }
379
- function j(I, Q) {
380
- v((ee) => ({ ...ee, [I]: Q }));
379
+ function j(I, W) {
380
+ v((ee) => ({ ...ee, [I]: W }));
381
381
  }
382
- function oe(I, Q) {
383
- y((ee) => ({ ...ee, [I]: Q }));
382
+ function oe(I, W) {
383
+ y((ee) => ({ ...ee, [I]: W }));
384
384
  }
385
- function me(I, Q) {
386
- S((ee) => ({ ...ee, [I]: Q }));
385
+ function he(I, W) {
386
+ D((ee) => ({ ...ee, [I]: W }));
387
387
  }
388
- function Te(I, Q) {
389
- A.current !== null && window.clearTimeout(A.current), g({ group: I, item: Q, key: Date.now() }), A.current = window.setTimeout(() => {
390
- g((ee) => (ee == null ? void 0 : ee.group) === I && (ee == null ? void 0 : ee.item) === Q ? null : ee), A.current = null;
388
+ function Se(I, W) {
389
+ P.current !== null && window.clearTimeout(P.current), g({ group: I, item: W, key: Date.now() }), P.current = window.setTimeout(() => {
390
+ g((ee) => (ee == null ? void 0 : ee.group) === I && (ee == null ? void 0 : ee.item) === W ? null : ee), P.current = null;
391
391
  }, 1100);
392
392
  }
393
393
  function ve(I) {
394
- return [...I].sort((Q, ee) => {
395
- const Ne = ct(x.current[Q.id]) || ct(Q.last_message_at || void 0) || ct(Q.created_at);
396
- return (ct(x.current[ee.id]) || ct(ee.last_message_at || void 0) || ct(ee.created_at)) - Ne;
394
+ return [...I].sort((W, ee) => {
395
+ const xe = lt(x.current[W.id]) || lt(W.last_message_at || void 0) || lt(W.created_at);
396
+ return (lt(x.current[ee.id]) || lt(ee.last_message_at || void 0) || lt(ee.created_at)) - xe;
397
397
  });
398
398
  }
399
- function Re(I) {
400
- s((Q) => ve(I(Q)));
399
+ function _e(I) {
400
+ s((W) => ve(I(W)));
401
401
  }
402
- function ge(I, Q) {
403
- const ee = Q || (/* @__PURE__ */ new Date()).toISOString(), Ne = x.current[I];
404
- ct(ee) >= ct(Ne) && (x.current = {
402
+ function ge(I, W) {
403
+ const ee = W || (/* @__PURE__ */ new Date()).toISOString(), xe = x.current[I];
404
+ lt(ee) >= lt(xe) && (x.current = {
405
405
  ...x.current,
406
406
  [I]: ee
407
407
  });
408
408
  }
409
- function ze(I) {
410
- const Q = { ...x.current };
409
+ function $e(I) {
410
+ const W = { ...x.current };
411
411
  for (const ee of I)
412
- ee.last_message_at && !Q[ee.id] && (Q[ee.id] = ee.last_message_at);
413
- x.current = Q;
412
+ ee.last_message_at && !W[ee.id] && (W[ee.id] = ee.last_message_at);
413
+ x.current = W;
414
414
  }
415
- function $e(I) {
416
- const Q = X.current;
417
- if (!Q || Q.readyState !== WebSocket.OPEN)
415
+ function Ve(I) {
416
+ const W = X.current;
417
+ if (!W || W.readyState !== WebSocket.OPEN)
418
418
  throw new Error("Chat is disconnected.");
419
- Q.send(JSON.stringify(I));
419
+ W.send(JSON.stringify(I));
420
420
  }
421
- function E(I, Q, ee) {
422
- return new Promise((Ne, Be) => {
423
- const Fe = Lr();
424
- O.current.set(Fe, {
421
+ function E(I, W, ee) {
422
+ return new Promise((xe, Be) => {
423
+ const ze = Lr();
424
+ O.current.set(ze, {
425
425
  expectedType: ee,
426
- resolve: Ne,
426
+ resolve: xe,
427
427
  reject: Be
428
428
  });
429
429
  try {
430
- $e({ type: I, request_id: Fe, ...Q });
430
+ Ve({ type: I, request_id: ze, ...W });
431
431
  } catch (tt) {
432
- O.current.delete(Fe), Be(tt instanceof Error ? tt : new Error("Chat request failed."));
432
+ O.current.delete(ze), Be(tt instanceof Error ? tt : new Error("Chat request failed."));
433
433
  }
434
434
  });
435
435
  }
436
436
  ae(() => {
437
437
  let I = !1;
438
- function Q() {
438
+ function W() {
439
439
  if (I) return;
440
- D("connecting");
441
- const Ne = `${window.location.protocol === "https:" ? "wss:" : "ws:"}//${window.location.host}/ws/chat`, Be = new WebSocket(Ne);
440
+ A("connecting");
441
+ const xe = `${window.location.protocol === "https:" ? "wss:" : "ws:"}//${window.location.host}/ws/chat`, Be = new WebSocket(xe);
442
442
  X.current = Be, Be.onopen = () => {
443
443
  if (I) {
444
444
  Be.close();
445
445
  return;
446
446
  }
447
- D("connected"), V((Fe) => Fe + 1);
448
- }, Be.onmessage = (Fe) => {
447
+ A("connected"), V((ze) => ze + 1);
448
+ }, Be.onmessage = (ze) => {
449
449
  var tt;
450
450
  try {
451
- const Y = JSON.parse(Fe.data), pt = typeof Y.request_id == "string" ? Y.request_id : null, we = typeof Y.type == "string" ? Y.type : null, F = typeof Y.session_id == "string" ? Y.session_id : null;
452
- if (pt) {
453
- const z = O.current.get(pt);
454
- z && (we === "error" ? (O.current.delete(pt), z.reject(new Error(String(Y.content || "Request failed.")))) : we === z.expectedType && (O.current.delete(pt), z.resolve(Y)));
451
+ const H = JSON.parse(ze.data), mt = typeof H.request_id == "string" ? H.request_id : null, Ne = typeof H.type == "string" ? H.type : null, F = typeof H.session_id == "string" ? H.session_id : null;
452
+ if (mt) {
453
+ const z = O.current.get(mt);
454
+ z && (Ne === "error" ? (O.current.delete(mt), z.reject(new Error(String(H.content || "Request failed.")))) : Ne === z.expectedType && (O.current.delete(mt), z.resolve(H)));
455
455
  }
456
- if (we === "sessions_list") {
457
- const z = Array.isArray(Y.sessions) ? Y.sessions : [];
458
- ze(z), s(
456
+ if (Ne === "sessions_list") {
457
+ const z = Array.isArray(H.sessions) ? H.sessions : [];
458
+ $e(z), s(
459
459
  ve(
460
460
  z
461
461
  )
462
462
  );
463
- const J = new Set(z.map((Ee) => Ee.id)), We = [...hn()].filter((Ee) => !J.has(Ee));
464
- We.length > 0 && Promise.all(
465
- We.map(async (Ee) => {
463
+ const Q = new Set(z.map((Ee) => Ee.id)), je = [...hn()].filter((Ee) => !Q.has(Ee));
464
+ je.length > 0 && Promise.all(
465
+ je.map(async (Ee) => {
466
466
  try {
467
467
  const pe = await B.getChatSession(Ee);
468
468
  return !pe || pe.detail || !pe.id ? (In(Ee), null) : pe;
@@ -471,306 +471,306 @@ function Or({ children: e }) {
471
471
  }
472
472
  })
473
473
  ).then((Ee) => {
474
- const pe = Ee.filter((ke) => !!ke);
475
- pe.length && (ze(pe), Re((ke) => [
476
- ...pe.filter((wt) => !ke.some((ot) => ot.id === wt.id)),
477
- ...ke
474
+ const pe = Ee.filter((we) => !!we);
475
+ pe.length && ($e(pe), _e((we) => [
476
+ ...pe.filter((wt) => !we.some((it) => it.id === wt.id)),
477
+ ...we
478
478
  ]));
479
479
  });
480
480
  return;
481
481
  }
482
- if (we === "session_created") {
483
- const z = Y.session;
482
+ if (Ne === "session_created") {
483
+ const z = H.session;
484
484
  if (!z) return;
485
- va(z.id), ze([z]), Re((J) => [z, ...J.filter((te) => te.id !== z.id)]);
485
+ va(z.id), $e([z]), _e((Q) => [z, ...Q.filter((te) => te.id !== z.id)]);
486
486
  return;
487
487
  }
488
- if (we === "session_deleted" && F) {
489
- In(F), Re((J) => J.filter((te) => te.id !== F)), i((J) => {
490
- const te = { ...J };
488
+ if (Ne === "session_deleted" && F) {
489
+ In(F), _e((Q) => Q.filter((te) => te.id !== F)), i((Q) => {
490
+ const te = { ...Q };
491
491
  return delete te[F], te;
492
- }), v((J) => {
493
- const te = { ...J };
492
+ }), v((Q) => {
493
+ const te = { ...Q };
494
494
  return delete te[F], te;
495
- }), y((J) => {
496
- const te = { ...J };
495
+ }), y((Q) => {
496
+ const te = { ...Q };
497
497
  return delete te[F], te;
498
- }), S((J) => {
499
- const te = { ...J };
498
+ }), D((Q) => {
499
+ const te = { ...Q };
500
500
  return delete te[F], te;
501
- }), l((J) => {
502
- const te = { ...J };
501
+ }), l((Q) => {
502
+ const te = { ...Q };
503
503
  return delete te[F], te;
504
- }), u((J) => {
505
- const te = { ...J };
504
+ }), u((Q) => {
505
+ const te = { ...Q };
506
506
  return delete te[F], te;
507
- }), d((J) => {
508
- const te = { ...J };
507
+ }), d((Q) => {
508
+ const te = { ...Q };
509
509
  return delete te[F], te;
510
510
  });
511
511
  const z = { ...x.current };
512
512
  delete z[F], x.current = z;
513
513
  return;
514
514
  }
515
- if (we === "history_loaded" && F) {
516
- const z = Array.isArray(Y.messages) ? Y.messages.map(Rn) : [], J = Y.before_id != null, te = !!Y.has_more, We = typeof Y.oldest_id == "number" ? Y.oldest_id : null;
515
+ if (Ne === "history_loaded" && F) {
516
+ const z = Array.isArray(H.messages) ? H.messages.map(Rn) : [], Q = H.before_id != null, te = !!H.has_more, je = typeof H.oldest_id == "number" ? H.oldest_id : null;
517
517
  i((pe) => {
518
- if (J) {
519
- const ke = pe[F] ?? [], wt = new Set(
520
- ke.map((nt) => nt.id).filter((nt) => typeof nt == "number")
521
- ), ot = z.filter(
518
+ if (Q) {
519
+ const we = pe[F] ?? [], wt = new Set(
520
+ we.map((nt) => nt.id).filter((nt) => typeof nt == "number")
521
+ ), it = z.filter(
522
522
  (nt) => nt.id === void 0 || !wt.has(nt.id)
523
523
  );
524
- return { ...pe, [F]: [...ot, ...ke] };
524
+ return { ...pe, [F]: [...it, ...we] };
525
525
  }
526
526
  return { ...pe, [F]: z };
527
- }), l((pe) => ({ ...pe, [F]: te })), u((pe) => ({ ...pe, [F]: We })), d((pe) => ({ ...pe, [F]: !1 }));
528
- const Ee = typeof Y.title == "string" ? Y.title : null;
529
- if (Ee && Re(
530
- (pe) => pe.map((ke) => ke.id === F ? { ...ke, title: Ee } : ke)
531
- ), !J) {
527
+ }), l((pe) => ({ ...pe, [F]: te })), u((pe) => ({ ...pe, [F]: je })), d((pe) => ({ ...pe, [F]: !1 }));
528
+ const Ee = typeof H.title == "string" ? H.title : null;
529
+ if (Ee && _e(
530
+ (pe) => pe.map((we) => we.id === F ? { ...we, title: Ee } : we)
531
+ ), !Q) {
532
532
  const pe = z[z.length - 1];
533
- pe != null && pe.timestamp && (ge(F, pe.timestamp), Re((ke) => ke));
533
+ pe != null && pe.timestamp && (ge(F, pe.timestamp), _e((we) => we));
534
534
  }
535
535
  return;
536
536
  }
537
- if (we === "history_cleared" && F) {
538
- i((z) => ({ ...z, [F]: [] })), l((z) => ({ ...z, [F]: !1 })), u((z) => ({ ...z, [F]: null })), d((z) => ({ ...z, [F]: !1 })), j(F, !1), oe(F, "idle"), me(F, null);
537
+ if (Ne === "history_cleared" && F) {
538
+ i((z) => ({ ...z, [F]: [] })), l((z) => ({ ...z, [F]: !1 })), u((z) => ({ ...z, [F]: null })), d((z) => ({ ...z, [F]: !1 })), j(F, !1), oe(F, "idle"), he(F, null);
539
539
  return;
540
540
  }
541
- if (we === "message_added" && F) {
542
- const z = Y.message;
541
+ if (Ne === "message_added" && F) {
542
+ const z = H.message;
543
543
  if (!z) return;
544
- ge(F, z.created_at), z.role === "user" && me(F, null), q(F, (J) => [
545
- ...J.filter((te) => te.type !== "thinking"),
544
+ ge(F, z.created_at), z.role === "user" && he(F, null), q(F, (Q) => [
545
+ ...Q.filter((te) => te.type !== "thinking"),
546
546
  Rn(z)
547
- ]), Re((J) => J);
547
+ ]), _e((Q) => Q);
548
548
  return;
549
549
  }
550
- if (we === "demo_started" && F) {
551
- oe(F, "running"), me(F, null);
550
+ if (Ne === "demo_started" && F) {
551
+ oe(F, "running"), he(F, null);
552
552
  return;
553
553
  }
554
- if (we === "demo_typing" && F) {
555
- oe(F, "running"), me(F, {
556
- content: String(Y.content || ""),
557
- seq: Math.max(0, Number(Y.seq || 0)),
558
- typingMs: Math.max(0, Number(Y.typing_ms || 0))
554
+ if (Ne === "demo_typing" && F) {
555
+ oe(F, "running"), he(F, {
556
+ content: String(H.content || ""),
557
+ seq: Math.max(0, Number(H.seq || 0)),
558
+ typingMs: Math.max(0, Number(H.typing_ms || 0))
559
559
  });
560
560
  return;
561
561
  }
562
- if (we === "demo_replay_complete" && F) {
563
- oe(F, "complete"), me(F, null);
562
+ if (Ne === "demo_replay_complete" && F) {
563
+ oe(F, "complete"), he(F, null);
564
564
  return;
565
565
  }
566
- if (we === "navigation_flash") {
567
- const z = typeof Y.group == "string" ? Y.group : "", J = typeof Y.item == "string" ? Y.item : void 0;
568
- z && Te(z, J);
566
+ if (Ne === "navigation_flash") {
567
+ const z = typeof H.group == "string" ? H.group : "", Q = typeof H.item == "string" ? H.item : void 0;
568
+ z && Se(z, Q);
569
569
  return;
570
570
  }
571
- if (we === "session_title_updated" && F) {
572
- const z = typeof Y.title == "string" ? Y.title : "";
573
- Re(
574
- (J) => J.map((te) => te.id === F ? { ...te, title: z } : te)
571
+ if (Ne === "session_title_updated" && F) {
572
+ const z = typeof H.title == "string" ? H.title : "";
573
+ _e(
574
+ (Q) => Q.map((te) => te.id === F ? { ...te, title: z } : te)
575
575
  );
576
576
  return;
577
577
  }
578
- if (we === "thinking" && F) {
578
+ if (Ne === "thinking" && F) {
579
579
  j(F, !0), q(F, (z) => {
580
- const J = z.find((te) => te.type === "thinking");
580
+ const Q = z.find((te) => te.type === "thinking");
581
581
  return [
582
582
  ...z.filter((te) => te.type !== "thinking"),
583
583
  {
584
584
  type: "thinking",
585
- content: `Thinking (step ${Y.iteration})...`,
586
- provider: J == null ? void 0 : J.provider,
587
- model: J == null ? void 0 : J.model
585
+ content: `Thinking (step ${H.iteration})...`,
586
+ provider: Q == null ? void 0 : Q.provider,
587
+ model: Q == null ? void 0 : Q.model
588
588
  }
589
589
  ];
590
590
  });
591
591
  return;
592
592
  }
593
- if (we === "llm_provider" && F) {
594
- const z = typeof Y.provider == "string" ? Y.provider : void 0, J = typeof Y.model == "string" ? Y.model : void 0, We = (typeof Y.role == "string" ? Y.role : void 0) === "code_specialist" ? "Delegating to code specialist..." : void 0;
595
- j(F, !0), q(F, (Ee) => Ee.some((ke) => ke.type === "thinking") ? Ee.map((ke) => ke.type === "thinking" ? {
596
- ...ke,
593
+ if (Ne === "llm_provider" && F) {
594
+ const z = typeof H.provider == "string" ? H.provider : void 0, Q = typeof H.model == "string" ? H.model : void 0, je = (typeof H.role == "string" ? H.role : void 0) === "code_specialist" ? "Delegating to code specialist..." : void 0;
595
+ j(F, !0), q(F, (Ee) => Ee.some((we) => we.type === "thinking") ? Ee.map((we) => we.type === "thinking" ? {
596
+ ...we,
597
597
  provider: z,
598
- model: J,
599
- ...We ? { content: We } : {}
600
- } : ke) : [
598
+ model: Q,
599
+ ...je ? { content: je } : {}
600
+ } : we) : [
601
601
  ...Ee,
602
602
  {
603
603
  type: "thinking",
604
- content: We ?? "Thinking...",
604
+ content: je ?? "Thinking...",
605
605
  provider: z,
606
- model: J
606
+ model: Q
607
607
  }
608
608
  ]);
609
609
  return;
610
610
  }
611
- if (we === "tool_call" && F) {
612
- W.current = {
613
- ...W.current,
611
+ if (Ne === "tool_call" && F) {
612
+ G.current = {
613
+ ...G.current,
614
614
  [F]: {
615
- tool: String(Y.tool || ""),
616
- args: Y.args
615
+ tool: String(H.tool || ""),
616
+ args: H.args
617
617
  }
618
618
  }, q(F, (z) => [
619
- ...z.filter((J) => J.type !== "thinking"),
619
+ ...z.filter((Q) => Q.type !== "thinking"),
620
620
  {
621
621
  type: "tool_call",
622
- content: `Calling ${Y.tool}...`,
623
- tool: Y.tool,
624
- args: Y.args
622
+ content: `Calling ${H.tool}...`,
623
+ tool: H.tool,
624
+ args: H.args
625
625
  }
626
626
  ]);
627
627
  return;
628
628
  }
629
- if (we === "tool_result" && F) {
630
- const z = W.current[F];
631
- if (z && z.tool === String(Y.tool || "") && Y.success)
629
+ if (Ne === "tool_result" && F) {
630
+ const z = G.current[F];
631
+ if (z && z.tool === String(H.tool || "") && H.success)
632
632
  if (z.tool === "create_custom_analytics_report" || z.tool === "update_custom_analytics_report") {
633
- const te = typeof Y.report_id == "string" ? Y.report_id : void 0, We = typeof ((tt = z.args) == null ? void 0 : tt.report_id) == "string" ? z.args.report_id : void 0;
634
- Te("Custom Analytics", te || We || ""), n.invalidateQueries({ queryKey: ["runtime-drafts"] });
633
+ const te = typeof H.report_id == "string" ? H.report_id : void 0, je = typeof ((tt = z.args) == null ? void 0 : tt.report_id) == "string" ? z.args.report_id : void 0;
634
+ Se("Custom Analytics", te || je || ""), n.invalidateQueries({ queryKey: ["runtime-drafts"] });
635
635
  } else {
636
636
  const te = Er(z.tool, z.args);
637
- te && Te(te.group, te.item);
637
+ te && Se(te.group, te.item);
638
638
  }
639
- W.current = {
640
- ...W.current,
639
+ G.current = {
640
+ ...G.current,
641
641
  [F]: null
642
- }, q(F, (J) => [
643
- ...J,
642
+ }, q(F, (Q) => [
643
+ ...Q,
644
644
  {
645
645
  type: "tool_result",
646
- content: String(Y.summary || ""),
647
- tool: Y.tool,
648
- success: !!Y.success
646
+ content: String(H.summary || ""),
647
+ tool: H.tool,
648
+ success: !!H.success
649
649
  }
650
650
  ]);
651
651
  return;
652
652
  }
653
- if (we === "complete" && F) {
654
- j(F, !1), q(F, (z) => z.filter((J) => J.type !== "thinking"));
653
+ if (Ne === "complete" && F) {
654
+ j(F, !1), q(F, (z) => z.filter((Q) => Q.type !== "thinking"));
655
655
  return;
656
656
  }
657
- if (we === "error") {
658
- if (pt)
657
+ if (Ne === "error") {
658
+ if (mt)
659
659
  return;
660
660
  F && (j(F, !1), q(F, (z) => [
661
- ...z.filter((J) => J.type !== "thinking"),
662
- { type: "error", content: String(Y.content || "Chat error.") }
661
+ ...z.filter((Q) => Q.type !== "thinking"),
662
+ { type: "error", content: String(H.content || "Chat error.") }
663
663
  ]));
664
664
  }
665
665
  } catch {
666
666
  }
667
667
  }, Be.onerror = () => {
668
668
  Be.close();
669
- }, Be.onclose = (Fe) => {
670
- if (X.current === Be && (X.current = null), R("Chat disconnected."), D("disconnected"), !I) {
671
- if (Fe.code === 4001 || Fe.code === 4003) {
669
+ }, Be.onclose = (ze) => {
670
+ if (X.current === Be && (X.current = null), R("Chat disconnected."), A("disconnected"), !I) {
671
+ if (ze.code === 4001 || ze.code === 4003) {
672
672
  window.location.href = "/login";
673
673
  return;
674
674
  }
675
- P.current = window.setTimeout(Q, 3e3);
675
+ _.current = window.setTimeout(W, 3e3);
676
676
  }
677
677
  };
678
678
  }
679
- return Q(), () => {
680
- if (I = !0, P.current !== null && window.clearTimeout(P.current), A.current !== null && window.clearTimeout(A.current), R("Chat disconnected."), X.current) {
679
+ return W(), () => {
680
+ if (I = !0, _.current !== null && window.clearTimeout(_.current), P.current !== null && window.clearTimeout(P.current), R("Chat disconnected."), X.current) {
681
681
  const ee = X.current;
682
682
  X.current = null, ee.close();
683
683
  }
684
684
  };
685
685
  }, []);
686
- async function ue() {
687
- if (Z.current)
688
- return Z.current;
689
- const I = E("create_session", {}, "session_created").then((Q) => Q.session).finally(() => {
690
- Z.current === I && (Z.current = null);
686
+ async function ce() {
687
+ if (J.current)
688
+ return J.current;
689
+ const I = E("create_session", {}, "session_created").then((W) => W.session).finally(() => {
690
+ J.current === I && (J.current = null);
691
691
  });
692
- return Z.current = I, I;
692
+ return J.current = I, I;
693
693
  }
694
- async function Ie(I) {
695
- oe(I, "running"), me(I, null);
694
+ async function Re(I) {
695
+ oe(I, "running"), he(I, null);
696
696
  try {
697
697
  await E("start_demo", { session_id: I }, "demo_started");
698
- } catch (Q) {
699
- throw oe(I, "idle"), Q;
698
+ } catch (W) {
699
+ throw oe(I, "idle"), W;
700
700
  }
701
701
  }
702
- function Ce(I, Q) {
702
+ function Ie(I, W) {
703
703
  try {
704
- $e({ type: "demo_typing_done", session_id: I, seq: Q });
704
+ Ve({ type: "demo_typing_done", session_id: I, seq: W });
705
705
  } catch {
706
706
  }
707
707
  }
708
- async function Ve(I) {
708
+ async function Me(I) {
709
709
  await E("delete_session", { session_id: I }, "session_deleted");
710
710
  }
711
- async function Ge(I) {
711
+ async function We(I) {
712
712
  await E("load_history", { session_id: I }, "history_loaded");
713
713
  }
714
714
  async function st(I) {
715
715
  if (h[I]) return;
716
- const Q = p[I];
717
- if (Q != null && c[I]) {
716
+ const W = p[I];
717
+ if (W != null && c[I]) {
718
718
  d((ee) => ({ ...ee, [I]: !0 }));
719
719
  try {
720
720
  await E(
721
721
  "load_history",
722
- { session_id: I, before_id: Q },
722
+ { session_id: I, before_id: W },
723
723
  "history_loaded"
724
724
  );
725
725
  } catch (ee) {
726
- throw d((Ne) => ({ ...Ne, [I]: !1 })), ee;
726
+ throw d((xe) => ({ ...xe, [I]: !1 })), ee;
727
727
  }
728
728
  }
729
729
  }
730
- async function it(I) {
730
+ async function et(I) {
731
731
  await E("clear_history", { session_id: I }, "history_cleared");
732
732
  }
733
- function He(I, Q, ee) {
734
- const Ne = Q.trim(), Be = ((ee == null ? void 0 : ee.length) ?? 0) > 0;
735
- if (!Ne && !Be) return !1;
733
+ function Je(I, W, ee) {
734
+ const xe = W.trim(), Be = ((ee == null ? void 0 : ee.length) ?? 0) > 0;
735
+ if (!xe && !Be) return !1;
736
736
  try {
737
737
  j(I, !0);
738
- const Fe = {
738
+ const ze = {
739
739
  type: "send_message",
740
740
  session_id: I,
741
- content: Ne
741
+ content: xe
742
742
  };
743
- return Be && (Fe.attachment_ids = ee), $e(Fe), !0;
743
+ return Be && (ze.attachment_ids = ee), Ve(ze), !0;
744
744
  } catch {
745
745
  return j(I, !1), !1;
746
746
  }
747
747
  }
748
- async function _(I, Q, ee) {
749
- const Ne = await E(
748
+ async function bt(I, W, ee) {
749
+ const xe = await E(
750
750
  "transcribe",
751
- { audio_data: I, audio_format: Q, session_id: ee },
751
+ { audio_data: I, audio_format: W, session_id: ee },
752
752
  "transcription_result"
753
753
  );
754
- if (!Ne.success)
755
- throw new Error(typeof Ne.error == "string" ? Ne.error : "Transcription failed.");
756
- return typeof Ne.text == "string" ? Ne.text : "";
754
+ if (!xe.success)
755
+ throw new Error(typeof xe.error == "string" ? xe.error : "Transcription failed.");
756
+ return typeof xe.text == "string" ? xe.text : "";
757
757
  }
758
- function M(I) {
758
+ function S(I) {
759
759
  return I ? o[I] ?? [] : [];
760
760
  }
761
- function G(I) {
761
+ function M(I) {
762
762
  return I ? !!b[I] : !1;
763
763
  }
764
- function H(I) {
764
+ function Z(I) {
765
765
  return I ? !!c[I] : !1;
766
766
  }
767
- function xe(I) {
767
+ function Y(I) {
768
768
  return I ? !!h[I] : !1;
769
769
  }
770
- function he(I) {
770
+ function me(I) {
771
771
  return I ? N[I] ?? "idle" : "idle";
772
772
  }
773
- function je(I) {
773
+ function Te(I) {
774
774
  return I ? k[I] ?? null : null;
775
775
  }
776
776
  return /* @__PURE__ */ t(
@@ -781,27 +781,27 @@ function Or({ children: e }) {
781
781
  connectionStatus: m,
782
782
  connectionVersion: T,
783
783
  navigationFlash: f,
784
- createSession: ue,
785
- startDemo: Ie,
786
- completeDemoTyping: Ce,
787
- deleteSession: Ve,
788
- loadHistory: Ge,
784
+ createSession: ce,
785
+ startDemo: Re,
786
+ completeDemoTyping: Ie,
787
+ deleteSession: Me,
788
+ loadHistory: We,
789
789
  loadMoreHistory: st,
790
- clearHistory: it,
791
- sendMessage: He,
792
- transcribeAudio: _,
793
- getMessages: M,
794
- hasMoreHistory: H,
795
- isLoadingOlder: xe,
796
- isThinking: G,
797
- getDemoStatus: he,
798
- getDemoTypingCue: je
790
+ clearHistory: et,
791
+ sendMessage: Je,
792
+ transcribeAudio: bt,
793
+ getMessages: S,
794
+ hasMoreHistory: Z,
795
+ isLoadingOlder: Y,
796
+ isThinking: M,
797
+ getDemoStatus: me,
798
+ getDemoTypingCue: Te
799
799
  },
800
800
  children: e
801
801
  }
802
802
  );
803
803
  }
804
- function bt() {
804
+ function yt() {
805
805
  const e = un(fa);
806
806
  if (!e)
807
807
  throw new Error("useChat must be used within ChatProvider.");
@@ -845,7 +845,7 @@ function qr(e) {
845
845
  minute: "2-digit"
846
846
  });
847
847
  }
848
- function Ye(e, n) {
848
+ function Ge(e, n) {
849
849
  const a = parseFloat(String(e ?? 0)) || 0;
850
850
  return n !== void 0 ? parseFloat(a.toFixed(n)) : a;
851
851
  }
@@ -1003,7 +1003,7 @@ function wa() {
1003
1003
  function $r() {
1004
1004
  return Na().prompt;
1005
1005
  }
1006
- const ft = [
1006
+ const gt = [
1007
1007
  {
1008
1008
  label: "Introduction",
1009
1009
  icon: /* @__PURE__ */ t(sr, { className: "h-4 w-4" }),
@@ -1098,19 +1098,19 @@ const ft = [
1098
1098
  }
1099
1099
  ];
1100
1100
  function Vr() {
1101
- return ft;
1101
+ return gt;
1102
1102
  }
1103
1103
  function Il(e, n) {
1104
- const a = ft.findIndex((s) => s.label === e.label);
1104
+ const a = gt.findIndex((s) => s.label === e.label);
1105
1105
  if (a >= 0) {
1106
- ft[a] = e;
1106
+ gt[a] = e;
1107
1107
  return;
1108
1108
  }
1109
- (n == null ? void 0 : n.index) != null ? ft.splice(n.index, 0, e) : ft.push(e);
1109
+ (n == null ? void 0 : n.index) != null ? gt.splice(n.index, 0, e) : gt.push(e);
1110
1110
  }
1111
1111
  function Bl(e, n) {
1112
- const a = ft.find((s) => s.label === e);
1113
- a ? a.items.push(n) : ft.push({ label: e, icon: null, items: [n] });
1112
+ const a = gt.find((s) => s.label === e);
1113
+ a ? a.items.push(n) : gt.push({ label: e, icon: null, items: [n] });
1114
1114
  }
1115
1115
  let sn = { appName: "Lambda ERP" };
1116
1116
  function El(e) {
@@ -1162,7 +1162,7 @@ const yn = {
1162
1162
  "Custom Analytics": "bg-indigo-300 text-indigo-950 ring-2 ring-inset ring-indigo-100"
1163
1163
  };
1164
1164
  function Ur() {
1165
- const [e, n] = fn("chats"), a = Nt(), s = Me(), { t: o } = ne(), { sessions: i, createSession: c, deleteSession: l } = bt(), p = async () => {
1165
+ const [e, n] = fn("chats"), a = Nt(), s = Fe(), { t: o } = ne(), { sessions: i, createSession: c, deleteSession: l } = yt(), p = async () => {
1166
1166
  try {
1167
1167
  const h = await c();
1168
1168
  s(`/chat/${h.id}`);
@@ -1240,7 +1240,7 @@ function bn() {
1240
1240
  );
1241
1241
  }
1242
1242
  function Kr() {
1243
- const [e, n, a] = fn("custom-analytics"), s = Nt(), o = Me(), i = Ze(), { t: c } = ne(), { navigationFlash: l, sessions: p, createSession: u } = bt(), h = (l == null ? void 0 : l.group) === "Custom Analytics", d = yn["Custom Analytics"], { data: b } = ce({
1243
+ const [e, n, a] = fn("custom-analytics"), s = Nt(), o = Fe(), i = Qe(), { t: c } = ne(), { navigationFlash: l, sessions: p, createSession: u } = yt(), h = (l == null ? void 0 : l.group) === "Custom Analytics", d = yn["Custom Analytics"], { data: b } = de({
1244
1244
  queryKey: ["runtime-drafts"],
1245
1245
  queryFn: () => B.listRuntimeDrafts(),
1246
1246
  staleTime: 3e4
@@ -1248,16 +1248,16 @@ function Kr() {
1248
1248
  ae(() => {
1249
1249
  (l == null ? void 0 : l.group) === "Custom Analytics" && (a(), i.invalidateQueries({ queryKey: ["runtime-drafts"] }));
1250
1250
  }, [l == null ? void 0 : l.key, i, a]);
1251
- const N = de({
1252
- mutationFn: (S) => B.deleteRuntimeDraft(S),
1253
- onSuccess: (S, f) => {
1251
+ const N = ue({
1252
+ mutationFn: (D) => B.deleteRuntimeDraft(D),
1253
+ onSuccess: (D, f) => {
1254
1254
  i.invalidateQueries({ queryKey: ["runtime-drafts"] }), s.search.includes(`report_id=${f}`) && o("/reports/analytics");
1255
1255
  }
1256
- }), y = async (S, f) => {
1257
- S.preventDefault(), S.stopPropagation(), N.mutate(f);
1256
+ }), y = async (D, f) => {
1257
+ D.preventDefault(), D.stopPropagation(), N.mutate(f);
1258
1258
  }, k = async () => {
1259
1259
  var g;
1260
- const S = "Build me a custom analytics report: <describe what you want — e.g. top 10 customers by revenue for the last quarter, or monthly purchases trend by supplier>";
1260
+ const D = "Build me a custom analytics report: <describe what you want — e.g. top 10 customers by revenue for the last quarter, or monthly purchases trend by supplier>";
1261
1261
  let f = ((g = p[0]) == null ? void 0 : g.id) || "";
1262
1262
  if (!f)
1263
1263
  try {
@@ -1266,7 +1266,7 @@ function Kr() {
1266
1266
  o("/reports/analytics");
1267
1267
  return;
1268
1268
  }
1269
- o(`/chat/${f}`, { state: { prefillMessage: S } });
1269
+ o(`/chat/${f}`, { state: { prefillMessage: D } });
1270
1270
  };
1271
1271
  return /* @__PURE__ */ r("div", { children: [
1272
1272
  /* @__PURE__ */ r(
@@ -1297,8 +1297,8 @@ function Kr() {
1297
1297
  ]
1298
1298
  }
1299
1299
  ) }),
1300
- v.map((S) => {
1301
- const f = `/reports/analytics?report_id=${S.id}`, g = s.pathname === "/reports/analytics" && s.search.includes(`report_id=${S.id}`), m = (l == null ? void 0 : l.group) === "Custom Analytics" && (l == null ? void 0 : l.item) === S.id;
1300
+ v.map((D) => {
1301
+ const f = `/reports/analytics?report_id=${D.id}`, g = s.pathname === "/reports/analytics" && s.search.includes(`report_id=${D.id}`), m = (l == null ? void 0 : l.group) === "Custom Analytics" && (l == null ? void 0 : l.item) === D.id;
1302
1302
  return /* @__PURE__ */ r("li", { className: "group relative", children: [
1303
1303
  /* @__PURE__ */ t(
1304
1304
  $t,
@@ -1310,27 +1310,27 @@ function Kr() {
1310
1310
  g && "bg-surface-subtle font-medium text-fg",
1311
1311
  m && d
1312
1312
  ),
1313
- title: S.title,
1314
- children: S.title
1313
+ title: D.title,
1314
+ children: D.title
1315
1315
  }
1316
1316
  ),
1317
1317
  g && /* @__PURE__ */ t(bn, {}),
1318
1318
  /* @__PURE__ */ t(
1319
1319
  "button",
1320
1320
  {
1321
- onClick: (D) => y(D, S.id),
1321
+ onClick: (A) => y(A, D.id),
1322
1322
  className: "absolute right-2 top-1/2 -translate-y-1/2 rounded p-0.5 text-fg-muted opacity-0 transition-opacity hover:text-red-500 group-hover:opacity-100",
1323
1323
  title: c("nav.deleteReport"),
1324
1324
  children: /* @__PURE__ */ t(ca, { className: "h-3.5 w-3.5" })
1325
1325
  }
1326
1326
  )
1327
- ] }, S.id);
1327
+ ] }, D.id);
1328
1328
  })
1329
1329
  ] })
1330
1330
  ] });
1331
1331
  }
1332
1332
  function jr({ group: e }) {
1333
- const [n, a] = fn(e.label), { t: s } = ne(), { navigationFlash: o } = bt(), i = (o == null ? void 0 : o.group) === e.label, c = yn[e.label] ?? "bg-blue-300 text-blue-950 ring-2 ring-inset ring-blue-100";
1333
+ const [n, a] = fn(e.label), { t: s } = ne(), { navigationFlash: o } = yt(), i = (o == null ? void 0 : o.group) === e.label, c = yn[e.label] ?? "bg-blue-300 text-blue-950 ring-2 ring-inset ring-blue-100";
1334
1334
  return /* @__PURE__ */ r("div", { children: [
1335
1335
  /* @__PURE__ */ r(
1336
1336
  "button",
@@ -1363,7 +1363,7 @@ function jr({ group: e }) {
1363
1363
  u && "bg-surface-subtle font-medium text-fg",
1364
1364
  (o == null ? void 0 : o.group) === e.label && (o == null ? void 0 : o.item) === l.label && c
1365
1365
  ),
1366
- children: ({ isActive: u }) => /* @__PURE__ */ r(Pe, { children: [
1366
+ children: ({ isActive: u }) => /* @__PURE__ */ r(Ae, { children: [
1367
1367
  u && /* @__PURE__ */ t(bn, {}),
1368
1368
  s(`nav.items.${l.label}`, { defaultValue: l.label })
1369
1369
  ] })
@@ -1377,11 +1377,11 @@ const Wr = {
1377
1377
  };
1378
1378
  function Gr({ isMobileOpen: e = !1, onClose: n }) {
1379
1379
  var l;
1380
- const { data: a } = ce({
1380
+ const { data: a } = de({
1381
1381
  queryKey: ["settings"],
1382
1382
  queryFn: () => B.getSettings(),
1383
1383
  staleTime: 6e4
1384
- }), { data: s } = ce({
1384
+ }), { data: s } = de({
1385
1385
  queryKey: ["setup-status"],
1386
1386
  queryFn: () => B.setupStatus(),
1387
1387
  staleTime: 6e4
@@ -1446,12 +1446,12 @@ function Gr({ isMobileOpen: e = !1, onClose: n }) {
1446
1446
  }
1447
1447
  const Tt = ["my-settings"];
1448
1448
  function vn() {
1449
- const e = Ze(), { user: n } = at(), { data: a } = ce({
1449
+ const e = Qe(), { user: n } = at(), { data: a } = de({
1450
1450
  queryKey: Tt,
1451
1451
  queryFn: () => B.getMySettings(),
1452
1452
  enabled: !!n,
1453
1453
  staleTime: 300 * 1e3
1454
- }), s = de({
1454
+ }), s = ue({
1455
1455
  mutationFn: (c) => B.updateMySettings(c),
1456
1456
  onSuccess: (c) => e.setQueryData(Tt, c)
1457
1457
  });
@@ -1488,7 +1488,7 @@ function Qr() {
1488
1488
  return /* @__PURE__ */ t(zr, { children: /* @__PURE__ */ t(Or, { children: /* @__PURE__ */ t(Jr, {}) }) });
1489
1489
  }
1490
1490
  function Jr() {
1491
- const { pathname: e } = Nt(), n = Me(), { user: a, logout: s } = at(), { navigationFlash: o } = bt(), { t: i, i18n: c } = ne(), { settings: l } = vn();
1491
+ const { pathname: e } = Nt(), n = Fe(), { user: a, logout: s } = at(), { navigationFlash: o } = yt(), { t: i, i18n: c } = ne(), { settings: l } = vn();
1492
1492
  ae(() => {
1493
1493
  const N = l.language;
1494
1494
  N && N !== (c.language || "").split("-")[0] && c.changeLanguage(N);
@@ -1558,9 +1558,9 @@ function Jr() {
1558
1558
  }
1559
1559
  function Zr({ children: e }) {
1560
1560
  const { user: n, loading: a } = at();
1561
- return a ? /* @__PURE__ */ t("div", { className: "flex h-dvh items-center justify-center", children: /* @__PURE__ */ t("div", { className: "text-gray-400", children: "Loading..." }) }) : n ? /* @__PURE__ */ t(Pe, { children: e }) : /* @__PURE__ */ t(tr, { to: "/login", replace: !0 });
1561
+ return a ? /* @__PURE__ */ t("div", { className: "flex h-dvh items-center justify-center", children: /* @__PURE__ */ t("div", { className: "text-gray-400", children: "Loading..." }) }) : n ? /* @__PURE__ */ t(Ae, { children: e }) : /* @__PURE__ */ t(tr, { to: "/login", replace: !0 });
1562
1562
  }
1563
- function _e(e) {
1563
+ function Pe(e) {
1564
1564
  ae(() => {
1565
1565
  const n = ka().appName || "Lambda ERP";
1566
1566
  return document.title = e ? `${e} - ${n}` : n, () => {
@@ -1632,7 +1632,7 @@ function xn({ status: e }) {
1632
1632
  }
1633
1633
  function Ke(e) {
1634
1634
  var s;
1635
- const { data: n } = ce({
1635
+ const { data: n } = de({
1636
1636
  queryKey: ["setup-status"],
1637
1637
  queryFn: () => B.setupStatus(),
1638
1638
  staleTime: 3e5
@@ -1674,7 +1674,7 @@ const ts = {
1674
1674
  function ns({ doc: e }) {
1675
1675
  const { t: n } = ne(), a = e.doctype ?? e.type ?? "Document", s = e.creation ?? e.date, o = ts[a] ?? pn, c = `/app/${a.toLowerCase().replace(/\s+/g, "-")}/${encodeURIComponent(e.name)}`;
1676
1676
  return /* @__PURE__ */ r(
1677
- De,
1677
+ Ce,
1678
1678
  {
1679
1679
  to: c,
1680
1680
  className: "grid grid-cols-[auto_1fr_auto_auto] items-center gap-3 rounded-lg px-3 py-2.5 transition-colors hover:bg-surface-subtle",
@@ -1703,18 +1703,18 @@ function Ct() {
1703
1703
  }
1704
1704
  function as() {
1705
1705
  const { t: e } = ne();
1706
- _e(e("titles.dashboard"));
1707
- const { data: n, isLoading: a } = ce({
1706
+ Pe(e("titles.dashboard"));
1707
+ const { data: n, isLoading: a } = de({
1708
1708
  queryKey: ["dashboard-summary"],
1709
1709
  queryFn: () => B.dashboardSummary()
1710
1710
  });
1711
1711
  return /* @__PURE__ */ r("div", { className: "space-y-6", children: [
1712
- /* @__PURE__ */ t("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4", children: a ? /* @__PURE__ */ r(Pe, { children: [
1712
+ /* @__PURE__ */ t("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4", children: a ? /* @__PURE__ */ r(Ae, { children: [
1713
1713
  /* @__PURE__ */ t(It, {}),
1714
1714
  /* @__PURE__ */ t(It, {}),
1715
1715
  /* @__PURE__ */ t(It, {}),
1716
1716
  /* @__PURE__ */ t(It, {})
1717
- ] }) : /* @__PURE__ */ r(Pe, { children: [
1717
+ ] }) : /* @__PURE__ */ r(Ae, { children: [
1718
1718
  /* @__PURE__ */ t(
1719
1719
  Rt,
1720
1720
  {
@@ -1752,7 +1752,7 @@ function as() {
1752
1752
  }
1753
1753
  )
1754
1754
  ] }) }),
1755
- /* @__PURE__ */ t($, { title: e("dashboard.recentDocuments"), children: /* @__PURE__ */ t("div", { className: "-mx-3 space-y-0.5", children: a ? /* @__PURE__ */ r(Pe, { children: [
1755
+ /* @__PURE__ */ t($, { title: e("dashboard.recentDocuments"), children: /* @__PURE__ */ t("div", { className: "-mx-3 space-y-0.5", children: a ? /* @__PURE__ */ r(Ae, { children: [
1756
1756
  /* @__PURE__ */ t(Ct, {}),
1757
1757
  /* @__PURE__ */ t(Ct, {}),
1758
1758
  /* @__PURE__ */ t(Ct, {}),
@@ -1780,7 +1780,7 @@ function rs(e) {
1780
1780
  return Da()[e];
1781
1781
  }
1782
1782
  function ss(e, n) {
1783
- const { data: a, isLoading: s, error: o, refetch: i } = ce({
1783
+ const { data: a, isLoading: s, error: o, refetch: i } = de({
1784
1784
  queryKey: ["documents", e, n],
1785
1785
  queryFn: () => B.listDocuments(e, n),
1786
1786
  enabled: !!e
@@ -1828,7 +1828,7 @@ function le(e, n) {
1828
1828
  );
1829
1829
  return [i, c];
1830
1830
  }
1831
- const mt = [
1831
+ const ut = [
1832
1832
  { name: "item_code", label: "Item", type: "link", linkDoctype: "item", required: !0 },
1833
1833
  { name: "item_name", label: "Item Name", type: "text", readOnly: !0 },
1834
1834
  // Per-line description/blurb. Defaults from the Item master on save (an empty
@@ -1839,7 +1839,7 @@ const mt = [
1839
1839
  { name: "rate", label: "Rate", type: "currency", required: !0 },
1840
1840
  { name: "amount", label: "Amount", type: "currency", readOnly: !0 }
1841
1841
  ], is = [
1842
- ...mt,
1842
+ ...ut,
1843
1843
  {
1844
1844
  name: "frequency",
1845
1845
  label: "Frequency",
@@ -1847,13 +1847,13 @@ const mt = [
1847
1847
  options: ["One-time", "Monthly", "Quarterly", "Half-Yearly", "Yearly"],
1848
1848
  default: "One-time"
1849
1849
  }
1850
- ], dt = {
1850
+ ], ct = {
1851
1851
  name: "currency",
1852
1852
  label: "Currency",
1853
1853
  type: "select",
1854
1854
  optionsSource: "currency",
1855
1855
  hint: "The currency this document is transacted in. Defaults from the party's (or the company's) default currency. The ledger still posts in the company base currency, translated at this document's exchange rate."
1856
- }, ut = [
1856
+ }, dt = [
1857
1857
  {
1858
1858
  name: "charge_type",
1859
1859
  label: "Type",
@@ -1878,7 +1878,7 @@ const mt = [
1878
1878
  { name: "transaction_date", label: "Date", type: "date", required: !0 },
1879
1879
  { name: "valid_till", label: "Valid Till", type: "date" },
1880
1880
  { name: "company", label: "Company", type: "link", linkDoctype: "company", required: !0 },
1881
- dt,
1881
+ ct,
1882
1882
  { name: "net_total", label: "Net Total", type: "currency", readOnly: !0 },
1883
1883
  { name: "total_taxes_and_charges", label: "Tax", type: "currency", readOnly: !0 },
1884
1884
  { name: "grand_total", label: "Grand Total", type: "currency", readOnly: !0 },
@@ -1886,7 +1886,7 @@ const mt = [
1886
1886
  ],
1887
1887
  childTables: [
1888
1888
  { key: "items", label: "Items", fields: is },
1889
- { key: "taxes", label: "Taxes", fields: ut }
1889
+ { key: "taxes", label: "Taxes", fields: dt }
1890
1890
  ],
1891
1891
  listColumns: ["name", "customer", "transaction_date", "grand_total", "status"],
1892
1892
  canSubmit: !0,
@@ -1925,7 +1925,7 @@ const mt = [
1925
1925
  { name: "transaction_date", label: "Date", type: "date", required: !0 },
1926
1926
  { name: "delivery_date", label: "Delivery Date", type: "date" },
1927
1927
  { name: "company", label: "Company", type: "link", linkDoctype: "company", required: !0 },
1928
- dt,
1928
+ ct,
1929
1929
  { name: "per_delivered", label: "% Delivered", type: "number", readOnly: !0 },
1930
1930
  { name: "per_billed", label: "% Billed", type: "number", readOnly: !0 },
1931
1931
  { name: "net_total", label: "Net Total", type: "currency", readOnly: !0 },
@@ -1933,8 +1933,8 @@ const mt = [
1933
1933
  { name: "remarks", label: "Notes / Terms", type: "textarea" }
1934
1934
  ],
1935
1935
  childTables: [
1936
- { key: "items", label: "Items", fields: mt },
1937
- { key: "taxes", label: "Taxes", fields: ut }
1936
+ { key: "items", label: "Items", fields: ut },
1937
+ { key: "taxes", label: "Taxes", fields: dt }
1938
1938
  ],
1939
1939
  listColumns: ["name", "customer", "transaction_date", "grand_total", "status"],
1940
1940
  canSubmit: !0,
@@ -1956,7 +1956,7 @@ const mt = [
1956
1956
  { name: "posting_date", label: "Posting Date", type: "date", required: !0 },
1957
1957
  { name: "due_date", label: "Due Date", type: "date" },
1958
1958
  { name: "company", label: "Company", type: "link", linkDoctype: "company", required: !0 },
1959
- dt,
1959
+ ct,
1960
1960
  { name: "net_total", label: "Net Total", type: "currency", readOnly: !0 },
1961
1961
  { name: "total_taxes_and_charges", label: "Tax", type: "currency", readOnly: !0 },
1962
1962
  { name: "grand_total", label: "Grand Total", type: "currency", readOnly: !0 },
@@ -1964,8 +1964,8 @@ const mt = [
1964
1964
  { name: "remarks", label: "Notes / Terms", type: "textarea" }
1965
1965
  ],
1966
1966
  childTables: [
1967
- { key: "items", label: "Items", fields: [...mt, { name: "income_account", label: "Income Account", type: "link", linkDoctype: "account" }] },
1968
- { key: "taxes", label: "Taxes", fields: ut }
1967
+ { key: "items", label: "Items", fields: [...ut, { name: "income_account", label: "Income Account", type: "link", linkDoctype: "account" }] },
1968
+ { key: "taxes", label: "Taxes", fields: dt }
1969
1969
  ],
1970
1970
  listColumns: ["name", "customer", "posting_date", "grand_total", "outstanding_amount", "status"],
1971
1971
  canSubmit: !0,
@@ -1985,14 +1985,14 @@ const mt = [
1985
1985
  { name: "supplier", label: "Supplier", type: "link", linkDoctype: "supplier", required: !0 },
1986
1986
  { name: "transaction_date", label: "Date", type: "date", required: !0 },
1987
1987
  { name: "company", label: "Company", type: "link", linkDoctype: "company", required: !0 },
1988
- dt,
1988
+ ct,
1989
1989
  { name: "net_total", label: "Net Total", type: "currency", readOnly: !0 },
1990
1990
  { name: "grand_total", label: "Grand Total", type: "currency", readOnly: !0 },
1991
1991
  { name: "remarks", label: "Notes / Terms", type: "textarea" }
1992
1992
  ],
1993
1993
  childTables: [
1994
- { key: "items", label: "Items", fields: [...mt, { name: "warehouse", label: "Warehouse", type: "link", linkDoctype: "warehouse" }] },
1995
- { key: "taxes", label: "Taxes", fields: ut }
1994
+ { key: "items", label: "Items", fields: [...ut, { name: "warehouse", label: "Warehouse", type: "link", linkDoctype: "warehouse" }] },
1995
+ { key: "taxes", label: "Taxes", fields: dt }
1996
1996
  ],
1997
1997
  listColumns: ["name", "supplier", "transaction_date", "grand_total", "status"],
1998
1998
  canSubmit: !0,
@@ -2014,7 +2014,7 @@ const mt = [
2014
2014
  { name: "posting_date", label: "Posting Date", type: "date", required: !0 },
2015
2015
  { name: "due_date", label: "Due Date", type: "date" },
2016
2016
  { name: "company", label: "Company", type: "link", linkDoctype: "company", required: !0 },
2017
- dt,
2017
+ ct,
2018
2018
  {
2019
2019
  name: "update_stock",
2020
2020
  label: "Update Stock",
@@ -2033,7 +2033,7 @@ const mt = [
2033
2033
  key: "items",
2034
2034
  label: "Items",
2035
2035
  fields: [
2036
- ...mt,
2036
+ ...ut,
2037
2037
  {
2038
2038
  name: "warehouse",
2039
2039
  label: "Warehouse",
@@ -2044,7 +2044,7 @@ const mt = [
2044
2044
  { name: "expense_account", label: "Expense Account", type: "link", linkDoctype: "account" }
2045
2045
  ]
2046
2046
  },
2047
- { key: "taxes", label: "Taxes", fields: ut }
2047
+ { key: "taxes", label: "Taxes", fields: dt }
2048
2048
  ],
2049
2049
  listColumns: ["name", "supplier", "posting_date", "grand_total", "outstanding_amount", "status"],
2050
2050
  canSubmit: !0,
@@ -2225,7 +2225,7 @@ const mt = [
2225
2225
  { name: "customer", label: "Customer", type: "link", linkDoctype: "customer", required: !0 },
2226
2226
  { name: "posting_date", label: "Posting Date", type: "date", required: !0 },
2227
2227
  { name: "company", label: "Company", type: "link", linkDoctype: "company", required: !0 },
2228
- dt,
2228
+ ct,
2229
2229
  { name: "net_total", label: "Net Total", type: "currency", readOnly: !0 },
2230
2230
  { name: "total_taxes_and_charges", label: "Tax", type: "currency", readOnly: !0 },
2231
2231
  { name: "grand_total", label: "Grand Total", type: "currency", readOnly: !0 },
@@ -2236,11 +2236,11 @@ const mt = [
2236
2236
  key: "items",
2237
2237
  label: "Items",
2238
2238
  fields: [
2239
- ...mt,
2239
+ ...ut,
2240
2240
  { name: "warehouse", label: "Warehouse", type: "link", linkDoctype: "warehouse", required: !0 }
2241
2241
  ]
2242
2242
  },
2243
- { key: "taxes", label: "Taxes", fields: ut }
2243
+ { key: "taxes", label: "Taxes", fields: dt }
2244
2244
  ],
2245
2245
  listColumns: ["name", "customer", "posting_date", "grand_total", "status"],
2246
2246
  canSubmit: !0,
@@ -2260,7 +2260,7 @@ const mt = [
2260
2260
  { name: "supplier", label: "Supplier", type: "link", linkDoctype: "supplier", required: !0 },
2261
2261
  { name: "posting_date", label: "Posting Date", type: "date", required: !0 },
2262
2262
  { name: "company", label: "Company", type: "link", linkDoctype: "company", required: !0 },
2263
- dt,
2263
+ ct,
2264
2264
  { name: "net_total", label: "Net Total", type: "currency", readOnly: !0 },
2265
2265
  { name: "total_taxes_and_charges", label: "Tax", type: "currency", readOnly: !0 },
2266
2266
  { name: "grand_total", label: "Grand Total", type: "currency", readOnly: !0 },
@@ -2271,11 +2271,11 @@ const mt = [
2271
2271
  key: "items",
2272
2272
  label: "Items",
2273
2273
  fields: [
2274
- ...mt,
2274
+ ...ut,
2275
2275
  { name: "warehouse", label: "Warehouse", type: "link", linkDoctype: "warehouse", required: !0 }
2276
2276
  ]
2277
2277
  },
2278
- { key: "taxes", label: "Taxes", fields: ut }
2278
+ { key: "taxes", label: "Taxes", fields: dt }
2279
2279
  ],
2280
2280
  listColumns: ["name", "supplier", "posting_date", "grand_total", "status"],
2281
2281
  canSubmit: !0,
@@ -2295,7 +2295,7 @@ const mt = [
2295
2295
  { name: "customer", label: "Customer", type: "link", linkDoctype: "customer", required: !0 },
2296
2296
  { name: "posting_date", label: "Posting Date", type: "date", required: !0 },
2297
2297
  { name: "company", label: "Company", type: "link", linkDoctype: "company", required: !0 },
2298
- dt,
2298
+ ct,
2299
2299
  {
2300
2300
  name: "update_stock",
2301
2301
  label: "Update Stock",
@@ -2315,7 +2315,7 @@ const mt = [
2315
2315
  key: "items",
2316
2316
  label: "Items",
2317
2317
  fields: [
2318
- ...mt,
2318
+ ...ut,
2319
2319
  {
2320
2320
  name: "warehouse",
2321
2321
  label: "Warehouse",
@@ -2325,7 +2325,7 @@ const mt = [
2325
2325
  }
2326
2326
  ]
2327
2327
  },
2328
- { key: "taxes", label: "Taxes", fields: ut },
2328
+ { key: "taxes", label: "Taxes", fields: dt },
2329
2329
  {
2330
2330
  key: "payments",
2331
2331
  label: "Payments",
@@ -2587,7 +2587,7 @@ function Ol() {
2587
2587
  return Object.values(Nn);
2588
2588
  }
2589
2589
  function _a({ slug: e, name: n, onSave: a, kind: s = "document" }) {
2590
- const o = Me(), i = s === "master", c = rs(i ? `master:${e}` : e), l = i ? `/masters/${e}` : `/app/${e}`, { data: p } = ce({
2590
+ const o = Fe(), i = s === "master", c = rs(i ? `master:${e}` : e), l = i ? `/masters/${e}` : `/app/${e}`, { data: p } = de({
2591
2591
  queryKey: ["adjacent", s, e, n, (c == null ? void 0 : c.filters) ?? null],
2592
2592
  queryFn: () => i ? B.adjacentMaster(e, n) : B.adjacentDocument(e, n, c == null ? void 0 : c.filters)
2593
2593
  }), u = (p == null ? void 0 : p.prev) ?? null, h = (p == null ? void 0 : p.next) ?? null;
@@ -2597,8 +2597,8 @@ function _a({ slug: e, name: n, onSave: a, kind: s = "document" }) {
2597
2597
  a && (k.preventDefault(), a());
2598
2598
  return;
2599
2599
  }
2600
- const S = document.activeElement;
2601
- S && (/^(input|textarea|select)$/i.test(S.tagName) || S.isContentEditable) || k.metaKey || k.ctrlKey || k.altKey || (k.key === "j" || k.key === "ArrowRight" ? (k.preventDefault(), v()) : k.key === "k" || k.key === "ArrowLeft" ? (k.preventDefault(), b()) : (k.key === "Escape" || k.key === "u") && (k.preventDefault(), N()));
2600
+ const D = document.activeElement;
2601
+ D && (/^(input|textarea|select)$/i.test(D.tagName) || D.isContentEditable) || k.metaKey || k.ctrlKey || k.altKey || (k.key === "j" || k.key === "ArrowRight" ? (k.preventDefault(), v()) : k.key === "k" || k.key === "ArrowLeft" ? (k.preventDefault(), b()) : (k.key === "Escape" || k.key === "u") && (k.preventDefault(), N()));
2602
2602
  };
2603
2603
  return window.addEventListener("keydown", y), () => window.removeEventListener("keydown", y);
2604
2604
  }, [u, h, l, c == null ? void 0 : c.search, a, o]);
@@ -2631,7 +2631,7 @@ function _a({ slug: e, name: n, onSave: a, kind: s = "document" }) {
2631
2631
  function os(e) {
2632
2632
  return typeof e == "string" ? { value: e, label: e } : e;
2633
2633
  }
2634
- function Je({ label: e, options: n, value: a, onChange: s, className: o, required: i, disabled: c }) {
2634
+ function Ye({ label: e, options: n, value: a, onChange: s, className: o, required: i, disabled: c }) {
2635
2635
  const l = e ? e.toLowerCase().replace(/\s+/g, "-") : void 0;
2636
2636
  return /* @__PURE__ */ r("div", { children: [
2637
2637
  e && /* @__PURE__ */ t(
@@ -2734,7 +2734,7 @@ function cs() {
2734
2734
  );
2735
2735
  }
2736
2736
  function ds(e, n = !0) {
2737
- const { data: a } = ce({
2737
+ const { data: a } = de({
2738
2738
  queryKey: ["currencies", ""],
2739
2739
  queryFn: () => B.currencies(e),
2740
2740
  enabled: n,
@@ -2765,7 +2765,7 @@ function ms({
2765
2765
  disabled: s,
2766
2766
  hideLabel: o
2767
2767
  }) {
2768
- const [i, c] = w(n ?? ""), [l, p] = w(!1), u = ie(null), [h, d] = w(null), { data: b } = ce({
2768
+ const [i, c] = w(n ?? ""), [l, p] = w(!1), u = ie(null), [h, d] = w(null), { data: b } = de({
2769
2769
  queryKey: ["link-search", e.linkDoctype, i],
2770
2770
  queryFn: () => B.searchLink(e.linkDoctype, i),
2771
2771
  enabled: !!e.linkDoctype && l
@@ -2848,7 +2848,7 @@ function Ot({
2848
2848
  return /* @__PURE__ */ r("div", { children: [
2849
2849
  /* @__PURE__ */ t(h, {}),
2850
2850
  /* @__PURE__ */ t("p", { className: i ? "text-sm" : "py-2 text-sm", children: /* @__PURE__ */ t(
2851
- De,
2851
+ Ce,
2852
2852
  {
2853
2853
  to: g,
2854
2854
  className: "text-sky-600 hover:text-sky-800 hover:underline",
@@ -2859,13 +2859,13 @@ function Ot({
2859
2859
  }
2860
2860
  let k = n ?? "-";
2861
2861
  e.type === "currency" && typeof n == "number" && (k = Ue(n, c)), e.type === "datetime" && typeof n == "string" && n && (k = n.slice(0, 16));
2862
- const S = [
2862
+ const D = [
2863
2863
  i ? "text-sm text-fg" : "py-2 text-sm text-fg",
2864
2864
  e.type === "textarea" ? "whitespace-pre-line" : ""
2865
2865
  ].join(" ").trim();
2866
2866
  return /* @__PURE__ */ r("div", { children: [
2867
2867
  /* @__PURE__ */ t(h, {}),
2868
- /* @__PURE__ */ t("p", { className: S, children: k })
2868
+ /* @__PURE__ */ t("p", { className: D, children: k })
2869
2869
  ] });
2870
2870
  }
2871
2871
  if (e.type === "link") {
@@ -2888,19 +2888,19 @@ function Ot({
2888
2888
  const k = d ? n && !b.includes(n) ? [n, ...b] : b : (
2889
2889
  // Translate the visible label but keep the stored value (e.g. status
2890
2890
  // "Available" -> "Verfügbar"): t(`fieldOptions.<value>`), English fallback.
2891
- e.options.map((S) => {
2892
- const f = typeof S == "string" ? S : S.value, g = typeof S == "string" ? S : S.label;
2891
+ e.options.map((D) => {
2892
+ const f = typeof D == "string" ? D : D.value, g = typeof D == "string" ? D : D.label;
2893
2893
  return { value: f, label: p(`fieldOptions.${f}`, { defaultValue: g }) };
2894
2894
  })
2895
2895
  );
2896
2896
  return /* @__PURE__ */ r("div", { children: [
2897
2897
  /* @__PURE__ */ t(h, {}),
2898
2898
  /* @__PURE__ */ t(
2899
- Je,
2899
+ Ye,
2900
2900
  {
2901
2901
  options: k,
2902
2902
  value: n ?? "",
2903
- onChange: (S) => a(S.target.value)
2903
+ onChange: (D) => a(D.target.value)
2904
2904
  }
2905
2905
  )
2906
2906
  ] });
@@ -2922,7 +2922,7 @@ function Ot({
2922
2922
  className: "block w-full rounded-lg bg-surface px-3 py-2 text-sm text-fg ring-1 ring-line transition-all placeholder:text-fg-muted/70 focus:outline-none focus:ring-2 focus:ring-brand/30",
2923
2923
  rows: i ? 3 : 7,
2924
2924
  value: n ?? "",
2925
- onChange: (S) => a(S.target.value)
2925
+ onChange: (D) => a(D.target.value)
2926
2926
  }
2927
2927
  )
2928
2928
  ] });
@@ -2937,9 +2937,9 @@ function Ot({
2937
2937
  step: e.type === "currency" ? "0.01" : void 0,
2938
2938
  value: N,
2939
2939
  onChange: (k) => {
2940
- const S = k.target.value;
2940
+ const D = k.target.value;
2941
2941
  a(
2942
- v === "number" ? parseFloat(S) || 0 : e.type === "datetime" ? S.replace("T", " ") : S
2942
+ v === "number" ? parseFloat(D) || 0 : e.type === "datetime" ? D.replace("T", " ") : D
2943
2943
  );
2944
2944
  }
2945
2945
  }
@@ -3024,14 +3024,14 @@ function hs({
3024
3024
  onSoftCancel: b,
3025
3025
  softCancelDone: v
3026
3026
  }) {
3027
- const { t: N } = ne(), [y, k] = w(!1), [S, f] = w(!1), [g, m] = w(!1);
3027
+ const { t: N } = ne(), [y, k] = w(!1), [D, f] = w(!1), [g, m] = w(!1);
3028
3028
  if (!c) return null;
3029
- const D = !e && n && a ? `/api/documents/${n}/${encodeURIComponent(a)}/pdf` : null, T = !e && c.canCancel && s === 1;
3029
+ const A = !e && n && a ? `/api/documents/${n}/${encodeURIComponent(a)}/pdf` : null, T = !e && c.canCancel && s === 1;
3030
3030
  return /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-2", children: [
3031
- D && /* @__PURE__ */ t(K, { variant: "secondary", onClick: () => window.open(D, "_blank"), children: N("common.pdf") }),
3031
+ A && /* @__PURE__ */ t(K, { variant: "secondary", onClick: () => window.open(A, "_blank"), children: N("common.pdf") }),
3032
3032
  s < 1 && !o && /* @__PURE__ */ t(K, { onClick: l, disabled: i, children: N(i ? "common.saving" : "common.save") }),
3033
3033
  !e && c.canSubmit && s === 0 && !o && /* @__PURE__ */ t(K, { variant: "secondary", onClick: p, children: N("common.submit") }),
3034
- !e && c.canSubmit && s === 0 && !o && (S ? /* @__PURE__ */ r(Pe, { children: [
3034
+ !e && c.canSubmit && s === 0 && !o && (D ? /* @__PURE__ */ r(Ae, { children: [
3035
3035
  /* @__PURE__ */ t(K, { variant: "secondary", onClick: () => f(!1), children: N("common.keepDraft") }),
3036
3036
  /* @__PURE__ */ t(
3037
3037
  K,
@@ -3044,7 +3044,7 @@ function hs({
3044
3044
  }
3045
3045
  )
3046
3046
  ] }) : /* @__PURE__ */ t(K, { variant: "ghost", onClick: () => f(!0), children: N("common.discardDraft") })),
3047
- c.softCancel && !e && !o && !v && (g ? /* @__PURE__ */ r(Pe, { children: [
3047
+ c.softCancel && !e && !o && !v && (g ? /* @__PURE__ */ r(Ae, { children: [
3048
3048
  /* @__PURE__ */ t(K, { variant: "secondary", onClick: () => m(!1), children: N("common.keepBooking") }),
3049
3049
  /* @__PURE__ */ t(
3050
3050
  K,
@@ -3085,35 +3085,35 @@ function On(e, n) {
3085
3085
  const a = { ...e };
3086
3086
  if (n.childTables.some((i) => i.key === "items") && Array.isArray(a.items) && (a.items = a.items.map((i) => ({
3087
3087
  ...i,
3088
- amount: Ye(i.qty, 2) * Ye(i.rate, 2)
3088
+ amount: Ge(i.qty, 2) * Ge(i.rate, 2)
3089
3089
  })), a.net_total = a.items.reduce(
3090
- (i, c) => i + Ye(c.amount, 2),
3090
+ (i, c) => i + Ge(c.amount, 2),
3091
3091
  0
3092
3092
  )), n.childTables.some((i) => i.key === "taxes") && Array.isArray(a.taxes)) {
3093
3093
  a.taxes = a.taxes.map((c) => c.charge_type === "On Net Total" ? {
3094
3094
  ...c,
3095
- tax_amount: Ye(a.net_total, 2) * Ye(c.rate, 2) / 100
3095
+ tax_amount: Ge(a.net_total, 2) * Ge(c.rate, 2) / 100
3096
3096
  } : c);
3097
3097
  const i = a.taxes.reduce(
3098
- (c, l) => c + Ye(l.tax_amount, 2),
3098
+ (c, l) => c + Ge(l.tax_amount, 2),
3099
3099
  0
3100
3100
  );
3101
- a.total_taxes_and_charges = i, a.grand_total = Ye(a.net_total, 2) + i;
3101
+ a.total_taxes_and_charges = i, a.grand_total = Ge(a.net_total, 2) + i;
3102
3102
  }
3103
3103
  return a;
3104
3104
  }
3105
3105
  function qn() {
3106
- var $e;
3107
- const { doctype: e, name: n } = yt(), a = Me(), s = Ze(), { t: o } = ne(), i = Pa(e ?? ""), c = !n;
3108
- _e(c ? (i == null ? void 0 : i.label) ?? null : n ?? (i == null ? void 0 : i.label) ?? null);
3109
- const [l, p] = w({}), [u, h] = w(!1), { data: d, isLoading: b } = ce({
3106
+ var Ve;
3107
+ const { doctype: e, name: n } = ft(), a = Fe(), s = Qe(), { t: o } = ne(), i = Pa(e ?? ""), c = !n;
3108
+ Pe(c ? (i == null ? void 0 : i.label) ?? null : n ?? (i == null ? void 0 : i.label) ?? null);
3109
+ const [l, p] = w({}), [u, h] = w(!1), { data: d, isLoading: b } = de({
3110
3110
  queryKey: ["document", e, n],
3111
3111
  queryFn: () => B.getDocument(e, n),
3112
3112
  enabled: !!e && !!n && !c
3113
3113
  }), v = be(
3114
3114
  () => !!(i != null && i.fields.some((E) => E.name === "currency")),
3115
3115
  [i]
3116
- ), N = i == null ? void 0 : i.partyField, y = N ? l[N] : void 0, k = Ke(l.company), { data: S } = ce({
3116
+ ), N = i == null ? void 0 : i.partyField, y = N ? l[N] : void 0, k = Ke(l.company), { data: D } = de({
3117
3117
  queryKey: ["master", N, y],
3118
3118
  queryFn: () => B.getMaster(N, y),
3119
3119
  enabled: c && v && !!N && !!y,
@@ -3123,85 +3123,85 @@ function qn() {
3123
3123
  if (!c || !v || u) return;
3124
3124
  let E;
3125
3125
  if (y) {
3126
- if (!S) return;
3127
- E = S.default_currency || k;
3126
+ if (!D) return;
3127
+ E = D.default_currency || k;
3128
3128
  } else
3129
3129
  E = k;
3130
- E && E !== l.currency && p((ue) => ({ ...ue, currency: E }));
3130
+ E && E !== l.currency && p((ce) => ({ ...ce, currency: E }));
3131
3131
  }, [
3132
3132
  c,
3133
3133
  v,
3134
3134
  u,
3135
3135
  y,
3136
- S,
3136
+ D,
3137
3137
  k,
3138
3138
  l.currency
3139
3139
  ]), ae(() => {
3140
3140
  if (c && i) {
3141
3141
  const E = {};
3142
- i.fields.forEach((ue) => {
3143
- ue.type === "date" ? E[ue.name] = (/* @__PURE__ */ new Date()).toISOString().split("T")[0] : E[ue.name] = ue.default ?? "";
3144
- }), i.childTables.forEach((ue) => {
3145
- E[ue.key] = [];
3142
+ i.fields.forEach((ce) => {
3143
+ ce.type === "date" ? E[ce.name] = (/* @__PURE__ */ new Date()).toISOString().split("T")[0] : E[ce.name] = ce.default ?? "";
3144
+ }), i.childTables.forEach((ce) => {
3145
+ E[ce.key] = [];
3146
3146
  }), E.docstatus = 0, p(E);
3147
3147
  } else d && p(d);
3148
3148
  }, [c, d, i]);
3149
- const f = de({
3149
+ const f = ue({
3150
3150
  mutationFn: (E) => B.createDocument(e, E),
3151
3151
  onSuccess: (E) => {
3152
3152
  s.invalidateQueries({ queryKey: ["documents", e] }), a(`/app/${e}/${E.name}`, { replace: !0 });
3153
3153
  }
3154
- }), g = de({
3154
+ }), g = ue({
3155
3155
  mutationFn: (E) => B.updateDocument(e, n, E),
3156
3156
  onSuccess: (E) => {
3157
3157
  s.invalidateQueries({ queryKey: ["document", e, n] }), s.invalidateQueries({ queryKey: ["documents", e] }), p(E);
3158
3158
  }
3159
- }), m = de({
3159
+ }), m = ue({
3160
3160
  mutationFn: () => B.submitDocument(e, n),
3161
3161
  onSuccess: (E) => {
3162
3162
  p(E), s.invalidateQueries({ queryKey: ["document", e, n] }), s.invalidateQueries({ queryKey: ["documents", e] });
3163
3163
  }
3164
- }), D = de({
3164
+ }), A = ue({
3165
3165
  mutationFn: () => B.cancelDocument(e, n),
3166
3166
  onSuccess: (E) => {
3167
3167
  p(E), s.invalidateQueries({ queryKey: ["document", e, n] }), s.invalidateQueries({ queryKey: ["documents", e] });
3168
3168
  }
3169
- }), T = de({
3169
+ }), T = ue({
3170
3170
  mutationFn: () => B.discardDocument(e, n),
3171
3171
  onSuccess: () => {
3172
3172
  s.invalidateQueries({ queryKey: ["documents", e] }), a(`/app/${e}`, { replace: !0 });
3173
3173
  }
3174
- }), V = de({
3174
+ }), V = ue({
3175
3175
  mutationFn: (E) => B.convertDocument(e, n, E),
3176
- onSuccess: (E, ue) => {
3177
- const Ie = ue.toLowerCase().replace(/\s+/g, "-");
3178
- a(`/app/${Ie}/${E.name}`);
3176
+ onSuccess: (E, ce) => {
3177
+ const Re = ce.toLowerCase().replace(/\s+/g, "-");
3178
+ a(`/app/${Re}/${E.name}`);
3179
3179
  }
3180
3180
  }), X = Le(
3181
- (E, ue) => {
3182
- E === "currency" && h(!0), p((Ie) => {
3183
- const Ce = { ...Ie, [E]: ue };
3184
- return E === "currency" && (Ce.conversion_rate = 0), On(Ce, i);
3181
+ (E, ce) => {
3182
+ E === "currency" && h(!0), p((Re) => {
3183
+ const Ie = { ...Re, [E]: ce };
3184
+ return E === "currency" && (Ie.conversion_rate = 0), On(Ie, i);
3185
3185
  });
3186
3186
  },
3187
3187
  [i]
3188
- ), P = Le(
3189
- (E, ue) => {
3190
- p((Ie) => {
3191
- const Ce = { ...Ie, [E]: ue };
3192
- return On(Ce, i);
3188
+ ), _ = Le(
3189
+ (E, ce) => {
3190
+ p((Re) => {
3191
+ const Ie = { ...Re, [E]: ce };
3192
+ return On(Ie, i);
3193
3193
  });
3194
3194
  },
3195
3195
  [i]
3196
3196
  ), O = () => {
3197
3197
  c ? f.mutate(l) : g.mutate(l);
3198
- }, Z = () => {
3198
+ }, J = () => {
3199
3199
  m.mutate();
3200
3200
  }, x = () => {
3201
- D.mutate();
3202
- }, W = (E) => {
3201
+ A.mutate();
3202
+ }, G = (E) => {
3203
3203
  V.mutate(E);
3204
- }, A = () => {
3204
+ }, P = () => {
3205
3205
  T.mutate();
3206
3206
  }, R = () => {
3207
3207
  i != null && i.softCancel && g.mutate({ ...l, [i.softCancel.field]: i.softCancel.value });
@@ -3213,7 +3213,7 @@ function qn() {
3213
3213
  ] });
3214
3214
  if (!c && b)
3215
3215
  return /* @__PURE__ */ t("p", { className: "text-fg-muted", children: o("common.loading") });
3216
- const q = l.docstatus ?? 0, j = !!l.discarded, oe = q >= 1 || j, me = l.currency || k, Te = Ye(l.conversion_rate ?? 1), ve = i.fields.filter((E) => !E.readOnly), Re = ve.filter((E) => E.type !== "textarea"), ge = ve.filter((E) => E.type === "textarea"), ze = i.fields.filter((E) => E.readOnly);
3216
+ const q = l.docstatus ?? 0, j = !!l.discarded, oe = q >= 1 || j, he = l.currency || k, Se = Ge(l.conversion_rate ?? 1), ve = i.fields.filter((E) => !E.readOnly), _e = ve.filter((E) => E.type !== "textarea"), ge = ve.filter((E) => E.type === "textarea"), $e = i.fields.filter((E) => E.readOnly);
3217
3217
  return /* @__PURE__ */ r("div", { className: "space-y-6", children: [
3218
3218
  /* @__PURE__ */ r("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: [
3219
3219
  /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
@@ -3223,12 +3223,12 @@ function qn() {
3223
3223
  "span",
3224
3224
  {
3225
3225
  className: "inline-flex items-center gap-1 rounded-full bg-surface-subtle px-2.5 py-0.5 text-xs font-medium text-fg-muted ring-1 ring-line",
3226
- title: Te !== 1 ? `1 ${me} = ${Te} base currency` : void 0,
3226
+ title: Se !== 1 ? `1 ${he} = ${Se} base currency` : void 0,
3227
3227
  children: [
3228
- me,
3229
- Te !== 1 && /* @__PURE__ */ r("span", { className: "text-fg-muted/70", children: [
3228
+ he,
3229
+ Se !== 1 && /* @__PURE__ */ r("span", { className: "text-fg-muted/70", children: [
3230
3230
  "@ ",
3231
- Te
3231
+ Se
3232
3232
  ] })
3233
3233
  ]
3234
3234
  }
@@ -3245,26 +3245,26 @@ function qn() {
3245
3245
  config: i,
3246
3246
  discarded: j,
3247
3247
  onSave: O,
3248
- onSubmit: Z,
3248
+ onSubmit: J,
3249
3249
  onCancel: x,
3250
- onConvert: W,
3251
- onDiscard: A,
3250
+ onConvert: G,
3251
+ onDiscard: P,
3252
3252
  onSoftCancel: R,
3253
3253
  softCancelDone: !!i.softCancel && l[i.softCancel.field] === i.softCancel.value
3254
3254
  }
3255
3255
  )
3256
3256
  ] }),
3257
- (f.error || g.error || m.error || D.error) && /* @__PURE__ */ t("div", { className: "rounded-lg bg-rose-50 p-4 text-sm text-rose-700 ring-1 ring-rose-200", children: (($e = f.error ?? g.error ?? m.error ?? D.error) == null ? void 0 : $e.message) ?? o("common.errorOccurred") }),
3257
+ (f.error || g.error || m.error || A.error) && /* @__PURE__ */ t("div", { className: "rounded-lg bg-rose-50 p-4 text-sm text-rose-700 ring-1 ring-rose-200", children: ((Ve = f.error ?? g.error ?? m.error ?? A.error) == null ? void 0 : Ve.message) ?? o("common.errorOccurred") }),
3258
3258
  /* @__PURE__ */ r($, { children: [
3259
- /* @__PURE__ */ t("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3", children: Re.map((E) => /* @__PURE__ */ t(
3259
+ /* @__PURE__ */ t("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3", children: _e.map((E) => /* @__PURE__ */ t(
3260
3260
  Ot,
3261
3261
  {
3262
3262
  field: E,
3263
3263
  value: l[E.name],
3264
- onChange: (ue) => X(E.name, ue),
3264
+ onChange: (ce) => X(E.name, ce),
3265
3265
  readOnly: oe,
3266
3266
  rowData: l,
3267
- currency: me,
3267
+ currency: he,
3268
3268
  doctype: e
3269
3269
  },
3270
3270
  E.name
@@ -3274,10 +3274,10 @@ function qn() {
3274
3274
  {
3275
3275
  field: E,
3276
3276
  value: l[E.name],
3277
- onChange: (ue) => X(E.name, ue),
3277
+ onChange: (ce) => X(E.name, ce),
3278
3278
  readOnly: oe,
3279
3279
  rowData: l,
3280
- currency: me,
3280
+ currency: he,
3281
3281
  doctype: e
3282
3282
  },
3283
3283
  E.name
@@ -3288,13 +3288,13 @@ function qn() {
3288
3288
  {
3289
3289
  tableDef: E,
3290
3290
  rows: l[E.key] ?? [],
3291
- onChange: (ue) => P(E.key, ue),
3291
+ onChange: (ce) => _(E.key, ce),
3292
3292
  readOnly: oe,
3293
- currency: me
3293
+ currency: he
3294
3294
  },
3295
3295
  E.key
3296
3296
  )),
3297
- ze.length > 0 && /* @__PURE__ */ t($, { title: o("common.totals"), children: /* @__PURE__ */ t("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-3", children: ze.map((E) => /* @__PURE__ */ t(
3297
+ $e.length > 0 && /* @__PURE__ */ t($, { title: o("common.totals"), children: /* @__PURE__ */ t("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-3", children: $e.map((E) => /* @__PURE__ */ t(
3298
3298
  Ot,
3299
3299
  {
3300
3300
  field: E,
@@ -3302,13 +3302,13 @@ function qn() {
3302
3302
  onChange: () => {
3303
3303
  },
3304
3304
  readOnly: !0,
3305
- currency: me
3305
+ currency: he
3306
3306
  },
3307
3307
  E.name
3308
3308
  )) }) })
3309
3309
  ] });
3310
3310
  }
3311
- function Se(e) {
3311
+ function ke(e) {
3312
3312
  return e.toISOString().split("T")[0];
3313
3313
  }
3314
3314
  function Ta(e) {
@@ -3343,45 +3343,45 @@ const fs = [
3343
3343
  {
3344
3344
  label: "Today",
3345
3345
  range: () => {
3346
- const e = Se(/* @__PURE__ */ new Date());
3346
+ const e = ke(/* @__PURE__ */ new Date());
3347
3347
  return [e, e];
3348
3348
  }
3349
3349
  },
3350
3350
  {
3351
3351
  label: "This Week",
3352
- range: () => [Se(Ta(/* @__PURE__ */ new Date())), Se(gs(/* @__PURE__ */ new Date()))]
3352
+ range: () => [ke(Ta(/* @__PURE__ */ new Date())), ke(gs(/* @__PURE__ */ new Date()))]
3353
3353
  },
3354
3354
  {
3355
3355
  label: "This Month",
3356
- range: () => [Se(Mn(/* @__PURE__ */ new Date())), Se(Mt(/* @__PURE__ */ new Date()))]
3356
+ range: () => [ke(Mn(/* @__PURE__ */ new Date())), ke(Mt(/* @__PURE__ */ new Date()))]
3357
3357
  },
3358
3358
  {
3359
3359
  label: "This Quarter",
3360
- range: () => [Se(ln(/* @__PURE__ */ new Date())), Se(cn(/* @__PURE__ */ new Date()))]
3360
+ range: () => [ke(ln(/* @__PURE__ */ new Date())), ke(cn(/* @__PURE__ */ new Date()))]
3361
3361
  },
3362
3362
  {
3363
3363
  label: "This Year",
3364
- range: () => [Se(Fn(/* @__PURE__ */ new Date())), Se(Ft(/* @__PURE__ */ new Date()))]
3364
+ range: () => [ke(Fn(/* @__PURE__ */ new Date())), ke(Ft(/* @__PURE__ */ new Date()))]
3365
3365
  },
3366
3366
  {
3367
3367
  label: "Last Month",
3368
3368
  range: () => {
3369
3369
  const e = /* @__PURE__ */ new Date(), n = new Date(e.getFullYear(), e.getMonth() - 1, 1);
3370
- return [Se(Mn(n)), Se(Mt(n))];
3370
+ return [ke(Mn(n)), ke(Mt(n))];
3371
3371
  }
3372
3372
  },
3373
3373
  {
3374
3374
  label: "Last Quarter",
3375
3375
  range: () => {
3376
3376
  const e = /* @__PURE__ */ new Date(), n = new Date(e.getFullYear(), e.getMonth() - 3, 1);
3377
- return [Se(ln(n)), Se(cn(n))];
3377
+ return [ke(ln(n)), ke(cn(n))];
3378
3378
  }
3379
3379
  },
3380
3380
  {
3381
3381
  label: "Last Year",
3382
3382
  range: () => {
3383
3383
  const e = new Date((/* @__PURE__ */ new Date()).getFullYear() - 1, 6, 1);
3384
- return [Se(Fn(e)), Se(Ft(e))];
3384
+ return [ke(Fn(e)), ke(Ft(e))];
3385
3385
  }
3386
3386
  }
3387
3387
  ];
@@ -3402,15 +3402,15 @@ function Kt({ onSelect: e }) {
3402
3402
  }
3403
3403
  function wn({ onSelect: e }) {
3404
3404
  return /* @__PURE__ */ t("div", { className: "flex flex-wrap gap-1.5", children: [
3405
- { label: "Today", value: () => Se(/* @__PURE__ */ new Date()) },
3406
- { label: "End of This Month", value: () => Se(Mt(/* @__PURE__ */ new Date())) },
3405
+ { label: "Today", value: () => ke(/* @__PURE__ */ new Date()) },
3406
+ { label: "End of This Month", value: () => ke(Mt(/* @__PURE__ */ new Date())) },
3407
3407
  { label: "End of Last Month", value: () => {
3408
3408
  const a = /* @__PURE__ */ new Date();
3409
- return Se(Mt(new Date(a.getFullYear(), a.getMonth() - 1, 1)));
3409
+ return ke(Mt(new Date(a.getFullYear(), a.getMonth() - 1, 1)));
3410
3410
  } },
3411
- { label: "End of This Quarter", value: () => Se(cn(/* @__PURE__ */ new Date())) },
3412
- { label: "End of This Year", value: () => Se(Ft(/* @__PURE__ */ new Date())) },
3413
- { label: "End of Last Year", value: () => Se(Ft(new Date((/* @__PURE__ */ new Date()).getFullYear() - 1, 0, 1))) }
3411
+ { label: "End of This Quarter", value: () => ke(cn(/* @__PURE__ */ new Date())) },
3412
+ { label: "End of This Year", value: () => ke(Ft(/* @__PURE__ */ new Date())) },
3413
+ { label: "End of Last Year", value: () => ke(Ft(new Date((/* @__PURE__ */ new Date()).getFullYear() - 1, 0, 1))) }
3414
3414
  ].map((a) => /* @__PURE__ */ t(
3415
3415
  "button",
3416
3416
  {
@@ -3540,155 +3540,155 @@ function $n({
3540
3540
  ] });
3541
3541
  }
3542
3542
  function ks() {
3543
- const { t: e } = ne(), n = Ke(), { doctype: a } = yt(), s = Pa(a ?? ""), o = Nt();
3544
- _e((s == null ? void 0 : s.label) ?? a ?? null);
3543
+ const { t: e } = ne(), n = Ke(), { doctype: a } = ft(), s = Pa(a ?? ""), o = Nt();
3544
+ Pe((s == null ? void 0 : s.label) ?? a ?? null);
3545
3545
  const i = (s == null ? void 0 : s.listFilters) ?? [], c = be(() => {
3546
- const _ = new URLSearchParams(o.search), M = {};
3547
- for (const G of i) M[G] = _.get(G) ?? "";
3546
+ const S = new URLSearchParams(o.search), M = {};
3547
+ for (const Z of i) M[Z] = S.get(Z) ?? "";
3548
3548
  return M;
3549
- }, [o.search, i]), [l] = le("status", "All"), [p] = le("from", ""), [u] = le("to", ""), [h] = le("discarded", ""), [d] = le("per_page", 50), b = (s == null ? void 0 : s.searchFields) ?? [], [v] = le("q", ""), [N, y] = w(v), [k] = le("page", 1), S = k - 1, f = rt(), { settings: g, setSetting: m } = vn(), [D] = le("order_by", ""), [T] = le("order", ""), [V, X] = (g[`sort.${a}`] || "").split(":"), P = D || V || "", O = (D ? T : X) || "desc", Z = (_) => {
3550
- const M = P === _ ? O === "desc" ? "asc" : "desc" : xs(_) ? "desc" : "asc";
3551
- f({ order_by: _, order: M, page: null }), m(`sort.${a}`, `${_}:${M}`);
3552
- }, [x, W] = w(!1), A = ie(null), R = be(
3553
- () => (g[`columns.${a}`] || "").split(",").map((_) => _.trim()).filter(Boolean),
3549
+ }, [o.search, i]), [l] = le("status", "All"), [p] = le("from", ""), [u] = le("to", ""), [h] = le("discarded", ""), [d] = le("per_page", 50), b = (s == null ? void 0 : s.searchFields) ?? [], [v] = le("q", ""), [N, y] = w(v), [k] = le("page", 1), D = k - 1, f = rt(), { settings: g, setSetting: m } = vn(), [A] = le("order_by", ""), [T] = le("order", ""), [V, X] = (g[`sort.${a}`] || "").split(":"), _ = A || V || "", O = (A ? T : X) || "desc", J = (S) => {
3550
+ const M = _ === S ? O === "desc" ? "asc" : "desc" : xs(S) ? "desc" : "asc";
3551
+ f({ order_by: S, order: M, page: null }), m(`sort.${a}`, `${S}:${M}`);
3552
+ }, [x, G] = w(!1), P = ie(null), R = be(
3553
+ () => (g[`columns.${a}`] || "").split(",").map((S) => S.trim()).filter(Boolean),
3554
3554
  [g, a]
3555
- ), q = R.length ? R : (s == null ? void 0 : s.listColumns) ?? [], j = be(() => {
3555
+ ), q = R.length ? R : (s == null ? void 0 : s.listColumns) ?? [], j = q.length ? [...q, "currency", "party_type"].join(",") : void 0, oe = be(() => {
3556
3556
  if (!s) return [];
3557
- const _ = /* @__PURE__ */ new Set(), M = [], G = (H, xe) => {
3558
- _.has(H) || (_.add(H), M.push({ name: H, label: xe }));
3557
+ const S = /* @__PURE__ */ new Set(), M = [], Z = (Y, me) => {
3558
+ S.has(Y) || (S.add(Y), M.push({ name: Y, label: me }));
3559
3559
  };
3560
- G("name", e("fields.Name", { defaultValue: "Name" }));
3561
- for (const H of s.fields) G(H.name, e(`fields.${H.label}`, { defaultValue: H.label }));
3562
- for (const H of dn) G(H.name, e(`fields.${H.label}`, { defaultValue: H.label }));
3560
+ Z("name", e("fields.Name", { defaultValue: "Name" }));
3561
+ for (const Y of s.fields) Z(Y.name, e(`fields.${Y.label}`, { defaultValue: Y.label }));
3562
+ for (const Y of dn) Z(Y.name, e(`fields.${Y.label}`, { defaultValue: Y.label }));
3563
3563
  return M;
3564
- }, [s, e]), oe = (_) => {
3565
- const M = q.includes(_) ? q.filter((G) => G !== _) : [...q, _];
3564
+ }, [s, e]), he = (S) => {
3565
+ const M = q.includes(S) ? q.filter((Z) => Z !== S) : [...q, S];
3566
3566
  M.length !== 0 && m(`columns.${a}`, M.join(","));
3567
3567
  };
3568
3568
  ae(() => {
3569
3569
  if (!x) return;
3570
- const _ = (M) => {
3571
- A.current && !A.current.contains(M.target) && W(!1);
3570
+ const S = (M) => {
3571
+ P.current && !P.current.contains(M.target) && G(!1);
3572
3572
  };
3573
- return document.addEventListener("mousedown", _), () => document.removeEventListener("mousedown", _);
3573
+ return document.addEventListener("mousedown", S), () => document.removeEventListener("mousedown", S);
3574
3574
  }, [x]);
3575
- const me = (_) => f({ page: _ === 0 ? null : _ + 1 }), Te = (_) => f({ status: _ === "All" ? null : _, page: null }), ve = (_) => f({ from: _ || null, page: null }), Re = (_) => f({ to: _ || null, page: null }), ge = (_) => f({ discarded: _ ? "1" : null, page: null }), ze = (_) => f({ per_page: _, page: null });
3575
+ const Se = (S) => f({ page: S === 0 ? null : S + 1 }), ve = (S) => f({ status: S === "All" ? null : S, page: null }), _e = (S) => f({ from: S || null, page: null }), ge = (S) => f({ to: S || null, page: null }), $e = (S) => f({ discarded: S ? "1" : null, page: null }), Ve = (S) => f({ per_page: S, page: null });
3576
3576
  ae(() => {
3577
3577
  y(v);
3578
3578
  }, [v]), ae(() => {
3579
3579
  if (N === v) return;
3580
- const _ = setTimeout(() => f({ q: N || null, page: null }), 300);
3581
- return () => clearTimeout(_);
3580
+ const S = setTimeout(() => f({ q: N || null, page: null }), 300);
3581
+ return () => clearTimeout(S);
3582
3582
  }, [N, v]);
3583
- const $e = be(() => {
3584
- const _ = {};
3585
- i.length === 0 && l !== "All" && (_.status = l), p && (_.from_date = p), u && (_.to_date = u), s != null && s.dateField && (_.date_field = s.dateField);
3583
+ const E = be(() => {
3584
+ const S = {};
3585
+ i.length === 0 && l !== "All" && (S.status = l), p && (S.from_date = p), u && (S.to_date = u), s != null && s.dateField && (S.date_field = s.dateField);
3586
3586
  for (const M of i)
3587
- c[M] && (_[M] = c[M]);
3588
- return b.length > 0 && v && (_.search = v, _.search_fields = b.join(",")), h && (_.include_discarded = "true"), P && (_.order_by = P, _.order = O), _.limit = d, _.offset = S * d, _;
3589
- }, [l, p, u, h, d, S, s == null ? void 0 : s.dateField, i, c, b, v, P, O]), { data: E, isLoading: ue } = ss(a ?? "", $e), Ie = (E == null ? void 0 : E.rows) ?? [], Ce = (E == null ? void 0 : E.total) ?? 0;
3587
+ c[M] && (S[M] = c[M]);
3588
+ return b.length > 0 && v && (S.search = v, S.search_fields = b.join(",")), h && (S.include_discarded = "true"), _ && (S.order_by = _, S.order = O), j && (S.fields = j), S.limit = d, S.offset = D * d, S;
3589
+ }, [l, p, u, h, d, D, s == null ? void 0 : s.dateField, i, c, b, v, _, O, j]), { data: ce, isLoading: Re } = ss(a ?? "", E), Ie = (ce == null ? void 0 : ce.rows) ?? [], Me = (ce == null ? void 0 : ce.total) ?? 0;
3590
3590
  ae(() => {
3591
- const { limit: _, offset: M, ...G } = $e;
3592
- Aa(a ?? "", { filters: G, search: o.search });
3593
- }, [a, $e, o.search]);
3594
- const Ve = Math.max(1, Math.ceil(Ce / d)), Ge = Ce === 0 ? 0 : S * d + 1, st = Math.min(Ce, (S + 1) * d), it = be(() => {
3591
+ const { limit: S, offset: M, ...Z } = E;
3592
+ Aa(a ?? "", { filters: Z, search: o.search });
3593
+ }, [a, E, o.search]);
3594
+ const We = Math.max(1, Math.ceil(Me / d)), st = Me === 0 ? 0 : D * d + 1, et = Math.min(Me, (D + 1) * d), Je = be(() => {
3595
3595
  if (!s) return [];
3596
- const _ = da(), M = (G) => {
3597
- const H = dn.find((he) => he.name === G);
3598
- if (H) return e(`fields.${H.label}`, { defaultValue: H.label });
3599
- const xe = G.split("_").map((he) => he.charAt(0).toUpperCase() + he.slice(1)).join(" ");
3600
- return e(`fields.${xe}`, { defaultValue: xe });
3596
+ const S = da(), M = (Z) => {
3597
+ const Y = dn.find((Te) => Te.name === Z);
3598
+ if (Y) return e(`fields.${Y.label}`, { defaultValue: Y.label });
3599
+ const me = Z.split("_").map((Te) => Te.charAt(0).toUpperCase() + Te.slice(1)).join(" ");
3600
+ return e(`fields.${me}`, { defaultValue: me });
3601
3601
  };
3602
- return q.map((G) => {
3603
- if (G === "name")
3604
- return _.accessor("name", {
3602
+ return q.map((Z) => {
3603
+ if (Z === "name")
3604
+ return S.accessor("name", {
3605
3605
  header: e("fields.Name", { defaultValue: "Name" }),
3606
- cell: (H) => /* @__PURE__ */ t(
3607
- De,
3606
+ cell: (Y) => /* @__PURE__ */ t(
3607
+ Ce,
3608
3608
  {
3609
- to: `/app/${s.slug}/${H.getValue()}`,
3609
+ to: `/app/${s.slug}/${Y.getValue()}`,
3610
3610
  className: "font-medium text-brand transition-colors hover:text-brand/80",
3611
- children: H.getValue()
3611
+ children: Y.getValue()
3612
3612
  }
3613
3613
  )
3614
3614
  });
3615
- if (G === "status")
3616
- return _.accessor("status", {
3615
+ if (Z === "status")
3616
+ return S.accessor("status", {
3617
3617
  header: e("fields.Status", { defaultValue: "Status" }),
3618
- cell: (H) => /* @__PURE__ */ t(xn, { status: H.getValue() })
3618
+ cell: (Y) => /* @__PURE__ */ t(xn, { status: Y.getValue() })
3619
3619
  });
3620
- if (bs.has(G))
3621
- return _.accessor(G, {
3622
- header: M(G),
3623
- cell: (H) => {
3624
- var xe;
3625
- return Ue(H.getValue(), ((xe = H.row.original) == null ? void 0 : xe.currency) || n);
3620
+ if (bs.has(Z))
3621
+ return S.accessor(Z, {
3622
+ header: M(Z),
3623
+ cell: (Y) => {
3624
+ var me;
3625
+ return Ue(Y.getValue(), ((me = Y.row.original) == null ? void 0 : me.currency) || n);
3626
3626
  }
3627
3627
  });
3628
- if (G === "party")
3629
- return _.accessor("party", {
3628
+ if (Z === "party")
3629
+ return S.accessor("party", {
3630
3630
  header: e("fields.Party", { defaultValue: "Party" }),
3631
- cell: (H) => {
3632
- const xe = H.getValue();
3633
- if (!xe) return "-";
3634
- const he = Ns(H.row.original.party_type), je = he ? on(he, String(xe)) : null;
3635
- return je ? /* @__PURE__ */ t(
3636
- De,
3631
+ cell: (Y) => {
3632
+ const me = Y.getValue();
3633
+ if (!me) return "-";
3634
+ const Te = Ns(Y.row.original.party_type), I = Te ? on(Te, String(me)) : null;
3635
+ return I ? /* @__PURE__ */ t(
3636
+ Ce,
3637
3637
  {
3638
- to: je,
3639
- onClick: (I) => I.stopPropagation(),
3638
+ to: I,
3639
+ onClick: (W) => W.stopPropagation(),
3640
3640
  className: "text-brand transition-colors hover:text-brand/80 hover:underline",
3641
- children: xe
3641
+ children: me
3642
3642
  }
3643
- ) : String(xe);
3643
+ ) : String(me);
3644
3644
  }
3645
3645
  });
3646
- if (zn[G]) {
3647
- const H = zn[G];
3648
- return _.accessor(G, {
3649
- header: M(G),
3650
- cell: (xe) => {
3651
- const he = xe.getValue();
3652
- if (!he) return "-";
3653
- const je = on(H, String(he));
3654
- return je ? /* @__PURE__ */ t(
3655
- De,
3646
+ if (zn[Z]) {
3647
+ const Y = zn[Z];
3648
+ return S.accessor(Z, {
3649
+ header: M(Z),
3650
+ cell: (me) => {
3651
+ const Te = me.getValue();
3652
+ if (!Te) return "-";
3653
+ const I = on(Y, String(Te));
3654
+ return I ? /* @__PURE__ */ t(
3655
+ Ce,
3656
3656
  {
3657
- to: je,
3658
- onClick: (I) => I.stopPropagation(),
3657
+ to: I,
3658
+ onClick: (W) => W.stopPropagation(),
3659
3659
  className: "text-brand transition-colors hover:text-brand/80 hover:underline",
3660
- children: he
3660
+ children: Te
3661
3661
  }
3662
- ) : String(he);
3662
+ ) : String(Te);
3663
3663
  }
3664
3664
  });
3665
3665
  }
3666
- return G.endsWith("_datetime") ? _.accessor(G, {
3667
- header: M(G),
3668
- cell: (H) => qr(H.getValue())
3669
- }) : Ra.has(G) || vs.has(G) ? _.accessor(G, {
3670
- header: M(G),
3671
- cell: (H) => Ut(H.getValue())
3672
- }) : _.accessor(G, {
3673
- header: M(G)
3666
+ return Z.endsWith("_datetime") ? S.accessor(Z, {
3667
+ header: M(Z),
3668
+ cell: (Y) => qr(Y.getValue())
3669
+ }) : Ra.has(Z) || vs.has(Z) ? S.accessor(Z, {
3670
+ header: M(Z),
3671
+ cell: (Y) => Ut(Y.getValue())
3672
+ }) : S.accessor(Z, {
3673
+ header: M(Z)
3674
3674
  });
3675
3675
  });
3676
- }, [s, e, n, q]), He = ua({
3676
+ }, [s, e, n, q]), bt = ua({
3677
3677
  data: Ie,
3678
- columns: it,
3678
+ columns: Je,
3679
3679
  getCoreRowModel: ma()
3680
3680
  });
3681
3681
  return s ? /* @__PURE__ */ r("div", { className: "space-y-4", children: [
3682
3682
  /* @__PURE__ */ r("div", { className: "flex items-center justify-end gap-2", children: [
3683
- /* @__PURE__ */ r("div", { className: "relative", ref: A, children: [
3684
- /* @__PURE__ */ t(K, { variant: "secondary", onClick: () => W((_) => !_), children: /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1.5", children: [
3683
+ /* @__PURE__ */ r("div", { className: "relative", ref: P, children: [
3684
+ /* @__PURE__ */ t(K, { variant: "secondary", onClick: () => G((S) => !S), children: /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1.5", children: [
3685
3685
  /* @__PURE__ */ t(xr, { className: "h-4 w-4" }),
3686
3686
  e("common.columns", { defaultValue: "Columns" })
3687
3687
  ] }) }),
3688
3688
  x && /* @__PURE__ */ r("div", { className: "absolute right-0 z-20 mt-2 max-h-80 w-60 overflow-y-auto rounded-lg border border-line bg-surface p-2 shadow-card", children: [
3689
3689
  /* @__PURE__ */ t("div", { className: "px-2 py-1 text-xs font-medium uppercase tracking-wide text-fg-muted", children: e("common.columns", { defaultValue: "Columns" }) }),
3690
- j.map((_) => {
3691
- const M = q.includes(_.name), G = M && q.length === 1;
3690
+ oe.map((S) => {
3691
+ const M = q.includes(S.name), Z = M && q.length === 1;
3692
3692
  return /* @__PURE__ */ r(
3693
3693
  "label",
3694
3694
  {
@@ -3700,19 +3700,19 @@ function ks() {
3700
3700
  type: "checkbox",
3701
3701
  className: "h-4 w-4 rounded border-line text-brand focus:ring-brand/30 disabled:opacity-50",
3702
3702
  checked: M,
3703
- disabled: G,
3704
- onChange: () => oe(_.name)
3703
+ disabled: Z,
3704
+ onChange: () => he(S.name)
3705
3705
  }
3706
3706
  ),
3707
- _.label
3707
+ S.label
3708
3708
  ]
3709
3709
  },
3710
- _.name
3710
+ S.name
3711
3711
  );
3712
3712
  })
3713
3713
  ] })
3714
3714
  ] }),
3715
- /* @__PURE__ */ t(De, { to: `/app/${s.slug}/new`, children: /* @__PURE__ */ t(K, { children: e("common.new") }) })
3715
+ /* @__PURE__ */ t(Ce, { to: `/app/${s.slug}/new`, children: /* @__PURE__ */ t(K, { children: e("common.new") }) })
3716
3716
  ] }),
3717
3717
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
3718
3718
  b.length > 0 && /* @__PURE__ */ t(
@@ -3722,34 +3722,34 @@ function ks() {
3722
3722
  type: "search",
3723
3723
  placeholder: e("common.searchPlaceholder", { defaultValue: "Search…" }),
3724
3724
  value: N,
3725
- onChange: (_) => y(_.target.value),
3725
+ onChange: (S) => y(S.target.value),
3726
3726
  className: "min-w-[16rem]"
3727
3727
  }
3728
3728
  ),
3729
3729
  i.length === 0 ? /* @__PURE__ */ t(
3730
- Je,
3730
+ Ye,
3731
3731
  {
3732
3732
  label: e("fields.Status", { defaultValue: "Status" }),
3733
- options: ys.map((_) => ({
3734
- value: _,
3735
- label: _ === "All" ? e("common.all") : e(`status.${_}`, { defaultValue: _ })
3733
+ options: ys.map((S) => ({
3734
+ value: S,
3735
+ label: S === "All" ? e("common.all") : e(`status.${S}`, { defaultValue: S })
3736
3736
  })),
3737
3737
  value: l,
3738
- onChange: (_) => Te(_.target.value)
3738
+ onChange: (S) => ve(S.target.value)
3739
3739
  }
3740
- ) : i.map((_) => {
3741
- const M = s.fields.find((H) => H.name === _), G = ((M == null ? void 0 : M.options) ?? []).map(
3742
- (H) => typeof H == "string" ? { value: H, label: H } : H
3740
+ ) : i.map((S) => {
3741
+ const M = s.fields.find((Y) => Y.name === S), Z = ((M == null ? void 0 : M.options) ?? []).map(
3742
+ (Y) => typeof Y == "string" ? { value: Y, label: Y } : Y
3743
3743
  );
3744
3744
  return /* @__PURE__ */ t(
3745
- Je,
3745
+ Ye,
3746
3746
  {
3747
- label: e(`fields.${(M == null ? void 0 : M.label) ?? _}`, { defaultValue: (M == null ? void 0 : M.label) ?? _ }),
3748
- options: [{ value: "", label: e("common.all") }, ...G],
3749
- value: c[_],
3750
- onChange: (H) => f({ [_]: H.target.value || null, page: null })
3747
+ label: e(`fields.${(M == null ? void 0 : M.label) ?? S}`, { defaultValue: (M == null ? void 0 : M.label) ?? S }),
3748
+ options: [{ value: "", label: e("common.all") }, ...Z],
3749
+ value: c[S],
3750
+ onChange: (Y) => f({ [S]: Y.target.value || null, page: null })
3751
3751
  },
3752
- _
3752
+ S
3753
3753
  );
3754
3754
  }),
3755
3755
  /* @__PURE__ */ t(
@@ -3758,7 +3758,7 @@ function ks() {
3758
3758
  label: e("fields.From Date", { defaultValue: "From Date" }),
3759
3759
  type: "date",
3760
3760
  value: p,
3761
- onChange: (_) => ve(_.target.value)
3761
+ onChange: (S) => _e(S.target.value)
3762
3762
  }
3763
3763
  ),
3764
3764
  /* @__PURE__ */ t(
@@ -3767,7 +3767,7 @@ function ks() {
3767
3767
  label: e("fields.To Date", { defaultValue: "To Date" }),
3768
3768
  type: "date",
3769
3769
  value: u,
3770
- onChange: (_) => Re(_.target.value)
3770
+ onChange: (S) => ge(S.target.value)
3771
3771
  }
3772
3772
  ),
3773
3773
  /* @__PURE__ */ r("label", { className: "flex h-10 items-center gap-2 text-sm text-fg-muted", children: [
@@ -3777,29 +3777,29 @@ function ks() {
3777
3777
  type: "checkbox",
3778
3778
  className: "h-4 w-4 rounded border-line text-brand focus:ring-brand/30",
3779
3779
  checked: !!h,
3780
- onChange: (_) => ge(_.target.checked)
3780
+ onChange: (S) => $e(S.target.checked)
3781
3781
  }
3782
3782
  ),
3783
3783
  e("common.showDiscarded")
3784
3784
  ] })
3785
3785
  ] }),
3786
- /* @__PURE__ */ t(Kt, { onSelect: (_, M) => f({ from: _, to: M, page: null }) }),
3787
- ue ? /* @__PURE__ */ t("p", { className: "text-fg-muted", children: e("common.loading") }) : Ie.length === 0 ? /* @__PURE__ */ t("p", { className: "py-8 text-center text-fg-muted", children: e("reports.noDocuments") }) : /* @__PURE__ */ r(Pe, { children: [
3786
+ /* @__PURE__ */ t(Kt, { onSelect: (S, M) => f({ from: S, to: M, page: null }) }),
3787
+ Re ? /* @__PURE__ */ t("p", { className: "text-fg-muted", children: e("common.loading") }) : Ie.length === 0 ? /* @__PURE__ */ t("p", { className: "py-8 text-center text-fg-muted", children: e("reports.noDocuments") }) : /* @__PURE__ */ r(Ae, { children: [
3788
3788
  /* @__PURE__ */ t(
3789
3789
  $n,
3790
3790
  {
3791
- page: S,
3792
- totalPages: Ve,
3791
+ page: D,
3792
+ totalPages: We,
3793
3793
  pageSize: d,
3794
- total: Ce,
3795
- rangeStart: Ge,
3796
- rangeEnd: st,
3797
- setPage: me,
3798
- setPageSize: ze
3794
+ total: Me,
3795
+ rangeStart: st,
3796
+ rangeEnd: et,
3797
+ setPage: Se,
3798
+ setPageSize: Ve
3799
3799
  }
3800
3800
  ),
3801
3801
  /* @__PURE__ */ t("div", { className: "overflow-x-auto rounded-xl bg-surface ring-1 ring-line shadow-card", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-line text-sm", children: [
3802
- /* @__PURE__ */ t("thead", { className: "bg-surface-subtle", children: He.getHeaderGroups().map((_) => /* @__PURE__ */ t("tr", { children: _.headers.map((M) => /* @__PURE__ */ t(
3802
+ /* @__PURE__ */ t("thead", { className: "bg-surface-subtle", children: bt.getHeaderGroups().map((S) => /* @__PURE__ */ t("tr", { children: S.headers.map((M) => /* @__PURE__ */ t(
3803
3803
  "th",
3804
3804
  {
3805
3805
  className: "px-4 py-3 text-left text-xs font-medium uppercase tracking-wide text-fg-muted",
@@ -3807,34 +3807,34 @@ function ks() {
3807
3807
  "button",
3808
3808
  {
3809
3809
  type: "button",
3810
- onClick: () => Z(M.column.id),
3810
+ onClick: () => J(M.column.id),
3811
3811
  title: e("common.sortByColumn", { defaultValue: "Sort by this column" }),
3812
3812
  className: "group inline-flex items-center gap-1 uppercase tracking-wide transition-colors hover:text-fg",
3813
3813
  children: [
3814
3814
  qt(M.column.columnDef.header, M.getContext()),
3815
- P === M.column.id ? O === "asc" ? /* @__PURE__ */ t(Nr, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(At, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(wr, { className: "h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-40" })
3815
+ _ === M.column.id ? O === "asc" ? /* @__PURE__ */ t(Nr, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(At, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(wr, { className: "h-3.5 w-3.5 opacity-0 transition-opacity group-hover:opacity-40" })
3816
3816
  ]
3817
3817
  }
3818
3818
  )
3819
3819
  },
3820
3820
  M.id
3821
- )) }, _.id)) }),
3822
- /* @__PURE__ */ t("tbody", { className: "divide-y divide-line", children: He.getRowModel().rows.map((_) => /* @__PURE__ */ t("tr", { className: "transition-colors hover:bg-surface-subtle", children: _.getVisibleCells().map((M) => /* @__PURE__ */ t("td", { className: "px-4 py-2.5 text-fg", children: qt(
3821
+ )) }, S.id)) }),
3822
+ /* @__PURE__ */ t("tbody", { className: "divide-y divide-line", children: bt.getRowModel().rows.map((S) => /* @__PURE__ */ t("tr", { className: "transition-colors hover:bg-surface-subtle", children: S.getVisibleCells().map((M) => /* @__PURE__ */ t("td", { className: "px-4 py-2.5 text-fg", children: qt(
3823
3823
  M.column.columnDef.cell,
3824
3824
  M.getContext()
3825
- ) }, M.id)) }, _.id)) })
3825
+ ) }, M.id)) }, S.id)) })
3826
3826
  ] }) }),
3827
3827
  /* @__PURE__ */ t(
3828
3828
  $n,
3829
3829
  {
3830
- page: S,
3831
- totalPages: Ve,
3830
+ page: D,
3831
+ totalPages: We,
3832
3832
  pageSize: d,
3833
- total: Ce,
3834
- rangeStart: Ge,
3835
- rangeEnd: st,
3836
- setPage: me,
3837
- setPageSize: ze
3833
+ total: Me,
3834
+ rangeStart: st,
3835
+ rangeEnd: et,
3836
+ setPage: Se,
3837
+ setPageSize: Ve
3838
3838
  }
3839
3839
  )
3840
3840
  ] })
@@ -3843,34 +3843,34 @@ function ks() {
3843
3843
  a
3844
3844
  ] });
3845
3845
  }
3846
- function Ae({
3846
+ function De({
3847
3847
  label: e,
3848
3848
  value: n,
3849
3849
  onChange: a,
3850
3850
  linkDoctype: s,
3851
3851
  readOnly: o
3852
3852
  }) {
3853
- const [i, c] = w(n ?? ""), [l, p] = w([]), [u, h] = w(!1), [d, b] = w(!1), [v, N] = w({}), y = ie(null), k = ie(null), S = ie(null), f = ie(null), g = ie(!1);
3853
+ const [i, c] = w(n ?? ""), [l, p] = w([]), [u, h] = w(!1), [d, b] = w(!1), [v, N] = w({}), y = ie(null), k = ie(null), D = ie(null), f = ie(null), g = ie(!1);
3854
3854
  ae(() => {
3855
3855
  c(n ?? "");
3856
3856
  }, [n]);
3857
3857
  const m = Le(() => {
3858
3858
  if (f.current) {
3859
- const P = f.current.getBoundingClientRect();
3859
+ const _ = f.current.getBoundingClientRect();
3860
3860
  N({
3861
3861
  position: "fixed",
3862
- top: P.bottom + 4,
3863
- left: P.left,
3864
- width: P.width,
3862
+ top: _.bottom + 4,
3863
+ left: _.left,
3864
+ width: _.width,
3865
3865
  zIndex: 9999
3866
3866
  });
3867
3867
  }
3868
- }, []), D = Le(
3869
- (P) => {
3868
+ }, []), A = Le(
3869
+ (_) => {
3870
3870
  y.current && clearTimeout(y.current), y.current = setTimeout(async () => {
3871
3871
  b(!0);
3872
3872
  try {
3873
- const O = await B.searchLink(s, P);
3873
+ const O = await B.searchLink(s, _);
3874
3874
  p(O), h(!0);
3875
3875
  } catch {
3876
3876
  p([]);
@@ -3880,11 +3880,11 @@ function Ae({
3880
3880
  }, 300);
3881
3881
  },
3882
3882
  [s]
3883
- ), T = (P) => {
3884
- const O = P.target.value;
3885
- c(O), D(O);
3886
- }, V = (P) => {
3887
- const O = P.name ?? P.id ?? String(P);
3883
+ ), T = (_) => {
3884
+ const O = _.target.value;
3885
+ c(O), A(O);
3886
+ }, V = (_) => {
3887
+ const O = _.name ?? _.id ?? String(_);
3888
3888
  c(O), a(O), h(!1), p([]);
3889
3889
  }, X = () => {
3890
3890
  setTimeout(() => {
@@ -3896,12 +3896,12 @@ function Ae({
3896
3896
  }, 150);
3897
3897
  };
3898
3898
  return ae(() => {
3899
- const P = (O) => {
3900
- var x, W;
3901
- const Z = O.target;
3902
- (x = k.current) != null && x.contains(Z) || (W = S.current) != null && W.contains(Z) || h(!1);
3899
+ const _ = (O) => {
3900
+ var x, G;
3901
+ const J = O.target;
3902
+ (x = k.current) != null && x.contains(J) || (G = D.current) != null && G.contains(J) || h(!1);
3903
3903
  };
3904
- return document.addEventListener("mousedown", P), () => document.removeEventListener("mousedown", P);
3904
+ return document.addEventListener("mousedown", _), () => document.removeEventListener("mousedown", _);
3905
3905
  }, []), o ? /* @__PURE__ */ r("div", { children: [
3906
3906
  e && /* @__PURE__ */ t("span", { className: "mb-1.5 block text-sm font-medium text-fg", children: e }),
3907
3907
  /* @__PURE__ */ t("span", { className: "text-sm text-fg", children: n || "—" })
@@ -3915,7 +3915,7 @@ function Ae({
3915
3915
  value: i,
3916
3916
  onChange: T,
3917
3917
  onFocus: () => {
3918
- m(), D(i);
3918
+ m(), A(i);
3919
3919
  },
3920
3920
  onBlur: X,
3921
3921
  placeholder: `Search ${s}...`,
@@ -3926,8 +3926,8 @@ function Ae({
3926
3926
  }
3927
3927
  ),
3928
3928
  u && l.length > 0 && pa(
3929
- /* @__PURE__ */ t("div", { ref: S, style: v, className: "max-h-48 overflow-y-auto rounded-lg bg-surface ring-1 ring-line shadow-card-hover", children: l.map((P, O) => {
3930
- const Z = P.name ?? P.id ?? String(P);
3929
+ /* @__PURE__ */ t("div", { ref: D, style: v, className: "max-h-48 overflow-y-auto rounded-lg bg-surface ring-1 ring-line shadow-card-hover", children: l.map((_, O) => {
3930
+ const J = _.name ?? _.id ?? String(_);
3931
3931
  return /* @__PURE__ */ t(
3932
3932
  "button",
3933
3933
  {
@@ -3935,9 +3935,9 @@ function Ae({
3935
3935
  onMouseDown: () => {
3936
3936
  g.current = !0;
3937
3937
  },
3938
- onClick: () => V(P),
3938
+ onClick: () => V(_),
3939
3939
  className: "block w-full px-3 py-1.5 text-left text-sm text-fg transition-colors hover:bg-surface-subtle",
3940
- children: Z
3940
+ children: J
3941
3941
  },
3942
3942
  O
3943
3943
  );
@@ -3953,9 +3953,9 @@ const Bt = () => ({
3953
3953
  is_recommended: 0
3954
3954
  }), Cs = "ABCDEFGHIJKLMNOPQRSTUVWXYZ";
3955
3955
  function Vn() {
3956
- const { name: e } = yt(), n = !e, a = Me(), s = Ze(), { t: o } = ne();
3957
- _e(o("titles.proposal"));
3958
- const i = (A, R) => o(A, { defaultValue: R }), c = wa(), [l, p] = w({
3956
+ const { name: e } = ft(), n = !e, a = Fe(), s = Qe(), { t: o } = ne();
3957
+ Pe(o("titles.proposal"));
3958
+ const i = (P, R) => o(P, { defaultValue: R }), c = wa(), [l, p] = w({
3959
3959
  title: "Offerte",
3960
3960
  customer: "",
3961
3961
  company: "",
@@ -3963,7 +3963,7 @@ function Vn() {
3963
3963
  partner_name: "",
3964
3964
  partner_email: "",
3965
3965
  cover_letter: ""
3966
- }), [u, h] = w([Bt()]), [d, b] = w(null), [v, N] = w(!1), [y, k] = w(null), S = ie(null), f = (A, R) => p((q) => ({ ...q, [A]: R })), { data: g } = ce({
3966
+ }), [u, h] = w([Bt()]), [d, b] = w(null), [v, N] = w(!1), [y, k] = w(null), D = ie(null), f = (P, R) => p((q) => ({ ...q, [P]: R })), { data: g } = de({
3967
3967
  queryKey: ["document", "proposal", e],
3968
3968
  queryFn: () => B.getDocument("proposal", e),
3969
3969
  enabled: !n
@@ -3979,43 +3979,43 @@ function Vn() {
3979
3979
  partner_email: g.partner_email ?? "",
3980
3980
  cover_letter: g.cover_letter ?? ""
3981
3981
  });
3982
- const A = g.quotations ?? [];
3983
- h(A.length ? A.map((R) => ({ ...Bt(), ...R })) : [Bt()]), b(g.appendix_filename ?? null);
3982
+ const P = g.quotations ?? [];
3983
+ h(P.length ? P.map((R) => ({ ...Bt(), ...R })) : [Bt()]), b(g.appendix_filename ?? null);
3984
3984
  }, [g]);
3985
3985
  const m = async () => {
3986
3986
  try {
3987
- const { cover_letter: A } = await B.getProposalCoverDefault(l.company, l.customer);
3988
- A && f("cover_letter", A);
3987
+ const { cover_letter: P } = await B.getProposalCoverDefault(l.company, l.customer);
3988
+ P && f("cover_letter", P);
3989
3989
  } catch {
3990
3990
  }
3991
3991
  };
3992
3992
  ae(() => {
3993
3993
  n && l.customer && !l.cover_letter && m();
3994
3994
  }, [l.customer, l.company]);
3995
- const D = () => ({
3995
+ const A = () => ({
3996
3996
  ...l,
3997
- quotations: u.filter((A) => A.quotation).map((A, R) => ({ ...A, idx: R + 1, is_recommended: A.is_recommended ? 1 : 0 }))
3998
- }), T = de({
3999
- mutationFn: async () => n ? B.createDocument("proposal", D()) : B.updateDocument("proposal", e, D()),
4000
- onSuccess: (A) => {
4001
- k(null), s.invalidateQueries({ queryKey: ["documents", "proposal"] }), s.invalidateQueries({ queryKey: ["document", "proposal", A.name] }), n && a(`/app/proposal/${encodeURIComponent(A.name)}`);
3997
+ quotations: u.filter((P) => P.quotation).map((P, R) => ({ ...P, idx: R + 1, is_recommended: P.is_recommended ? 1 : 0 }))
3998
+ }), T = ue({
3999
+ mutationFn: async () => n ? B.createDocument("proposal", A()) : B.updateDocument("proposal", e, A()),
4000
+ onSuccess: (P) => {
4001
+ k(null), s.invalidateQueries({ queryKey: ["documents", "proposal"] }), s.invalidateQueries({ queryKey: ["document", "proposal", P.name] }), n && a(`/app/proposal/${encodeURIComponent(P.name)}`);
4002
4002
  },
4003
- onError: (A) => k((A == null ? void 0 : A.message) ?? "Save failed")
4004
- }), V = de({
4003
+ onError: (P) => k((P == null ? void 0 : P.message) ?? "Save failed")
4004
+ }), V = ue({
4005
4005
  mutationFn: () => B.discardDocument("proposal", e),
4006
4006
  onSuccess: () => {
4007
4007
  s.invalidateQueries({ queryKey: ["documents", "proposal"] }), a("/app/proposal");
4008
4008
  },
4009
- onError: (A) => k((A == null ? void 0 : A.message) ?? "Discard failed")
4010
- }), X = (A, R) => h((q) => q.map((j, oe) => oe === A ? { ...j, ...R } : j)), P = () => h((A) => [...A, Bt()]), O = (A) => h((R) => R.length > 1 ? R.filter((q, j) => j !== A) : R), Z = (A, R) => h((q) => {
4011
- const j = A + R;
4009
+ onError: (P) => k((P == null ? void 0 : P.message) ?? "Discard failed")
4010
+ }), X = (P, R) => h((q) => q.map((j, oe) => oe === P ? { ...j, ...R } : j)), _ = () => h((P) => [...P, Bt()]), O = (P) => h((R) => R.length > 1 ? R.filter((q, j) => j !== P) : R), J = (P, R) => h((q) => {
4011
+ const j = P + R;
4012
4012
  if (j < 0 || j >= q.length) return q;
4013
4013
  const oe = [...q];
4014
- return [oe[A], oe[j]] = [oe[j], oe[A]], oe;
4015
- }), x = async (A) => {
4014
+ return [oe[P], oe[j]] = [oe[j], oe[P]], oe;
4015
+ }), x = async (P) => {
4016
4016
  var q;
4017
- const R = (q = A.target.files) == null ? void 0 : q[0];
4018
- if (A.target.value = "", !(!R || n)) {
4017
+ const R = (q = P.target.files) == null ? void 0 : q[0];
4018
+ if (P.target.value = "", !(!R || n)) {
4019
4019
  N(!0), k(null);
4020
4020
  try {
4021
4021
  const j = await B.uploadProposalAppendix(e, R);
@@ -4026,13 +4026,13 @@ function Vn() {
4026
4026
  N(!1);
4027
4027
  }
4028
4028
  }
4029
- }, W = async () => {
4029
+ }, G = async () => {
4030
4030
  if (!n) {
4031
4031
  N(!0);
4032
4032
  try {
4033
4033
  await B.deleteProposalAppendix(e), b(null);
4034
- } catch (A) {
4035
- k((A == null ? void 0 : A.message) ?? "Failed");
4034
+ } catch (P) {
4035
+ k((P == null ? void 0 : P.message) ?? "Failed");
4036
4036
  } finally {
4037
4037
  N(!1);
4038
4038
  }
@@ -4067,12 +4067,12 @@ function Vn() {
4067
4067
  y && /* @__PURE__ */ t("div", { className: "rounded-lg bg-red-50 px-4 py-2 text-sm text-red-700 ring-1 ring-red-200", children: y }),
4068
4068
  /* @__PURE__ */ r($, { className: "space-y-4 p-5", children: [
4069
4069
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: [
4070
- /* @__PURE__ */ t(re, { label: i("fields.Title", "Title"), value: l.title, onChange: (A) => f("title", A.target.value) }),
4071
- /* @__PURE__ */ t(re, { label: i("fields.Date", "Date"), type: "date", value: l.proposal_date, onChange: (A) => f("proposal_date", A.target.value) }),
4072
- /* @__PURE__ */ t(Ae, { label: i("fields.Customer", "Customer"), value: l.customer, onChange: (A) => f("customer", A), linkDoctype: "customer", readOnly: !1 }),
4073
- /* @__PURE__ */ t(Ae, { label: i("fields.Company", "Company"), value: l.company, onChange: (A) => f("company", A), linkDoctype: "company", readOnly: !1 }),
4074
- /* @__PURE__ */ t(re, { label: i("fields.Partner", "Account Manager"), value: l.partner_name, onChange: (A) => f("partner_name", A.target.value) }),
4075
- /* @__PURE__ */ t(re, { label: i("fields.Partner Email", "Account Manager Email"), value: l.partner_email, onChange: (A) => f("partner_email", A.target.value) })
4070
+ /* @__PURE__ */ t(re, { label: i("fields.Title", "Title"), value: l.title, onChange: (P) => f("title", P.target.value) }),
4071
+ /* @__PURE__ */ t(re, { label: i("fields.Date", "Date"), type: "date", value: l.proposal_date, onChange: (P) => f("proposal_date", P.target.value) }),
4072
+ /* @__PURE__ */ t(De, { label: i("fields.Customer", "Customer"), value: l.customer, onChange: (P) => f("customer", P), linkDoctype: "customer", readOnly: !1 }),
4073
+ /* @__PURE__ */ t(De, { label: i("fields.Company", "Company"), value: l.company, onChange: (P) => f("company", P), linkDoctype: "company", readOnly: !1 }),
4074
+ /* @__PURE__ */ t(re, { label: i("fields.Partner", "Account Manager"), value: l.partner_name, onChange: (P) => f("partner_name", P.target.value) }),
4075
+ /* @__PURE__ */ t(re, { label: i("fields.Partner Email", "Account Manager Email"), value: l.partner_email, onChange: (P) => f("partner_email", P.target.value) })
4076
4076
  ] }),
4077
4077
  /* @__PURE__ */ r("div", { children: [
4078
4078
  /* @__PURE__ */ r("div", { className: "mb-1.5 flex items-center justify-between", children: [
@@ -4083,7 +4083,7 @@ function Vn() {
4083
4083
  "textarea",
4084
4084
  {
4085
4085
  value: l.cover_letter,
4086
- onChange: (A) => f("cover_letter", A.target.value),
4086
+ onChange: (P) => f("cover_letter", P.target.value),
4087
4087
  rows: 5,
4088
4088
  className: "block w-full rounded-lg bg-surface px-3 py-2 text-sm text-fg ring-1 ring-line focus:outline-none focus:ring-2 focus:ring-brand/30"
4089
4089
  }
@@ -4093,23 +4093,23 @@ function Vn() {
4093
4093
  /* @__PURE__ */ r($, { className: "space-y-4 p-5", children: [
4094
4094
  /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
4095
4095
  /* @__PURE__ */ t("h2", { className: "font-semibold text-fg", children: i("proposal.offers", "Offers") }),
4096
- /* @__PURE__ */ t(K, { size: "sm", variant: "secondary", onClick: P, children: i("proposal.addOffer", "Add offer") })
4096
+ /* @__PURE__ */ t(K, { size: "sm", variant: "secondary", onClick: _, children: i("proposal.addOffer", "Add offer") })
4097
4097
  ] }),
4098
- u.map((A, R) => /* @__PURE__ */ r("div", { className: "rounded-lg p-3 ring-1 ring-line", children: [
4098
+ u.map((P, R) => /* @__PURE__ */ r("div", { className: "rounded-lg p-3 ring-1 ring-line", children: [
4099
4099
  /* @__PURE__ */ r("div", { className: "mb-2 flex items-center gap-2", children: [
4100
4100
  /* @__PURE__ */ t("span", { className: "flex h-6 w-6 items-center justify-center rounded-full bg-brand/10 text-sm font-bold text-brand", children: Cs[R] ?? R + 1 }),
4101
- /* @__PURE__ */ t("div", { className: "flex-1", children: /* @__PURE__ */ t(Ae, { label: "", value: A.quotation, onChange: (q) => X(R, { quotation: q }), linkDoctype: "quotation", readOnly: !1 }) }),
4102
- /* @__PURE__ */ t("button", { type: "button", onClick: () => Z(R, -1), disabled: R === 0, className: "px-1 text-fg-muted disabled:opacity-30", children: "↑" }),
4103
- /* @__PURE__ */ t("button", { type: "button", onClick: () => Z(R, 1), disabled: R === u.length - 1, className: "px-1 text-fg-muted disabled:opacity-30", children: "↓" }),
4101
+ /* @__PURE__ */ t("div", { className: "flex-1", children: /* @__PURE__ */ t(De, { label: "", value: P.quotation, onChange: (q) => X(R, { quotation: q }), linkDoctype: "quotation", readOnly: !1 }) }),
4102
+ /* @__PURE__ */ t("button", { type: "button", onClick: () => J(R, -1), disabled: R === 0, className: "px-1 text-fg-muted disabled:opacity-30", children: "↑" }),
4103
+ /* @__PURE__ */ t("button", { type: "button", onClick: () => J(R, 1), disabled: R === u.length - 1, className: "px-1 text-fg-muted disabled:opacity-30", children: "↓" }),
4104
4104
  /* @__PURE__ */ t("button", { type: "button", onClick: () => O(R), className: "px-1 text-red-500 hover:text-red-700", children: "✕" })
4105
4105
  ] }),
4106
4106
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 gap-2 pl-8 sm:grid-cols-2", children: [
4107
- /* @__PURE__ */ t(re, { label: i("proposal.positionTitle", "Position title"), value: A.position_title, onChange: (q) => X(R, { position_title: q.target.value }), placeholder: i("proposal.positionTitleHint", "defaults to the offer's first item") }),
4107
+ /* @__PURE__ */ t(re, { label: i("proposal.positionTitle", "Position title"), value: P.position_title, onChange: (q) => X(R, { position_title: q.target.value }), placeholder: i("proposal.positionTitleHint", "defaults to the offer's first item") }),
4108
4108
  /* @__PURE__ */ r("label", { className: "flex items-center gap-2 self-end pb-2 text-sm text-fg", children: [
4109
- /* @__PURE__ */ t("input", { type: "checkbox", checked: !!A.is_recommended, onChange: (q) => X(R, { is_recommended: q.target.checked ? 1 : 0 }) }),
4109
+ /* @__PURE__ */ t("input", { type: "checkbox", checked: !!P.is_recommended, onChange: (q) => X(R, { is_recommended: q.target.checked ? 1 : 0 }) }),
4110
4110
  i("proposal.recommended", "Mark as recommendation")
4111
4111
  ] }),
4112
- /* @__PURE__ */ t("div", { className: "sm:col-span-2", children: /* @__PURE__ */ t(re, { label: i("proposal.blurb", "Description"), value: A.position_blurb, onChange: (q) => X(R, { position_blurb: q.target.value }), placeholder: i("proposal.blurbHint", "defaults to the offer's notes") }) })
4112
+ /* @__PURE__ */ t("div", { className: "sm:col-span-2", children: /* @__PURE__ */ t(re, { label: i("proposal.blurb", "Description"), value: P.position_blurb, onChange: (q) => X(R, { position_blurb: q.target.value }), placeholder: i("proposal.blurbHint", "defaults to the offer's notes") }) })
4113
4113
  ] })
4114
4114
  ] }, R))
4115
4115
  ] }),
@@ -4120,12 +4120,12 @@ function Vn() {
4120
4120
  "📎 ",
4121
4121
  d
4122
4122
  ] }),
4123
- /* @__PURE__ */ t("button", { type: "button", onClick: W, disabled: v, className: "text-red-500 hover:underline", children: i("common.remove", "Remove") })
4123
+ /* @__PURE__ */ t("button", { type: "button", onClick: G, disabled: v, className: "text-red-500 hover:underline", children: i("common.remove", "Remove") })
4124
4124
  ] }) : /* @__PURE__ */ r("div", { children: [
4125
- /* @__PURE__ */ t("input", { ref: S, type: "file", accept: "application/pdf", onChange: x, className: "hidden" }),
4125
+ /* @__PURE__ */ t("input", { ref: D, type: "file", accept: "application/pdf", onChange: x, className: "hidden" }),
4126
4126
  /* @__PURE__ */ t(K, { size: "sm", variant: "secondary", disabled: v, onClick: () => {
4127
- var A;
4128
- return (A = S.current) == null ? void 0 : A.click();
4127
+ var P;
4128
+ return (P = D.current) == null ? void 0 : P.click();
4129
4129
  }, children: v ? i("common.uploading", "Uploading…") : i("proposal.uploadAppendix", "Upload appendix PDF") }),
4130
4130
  /* @__PURE__ */ t("p", { className: "mt-1 text-xs text-fg-muted", children: i("proposal.appendixHint", "Appended after the offers — e.g. a price overview.") })
4131
4131
  ] })
@@ -4141,13 +4141,13 @@ const Ss = {
4141
4141
  }, Ds = ["25", "50", "100", "200"];
4142
4142
  function As() {
4143
4143
  var m;
4144
- const { type: e } = yt(), n = Me(), a = Nt(), s = Ss[e ?? ""] ?? e ?? "";
4145
- _e(s || null);
4144
+ const { type: e } = ft(), n = Fe(), a = Nt(), s = Ss[e ?? ""] ?? e ?? "";
4145
+ Pe(s || null);
4146
4146
  const o = (m = a.state) == null ? void 0 : m.notice;
4147
4147
  ae(() => {
4148
4148
  e && Aa(`master:${e}`, { filters: {}, search: a.search });
4149
4149
  }, [e, a.search]);
4150
- const [i] = le("per_page", 50), [c] = le("page", 1), l = c - 1, p = rt(), u = (D) => p({ page: D === 0 ? null : D + 1 }), h = (D) => p({ per_page: D, page: null }), { data: d, isLoading: b } = ce({
4150
+ const [i] = le("per_page", 50), [c] = le("page", 1), l = c - 1, p = rt(), u = (A) => p({ page: A === 0 ? null : A + 1 }), h = (A) => p({ per_page: A, page: null }), { data: d, isLoading: b } = de({
4151
4151
  queryKey: ["masters", e, l, i],
4152
4152
  queryFn: () => B.listMasters(e, {
4153
4153
  include_disabled: 1,
@@ -4155,26 +4155,26 @@ function As() {
4155
4155
  offset: l * i
4156
4156
  }),
4157
4157
  enabled: !!e
4158
- }), v = (d == null ? void 0 : d.rows) ?? [], N = (d == null ? void 0 : d.total) ?? 0, y = Math.max(1, Math.ceil(N / i)), k = N === 0 ? 0 : l * i + 1, S = Math.min(N, (l + 1) * i), f = be(() => {
4158
+ }), v = (d == null ? void 0 : d.rows) ?? [], N = (d == null ? void 0 : d.total) ?? 0, y = Math.max(1, Math.ceil(N / i)), k = N === 0 ? 0 : l * i + 1, D = Math.min(N, (l + 1) * i), f = be(() => {
4159
4159
  if (!v || v.length === 0) return [];
4160
- const D = da();
4160
+ const A = da();
4161
4161
  return Object.keys(v[0]).map(
4162
- (V) => D.accessor(V, {
4162
+ (V) => A.accessor(V, {
4163
4163
  header: V.split("_").map((X) => X.charAt(0).toUpperCase() + X.slice(1)).join(" "),
4164
4164
  cell: (X) => {
4165
- const P = X.getValue();
4165
+ const _ = X.getValue();
4166
4166
  if (V === "name") {
4167
4167
  const O = X.row.original.disabled === 1;
4168
4168
  return /* @__PURE__ */ t(
4169
- De,
4169
+ Ce,
4170
4170
  {
4171
- to: `/masters/${e}/${P}`,
4171
+ to: `/masters/${e}/${_}`,
4172
4172
  className: O ? "font-medium text-fg-muted" : "font-medium text-brand transition-colors hover:text-brand/80",
4173
- children: P
4173
+ children: _
4174
4174
  }
4175
4175
  );
4176
4176
  }
4177
- return V === "disabled" ? P === 1 ? "Disabled" : "Active" : P ?? "-";
4177
+ return V === "disabled" ? _ === 1 ? "Disabled" : "Active" : _ ?? "-";
4178
4178
  }
4179
4179
  })
4180
4180
  );
@@ -4185,10 +4185,10 @@ function As() {
4185
4185
  });
4186
4186
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4187
4187
  o && /* @__PURE__ */ t("div", { className: "rounded-md bg-amber-50 px-4 py-3 text-sm text-amber-800", children: o }),
4188
- /* @__PURE__ */ t("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ t(De, { to: `/masters/${e}/new`, children: /* @__PURE__ */ t(K, { children: "New" }) }) }),
4189
- b ? /* @__PURE__ */ t("p", { className: "text-fg-muted", children: "Loading..." }) : v.length === 0 ? /* @__PURE__ */ t("p", { className: "py-8 text-center text-fg-muted", children: "No records found" }) : /* @__PURE__ */ r(Pe, { children: [
4188
+ /* @__PURE__ */ t("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ t(Ce, { to: `/masters/${e}/new`, children: /* @__PURE__ */ t(K, { children: "New" }) }) }),
4189
+ b ? /* @__PURE__ */ t("p", { className: "text-fg-muted", children: "Loading..." }) : v.length === 0 ? /* @__PURE__ */ t("p", { className: "py-8 text-center text-fg-muted", children: "No records found" }) : /* @__PURE__ */ r(Ae, { children: [
4190
4190
  /* @__PURE__ */ t("div", { className: "overflow-x-auto rounded-xl bg-surface ring-1 ring-line shadow-card", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-line text-sm", children: [
4191
- /* @__PURE__ */ t("thead", { className: "bg-surface-subtle", children: g.getHeaderGroups().map((D) => /* @__PURE__ */ t("tr", { children: D.headers.map((T) => /* @__PURE__ */ t(
4191
+ /* @__PURE__ */ t("thead", { className: "bg-surface-subtle", children: g.getHeaderGroups().map((A) => /* @__PURE__ */ t("tr", { children: A.headers.map((T) => /* @__PURE__ */ t(
4192
4192
  "th",
4193
4193
  {
4194
4194
  className: "px-4 py-3 text-left text-xs font-medium uppercase tracking-wide text-fg-muted",
@@ -4198,18 +4198,18 @@ function As() {
4198
4198
  )
4199
4199
  },
4200
4200
  T.id
4201
- )) }, D.id)) }),
4202
- /* @__PURE__ */ t("tbody", { className: "divide-y divide-line", children: g.getRowModel().rows.map((D) => /* @__PURE__ */ t(
4201
+ )) }, A.id)) }),
4202
+ /* @__PURE__ */ t("tbody", { className: "divide-y divide-line", children: g.getRowModel().rows.map((A) => /* @__PURE__ */ t(
4203
4203
  "tr",
4204
4204
  {
4205
- className: D.original.disabled === 1 ? "cursor-pointer bg-surface-subtle text-fg-muted transition-colors hover:bg-surface-subtle/80" : "cursor-pointer text-fg transition-colors hover:bg-surface-subtle",
4206
- onClick: () => n(`/masters/${e}/${D.original.name}`),
4207
- children: D.getVisibleCells().map((T) => /* @__PURE__ */ t("td", { className: "px-4 py-2.5", children: qt(
4205
+ className: A.original.disabled === 1 ? "cursor-pointer bg-surface-subtle text-fg-muted transition-colors hover:bg-surface-subtle/80" : "cursor-pointer text-fg transition-colors hover:bg-surface-subtle",
4206
+ onClick: () => n(`/masters/${e}/${A.original.name}`),
4207
+ children: A.getVisibleCells().map((T) => /* @__PURE__ */ t("td", { className: "px-4 py-2.5", children: qt(
4208
4208
  T.column.columnDef.cell,
4209
4209
  T.getContext()
4210
4210
  ) }, T.id))
4211
4211
  },
4212
- D.id
4212
+ A.id
4213
4213
  )) })
4214
4214
  ] }) }),
4215
4215
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center justify-between gap-3 text-sm text-fg-muted", children: [
@@ -4218,7 +4218,7 @@ function As() {
4218
4218
  /* @__PURE__ */ r("span", { className: "font-medium text-fg", children: [
4219
4219
  k,
4220
4220
  "–",
4221
- S
4221
+ D
4222
4222
  ] }),
4223
4223
  " ",
4224
4224
  "of ",
@@ -4231,9 +4231,9 @@ function As() {
4231
4231
  "select",
4232
4232
  {
4233
4233
  value: i,
4234
- onChange: (D) => h(Number(D.target.value)),
4234
+ onChange: (A) => h(Number(A.target.value)),
4235
4235
  className: "h-8 rounded-md bg-surface px-2 text-sm text-fg ring-1 ring-line transition-all focus:outline-none focus:ring-2 focus:ring-brand/30",
4236
- children: Ds.map((D) => /* @__PURE__ */ t("option", { value: D, children: D }, D))
4236
+ children: Ds.map((A) => /* @__PURE__ */ t("option", { value: A, children: A }, A))
4237
4237
  }
4238
4238
  )
4239
4239
  ] }),
@@ -4338,38 +4338,38 @@ const Ps = {
4338
4338
  company: "Company"
4339
4339
  }, Un = /* @__PURE__ */ new Set(["customer", "supplier", "item", "warehouse"]);
4340
4340
  function Kn() {
4341
- var O, Z;
4342
- const { type: e, name: n } = yt(), a = Me(), s = Ze(), { t: o } = ne(), i = !n || n === "new", c = _s[e ?? ""] ?? e ?? "", l = o(`masters.${e}.one`, { defaultValue: c }), p = Ps[e ?? ""] ?? [], u = (x) => o(`fields.${x.label}`, { defaultValue: x.label }), [h, d] = w({}), { data: b, isLoading: v } = ce({
4341
+ var O, J;
4342
+ const { type: e, name: n } = ft(), a = Fe(), s = Qe(), { t: o } = ne(), i = !n || n === "new", c = _s[e ?? ""] ?? e ?? "", l = o(`masters.${e}.one`, { defaultValue: c }), p = Ps[e ?? ""] ?? [], u = (x) => o(`fields.${x.label}`, { defaultValue: x.label }), [h, d] = w({}), { data: b, isLoading: v } = de({
4343
4343
  queryKey: ["master", e, n],
4344
4344
  queryFn: () => B.getMaster(e, n),
4345
4345
  enabled: !!e && !!n && !i
4346
4346
  }), N = (O = p.find((x) => x.name.endsWith("_name"))) == null ? void 0 : O.name, y = N ? b == null ? void 0 : b[N] : void 0;
4347
- _e(i ? l : y ?? n ?? l), ae(() => {
4347
+ Pe(i ? l : y ?? n ?? l), ae(() => {
4348
4348
  if (i) {
4349
4349
  const x = {};
4350
- p.forEach((W) => {
4351
- x[W.name] = W.default ?? "";
4350
+ p.forEach((G) => {
4351
+ x[G.name] = G.default ?? "";
4352
4352
  }), d(x);
4353
4353
  } else b && d(b);
4354
4354
  }, [i, b, p]);
4355
4355
  const k = Ke();
4356
4356
  ae(() => {
4357
4357
  !i || !k || p.some((x) => x.name === "default_currency") && d((x) => {
4358
- const W = x.default_currency;
4359
- return W && W !== "USD" || W === k ? x : { ...x, default_currency: k };
4358
+ const G = x.default_currency;
4359
+ return G && G !== "USD" || G === k ? x : { ...x, default_currency: k };
4360
4360
  });
4361
4361
  }, [i, p, k]);
4362
- const S = de({
4362
+ const D = ue({
4363
4363
  mutationFn: (x) => B.createMaster(e, x),
4364
4364
  onSuccess: (x) => {
4365
4365
  s.invalidateQueries({ queryKey: ["masters", e] }), a(`/masters/${e}/${x.name}`, { replace: !0 });
4366
4366
  }
4367
- }), f = de({
4367
+ }), f = ue({
4368
4368
  mutationFn: (x) => B.updateMaster(e, n, x),
4369
4369
  onSuccess: () => {
4370
4370
  s.invalidateQueries({ queryKey: ["master", e, n] }), s.invalidateQueries({ queryKey: ["masters", e] });
4371
4371
  }
4372
- }), g = de({
4372
+ }), g = ue({
4373
4373
  mutationFn: () => B.deleteMaster(e, n),
4374
4374
  onSuccess: (x) => {
4375
4375
  if (s.invalidateQueries({ queryKey: ["masters", e] }), (x == null ? void 0 : x.status) === "disabled") {
@@ -4388,30 +4388,30 @@ function Kn() {
4388
4388
  a(`/masters/${e}`, { replace: !0 });
4389
4389
  }
4390
4390
  }), m = () => {
4391
- if (P.length > 0) return;
4391
+ if (_.length > 0) return;
4392
4392
  const x = e === "company" && !h.name ? { ...h, name: h.company_name } : h;
4393
- i ? S.mutate(x) : f.mutate(x);
4394
- }, D = wa(), T = async () => {
4395
- await D({
4393
+ i ? D.mutate(x) : f.mutate(x);
4394
+ }, A = wa(), T = async () => {
4395
+ await A({
4396
4396
  title: o("masterForm.deleteConfirm", { label: l }),
4397
4397
  confirmLabel: o("common.delete", { defaultValue: "Delete" }),
4398
4398
  danger: !0
4399
4399
  }) && g.mutate();
4400
- }, V = (x, W) => {
4401
- d((A) => ({ ...A, [x]: W }));
4400
+ }, V = (x, G) => {
4401
+ d((P) => ({ ...P, [x]: G }));
4402
4402
  };
4403
4403
  if (!i && v)
4404
4404
  return /* @__PURE__ */ t("p", { className: "text-fg-muted", children: o("common.loading") });
4405
- const X = S.isPending || f.isPending, P = p.filter((x) => {
4405
+ const X = D.isPending || f.isPending, _ = p.filter((x) => {
4406
4406
  if (!x.required || x.readOnly || i && x.name === "name" && Un.has(e ?? "")) return !1;
4407
- const W = h[x.name];
4408
- return W == null || String(W).trim() === "";
4407
+ const G = h[x.name];
4408
+ return G == null || String(G).trim() === "";
4409
4409
  });
4410
4410
  return /* @__PURE__ */ r("div", { className: "space-y-6", children: [
4411
4411
  /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
4412
4412
  i ? /* @__PURE__ */ t("div", {}) : /* @__PURE__ */ t(_a, { kind: "master", slug: e, name: n, onSave: m }),
4413
4413
  /* @__PURE__ */ r("div", { className: "flex gap-2", children: [
4414
- /* @__PURE__ */ t(K, { onClick: m, disabled: X || P.length > 0, children: o(X ? "common.saving" : "common.save") }),
4414
+ /* @__PURE__ */ t(K, { onClick: m, disabled: X || _.length > 0, children: o(X ? "common.saving" : "common.save") }),
4415
4415
  !i && /* @__PURE__ */ t(
4416
4416
  K,
4417
4417
  {
@@ -4423,22 +4423,22 @@ function Kn() {
4423
4423
  )
4424
4424
  ] })
4425
4425
  ] }),
4426
- (S.error || f.error || g.error) && /* @__PURE__ */ t("div", { className: "rounded-lg bg-rose-50 p-4 text-sm text-rose-700 ring-1 ring-rose-200", children: ((Z = S.error ?? f.error ?? g.error) == null ? void 0 : Z.message) ?? o("common.errorOccurred") }),
4427
- P.length > 0 && /* @__PURE__ */ t("div", { className: "rounded-lg bg-amber-50 p-4 text-sm text-amber-800 ring-1 ring-amber-200", children: o("masterForm.required", { fields: P.map(u).join(", ") }) }),
4426
+ (D.error || f.error || g.error) && /* @__PURE__ */ t("div", { className: "rounded-lg bg-rose-50 p-4 text-sm text-rose-700 ring-1 ring-rose-200", children: ((J = D.error ?? f.error ?? g.error) == null ? void 0 : J.message) ?? o("common.errorOccurred") }),
4427
+ _.length > 0 && /* @__PURE__ */ t("div", { className: "rounded-lg bg-amber-50 p-4 text-sm text-amber-800 ring-1 ring-amber-200", children: o("masterForm.required", { fields: _.map(u).join(", ") }) }),
4428
4428
  h.disabled === 1 && /* @__PURE__ */ t("div", { className: "rounded-lg bg-amber-50 p-4 text-sm text-amber-800 ring-1 ring-amber-200", children: o("masterForm.disabledNotice", { label: l }) }),
4429
4429
  /* @__PURE__ */ t($, { children: /* @__PURE__ */ t("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: p.map((x) => {
4430
- const A = x.name === "name" && !i || x.readOnly, R = x.required && !(i && x.name === "name" && Un.has(e ?? ""));
4430
+ const P = x.name === "name" && !i || x.readOnly, R = x.required && !(i && x.name === "name" && Un.has(e ?? ""));
4431
4431
  if (x.type === "select" && x.options) {
4432
4432
  const j = h[x.name], oe = typeof j == "string" && j !== "" && !x.options.includes(j) ? [...x.options, j] : x.options;
4433
4433
  return /* @__PURE__ */ t("div", { children: /* @__PURE__ */ t(
4434
- Je,
4434
+ Ye,
4435
4435
  {
4436
4436
  label: u(x),
4437
4437
  options: oe,
4438
4438
  value: h[x.name] ?? "",
4439
4439
  required: R,
4440
- disabled: A,
4441
- onChange: (me) => V(x.name, me.target.value)
4440
+ disabled: P,
4441
+ onChange: (he) => V(x.name, he.target.value)
4442
4442
  }
4443
4443
  ) }, x.name);
4444
4444
  }
@@ -4452,8 +4452,8 @@ function Kn() {
4452
4452
  rows: 3,
4453
4453
  value: h[x.name] ?? "",
4454
4454
  required: R,
4455
- readOnly: A,
4456
- disabled: A,
4455
+ readOnly: P,
4456
+ disabled: P,
4457
4457
  onChange: (j) => V(x.name, j.target.value)
4458
4458
  }
4459
4459
  )
@@ -4466,8 +4466,8 @@ function Kn() {
4466
4466
  type: q,
4467
4467
  step: x.type === "currency" ? "0.01" : void 0,
4468
4468
  required: R,
4469
- readOnly: A,
4470
- disabled: A,
4469
+ readOnly: P,
4470
+ disabled: P,
4471
4471
  value: h[x.name] ?? "",
4472
4472
  onChange: (j) => V(
4473
4473
  x.name,
@@ -4480,56 +4480,56 @@ function Kn() {
4480
4480
  ] });
4481
4481
  }
4482
4482
  function Ts(e) {
4483
- const { data: n, isLoading: a, error: s, refetch: o } = ce({
4483
+ const { data: n, isLoading: a, error: s, refetch: o } = de({
4484
4484
  queryKey: ["report", "trial-balance", e],
4485
4485
  queryFn: () => B.trialBalance(e)
4486
4486
  });
4487
4487
  return { data: n, isLoading: a, error: s, refetch: o };
4488
4488
  }
4489
4489
  function Rs(e) {
4490
- const { data: n, isLoading: a, error: s, refetch: o } = ce({
4490
+ const { data: n, isLoading: a, error: s, refetch: o } = de({
4491
4491
  queryKey: ["report", "chart-of-accounts", e],
4492
4492
  queryFn: () => B.chartOfAccounts(e)
4493
4493
  });
4494
4494
  return { data: n, isLoading: a, error: s, refetch: o };
4495
4495
  }
4496
4496
  function Is(e) {
4497
- const { data: n, isLoading: a, error: s, refetch: o } = ce({
4497
+ const { data: n, isLoading: a, error: s, refetch: o } = de({
4498
4498
  queryKey: ["report", "general-ledger", e],
4499
4499
  queryFn: () => B.generalLedger(e)
4500
4500
  });
4501
4501
  return { data: n, isLoading: a, error: s, refetch: o };
4502
4502
  }
4503
4503
  function Bs(e) {
4504
- const { data: n, isLoading: a, error: s, refetch: o } = ce({
4504
+ const { data: n, isLoading: a, error: s, refetch: o } = de({
4505
4505
  queryKey: ["report", "stock-balance", e],
4506
4506
  queryFn: () => B.stockBalance(e)
4507
4507
  });
4508
4508
  return { data: n, isLoading: a, error: s, refetch: o };
4509
4509
  }
4510
4510
  function Es(e) {
4511
- const { data: n, isLoading: a, error: s, refetch: o } = ce({
4511
+ const { data: n, isLoading: a, error: s, refetch: o } = de({
4512
4512
  queryKey: ["report", "profit-and-loss", e],
4513
4513
  queryFn: () => B.profitAndLoss(e)
4514
4514
  });
4515
4515
  return { data: n, isLoading: a, error: s, refetch: o };
4516
4516
  }
4517
4517
  function Ls(e) {
4518
- const { data: n, isLoading: a, error: s, refetch: o } = ce({
4518
+ const { data: n, isLoading: a, error: s, refetch: o } = de({
4519
4519
  queryKey: ["report", "balance-sheet", e],
4520
4520
  queryFn: () => B.balanceSheet(e)
4521
4521
  });
4522
4522
  return { data: n, isLoading: a, error: s, refetch: o };
4523
4523
  }
4524
4524
  function Os(e) {
4525
- const { data: n, isLoading: a, error: s, refetch: o } = ce({
4525
+ const { data: n, isLoading: a, error: s, refetch: o } = de({
4526
4526
  queryKey: ["report", "ar-aging", e],
4527
4527
  queryFn: () => B.arAging(e)
4528
4528
  });
4529
4529
  return { data: n, isLoading: a, error: s, refetch: o };
4530
4530
  }
4531
4531
  function qs(e) {
4532
- const { data: n, isLoading: a, error: s, refetch: o } = ce({
4532
+ const { data: n, isLoading: a, error: s, refetch: o } = de({
4533
4533
  queryKey: ["report", "ap-aging", e],
4534
4534
  queryFn: () => B.apAging(e)
4535
4535
  });
@@ -4537,11 +4537,11 @@ function qs(e) {
4537
4537
  }
4538
4538
  function Ms() {
4539
4539
  const { t: e } = ne();
4540
- _e(e("titles.trial-balance"));
4540
+ Pe(e("titles.trial-balance"));
4541
4541
  const [n] = le("company", ""), [a] = le("from", ""), [s] = le("to", ""), o = rt(), [i, c] = w(n), [l, p] = w(a), [u, h] = w(s), d = Ke(i), b = (g) => Ue(g, d), v = be(() => {
4542
4542
  const g = {};
4543
4543
  return n && (g.company = n), a && (g.from_date = a), s && (g.to_date = s), g;
4544
- }, [n, a, s]), { data: N, isLoading: y, refetch: k } = Ts(v), S = () => {
4544
+ }, [n, a, s]), { data: N, isLoading: y, refetch: k } = Ts(v), D = () => {
4545
4545
  o({
4546
4546
  company: i || null,
4547
4547
  from: l || null,
@@ -4551,7 +4551,7 @@ function Ms() {
4551
4551
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4552
4552
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
4553
4553
  /* @__PURE__ */ t(
4554
- Ae,
4554
+ De,
4555
4555
  {
4556
4556
  label: e("fields.Company", { defaultValue: "Company" }),
4557
4557
  value: i,
@@ -4578,7 +4578,7 @@ function Ms() {
4578
4578
  onChange: (g) => h(g.target.value)
4579
4579
  }
4580
4580
  ),
4581
- /* @__PURE__ */ t(K, { onClick: S, children: e("common.apply") })
4581
+ /* @__PURE__ */ t(K, { onClick: D, children: e("common.apply") })
4582
4582
  ] }),
4583
4583
  /* @__PURE__ */ t(Kt, { onSelect: (g, m) => {
4584
4584
  p(g), h(m), o({ from: g, to: m });
@@ -4617,7 +4617,7 @@ function Ms() {
4617
4617
  const Fs = ["Asset", "Liability", "Equity", "Income", "Expense"];
4618
4618
  function zs() {
4619
4619
  const { t: e } = ne();
4620
- _e(e("titles.chart-of-accounts", { defaultValue: "Chart of Accounts" }));
4620
+ Pe(e("titles.chart-of-accounts", { defaultValue: "Chart of Accounts" }));
4621
4621
  const n = (/* @__PURE__ */ new Date()).getFullYear(), [a, s] = w(String(n)), [o, i] = w(/* @__PURE__ */ new Set()), c = be(() => {
4622
4622
  const f = [];
4623
4623
  for (let g = n; g >= n - 6; g--)
@@ -4627,14 +4627,14 @@ function zs() {
4627
4627
  const f = {};
4628
4628
  return a !== "all" && (f.from_date = `${a}-01-01`, f.to_date = `${a}-12-31`), f;
4629
4629
  }, [a]), { data: p, isLoading: u } = Rs(l), h = Ke(""), d = (f) => Ue(f, h), b = (p == null ? void 0 : p.accounts) ?? [], { childrenOf: v, rootsByType: N } = be(() => {
4630
- const f = new Map(b.map((D) => [D.name, D])), g = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
4631
- for (const D of b)
4632
- if (D.parent_account && f.has(D.parent_account)) {
4633
- const T = g.get(D.parent_account) ?? [];
4634
- T.push(D), g.set(D.parent_account, T);
4630
+ const f = new Map(b.map((A) => [A.name, A])), g = /* @__PURE__ */ new Map(), m = /* @__PURE__ */ new Map();
4631
+ for (const A of b)
4632
+ if (A.parent_account && f.has(A.parent_account)) {
4633
+ const T = g.get(A.parent_account) ?? [];
4634
+ T.push(A), g.set(A.parent_account, T);
4635
4635
  } else {
4636
- const T = D.root_type ?? "Other", V = m.get(T) ?? [];
4637
- V.push(D), m.set(T, V);
4636
+ const T = A.root_type ?? "Other", V = m.get(T) ?? [];
4637
+ V.push(A), m.set(T, V);
4638
4638
  }
4639
4639
  return { childrenOf: g, rootsByType: m };
4640
4640
  }, [b]), y = (f) => {
@@ -4645,8 +4645,8 @@ function zs() {
4645
4645
  }, k = (f) => {
4646
4646
  const g = new URLSearchParams({ account: f });
4647
4647
  return a !== "all" && (g.set("from", `${a}-01-01`), g.set("to", `${a}-12-31`)), `/reports/general-ledger?${g.toString()}`;
4648
- }, S = (f, g) => {
4649
- const m = v.get(f.name) ?? [], D = o.has(f.name), T = !f.has_entries || f.disabled;
4648
+ }, D = (f, g) => {
4649
+ const m = v.get(f.name) ?? [], A = o.has(f.name), T = !f.has_entries || f.disabled;
4650
4650
  return /* @__PURE__ */ r("div", { children: [
4651
4651
  /* @__PURE__ */ r(
4652
4652
  "div",
@@ -4660,11 +4660,11 @@ function zs() {
4660
4660
  type: "button",
4661
4661
  onClick: () => y(f.name),
4662
4662
  className: "shrink-0 text-fg-muted transition-colors hover:text-fg",
4663
- children: D ? /* @__PURE__ */ t(Pt, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(At, { className: "h-3.5 w-3.5" })
4663
+ children: A ? /* @__PURE__ */ t(Pt, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ t(At, { className: "h-3.5 w-3.5" })
4664
4664
  }
4665
4665
  ) : /* @__PURE__ */ t("span", { className: "w-3.5 shrink-0" }),
4666
4666
  /* @__PURE__ */ r("span", { className: `min-w-0 flex-1 truncate ${f.is_group ? "font-medium" : ""}`, children: [
4667
- f.is_group ? /* @__PURE__ */ t(Pe, { children: f.account_name || f.name }) : /* @__PURE__ */ r(De, { to: k(f.name), className: "hover:text-brand hover:underline", children: [
4667
+ f.is_group ? /* @__PURE__ */ t(Ae, { children: f.account_name || f.name }) : /* @__PURE__ */ r(Ce, { to: k(f.name), className: "hover:text-brand hover:underline", children: [
4668
4668
  /* @__PURE__ */ t("span", { className: "font-mono text-xs text-fg-muted", children: f.name }),
4669
4669
  " ",
4670
4670
  f.account_name || f.name
@@ -4676,13 +4676,13 @@ function zs() {
4676
4676
  ]
4677
4677
  }
4678
4678
  ),
4679
- !D && m.map((V) => S(V, g + 1))
4679
+ !A && m.map((V) => D(V, g + 1))
4680
4680
  ] }, f.name);
4681
4681
  };
4682
4682
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4683
4683
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
4684
4684
  /* @__PURE__ */ t("div", { className: "w-40", children: /* @__PURE__ */ t(
4685
- Je,
4685
+ Ye,
4686
4686
  {
4687
4687
  label: e("coa.period", { defaultValue: "Period" }),
4688
4688
  options: c,
@@ -4698,7 +4698,7 @@ function zs() {
4698
4698
  !u && b.length === 0 && /* @__PURE__ */ t($, { children: /* @__PURE__ */ t("p", { className: "text-sm text-fg-muted", children: e("coa.empty", { defaultValue: "No accounts found. Complete the company setup first." }) }) }),
4699
4699
  !u && Fs.filter((f) => (N.get(f) ?? []).length > 0).map((f) => /* @__PURE__ */ r($, { children: [
4700
4700
  /* @__PURE__ */ t("h3", { className: "mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-fg-muted", children: e(`coa.rootType.${f}`, { defaultValue: f }) }),
4701
- /* @__PURE__ */ t("div", { children: (N.get(f) ?? []).map((g) => S(g, 0)) })
4701
+ /* @__PURE__ */ t("div", { children: (N.get(f) ?? []).map((g) => D(g, 0)) })
4702
4702
  ] }, f))
4703
4703
  ] });
4704
4704
  }
@@ -4708,23 +4708,23 @@ function $s(e) {
4708
4708
  const Vs = ["25", "50", "100", "200"];
4709
4709
  function Us() {
4710
4710
  const { t: e } = ne();
4711
- _e(e("titles.general-ledger"));
4712
- const [n] = le("account", ""), [a] = le("party", ""), [s] = le("from", ""), [o] = le("to", ""), [i] = le("per_page", 50), [c] = le("page", 1), l = c - 1, p = rt(), u = (R) => p({ page: R === 0 ? null : R + 1 }), h = (R) => p({ per_page: R, page: null }), [d, b] = w(n), [v, N] = w(a), [y, k] = w(s), [S, f] = w(o), g = Ke(), m = (R) => Ue(R, g), D = be(() => {
4711
+ Pe(e("titles.general-ledger"));
4712
+ const [n] = le("account", ""), [a] = le("party", ""), [s] = le("from", ""), [o] = le("to", ""), [i] = le("per_page", 50), [c] = le("page", 1), l = c - 1, p = rt(), u = (R) => p({ page: R === 0 ? null : R + 1 }), h = (R) => p({ per_page: R, page: null }), [d, b] = w(n), [v, N] = w(a), [y, k] = w(s), [D, f] = w(o), g = Ke(), m = (R) => Ue(R, g), A = be(() => {
4713
4713
  const R = {};
4714
4714
  return n && (R.account = n), a && (R.party = a), s && (R.from_date = s), o && (R.to_date = o), R.limit = String(i), R.offset = String(l * i), R;
4715
- }, [n, a, s, o, i, l]), { data: T, isLoading: V, refetch: X } = Is(D), P = (T == null ? void 0 : T.rows) ?? [], O = (T == null ? void 0 : T.total) ?? 0, Z = Math.max(1, Math.ceil(O / i)), x = O === 0 ? 0 : l * i + 1, W = Math.min(O, (l + 1) * i), A = () => {
4715
+ }, [n, a, s, o, i, l]), { data: T, isLoading: V, refetch: X } = Is(A), _ = (T == null ? void 0 : T.rows) ?? [], O = (T == null ? void 0 : T.total) ?? 0, J = Math.max(1, Math.ceil(O / i)), x = O === 0 ? 0 : l * i + 1, G = Math.min(O, (l + 1) * i), P = () => {
4716
4716
  p({
4717
4717
  account: d || null,
4718
4718
  party: v || null,
4719
4719
  from: y || null,
4720
- to: S || null,
4720
+ to: D || null,
4721
4721
  page: null
4722
4722
  }), X();
4723
4723
  };
4724
4724
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4725
4725
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
4726
4726
  /* @__PURE__ */ t(
4727
- Ae,
4727
+ De,
4728
4728
  {
4729
4729
  label: e("fields.Account", { defaultValue: "Account" }),
4730
4730
  value: d,
@@ -4734,7 +4734,7 @@ function Us() {
4734
4734
  }
4735
4735
  ),
4736
4736
  /* @__PURE__ */ t(
4737
- Ae,
4737
+ De,
4738
4738
  {
4739
4739
  label: e("fields.Party", { defaultValue: "Party" }),
4740
4740
  value: v,
@@ -4757,16 +4757,16 @@ function Us() {
4757
4757
  {
4758
4758
  label: e("fields.To Date", { defaultValue: "To Date" }),
4759
4759
  type: "date",
4760
- value: S,
4760
+ value: D,
4761
4761
  onChange: (R) => f(R.target.value)
4762
4762
  }
4763
4763
  ),
4764
- /* @__PURE__ */ t(K, { onClick: A, children: e("common.apply") })
4764
+ /* @__PURE__ */ t(K, { onClick: P, children: e("common.apply") })
4765
4765
  ] }),
4766
4766
  /* @__PURE__ */ t(Kt, { onSelect: (R, q) => {
4767
4767
  k(R), f(q), p({ from: R, to: q, page: null });
4768
4768
  } }),
4769
- V ? /* @__PURE__ */ t("p", { className: "text-gray-500", children: e("common.loading") }) : P.length === 0 ? /* @__PURE__ */ t("p", { className: "py-8 text-center text-gray-400", children: e("reports.noEntries") }) : /* @__PURE__ */ r(Pe, { children: [
4769
+ V ? /* @__PURE__ */ t("p", { className: "text-gray-500", children: e("common.loading") }) : _.length === 0 ? /* @__PURE__ */ t("p", { className: "py-8 text-center text-gray-400", children: e("reports.noEntries") }) : /* @__PURE__ */ r(Ae, { children: [
4770
4770
  /* @__PURE__ */ t($, { children: /* @__PURE__ */ t("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
4771
4771
  /* @__PURE__ */ t("thead", { className: "bg-gray-50", children: /* @__PURE__ */ r("tr", { children: [
4772
4772
  /* @__PURE__ */ t("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: e("fields.Date", { defaultValue: "Date" }) }),
@@ -4778,7 +4778,7 @@ function Us() {
4778
4778
  /* @__PURE__ */ t("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: e("fields.Voucher Type", { defaultValue: "Voucher Type" }) }),
4779
4779
  /* @__PURE__ */ t("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: e("fields.Voucher No", { defaultValue: "Voucher No" }) })
4780
4780
  ] }) }),
4781
- /* @__PURE__ */ t("tbody", { className: "divide-y divide-gray-100", children: P.map((R, q) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4781
+ /* @__PURE__ */ t("tbody", { className: "divide-y divide-gray-100", children: _.map((R, q) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4782
4782
  /* @__PURE__ */ t("td", { className: "px-4 py-2 text-gray-500", children: Ut(R.posting_date ?? R.date) }),
4783
4783
  /* @__PURE__ */ t("td", { className: "px-4 py-2 text-gray-900", children: R.account }),
4784
4784
  /* @__PURE__ */ t("td", { className: "px-4 py-2 text-gray-700", children: R.party ?? "-" }),
@@ -4787,7 +4787,7 @@ function Us() {
4787
4787
  /* @__PURE__ */ t("td", { className: "px-4 py-2 text-right font-medium", children: m(R.balance) }),
4788
4788
  /* @__PURE__ */ t("td", { className: "px-4 py-2 text-gray-700", children: R.voucher_type ?? "-" }),
4789
4789
  /* @__PURE__ */ t("td", { className: "px-4 py-2", children: R.voucher_type && R.voucher_no ? /* @__PURE__ */ t(
4790
- De,
4790
+ Ce,
4791
4791
  {
4792
4792
  to: `/app/${$s(R.voucher_type)}/${R.voucher_no}`,
4793
4793
  className: "font-medium text-blue-600 hover:text-blue-800",
@@ -4803,7 +4803,7 @@ function Us() {
4803
4803
  /* @__PURE__ */ r("span", { className: "font-medium text-gray-900", children: [
4804
4804
  x,
4805
4805
  "–",
4806
- W
4806
+ G
4807
4807
  ] }),
4808
4808
  " ",
4809
4809
  e("common.of"),
@@ -4839,13 +4839,13 @@ function Us() {
4839
4839
  " ",
4840
4840
  e("common.of"),
4841
4841
  " ",
4842
- /* @__PURE__ */ t("span", { className: "font-medium text-gray-900", children: Z })
4842
+ /* @__PURE__ */ t("span", { className: "font-medium text-gray-900", children: J })
4843
4843
  ] }),
4844
4844
  /* @__PURE__ */ t(
4845
4845
  "button",
4846
4846
  {
4847
- onClick: () => u(Math.min(Z - 1, l + 1)),
4848
- disabled: l >= Z - 1,
4847
+ onClick: () => u(Math.min(J - 1, l + 1)),
4848
+ disabled: l >= J - 1,
4849
4849
  className: "rounded border border-gray-300 bg-white px-3 py-1 text-sm text-gray-700 hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-40",
4850
4850
  children: e("common.next")
4851
4851
  }
@@ -4857,7 +4857,7 @@ function Us() {
4857
4857
  }
4858
4858
  function Ks() {
4859
4859
  const { t: e } = ne();
4860
- _e(e("titles.stock-balance"));
4860
+ Pe(e("titles.stock-balance"));
4861
4861
  const [n] = le("item_code", ""), [a] = le("warehouse", ""), s = rt(), [o, i] = w(n), [c, l] = w(a), p = Ke(), u = (y) => Ue(y, p), h = be(() => {
4862
4862
  const y = {};
4863
4863
  return n && (y.item_code = n), a && (y.warehouse = a), y;
@@ -4870,7 +4870,7 @@ function Ks() {
4870
4870
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4871
4871
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
4872
4872
  /* @__PURE__ */ t(
4873
- Ae,
4873
+ De,
4874
4874
  {
4875
4875
  label: e("fields.Item Code", { defaultValue: "Item Code" }),
4876
4876
  value: o,
@@ -4880,7 +4880,7 @@ function Ks() {
4880
4880
  }
4881
4881
  ),
4882
4882
  /* @__PURE__ */ t(
4883
- Ae,
4883
+ De,
4884
4884
  {
4885
4885
  label: e("fields.Warehouse", { defaultValue: "Warehouse" }),
4886
4886
  value: c,
@@ -4913,11 +4913,11 @@ function Ks() {
4913
4913
  }
4914
4914
  function js() {
4915
4915
  const { t: e } = ne();
4916
- _e(e("titles.profit-and-loss"));
4916
+ Pe(e("titles.profit-and-loss"));
4917
4917
  const [n] = le("company", ""), [a] = le("from", ""), [s] = le("to", ""), o = rt(), [i, c] = w(n), l = Ke(i), p = (g) => Ue(g, l), [u, h] = w(a), [d, b] = w(s), v = be(() => {
4918
4918
  const g = {};
4919
4919
  return n && (g.company = n), a && (g.from_date = a), s && (g.to_date = s), g;
4920
- }, [n, a, s]), { data: N, isLoading: y, refetch: k } = Es(v), S = () => {
4920
+ }, [n, a, s]), { data: N, isLoading: y, refetch: k } = Es(v), D = () => {
4921
4921
  o({
4922
4922
  company: i || null,
4923
4923
  from: u || null,
@@ -4926,10 +4926,10 @@ function js() {
4926
4926
  }, f = N && (N.income && N.income.length > 0 || N.expense && N.expense.length > 0);
4927
4927
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4928
4928
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
4929
- /* @__PURE__ */ t(Ae, { label: e("fields.Company", { defaultValue: "Company" }), value: i, onChange: c, linkDoctype: "company", readOnly: !1 }),
4929
+ /* @__PURE__ */ t(De, { label: e("fields.Company", { defaultValue: "Company" }), value: i, onChange: c, linkDoctype: "company", readOnly: !1 }),
4930
4930
  /* @__PURE__ */ t(re, { label: e("fields.From Date", { defaultValue: "From Date" }), type: "date", value: u, onChange: (g) => h(g.target.value) }),
4931
4931
  /* @__PURE__ */ t(re, { label: e("fields.To Date", { defaultValue: "To Date" }), type: "date", value: d, onChange: (g) => b(g.target.value) }),
4932
- /* @__PURE__ */ t(K, { onClick: S, children: e("common.apply") })
4932
+ /* @__PURE__ */ t(K, { onClick: D, children: e("common.apply") })
4933
4933
  ] }),
4934
4934
  /* @__PURE__ */ t(Kt, { onSelect: (g, m) => {
4935
4935
  h(g), b(m), o({ from: g, to: m });
@@ -4998,18 +4998,18 @@ function Qt({ title: e, rows: n, total: a, totalLabel: s, currency: o }) {
4998
4998
  ] });
4999
4999
  }
5000
5000
  function Ws() {
5001
- var S, f, g;
5001
+ var D, f, g;
5002
5002
  const { t: e } = ne();
5003
- _e(e("titles.balance-sheet"));
5003
+ Pe(e("titles.balance-sheet"));
5004
5004
  const [n] = le("company", ""), [a] = le("as_of_date", ""), s = rt(), [o, i] = w(n), [c, l] = w(a), p = Ke(o), u = (m) => Ue(m, p), h = be(() => {
5005
5005
  const m = {};
5006
5006
  return n && (m.company = n), a && (m.as_of_date = a), m;
5007
5007
  }, [n, a]), { data: d, isLoading: b, refetch: v } = Ls(h), N = () => {
5008
5008
  s({ company: o || null, as_of_date: c || null }), v();
5009
- }, y = d && (((S = d.assets) == null ? void 0 : S.length) > 0 || ((f = d.liabilities) == null ? void 0 : f.length) > 0 || ((g = d.equity) == null ? void 0 : g.length) > 0), k = d ? Math.abs(d.total_assets - d.total_liabilities_and_equity) < 0.01 : !1;
5009
+ }, y = d && (((D = d.assets) == null ? void 0 : D.length) > 0 || ((f = d.liabilities) == null ? void 0 : f.length) > 0 || ((g = d.equity) == null ? void 0 : g.length) > 0), k = d ? Math.abs(d.total_assets - d.total_liabilities_and_equity) < 0.01 : !1;
5010
5010
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
5011
5011
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
5012
- /* @__PURE__ */ t(Ae, { label: e("fields.Company", { defaultValue: "Company" }), value: o, onChange: i, linkDoctype: "company", readOnly: !1 }),
5012
+ /* @__PURE__ */ t(De, { label: e("fields.Company", { defaultValue: "Company" }), value: o, onChange: i, linkDoctype: "company", readOnly: !1 }),
5013
5013
  /* @__PURE__ */ t(re, { label: e("fields.As of Date", { defaultValue: "As of Date" }), type: "date", value: c, onChange: (m) => l(m.target.value) }),
5014
5014
  /* @__PURE__ */ t(K, { onClick: N, children: e("common.apply") })
5015
5015
  ] }),
@@ -5040,7 +5040,7 @@ function Ws() {
5040
5040
  }
5041
5041
  function Gs() {
5042
5042
  const { t: e } = ne();
5043
- _e(e("titles.ar-aging"));
5043
+ Pe(e("titles.ar-aging"));
5044
5044
  const [n] = le("company", ""), [a] = le("as_of_date", ""), s = rt(), [o, i] = w(n), [c, l] = w(a), p = Ke(o), u = (y) => Ue(y, p), h = be(() => {
5045
5045
  const y = {};
5046
5046
  return n && (y.company = n), a && (y.as_of_date = a), y;
@@ -5049,7 +5049,7 @@ function Gs() {
5049
5049
  };
5050
5050
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
5051
5051
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
5052
- /* @__PURE__ */ t(Ae, { label: e("fields.Company", { defaultValue: "Company" }), value: o, onChange: i, linkDoctype: "company", readOnly: !1 }),
5052
+ /* @__PURE__ */ t(De, { label: e("fields.Company", { defaultValue: "Company" }), value: o, onChange: i, linkDoctype: "company", readOnly: !1 }),
5053
5053
  /* @__PURE__ */ t(re, { label: e("fields.As of Date", { defaultValue: "As of Date" }), type: "date", value: c, onChange: (y) => l(y.target.value) }),
5054
5054
  /* @__PURE__ */ t(K, { onClick: N, children: e("common.apply") })
5055
5055
  ] }),
@@ -5070,7 +5070,7 @@ function Gs() {
5070
5070
  ] }) }),
5071
5071
  /* @__PURE__ */ t("tbody", { className: "divide-y divide-gray-100", children: d.rows.map((y, k) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
5072
5072
  /* @__PURE__ */ t("td", { className: "px-3 py-2", children: /* @__PURE__ */ t(
5073
- De,
5073
+ Ce,
5074
5074
  {
5075
5075
  to: `/app/sales-invoice/${encodeURIComponent(y.invoice)}`,
5076
5076
  className: "font-medium text-blue-600 hover:text-blue-800",
@@ -5100,7 +5100,7 @@ function Gs() {
5100
5100
  }
5101
5101
  function Hs() {
5102
5102
  const { t: e } = ne();
5103
- _e(e("titles.ap-aging"));
5103
+ Pe(e("titles.ap-aging"));
5104
5104
  const [n] = le("company", ""), [a] = le("as_of_date", ""), s = rt(), [o, i] = w(n), [c, l] = w(a), p = Ke(o), u = (y) => Ue(y, p), h = be(() => {
5105
5105
  const y = {};
5106
5106
  return n && (y.company = n), a && (y.as_of_date = a), y;
@@ -5109,7 +5109,7 @@ function Hs() {
5109
5109
  };
5110
5110
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
5111
5111
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
5112
- /* @__PURE__ */ t(Ae, { label: e("fields.Company", { defaultValue: "Company" }), value: o, onChange: i, linkDoctype: "company", readOnly: !1 }),
5112
+ /* @__PURE__ */ t(De, { label: e("fields.Company", { defaultValue: "Company" }), value: o, onChange: i, linkDoctype: "company", readOnly: !1 }),
5113
5113
  /* @__PURE__ */ t(re, { label: e("fields.As of Date", { defaultValue: "As of Date" }), type: "date", value: c, onChange: (y) => l(y.target.value) }),
5114
5114
  /* @__PURE__ */ t(K, { onClick: N, children: e("common.apply") })
5115
5115
  ] }),
@@ -5130,7 +5130,7 @@ function Hs() {
5130
5130
  ] }) }),
5131
5131
  /* @__PURE__ */ t("tbody", { className: "divide-y divide-gray-100", children: d.rows.map((y, k) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
5132
5132
  /* @__PURE__ */ t("td", { className: "px-3 py-2", children: /* @__PURE__ */ t(
5133
- De,
5133
+ Ce,
5134
5134
  {
5135
5135
  to: `/app/purchase-invoice/${encodeURIComponent(y.invoice)}`,
5136
5136
  className: "font-medium text-blue-600 hover:text-blue-800",
@@ -5253,41 +5253,41 @@ return {
5253
5253
  }
5254
5254
  const Ba = Qs();
5255
5255
  function Js() {
5256
- _e("Analytics");
5257
- const e = Me(), { sessions: n, createSession: a } = bt(), [s] = le("report_id", ""), [o] = le("metric", ""), [i] = le("group_by", ""), [c] = le("from", ""), [l] = le("to", ""), [p] = le("company", ""), [u, h] = w(Ba), [d, b] = w([]), [v, N] = w(null), [y, k] = w(""), [S, f] = w(!1), [g, m] = w(!1), [D, T] = w(""), V = ie(null), X = ie(""), P = ie(""), O = ie(0), Z = be(() => !o || !i ? "" : JSON.stringify(ti({
5256
+ Pe("Analytics");
5257
+ const e = Fe(), { sessions: n, createSession: a } = yt(), [s] = le("report_id", ""), [o] = le("metric", ""), [i] = le("group_by", ""), [c] = le("from", ""), [l] = le("to", ""), [p] = le("company", ""), [u, h] = w(Ba), [d, b] = w([]), [v, N] = w(null), [y, k] = w(""), [D, f] = w(!1), [g, m] = w(!1), [A, T] = w(""), V = ie(null), X = ie(""), _ = ie(""), O = ie(0), J = be(() => !o || !i ? "" : JSON.stringify(ti({
5258
5258
  metric: o,
5259
5259
  groupBy: i,
5260
5260
  fromDate: c || void 0,
5261
5261
  toDate: l || void 0,
5262
5262
  company: p || void 0
5263
5263
  }), null, 2), [o, i, c, l, p]), x = async (q) => {
5264
- var me;
5264
+ var he;
5265
5265
  const j = ++O.current, oe = () => O.current === j;
5266
5266
  k(""), f(!0);
5267
5267
  try {
5268
- const ve = JSON.parse(q ?? u), Re = await B.runtimeData({ requests: ve.data_requests || [] });
5268
+ const ve = JSON.parse(q ?? u), _e = await B.runtimeData({ requests: ve.data_requests || [] });
5269
5269
  if (!oe()) return;
5270
- b(Re.datasets), (me = V.current) == null || me.terminate();
5270
+ b(_e.datasets), (he = V.current) == null || he.terminate();
5271
5271
  const ge = new Ys();
5272
5272
  V.current = ge;
5273
- const ze = await new Promise(($e, E) => {
5274
- const ue = window.setTimeout(() => {
5273
+ const $e = await new Promise((Ve, E) => {
5274
+ const ce = window.setTimeout(() => {
5275
5275
  ge.terminate(), E(new Error("Report runtime exceeded 4 seconds"));
5276
5276
  }, 4e3);
5277
- ge.onmessage = (Ie) => {
5278
- var Ce, Ve;
5279
- window.clearTimeout(ue), ge.terminate(), V.current === ge && (V.current = null), (Ce = Ie.data) != null && Ce.ok ? $e(Ie.data.output) : E(new Error(((Ve = Ie.data) == null ? void 0 : Ve.error) || "Runtime failed"));
5277
+ ge.onmessage = (Re) => {
5278
+ var Ie, Me;
5279
+ window.clearTimeout(ce), ge.terminate(), V.current === ge && (V.current = null), (Ie = Re.data) != null && Ie.ok ? Ve(Re.data.output) : E(new Error(((Me = Re.data) == null ? void 0 : Me.error) || "Runtime failed"));
5280
5280
  }, ge.postMessage({
5281
- datasets: Re.datasets,
5281
+ datasets: _e.datasets,
5282
5282
  params: {},
5283
5283
  transformJs: ve.transform_js || "return {};"
5284
5284
  });
5285
5285
  });
5286
5286
  if (!oe()) return;
5287
- N(ze);
5288
- } catch (Te) {
5287
+ N($e);
5288
+ } catch (Se) {
5289
5289
  if (!oe()) return;
5290
- N(null), k(Te instanceof Error ? Te.message : String(Te));
5290
+ N(null), k(Se instanceof Error ? Se.message : String(Se));
5291
5291
  } finally {
5292
5292
  oe() && f(!1);
5293
5293
  }
@@ -5297,53 +5297,53 @@ function Js() {
5297
5297
  return s ? X.current === s ? void 0 : (m(!0), k(""), B.getRuntimeDraft(s).then((j) => {
5298
5298
  if (q) return;
5299
5299
  const oe = JSON.stringify(j.definition, null, 2);
5300
- return X.current = s, P.current = oe, T(j.source_chat_session_id || ""), h(oe), x(oe);
5300
+ return X.current = s, _.current = oe, T(j.source_chat_session_id || ""), h(oe), x(oe);
5301
5301
  }).catch((j) => {
5302
5302
  q || (N(null), k(j instanceof Error ? j.message : String(j)));
5303
5303
  }).finally(() => {
5304
5304
  q || m(!1);
5305
5305
  }), () => {
5306
5306
  q = !0;
5307
- }) : (X.current = "", P.current = "", T(""), Z && (P.current = Z, h(Z), x(Z)), () => {
5307
+ }) : (X.current = "", _.current = "", T(""), J && (_.current = J, h(J), x(J)), () => {
5308
5308
  q = !0;
5309
5309
  });
5310
- }, [s, Z]);
5311
- const W = !!(!s && Z), A = be(() => ei(v), [v]), R = async () => {
5312
- var Re;
5313
- const q = u.trim() !== P.current.trim(), j = s || "unsaved-runtime-report", oe = d.map((ge) => ({
5310
+ }, [s, J]);
5311
+ const G = !!(!s && J), P = be(() => ei(v), [v]), R = async () => {
5312
+ var _e;
5313
+ const q = u.trim() !== _.current.trim(), j = s || "unsaved-runtime-report", oe = d.map((ge) => ({
5314
5314
  name: ge.name,
5315
5315
  dataset: ge.dataset,
5316
5316
  row_count: ge.row_count,
5317
5317
  sample_rows: ge.rows.slice(0, 3)
5318
- })), me = [
5318
+ })), he = [
5319
5319
  "This custom analytics report does not work yet. Please repair the existing report draft instead of creating a new one.",
5320
5320
  "",
5321
5321
  `Report ID: ${j}`,
5322
5322
  "",
5323
5323
  "Current issue summary:",
5324
- y || A.join(`
5324
+ y || P.join(`
5325
5325
  `) || "No runtime error captured; please review and improve the report definition."
5326
5326
  ];
5327
- q ? me.push(
5327
+ q ? he.push(
5328
5328
  "",
5329
5329
  "The analytics editor contains unsaved local changes. Use this JSON as the source of truth when repairing the draft:",
5330
5330
  "```json",
5331
5331
  u,
5332
5332
  "```"
5333
- ) : me.push(
5333
+ ) : he.push(
5334
5334
  "",
5335
5335
  "Load the current saved draft with `get_custom_analytics_report` before making changes."
5336
- ), oe.length > 0 && me.push(
5336
+ ), oe.length > 0 && he.push(
5337
5337
  "",
5338
5338
  "Fetched dataset preview:",
5339
5339
  "```json",
5340
5340
  JSON.stringify(oe, null, 2),
5341
5341
  "```"
5342
5342
  );
5343
- const Te = me.join(`
5343
+ const Se = he.join(`
5344
5344
  `);
5345
- let ve = D;
5346
- ve || (ve = ((Re = n[0]) == null ? void 0 : Re.id) || ""), ve || (ve = (await a()).id), e(`/chat/${ve}`, { state: { prefillMessage: Te } });
5345
+ let ve = A;
5346
+ ve || (ve = ((_e = n[0]) == null ? void 0 : _e.id) || ""), ve || (ve = (await a()).id), e(`/chat/${ve}`, { state: { prefillMessage: Se } });
5347
5347
  };
5348
5348
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
5349
5349
  /* @__PURE__ */ t($, { children: /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center justify-between gap-3", children: [
@@ -5355,9 +5355,9 @@ function Js() {
5355
5355
  s ? /* @__PURE__ */ r("div", { className: "text-xs text-gray-500", children: [
5356
5356
  "Loaded draft: ",
5357
5357
  s
5358
- ] }) : W ? /* @__PURE__ */ t("div", { className: "text-xs text-gray-500", children: "Loaded runtime report from legacy URL filters." }) : null,
5358
+ ] }) : G ? /* @__PURE__ */ t("div", { className: "text-xs text-gray-500", children: "Loaded runtime report from legacy URL filters." }) : null,
5359
5359
  s ? /* @__PURE__ */ t(K, { variant: "secondary", onClick: () => void R(), children: "Fix In Chat" }) : null,
5360
- /* @__PURE__ */ t(K, { onClick: () => void x(), disabled: S, children: S ? "Running..." : "Run Report" })
5360
+ /* @__PURE__ */ t(K, { onClick: () => void x(), disabled: D, children: D ? "Running..." : "Run Report" })
5361
5361
  ] })
5362
5362
  ] }) }),
5363
5363
  g ? /* @__PURE__ */ t($, { children: /* @__PURE__ */ t("p", { className: "text-sm text-gray-600", children: "Loading draft..." }) }) : y ? /* @__PURE__ */ t($, { children: /* @__PURE__ */ t("p", { className: "text-sm text-red-600", children: y }) }) : v ? /* @__PURE__ */ t(Zs, { output: v }) : /* @__PURE__ */ t($, { children: /* @__PURE__ */ t("p", { className: "text-sm text-gray-600", children: "Edit the runtime JSON below or open a draft from chat, then run the report." }) }),
@@ -5659,7 +5659,7 @@ function Jt(e, n) {
5659
5659
  return ((a = e == null ? void 0 : e.columns.find((o) => o.key === n)) == null ? void 0 : a.type) || ((s = e == null ? void 0 : e.columns.find((o) => o.key === n)) == null ? void 0 : s.format);
5660
5660
  }
5661
5661
  function St(e, n, a) {
5662
- return n === "currency" ? Ue(Ye(e), a) : n === "percent" ? `${(Ye(e) * 100).toFixed(1)}%` : n === "number" ? rn(Ye(e)) : n === "date" ? Ut(String(e ?? "")) : typeof e == "number" ? rn(e) : String(e ?? "");
5662
+ return n === "currency" ? Ue(Ge(e), a) : n === "percent" ? `${(Ge(e) * 100).toFixed(1)}%` : n === "number" ? rn(Ge(e)) : n === "date" ? Ut(String(e ?? "")) : typeof e == "number" ? rn(e) : String(e ?? "");
5663
5663
  }
5664
5664
  function Wn(e) {
5665
5665
  const n = Math.abs(e);
@@ -5682,7 +5682,7 @@ function si(e) {
5682
5682
  return { angle: s, axisHeight: c, maxWidth: a };
5683
5683
  }
5684
5684
  function ii(e) {
5685
- return ce({
5685
+ return de({
5686
5686
  queryKey: ["fleet-calendar", e],
5687
5687
  queryFn: () => B.fleetCalendar(e)
5688
5688
  });
@@ -5715,36 +5715,36 @@ const oi = {
5715
5715
  };
5716
5716
  function ci() {
5717
5717
  const { t: e } = ne();
5718
- _e(e("rentals.fleetCalendar", { defaultValue: "Fleet Calendar" }));
5719
- const n = Me(), [a, s] = w(28), [o, i] = w(Hn()), [c, l] = w(""), [p, u] = w(""), [h, d] = w(""), [b, v] = w(""), N = be(() => tn(o, a), [o, a]), y = o.getTime(), k = a * La, S = be(
5720
- () => Array.from({ length: a }, (x, W) => tn(o, W)),
5718
+ Pe(e("rentals.fleetCalendar", { defaultValue: "Fleet Calendar" }));
5719
+ const n = Fe(), [a, s] = w(28), [o, i] = w(Hn()), [c, l] = w(""), [p, u] = w(""), [h, d] = w(""), [b, v] = w(""), N = be(() => tn(o, a), [o, a]), y = o.getTime(), k = a * La, D = be(
5720
+ () => Array.from({ length: a }, (x, G) => tn(o, G)),
5721
5721
  [o, a]
5722
5722
  ), { data: f, isLoading: g, error: m } = ii({
5723
5723
  from: Et(o),
5724
5724
  to: Et(N),
5725
5725
  warehouse: h || void 0,
5726
5726
  item_code: b || void 0
5727
- }), D = (f == null ? void 0 : f.assets) ?? [], T = be(() => {
5727
+ }), A = (f == null ? void 0 : f.assets) ?? [], T = be(() => {
5728
5728
  const x = /* @__PURE__ */ new Map();
5729
- for (const W of (f == null ? void 0 : f.reservations) ?? []) {
5730
- if (!W.asset) continue;
5731
- const A = x.get(W.asset) ?? [];
5732
- A.push(W), x.set(W.asset, A);
5729
+ for (const G of (f == null ? void 0 : f.reservations) ?? []) {
5730
+ if (!G.asset) continue;
5731
+ const P = x.get(G.asset) ?? [];
5732
+ P.push(G), x.set(G.asset, P);
5733
5733
  }
5734
5734
  return x;
5735
5735
  }, [f]), V = ((f == null ? void 0 : f.reservations) ?? []).filter((x) => !x.asset).length;
5736
5736
  function X(x) {
5737
- const W = Yn(x.from_datetime), A = Yn(x.to_datetime), R = Math.max(0, W - y), q = Math.min(k, A - y), j = R / k * 100, oe = Math.max(0.6, (q - R) / k * 100);
5737
+ const G = Yn(x.from_datetime), P = Yn(x.to_datetime), R = Math.max(0, G - y), q = Math.min(k, P - y), j = R / k * 100, oe = Math.max(0.6, (q - R) / k * 100);
5738
5738
  return { left: j, width: oe };
5739
5739
  }
5740
- const P = () => {
5740
+ const _ = () => {
5741
5741
  d(c), v(p);
5742
- }, O = (x) => i((W) => tn(W, x)), Z = a * Xt;
5742
+ }, O = (x) => i((G) => tn(G, x)), J = a * Xt;
5743
5743
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
5744
5744
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-3", children: [
5745
- /* @__PURE__ */ t(Ae, { label: e("rentals.yard", { defaultValue: "Yard" }), value: c, onChange: l, linkDoctype: "warehouse", readOnly: !1 }),
5746
- /* @__PURE__ */ t(Ae, { label: e("rentals.machineType", { defaultValue: "Machine type" }), value: p, onChange: u, linkDoctype: "item", readOnly: !1 }),
5747
- /* @__PURE__ */ t(K, { onClick: P, children: e("common.apply", { defaultValue: "Apply" }) }),
5745
+ /* @__PURE__ */ t(De, { label: e("rentals.yard", { defaultValue: "Yard" }), value: c, onChange: l, linkDoctype: "warehouse", readOnly: !1 }),
5746
+ /* @__PURE__ */ t(De, { label: e("rentals.machineType", { defaultValue: "Machine type" }), value: p, onChange: u, linkDoctype: "item", readOnly: !1 }),
5747
+ /* @__PURE__ */ t(K, { onClick: _, children: e("common.apply", { defaultValue: "Apply" }) }),
5748
5748
  /* @__PURE__ */ r("div", { className: "ml-auto flex items-center gap-2", children: [
5749
5749
  /* @__PURE__ */ r(K, { variant: "secondary", onClick: () => O(-a), children: [
5750
5750
  "‹ ",
@@ -5799,16 +5799,16 @@ function ci() {
5799
5799
  e("rentals.pooledNote", { count: V, defaultValue: "{{count}} pooled booking(s) not shown on a unit lane" })
5800
5800
  ] })
5801
5801
  ] }),
5802
- m ? /* @__PURE__ */ t("p", { className: "py-8 text-center text-red-500", children: e("rentals.loadError", { defaultValue: "Could not load the fleet calendar." }) }) : g ? /* @__PURE__ */ t("p", { className: "py-8 text-center text-gray-400", children: e("common.loading", { defaultValue: "Loading…" }) }) : D.length === 0 ? /* @__PURE__ */ t("p", { className: "py-8 text-center text-gray-400", children: e("rentals.noAssets", { defaultValue: "No assets to show. Add machines under Rentals → Fleet." }) }) : /* @__PURE__ */ t($, { children: /* @__PURE__ */ t("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("div", { style: { minWidth: en + Z }, children: [
5802
+ m ? /* @__PURE__ */ t("p", { className: "py-8 text-center text-red-500", children: e("rentals.loadError", { defaultValue: "Could not load the fleet calendar." }) }) : g ? /* @__PURE__ */ t("p", { className: "py-8 text-center text-gray-400", children: e("common.loading", { defaultValue: "Loading…" }) }) : A.length === 0 ? /* @__PURE__ */ t("p", { className: "py-8 text-center text-gray-400", children: e("rentals.noAssets", { defaultValue: "No assets to show. Add machines under Rentals → Fleet." }) }) : /* @__PURE__ */ t($, { children: /* @__PURE__ */ t("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("div", { style: { minWidth: en + J }, children: [
5803
5803
  /* @__PURE__ */ r("div", { className: "flex border-b bg-gray-50 text-xs text-gray-500", children: [
5804
5804
  /* @__PURE__ */ t("div", { className: "shrink-0 px-3 py-2 font-medium", style: { width: en }, children: e("rentals.machine", { defaultValue: "Machine" }) }),
5805
- /* @__PURE__ */ t("div", { className: "flex", style: { width: Z }, children: S.map((x) => /* @__PURE__ */ r("div", { className: "shrink-0 border-l py-2 text-center", style: { width: Xt }, children: [
5805
+ /* @__PURE__ */ t("div", { className: "flex", style: { width: J }, children: D.map((x) => /* @__PURE__ */ r("div", { className: "shrink-0 border-l py-2 text-center", style: { width: Xt }, children: [
5806
5806
  /* @__PURE__ */ t("div", { children: x.getDate() }),
5807
5807
  /* @__PURE__ */ t("div", { className: "text-[10px] uppercase", children: x.toLocaleDateString(void 0, { weekday: "short" }) })
5808
5808
  ] }, x.getTime())) })
5809
5809
  ] }),
5810
- D.map((x) => {
5811
- const W = T.get(x.name) ?? [];
5810
+ A.map((x) => {
5811
+ const G = T.get(x.name) ?? [];
5812
5812
  return /* @__PURE__ */ r("div", { className: "flex border-b hover:bg-gray-50", children: [
5813
5813
  /* @__PURE__ */ r("div", { className: "shrink-0 px-3 py-2", style: { width: en }, children: [
5814
5814
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2 text-sm font-medium", children: [
@@ -5821,20 +5821,20 @@ function ci() {
5821
5821
  x.warehouse ?? "—"
5822
5822
  ] })
5823
5823
  ] }),
5824
- /* @__PURE__ */ r("div", { className: "relative", style: { width: Z, height: 44 }, children: [
5825
- /* @__PURE__ */ t("div", { className: "absolute inset-0 flex", children: S.map((A) => /* @__PURE__ */ t("div", { className: "shrink-0 border-l", style: { width: Xt } }, A.getTime())) }),
5826
- W.map((A) => {
5827
- const { left: R, width: q } = X(A), j = oi[A.status ?? ""] ?? "bg-slate-400 text-white";
5824
+ /* @__PURE__ */ r("div", { className: "relative", style: { width: J, height: 44 }, children: [
5825
+ /* @__PURE__ */ t("div", { className: "absolute inset-0 flex", children: D.map((P) => /* @__PURE__ */ t("div", { className: "shrink-0 border-l", style: { width: Xt } }, P.getTime())) }),
5826
+ G.map((P) => {
5827
+ const { left: R, width: q } = X(P), j = oi[P.status ?? ""] ?? "bg-slate-400 text-white";
5828
5828
  return /* @__PURE__ */ t(
5829
5829
  "button",
5830
5830
  {
5831
- onClick: () => n(`/app/reservation/${encodeURIComponent(A.name)}`),
5832
- title: `${A.party ?? "—"} · ${A.from_datetime} → ${A.to_datetime}${A.purpose ? ` · ${A.purpose}` : ""}`,
5831
+ onClick: () => n(`/app/reservation/${encodeURIComponent(P.name)}`),
5832
+ title: `${P.party ?? "—"} · ${P.from_datetime} → ${P.to_datetime}${P.purpose ? ` · ${P.purpose}` : ""}`,
5833
5833
  className: `absolute top-1.5 h-8 overflow-hidden truncate rounded px-2 text-left text-xs ${j}`,
5834
5834
  style: { left: `${R}%`, width: `${q}%` },
5835
- children: A.party ?? A.status
5835
+ children: P.party ?? P.status
5836
5836
  },
5837
- A.name
5837
+ P.name
5838
5838
  );
5839
5839
  })
5840
5840
  ] })
@@ -5845,8 +5845,8 @@ function ci() {
5845
5845
  }
5846
5846
  const di = ["USD", "EUR", "GBP", "CHF", "JPY", "CAD", "AUD", "CNY", "INR"];
5847
5847
  function ui() {
5848
- _e("Company Setup");
5849
- const e = Ze(), { data: n, isLoading: a } = ce({
5848
+ Pe("Company Setup");
5849
+ const e = Qe(), { data: n, isLoading: a } = de({
5850
5850
  queryKey: ["setup-status"],
5851
5851
  queryFn: () => B.setupStatus()
5852
5852
  }), [s, o] = w(""), [i, c] = w("USD"), [l, p] = w({
@@ -5857,11 +5857,11 @@ function ui() {
5857
5857
  email: "",
5858
5858
  phone: "",
5859
5859
  tax_id: ""
5860
- }), u = (T) => (V) => p((X) => ({ ...X, [T]: V.target.value })), [h, d] = w("quick"), [b, v] = w(!1), [N, y] = w(null), k = de({
5860
+ }), u = (T) => (V) => p((X) => ({ ...X, [T]: V.target.value })), [h, d] = w("quick"), [b, v] = w(!1), [N, y] = w(null), k = ue({
5861
5861
  mutationFn: () => B.createCompany({ name: s, currency: i, ...l })
5862
- }), S = de({
5862
+ }), D = ue({
5863
5863
  mutationFn: () => B.seedDemo()
5864
- }), f = de({
5864
+ }), f = ue({
5865
5865
  mutationFn: () => B.seedHistory()
5866
5866
  }), g = async () => {
5867
5867
  if (s.trim())
@@ -5869,7 +5869,7 @@ function ui() {
5869
5869
  if (await k.mutateAsync(), h === "history") {
5870
5870
  const T = await f.mutateAsync();
5871
5871
  y(T.stats);
5872
- } else h === "quick" && await S.mutateAsync();
5872
+ } else h === "quick" && await D.mutateAsync();
5873
5873
  e.invalidateQueries({ queryKey: ["setup-status"] }), v(!0);
5874
5874
  } catch {
5875
5875
  }
@@ -5879,7 +5879,7 @@ function ui() {
5879
5879
  if (n != null && n.setup_complete && !b)
5880
5880
  return /* @__PURE__ */ r("div", { className: "space-y-6", children: [
5881
5881
  /* @__PURE__ */ t($, { title: "Companies", children: n.companies && n.companies.length > 0 ? /* @__PURE__ */ t("ul", { className: "divide-y divide-gray-100", children: n.companies.map((T, V) => /* @__PURE__ */ t("li", { className: "py-3", children: /* @__PURE__ */ t(mi, { company: T }) }, V)) }) : /* @__PURE__ */ t("p", { className: "text-gray-400", children: "No companies found" }) }),
5882
- /* @__PURE__ */ t(De, { to: "/", className: "text-blue-600 hover:text-blue-800 text-sm font-medium", children: "Go to Dashboard" })
5882
+ /* @__PURE__ */ t(Ce, { to: "/", className: "text-blue-600 hover:text-blue-800 text-sm font-medium", children: "Go to Dashboard" })
5883
5883
  ] });
5884
5884
  if (b)
5885
5885
  return /* @__PURE__ */ t("div", { className: "space-y-6", children: /* @__PURE__ */ t($, { children: /* @__PURE__ */ r("div", { className: "py-8 text-center", children: [
@@ -5892,12 +5892,12 @@ function ui() {
5892
5892
  /* @__PURE__ */ t("span", { className: "font-mono text-gray-900", children: V.toLocaleString() })
5893
5893
  ] }, T)) })
5894
5894
  ] }),
5895
- /* @__PURE__ */ t("div", { className: "mt-6", children: /* @__PURE__ */ t(De, { to: "/", children: /* @__PURE__ */ t(K, { children: "Go to Dashboard" }) }) })
5895
+ /* @__PURE__ */ t("div", { className: "mt-6", children: /* @__PURE__ */ t(Ce, { to: "/", children: /* @__PURE__ */ t(K, { children: "Go to Dashboard" }) }) })
5896
5896
  ] }) }) });
5897
- const m = k.isPending || S.isPending || f.isPending, D = k.error ?? S.error ?? f.error;
5897
+ const m = k.isPending || D.isPending || f.isPending, A = k.error ?? D.error ?? f.error;
5898
5898
  return /* @__PURE__ */ r("div", { className: "mx-auto max-w-lg space-y-6", children: [
5899
5899
  /* @__PURE__ */ t("p", { className: "text-sm text-gray-500", children: "Set up your first company to get started." }),
5900
- D && /* @__PURE__ */ t("div", { className: "rounded-md bg-red-50 p-4 text-sm text-red-700", children: D.message ?? "An error occurred during setup" }),
5900
+ A && /* @__PURE__ */ t("div", { className: "rounded-md bg-red-50 p-4 text-sm text-red-700", children: A.message ?? "An error occurred during setup" }),
5901
5901
  /* @__PURE__ */ t($, { children: /* @__PURE__ */ r("div", { className: "space-y-4", children: [
5902
5902
  /* @__PURE__ */ t(
5903
5903
  re,
@@ -5910,7 +5910,7 @@ function ui() {
5910
5910
  }
5911
5911
  ),
5912
5912
  /* @__PURE__ */ t(
5913
- Je,
5913
+ Ye,
5914
5914
  {
5915
5915
  label: "Currency",
5916
5916
  options: di,
@@ -6017,15 +6017,15 @@ function mi({ company: e }) {
6017
6017
  /* @__PURE__ */ r("div", { className: "min-w-0 space-y-1", children: [
6018
6018
  /* @__PURE__ */ t("div", { className: "font-medium text-gray-900", children: e.company_name || e.name }),
6019
6019
  /* @__PURE__ */ r("dl", { className: "grid grid-cols-[auto,1fr] gap-x-3 gap-y-0.5 text-xs text-gray-500", children: [
6020
- e.address && /* @__PURE__ */ r(Pe, { children: [
6020
+ e.address && /* @__PURE__ */ r(Ae, { children: [
6021
6021
  /* @__PURE__ */ t("dt", { className: "text-gray-400", children: "Address" }),
6022
6022
  /* @__PURE__ */ t("dd", { className: "text-gray-700", children: e.address })
6023
6023
  ] }),
6024
- n && /* @__PURE__ */ r(Pe, { children: [
6024
+ n && /* @__PURE__ */ r(Ae, { children: [
6025
6025
  /* @__PURE__ */ t("dt", { className: "text-gray-400", children: "Location" }),
6026
6026
  /* @__PURE__ */ t("dd", { className: "text-gray-700", children: n })
6027
6027
  ] }),
6028
- e.email && /* @__PURE__ */ r(Pe, { children: [
6028
+ e.email && /* @__PURE__ */ r(Ae, { children: [
6029
6029
  /* @__PURE__ */ t("dt", { className: "text-gray-400", children: "Email" }),
6030
6030
  /* @__PURE__ */ t("dd", { className: "truncate text-gray-700", children: /* @__PURE__ */ t(
6031
6031
  "a",
@@ -6036,11 +6036,11 @@ function mi({ company: e }) {
6036
6036
  }
6037
6037
  ) })
6038
6038
  ] }),
6039
- e.phone && /* @__PURE__ */ r(Pe, { children: [
6039
+ e.phone && /* @__PURE__ */ r(Ae, { children: [
6040
6040
  /* @__PURE__ */ t("dt", { className: "text-gray-400", children: "Phone" }),
6041
6041
  /* @__PURE__ */ t("dd", { className: "text-gray-700", children: e.phone })
6042
6042
  ] }),
6043
- e.tax_id && /* @__PURE__ */ r(Pe, { children: [
6043
+ e.tax_id && /* @__PURE__ */ r(Ae, { children: [
6044
6044
  /* @__PURE__ */ t("dt", { className: "text-gray-400", children: "Tax ID" }),
6045
6045
  /* @__PURE__ */ t("dd", { className: "font-mono text-gray-700", children: e.tax_id })
6046
6046
  ] })
@@ -6187,7 +6187,7 @@ const pi = [
6187
6187
  }
6188
6188
  ];
6189
6189
  function Oa() {
6190
- const e = Me(), { sessions: n, createSession: a } = bt();
6190
+ const e = Fe(), { sessions: n, createSession: a } = yt();
6191
6191
  return async (s) => {
6192
6192
  var i;
6193
6193
  let o = ((i = n[0]) == null ? void 0 : i.id) || "";
@@ -6228,7 +6228,7 @@ function hi() {
6228
6228
  /* @__PURE__ */ r("span", { className: "text-xs text-gray-500", children: [
6229
6229
  e("tutorial.setupManual"),
6230
6230
  " ",
6231
- /* @__PURE__ */ r(De, { to: "/setup", className: "font-medium text-emerald-700 hover:text-emerald-900", children: [
6231
+ /* @__PURE__ */ r(Ce, { to: "/setup", className: "font-medium text-emerald-700 hover:text-emerald-900", children: [
6232
6232
  e("tutorial.setupManualLink"),
6233
6233
  " →"
6234
6234
  ] })
@@ -6282,7 +6282,7 @@ function gi() {
6282
6282
  }
6283
6283
  ),
6284
6284
  /* @__PURE__ */ r(
6285
- De,
6285
+ Ce,
6286
6286
  {
6287
6287
  to: "/reports/analytics",
6288
6288
  className: "text-sm font-medium text-indigo-700 hover:text-indigo-900",
@@ -6405,12 +6405,12 @@ function yi() {
6405
6405
  }
6406
6406
  function bi() {
6407
6407
  const { t: e } = ne();
6408
- return _e(e("titles.tutorial")), /* @__PURE__ */ r("div", { className: "mx-auto max-w-3xl space-y-6", children: [
6408
+ return Pe(e("titles.tutorial")), /* @__PURE__ */ r("div", { className: "mx-auto max-w-3xl space-y-6", children: [
6409
6409
  /* @__PURE__ */ r("div", { children: [
6410
6410
  /* @__PURE__ */ t("h2", { className: "text-xl font-semibold text-gray-900", children: e("tutorial.pageTitle") }),
6411
6411
  /* @__PURE__ */ t("p", { className: "mt-1 text-sm text-gray-500", children: e("tutorial.intro") }),
6412
6412
  /* @__PURE__ */ r(
6413
- De,
6413
+ Ce,
6414
6414
  {
6415
6415
  to: "/chat",
6416
6416
  className: "mt-3 inline-flex items-center gap-2 rounded-lg bg-blue-600 px-4 py-2 text-sm font-medium text-white hover:bg-blue-700",
@@ -6445,7 +6445,7 @@ function bi() {
6445
6445
  ] }),
6446
6446
  /* @__PURE__ */ r("div", { className: "flex flex-wrap gap-3 pt-1", children: [
6447
6447
  n.link && n.linkLabel && /* @__PURE__ */ r(
6448
- De,
6448
+ Ce,
6449
6449
  {
6450
6450
  to: n.link,
6451
6451
  className: "text-sm font-medium text-blue-600 hover:text-blue-800",
@@ -6456,7 +6456,7 @@ function bi() {
6456
6456
  }
6457
6457
  ),
6458
6458
  (a = n.links) == null ? void 0 : a.map((s) => /* @__PURE__ */ r(
6459
- De,
6459
+ Ce,
6460
6460
  {
6461
6461
  to: s.to,
6462
6462
  className: "text-sm font-medium text-blue-600 hover:text-blue-800",
@@ -6478,7 +6478,7 @@ function bi() {
6478
6478
  /* @__PURE__ */ t("p", { className: "text-sm leading-relaxed text-gray-600", children: e("tutorial.readyBody1") }),
6479
6479
  /* @__PURE__ */ t("p", { className: "text-sm leading-relaxed text-gray-600", children: e("tutorial.readyBody2") }),
6480
6480
  /* @__PURE__ */ r(
6481
- De,
6481
+ Ce,
6482
6482
  {
6483
6483
  to: "/chat",
6484
6484
  className: "inline-block text-sm font-medium text-blue-600 hover:text-blue-800",
@@ -6575,82 +6575,82 @@ function Jn(e) {
6575
6575
  }
6576
6576
  function Zn() {
6577
6577
  var kn;
6578
- const { t: e } = ne(), { sessionId: n } = yt(), a = Me(), s = Nt(), [o] = Vt(), i = o.get("demo") === "1", [c, l] = w(""), [p, u] = w(""), [h, d] = w([]), [b, v] = w(""), [N, y] = w(!1), [k, S] = w("idle"), f = ie(null), g = ie(null), m = ie([]), {
6579
- sessions: D,
6578
+ const { t: e } = ne(), { sessionId: n } = ft(), a = Fe(), s = Nt(), [o] = Vt(), i = o.get("demo") === "1", [c, l] = w(""), [p, u] = w(""), [h, d] = w([]), [b, v] = w(""), [N, y] = w(!1), [k, D] = w("idle"), f = ie(null), g = ie(null), m = ie([]), {
6579
+ sessions: A,
6580
6580
  connectionStatus: T,
6581
6581
  connectionVersion: V,
6582
6582
  createSession: X,
6583
- startDemo: P,
6583
+ startDemo: _,
6584
6584
  completeDemoTyping: O,
6585
- loadHistory: Z,
6585
+ loadHistory: J,
6586
6586
  loadMoreHistory: x,
6587
- sendMessage: W,
6588
- transcribeAudio: A,
6587
+ sendMessage: G,
6588
+ transcribeAudio: P,
6589
6589
  getMessages: R,
6590
6590
  hasMoreHistory: q,
6591
6591
  isLoadingOlder: j,
6592
6592
  isThinking: oe,
6593
- getDemoStatus: me,
6594
- getDemoTypingCue: Te
6595
- } = bt(), ve = ie(null), Re = ie(null), ge = ie(null), ze = ie(null), [$e, E] = w(0), ue = ie(!1), Ie = ie(null), Ce = ie(0), Ve = ie(!0), Ge = ie(null), st = ie(!1), it = ie(null), He = R(n), _ = (kn = D.find((C) => C.id === n)) == null ? void 0 : kn.title;
6596
- _e(_ || null);
6597
- const M = T === "connected", G = oe(n), H = me(n), xe = Te(n), he = i || H === "running", je = q(n), I = j(n), Q = He[He.length - 1], ee = Q ? `${Q.type}:${Q.timestamp || ""}:${Q.content}` : "empty", Ne = Le(() => {
6598
- st.current = !0, it.current !== null && window.clearTimeout(it.current), it.current = window.setTimeout(() => {
6599
- st.current = !1, it.current = null;
6593
+ getDemoStatus: he,
6594
+ getDemoTypingCue: Se
6595
+ } = yt(), ve = ie(null), _e = ie(null), ge = ie(null), $e = ie(null), [Ve, E] = w(0), ce = ie(!1), Re = ie(null), Ie = ie(0), Me = ie(!0), We = ie(null), st = ie(!1), et = ie(null), Je = R(n), bt = (kn = A.find((C) => C.id === n)) == null ? void 0 : kn.title;
6596
+ Pe(bt || null);
6597
+ const S = T === "connected", M = oe(n), Z = he(n), Y = Se(n), me = i || Z === "running", Te = q(n), I = j(n), W = Je[Je.length - 1], ee = W ? `${W.type}:${W.timestamp || ""}:${W.content}` : "empty", xe = Le(() => {
6598
+ st.current = !0, et.current !== null && window.clearTimeout(et.current), et.current = window.setTimeout(() => {
6599
+ st.current = !1, et.current = null;
6600
6600
  }, 600);
6601
6601
  }, []), Be = Le((C = "smooth") => {
6602
6602
  const U = ve.current;
6603
6603
  if (!U) return;
6604
- Ne(), U.scrollTo({ top: U.scrollHeight, behavior: C });
6604
+ xe(), U.scrollTo({ top: U.scrollHeight, behavior: C });
6605
6605
  const se = () => {
6606
6606
  const fe = ve.current;
6607
- fe && (!Ve.current && !he && !G || fe.scrollTop + fe.clientHeight >= fe.scrollHeight - 2 || (Ne(), fe.scrollTo({ top: fe.scrollHeight, behavior: "auto" })));
6607
+ fe && (!Me.current && !me && !M || fe.scrollTop + fe.clientHeight >= fe.scrollHeight - 2 || (xe(), fe.scrollTo({ top: fe.scrollHeight, behavior: "auto" })));
6608
6608
  };
6609
6609
  requestAnimationFrame(se), window.setTimeout(se, 120);
6610
- }, [he, G, Ne]);
6610
+ }, [me, M, xe]);
6611
6611
  Cn(() => {
6612
- const C = ve.current, U = Ge.current;
6612
+ const C = ve.current, U = We.current;
6613
6613
  if (!C || U === null) return;
6614
6614
  const se = C.scrollHeight - U;
6615
- se > 0 && (C.scrollTop = C.scrollTop + se), Ge.current = null;
6616
- }, [He.length]), ae(() => {
6617
- Ge.current === null && (!Ve.current && !he && !G || Be(he ? "auto" : "smooth"));
6618
- }, [ee, he, G, Be]), ae(() => {
6615
+ se > 0 && (C.scrollTop = C.scrollTop + se), We.current = null;
6616
+ }, [Je.length]), ae(() => {
6617
+ We.current === null && (!Me.current && !me && !M || Be(me ? "auto" : "smooth"));
6618
+ }, [ee, me, M, Be]), ae(() => {
6619
6619
  const C = ve.current;
6620
6620
  if (!C || typeof ResizeObserver > "u") return;
6621
6621
  let U = 0;
6622
6622
  const se = new ResizeObserver(() => {
6623
- Ge.current === null && (!Ve.current && !he && !G || (cancelAnimationFrame(U), U = requestAnimationFrame(() => {
6623
+ We.current === null && (!Me.current && !me && !M || (cancelAnimationFrame(U), U = requestAnimationFrame(() => {
6624
6624
  const ye = ve.current;
6625
6625
  if (!ye) return;
6626
- ye.scrollHeight - ye.scrollTop - ye.clientHeight <= 120 && (Ne(), ye.scrollTo({ top: ye.scrollHeight, behavior: "auto" }));
6626
+ ye.scrollHeight - ye.scrollTop - ye.clientHeight <= 120 && (xe(), ye.scrollTo({ top: ye.scrollHeight, behavior: "auto" }));
6627
6627
  })));
6628
6628
  }), fe = C.firstElementChild;
6629
6629
  return fe && se.observe(fe), se.observe(C), () => {
6630
6630
  se.disconnect(), cancelAnimationFrame(U);
6631
6631
  };
6632
- }, [he, G, Ne]), Cn(() => {
6633
- const C = ze.current;
6632
+ }, [me, M, xe]), Cn(() => {
6633
+ const C = $e.current;
6634
6634
  if (!C || (E(C.offsetHeight), typeof ResizeObserver > "u")) return;
6635
6635
  const U = new ResizeObserver(() => E(C.offsetHeight));
6636
6636
  return U.observe(C), () => U.disconnect();
6637
6637
  }, []);
6638
- const Fe = Le(() => {
6639
- if (!n || I || !je) return;
6638
+ const ze = Le(() => {
6639
+ if (!n || I || !Te) return;
6640
6640
  const C = ve.current;
6641
- Ge.current = C ? C.scrollHeight : null, Ve.current = !1, x(n).catch(() => {
6642
- Ge.current = null;
6641
+ We.current = C ? C.scrollHeight : null, Me.current = !1, x(n).catch(() => {
6642
+ We.current = null;
6643
6643
  });
6644
- }, [n, I, je, x]), tt = ie(null);
6644
+ }, [n, I, Te, x]), tt = ie(null);
6645
6645
  ae(() => {
6646
- u(""), Ie.current = null, Ce.current += 1, n && va(n);
6646
+ u(""), Re.current = null, Ie.current += 1, n && va(n);
6647
6647
  const C = s.state;
6648
6648
  C != null && C.prefillMessage && tt.current !== C ? (tt.current = C, l(C.prefillMessage), window.setTimeout(() => {
6649
6649
  var U;
6650
6650
  return (U = ge.current) == null ? void 0 : U.focus();
6651
6651
  }, 50)) : C != null && C.prefillMessage || (tt.current = null, l(""));
6652
6652
  }, [n, i, s.state]), ae(() => {
6653
- if (n || !M) return;
6653
+ if (n || !S) return;
6654
6654
  let C = !1;
6655
6655
  return X().then((U) => {
6656
6656
  C || a(`/chat/${U.id}`, { replace: !0 });
@@ -6658,52 +6658,52 @@ function Zn() {
6658
6658
  }), () => {
6659
6659
  C = !0;
6660
6660
  };
6661
- }, [n, M, a]);
6662
- const Y = ie(Z);
6661
+ }, [n, S, a]);
6662
+ const H = ie(J);
6663
6663
  ae(() => {
6664
- Y.current = Z;
6665
- }, [Z]), ae(() => {
6666
- !n || !M || i || H === "running" || Y.current(n).catch(() => {
6664
+ H.current = J;
6665
+ }, [J]), ae(() => {
6666
+ !n || !S || i || Z === "running" || H.current(n).catch(() => {
6667
6667
  });
6668
- }, [n, M, V, i, H]), ae(() => {
6669
- ue.current && !G && M && setTimeout(() => {
6668
+ }, [n, S, V, i, Z]), ae(() => {
6669
+ ce.current && !M && S && setTimeout(() => {
6670
6670
  var C;
6671
6671
  return (C = ge.current) == null ? void 0 : C.focus();
6672
- }, 50), ue.current = G;
6673
- }, [G, M]);
6674
- function pt(C) {
6672
+ }, 50), ce.current = M;
6673
+ }, [M, S]);
6674
+ function mt(C) {
6675
6675
  if (st.current) return;
6676
6676
  const U = C.currentTarget, se = U.scrollHeight - U.scrollTop - U.clientHeight;
6677
- Ve.current = se < 80;
6677
+ Me.current = se < 80;
6678
6678
  }
6679
6679
  ae(() => {
6680
- !n || !M || !i || Ie.current !== n && (Ie.current = n, u(""), P(n).catch((C) => {
6681
- Ie.current = null, u(C instanceof Error ? C.message : e("chat.demoError"));
6680
+ !n || !S || !i || Re.current !== n && (Re.current = n, u(""), _(n).catch((C) => {
6681
+ Re.current = null, u(C instanceof Error ? C.message : e("chat.demoError"));
6682
6682
  }));
6683
- }, [n, M, i, P]), ae(() => {
6684
- !n || !i || H !== "complete" || (l(""), a(`/chat/${n}`, { replace: !0 }));
6685
- }, [n, i, H, a]);
6686
- const we = ie(O);
6683
+ }, [n, S, i, _]), ae(() => {
6684
+ !n || !i || Z !== "complete" || (l(""), a(`/chat/${n}`, { replace: !0 }));
6685
+ }, [n, i, Z, a]);
6686
+ const Ne = ie(O);
6687
6687
  ae(() => {
6688
- we.current = O;
6688
+ Ne.current = O;
6689
6689
  }, [O]);
6690
6690
  const F = ie(null);
6691
6691
  ae(() => {
6692
- if (!xe || !n || F.current === xe.seq) return;
6693
- F.current = xe.seq;
6694
- const C = n, U = xe.content, se = U.length > 0 ? Math.max(8, xe.typingMs / U.length) : 0, fe = xe.seq, ye = ++Ce.current;
6692
+ if (!Y || !n || F.current === Y.seq) return;
6693
+ F.current = Y.seq;
6694
+ const C = n, U = Y.content, se = U.length > 0 ? Math.max(8, Y.typingMs / U.length) : 0, fe = Y.seq, ye = ++Ie.current;
6695
6695
  async function vt() {
6696
6696
  l("");
6697
- for (const lt of U) {
6698
- if (ye !== Ce.current) return;
6699
- l((Xe) => Xe + lt), await wi(se);
6697
+ for (const ot of U) {
6698
+ if (ye !== Ie.current) return;
6699
+ l((Ze) => Ze + ot), await wi(se);
6700
6700
  }
6701
- ye === Ce.current && we.current(C, fe);
6701
+ ye === Ie.current && Ne.current(C, fe);
6702
6702
  }
6703
6703
  vt();
6704
- }, [xe, n]), ae(() => {
6705
- H === "complete" && (Ce.current += 1, l(""));
6706
- }, [H]);
6704
+ }, [Y, n]), ae(() => {
6705
+ Z === "complete" && (Ie.current += 1, l(""));
6706
+ }, [Z]);
6707
6707
  const z = Le((C) => {
6708
6708
  if (!n) return;
6709
6709
  v("");
@@ -6724,32 +6724,32 @@ function Zn() {
6724
6724
  v(`"${ye.name}" is too large (max 10 MB).`);
6725
6725
  continue;
6726
6726
  }
6727
- const lt = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, Xe = ye.type.startsWith("image/") ? URL.createObjectURL(ye) : void 0, jt = { localId: lt, file: ye, previewUrl: Xe, uploading: !0 };
6728
- fe.push(jt), B.uploadChatAttachment(n, ye).then((ht) => {
6727
+ const ot = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, Ze = ye.type.startsWith("image/") ? URL.createObjectURL(ye) : void 0, jt = { localId: ot, file: ye, previewUrl: Ze, uploading: !0 };
6728
+ fe.push(jt), B.uploadChatAttachment(n, ye).then((pt) => {
6729
6729
  d(
6730
6730
  (_t) => _t.map(
6731
- (kt) => kt.localId === lt ? { ...kt, uploading: !1, uploadedId: ht.id } : kt
6731
+ (kt) => kt.localId === ot ? { ...kt, uploading: !1, uploadedId: pt.id } : kt
6732
6732
  )
6733
- ), ht.warning && v(`"${ye.name}": ${ht.warning}`);
6734
- }).catch((ht) => {
6735
- const _t = (ht == null ? void 0 : ht.message) || "Upload failed";
6733
+ ), pt.warning && v(`"${ye.name}": ${pt.warning}`);
6734
+ }).catch((pt) => {
6735
+ const _t = (pt == null ? void 0 : pt.message) || "Upload failed";
6736
6736
  v(`"${ye.name}": ${_t}`), d(
6737
6737
  (kt) => kt.map(
6738
- (Wt) => Wt.localId === lt ? { ...Wt, uploading: !1, error: _t } : Wt
6738
+ (Wt) => Wt.localId === ot ? { ...Wt, uploading: !1, error: _t } : Wt
6739
6739
  )
6740
6740
  );
6741
6741
  });
6742
6742
  }
6743
6743
  return fe;
6744
6744
  });
6745
- }, [n]), J = (C) => {
6745
+ }, [n]), Q = (C) => {
6746
6746
  d((U) => {
6747
6747
  const se = U.find((fe) => fe.localId === C);
6748
6748
  return se != null && se.previewUrl && URL.revokeObjectURL(se.previewUrl), U.filter((fe) => fe.localId !== C);
6749
6749
  });
6750
6750
  }, te = (C) => {
6751
6751
  C.dataTransfer.types.includes("Files") && (C.preventDefault(), y(!0));
6752
- }, We = (C) => {
6752
+ }, je = (C) => {
6753
6753
  const U = C.relatedTarget;
6754
6754
  (!U || !C.currentTarget.contains(U)) && y(!1);
6755
6755
  }, Ee = (C) => {
@@ -6762,10 +6762,10 @@ function Zn() {
6762
6762
  fe && U.push(fe);
6763
6763
  }
6764
6764
  U.length > 0 && (C.preventDefault(), z(U));
6765
- }, ke = h.some((C) => C.uploading), wt = h.some((C) => C.error), ot = h.filter((C) => C.uploadedId && !C.error).map((C) => C.uploadedId);
6765
+ }, we = h.some((C) => C.uploading), wt = h.some((C) => C.error), it = h.filter((C) => C.uploadedId && !C.error).map((C) => C.uploadedId);
6766
6766
  function nt() {
6767
6767
  const C = c.trim();
6768
- if (n && !(!C && ot.length === 0) && !ke && W(n, C, ot.length > 0 ? ot : void 0)) {
6768
+ if (n && !(!C && it.length === 0) && !we && G(n, C, it.length > 0 ? it : void 0)) {
6769
6769
  for (const U of h)
6770
6770
  U.previewUrl && URL.revokeObjectURL(U.previewUrl);
6771
6771
  d([]), v(""), l("");
@@ -6795,24 +6795,24 @@ function Zn() {
6795
6795
  g.current = U, m.current = [], U.ondataavailable = (se) => {
6796
6796
  se.data.size > 0 && m.current.push(se.data);
6797
6797
  }, U.onstop = async () => {
6798
- var lt;
6799
- C.getTracks().forEach((Xe) => Xe.stop());
6798
+ var ot;
6799
+ C.getTracks().forEach((Ze) => Ze.stop());
6800
6800
  const se = m.current;
6801
6801
  if (m.current = [], g.current = null, se.length === 0) {
6802
- S("idle");
6802
+ D("idle");
6803
6803
  return;
6804
6804
  }
6805
- const fe = U.mimeType || ((lt = se[0]) == null ? void 0 : lt.type) || "audio/webm", ye = new Blob(se, { type: fe }), vt = (fe.split(";")[0].split("/")[1] || "webm").toLowerCase();
6806
- S("transcribing");
6805
+ const fe = U.mimeType || ((ot = se[0]) == null ? void 0 : ot.type) || "audio/webm", ye = new Blob(se, { type: fe }), vt = (fe.split(";")[0].split("/")[1] || "webm").toLowerCase();
6806
+ D("transcribing");
6807
6807
  try {
6808
- const Xe = await ki(ye), jt = await A(Xe, vt, n);
6808
+ const Ze = await ki(ye), jt = await P(Ze, vt, n);
6809
6809
  Wa(jt);
6810
- } catch (Xe) {
6811
- v(Xe instanceof Error ? Xe.message : e("chat.transcribeFailed"));
6810
+ } catch (Ze) {
6811
+ v(Ze instanceof Error ? Ze.message : e("chat.transcribeFailed"));
6812
6812
  } finally {
6813
- S("idle");
6813
+ D("idle");
6814
6814
  }
6815
- }, U.start(), S("recording");
6815
+ }, U.start(), D("recording");
6816
6816
  }
6817
6817
  function Ha() {
6818
6818
  const C = g.current;
@@ -6826,7 +6826,7 @@ function Zn() {
6826
6826
  {
6827
6827
  className: "relative -m-4 h-[calc(100%+2rem)] overflow-hidden md:-m-6 md:h-[calc(100%+3rem)]",
6828
6828
  onDragOver: te,
6829
- onDragLeave: We,
6829
+ onDragLeave: je,
6830
6830
  onDrop: Ee,
6831
6831
  children: [
6832
6832
  N && /* @__PURE__ */ t("div", { className: "pointer-events-none absolute inset-3 z-50 flex items-center justify-center rounded-lg border-2 border-dashed border-brand bg-brand/5 text-sm font-medium text-brand", children: e("chat.dropToAttach") }),
@@ -6835,24 +6835,24 @@ function Zn() {
6835
6835
  {
6836
6836
  ref: ve,
6837
6837
  className: "absolute inset-0 overflow-y-auto px-4 py-6",
6838
- onScroll: pt,
6838
+ onScroll: mt,
6839
6839
  children: /* @__PURE__ */ r(
6840
6840
  "div",
6841
6841
  {
6842
6842
  className: "mx-auto max-w-3xl space-y-4",
6843
- style: { paddingBottom: ($e || 96) + 16 },
6843
+ style: { paddingBottom: (Ve || 96) + 16 },
6844
6844
  children: [
6845
- (je || I) && He.length > 0 && /* @__PURE__ */ t("div", { className: "flex justify-center", children: /* @__PURE__ */ t(
6845
+ (Te || I) && Je.length > 0 && /* @__PURE__ */ t("div", { className: "flex justify-center", children: /* @__PURE__ */ t(
6846
6846
  "button",
6847
6847
  {
6848
- onClick: Fe,
6849
- disabled: I || !je,
6848
+ onClick: ze,
6849
+ disabled: I || !Te,
6850
6850
  className: "rounded-full bg-surface px-3 py-1 text-xs text-fg-muted ring-1 ring-line transition-colors hover:bg-surface-subtle hover:text-fg disabled:cursor-not-allowed disabled:opacity-60",
6851
6851
  children: e(I ? "common.loading" : "chat.loadOlder")
6852
6852
  }
6853
6853
  ) }),
6854
6854
  p && /* @__PURE__ */ t("div", { className: "rounded-md bg-rose-50 px-4 py-3 text-sm text-rose-700 ring-1 ring-rose-200", children: p }),
6855
- He.length === 0 && H !== "running" && !i && /* @__PURE__ */ r("div", { className: "py-20 text-center", children: [
6855
+ Je.length === 0 && Z !== "running" && !i && /* @__PURE__ */ r("div", { className: "py-20 text-center", children: [
6856
6856
  /* @__PURE__ */ t("h3", { className: "text-lg font-semibold text-fg-muted", children: e("chat.title") }),
6857
6857
  /* @__PURE__ */ t("p", { className: "mt-2 text-sm text-fg-muted", children: e("chat.subtitle") }),
6858
6858
  /* @__PURE__ */ t("div", { className: "mt-6 flex flex-wrap justify-center gap-2", children: [
@@ -6873,8 +6873,8 @@ function Zn() {
6873
6873
  C
6874
6874
  )) })
6875
6875
  ] }),
6876
- He.map((C, U) => /* @__PURE__ */ t(Si, { message: C }, U)),
6877
- /* @__PURE__ */ t("div", { ref: Re })
6876
+ Je.map((C, U) => /* @__PURE__ */ t(Si, { message: C }, U)),
6877
+ /* @__PURE__ */ t("div", { ref: _e })
6878
6878
  ]
6879
6879
  }
6880
6880
  )
@@ -6883,7 +6883,7 @@ function Zn() {
6883
6883
  /* @__PURE__ */ t(
6884
6884
  "div",
6885
6885
  {
6886
- ref: ze,
6886
+ ref: $e,
6887
6887
  className: "absolute bottom-0 left-0 right-0 bg-surface-muted px-4 pb-[max(0.75rem,env(safe-area-inset-bottom))] md:right-6 md:pl-6 md:pr-0",
6888
6888
  children: /* @__PURE__ */ r("div", { className: "mx-auto max-w-3xl", children: [
6889
6889
  h.length > 0 && /* @__PURE__ */ t("div", { className: "mb-2 flex flex-wrap gap-2", children: h.map((C) => /* @__PURE__ */ r(
@@ -6899,7 +6899,7 @@ function Zn() {
6899
6899
  /* @__PURE__ */ t(
6900
6900
  "button",
6901
6901
  {
6902
- onClick: () => J(C.localId),
6902
+ onClick: () => Q(C.localId),
6903
6903
  className: "ml-1 text-fg-muted transition-colors hover:text-red-500",
6904
6904
  title: e("chat.remove"),
6905
6905
  children: /* @__PURE__ */ t("svg", { viewBox: "0 0 24 24", width: "14", height: "14", fill: "currentColor", children: /* @__PURE__ */ t("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) })
@@ -6932,8 +6932,8 @@ function Zn() {
6932
6932
  onChange: (C) => l(C.target.value),
6933
6933
  onKeyDown: ja,
6934
6934
  onPaste: pe,
6935
- placeholder: e(he ? "chat.placeholderDemo" : M ? "chat.placeholderType" : "chat.placeholderConnecting"),
6936
- disabled: !M || !n || G || he,
6935
+ placeholder: e(me ? "chat.placeholderDemo" : S ? "chat.placeholderType" : "chat.placeholderConnecting"),
6936
+ disabled: !S || !n || M || me,
6937
6937
  rows: 2,
6938
6938
  className: "block flex-1 resize-none bg-transparent px-2.5 py-1.5 text-sm text-fg outline-none placeholder:text-fg-muted/70 disabled:text-fg-muted",
6939
6939
  style: { minHeight: "3rem", maxHeight: "120px" },
@@ -6950,7 +6950,7 @@ function Zn() {
6950
6950
  var C;
6951
6951
  return (C = f.current) == null ? void 0 : C.click();
6952
6952
  },
6953
- disabled: !M || !n || G || he || h.length >= nn,
6953
+ disabled: !S || !n || M || me || h.length >= nn,
6954
6954
  className: "flex h-11 w-11 shrink-0 items-center justify-center rounded-lg text-fg-muted transition-all hover:bg-surface-subtle hover:text-fg disabled:cursor-not-allowed disabled:opacity-40 md:h-10 md:w-10",
6955
6955
  title: e("chat.attachTitle"),
6956
6956
  children: /* @__PURE__ */ t("svg", { viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: /* @__PURE__ */ t("path", { d: "M21.44 11.05l-9.19 9.19a6 6 0 01-8.49-8.49l9.19-9.19a4 4 0 015.66 5.66l-9.2 9.19a2 2 0 01-2.83-2.83l8.49-8.48" }) })
@@ -6960,7 +6960,7 @@ function Zn() {
6960
6960
  "button",
6961
6961
  {
6962
6962
  onClick: Ya,
6963
- disabled: !M || !n || G || he || k === "transcribing",
6963
+ disabled: !S || !n || M || me || k === "transcribing",
6964
6964
  className: `flex h-11 w-11 shrink-0 items-center justify-center rounded-lg transition-all disabled:cursor-not-allowed disabled:opacity-40 md:h-10 md:w-10 ${k === "recording" ? "bg-rose-500/10 text-rose-600 hover:bg-rose-500/20" : "text-fg-muted hover:bg-surface-subtle hover:text-fg"}`,
6965
6965
  title: e(k === "recording" ? "chat.voiceStop" : k === "transcribing" ? "chat.voiceTranscribing" : "chat.voiceStart"),
6966
6966
  children: k === "transcribing" ? /* @__PURE__ */ t("svg", { viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "animate-spin", children: /* @__PURE__ */ t("path", { d: "M21 12a9 9 0 11-6.219-8.56", strokeLinecap: "round" }) }) : k === "recording" ? /* @__PURE__ */ t("svg", { viewBox: "0 0 24 24", width: "18", height: "18", fill: "currentColor", className: "animate-pulse", children: /* @__PURE__ */ t("rect", { x: "6", y: "6", width: "12", height: "12", rx: "2" }) }) : /* @__PURE__ */ r("svg", { viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", strokeLinecap: "round", strokeLinejoin: "round", children: [
@@ -6975,7 +6975,7 @@ function Zn() {
6975
6975
  "button",
6976
6976
  {
6977
6977
  onClick: nt,
6978
- disabled: !c.trim() && ot.length === 0 || !M || !n || G || he || ke || wt,
6978
+ disabled: !c.trim() && it.length === 0 || !S || !n || M || me || we || wt,
6979
6979
  className: "flex h-11 w-11 shrink-0 items-center justify-center rounded-lg text-brand transition-all hover:bg-brand/10 active:translate-y-px disabled:cursor-not-allowed disabled:text-fg-muted disabled:active:translate-y-0 md:h-10 md:w-10",
6980
6980
  children: /* @__PURE__ */ t(
6981
6981
  "svg",
@@ -6994,10 +6994,10 @@ function Zn() {
6994
6994
  /* @__PURE__ */ t(
6995
6995
  "span",
6996
6996
  {
6997
- className: `inline-block h-1.5 w-1.5 rounded-full ${M ? "bg-emerald-500" : "bg-rose-500"} ${M ? "" : "animate-pulse"}`
6997
+ className: `inline-block h-1.5 w-1.5 rounded-full ${S ? "bg-emerald-500" : "bg-rose-500"} ${S ? "" : "animate-pulse"}`
6998
6998
  }
6999
6999
  ),
7000
- /* @__PURE__ */ t("span", { className: "text-[11px] text-fg-muted", children: M ? "Connected" : T === "connecting" ? "Connecting..." : "Disconnected" })
7000
+ /* @__PURE__ */ t("span", { className: "text-[11px] text-fg-muted", children: S ? "Connected" : T === "connecting" ? "Connecting..." : "Disconnected" })
7001
7001
  ] })
7002
7002
  ] })
7003
7003
  }
@@ -7122,7 +7122,7 @@ function Di({ content: e }) {
7122
7122
  }
7123
7123
  function Ma(e, n, a) {
7124
7124
  const s = e.startsWith("/") && !e.startsWith("/api/"), o = "font-medium text-brand underline decoration-brand/40 underline-offset-2 transition-colors hover:decoration-brand";
7125
- return s ? /* @__PURE__ */ t(De, { to: e, className: o, children: n }, a) : /* @__PURE__ */ t(
7125
+ return s ? /* @__PURE__ */ t(Ce, { to: e, className: o, children: n }, a) : /* @__PURE__ */ t(
7126
7126
  "a",
7127
7127
  {
7128
7128
  href: e,
@@ -7167,7 +7167,7 @@ function Pi(e, n) {
7167
7167
  return s < e.length && a.push(e.slice(s)), a.length > 0 ? a : [e];
7168
7168
  }
7169
7169
  function _i() {
7170
- const e = Me(), [n] = Vt(), { user: a, login: s, register: o } = at(), { t: i } = ne(), c = n.get("invite") || "", [l, p] = w(c ? "register" : "login"), [u, h] = w(!1), [d, b] = w(!1), [v, N] = w([]), [y, k] = w(!0), [S, f] = w(""), [g, m] = w(""), [D, T] = w(""), [V, X] = w(""), [P, O] = w("");
7170
+ const e = Fe(), [n] = Vt(), { user: a, login: s, register: o } = at(), { t: i } = ne(), c = n.get("invite") || "", [l, p] = w(c ? "register" : "login"), [u, h] = w(!1), [d, b] = w(!1), [v, N] = w([]), [y, k] = w(!0), [D, f] = w(""), [g, m] = w(""), [A, T] = w(""), [V, X] = w(""), [_, O] = w("");
7171
7171
  ae(() => {
7172
7172
  a && a.role !== "public_manager" && e("/", { replace: !0 });
7173
7173
  }, [a, e]), ae(() => {
@@ -7179,9 +7179,9 @@ function _i() {
7179
7179
  const x = n.get("oauth_error");
7180
7180
  x && f(i(`login.oauthError.${x}`, { defaultValue: i("login.oauthError.generic") }));
7181
7181
  }, [n, i]);
7182
- const Z = async (x) => {
7182
+ const J = async (x) => {
7183
7183
  if (x.preventDefault(), f(""), l === "register") {
7184
- if (V !== P) {
7184
+ if (V !== _) {
7185
7185
  f(i("login.passwordsNoMatch"));
7186
7186
  return;
7187
7187
  }
@@ -7190,15 +7190,15 @@ function _i() {
7190
7190
  return;
7191
7191
  }
7192
7192
  try {
7193
- await o(g, D, V, c || void 0), e("/", { replace: !0 });
7194
- } catch (W) {
7195
- f(W instanceof Qe ? W.message : i("login.registrationFailed"));
7193
+ await o(g, A, V, c || void 0), e("/", { replace: !0 });
7194
+ } catch (G) {
7195
+ f(G instanceof He ? G.message : i("login.registrationFailed"));
7196
7196
  }
7197
7197
  } else
7198
7198
  try {
7199
7199
  await s(g, V), e("/", { replace: !0 });
7200
- } catch (W) {
7201
- f(W instanceof Qe ? W.message : i("login.loginFailed"));
7200
+ } catch (G) {
7201
+ f(G instanceof He ? G.message : i("login.loginFailed"));
7202
7202
  }
7203
7203
  };
7204
7204
  return y ? /* @__PURE__ */ t("div", { className: "flex h-dvh items-center justify-center bg-surface-muted", children: /* @__PURE__ */ t("div", { className: "text-fg-muted", children: i("common.loading") }) }) : /* @__PURE__ */ t("div", { className: "flex min-h-dvh items-center justify-center bg-surface-muted px-4", children: /* @__PURE__ */ r("div", { className: "w-full max-w-sm space-y-6", children: [
@@ -7207,14 +7207,14 @@ function _i() {
7207
7207
  /* @__PURE__ */ t("p", { className: "mt-1 text-sm text-fg-muted", children: i(d ? "login.taglineFirstRun" : l === "register" ? "login.taglineRegister" : "login.taglineSignIn") }),
7208
7208
  (a == null ? void 0 : a.role) === "public_manager" && /* @__PURE__ */ t("p", { className: "mt-2 text-xs text-amber-700", children: i("login.demoBanner") })
7209
7209
  ] }),
7210
- S && /* @__PURE__ */ t("div", { className: "rounded-lg bg-rose-50 px-4 py-3 text-sm text-rose-700 ring-1 ring-rose-200", children: S }),
7210
+ D && /* @__PURE__ */ t("div", { className: "rounded-lg bg-rose-50 px-4 py-3 text-sm text-rose-700 ring-1 ring-rose-200", children: D }),
7211
7211
  /* @__PURE__ */ r($, { children: [
7212
- /* @__PURE__ */ r("form", { onSubmit: Z, className: "space-y-4", children: [
7212
+ /* @__PURE__ */ r("form", { onSubmit: J, className: "space-y-4", children: [
7213
7213
  l === "register" && /* @__PURE__ */ t(
7214
7214
  re,
7215
7215
  {
7216
7216
  label: i("login.fullName"),
7217
- value: D,
7217
+ value: A,
7218
7218
  onChange: (x) => T(x.target.value),
7219
7219
  required: !0
7220
7220
  }
@@ -7244,7 +7244,7 @@ function _i() {
7244
7244
  {
7245
7245
  label: i("login.confirmPassword"),
7246
7246
  type: "password",
7247
- value: P,
7247
+ value: _,
7248
7248
  onChange: (x) => O(x.target.value),
7249
7249
  required: !0
7250
7250
  }
@@ -7289,11 +7289,11 @@ function _i() {
7289
7289
  }
7290
7290
  )
7291
7291
  ] }) }),
7292
- !d && !c && u && /* @__PURE__ */ t("p", { className: "text-center text-sm text-fg-muted", children: l === "login" ? /* @__PURE__ */ r(Pe, { children: [
7292
+ !d && !c && u && /* @__PURE__ */ t("p", { className: "text-center text-sm text-fg-muted", children: l === "login" ? /* @__PURE__ */ r(Ae, { children: [
7293
7293
  i("login.noAccountPrompt"),
7294
7294
  " ",
7295
7295
  /* @__PURE__ */ t("button", { onClick: () => p("register"), className: "font-medium text-brand transition-colors hover:text-brand/80", children: i("login.registerLink") })
7296
- ] }) : /* @__PURE__ */ r(Pe, { children: [
7296
+ ] }) : /* @__PURE__ */ r(Ae, { children: [
7297
7297
  i("login.alreadyHaveAccount"),
7298
7298
  " ",
7299
7299
  /* @__PURE__ */ t("button", { onClick: () => p("login"), className: "font-medium text-brand transition-colors hover:text-brand/80", children: i("login.signInLink") })
@@ -7312,14 +7312,14 @@ function Ri({ provider: e }) {
7312
7312
  ] }) : e === "apple" ? /* @__PURE__ */ t("svg", { className: "h-4 w-4", viewBox: "0 0 24 24", fill: "currentColor", "aria-hidden": "true", children: /* @__PURE__ */ t("path", { d: "M16.365 1.43c0 1.14-.42 2.22-1.14 3.03-.78.9-2.06 1.6-3.12 1.5-.13-1.1.42-2.28 1.08-3.03.78-.9 2.13-1.56 3.18-1.5zM20.7 17.1c-.56 1.3-.83 1.88-1.55 3.03-1 1.6-2.42 3.6-4.18 3.62-1.56.02-1.96-1.02-4.07-1-2.12.01-2.56 1.02-4.12 1.01-1.76-.02-3.1-1.82-4.1-3.42C-.3 16.9-.6 11.16 1.7 8.1c1.16-1.54 3-2.51 4.85-2.51 1.87 0 3.05 1.02 4.6 1.02 1.5 0 2.42-1.02 4.6-1.02 1.62 0 3.34.88 4.56 2.4-4.01 2.2-3.36 7.92 0 9.11z" }) }) : null;
7313
7313
  }
7314
7314
  function Ii() {
7315
- const e = Me(), n = ie(!1), [a, s] = w("");
7315
+ const e = Fe(), n = ie(!1), [a, s] = w("");
7316
7316
  return ae(() => {
7317
7317
  n.current || (n.current = !0, B.createChatSession().then((o) => {
7318
7318
  e(`/chat/${o.id}?demo=1`, { replace: !0 });
7319
7319
  }).catch((o) => {
7320
- s(o instanceof Qe ? o.message : "Could not start demo");
7320
+ s(o instanceof He ? o.message : "Could not start demo");
7321
7321
  }));
7322
- }, [e]), /* @__PURE__ */ t("div", { className: "flex min-h-dvh items-center justify-center bg-surface-muted px-4", children: /* @__PURE__ */ t("div", { className: "text-center", children: a ? /* @__PURE__ */ r(Pe, { children: [
7322
+ }, [e]), /* @__PURE__ */ t("div", { className: "flex min-h-dvh items-center justify-center bg-surface-muted px-4", children: /* @__PURE__ */ t("div", { className: "text-center", children: a ? /* @__PURE__ */ r(Ae, { children: [
7323
7323
  /* @__PURE__ */ t("p", { className: "text-sm text-rose-600", children: a }),
7324
7324
  /* @__PURE__ */ t(
7325
7325
  "button",
@@ -7344,7 +7344,7 @@ function ta() {
7344
7344
  return { type: "sales", party: "", amount: "", due_date: "", remarks: "" };
7345
7345
  }
7346
7346
  function Bi() {
7347
- const e = Me(), n = Ze(), [a, s] = w(""), [o, i] = w((/* @__PURE__ */ new Date()).toISOString().split("T")[0]), [c, l] = w(""), [p, u] = w([Xn()]), [h, d] = w([ea()]), [b, v] = w([ta()]), [N, y] = w({}), k = de({
7347
+ const e = Fe(), n = Qe(), [a, s] = w(""), [o, i] = w((/* @__PURE__ */ new Date()).toISOString().split("T")[0]), [c, l] = w(""), [p, u] = w([Xn()]), [h, d] = w([ea()]), [b, v] = w([ta()]), [N, y] = w({}), k = ue({
7348
7348
  mutationFn: () => B.importAccountBalances({
7349
7349
  company: a,
7350
7350
  posting_date: o,
@@ -7356,8 +7356,8 @@ function Bi() {
7356
7356
  party: m.party || void 0
7357
7357
  }))
7358
7358
  }),
7359
- onSuccess: (m) => y((D) => ({ ...D, accounts: m }))
7360
- }), S = de({
7359
+ onSuccess: (m) => y((A) => ({ ...A, accounts: m }))
7360
+ }), D = ue({
7361
7361
  mutationFn: () => B.importStockBalances({
7362
7362
  company: a,
7363
7363
  posting_date: o,
@@ -7368,8 +7368,8 @@ function Bi() {
7368
7368
  rate: parseFloat(m.rate) || 0
7369
7369
  }))
7370
7370
  }),
7371
- onSuccess: (m) => y((D) => ({ ...D, stock: m }))
7372
- }), f = de({
7371
+ onSuccess: (m) => y((A) => ({ ...A, stock: m }))
7372
+ }), f = ue({
7373
7373
  mutationFn: () => B.importOutstandingInvoices({
7374
7374
  company: a,
7375
7375
  invoices: b.filter((m) => m.party && m.amount).map((m) => ({
@@ -7381,16 +7381,16 @@ function Bi() {
7381
7381
  posting_date: o
7382
7382
  }))
7383
7383
  }),
7384
- onSuccess: (m) => y((D) => ({ ...D, invoices: m }))
7384
+ onSuccess: (m) => y((A) => ({ ...A, invoices: m }))
7385
7385
  });
7386
- function g(m, D, T, V, X) {
7387
- const P = [...m];
7388
- P[T][V] = X, D(P);
7386
+ function g(m, A, T, V, X) {
7387
+ const _ = [...m];
7388
+ _[T][V] = X, A(_);
7389
7389
  }
7390
7390
  return /* @__PURE__ */ r("div", { className: "space-y-6", children: [
7391
7391
  /* @__PURE__ */ t("p", { className: "text-sm text-gray-500", children: "Import balances from your previous system. Each section creates the appropriate documents (Journal Entry, Stock Entry, or Invoices) and submits them automatically." }),
7392
7392
  /* @__PURE__ */ t($, { title: "Common Settings", children: /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
7393
- /* @__PURE__ */ t(Ae, { label: "Company", value: a, onChange: s, linkDoctype: "company", readOnly: !1 }),
7393
+ /* @__PURE__ */ t(De, { label: "Company", value: a, onChange: s, linkDoctype: "company", readOnly: !1 }),
7394
7394
  /* @__PURE__ */ t(re, { label: "As-of Date", type: "date", value: o, onChange: (m) => i(m.target.value) })
7395
7395
  ] }) }),
7396
7396
  /* @__PURE__ */ r($, { title: "1. Account Balances", children: [
@@ -7403,17 +7403,17 @@ function Bi() {
7403
7403
  /* @__PURE__ */ t("th", { className: "px-2 py-2 text-right font-medium text-gray-500", children: "Debit" }),
7404
7404
  /* @__PURE__ */ t("th", { className: "px-2 py-2 text-right font-medium text-gray-500", children: "Credit" })
7405
7405
  ] }) }),
7406
- /* @__PURE__ */ t("tbody", { children: p.map((m, D) => /* @__PURE__ */ r("tr", { children: [
7407
- /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ t(Ae, { value: m.account, onChange: (T) => g(p, u, D, "account", T), linkDoctype: "account", readOnly: !1, label: "" }) }),
7408
- /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ r("select", { value: m.party_type, onChange: (T) => g(p, u, D, "party_type", T.target.value), className: "w-full rounded border border-gray-300 px-2 py-1.5 text-sm", children: [
7406
+ /* @__PURE__ */ t("tbody", { children: p.map((m, A) => /* @__PURE__ */ r("tr", { children: [
7407
+ /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ t(De, { value: m.account, onChange: (T) => g(p, u, A, "account", T), linkDoctype: "account", readOnly: !1, label: "" }) }),
7408
+ /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ r("select", { value: m.party_type, onChange: (T) => g(p, u, A, "party_type", T.target.value), className: "w-full rounded border border-gray-300 px-2 py-1.5 text-sm", children: [
7409
7409
  /* @__PURE__ */ t("option", { value: "", children: "—" }),
7410
7410
  /* @__PURE__ */ t("option", { value: "Customer", children: "Customer" }),
7411
7411
  /* @__PURE__ */ t("option", { value: "Supplier", children: "Supplier" })
7412
7412
  ] }) }),
7413
- /* @__PURE__ */ t("td", { className: "px-2 py-1", children: m.party_type ? /* @__PURE__ */ t(Ae, { label: "", value: m.party, onChange: (T) => g(p, u, D, "party", T), linkDoctype: m.party_type.toLowerCase(), readOnly: !1 }) : /* @__PURE__ */ t("span", { className: "text-gray-300 text-xs", children: "set party type first" }) }),
7414
- /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ t("input", { type: "number", value: m.debit, onChange: (T) => g(p, u, D, "debit", T.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) }),
7415
- /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ t("input", { type: "number", value: m.credit, onChange: (T) => g(p, u, D, "credit", T.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) })
7416
- ] }, D)) })
7413
+ /* @__PURE__ */ t("td", { className: "px-2 py-1", children: m.party_type ? /* @__PURE__ */ t(De, { label: "", value: m.party, onChange: (T) => g(p, u, A, "party", T), linkDoctype: m.party_type.toLowerCase(), readOnly: !1 }) : /* @__PURE__ */ t("span", { className: "text-gray-300 text-xs", children: "set party type first" }) }),
7414
+ /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ t("input", { type: "number", value: m.debit, onChange: (T) => g(p, u, A, "debit", T.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) }),
7415
+ /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ t("input", { type: "number", value: m.credit, onChange: (T) => g(p, u, A, "credit", T.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) })
7416
+ ] }, A)) })
7417
7417
  ] }) }),
7418
7418
  /* @__PURE__ */ t("div", { className: "mt-2 flex gap-2", children: /* @__PURE__ */ t("button", { onClick: () => u([...p, Xn()]), className: "text-xs text-blue-600 hover:text-blue-800", children: "+ Add Row" }) }),
7419
7419
  /* @__PURE__ */ r("div", { className: "mt-3 flex items-center gap-3", children: [
@@ -7427,23 +7427,23 @@ function Bi() {
7427
7427
  ] }),
7428
7428
  /* @__PURE__ */ r($, { title: "2. Stock Balances", children: [
7429
7429
  /* @__PURE__ */ t("p", { className: "mb-3 text-xs text-gray-500", children: "Enter your current inventory. Creates a Stock Entry (Opening Stock) — posts Dr Stock In Hand / Cr Opening Balance Equity so the P&L isn't distorted by day-one inventory." }),
7430
- /* @__PURE__ */ t("div", { className: "mb-3", children: /* @__PURE__ */ t(Ae, { label: "Warehouse", value: c, onChange: l, linkDoctype: "warehouse", readOnly: !1 }) }),
7430
+ /* @__PURE__ */ t("div", { className: "mb-3", children: /* @__PURE__ */ t(De, { label: "Warehouse", value: c, onChange: l, linkDoctype: "warehouse", readOnly: !1 }) }),
7431
7431
  /* @__PURE__ */ t("div", { children: /* @__PURE__ */ r("table", { className: "min-w-full text-sm", children: [
7432
7432
  /* @__PURE__ */ t("thead", { className: "bg-gray-50", children: /* @__PURE__ */ r("tr", { children: [
7433
7433
  /* @__PURE__ */ t("th", { className: "px-2 py-2 text-left font-medium text-gray-500", children: "Item" }),
7434
7434
  /* @__PURE__ */ t("th", { className: "px-2 py-2 text-right font-medium text-gray-500", children: "Qty" }),
7435
7435
  /* @__PURE__ */ t("th", { className: "px-2 py-2 text-right font-medium text-gray-500", children: "Rate" })
7436
7436
  ] }) }),
7437
- /* @__PURE__ */ t("tbody", { children: h.map((m, D) => /* @__PURE__ */ r("tr", { children: [
7438
- /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ t(Ae, { label: "", value: m.item_code, onChange: (T) => g(h, d, D, "item_code", T), linkDoctype: "item", readOnly: !1 }) }),
7439
- /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ t("input", { type: "number", value: m.qty, onChange: (T) => g(h, d, D, "qty", T.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0" }) }),
7440
- /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ t("input", { type: "number", value: m.rate, onChange: (T) => g(h, d, D, "rate", T.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) })
7441
- ] }, D)) })
7437
+ /* @__PURE__ */ t("tbody", { children: h.map((m, A) => /* @__PURE__ */ r("tr", { children: [
7438
+ /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ t(De, { label: "", value: m.item_code, onChange: (T) => g(h, d, A, "item_code", T), linkDoctype: "item", readOnly: !1 }) }),
7439
+ /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ t("input", { type: "number", value: m.qty, onChange: (T) => g(h, d, A, "qty", T.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0" }) }),
7440
+ /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ t("input", { type: "number", value: m.rate, onChange: (T) => g(h, d, A, "rate", T.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) })
7441
+ ] }, A)) })
7442
7442
  ] }) }),
7443
7443
  /* @__PURE__ */ t("div", { className: "mt-2", children: /* @__PURE__ */ t("button", { onClick: () => d([...h, ea()]), className: "text-xs text-blue-600 hover:text-blue-800", children: "+ Add Row" }) }),
7444
7444
  /* @__PURE__ */ r("div", { className: "mt-3 flex items-center gap-3", children: [
7445
- /* @__PURE__ */ t(K, { onClick: () => S.mutate(), disabled: !a || !c || S.isPending, children: S.isPending ? "Importing..." : "Import Stock Balances" }),
7446
- S.error && /* @__PURE__ */ t("span", { className: "text-xs text-red-600", children: S.error.message }),
7445
+ /* @__PURE__ */ t(K, { onClick: () => D.mutate(), disabled: !a || !c || D.isPending, children: D.isPending ? "Importing..." : "Import Stock Balances" }),
7446
+ D.error && /* @__PURE__ */ t("span", { className: "text-xs text-red-600", children: D.error.message }),
7447
7447
  N.stock && /* @__PURE__ */ r("span", { className: "text-xs text-green-600", children: [
7448
7448
  "Created ",
7449
7449
  N.stock.stock_entry,
@@ -7463,25 +7463,25 @@ function Bi() {
7463
7463
  /* @__PURE__ */ t("th", { className: "px-2 py-2 text-left font-medium text-gray-500", children: "Due Date" }),
7464
7464
  /* @__PURE__ */ t("th", { className: "px-2 py-2 text-left font-medium text-gray-500", children: "Ref / Remarks" })
7465
7465
  ] }) }),
7466
- /* @__PURE__ */ t("tbody", { children: b.map((m, D) => /* @__PURE__ */ r("tr", { children: [
7467
- /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ r("select", { value: m.type, onChange: (T) => g(b, v, D, "type", T.target.value), className: "rounded border border-gray-300 px-2 py-1.5 text-sm", children: [
7466
+ /* @__PURE__ */ t("tbody", { children: b.map((m, A) => /* @__PURE__ */ r("tr", { children: [
7467
+ /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ r("select", { value: m.type, onChange: (T) => g(b, v, A, "type", T.target.value), className: "rounded border border-gray-300 px-2 py-1.5 text-sm", children: [
7468
7468
  /* @__PURE__ */ t("option", { value: "sales", children: "Sales (AR)" }),
7469
7469
  /* @__PURE__ */ t("option", { value: "purchase", children: "Purchase (AP)" })
7470
7470
  ] }) }),
7471
7471
  /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ t(
7472
- Ae,
7472
+ De,
7473
7473
  {
7474
7474
  label: "",
7475
7475
  value: m.party,
7476
- onChange: (T) => g(b, v, D, "party", T),
7476
+ onChange: (T) => g(b, v, A, "party", T),
7477
7477
  linkDoctype: m.type === "sales" ? "customer" : "supplier",
7478
7478
  readOnly: !1
7479
7479
  }
7480
7480
  ) }),
7481
- /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ t("input", { type: "number", value: m.amount, onChange: (T) => g(b, v, D, "amount", T.target.value), className: "w-28 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) }),
7482
- /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ t("input", { type: "date", value: m.due_date, onChange: (T) => g(b, v, D, "due_date", T.target.value), className: "rounded border border-gray-300 px-2 py-1.5 text-sm" }) }),
7483
- /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ t("input", { type: "text", value: m.remarks, onChange: (T) => g(b, v, D, "remarks", T.target.value), className: "w-full rounded border border-gray-300 px-2 py-1.5 text-sm", placeholder: "Old invoice ref" }) })
7484
- ] }, D)) })
7481
+ /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ t("input", { type: "number", value: m.amount, onChange: (T) => g(b, v, A, "amount", T.target.value), className: "w-28 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) }),
7482
+ /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ t("input", { type: "date", value: m.due_date, onChange: (T) => g(b, v, A, "due_date", T.target.value), className: "rounded border border-gray-300 px-2 py-1.5 text-sm" }) }),
7483
+ /* @__PURE__ */ t("td", { className: "px-2 py-1", children: /* @__PURE__ */ t("input", { type: "text", value: m.remarks, onChange: (T) => g(b, v, A, "remarks", T.target.value), className: "w-full rounded border border-gray-300 px-2 py-1.5 text-sm", placeholder: "Old invoice ref" }) })
7484
+ ] }, A)) })
7485
7485
  ] }) }),
7486
7486
  /* @__PURE__ */ t("div", { className: "mt-2", children: /* @__PURE__ */ t("button", { onClick: () => v([...b, ta()]), className: "text-xs text-blue-600 hover:text-blue-800", children: "+ Add Row" }) }),
7487
7487
  /* @__PURE__ */ r("div", { className: "mt-3 flex items-center gap-3", children: [
@@ -7510,32 +7510,32 @@ function Bi() {
7510
7510
  ] });
7511
7511
  }
7512
7512
  function Ei() {
7513
- _e("Users");
7514
- const { user: e } = at(), n = Ze(), { data: a, isLoading: s } = ce({
7513
+ Pe("Users");
7514
+ const { user: e } = at(), n = Qe(), { data: a, isLoading: s } = de({
7515
7515
  queryKey: ["auth-users"],
7516
7516
  queryFn: () => B.authListUsers()
7517
- }), { data: o } = ce({
7517
+ }), { data: o } = de({
7518
7518
  queryKey: ["auth-invites"],
7519
7519
  queryFn: () => B.authListInvites()
7520
- }), [i, c] = w(""), [l, p] = w("viewer"), [u, h] = w(null), d = de({
7520
+ }), [i, c] = w(""), [l, p] = w("viewer"), [u, h] = w(null), d = ue({
7521
7521
  mutationFn: () => B.authInvite(i, l),
7522
7522
  onSuccess: (m) => {
7523
7523
  h(m), c(""), n.invalidateQueries({ queryKey: ["auth-invites"] });
7524
7524
  }
7525
- }), b = de({
7526
- mutationFn: ({ name: m, role: D }) => B.authChangeRole(m, D),
7525
+ }), b = ue({
7526
+ mutationFn: ({ name: m, role: A }) => B.authChangeRole(m, A),
7527
7527
  onSuccess: () => n.invalidateQueries({ queryKey: ["auth-users"] })
7528
- }), v = de({
7528
+ }), v = ue({
7529
7529
  mutationFn: (m) => B.authDisableUser(m),
7530
7530
  onSuccess: () => n.invalidateQueries({ queryKey: ["auth-users"] })
7531
- }), N = de({
7531
+ }), N = ue({
7532
7532
  mutationFn: (m) => B.authRevokeInvite(m),
7533
7533
  onSuccess: () => n.invalidateQueries({ queryKey: ["auth-invites"] })
7534
- }), [y, k] = w(null), S = $r(), f = (m) => `${window.location.origin}/login?invite=${m}`, g = async (m) => {
7534
+ }), [y, k] = w(null), D = $r(), f = (m) => `${window.location.origin}/login?invite=${m}`, g = async (m) => {
7535
7535
  try {
7536
- await navigator.clipboard.writeText(f(m)), k(m), setTimeout(() => k((D) => D === m ? null : D), 2e3);
7536
+ await navigator.clipboard.writeText(f(m)), k(m), setTimeout(() => k((A) => A === m ? null : A), 2e3);
7537
7537
  } catch {
7538
- S({ title: "Invite link", body: "Copy this link:", defaultValue: f(m) });
7538
+ D({ title: "Invite link", body: "Copy this link:", defaultValue: f(m) });
7539
7539
  }
7540
7540
  };
7541
7541
  return (e == null ? void 0 : e.role) !== "admin" ? /* @__PURE__ */ t("p", { className: "py-8 text-center text-gray-400", children: "Admin access required" }) : /* @__PURE__ */ r("div", { className: "space-y-6", children: [
@@ -7566,7 +7566,7 @@ function Ei() {
7566
7566
  }
7567
7567
  ),
7568
7568
  /* @__PURE__ */ t(
7569
- Je,
7569
+ Ye,
7570
7570
  {
7571
7571
  label: "Role",
7572
7572
  options: ["viewer", "manager", "admin"],
@@ -7604,11 +7604,11 @@ function Ei() {
7604
7604
  /* @__PURE__ */ t("th", { className: "px-4 py-2 text-right font-medium text-gray-500", children: "Actions" })
7605
7605
  ] }) }),
7606
7606
  /* @__PURE__ */ t("tbody", { className: "divide-y divide-gray-100", children: o.filter((m) => !m.used).map((m) => {
7607
- var D;
7607
+ var A;
7608
7608
  return /* @__PURE__ */ r("tr", { children: [
7609
7609
  /* @__PURE__ */ t("td", { className: "px-4 py-2", children: m.email }),
7610
7610
  /* @__PURE__ */ t("td", { className: "px-4 py-2", children: /* @__PURE__ */ t("span", { className: "rounded bg-gray-100 px-2 py-0.5 text-xs font-medium", children: m.role }) }),
7611
- /* @__PURE__ */ t("td", { className: "px-4 py-2 text-gray-500", children: (D = m.creation) == null ? void 0 : D.split("T")[0] }),
7611
+ /* @__PURE__ */ t("td", { className: "px-4 py-2 text-gray-500", children: (A = m.creation) == null ? void 0 : A.split("T")[0] }),
7612
7612
  /* @__PURE__ */ t("td", { className: "px-4 py-2 text-right", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-end gap-2", children: [
7613
7613
  /* @__PURE__ */ t(
7614
7614
  K,
@@ -7648,7 +7648,7 @@ function Ei() {
7648
7648
  "select",
7649
7649
  {
7650
7650
  value: m.role,
7651
- onChange: (D) => b.mutate({ name: m.name, role: D.target.value }),
7651
+ onChange: (A) => b.mutate({ name: m.name, role: A.target.value }),
7652
7652
  disabled: m.name === (e == null ? void 0 : e.name),
7653
7653
  className: `rounded border px-2 py-1 text-xs ${m.name === (e == null ? void 0 : e.name) ? "border-gray-200 bg-gray-50 text-gray-400" : "border-gray-300 bg-white text-gray-900"}`,
7654
7654
  children: [
@@ -7784,7 +7784,7 @@ function al({ label: e }) {
7784
7784
  var i;
7785
7785
  const { t: n, i18n: a } = ne(), { setSetting: s } = vn(), o = ((i = a.language) == null ? void 0 : i.split("-")[0]) ?? "en";
7786
7786
  return /* @__PURE__ */ t(
7787
- Je,
7787
+ Ye,
7788
7788
  {
7789
7789
  label: e === null ? void 0 : e ?? n("language.label"),
7790
7790
  options: Fa.map((c) => ({ value: c.code, label: c.label })),
@@ -7804,22 +7804,22 @@ const na = [
7804
7804
  { value: "24h", label: "Last 24 hours", hours: 24 },
7805
7805
  { value: "7d", label: "Last 7 days", hours: 168 }
7806
7806
  ];
7807
- function et(e) {
7807
+ function Xe(e) {
7808
7808
  return e === 0 ? "$0.00" : e < 0.01 ? `$${e.toFixed(4)}` : `$${e.toFixed(2)}`;
7809
7809
  }
7810
7810
  function rl({ demoActive: e }) {
7811
- var S, f;
7812
- const { t: n } = ne(), [a, s] = w("1h"), { data: o, isLoading: i, isFetching: c, error: l, refetch: p, dataUpdatedAt: u } = ce({
7811
+ var D, f;
7812
+ const { t: n } = ne(), [a, s] = w("1h"), { data: o, isLoading: i, isFetching: c, error: l, refetch: p, dataUpdatedAt: u } = de({
7813
7813
  queryKey: ["demo-spend"],
7814
7814
  queryFn: () => B.getDemoSpend(),
7815
7815
  // Refresh once a minute — demo spend changes slowly; no need to poll harder.
7816
7816
  refetchInterval: 6e4
7817
- }), h = na.find((g) => g.value === a), d = (S = o == null ? void 0 : o.windows) == null ? void 0 : S[a], b = ((f = o == null ? void 0 : o.caps) == null ? void 0 : f.global_hourly_usd) ?? 0, v = d ? d.demo_usd / h.hours : 0, N = d ? d.total_usd / h.hours : 0, y = b > 0 ? Math.min(100, v / b * 100) : 0, k = y >= 90 ? "bg-red-500" : y >= 60 ? "bg-amber-500" : "bg-emerald-500";
7817
+ }), h = na.find((g) => g.value === a), d = (D = o == null ? void 0 : o.windows) == null ? void 0 : D[a], b = ((f = o == null ? void 0 : o.caps) == null ? void 0 : f.global_hourly_usd) ?? 0, v = d ? d.demo_usd / h.hours : 0, N = d ? d.total_usd / h.hours : 0, y = b > 0 ? Math.min(100, v / b * 100) : 0, k = y >= 90 ? "bg-red-500" : y >= 60 ? "bg-amber-500" : "bg-emerald-500";
7818
7818
  return /* @__PURE__ */ r($, { title: n("settings.tokenSpendTitle"), children: [
7819
7819
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end justify-between gap-4", children: [
7820
7820
  /* @__PURE__ */ r("div", { className: "max-w-lg text-sm text-gray-600", children: [
7821
7821
  "Cost and token usage from AI / LLM calls in this deployment, across all providers.",
7822
- e && /* @__PURE__ */ r(Pe, { children: [
7822
+ e && /* @__PURE__ */ r(Ae, { children: [
7823
7823
  " ",
7824
7824
  "Only",
7825
7825
  " ",
@@ -7830,7 +7830,7 @@ function rl({ demoActive: e }) {
7830
7830
  ] }),
7831
7831
  /* @__PURE__ */ r("div", { className: "flex items-end gap-2", children: [
7832
7832
  /* @__PURE__ */ t("div", { className: "w-48", children: /* @__PURE__ */ t(
7833
- Je,
7833
+ Ye,
7834
7834
  {
7835
7835
  label: "Time range",
7836
7836
  options: na.map((g) => ({ value: g.value, label: g.label })),
@@ -7887,10 +7887,10 @@ function rl({ demoActive: e }) {
7887
7887
  ")"
7888
7888
  ] }),
7889
7889
  /* @__PURE__ */ r("div", { className: "mt-1 text-2xl font-semibold text-gray-900", children: [
7890
- et(v),
7890
+ Xe(v),
7891
7891
  /* @__PURE__ */ r("span", { className: "ml-2 text-sm font-normal text-gray-500", children: [
7892
7892
  "/ ",
7893
- et(b),
7893
+ Xe(b),
7894
7894
  " hourly cap"
7895
7895
  ] })
7896
7896
  ] })
@@ -7898,10 +7898,10 @@ function rl({ demoActive: e }) {
7898
7898
  /* @__PURE__ */ r("div", { className: "text-right", children: [
7899
7899
  /* @__PURE__ */ t("div", { className: "text-xs font-medium uppercase tracking-wide text-gray-500", children: "Total (all roles)" }),
7900
7900
  /* @__PURE__ */ r("div", { className: "mt-1 text-lg font-semibold text-gray-700", children: [
7901
- et(d.total_usd),
7901
+ Xe(d.total_usd),
7902
7902
  /* @__PURE__ */ r("span", { className: "ml-1 text-xs font-normal text-gray-500", children: [
7903
7903
  "(",
7904
- et(N),
7904
+ Xe(N),
7905
7905
  "/hr)"
7906
7906
  ] })
7907
7907
  ] })
@@ -7923,10 +7923,10 @@ function rl({ demoActive: e }) {
7923
7923
  ")"
7924
7924
  ] }),
7925
7925
  /* @__PURE__ */ r("div", { className: "mt-1 text-2xl font-semibold text-gray-900", children: [
7926
- et(N),
7926
+ Xe(N),
7927
7927
  /* @__PURE__ */ r("span", { className: "ml-2 text-sm font-normal text-gray-500", children: [
7928
7928
  "(",
7929
- et(d.total_usd),
7929
+ Xe(d.total_usd),
7930
7930
  " over ",
7931
7931
  h.label.toLowerCase(),
7932
7932
  ")"
@@ -7935,7 +7935,7 @@ function rl({ demoActive: e }) {
7935
7935
  ] })
7936
7936
  ),
7937
7937
  /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-3 sm:grid-cols-4", children: [
7938
- e ? /* @__PURE__ */ t(Dt, { label: "Demo spend", value: et(d.demo_usd) }) : /* @__PURE__ */ t(Dt, { label: "Cost", value: et(d.total_usd) }),
7938
+ e ? /* @__PURE__ */ t(Dt, { label: "Demo spend", value: Xe(d.demo_usd) }) : /* @__PURE__ */ t(Dt, { label: "Cost", value: Xe(d.total_usd) }),
7939
7939
  /* @__PURE__ */ t(Dt, { label: "Calls", value: d.call_count.toLocaleString() }),
7940
7940
  /* @__PURE__ */ t(Dt, { label: "Unique IPs", value: d.unique_ips.toLocaleString() }),
7941
7941
  /* @__PURE__ */ t(
@@ -7958,7 +7958,7 @@ function rl({ demoActive: e }) {
7958
7958
  ] }) }),
7959
7959
  /* @__PURE__ */ t("tbody", { className: "divide-y divide-gray-100", children: Object.entries(d.by_provider).map(([g, m]) => /* @__PURE__ */ r("tr", { children: [
7960
7960
  /* @__PURE__ */ t("td", { className: "px-3 py-2 font-medium text-gray-900", children: g }),
7961
- /* @__PURE__ */ t("td", { className: "px-3 py-2 text-right tabular-nums", children: et(m.cost_usd) }),
7961
+ /* @__PURE__ */ t("td", { className: "px-3 py-2 text-right tabular-nums", children: Xe(m.cost_usd) }),
7962
7962
  /* @__PURE__ */ t("td", { className: "px-3 py-2 text-right tabular-nums", children: m.call_count.toLocaleString() }),
7963
7963
  /* @__PURE__ */ t("td", { className: "px-3 py-2 text-right tabular-nums", children: m.prompt_tokens.toLocaleString() }),
7964
7964
  /* @__PURE__ */ t("td", { className: "px-3 py-2 text-right tabular-nums", children: m.completion_tokens.toLocaleString() })
@@ -7977,7 +7977,7 @@ function rl({ demoActive: e }) {
7977
7977
  /* @__PURE__ */ t("tbody", { className: "divide-y divide-gray-100", children: o.top_ips_24h.map((g, m) => /* @__PURE__ */ r("tr", { children: [
7978
7978
  /* @__PURE__ */ t("td", { className: "px-3 py-2 font-mono text-xs text-gray-900", children: g.ip }),
7979
7979
  /* @__PURE__ */ t("td", { className: "px-3 py-2 text-gray-600", children: g.role ?? "—" }),
7980
- /* @__PURE__ */ t("td", { className: "px-3 py-2 text-right tabular-nums", children: et(g.cost_usd) }),
7980
+ /* @__PURE__ */ t("td", { className: "px-3 py-2 text-right tabular-nums", children: Xe(g.cost_usd) }),
7981
7981
  /* @__PURE__ */ t("td", { className: "px-3 py-2 text-right tabular-nums", children: g.call_count.toLocaleString() })
7982
7982
  ] }, `${g.ip}-${g.role ?? ""}-${m}`)) })
7983
7983
  ] }) })
@@ -7992,12 +7992,12 @@ function Dt({ label: e, value: n }) {
7992
7992
  ] });
7993
7993
  }
7994
7994
  function sl() {
7995
- const { t: e } = ne(), { user: n } = at(), [a, s] = w(""), [o, i] = w(""), [c, l] = w(""), [p, u] = w(""), [h, d] = w(!1), b = de({
7995
+ const { t: e } = ne(), { user: n } = at(), [a, s] = w(""), [o, i] = w(""), [c, l] = w(""), [p, u] = w(""), [h, d] = w(!1), b = ue({
7996
7996
  mutationFn: () => B.authChangePassword(a, o),
7997
7997
  onSuccess: () => {
7998
7998
  d(!0), u(""), s(""), i(""), l(""), setTimeout(() => d(!1), 4e3);
7999
7999
  },
8000
- onError: (N) => u(N instanceof Qe ? N.message : e("login.registrationFailed"))
8000
+ onError: (N) => u(N instanceof He ? N.message : e("login.registrationFailed"))
8001
8001
  }), v = (N) => {
8002
8002
  if (N.preventDefault(), u(""), d(!1), o !== c) {
8003
8003
  u(e("login.passwordsNoMatch"));
@@ -8069,12 +8069,12 @@ function sl() {
8069
8069
  ] }) });
8070
8070
  }
8071
8071
  function il() {
8072
- const { t: e } = ne(), { user: n, refreshUser: a } = at(), [s, o] = w(""), [i, c] = w(""), [l, p] = w(""), [u, h] = w(!1), d = de({
8072
+ const { t: e } = ne(), { user: n, refreshUser: a } = at(), [s, o] = w(""), [i, c] = w(""), [l, p] = w(""), [u, h] = w(!1), d = ue({
8073
8073
  mutationFn: () => B.authSetPassword(s),
8074
8074
  onSuccess: async () => {
8075
8075
  h(!0), p(""), o(""), c(""), await a();
8076
8076
  },
8077
- onError: (v) => p(v instanceof Qe ? v.message : e("login.registrationFailed"))
8077
+ onError: (v) => p(v instanceof He ? v.message : e("login.registrationFailed"))
8078
8078
  }), b = (v) => {
8079
8079
  if (v.preventDefault(), p(""), h(!1), s !== i) {
8080
8080
  p(e("login.passwordsNoMatch"));
@@ -8135,10 +8135,10 @@ function il() {
8135
8135
  ] });
8136
8136
  }
8137
8137
  function ol() {
8138
- const { t: e } = ne(), { data: n } = ce({
8138
+ const { t: e } = ne(), { data: n } = de({
8139
8139
  queryKey: ["auth-setup-status"],
8140
8140
  queryFn: () => B.authSetupStatus()
8141
- }), { data: a } = ce({
8141
+ }), { data: a } = de({
8142
8142
  queryKey: ["oauth-identities"],
8143
8143
  queryFn: () => B.oauthListIdentities()
8144
8144
  }), s = (n == null ? void 0 : n.oauth_providers) ?? [];
@@ -8170,44 +8170,44 @@ function ol() {
8170
8170
  }
8171
8171
  const an = { viewer: 1, manager: 2, admin: 3 };
8172
8172
  function $a({ ownRole: e }) {
8173
- const { t: n } = ne(), { user: a } = at(), s = Ze(), [o, i] = w(""), [c, l] = w(e in an ? e : "viewer"), [p, u] = w(null), [h, d] = w(null), b = ["viewer", "manager", "admin"].filter(
8174
- (P) => an[P] <= (an[e] ?? 1)
8173
+ const { t: n } = ne(), { user: a } = at(), s = Qe(), [o, i] = w(""), [c, l] = w(e in an ? e : "viewer"), [p, u] = w(null), [h, d] = w(null), b = ["viewer", "manager", "admin"].filter(
8174
+ (_) => an[_] <= (an[e] ?? 1)
8175
8175
  ), v = `${window.location.origin}/api/mcp`, N = p ? `claude mcp add --transport http --scope user lambda-erp ${v} \\
8176
8176
  --header "Authorization: Bearer ${p}"` : "", y = p ? `# ~/.codex/config.toml
8177
8177
  [mcp_servers.lambda-erp]
8178
8178
  url = "${v}"
8179
- http_headers = { Authorization = "Bearer ${p}" }` : "", { data: k } = ce({
8179
+ http_headers = { Authorization = "Bearer ${p}" }` : "", { data: k } = de({
8180
8180
  queryKey: ["api-keys"],
8181
8181
  queryFn: () => B.getApiKeys()
8182
- }), S = de({
8182
+ }), D = ue({
8183
8183
  mutationFn: () => B.createApiKey(o.trim(), c),
8184
- onSuccess: (P) => {
8185
- u(P.token), i(""), s.invalidateQueries({ queryKey: ["api-keys"] });
8184
+ onSuccess: (_) => {
8185
+ u(_.token), i(""), s.invalidateQueries({ queryKey: ["api-keys"] });
8186
8186
  }
8187
- }), f = de({
8188
- mutationFn: (P) => B.revokeApiKey(P),
8187
+ }), f = ue({
8188
+ mutationFn: (_) => B.revokeApiKey(_),
8189
8189
  onSuccess: () => s.invalidateQueries({ queryKey: ["api-keys"] })
8190
- }), g = de({
8191
- mutationFn: (P) => B.deleteApiKey(P),
8190
+ }), g = ue({
8191
+ mutationFn: (_) => B.deleteApiKey(_),
8192
8192
  onSuccess: () => s.invalidateQueries({ queryKey: ["api-keys"] })
8193
- }), m = (P) => P.is_mine ?? P.user === (a == null ? void 0 : a.name), D = (P) => P.owner_full_name || P.owner_email || P.user || n("settings.chatApiUnknownUser"), T = be(() => {
8194
- const P = /* @__PURE__ */ new Map();
8193
+ }), m = (_) => _.is_mine ?? _.user === (a == null ? void 0 : a.name), A = (_) => _.owner_full_name || _.owner_email || _.user || n("settings.chatApiUnknownUser"), T = be(() => {
8194
+ const _ = /* @__PURE__ */ new Map();
8195
8195
  for (const O of k ?? []) {
8196
- const Z = O.is_mine ?? O.user === (a == null ? void 0 : a.name), x = Z ? "__me__" : O.user ?? "__unknown__";
8197
- P.has(x) || P.set(x, {
8198
- label: Z ? n("settings.chatApiYourKeys") : O.owner_full_name || O.owner_email || O.user || n("settings.chatApiUnknownUser"),
8199
- sublabel: Z ? void 0 : O.owner_email ?? void 0,
8200
- isMine: Z,
8196
+ const J = O.is_mine ?? O.user === (a == null ? void 0 : a.name), x = J ? "__me__" : O.user ?? "__unknown__";
8197
+ _.has(x) || _.set(x, {
8198
+ label: J ? n("settings.chatApiYourKeys") : O.owner_full_name || O.owner_email || O.user || n("settings.chatApiUnknownUser"),
8199
+ sublabel: J ? void 0 : O.owner_email ?? void 0,
8200
+ isMine: J,
8201
8201
  keys: []
8202
- }), P.get(x).keys.push(O);
8202
+ }), _.get(x).keys.push(O);
8203
8203
  }
8204
- return Array.from(P.values()).sort(
8205
- (O, Z) => O.isMine ? -1 : Z.isMine ? 1 : O.label.localeCompare(Z.label)
8204
+ return Array.from(_.values()).sort(
8205
+ (O, J) => O.isMine ? -1 : J.isMine ? 1 : O.label.localeCompare(J.label)
8206
8206
  );
8207
- }, [k, a, n]), V = (P, O) => {
8208
- O === "revoke" ? f.mutate(P) : g.mutate(P);
8209
- }, X = (P, O) => {
8210
- m(P) ? V(P.id, O) : d({ id: P.id, action: O, owner: D(P), keyName: P.name });
8207
+ }, [k, a, n]), V = (_, O) => {
8208
+ O === "revoke" ? f.mutate(_) : g.mutate(_);
8209
+ }, X = (_, O) => {
8210
+ m(_) ? V(_.id, O) : d({ id: _.id, action: O, owner: A(_), keyName: _.name });
8211
8211
  };
8212
8212
  return /* @__PURE__ */ r("div", { children: [
8213
8213
  p && /* @__PURE__ */ r("div", { className: "mb-3 rounded-lg bg-amber-50 p-3 ring-1 ring-inset ring-amber-200", children: [
@@ -8218,8 +8218,8 @@ http_headers = { Authorization = "Bearer ${p}" }` : "", { data: k } = ce({
8218
8218
  {
8219
8219
  className: "mt-2 text-xs font-medium text-brand hover:underline",
8220
8220
  onClick: () => {
8221
- var P;
8222
- return (P = navigator.clipboard) == null ? void 0 : P.writeText(p);
8221
+ var _;
8222
+ return (_ = navigator.clipboard) == null ? void 0 : _.writeText(p);
8223
8223
  },
8224
8224
  children: n("settings.chatApiCopy")
8225
8225
  }
@@ -8248,12 +8248,12 @@ http_headers = { Authorization = "Bearer ${p}" }` : "", { data: k } = ce({
8248
8248
  ] })
8249
8249
  ] }),
8250
8250
  e === "admin" && /* @__PURE__ */ t("p", { className: "mb-3 text-xs text-fg-muted", children: n("settings.chatApiAdminAllNote") }),
8251
- T.length > 0 ? /* @__PURE__ */ t("div", { className: "mb-4 space-y-4", children: T.map((P) => /* @__PURE__ */ r("div", { children: [
8251
+ T.length > 0 ? /* @__PURE__ */ t("div", { className: "mb-4 space-y-4", children: T.map((_) => /* @__PURE__ */ r("div", { children: [
8252
8252
  /* @__PURE__ */ r("div", { className: "mb-1.5 flex items-baseline gap-2", children: [
8253
- /* @__PURE__ */ t("span", { className: "text-xs font-semibold text-fg", children: P.label }),
8254
- P.isMine ? /* @__PURE__ */ t(Lt, { variant: "default", children: n("settings.chatApiYouBadge") }) : P.sublabel && /* @__PURE__ */ t("span", { className: "text-xs text-fg-muted", children: P.sublabel })
8253
+ /* @__PURE__ */ t("span", { className: "text-xs font-semibold text-fg", children: _.label }),
8254
+ _.isMine ? /* @__PURE__ */ t(Lt, { variant: "default", children: n("settings.chatApiYouBadge") }) : _.sublabel && /* @__PURE__ */ t("span", { className: "text-xs text-fg-muted", children: _.sublabel })
8255
8255
  ] }),
8256
- /* @__PURE__ */ t("ul", { className: "divide-y divide-line rounded-lg ring-1 ring-line", children: P.keys.map((O) => /* @__PURE__ */ r(
8256
+ /* @__PURE__ */ t("ul", { className: "divide-y divide-line rounded-lg ring-1 ring-line", children: _.keys.map((O) => /* @__PURE__ */ r(
8257
8257
  "li",
8258
8258
  {
8259
8259
  className: "flex items-center justify-between gap-3 px-3 py-2 text-sm",
@@ -8282,27 +8282,27 @@ http_headers = { Authorization = "Bearer ${p}" }` : "", { data: k } = ce({
8282
8282
  },
8283
8283
  O.id
8284
8284
  )) })
8285
- ] }, P.label)) }) : /* @__PURE__ */ t("p", { className: "mb-4 text-xs text-fg-muted", children: n("settings.chatApiNoKeys") }),
8285
+ ] }, _.label)) }) : /* @__PURE__ */ t("p", { className: "mb-4 text-xs text-fg-muted", children: n("settings.chatApiNoKeys") }),
8286
8286
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-3", children: [
8287
8287
  /* @__PURE__ */ t("div", { className: "w-48", children: /* @__PURE__ */ t(
8288
8288
  re,
8289
8289
  {
8290
8290
  label: n("settings.chatApiName"),
8291
8291
  value: o,
8292
- onChange: (P) => i(P.target.value),
8292
+ onChange: (_) => i(_.target.value),
8293
8293
  placeholder: "lambda-web"
8294
8294
  }
8295
8295
  ) }),
8296
8296
  /* @__PURE__ */ t(
8297
- Je,
8297
+ Ye,
8298
8298
  {
8299
8299
  label: n("settings.chatApiRole"),
8300
8300
  options: b,
8301
8301
  value: c,
8302
- onChange: (P) => l(P.target.value)
8302
+ onChange: (_) => l(_.target.value)
8303
8303
  }
8304
8304
  ),
8305
- /* @__PURE__ */ t(K, { onClick: () => S.mutate(), disabled: !o.trim() || S.isPending, children: n("settings.chatApiCreate") })
8305
+ /* @__PURE__ */ t(K, { onClick: () => D.mutate(), disabled: !o.trim() || D.isPending, children: n("settings.chatApiCreate") })
8306
8306
  ] }),
8307
8307
  /* @__PURE__ */ t("p", { className: "mt-2 text-xs text-fg-muted", children: n("settings.chatApiWarn") }),
8308
8308
  h && /* @__PURE__ */ t(
@@ -8316,7 +8316,7 @@ http_headers = { Authorization = "Bearer ${p}" }` : "", { data: k } = ce({
8316
8316
  className: "w-full max-w-sm rounded-xl border border-line bg-surface p-5 shadow-xl",
8317
8317
  role: "dialog",
8318
8318
  "aria-modal": "true",
8319
- onClick: (P) => P.stopPropagation(),
8319
+ onClick: (_) => _.stopPropagation(),
8320
8320
  children: [
8321
8321
  /* @__PURE__ */ t("h3", { className: "text-sm font-semibold text-fg", children: n("settings.chatApiConfirmTitle") }),
8322
8322
  /* @__PURE__ */ t("p", { className: "mt-2 text-xs text-fg-muted", children: n(
@@ -8440,26 +8440,26 @@ function ll({
8440
8440
  ] });
8441
8441
  }
8442
8442
  function cl() {
8443
- const { user: e } = at(), { t: n } = ne(), a = Ze(), s = (e == null ? void 0 : e.role) === "admin", { data: o, isLoading: i } = ce({
8443
+ const { user: e } = at(), { t: n } = ne(), a = Qe(), s = (e == null ? void 0 : e.role) === "admin", { data: o, isLoading: i } = de({
8444
8444
  queryKey: ["settings"],
8445
8445
  queryFn: () => B.getSettings()
8446
- }), c = de({
8446
+ }), c = ue({
8447
8447
  mutationFn: (v) => B.updateSettings(v),
8448
8448
  onSuccess: () => a.invalidateQueries({ queryKey: ["settings"] })
8449
- }), { data: l } = ce({
8449
+ }), { data: l } = de({
8450
8450
  queryKey: ["public-manager"],
8451
8451
  queryFn: () => B.getPublicManagerStatus()
8452
- }), { data: p } = ce({
8452
+ }), { data: p } = de({
8453
8453
  queryKey: ["health"],
8454
8454
  queryFn: () => B.getHealth(),
8455
8455
  staleTime: 1 / 0
8456
8456
  // version only changes on deploy
8457
- }), [u, h] = w(!1), d = de({
8457
+ }), [u, h] = w(!1), d = ue({
8458
8458
  mutationFn: () => B.createPublicManager(),
8459
8459
  onSuccess: () => {
8460
8460
  a.invalidateQueries({ queryKey: ["public-manager"] }), h(!1);
8461
8461
  }
8462
- }), b = de({
8462
+ }), b = ue({
8463
8463
  mutationFn: () => B.removePublicManager(),
8464
8464
  onSuccess: () => a.invalidateQueries({ queryKey: ["public-manager"] })
8465
8465
  });
@@ -8472,7 +8472,7 @@ function cl() {
8472
8472
  (e == null ? void 0 : e.role) !== "public_manager" && /* @__PURE__ */ t(ol, {}),
8473
8473
  /* @__PURE__ */ r($, { title: n("settings.pdfTitle"), children: [
8474
8474
  /* @__PURE__ */ t("div", { className: "flex flex-wrap items-end gap-4", children: s ? /* @__PURE__ */ t(
8475
- Je,
8475
+ Ye,
8476
8476
  {
8477
8477
  label: n("settings.pageSize"),
8478
8478
  options: ["A4", "letter"],
@@ -8660,7 +8660,7 @@ function gl() {
8660
8660
  ];
8661
8661
  }
8662
8662
  function fl({ slug: e, parentSlug: n, linkField: a }) {
8663
- const { name: s = "" } = yt(), o = Me();
8663
+ const { name: s = "" } = ft(), o = Fe();
8664
8664
  return ae(() => {
8665
8665
  let i = !0;
8666
8666
  return B.getDocument(e, s).then((c) => {
@@ -8752,7 +8752,7 @@ function Fl({
8752
8752
  children: a ?? d("common.delete", { defaultValue: "Delete" })
8753
8753
  },
8754
8754
  "confirm"
8755
- ), S = /* @__PURE__ */ t(
8755
+ ), D = /* @__PURE__ */ t(
8756
8756
  "button",
8757
8757
  {
8758
8758
  type: "button",
@@ -8770,12 +8770,12 @@ function Fl({
8770
8770
  {
8771
8771
  className: qe("inline-flex items-center", y ? "gap-2" : "gap-1"),
8772
8772
  onMouseLeave: () => v(!1),
8773
- children: h === "right" ? [k, S] : [S, k]
8773
+ children: h === "right" ? [k, D] : [D, k]
8774
8774
  }
8775
8775
  );
8776
8776
  }
8777
8777
  export {
8778
- Qe as ApiError,
8778
+ He as ApiError,
8779
8779
  Qr as AppShell,
8780
8780
  Br as AuthProvider,
8781
8781
  Fl as ConfirmButton,
@@ -8807,7 +8807,7 @@ export {
8807
8807
  Aa as setListContext,
8808
8808
  at as useAuth,
8809
8809
  wa as useConfirm,
8810
- _e as usePageTitle,
8810
+ Pe as usePageTitle,
8811
8811
  $r as usePrompt
8812
8812
  };
8813
8813
  //# sourceMappingURL=index.js.map