@lambda-development/erp-core 0.6.4 → 0.6.5

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,20 +1,20 @@
1
1
  import { jsx as e, jsxs as r, Fragment as we } from "react/jsx-runtime";
2
- import { useState as S, useEffect as re, useCallback as Pe, useContext as Kn, createContext as jn, useRef as ee, useMemo as Ce, useLayoutEffect as un, StrictMode as Ca } from "react";
3
- import { createRoot as Da } from "react-dom/client";
4
- import { useQueryClient as We, useQuery as ie, useMutation as oe, QueryClientProvider as Aa, QueryClient as Pa } from "@tanstack/react-query";
5
- import { NavLink as qt, useLocation as vt, useNavigate as Ie, Outlet as _a, Navigate as Ta, Link as be, useSearchParams as zt, useParams as ut, createBrowserRouter as Ra, RouterProvider as Ia } from "react-router-dom";
6
- import { useTranslation as Z, initReactI18next as Ba } from "react-i18next";
7
- import { BookOpen as Ea, ShoppingCart as Gn, CreditCard as La, FileText as nn, Package as Wn, BarChart3 as Oa, Database as qa, Settings as za, MessageCircle as Ma, ChevronDown as Mt, ChevronRight as Dt, Plus as Hn, Trash2 as Qn, LineChart as Fa, ArrowLeft as $a, TrendingUp as Ua, ArrowDownRight as Va, ArrowUpRight as Ka, Wallet as ja, Receipt as mn, ChevronLeft as Ga, Info as Wa } from "lucide-react";
2
+ import { useState as S, useEffect as ae, useCallback as Pe, useContext as Kn, createContext as jn, useRef as ee, useMemo as Ce, useLayoutEffect as un, StrictMode as Aa } from "react";
3
+ import { createRoot as Pa } from "react-dom/client";
4
+ import { useQueryClient as We, useQuery as ie, useMutation as oe, QueryClientProvider as _a, QueryClient as Ta } from "@tanstack/react-query";
5
+ import { NavLink as qt, useLocation as vt, useNavigate as Ie, Outlet as Ra, Navigate as Ia, Link as be, useSearchParams as zt, useParams as ut, createBrowserRouter as Ba, RouterProvider as Ea } from "react-router-dom";
6
+ import { useTranslation as Z, initReactI18next as La } from "react-i18next";
7
+ import { BookOpen as Oa, ShoppingCart as Gn, CreditCard as qa, FileText as nn, Package as Wn, BarChart3 as za, Database as Ma, Settings as Fa, MessageCircle as $a, ChevronDown as Mt, ChevronRight as Dt, Plus as Hn, Trash2 as Qn, LineChart as Ua, ArrowLeft as Va, TrendingUp as Ka, ArrowDownRight as ja, ArrowUpRight as Ga, Wallet as Wa, Receipt as mn, ChevronLeft as Ha, Info as Qa } from "lucide-react";
8
8
  import { createColumnHelper as Yn, useReactTable as Jn, getCoreRowModel as Zn, flexRender as Bt } from "@tanstack/react-table";
9
9
  import { createPortal as Xn } from "react-dom";
10
- import { ResponsiveContainer as Ha, LineChart as Qa, CartesianGrid as pn, XAxis as hn, YAxis as gn, Tooltip as Vt, Line as Ya, PieChart as Ja, Pie as Za, Cell as Xa, BarChart as er, Bar as tr } from "recharts";
10
+ import { ResponsiveContainer as Ya, LineChart as Ja, CartesianGrid as pn, XAxis as hn, YAxis as gn, Tooltip as Vt, Line as Za, PieChart as Xa, Pie as er, Cell as tr, BarChart as nr, Bar as ar } from "recharts";
11
11
  import ea from "i18next";
12
12
  import { default as Qo } from "i18next";
13
13
  let ct = "/api";
14
14
  function Mo(t) {
15
15
  ct = t.replace(/\/+$/, "");
16
16
  }
17
- function nr(t) {
17
+ function rr(t) {
18
18
  return new URL(`${ct}${t}`, window.location.origin).toString();
19
19
  }
20
20
  class $e extends Error {
@@ -22,7 +22,7 @@ class $e extends Error {
22
22
  super(a), this.status = n;
23
23
  }
24
24
  }
25
- function ar(t) {
25
+ function sr(t) {
26
26
  if (!t) return "Request failed";
27
27
  if (typeof t == "string") return t;
28
28
  if (Array.isArray(t))
@@ -47,7 +47,7 @@ async function B(t, n) {
47
47
  if (a.status === 401 && !t.startsWith("/auth/"))
48
48
  throw window.location.href = "/login", new $e(401, "Session expired");
49
49
  const s = await a.json().catch(() => ({ detail: a.statusText }));
50
- throw new $e(a.status, ar(s.detail));
50
+ throw new $e(a.status, sr(s.detail));
51
51
  }
52
52
  return a.json();
53
53
  }
@@ -58,7 +58,7 @@ function Re(t) {
58
58
  ), a = new URLSearchParams(n).toString();
59
59
  return a ? `?${a}` : "";
60
60
  }
61
- const _ = {
61
+ const T = {
62
62
  // Generic request (used by sidebar for chat sessions)
63
63
  request: B,
64
64
  // Chat attachments
@@ -96,6 +96,10 @@ const _ = {
96
96
  adjacentDocument: (t, n, a) => B(
97
97
  `/documents/${t}/${encodeURIComponent(n)}/adjacent${Re(a)}`
98
98
  ),
99
+ // Prev/next master record around `name` in the master list's order (name ASC).
100
+ adjacentMaster: (t, n) => B(
101
+ `/masters/${t}/${encodeURIComponent(n)}/adjacent`
102
+ ),
99
103
  createDocument: (t, n) => B(`/documents/${t}`, { method: "POST", body: JSON.stringify(n) }),
100
104
  updateDocument: (t, n, a) => B(`/documents/${t}/${encodeURIComponent(n)}`, {
101
105
  method: "PUT",
@@ -198,7 +202,7 @@ const _ = {
198
202
  const a = new URLSearchParams();
199
203
  n != null && n.link && a.set("link", "1"), n != null && n.invite && a.set("invite", n.invite);
200
204
  const s = a.toString() ? `?${a.toString()}` : "";
201
- return nr(`/auth/${encodeURIComponent(t)}/login${s}`);
205
+ return rr(`/auth/${encodeURIComponent(t)}/login${s}`);
202
206
  },
203
207
  oauthListIdentities: () => B("/auth/oauth/identities"),
204
208
  authRegister: (t) => B("/auth/register", { method: "POST", body: JSON.stringify(t) }),
@@ -237,27 +241,27 @@ const _ = {
237
241
  ),
238
242
  getDemoSpend: () => B("/admin/demo-spend")
239
243
  }, ta = jn(null);
240
- function rr({ children: t }) {
244
+ function ir({ children: t }) {
241
245
  const [n, a] = S(null), [s, i] = S(!0);
242
- re(() => {
243
- _.authMe().then((m) => a(m)).catch(() => a(null)).finally(() => i(!1));
246
+ ae(() => {
247
+ T.authMe().then((d) => a(d)).catch(() => a(null)).finally(() => i(!1));
244
248
  }, []);
245
- const o = Pe(async (m, p) => {
246
- const u = await _.authLogin(m, p);
247
- return a(u), u;
248
- }, []), l = Pe(async (m, p, u, w) => {
249
- const b = await _.authRegister({ email: m, full_name: p, password: u, invite_token: w });
250
- return a(b), b;
249
+ const o = Pe(async (d, p) => {
250
+ const m = await T.authLogin(d, p);
251
+ return a(m), m;
252
+ }, []), l = Pe(async (d, p, m, w) => {
253
+ const x = await T.authRegister({ email: d, full_name: p, password: m, invite_token: w });
254
+ return a(x), x;
251
255
  }, []), c = Pe(async () => {
252
256
  try {
253
- await _.authLogout();
257
+ await T.authLogout();
254
258
  } catch {
255
259
  }
256
260
  a(null);
257
261
  }, []), g = Pe(async () => {
258
262
  try {
259
- const m = await _.authMe();
260
- a(m);
263
+ const d = await T.authMe();
264
+ a(d);
261
265
  } catch {
262
266
  }
263
267
  }, []);
@@ -294,7 +298,7 @@ const na = jn(null), fn = {
294
298
  function Kt(t) {
295
299
  return typeof t != "string" ? null : t.trim().toLowerCase().replace(/\s+/g, "-");
296
300
  }
297
- function sr(t, n) {
301
+ function or(t, n) {
298
302
  if (t === "create_custom_analytics_report" || t === "update_custom_analytics_report")
299
303
  return { group: "Custom Analytics", item: "" };
300
304
  if (!n) return null;
@@ -344,7 +348,7 @@ function vn(t) {
344
348
  const n = an();
345
349
  n.delete(t) && ra(n);
346
350
  }
347
- function ir() {
351
+ function lr() {
348
352
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `req-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
349
353
  }
350
354
  function tt(t) {
@@ -352,9 +356,9 @@ function tt(t) {
352
356
  const n = /^\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/.test(t) ? t.replace(" ", "T") : t, a = new Date(n).getTime();
353
357
  return Number.isNaN(a) ? 0 : a;
354
358
  }
355
- function or({ children: t }) {
356
- const n = We(), [a, s] = S([]), [i, o] = S({}), [l, c] = S({}), [g, m] = S({}), [p, u] = S({}), [w, b] = S({}), [N, y] = S({}), [T, A] = S({}), [x, d] = S(null), [h, P] = S("connecting"), [v, I] = S(0), C = ee(null), O = ee(null), G = ee(/* @__PURE__ */ new Map()), te = ee(null), U = ee({}), f = ee({}), q = ee(null);
357
- function D(R) {
359
+ function cr({ children: t }) {
360
+ const n = We(), [a, s] = S([]), [i, o] = S({}), [l, c] = S({}), [g, d] = S({}), [p, m] = S({}), [w, x] = S({}), [N, y] = S({}), [D, A] = S({}), [b, u] = S(null), [h, _] = S("connecting"), [v, I] = S(0), C = ee(null), O = ee(null), G = ee(/* @__PURE__ */ new Map()), te = ee(null), U = ee({}), f = ee({}), q = ee(null);
361
+ function P(R) {
358
362
  for (const V of G.current.values())
359
363
  V.reject(new Error(R));
360
364
  G.current.clear();
@@ -366,7 +370,7 @@ function or({ children: t }) {
366
370
  }));
367
371
  }
368
372
  function Y(R, V) {
369
- b((W) => ({ ...W, [R]: V }));
373
+ x((W) => ({ ...W, [R]: V }));
370
374
  }
371
375
  function ne(R, V) {
372
376
  y((W) => ({ ...W, [R]: V }));
@@ -375,8 +379,8 @@ function or({ children: t }) {
375
379
  A((W) => ({ ...W, [R]: V }));
376
380
  }
377
381
  function de(R, V) {
378
- q.current !== null && window.clearTimeout(q.current), d({ group: R, item: V, key: Date.now() }), q.current = window.setTimeout(() => {
379
- d((W) => (W == null ? void 0 : W.group) === R && (W == null ? void 0 : W.item) === V ? null : W), q.current = null;
382
+ q.current !== null && window.clearTimeout(q.current), u({ group: R, item: V, key: Date.now() }), q.current = window.setTimeout(() => {
383
+ u((W) => (W == null ? void 0 : W.group) === R && (W == null ? void 0 : W.item) === V ? null : W), q.current = null;
380
384
  }, 1100);
381
385
  }
382
386
  function _e(R) {
@@ -407,9 +411,9 @@ function or({ children: t }) {
407
411
  throw new Error("Chat is disconnected.");
408
412
  V.send(JSON.stringify(R));
409
413
  }
410
- function ae(R, V, W) {
414
+ function re(R, V, W) {
411
415
  return new Promise((ve, xe) => {
412
- const Ae = ir();
416
+ const Ae = lr();
413
417
  G.current.set(Ae, {
414
418
  expectedType: W,
415
419
  resolve: ve,
@@ -422,18 +426,18 @@ function or({ children: t }) {
422
426
  }
423
427
  });
424
428
  }
425
- re(() => {
429
+ ae(() => {
426
430
  let R = !1;
427
431
  function V() {
428
432
  if (R) return;
429
- P("connecting");
433
+ _("connecting");
430
434
  const ve = `${window.location.protocol === "https:" ? "wss:" : "ws:"}//${window.location.host}/ws/chat`, xe = new WebSocket(ve);
431
435
  C.current = xe, xe.onopen = () => {
432
436
  if (R) {
433
437
  xe.close();
434
438
  return;
435
439
  }
436
- P("connected"), I((Ae) => Ae + 1);
440
+ _("connected"), I((Ae) => Ae + 1);
437
441
  }, xe.onmessage = (Ae) => {
438
442
  var ot;
439
443
  try {
@@ -453,7 +457,7 @@ function or({ children: t }) {
453
457
  ze.length > 0 && Promise.all(
454
458
  ze.map(async (Ne) => {
455
459
  try {
456
- const le = await _.getChatSession(Ne);
460
+ const le = await T.getChatSession(Ne);
457
461
  return !le || le.detail || !le.id ? (vn(Ne), null) : le;
458
462
  } catch {
459
463
  return null;
@@ -478,7 +482,7 @@ function or({ children: t }) {
478
482
  vn(z), he((j) => j.filter((Q) => Q.id !== z)), o((j) => {
479
483
  const Q = { ...j };
480
484
  return delete Q[z], Q;
481
- }), b((j) => {
485
+ }), x((j) => {
482
486
  const Q = { ...j };
483
487
  return delete Q[z], Q;
484
488
  }), y((j) => {
@@ -490,10 +494,10 @@ function or({ children: t }) {
490
494
  }), c((j) => {
491
495
  const Q = { ...j };
492
496
  return delete Q[z], Q;
493
- }), m((j) => {
497
+ }), d((j) => {
494
498
  const Q = { ...j };
495
499
  return delete Q[z], Q;
496
- }), u((j) => {
500
+ }), m((j) => {
497
501
  const Q = { ...j };
498
502
  return delete Q[z], Q;
499
503
  });
@@ -513,7 +517,7 @@ function or({ children: t }) {
513
517
  return { ...le, [z]: [...Nt, ...me] };
514
518
  }
515
519
  return { ...le, [z]: M };
516
- }), c((le) => ({ ...le, [z]: Q })), m((le) => ({ ...le, [z]: ze })), u((le) => ({ ...le, [z]: !1 }));
520
+ }), c((le) => ({ ...le, [z]: Q })), d((le) => ({ ...le, [z]: ze })), m((le) => ({ ...le, [z]: !1 }));
517
521
  const Ne = typeof K.title == "string" ? K.title : null;
518
522
  if (Ne && he(
519
523
  (le) => le.map((me) => me.id === z ? { ...me, title: Ne } : me)
@@ -524,7 +528,7 @@ function or({ children: t }) {
524
528
  return;
525
529
  }
526
530
  if (pe === "history_cleared" && z) {
527
- o((M) => ({ ...M, [z]: [] })), c((M) => ({ ...M, [z]: !1 })), m((M) => ({ ...M, [z]: null })), u((M) => ({ ...M, [z]: !1 })), Y(z, !1), ne(z, "idle"), ce(z, null);
531
+ o((M) => ({ ...M, [z]: [] })), c((M) => ({ ...M, [z]: !1 })), d((M) => ({ ...M, [z]: null })), m((M) => ({ ...M, [z]: !1 })), Y(z, !1), ne(z, "idle"), ce(z, null);
528
532
  return;
529
533
  }
530
534
  if (pe === "message_added" && z) {
@@ -622,7 +626,7 @@ function or({ children: t }) {
622
626
  const Q = typeof K.report_id == "string" ? K.report_id : void 0, ze = typeof ((ot = M.args) == null ? void 0 : ot.report_id) == "string" ? M.args.report_id : void 0;
623
627
  de("Custom Analytics", Q || ze || ""), n.invalidateQueries({ queryKey: ["runtime-drafts"] });
624
628
  } else {
625
- const Q = sr(M.tool, M.args);
629
+ const Q = or(M.tool, M.args);
626
630
  Q && de(Q.group, Q.item);
627
631
  }
628
632
  f.current = {
@@ -656,7 +660,7 @@ function or({ children: t }) {
656
660
  }, xe.onerror = () => {
657
661
  xe.close();
658
662
  }, xe.onclose = (Ae) => {
659
- if (C.current === xe && (C.current = null), D("Chat disconnected."), P("disconnected"), !R) {
663
+ if (C.current === xe && (C.current = null), P("Chat disconnected."), _("disconnected"), !R) {
660
664
  if (Ae.code === 4001 || Ae.code === 4003) {
661
665
  window.location.href = "/login";
662
666
  return;
@@ -666,7 +670,7 @@ function or({ children: t }) {
666
670
  };
667
671
  }
668
672
  return V(), () => {
669
- if (R = !0, O.current !== null && window.clearTimeout(O.current), q.current !== null && window.clearTimeout(q.current), D("Chat disconnected."), C.current) {
673
+ if (R = !0, O.current !== null && window.clearTimeout(O.current), q.current !== null && window.clearTimeout(q.current), P("Chat disconnected."), C.current) {
670
674
  const W = C.current;
671
675
  C.current = null, W.close();
672
676
  }
@@ -675,7 +679,7 @@ function or({ children: t }) {
675
679
  async function Be() {
676
680
  if (te.current)
677
681
  return te.current;
678
- const R = ae("create_session", {}, "session_created").then((V) => V.session).finally(() => {
682
+ const R = re("create_session", {}, "session_created").then((V) => V.session).finally(() => {
679
683
  te.current === R && (te.current = null);
680
684
  });
681
685
  return te.current = R, R;
@@ -683,7 +687,7 @@ function or({ children: t }) {
683
687
  async function De(R) {
684
688
  ne(R, "running"), ce(R, null);
685
689
  try {
686
- await ae("start_demo", { session_id: R }, "demo_started");
690
+ await re("start_demo", { session_id: R }, "demo_started");
687
691
  } catch (V) {
688
692
  throw ne(R, "idle"), V;
689
693
  }
@@ -695,29 +699,29 @@ function or({ children: t }) {
695
699
  }
696
700
  }
697
701
  async function Me(R) {
698
- await ae("delete_session", { session_id: R }, "session_deleted");
702
+ await re("delete_session", { session_id: R }, "session_deleted");
699
703
  }
700
704
  async function xt(R) {
701
- await ae("load_history", { session_id: R }, "history_loaded");
705
+ await re("load_history", { session_id: R }, "history_loaded");
702
706
  }
703
707
  async function pt(R) {
704
708
  if (p[R]) return;
705
709
  const V = g[R];
706
710
  if (V != null && l[R]) {
707
- u((W) => ({ ...W, [R]: !0 }));
711
+ m((W) => ({ ...W, [R]: !0 }));
708
712
  try {
709
- await ae(
713
+ await re(
710
714
  "load_history",
711
715
  { session_id: R, before_id: V },
712
716
  "history_loaded"
713
717
  );
714
718
  } catch (W) {
715
- throw u((ve) => ({ ...ve, [R]: !1 })), W;
719
+ throw m((ve) => ({ ...ve, [R]: !1 })), W;
716
720
  }
717
721
  }
718
722
  }
719
723
  async function Je(R) {
720
- await ae("clear_history", { session_id: R }, "history_cleared");
724
+ await re("clear_history", { session_id: R }, "history_cleared");
721
725
  }
722
726
  function ke(R, V, W) {
723
727
  const ve = V.trim(), xe = ((W == null ? void 0 : W.length) ?? 0) > 0;
@@ -735,7 +739,7 @@ function or({ children: t }) {
735
739
  }
736
740
  }
737
741
  async function Te(R, V, W) {
738
- const ve = await ae(
742
+ const ve = await re(
739
743
  "transcribe",
740
744
  { audio_data: R, audio_format: V, session_id: W },
741
745
  "transcription_result"
@@ -760,7 +764,7 @@ function or({ children: t }) {
760
764
  return R ? N[R] ?? "idle" : "idle";
761
765
  }
762
766
  function gt(R) {
763
- return R ? T[R] ?? null : null;
767
+ return R ? D[R] ?? null : null;
764
768
  }
765
769
  return /* @__PURE__ */ e(
766
770
  na.Provider,
@@ -769,7 +773,7 @@ function or({ children: t }) {
769
773
  sessions: a,
770
774
  connectionStatus: h,
771
775
  connectionVersion: v,
772
- navigationFlash: x,
776
+ navigationFlash: b,
773
777
  createSession: Be,
774
778
  startDemo: De,
775
779
  completeDemoTyping: Ve,
@@ -799,7 +803,7 @@ function mt() {
799
803
  const dt = [
800
804
  {
801
805
  label: "Introduction",
802
- icon: /* @__PURE__ */ e(Ea, { className: "h-4 w-4" }),
806
+ icon: /* @__PURE__ */ e(Oa, { className: "h-4 w-4" }),
803
807
  items: [
804
808
  { label: "Getting Started", path: "/tutorial" },
805
809
  { label: "Company Setup", path: "/setup" },
@@ -819,7 +823,7 @@ const dt = [
819
823
  },
820
824
  {
821
825
  label: "Buying",
822
- icon: /* @__PURE__ */ e(La, { className: "h-4 w-4" }),
826
+ icon: /* @__PURE__ */ e(qa, { className: "h-4 w-4" }),
823
827
  items: [
824
828
  { label: "Purchase Order", path: "/app/purchase-order" },
825
829
  { label: "Purchase Invoice", path: "/app/purchase-invoice" }
@@ -848,7 +852,7 @@ const dt = [
848
852
  },
849
853
  {
850
854
  label: "Reports",
851
- icon: /* @__PURE__ */ e(Oa, { className: "h-4 w-4" }),
855
+ icon: /* @__PURE__ */ e(za, { className: "h-4 w-4" }),
852
856
  items: [
853
857
  { label: "Trial Balance", path: "/reports/trial-balance" },
854
858
  { label: "Profit & Loss", path: "/reports/profit-and-loss" },
@@ -862,7 +866,7 @@ const dt = [
862
866
  },
863
867
  {
864
868
  label: "Masters",
865
- icon: /* @__PURE__ */ e(qa, { className: "h-4 w-4" }),
869
+ icon: /* @__PURE__ */ e(Ma, { className: "h-4 w-4" }),
866
870
  items: [
867
871
  { label: "Company", path: "/masters/company" },
868
872
  { label: "Customer", path: "/masters/customer" },
@@ -873,7 +877,7 @@ const dt = [
873
877
  },
874
878
  {
875
879
  label: "Settings",
876
- icon: /* @__PURE__ */ e(za, { className: "h-4 w-4" }),
880
+ icon: /* @__PURE__ */ e(Fa, { className: "h-4 w-4" }),
877
881
  items: [
878
882
  { label: "General", path: "/admin/settings" },
879
883
  { label: "Pricing Rule", path: "/app/pricing-rule" },
@@ -881,7 +885,7 @@ const dt = [
881
885
  ]
882
886
  }
883
887
  ];
884
- function lr() {
888
+ function dr() {
885
889
  return dt;
886
890
  }
887
891
  function Fo(t, n) {
@@ -904,7 +908,7 @@ function Uo(t) {
904
908
  n.style.setProperty(a.startsWith("--") ? a : `--${a}`, s);
905
909
  }
906
910
  }
907
- function cr() {
911
+ function ur() {
908
912
  return Jt;
909
913
  }
910
914
  function Le(...t) {
@@ -972,17 +976,17 @@ const sn = {
972
976
  Settings: "bg-purple-300 text-purple-950 ring-2 ring-inset ring-purple-100",
973
977
  "Custom Analytics": "bg-indigo-300 text-indigo-950 ring-2 ring-inset ring-indigo-100"
974
978
  };
975
- function dr() {
979
+ function mr() {
976
980
  const [t, n] = rn("chats"), a = vt(), s = Ie(), { t: i } = Z(), { sessions: o, createSession: l, deleteSession: c } = mt(), g = async () => {
977
981
  try {
978
982
  const p = await l();
979
983
  s(`/chat/${p.id}`);
980
984
  } catch {
981
985
  }
982
- }, m = async (p, u) => {
986
+ }, d = async (p, m) => {
983
987
  p.preventDefault(), p.stopPropagation();
984
988
  try {
985
- await c(u), window.location.pathname === `/chat/${u}` && s("/");
989
+ await c(m), window.location.pathname === `/chat/${m}` && s("/");
986
990
  } catch {
987
991
  }
988
992
  };
@@ -994,7 +998,7 @@ function dr() {
994
998
  onClick: n,
995
999
  className: "flex w-full items-center gap-2 px-4 py-2 text-xs font-semibold uppercase tracking-wider text-fg-muted transition-colors hover:text-fg",
996
1000
  children: [
997
- /* @__PURE__ */ e(Ma, { className: "h-4 w-4" }),
1001
+ /* @__PURE__ */ e($a, { className: "h-4 w-4" }),
998
1002
  /* @__PURE__ */ e("span", { className: "flex-1 text-left", children: i("nav.chats") }),
999
1003
  t ? /* @__PURE__ */ e(Mt, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ e(Dt, { className: "h-3.5 w-3.5" })
1000
1004
  ]
@@ -1013,7 +1017,7 @@ function dr() {
1013
1017
  }
1014
1018
  ) }),
1015
1019
  o.map((p) => {
1016
- const u = a.pathname === `/chat/${p.id}`;
1020
+ const m = a.pathname === `/chat/${p.id}`;
1017
1021
  return /* @__PURE__ */ r("li", { className: "group relative", children: [
1018
1022
  /* @__PURE__ */ e(
1019
1023
  qt,
@@ -1021,16 +1025,16 @@ function dr() {
1021
1025
  to: `/chat/${p.id}`,
1022
1026
  className: Le(
1023
1027
  "relative block truncate px-4 py-1.5 pl-10 pr-8 text-sm transition-colors",
1024
- u ? "bg-surface-subtle font-medium text-fg" : "text-fg-muted hover:bg-surface-subtle hover:text-fg"
1028
+ m ? "bg-surface-subtle font-medium text-fg" : "text-fg-muted hover:bg-surface-subtle hover:text-fg"
1025
1029
  ),
1026
1030
  children: p.title
1027
1031
  }
1028
1032
  ),
1029
- u && /* @__PURE__ */ e(on, {}),
1033
+ m && /* @__PURE__ */ e(on, {}),
1030
1034
  /* @__PURE__ */ e(
1031
1035
  "button",
1032
1036
  {
1033
- onClick: (w) => m(w, p.id),
1037
+ onClick: (w) => d(w, p.id),
1034
1038
  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",
1035
1039
  title: i("nav.deleteChat"),
1036
1040
  children: /* @__PURE__ */ e(Qn, { className: "h-3.5 w-3.5" })
@@ -1050,34 +1054,34 @@ function on() {
1050
1054
  }
1051
1055
  );
1052
1056
  }
1053
- function ur() {
1054
- const [t, n, a] = rn("custom-analytics"), s = vt(), i = Ie(), o = We(), { t: l } = Z(), { navigationFlash: c, sessions: g, createSession: m } = mt(), p = (c == null ? void 0 : c.group) === "Custom Analytics", u = sn["Custom Analytics"], { data: w } = ie({
1057
+ function pr() {
1058
+ const [t, n, a] = rn("custom-analytics"), s = vt(), i = Ie(), o = We(), { t: l } = Z(), { navigationFlash: c, sessions: g, createSession: d } = mt(), p = (c == null ? void 0 : c.group) === "Custom Analytics", m = sn["Custom Analytics"], { data: w } = ie({
1055
1059
  queryKey: ["runtime-drafts"],
1056
- queryFn: () => _.listRuntimeDrafts(),
1060
+ queryFn: () => T.listRuntimeDrafts(),
1057
1061
  staleTime: 3e4
1058
- }), b = (w == null ? void 0 : w.drafts) ?? [];
1059
- re(() => {
1062
+ }), x = (w == null ? void 0 : w.drafts) ?? [];
1063
+ ae(() => {
1060
1064
  (c == null ? void 0 : c.group) === "Custom Analytics" && (a(), o.invalidateQueries({ queryKey: ["runtime-drafts"] }));
1061
1065
  }, [c == null ? void 0 : c.key, o, a]);
1062
1066
  const N = oe({
1063
- mutationFn: (A) => _.deleteRuntimeDraft(A),
1064
- onSuccess: (A, x) => {
1065
- o.invalidateQueries({ queryKey: ["runtime-drafts"] }), s.search.includes(`report_id=${x}`) && i("/reports/analytics");
1067
+ mutationFn: (A) => T.deleteRuntimeDraft(A),
1068
+ onSuccess: (A, b) => {
1069
+ o.invalidateQueries({ queryKey: ["runtime-drafts"] }), s.search.includes(`report_id=${b}`) && i("/reports/analytics");
1066
1070
  }
1067
- }), y = async (A, x) => {
1068
- A.preventDefault(), A.stopPropagation(), N.mutate(x);
1069
- }, T = async () => {
1070
- var d;
1071
+ }), y = async (A, b) => {
1072
+ A.preventDefault(), A.stopPropagation(), N.mutate(b);
1073
+ }, D = async () => {
1074
+ var u;
1071
1075
  const A = "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>";
1072
- let x = ((d = g[0]) == null ? void 0 : d.id) || "";
1073
- if (!x)
1076
+ let b = ((u = g[0]) == null ? void 0 : u.id) || "";
1077
+ if (!b)
1074
1078
  try {
1075
- x = (await m()).id;
1079
+ b = (await d()).id;
1076
1080
  } catch {
1077
1081
  i("/reports/analytics");
1078
1082
  return;
1079
1083
  }
1080
- i(`/chat/${x}`, { state: { prefillMessage: A } });
1084
+ i(`/chat/${b}`, { state: { prefillMessage: A } });
1081
1085
  };
1082
1086
  return /* @__PURE__ */ r("div", { children: [
1083
1087
  /* @__PURE__ */ r(
@@ -1087,10 +1091,10 @@ function ur() {
1087
1091
  onClick: n,
1088
1092
  className: Le(
1089
1093
  "flex w-full items-center gap-2 px-4 py-2 text-xs font-semibold uppercase tracking-wider text-fg-muted transition-all duration-300 hover:text-fg",
1090
- p && u
1094
+ p && m
1091
1095
  ),
1092
1096
  children: [
1093
- /* @__PURE__ */ e(Fa, { className: "h-4 w-4" }),
1097
+ /* @__PURE__ */ e(Ua, { className: "h-4 w-4" }),
1094
1098
  /* @__PURE__ */ e("span", { className: "flex-1 text-left", children: l("nav.customAnalytics") }),
1095
1099
  t ? /* @__PURE__ */ e(Mt, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ e(Dt, { className: "h-3.5 w-3.5" })
1096
1100
  ]
@@ -1100,7 +1104,7 @@ function ur() {
1100
1104
  /* @__PURE__ */ e("li", { children: /* @__PURE__ */ r(
1101
1105
  "button",
1102
1106
  {
1103
- onClick: T,
1107
+ onClick: D,
1104
1108
  className: "flex w-full items-center gap-2 px-4 py-1.5 pl-10 text-sm text-brand transition-colors hover:bg-brand/5",
1105
1109
  children: [
1106
1110
  /* @__PURE__ */ e(Hn, { className: "h-3.5 w-3.5" }),
@@ -1108,28 +1112,28 @@ function ur() {
1108
1112
  ]
1109
1113
  }
1110
1114
  ) }),
1111
- b.map((A) => {
1112
- const x = `/reports/analytics?report_id=${A.id}`, d = s.pathname === "/reports/analytics" && s.search.includes(`report_id=${A.id}`), h = (c == null ? void 0 : c.group) === "Custom Analytics" && (c == null ? void 0 : c.item) === A.id;
1115
+ x.map((A) => {
1116
+ const b = `/reports/analytics?report_id=${A.id}`, u = s.pathname === "/reports/analytics" && s.search.includes(`report_id=${A.id}`), h = (c == null ? void 0 : c.group) === "Custom Analytics" && (c == null ? void 0 : c.item) === A.id;
1113
1117
  return /* @__PURE__ */ r("li", { className: "group relative", children: [
1114
1118
  /* @__PURE__ */ e(
1115
1119
  qt,
1116
1120
  {
1117
- to: x,
1121
+ to: b,
1118
1122
  className: Le(
1119
1123
  "relative block truncate px-4 py-1.5 pl-10 pr-8 text-sm transition-all duration-300",
1120
- !d && "text-fg-muted hover:bg-surface-subtle hover:text-fg",
1121
- d && "bg-surface-subtle font-medium text-fg",
1122
- h && u
1124
+ !u && "text-fg-muted hover:bg-surface-subtle hover:text-fg",
1125
+ u && "bg-surface-subtle font-medium text-fg",
1126
+ h && m
1123
1127
  ),
1124
1128
  title: A.title,
1125
1129
  children: A.title
1126
1130
  }
1127
1131
  ),
1128
- d && /* @__PURE__ */ e(on, {}),
1132
+ u && /* @__PURE__ */ e(on, {}),
1129
1133
  /* @__PURE__ */ e(
1130
1134
  "button",
1131
1135
  {
1132
- onClick: (P) => y(P, A.id),
1136
+ onClick: (_) => y(_, A.id),
1133
1137
  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",
1134
1138
  title: l("nav.deleteReport"),
1135
1139
  children: /* @__PURE__ */ e(Qn, { className: "h-3.5 w-3.5" })
@@ -1140,7 +1144,7 @@ function ur() {
1140
1144
  ] })
1141
1145
  ] });
1142
1146
  }
1143
- function mr({ group: t }) {
1147
+ function hr({ group: t }) {
1144
1148
  const [n, a] = rn(t.label), { t: s } = Z(), { navigationFlash: i } = mt(), o = (i == null ? void 0 : i.group) === t.label, l = sn[t.label] ?? "bg-blue-300 text-blue-950 ring-2 ring-inset ring-blue-100";
1145
1149
  return /* @__PURE__ */ r("div", { children: [
1146
1150
  /* @__PURE__ */ r(
@@ -1161,21 +1165,21 @@ function mr({ group: t }) {
1161
1165
  ),
1162
1166
  n && /* @__PURE__ */ e("ul", { className: "mb-1", children: t.items.map((c) => {
1163
1167
  const g = t.items.some(
1164
- (m) => m.path !== c.path && m.path.startsWith(c.path + "/")
1168
+ (d) => d.path !== c.path && d.path.startsWith(c.path + "/")
1165
1169
  );
1166
1170
  return /* @__PURE__ */ e("li", { className: "relative", children: /* @__PURE__ */ e(
1167
1171
  qt,
1168
1172
  {
1169
1173
  to: c.path,
1170
1174
  end: g,
1171
- className: ({ isActive: m }) => Le(
1175
+ className: ({ isActive: d }) => Le(
1172
1176
  "relative block px-4 py-1.5 pl-10 text-sm transition-all duration-300",
1173
- !m && "text-fg-muted hover:bg-surface-subtle hover:text-fg",
1174
- m && "bg-surface-subtle font-medium text-fg",
1177
+ !d && "text-fg-muted hover:bg-surface-subtle hover:text-fg",
1178
+ d && "bg-surface-subtle font-medium text-fg",
1175
1179
  (i == null ? void 0 : i.group) === t.label && (i == null ? void 0 : i.item) === c.label && l
1176
1180
  ),
1177
- children: ({ isActive: m }) => /* @__PURE__ */ r(we, { children: [
1178
- m && /* @__PURE__ */ e(on, {}),
1181
+ children: ({ isActive: d }) => /* @__PURE__ */ r(we, { children: [
1182
+ d && /* @__PURE__ */ e(on, {}),
1179
1183
  s(`nav.items.${c.label}`, { defaultValue: c.label })
1180
1184
  ] })
1181
1185
  }
@@ -1183,25 +1187,25 @@ function mr({ group: t }) {
1183
1187
  }) })
1184
1188
  ] });
1185
1189
  }
1186
- const pr = {
1190
+ const gr = {
1187
1191
  "/setup/opening-balances": "opening_balances_enabled"
1188
1192
  };
1189
- function hr({ isMobileOpen: t = !1, onClose: n }) {
1193
+ function fr({ isMobileOpen: t = !1, onClose: n }) {
1190
1194
  var c;
1191
1195
  const { data: a } = ie({
1192
1196
  queryKey: ["settings"],
1193
- queryFn: () => _.getSettings(),
1197
+ queryFn: () => T.getSettings(),
1194
1198
  staleTime: 6e4
1195
1199
  }), { data: s } = ie({
1196
1200
  queryKey: ["setup-status"],
1197
- queryFn: () => _.setupStatus(),
1201
+ queryFn: () => T.setupStatus(),
1198
1202
  staleTime: 6e4
1199
- }), i = (c = s == null ? void 0 : s.companies) == null ? void 0 : c[0], o = (i == null ? void 0 : i.company_name) || (i == null ? void 0 : i.name) || cr().appName, l = Ce(() => lr().map((m) => ({
1200
- ...m,
1201
- items: m.items.filter((p) => {
1203
+ }), i = (c = s == null ? void 0 : s.companies) == null ? void 0 : c[0], o = (i == null ? void 0 : i.company_name) || (i == null ? void 0 : i.name) || ur().appName, l = Ce(() => dr().map((d) => ({
1204
+ ...d,
1205
+ items: d.items.filter((p) => {
1202
1206
  if (p.path === "/setup" && (s != null && s.setup_complete)) return !1;
1203
- const u = pr[p.path];
1204
- return !u || !a ? !0 : a[u] !== "0";
1207
+ const m = gr[p.path];
1208
+ return !m || !a ? !0 : a[m] !== "0";
1205
1209
  })
1206
1210
  })), [a, s]);
1207
1211
  return /* @__PURE__ */ r(
@@ -1247,16 +1251,16 @@ function hr({ isMobileOpen: t = !1, onClose: n }) {
1247
1251
  )
1248
1252
  ] }),
1249
1253
  /* @__PURE__ */ r("nav", { className: "flex-1 overflow-y-auto py-3", children: [
1250
- /* @__PURE__ */ e(dr, {}),
1251
- /* @__PURE__ */ e(ur, {}),
1252
- l.map((g) => /* @__PURE__ */ e(mr, { group: g }, g.label))
1254
+ /* @__PURE__ */ e(mr, {}),
1255
+ /* @__PURE__ */ e(pr, {}),
1256
+ l.map((g) => /* @__PURE__ */ e(hr, { group: g }, g.label))
1253
1257
  ] })
1254
1258
  ]
1255
1259
  }
1256
1260
  );
1257
1261
  }
1258
1262
  const Nn = (t) => t.replace(/-/g, " ").replace(/\b\w/g, (n) => n.toUpperCase());
1259
- function gr(t, n) {
1263
+ function yr(t, n) {
1260
1264
  const a = t.split("/").filter(Boolean);
1261
1265
  if (a[0] === "setup") return n("titles.setup");
1262
1266
  if (a[0] === "tutorial") return n("titles.tutorial");
@@ -1275,25 +1279,25 @@ function gr(t, n) {
1275
1279
  }
1276
1280
  return n("titles.dashboard");
1277
1281
  }
1278
- function fr(t) {
1282
+ function br(t) {
1279
1283
  const n = t.split("/").filter(Boolean);
1280
1284
  return (n[0] === "app" || n[0] === "masters") && n.length > 2 ? `/${n[0]}/${n[1]}` : n[0] === "setup" && n.length > 1 ? "/setup" : null;
1281
1285
  }
1282
- function yr() {
1283
- return /* @__PURE__ */ e(or, { children: /* @__PURE__ */ e(br, {}) });
1286
+ function vr() {
1287
+ return /* @__PURE__ */ e(cr, { children: /* @__PURE__ */ e(xr, {}) });
1284
1288
  }
1285
- function br() {
1286
- const { pathname: t } = vt(), n = Ie(), { user: a, logout: s } = st(), { navigationFlash: i } = mt(), { t: o } = Z(), l = gr(t, o), c = fr(t), g = () => {
1289
+ function xr() {
1290
+ const { pathname: t } = vt(), n = Ie(), { user: a, logout: s } = st(), { navigationFlash: i } = mt(), { t: o } = Z(), l = yr(t, o), c = br(t), g = () => {
1287
1291
  var w;
1288
1292
  c && (((w = window.history.state) == null ? void 0 : w.idx) > 0 ? n(-1) : n(c));
1289
- }, [m, p] = S(!1);
1290
- re(() => {
1293
+ }, [d, p] = S(!1);
1294
+ ae(() => {
1291
1295
  p(!1);
1292
1296
  }, [t]);
1293
- const u = i ? sn[i.group] : null;
1297
+ const m = i ? sn[i.group] : null;
1294
1298
  return /* @__PURE__ */ r("div", { className: "flex h-dvh bg-surface-muted", children: [
1295
- /* @__PURE__ */ e(hr, { isMobileOpen: m, onClose: () => p(!1) }),
1296
- m && /* @__PURE__ */ e(
1299
+ /* @__PURE__ */ e(fr, { isMobileOpen: d, onClose: () => p(!1) }),
1300
+ d && /* @__PURE__ */ e(
1297
1301
  "div",
1298
1302
  {
1299
1303
  onClick: () => p(!1),
@@ -1310,7 +1314,7 @@ function br() {
1310
1314
  onClick: () => p(!0),
1311
1315
  className: Le(
1312
1316
  "rounded p-1 text-gray-500 transition-all duration-300 hover:bg-gray-100 hover:text-gray-900 md:hidden",
1313
- u
1317
+ m
1314
1318
  ),
1315
1319
  "aria-label": o("header.openMenu"),
1316
1320
  children: /* @__PURE__ */ e("svg", { viewBox: "0 0 20 20", fill: "currentColor", width: "22", height: "22", children: /* @__PURE__ */ e("path", { d: "M6.835 4c-.451.004-.82.012-1.137.038-.386.032-.659.085-.876.162l-.2.086c-.44.224-.807.564-1.063.982l-.103.184c-.126.247-.206.562-.248 1.076-.043.523-.043 1.19-.043 2.135v2.664c0 .944 0 1.612.043 2.135.042.515.122.829.248 1.076l.103.184c.256.418.624.758 1.063.982l.2.086c.217.077.49.13.876.162.316.026.685.034 1.136.038zm11.33 7.327c0 .922 0 1.654-.048 2.243-.043.522-.125.977-.305 1.395l-.082.177a4 4 0 0 1-1.473 1.593l-.276.155c-.465.237-.974.338-1.57.387-.59.048-1.322.048-2.244.048H7.833c-.922 0-1.654 0-2.243-.048-.522-.042-.977-.126-1.395-.305l-.176-.082a4 4 0 0 1-1.594-1.473l-.154-.275c-.238-.466-.34-.975-.388-1.572-.048-.589-.048-1.32-.048-2.243V8.663c0-.922 0-1.654.048-2.243.049-.597.15-1.106.388-1.571l.154-.276a4 4 0 0 1 1.594-1.472l.176-.083c.418-.18.873-.263 1.395-.305.589-.048 1.32-.048 2.243-.048h4.334c.922 0 1.654 0 2.243.048.597.049 1.106.15 1.571.388l.276.154a4 4 0 0 1 1.473 1.594l.082.176c.18.418.262.873.305 1.395.048.589.048 1.32.048 2.243zm-10 4.668h4.002c.944 0 1.612 0 2.135-.043.514-.042.829-.122 1.076-.248l.184-.103c.418-.256.758-.624.982-1.063l.086-.2c.077-.217.13-.49.162-.876.043-.523.043-1.19.043-2.135V8.663c0-.944 0-1.612-.043-2.135-.032-.386-.085-.659-.162-.876l-.086-.2a2.67 2.67 0 0 0-.982-1.063l-.184-.103c-.247-.126-.562-.206-1.076-.248-.523-.043-1.19-.043-2.135-.043H8.164L8.165 4z" }) })
@@ -1322,7 +1326,7 @@ function br() {
1322
1326
  onClick: g,
1323
1327
  className: "-ml-1 rounded p-1 text-gray-500 hover:bg-gray-100 hover:text-gray-900",
1324
1328
  "aria-label": o("header.back"),
1325
- children: /* @__PURE__ */ e($a, { className: "h-5 w-5" })
1329
+ children: /* @__PURE__ */ e(Va, { className: "h-5 w-5" })
1326
1330
  }
1327
1331
  ),
1328
1332
  /* @__PURE__ */ e("h1", { className: "text-base font-semibold text-gray-500 md:text-lg", children: l })
@@ -1342,13 +1346,13 @@ function br() {
1342
1346
  )
1343
1347
  ] })
1344
1348
  ] }),
1345
- /* @__PURE__ */ e("main", { className: "flex-1 overflow-auto p-4 md:p-6", children: /* @__PURE__ */ e(_a, {}) })
1349
+ /* @__PURE__ */ e("main", { className: "flex-1 overflow-auto p-4 md:p-6", children: /* @__PURE__ */ e(Ra, {}) })
1346
1350
  ] })
1347
1351
  ] });
1348
1352
  }
1349
- function vr({ children: t }) {
1353
+ function Nr({ children: t }) {
1350
1354
  const { user: n, loading: a } = st();
1351
- return a ? /* @__PURE__ */ e("div", { className: "flex h-dvh items-center justify-center", children: /* @__PURE__ */ e("div", { className: "text-gray-400", children: "Loading..." }) }) : n ? /* @__PURE__ */ e(we, { children: t }) : /* @__PURE__ */ e(Ta, { to: "/login", replace: !0 });
1355
+ return a ? /* @__PURE__ */ e("div", { className: "flex h-dvh items-center justify-center", children: /* @__PURE__ */ e("div", { className: "text-gray-400", children: "Loading..." }) }) : n ? /* @__PURE__ */ e(we, { children: t }) : /* @__PURE__ */ e(Ia, { to: "/login", replace: !0 });
1352
1356
  }
1353
1357
  function F({ title: t, children: n, className: a, interactive: s }) {
1354
1358
  return /* @__PURE__ */ r(
@@ -1371,7 +1375,7 @@ function F({ title: t, children: n, className: a, interactive: s }) {
1371
1375
  }
1372
1376
  );
1373
1377
  }
1374
- const xr = {
1378
+ const wr = {
1375
1379
  default: "bg-brand/10 text-brand ring-1 ring-inset ring-brand/20",
1376
1380
  success: "bg-emerald-50 text-emerald-700 ring-1 ring-inset ring-emerald-200",
1377
1381
  warning: "bg-amber-50 text-amber-700 ring-1 ring-inset ring-amber-200",
@@ -1384,7 +1388,7 @@ function Rt({ variant: t = "default", dot: n, children: a, className: s }) {
1384
1388
  {
1385
1389
  className: Le(
1386
1390
  "inline-flex items-center gap-1.5 rounded-full px-2 py-0.5 text-xs font-medium",
1387
- xr[t],
1391
+ wr[t],
1388
1392
  s
1389
1393
  ),
1390
1394
  children: [
@@ -1394,7 +1398,7 @@ function Rt({ variant: t = "default", dot: n, children: a, className: s }) {
1394
1398
  }
1395
1399
  );
1396
1400
  }
1397
- const Nr = {
1401
+ const kr = {
1398
1402
  Draft: "secondary",
1399
1403
  Open: "default",
1400
1404
  Submitted: "default",
@@ -1409,14 +1413,14 @@ const Nr = {
1409
1413
  Overdue: "danger"
1410
1414
  };
1411
1415
  function ln({ status: t }) {
1412
- const { t: n } = Z(), a = Nr[t] ?? "secondary";
1416
+ const { t: n } = Z(), a = kr[t] ?? "secondary";
1413
1417
  return /* @__PURE__ */ e(Rt, { variant: a, children: n(`status.${t}`, { defaultValue: t }) });
1414
1418
  }
1415
1419
  function qe(t) {
1416
1420
  var s;
1417
1421
  const { data: n } = ie({
1418
1422
  queryKey: ["setup-status"],
1419
- queryFn: () => _.setupStatus(),
1423
+ queryFn: () => T.setupStatus(),
1420
1424
  staleTime: 3e5
1421
1425
  }), a = (n == null ? void 0 : n.companies) ?? [];
1422
1426
  if (t) {
@@ -1446,15 +1450,15 @@ function _t() {
1446
1450
  /* @__PURE__ */ e("div", { className: "h-9 w-9 shrink-0 animate-pulse rounded-lg bg-surface-subtle" })
1447
1451
  ] }) });
1448
1452
  }
1449
- const wr = {
1453
+ const Sr = {
1450
1454
  "Sales Invoice": mn,
1451
1455
  "Purchase Invoice": mn,
1452
- "Payment Entry": ja,
1456
+ "Payment Entry": Wa,
1453
1457
  "Sales Order": Gn,
1454
1458
  Quotation: nn
1455
1459
  };
1456
- function kr({ doc: t }) {
1457
- const { t: n } = Z(), a = t.doctype ?? t.type ?? "Document", s = t.creation ?? t.date, i = wr[a] ?? nn, l = `/app/${a.toLowerCase().replace(/\s+/g, "-")}/${encodeURIComponent(t.name)}`;
1460
+ function Cr({ doc: t }) {
1461
+ const { t: n } = Z(), a = t.doctype ?? t.type ?? "Document", s = t.creation ?? t.date, i = Sr[a] ?? nn, l = `/app/${a.toLowerCase().replace(/\s+/g, "-")}/${encodeURIComponent(t.name)}`;
1458
1462
  return /* @__PURE__ */ r(
1459
1463
  be,
1460
1464
  {
@@ -1483,10 +1487,10 @@ function kt() {
1483
1487
  /* @__PURE__ */ e("div", { className: "hidden h-3 w-16 animate-pulse rounded bg-surface-subtle sm:block" })
1484
1488
  ] });
1485
1489
  }
1486
- function Sr() {
1490
+ function Dr() {
1487
1491
  const { t } = Z(), { data: n, isLoading: a } = ie({
1488
1492
  queryKey: ["dashboard-summary"],
1489
- queryFn: () => _.dashboardSummary()
1493
+ queryFn: () => T.dashboardSummary()
1490
1494
  });
1491
1495
  return /* @__PURE__ */ r("div", { className: "space-y-6", children: [
1492
1496
  /* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-4", children: a ? /* @__PURE__ */ r(we, { children: [
@@ -1500,7 +1504,7 @@ function Sr() {
1500
1504
  {
1501
1505
  title: t("dashboard.totalRevenue"),
1502
1506
  value: n == null ? void 0 : n.total_revenue,
1503
- icon: Ua,
1507
+ icon: Ka,
1504
1508
  tone: "text-emerald-600 bg-emerald-500/10"
1505
1509
  }
1506
1510
  ),
@@ -1509,7 +1513,7 @@ function Sr() {
1509
1513
  {
1510
1514
  title: t("dashboard.outstandingReceivable"),
1511
1515
  value: n == null ? void 0 : n.outstanding_receivable,
1512
- icon: Va,
1516
+ icon: ja,
1513
1517
  tone: "text-sky-600 bg-sky-500/10"
1514
1518
  }
1515
1519
  ),
@@ -1518,7 +1522,7 @@ function Sr() {
1518
1522
  {
1519
1523
  title: t("dashboard.outstandingPayable"),
1520
1524
  value: n == null ? void 0 : n.outstanding_payable,
1521
- icon: Ka,
1525
+ icon: Ga,
1522
1526
  tone: "text-amber-600 bg-amber-500/10"
1523
1527
  }
1524
1528
  ),
@@ -1538,7 +1542,7 @@ function Sr() {
1538
1542
  /* @__PURE__ */ e(kt, {}),
1539
1543
  /* @__PURE__ */ e(kt, {}),
1540
1544
  /* @__PURE__ */ e(kt, {})
1541
- ] }) : n != null && n.recent_documents && n.recent_documents.length > 0 ? n.recent_documents.map((s, i) => /* @__PURE__ */ e(kr, { doc: s }, `${s.name}-${i}`)) : /* @__PURE__ */ e("div", { className: "px-3 py-10 text-center text-sm text-fg-muted", children: t("dashboard.noRecentDocuments") }) }) })
1545
+ ] }) : n != null && n.recent_documents && n.recent_documents.length > 0 ? n.recent_documents.map((s, i) => /* @__PURE__ */ e(Cr, { doc: s }, `${s.name}-${i}`)) : /* @__PURE__ */ e("div", { className: "px-3 py-10 text-center text-sm text-fg-muted", children: t("dashboard.noRecentDocuments") }) }) })
1542
1546
  ] });
1543
1547
  }
1544
1548
  const oa = "lad.docListContext";
@@ -1549,20 +1553,20 @@ function la() {
1549
1553
  return {};
1550
1554
  }
1551
1555
  }
1552
- function Cr(t, n) {
1556
+ function ca(t, n) {
1553
1557
  try {
1554
1558
  const a = la();
1555
1559
  a[t] = n, sessionStorage.setItem(oa, JSON.stringify(a));
1556
1560
  } catch {
1557
1561
  }
1558
1562
  }
1559
- function Dr(t) {
1563
+ function Ar(t) {
1560
1564
  return la()[t];
1561
1565
  }
1562
- function Ar(t, n) {
1566
+ function Pr(t, n) {
1563
1567
  const { data: a, isLoading: s, error: i, refetch: o } = ie({
1564
1568
  queryKey: ["documents", t, n],
1565
- queryFn: () => _.listDocuments(t, n),
1569
+ queryFn: () => T.listDocuments(t, n),
1566
1570
  enabled: !!t
1567
1571
  });
1568
1572
  return { data: a, isLoading: s, error: i, refetch: o };
@@ -1598,8 +1602,8 @@ function se(t, n) {
1598
1602
  (c) => {
1599
1603
  s(
1600
1604
  (g) => {
1601
- const m = new URLSearchParams(g);
1602
- return c === n || c === "" || c == null ? m.delete(t) : m.set(t, String(c)), m;
1605
+ const d = new URLSearchParams(g);
1606
+ return c === n || c === "" || c == null ? d.delete(t) : d.set(t, String(c)), d;
1603
1607
  },
1604
1608
  { replace: !0 }
1605
1609
  );
@@ -1618,7 +1622,7 @@ const rt = [
1618
1622
  { name: "qty", label: "Qty", type: "number", required: !0 },
1619
1623
  { name: "rate", label: "Rate", type: "currency", required: !0 },
1620
1624
  { name: "amount", label: "Amount", type: "currency", readOnly: !0 }
1621
- ], Pr = [
1625
+ ], _r = [
1622
1626
  ...rt,
1623
1627
  {
1624
1628
  name: "frequency",
@@ -1665,7 +1669,7 @@ const rt = [
1665
1669
  { name: "remarks", label: "Notes / Terms", type: "textarea" }
1666
1670
  ],
1667
1671
  childTables: [
1668
- { key: "items", label: "Items", fields: Pr },
1672
+ { key: "items", label: "Items", fields: _r },
1669
1673
  { key: "taxes", label: "Taxes", fields: at }
1670
1674
  ],
1671
1675
  listColumns: ["name", "customer", "transaction_date", "grand_total", "status"],
@@ -2252,7 +2256,7 @@ const rt = [
2252
2256
  conversions: []
2253
2257
  }
2254
2258
  };
2255
- function ca(t) {
2259
+ function da(t) {
2256
2260
  return cn[t];
2257
2261
  }
2258
2262
  function Vo(t) {
@@ -2261,43 +2265,43 @@ function Vo(t) {
2261
2265
  function Ko() {
2262
2266
  return Object.values(cn);
2263
2267
  }
2264
- function _r({ slug: t, name: n, onSave: a }) {
2265
- const s = Ie(), i = Dr(t), { data: o } = ie({
2266
- queryKey: ["adjacent", t, n, (i == null ? void 0 : i.filters) ?? null],
2267
- queryFn: () => _.adjacentDocument(t, n, i == null ? void 0 : i.filters)
2268
- }), l = (o == null ? void 0 : o.prev) ?? null, c = (o == null ? void 0 : o.next) ?? null;
2269
- re(() => {
2270
- const m = () => l && s(`/app/${t}/${l}`), p = () => c && s(`/app/${t}/${c}`), u = () => s(`/app/${t}${(i == null ? void 0 : i.search) || ""}`), w = (b) => {
2271
- if ((b.metaKey || b.ctrlKey) && b.key.toLowerCase() === "s") {
2272
- a && (b.preventDefault(), a());
2268
+ function ua({ slug: t, name: n, onSave: a, kind: s = "document" }) {
2269
+ const i = Ie(), o = s === "master", l = Ar(o ? `master:${t}` : t), c = o ? `/masters/${t}` : `/app/${t}`, { data: g } = ie({
2270
+ queryKey: ["adjacent", s, t, n, (l == null ? void 0 : l.filters) ?? null],
2271
+ queryFn: () => o ? T.adjacentMaster(t, n) : T.adjacentDocument(t, n, l == null ? void 0 : l.filters)
2272
+ }), d = (g == null ? void 0 : g.prev) ?? null, p = (g == null ? void 0 : g.next) ?? null;
2273
+ ae(() => {
2274
+ const w = () => d && i(`${c}/${d}`), x = () => p && i(`${c}/${p}`), N = () => i(`${c}${(l == null ? void 0 : l.search) || ""}`), y = (D) => {
2275
+ if ((D.metaKey || D.ctrlKey) && D.key.toLowerCase() === "s") {
2276
+ a && (D.preventDefault(), a());
2273
2277
  return;
2274
2278
  }
2275
- const N = document.activeElement;
2276
- N && (/^(input|textarea|select)$/i.test(N.tagName) || N.isContentEditable) || b.metaKey || b.ctrlKey || b.altKey || (b.key === "j" || b.key === "ArrowRight" ? (b.preventDefault(), p()) : b.key === "k" || b.key === "ArrowLeft" ? (b.preventDefault(), m()) : (b.key === "Escape" || b.key === "u") && (b.preventDefault(), u()));
2279
+ const A = document.activeElement;
2280
+ A && (/^(input|textarea|select)$/i.test(A.tagName) || A.isContentEditable) || D.metaKey || D.ctrlKey || D.altKey || (D.key === "j" || D.key === "ArrowRight" ? (D.preventDefault(), x()) : D.key === "k" || D.key === "ArrowLeft" ? (D.preventDefault(), w()) : (D.key === "Escape" || D.key === "u") && (D.preventDefault(), N()));
2277
2281
  };
2278
- return window.addEventListener("keydown", w), () => window.removeEventListener("keydown", w);
2279
- }, [l, c, t, i == null ? void 0 : i.search, a, s]);
2280
- const g = "rounded-md border border-line bg-surface p-1.5 text-fg-muted transition hover:bg-surface-subtle hover:text-fg disabled:cursor-default disabled:opacity-40";
2282
+ return window.addEventListener("keydown", y), () => window.removeEventListener("keydown", y);
2283
+ }, [d, p, c, l == null ? void 0 : l.search, a, i]);
2284
+ const m = "rounded-md border border-line bg-surface p-1.5 text-fg-muted transition hover:bg-surface-subtle hover:text-fg disabled:cursor-default disabled:opacity-40";
2281
2285
  return /* @__PURE__ */ r("div", { className: "flex items-center gap-1", children: [
2282
2286
  /* @__PURE__ */ e(
2283
2287
  "button",
2284
2288
  {
2285
2289
  type: "button",
2286
- disabled: !l,
2290
+ disabled: !d,
2287
2291
  title: "Previous record (k / ←)",
2288
- onClick: () => l && s(`/app/${t}/${l}`),
2289
- className: g,
2290
- children: /* @__PURE__ */ e(Ga, { className: "h-4 w-4" })
2292
+ onClick: () => d && i(`${c}/${d}`),
2293
+ className: m,
2294
+ children: /* @__PURE__ */ e(Ha, { className: "h-4 w-4" })
2291
2295
  }
2292
2296
  ),
2293
2297
  /* @__PURE__ */ e(
2294
2298
  "button",
2295
2299
  {
2296
2300
  type: "button",
2297
- disabled: !c,
2301
+ disabled: !p,
2298
2302
  title: "Next record (j / →)",
2299
- onClick: () => c && s(`/app/${t}/${c}`),
2300
- className: g,
2303
+ onClick: () => p && i(`${c}/${p}`),
2304
+ className: m,
2301
2305
  children: /* @__PURE__ */ e(Dt, { className: "h-4 w-4" })
2302
2306
  }
2303
2307
  )
@@ -2427,8 +2431,8 @@ function He({ label: t, options: n, value: a, onChange: s, className: i, require
2427
2431
  children: [
2428
2432
  /* @__PURE__ */ e("option", { value: "", children: "Select..." }),
2429
2433
  n.map((g) => {
2430
- const { value: m, label: p } = Ir(g);
2431
- return /* @__PURE__ */ e("option", { value: m, children: p }, m);
2434
+ const { value: d, label: p } = Ir(g);
2435
+ return /* @__PURE__ */ e("option", { value: d, children: p }, d);
2432
2436
  })
2433
2437
  ]
2434
2438
  }
@@ -2481,7 +2485,7 @@ function Er() {
2481
2485
  className: "inline-flex h-4 w-4 items-center justify-center rounded-full text-fg-muted hover:text-fg",
2482
2486
  onClick: () => a((i) => !i),
2483
2487
  "aria-label": t("notesMarkup.title", { defaultValue: "Formatting help" }),
2484
- children: /* @__PURE__ */ e(Wa, { className: "h-3.5 w-3.5" })
2488
+ children: /* @__PURE__ */ e(Qa, { className: "h-3.5 w-3.5" })
2485
2489
  }
2486
2490
  ),
2487
2491
  n && /* @__PURE__ */ r("div", { className: "absolute bottom-full left-0 z-50 mb-2 w-80 rounded-md bg-gray-900 px-3 py-2.5 text-xs leading-relaxed text-white shadow-lg", children: [
@@ -2501,7 +2505,7 @@ function Er() {
2501
2505
  function Lr(t, n = !0) {
2502
2506
  const { data: a } = ie({
2503
2507
  queryKey: ["currencies", ""],
2504
- queryFn: () => _.currencies(t),
2508
+ queryFn: () => T.currencies(t),
2505
2509
  enabled: n,
2506
2510
  staleTime: 3e5
2507
2511
  });
@@ -2530,36 +2534,36 @@ function qr({
2530
2534
  disabled: s,
2531
2535
  hideLabel: i
2532
2536
  }) {
2533
- const [o, l] = S(n ?? ""), [c, g] = S(!1), m = ee(null), [p, u] = S(null), { data: w } = ie({
2537
+ const [o, l] = S(n ?? ""), [c, g] = S(!1), d = ee(null), [p, m] = S(null), { data: w } = ie({
2534
2538
  queryKey: ["link-search", t.linkDoctype, o],
2535
- queryFn: () => _.searchLink(t.linkDoctype, o),
2539
+ queryFn: () => T.searchLink(t.linkDoctype, o),
2536
2540
  enabled: !!t.linkDoctype && c
2537
2541
  });
2538
- return re(() => {
2542
+ return ae(() => {
2539
2543
  l(n ?? "");
2540
- }, [n]), re(() => {
2544
+ }, [n]), ae(() => {
2541
2545
  if (!c) return;
2542
- const b = () => {
2543
- const N = m.current;
2546
+ const x = () => {
2547
+ const N = d.current;
2544
2548
  if (N) {
2545
2549
  const y = N.getBoundingClientRect();
2546
- u({ top: y.bottom, left: y.left, width: y.width });
2550
+ m({ top: y.bottom, left: y.left, width: y.width });
2547
2551
  }
2548
2552
  };
2549
- return b(), window.addEventListener("scroll", b, !0), window.addEventListener("resize", b), () => {
2550
- window.removeEventListener("scroll", b, !0), window.removeEventListener("resize", b);
2553
+ return x(), window.addEventListener("scroll", x, !0), window.addEventListener("resize", x), () => {
2554
+ window.removeEventListener("scroll", x, !0), window.removeEventListener("resize", x);
2551
2555
  };
2552
2556
  }, [c]), s ? /* @__PURE__ */ r("div", { children: [
2553
2557
  !i && /* @__PURE__ */ e("label", { className: "mb-1.5 block text-sm font-medium text-fg", children: t.label }),
2554
2558
  /* @__PURE__ */ e("p", { className: "py-2 text-sm text-fg", children: n || "-" })
2555
- ] }) : /* @__PURE__ */ r("div", { className: "relative", ref: m, children: [
2559
+ ] }) : /* @__PURE__ */ r("div", { className: "relative", ref: d, children: [
2556
2560
  /* @__PURE__ */ e(
2557
2561
  J,
2558
2562
  {
2559
2563
  label: i ? void 0 : t.label,
2560
2564
  value: o,
2561
- onChange: (b) => {
2562
- l(b.target.value), g(!0);
2565
+ onChange: (x) => {
2566
+ l(x.target.value), g(!0);
2563
2567
  },
2564
2568
  onFocus: () => g(!0),
2565
2569
  onBlur: () => setTimeout(() => g(!1), 200)
@@ -2571,16 +2575,16 @@ function qr({
2571
2575
  {
2572
2576
  className: "fixed z-50 mt-1 max-h-40 overflow-auto rounded-lg bg-surface ring-1 ring-line shadow-card-hover",
2573
2577
  style: { top: p.top, left: p.left, width: p.width },
2574
- children: w.map((b) => /* @__PURE__ */ e(
2578
+ children: w.map((x) => /* @__PURE__ */ e(
2575
2579
  "li",
2576
2580
  {
2577
2581
  className: "cursor-pointer px-3 py-2 text-sm text-fg transition-colors hover:bg-surface-subtle",
2578
2582
  onMouseDown: () => {
2579
- a(b.name), l(b.name), g(!1);
2583
+ a(x.name), l(x.name), g(!1);
2580
2584
  },
2581
- children: b.name
2585
+ children: x.name
2582
2586
  },
2583
- b.name
2587
+ x.name
2584
2588
  ))
2585
2589
  }
2586
2590
  ),
@@ -2597,14 +2601,14 @@ function It({
2597
2601
  hideLabel: o,
2598
2602
  currency: l = "USD"
2599
2603
  }) {
2600
- var b;
2601
- const { t: c } = Z(), g = s || !!t.readOnly, m = () => o ? null : /* @__PURE__ */ e(wn, { label: c(`fields.${t.label}`, { defaultValue: t.label }), hint: t.hint }), p = t.type === "select" && t.optionsSource === "currency", u = Lr(void 0, p);
2604
+ var x;
2605
+ const { t: c } = Z(), g = s || !!t.readOnly, d = () => o ? null : /* @__PURE__ */ e(wn, { label: c(`fields.${t.label}`, { defaultValue: t.label }), hint: t.hint }), p = t.type === "select" && t.optionsSource === "currency", m = Lr(void 0, p);
2602
2606
  if (g) {
2603
2607
  if (t.type === "link" && n) {
2604
- const T = t.linkDoctypeField && i ? String(i[t.linkDoctypeField] ?? "").toLowerCase().replace(/\s+/g, "-") : t.linkDoctype, A = Xt(T, String(n));
2608
+ const D = t.linkDoctypeField && i ? String(i[t.linkDoctypeField] ?? "").toLowerCase().replace(/\s+/g, "-") : t.linkDoctype, A = Xt(D, String(n));
2605
2609
  if (A)
2606
2610
  return /* @__PURE__ */ r("div", { children: [
2607
- /* @__PURE__ */ e(m, {}),
2611
+ /* @__PURE__ */ e(d, {}),
2608
2612
  /* @__PURE__ */ e("p", { className: o ? "text-sm" : "py-2 text-sm", children: /* @__PURE__ */ e(
2609
2613
  be,
2610
2614
  {
@@ -2622,14 +2626,14 @@ function It({
2622
2626
  t.type === "textarea" ? "whitespace-pre-line" : ""
2623
2627
  ].join(" ").trim();
2624
2628
  return /* @__PURE__ */ r("div", { children: [
2625
- /* @__PURE__ */ e(m, {}),
2629
+ /* @__PURE__ */ e(d, {}),
2626
2630
  /* @__PURE__ */ e("p", { className: y, children: N })
2627
2631
  ] });
2628
2632
  }
2629
2633
  if (t.type === "link") {
2630
- const N = t.linkDoctypeField && i ? { ...t, linkDoctype: (b = i[t.linkDoctypeField]) == null ? void 0 : b.toLowerCase().replace(/\s+/g, "-") } : t;
2634
+ const N = t.linkDoctypeField && i ? { ...t, linkDoctype: (x = i[t.linkDoctypeField]) == null ? void 0 : x.toLowerCase().replace(/\s+/g, "-") } : t;
2631
2635
  return /* @__PURE__ */ r("div", { children: [
2632
- /* @__PURE__ */ e(m, {}),
2636
+ /* @__PURE__ */ e(d, {}),
2633
2637
  /* @__PURE__ */ e(
2634
2638
  qr,
2635
2639
  {
@@ -2643,9 +2647,9 @@ function It({
2643
2647
  ] });
2644
2648
  }
2645
2649
  if (t.type === "select" && (t.options || p)) {
2646
- const N = p ? n && !u.includes(n) ? [n, ...u] : u : t.options;
2650
+ const N = p ? n && !m.includes(n) ? [n, ...m] : m : t.options;
2647
2651
  return /* @__PURE__ */ r("div", { children: [
2648
- /* @__PURE__ */ e(m, {}),
2652
+ /* @__PURE__ */ e(d, {}),
2649
2653
  /* @__PURE__ */ e(
2650
2654
  He,
2651
2655
  {
@@ -2680,7 +2684,7 @@ function It({
2680
2684
  }
2681
2685
  const w = t.type === "number" || t.type === "currency" ? "number" : t.type === "date" ? "date" : "text";
2682
2686
  return /* @__PURE__ */ r("div", { children: [
2683
- /* @__PURE__ */ e(m, {}),
2687
+ /* @__PURE__ */ e(d, {}),
2684
2688
  /* @__PURE__ */ e(
2685
2689
  J,
2686
2690
  {
@@ -2701,47 +2705,47 @@ function zr({
2701
2705
  readOnly: s,
2702
2706
  currency: i = "USD"
2703
2707
  }) {
2704
- const { t: o } = Z(), l = (m, p, u) => {
2708
+ const { t: o } = Z(), l = (d, p, m) => {
2705
2709
  const w = n.map(
2706
- (b, N) => N === m ? { ...b, [p]: u } : b
2710
+ (x, N) => N === d ? { ...x, [p]: m } : x
2707
2711
  );
2708
2712
  a(w);
2709
2713
  }, c = () => {
2710
- const m = {};
2714
+ const d = {};
2711
2715
  t.fields.forEach((p) => {
2712
- m[p.name] = p.default ?? (p.type === "number" || p.type === "currency" ? 0 : "");
2713
- }), a([...n, m]);
2714
- }, g = (m) => {
2715
- a(n.filter((p, u) => u !== m));
2716
+ d[p.name] = p.default ?? (p.type === "number" || p.type === "currency" ? 0 : "");
2717
+ }), a([...n, d]);
2718
+ }, g = (d) => {
2719
+ a(n.filter((p, m) => m !== d));
2716
2720
  };
2717
2721
  return /* @__PURE__ */ r(F, { title: o(`tables.${t.key}`, { defaultValue: t.label }), children: [
2718
2722
  /* @__PURE__ */ e("div", { className: "-mx-6 overflow-x-auto px-6", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-line text-sm", children: [
2719
2723
  /* @__PURE__ */ e("thead", { children: /* @__PURE__ */ r("tr", { children: [
2720
2724
  /* @__PURE__ */ e("th", { className: "px-2 py-2 text-left text-xs font-medium uppercase tracking-wide text-fg-muted", children: "#" }),
2721
- t.fields.map((m) => /* @__PURE__ */ e(
2725
+ t.fields.map((d) => /* @__PURE__ */ e(
2722
2726
  "th",
2723
2727
  {
2724
2728
  className: "px-2 py-2 text-left text-xs font-medium uppercase tracking-wide text-fg-muted",
2725
- children: o(`fields.${m.label}`, { defaultValue: m.label })
2729
+ children: o(`fields.${d.label}`, { defaultValue: d.label })
2726
2730
  },
2727
- m.name
2731
+ d.name
2728
2732
  )),
2729
2733
  !s && /* @__PURE__ */ e("th", { className: "px-2 py-2 text-left text-xs font-medium uppercase tracking-wide text-fg-muted" })
2730
2734
  ] }) }),
2731
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children: n.map((m, p) => /* @__PURE__ */ r("tr", { children: [
2735
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children: n.map((d, p) => /* @__PURE__ */ r("tr", { children: [
2732
2736
  /* @__PURE__ */ e("td", { className: "px-2 py-1 text-fg-muted", children: p + 1 }),
2733
- t.fields.map((u) => /* @__PURE__ */ e("td", { className: "px-2 py-1 align-top", children: /* @__PURE__ */ e(
2737
+ t.fields.map((m) => /* @__PURE__ */ e("td", { className: "px-2 py-1 align-top", children: /* @__PURE__ */ e(
2734
2738
  It,
2735
2739
  {
2736
- field: u,
2737
- value: m[u.name],
2738
- onChange: (w) => l(p, u.name, w),
2740
+ field: m,
2741
+ value: d[m.name],
2742
+ onChange: (w) => l(p, m.name, w),
2739
2743
  readOnly: s,
2740
- rowData: m,
2744
+ rowData: d,
2741
2745
  hideLabel: !0,
2742
2746
  currency: i
2743
2747
  }
2744
- ) }, u.name)),
2748
+ ) }, m.name)),
2745
2749
  !s && /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e(
2746
2750
  H,
2747
2751
  {
@@ -2766,47 +2770,47 @@ function Mr({
2766
2770
  config: l,
2767
2771
  onSave: c,
2768
2772
  onSubmit: g,
2769
- onCancel: m,
2773
+ onCancel: d,
2770
2774
  onConvert: p,
2771
- onDiscard: u
2775
+ onDiscard: m
2772
2776
  }) {
2773
- const { t: w } = Z(), [b, N] = S(!1), [y, T] = S(!1);
2777
+ const { t: w } = Z(), [x, N] = S(!1), [y, D] = S(!1);
2774
2778
  if (!l) return null;
2775
- const A = !t && n && a ? `/api/documents/${n}/${encodeURIComponent(a)}/pdf` : null, x = !t && l.canCancel && s === 1;
2779
+ const A = !t && n && a ? `/api/documents/${n}/${encodeURIComponent(a)}/pdf` : null, b = !t && l.canCancel && s === 1;
2776
2780
  return /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-2", children: [
2777
2781
  A && /* @__PURE__ */ e(H, { variant: "secondary", onClick: () => window.open(A, "_blank"), children: w("common.pdf") }),
2778
2782
  s < 1 && !i && /* @__PURE__ */ e(H, { onClick: c, disabled: o, children: w(o ? "common.saving" : "common.save") }),
2779
2783
  !t && l.canSubmit && s === 0 && !i && /* @__PURE__ */ e(H, { variant: "secondary", onClick: g, children: w("common.submit") }),
2780
2784
  !t && l.canSubmit && s === 0 && !i && (y ? /* @__PURE__ */ r(we, { children: [
2781
- /* @__PURE__ */ e(H, { variant: "secondary", onClick: () => T(!1), children: w("common.keepDraft") }),
2785
+ /* @__PURE__ */ e(H, { variant: "secondary", onClick: () => D(!1), children: w("common.keepDraft") }),
2782
2786
  /* @__PURE__ */ e(
2783
2787
  H,
2784
2788
  {
2785
2789
  variant: "danger",
2786
2790
  onClick: () => {
2787
- T(!1), u();
2791
+ D(!1), m();
2788
2792
  },
2789
2793
  children: w("common.discardDraftConfirm")
2790
2794
  }
2791
2795
  )
2792
- ] }) : /* @__PURE__ */ e(H, { variant: "ghost", onClick: () => T(!0), children: w("common.discardDraft") })),
2793
- x && (b ? /* @__PURE__ */ e(H, { variant: "secondary", onClick: () => N(!1), children: w("common.cancelDocAbort") }) : /* @__PURE__ */ e(H, { variant: "danger", onClick: () => N(!0), children: w("common.cancelDoc") })),
2794
- !t && s === 1 && !b && l.conversions.map((d) => /* @__PURE__ */ e(
2796
+ ] }) : /* @__PURE__ */ e(H, { variant: "ghost", onClick: () => D(!0), children: w("common.discardDraft") })),
2797
+ b && (x ? /* @__PURE__ */ e(H, { variant: "secondary", onClick: () => N(!1), children: w("common.cancelDocAbort") }) : /* @__PURE__ */ e(H, { variant: "danger", onClick: () => N(!0), children: w("common.cancelDoc") })),
2798
+ !t && s === 1 && !x && l.conversions.map((u) => /* @__PURE__ */ e(
2795
2799
  H,
2796
2800
  {
2797
2801
  variant: "secondary",
2798
- onClick: () => p(d.targetDoctype),
2799
- children: w(`conversions.${d.label}`, { defaultValue: d.label })
2802
+ onClick: () => p(u.targetDoctype),
2803
+ children: w(`conversions.${u.label}`, { defaultValue: u.label })
2800
2804
  },
2801
- d.targetDoctype
2805
+ u.targetDoctype
2802
2806
  )),
2803
- x && b && /* @__PURE__ */ e(
2807
+ b && x && /* @__PURE__ */ e(
2804
2808
  H,
2805
2809
  {
2806
2810
  variant: "danger",
2807
2811
  className: "ml-auto",
2808
2812
  onClick: () => {
2809
- N(!1), m();
2813
+ N(!1), d();
2810
2814
  },
2811
2815
  children: w("common.cancelDocConfirmBtn")
2812
2816
  }
@@ -2837,99 +2841,99 @@ function kn(t, n) {
2837
2841
  }
2838
2842
  function Sn() {
2839
2843
  var Ue;
2840
- const { doctype: t, name: n } = ut(), a = Ie(), s = We(), { t: i } = Z(), o = ca(t ?? ""), l = !n, [c, g] = S({}), [m, p] = S(!1), { data: u, isLoading: w } = ie({
2844
+ const { doctype: t, name: n } = ut(), a = Ie(), s = We(), { t: i } = Z(), o = da(t ?? ""), l = !n, [c, g] = S({}), [d, p] = S(!1), { data: m, isLoading: w } = ie({
2841
2845
  queryKey: ["document", t, n],
2842
- queryFn: () => _.getDocument(t, n),
2846
+ queryFn: () => T.getDocument(t, n),
2843
2847
  enabled: !!t && !!n && !l
2844
- }), b = Ce(
2848
+ }), x = Ce(
2845
2849
  () => !!(o != null && o.fields.some((E) => E.name === "currency")),
2846
2850
  [o]
2847
- ), N = o == null ? void 0 : o.partyField, y = N ? c[N] : void 0, T = qe(c.company), { data: A } = ie({
2851
+ ), N = o == null ? void 0 : o.partyField, y = N ? c[N] : void 0, D = qe(c.company), { data: A } = ie({
2848
2852
  queryKey: ["master", N, y],
2849
- queryFn: () => _.getMaster(N, y),
2850
- enabled: l && b && !!N && !!y,
2853
+ queryFn: () => T.getMaster(N, y),
2854
+ enabled: l && x && !!N && !!y,
2851
2855
  staleTime: 300 * 1e3
2852
2856
  });
2853
- re(() => {
2854
- if (!l || !b || m) return;
2857
+ ae(() => {
2858
+ if (!l || !x || d) return;
2855
2859
  let E;
2856
2860
  if (y) {
2857
2861
  if (!A) return;
2858
- E = A.default_currency || T;
2862
+ E = A.default_currency || D;
2859
2863
  } else
2860
- E = T;
2861
- E && E !== c.currency && g((ae) => ({ ...ae, currency: E }));
2864
+ E = D;
2865
+ E && E !== c.currency && g((re) => ({ ...re, currency: E }));
2862
2866
  }, [
2863
2867
  l,
2864
- b,
2865
- m,
2868
+ x,
2869
+ d,
2866
2870
  y,
2867
2871
  A,
2868
- T,
2872
+ D,
2869
2873
  c.currency
2870
- ]), re(() => {
2874
+ ]), ae(() => {
2871
2875
  if (l && o) {
2872
2876
  const E = {};
2873
- o.fields.forEach((ae) => {
2874
- ae.type === "date" ? E[ae.name] = (/* @__PURE__ */ new Date()).toISOString().split("T")[0] : E[ae.name] = ae.default ?? "";
2875
- }), o.childTables.forEach((ae) => {
2876
- E[ae.key] = [];
2877
+ o.fields.forEach((re) => {
2878
+ re.type === "date" ? E[re.name] = (/* @__PURE__ */ new Date()).toISOString().split("T")[0] : E[re.name] = re.default ?? "";
2879
+ }), o.childTables.forEach((re) => {
2880
+ E[re.key] = [];
2877
2881
  }), E.docstatus = 0, g(E);
2878
- } else u && g(u);
2879
- }, [l, u, o]);
2880
- const x = oe({
2881
- mutationFn: (E) => _.createDocument(t, E),
2882
+ } else m && g(m);
2883
+ }, [l, m, o]);
2884
+ const b = oe({
2885
+ mutationFn: (E) => T.createDocument(t, E),
2882
2886
  onSuccess: (E) => {
2883
2887
  s.invalidateQueries({ queryKey: ["documents", t] }), a(`/app/${t}/${E.name}`, { replace: !0 });
2884
2888
  }
2885
- }), d = oe({
2886
- mutationFn: (E) => _.updateDocument(t, n, E),
2889
+ }), u = oe({
2890
+ mutationFn: (E) => T.updateDocument(t, n, E),
2887
2891
  onSuccess: (E) => {
2888
2892
  s.invalidateQueries({ queryKey: ["document", t, n] }), s.invalidateQueries({ queryKey: ["documents", t] }), g(E);
2889
2893
  }
2890
2894
  }), h = oe({
2891
- mutationFn: () => _.submitDocument(t, n),
2895
+ mutationFn: () => T.submitDocument(t, n),
2892
2896
  onSuccess: (E) => {
2893
2897
  g(E), s.invalidateQueries({ queryKey: ["document", t, n] }), s.invalidateQueries({ queryKey: ["documents", t] });
2894
2898
  }
2895
- }), P = oe({
2896
- mutationFn: () => _.cancelDocument(t, n),
2899
+ }), _ = oe({
2900
+ mutationFn: () => T.cancelDocument(t, n),
2897
2901
  onSuccess: (E) => {
2898
2902
  g(E), s.invalidateQueries({ queryKey: ["document", t, n] }), s.invalidateQueries({ queryKey: ["documents", t] });
2899
2903
  }
2900
2904
  }), v = oe({
2901
- mutationFn: () => _.discardDocument(t, n),
2905
+ mutationFn: () => T.discardDocument(t, n),
2902
2906
  onSuccess: () => {
2903
2907
  s.invalidateQueries({ queryKey: ["documents", t] }), a(`/app/${t}`, { replace: !0 });
2904
2908
  }
2905
2909
  }), I = oe({
2906
- mutationFn: (E) => _.convertDocument(t, n, E),
2907
- onSuccess: (E, ae) => {
2908
- const Be = ae.toLowerCase().replace(/\s+/g, "-");
2910
+ mutationFn: (E) => T.convertDocument(t, n, E),
2911
+ onSuccess: (E, re) => {
2912
+ const Be = re.toLowerCase().replace(/\s+/g, "-");
2909
2913
  a(`/app/${Be}/${E.name}`);
2910
2914
  }
2911
2915
  }), C = Pe(
2912
- (E, ae) => {
2916
+ (E, re) => {
2913
2917
  E === "currency" && p(!0), g((Be) => {
2914
- const De = { ...Be, [E]: ae };
2918
+ const De = { ...Be, [E]: re };
2915
2919
  return E === "currency" && (De.conversion_rate = 0), kn(De, o);
2916
2920
  });
2917
2921
  },
2918
2922
  [o]
2919
2923
  ), O = Pe(
2920
- (E, ae) => {
2924
+ (E, re) => {
2921
2925
  g((Be) => {
2922
- const De = { ...Be, [E]: ae };
2926
+ const De = { ...Be, [E]: re };
2923
2927
  return kn(De, o);
2924
2928
  });
2925
2929
  },
2926
2930
  [o]
2927
2931
  ), G = () => {
2928
- l ? x.mutate(c) : d.mutate(c);
2932
+ l ? b.mutate(c) : u.mutate(c);
2929
2933
  }, te = () => {
2930
2934
  h.mutate();
2931
2935
  }, U = () => {
2932
- P.mutate();
2936
+ _.mutate();
2933
2937
  }, f = (E) => {
2934
2938
  I.mutate(E);
2935
2939
  }, q = () => {
@@ -2942,11 +2946,11 @@ function Sn() {
2942
2946
  ] });
2943
2947
  if (!l && w)
2944
2948
  return /* @__PURE__ */ e("p", { className: "text-fg-muted", children: i("common.loading") });
2945
- const D = c.docstatus ?? 0, L = !!c.discarded, Y = D >= 1 || L, ne = c.currency || T, ce = Fe(c.conversion_rate ?? 1), de = o.fields.filter((E) => !E.readOnly), _e = de.filter((E) => E.type !== "textarea"), he = de.filter((E) => E.type === "textarea"), fe = o.fields.filter((E) => E.readOnly);
2949
+ const P = c.docstatus ?? 0, L = !!c.discarded, Y = P >= 1 || L, ne = c.currency || D, ce = Fe(c.conversion_rate ?? 1), de = o.fields.filter((E) => !E.readOnly), _e = de.filter((E) => E.type !== "textarea"), he = de.filter((E) => E.type === "textarea"), fe = o.fields.filter((E) => E.readOnly);
2946
2950
  return /* @__PURE__ */ r("div", { className: "space-y-6", children: [
2947
2951
  /* @__PURE__ */ r("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: [
2948
2952
  /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
2949
- !l && /* @__PURE__ */ e(_r, { slug: o.slug, name: n, onSave: G }),
2953
+ !l && /* @__PURE__ */ e(ua, { slug: o.slug, name: n, onSave: G }),
2950
2954
  !l && c.status && /* @__PURE__ */ e(ln, { status: c.status }),
2951
2955
  !l && c.currency && /* @__PURE__ */ r(
2952
2956
  "span",
@@ -2969,8 +2973,8 @@ function Sn() {
2969
2973
  isNew: l,
2970
2974
  doctype: t,
2971
2975
  name: n,
2972
- docstatus: D,
2973
- saving: x.isPending || d.isPending,
2976
+ docstatus: P,
2977
+ saving: b.isPending || u.isPending,
2974
2978
  config: o,
2975
2979
  discarded: L,
2976
2980
  onSave: G,
@@ -2981,14 +2985,14 @@ function Sn() {
2981
2985
  }
2982
2986
  )
2983
2987
  ] }),
2984
- (x.error || d.error || h.error || P.error) && /* @__PURE__ */ e("div", { className: "rounded-lg bg-rose-50 p-4 text-sm text-rose-700 ring-1 ring-rose-200", children: ((Ue = x.error ?? d.error ?? h.error ?? P.error) == null ? void 0 : Ue.message) ?? i("common.errorOccurred") }),
2988
+ (b.error || u.error || h.error || _.error) && /* @__PURE__ */ e("div", { className: "rounded-lg bg-rose-50 p-4 text-sm text-rose-700 ring-1 ring-rose-200", children: ((Ue = b.error ?? u.error ?? h.error ?? _.error) == null ? void 0 : Ue.message) ?? i("common.errorOccurred") }),
2985
2989
  /* @__PURE__ */ r(F, { children: [
2986
2990
  /* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3", children: _e.map((E) => /* @__PURE__ */ e(
2987
2991
  It,
2988
2992
  {
2989
2993
  field: E,
2990
2994
  value: c[E.name],
2991
- onChange: (ae) => C(E.name, ae),
2995
+ onChange: (re) => C(E.name, re),
2992
2996
  readOnly: Y,
2993
2997
  rowData: c,
2994
2998
  currency: ne
@@ -3000,7 +3004,7 @@ function Sn() {
3000
3004
  {
3001
3005
  field: E,
3002
3006
  value: c[E.name],
3003
- onChange: (ae) => C(E.name, ae),
3007
+ onChange: (re) => C(E.name, re),
3004
3008
  readOnly: Y,
3005
3009
  rowData: c,
3006
3010
  currency: ne
@@ -3013,7 +3017,7 @@ function Sn() {
3013
3017
  {
3014
3018
  tableDef: E,
3015
3019
  rows: c[E.key] ?? [],
3016
- onChange: (ae) => O(E.key, ae),
3020
+ onChange: (re) => O(E.key, re),
3017
3021
  readOnly: Y,
3018
3022
  currency: ne
3019
3023
  },
@@ -3036,12 +3040,12 @@ function Sn() {
3036
3040
  function ye(t) {
3037
3041
  return t.toISOString().split("T")[0];
3038
3042
  }
3039
- function da(t) {
3043
+ function ma(t) {
3040
3044
  const n = new Date(t), a = n.getDay(), s = a === 0 ? 6 : a - 1;
3041
3045
  return n.setDate(n.getDate() - s), n;
3042
3046
  }
3043
3047
  function Fr(t) {
3044
- const n = da(t);
3048
+ const n = ma(t);
3045
3049
  return n.setDate(n.getDate() + 6), n;
3046
3050
  }
3047
3051
  function Cn(t) {
@@ -3074,7 +3078,7 @@ const $r = [
3074
3078
  },
3075
3079
  {
3076
3080
  label: "This Week",
3077
- range: () => [ye(da(/* @__PURE__ */ new Date())), ye(Fr(/* @__PURE__ */ new Date()))]
3081
+ range: () => [ye(ma(/* @__PURE__ */ new Date())), ye(Fr(/* @__PURE__ */ new Date()))]
3078
3082
  },
3079
3083
  {
3080
3084
  label: "This Month",
@@ -3178,22 +3182,22 @@ function jr(t) {
3178
3182
  }
3179
3183
  const Gr = ["25", "50", "100", "200"];
3180
3184
  function Wr() {
3181
- const { t } = Z(), n = qe(), { doctype: a } = ut(), s = ca(a ?? ""), [i] = se("status", "All"), [o] = se("from", ""), [l] = se("to", ""), [c] = se("discarded", ""), [g] = se("per_page", 50), [m] = se("page", 1), p = m - 1, u = Ye(), w = (f) => u({ page: f === 0 ? null : f + 1 }), b = (f) => u({ status: f === "All" ? null : f, page: null }), N = (f) => u({ from: f || null, page: null }), y = (f) => u({ to: f || null, page: null }), T = (f) => u({ discarded: f ? "1" : null, page: null }), A = (f) => u({ per_page: f, page: null }), x = Ce(() => {
3185
+ const { t } = Z(), n = qe(), { doctype: a } = ut(), s = da(a ?? ""), [i] = se("status", "All"), [o] = se("from", ""), [l] = se("to", ""), [c] = se("discarded", ""), [g] = se("per_page", 50), [d] = se("page", 1), p = d - 1, m = Ye(), w = (f) => m({ page: f === 0 ? null : f + 1 }), x = (f) => m({ status: f === "All" ? null : f, page: null }), N = (f) => m({ from: f || null, page: null }), y = (f) => m({ to: f || null, page: null }), D = (f) => m({ discarded: f ? "1" : null, page: null }), A = (f) => m({ per_page: f, page: null }), b = Ce(() => {
3182
3186
  const f = {};
3183
3187
  return i !== "All" && (f.status = i), o && (f.from_date = o), l && (f.to_date = l), c && (f.include_discarded = "true"), f.limit = g, f.offset = p * g, f;
3184
- }, [i, o, l, c, g, p]), { data: d, isLoading: h } = Ar(a ?? "", x), P = (d == null ? void 0 : d.rows) ?? [], v = (d == null ? void 0 : d.total) ?? 0, I = vt();
3185
- re(() => {
3186
- const { limit: f, offset: q, ...D } = x;
3187
- Cr(a ?? "", { filters: D, search: I.search });
3188
- }, [a, x, I.search]);
3188
+ }, [i, o, l, c, g, p]), { data: u, isLoading: h } = Pr(a ?? "", b), _ = (u == null ? void 0 : u.rows) ?? [], v = (u == null ? void 0 : u.total) ?? 0, I = vt();
3189
+ ae(() => {
3190
+ const { limit: f, offset: q, ...P } = b;
3191
+ ca(a ?? "", { filters: P, search: I.search });
3192
+ }, [a, b, I.search]);
3189
3193
  const C = Math.max(1, Math.ceil(v / g)), O = v === 0 ? 0 : p * g + 1, G = Math.min(v, (p + 1) * g), te = Ce(() => {
3190
3194
  if (!s) return [];
3191
- const f = Yn(), q = (D) => {
3192
- const L = D.split("_").map((Y) => Y.charAt(0).toUpperCase() + Y.slice(1)).join(" ");
3195
+ const f = Yn(), q = (P) => {
3196
+ const L = P.split("_").map((Y) => Y.charAt(0).toUpperCase() + Y.slice(1)).join(" ");
3193
3197
  return t(`fields.${L}`, { defaultValue: L });
3194
3198
  };
3195
- return s.listColumns.map((D) => {
3196
- if (D === "name")
3199
+ return s.listColumns.map((P) => {
3200
+ if (P === "name")
3197
3201
  return f.accessor("name", {
3198
3202
  header: t("fields.Name", { defaultValue: "Name" }),
3199
3203
  cell: (L) => /* @__PURE__ */ e(
@@ -3205,20 +3209,20 @@ function Wr() {
3205
3209
  }
3206
3210
  )
3207
3211
  });
3208
- if (D === "status")
3212
+ if (P === "status")
3209
3213
  return f.accessor("status", {
3210
3214
  header: t("fields.Status", { defaultValue: "Status" }),
3211
3215
  cell: (L) => /* @__PURE__ */ e(ln, { status: L.getValue() })
3212
3216
  });
3213
- if (Vr.has(D))
3214
- return f.accessor(D, {
3215
- header: q(D),
3217
+ if (Vr.has(P))
3218
+ return f.accessor(P, {
3219
+ header: q(P),
3216
3220
  cell: (L) => {
3217
3221
  var Y;
3218
3222
  return Oe(L.getValue(), ((Y = L.row.original) == null ? void 0 : Y.currency) || n);
3219
3223
  }
3220
3224
  });
3221
- if (D === "party")
3225
+ if (P === "party")
3222
3226
  return f.accessor("party", {
3223
3227
  header: t("fields.Party", { defaultValue: "Party" }),
3224
3228
  cell: (L) => {
@@ -3236,10 +3240,10 @@ function Wr() {
3236
3240
  ) : String(Y);
3237
3241
  }
3238
3242
  });
3239
- if (An[D]) {
3240
- const L = An[D];
3241
- return f.accessor(D, {
3242
- header: q(D),
3243
+ if (An[P]) {
3244
+ const L = An[P];
3245
+ return f.accessor(P, {
3246
+ header: q(P),
3243
3247
  cell: (Y) => {
3244
3248
  const ne = Y.getValue();
3245
3249
  if (!ne) return "-";
@@ -3256,15 +3260,15 @@ function Wr() {
3256
3260
  }
3257
3261
  });
3258
3262
  }
3259
- return Kr.has(D) ? f.accessor(D, {
3260
- header: q(D),
3263
+ return Kr.has(P) ? f.accessor(P, {
3264
+ header: q(P),
3261
3265
  cell: (L) => Ft(L.getValue())
3262
- }) : f.accessor(D, {
3263
- header: q(D)
3266
+ }) : f.accessor(P, {
3267
+ header: q(P)
3264
3268
  });
3265
3269
  });
3266
3270
  }, [s, t, n]), U = Jn({
3267
- data: P,
3271
+ data: _,
3268
3272
  columns: te,
3269
3273
  getCoreRowModel: Zn()
3270
3274
  });
@@ -3280,7 +3284,7 @@ function Wr() {
3280
3284
  label: f === "All" ? t("common.all") : t(`status.${f}`, { defaultValue: f })
3281
3285
  })),
3282
3286
  value: i,
3283
- onChange: (f) => b(f.target.value)
3287
+ onChange: (f) => x(f.target.value)
3284
3288
  }
3285
3289
  ),
3286
3290
  /* @__PURE__ */ e(
@@ -3308,14 +3312,14 @@ function Wr() {
3308
3312
  type: "checkbox",
3309
3313
  className: "h-4 w-4 rounded border-line text-brand focus:ring-brand/30",
3310
3314
  checked: !!c,
3311
- onChange: (f) => T(f.target.checked)
3315
+ onChange: (f) => D(f.target.checked)
3312
3316
  }
3313
3317
  ),
3314
3318
  t("common.showDiscarded")
3315
3319
  ] })
3316
3320
  ] }),
3317
- /* @__PURE__ */ e($t, { onSelect: (f, q) => u({ from: f, to: q, page: null }) }),
3318
- h ? /* @__PURE__ */ e("p", { className: "text-fg-muted", children: t("common.loading") }) : P.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-fg-muted", children: t("reports.noDocuments") }) : /* @__PURE__ */ r(we, { children: [
3321
+ /* @__PURE__ */ e($t, { onSelect: (f, q) => m({ from: f, to: q, page: null }) }),
3322
+ h ? /* @__PURE__ */ e("p", { className: "text-fg-muted", children: t("common.loading") }) : _.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-fg-muted", children: t("reports.noDocuments") }) : /* @__PURE__ */ r(we, { children: [
3319
3323
  /* @__PURE__ */ e("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: [
3320
3324
  /* @__PURE__ */ e("thead", { className: "bg-surface-subtle", children: U.getHeaderGroups().map((f) => /* @__PURE__ */ e("tr", { children: f.headers.map((q) => /* @__PURE__ */ e(
3321
3325
  "th",
@@ -3402,13 +3406,13 @@ function Se({
3402
3406
  linkDoctype: s,
3403
3407
  readOnly: i
3404
3408
  }) {
3405
- const [o, l] = S(n ?? ""), [c, g] = S([]), [m, p] = S(!1), [u, w] = S(!1), [b, N] = S({}), y = ee(null), T = ee(null), A = ee(null), x = ee(null), d = ee(!1);
3406
- re(() => {
3409
+ const [o, l] = S(n ?? ""), [c, g] = S([]), [d, p] = S(!1), [m, w] = S(!1), [x, N] = S({}), y = ee(null), D = ee(null), A = ee(null), b = ee(null), u = ee(!1);
3410
+ ae(() => {
3407
3411
  l(n ?? "");
3408
3412
  }, [n]);
3409
3413
  const h = Pe(() => {
3410
- if (x.current) {
3411
- const O = x.current.getBoundingClientRect();
3414
+ if (b.current) {
3415
+ const O = b.current.getBoundingClientRect();
3412
3416
  N({
3413
3417
  position: "fixed",
3414
3418
  top: O.bottom + 4,
@@ -3417,12 +3421,12 @@ function Se({
3417
3421
  zIndex: 9999
3418
3422
  });
3419
3423
  }
3420
- }, []), P = Pe(
3424
+ }, []), _ = Pe(
3421
3425
  (O) => {
3422
3426
  y.current && clearTimeout(y.current), y.current = setTimeout(async () => {
3423
3427
  w(!0);
3424
3428
  try {
3425
- const G = await _.searchLink(s, O);
3429
+ const G = await T.searchLink(s, O);
3426
3430
  g(G), p(!0);
3427
3431
  } catch {
3428
3432
  g([]);
@@ -3434,58 +3438,58 @@ function Se({
3434
3438
  [s]
3435
3439
  ), v = (O) => {
3436
3440
  const G = O.target.value;
3437
- l(G), P(G);
3441
+ l(G), _(G);
3438
3442
  }, I = (O) => {
3439
3443
  const G = O.name ?? O.id ?? String(O);
3440
3444
  l(G), a(G), p(!1), g([]);
3441
3445
  }, C = () => {
3442
3446
  setTimeout(() => {
3443
- if (d.current) {
3444
- d.current = !1;
3447
+ if (u.current) {
3448
+ u.current = !1;
3445
3449
  return;
3446
3450
  }
3447
3451
  p(!1), o !== n && a(o);
3448
3452
  }, 150);
3449
3453
  };
3450
- return re(() => {
3454
+ return ae(() => {
3451
3455
  const O = (G) => {
3452
3456
  var U, f;
3453
3457
  const te = G.target;
3454
- (U = T.current) != null && U.contains(te) || (f = A.current) != null && f.contains(te) || p(!1);
3458
+ (U = D.current) != null && U.contains(te) || (f = A.current) != null && f.contains(te) || p(!1);
3455
3459
  };
3456
3460
  return document.addEventListener("mousedown", O), () => document.removeEventListener("mousedown", O);
3457
3461
  }, []), i ? /* @__PURE__ */ r("div", { children: [
3458
3462
  t && /* @__PURE__ */ e("span", { className: "mb-1.5 block text-sm font-medium text-fg", children: t }),
3459
3463
  /* @__PURE__ */ e("span", { className: "text-sm text-fg", children: n || "—" })
3460
- ] }) : /* @__PURE__ */ r("div", { ref: T, className: "relative", children: [
3464
+ ] }) : /* @__PURE__ */ r("div", { ref: D, className: "relative", children: [
3461
3465
  t && /* @__PURE__ */ e("label", { className: "mb-1.5 block text-sm font-medium text-fg", children: t }),
3462
3466
  /* @__PURE__ */ e(
3463
3467
  "input",
3464
3468
  {
3465
- ref: x,
3469
+ ref: b,
3466
3470
  type: "text",
3467
3471
  value: o,
3468
3472
  onChange: v,
3469
3473
  onFocus: () => {
3470
- h(), P(o);
3474
+ h(), _(o);
3471
3475
  },
3472
3476
  onBlur: C,
3473
3477
  placeholder: `Search ${s}...`,
3474
3478
  className: Le(
3475
3479
  "block h-9 w-full rounded-lg bg-surface px-3 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",
3476
- u && "bg-surface-subtle"
3480
+ m && "bg-surface-subtle"
3477
3481
  )
3478
3482
  }
3479
3483
  ),
3480
- m && c.length > 0 && Xn(
3481
- /* @__PURE__ */ e("div", { ref: A, style: b, className: "max-h-48 overflow-y-auto rounded-lg bg-surface ring-1 ring-line shadow-card-hover", children: c.map((O, G) => {
3484
+ d && c.length > 0 && Xn(
3485
+ /* @__PURE__ */ e("div", { ref: A, style: x, className: "max-h-48 overflow-y-auto rounded-lg bg-surface ring-1 ring-line shadow-card-hover", children: c.map((O, G) => {
3482
3486
  const te = O.name ?? O.id ?? String(O);
3483
3487
  return /* @__PURE__ */ e(
3484
3488
  "button",
3485
3489
  {
3486
3490
  type: "button",
3487
3491
  onMouseDown: () => {
3488
- d.current = !0;
3492
+ u.current = !0;
3489
3493
  },
3490
3494
  onClick: () => I(O),
3491
3495
  className: "block w-full px-3 py-1.5 text-left text-sm text-fg transition-colors hover:bg-surface-subtle",
@@ -3513,78 +3517,78 @@ function Pn() {
3513
3517
  partner_name: "",
3514
3518
  partner_email: "",
3515
3519
  cover_letter: ""
3516
- }), [g, m] = S([Tt()]), [p, u] = S(null), [w, b] = S(!1), [N, y] = S(null), T = ee(null), A = (f, q) => c((D) => ({ ...D, [f]: q })), { data: x } = ie({
3520
+ }), [g, d] = S([Tt()]), [p, m] = S(null), [w, x] = S(!1), [N, y] = S(null), D = ee(null), A = (f, q) => c((P) => ({ ...P, [f]: q })), { data: b } = ie({
3517
3521
  queryKey: ["document", "proposal", t],
3518
- queryFn: () => _.getDocument("proposal", t),
3522
+ queryFn: () => T.getDocument("proposal", t),
3519
3523
  enabled: !n
3520
3524
  });
3521
- re(() => {
3522
- if (!x) return;
3525
+ ae(() => {
3526
+ if (!b) return;
3523
3527
  c({
3524
- title: x.title ?? "Offerte",
3525
- customer: x.customer ?? "",
3526
- company: x.company ?? "",
3527
- proposal_date: x.proposal_date ?? "",
3528
- partner_name: x.partner_name ?? "",
3529
- partner_email: x.partner_email ?? "",
3530
- cover_letter: x.cover_letter ?? ""
3528
+ title: b.title ?? "Offerte",
3529
+ customer: b.customer ?? "",
3530
+ company: b.company ?? "",
3531
+ proposal_date: b.proposal_date ?? "",
3532
+ partner_name: b.partner_name ?? "",
3533
+ partner_email: b.partner_email ?? "",
3534
+ cover_letter: b.cover_letter ?? ""
3531
3535
  });
3532
- const f = x.quotations ?? [];
3533
- m(f.length ? f.map((q) => ({ ...Tt(), ...q })) : [Tt()]), u(x.appendix_filename ?? null);
3534
- }, [x]);
3535
- const d = async () => {
3536
+ const f = b.quotations ?? [];
3537
+ d(f.length ? f.map((q) => ({ ...Tt(), ...q })) : [Tt()]), m(b.appendix_filename ?? null);
3538
+ }, [b]);
3539
+ const u = async () => {
3536
3540
  try {
3537
- const { cover_letter: f } = await _.getProposalCoverDefault(l.company, l.customer);
3541
+ const { cover_letter: f } = await T.getProposalCoverDefault(l.company, l.customer);
3538
3542
  f && A("cover_letter", f);
3539
3543
  } catch {
3540
3544
  }
3541
3545
  };
3542
- re(() => {
3543
- n && l.customer && !l.cover_letter && d();
3546
+ ae(() => {
3547
+ n && l.customer && !l.cover_letter && u();
3544
3548
  }, [l.customer, l.company]);
3545
3549
  const h = () => ({
3546
3550
  ...l,
3547
3551
  quotations: g.filter((f) => f.quotation).map((f, q) => ({ ...f, idx: q + 1, is_recommended: f.is_recommended ? 1 : 0 }))
3548
- }), P = oe({
3549
- mutationFn: async () => n ? _.createDocument("proposal", h()) : _.updateDocument("proposal", t, h()),
3552
+ }), _ = oe({
3553
+ mutationFn: async () => n ? T.createDocument("proposal", h()) : T.updateDocument("proposal", t, h()),
3550
3554
  onSuccess: (f) => {
3551
3555
  y(null), s.invalidateQueries({ queryKey: ["documents", "proposal"] }), s.invalidateQueries({ queryKey: ["document", "proposal", f.name] }), n && a(`/app/proposal/${encodeURIComponent(f.name)}`);
3552
3556
  },
3553
3557
  onError: (f) => y((f == null ? void 0 : f.message) ?? "Save failed")
3554
3558
  }), v = oe({
3555
- mutationFn: () => _.discardDocument("proposal", t),
3559
+ mutationFn: () => T.discardDocument("proposal", t),
3556
3560
  onSuccess: () => {
3557
3561
  s.invalidateQueries({ queryKey: ["documents", "proposal"] }), a("/app/proposal");
3558
3562
  },
3559
3563
  onError: (f) => y((f == null ? void 0 : f.message) ?? "Discard failed")
3560
- }), I = (f, q) => m((D) => D.map((L, Y) => Y === f ? { ...L, ...q } : L)), C = () => m((f) => [...f, Tt()]), O = (f) => m((q) => q.length > 1 ? q.filter((D, L) => L !== f) : q), G = (f, q) => m((D) => {
3564
+ }), I = (f, q) => d((P) => P.map((L, Y) => Y === f ? { ...L, ...q } : L)), C = () => d((f) => [...f, Tt()]), O = (f) => d((q) => q.length > 1 ? q.filter((P, L) => L !== f) : q), G = (f, q) => d((P) => {
3561
3565
  const L = f + q;
3562
- if (L < 0 || L >= D.length) return D;
3563
- const Y = [...D];
3566
+ if (L < 0 || L >= P.length) return P;
3567
+ const Y = [...P];
3564
3568
  return [Y[f], Y[L]] = [Y[L], Y[f]], Y;
3565
3569
  }), te = async (f) => {
3566
- var D;
3567
- const q = (D = f.target.files) == null ? void 0 : D[0];
3570
+ var P;
3571
+ const q = (P = f.target.files) == null ? void 0 : P[0];
3568
3572
  if (f.target.value = "", !(!q || n)) {
3569
- b(!0), y(null);
3573
+ x(!0), y(null);
3570
3574
  try {
3571
- const L = await _.uploadProposalAppendix(t, q);
3572
- u(L.appendix_filename), s.invalidateQueries({ queryKey: ["document", "proposal", t] });
3575
+ const L = await T.uploadProposalAppendix(t, q);
3576
+ m(L.appendix_filename), s.invalidateQueries({ queryKey: ["document", "proposal", t] });
3573
3577
  } catch (L) {
3574
3578
  y((L == null ? void 0 : L.message) ?? "Upload failed");
3575
3579
  } finally {
3576
- b(!1);
3580
+ x(!1);
3577
3581
  }
3578
3582
  }
3579
3583
  }, U = async () => {
3580
3584
  if (!n) {
3581
- b(!0);
3585
+ x(!0);
3582
3586
  try {
3583
- await _.deleteProposalAppendix(t), u(null);
3587
+ await T.deleteProposalAppendix(t), m(null);
3584
3588
  } catch (f) {
3585
3589
  y((f == null ? void 0 : f.message) ?? "Failed");
3586
3590
  } finally {
3587
- b(!1);
3591
+ x(!1);
3588
3592
  }
3589
3593
  }
3590
3594
  };
@@ -3606,8 +3610,8 @@ function Pn() {
3606
3610
  children: v.isPending ? o("common.discarding", "Discarding…") : o("common.discard", "Discard")
3607
3611
  }
3608
3612
  ),
3609
- !n && /* @__PURE__ */ e(H, { variant: "secondary", onClick: () => window.open(_.proposalPdfUrl(t), "_blank"), children: o("common.pdf", "PDF") }),
3610
- /* @__PURE__ */ e(H, { onClick: () => P.mutate(), disabled: P.isPending, children: P.isPending ? o("common.saving", "Saving…") : o("common.save", "Save") })
3613
+ !n && /* @__PURE__ */ e(H, { variant: "secondary", onClick: () => window.open(T.proposalPdfUrl(t), "_blank"), children: o("common.pdf", "PDF") }),
3614
+ /* @__PURE__ */ e(H, { onClick: () => _.mutate(), disabled: _.isPending, children: _.isPending ? o("common.saving", "Saving…") : o("common.save", "Save") })
3611
3615
  ] })
3612
3616
  ] }),
3613
3617
  N && /* @__PURE__ */ e("div", { className: "rounded-lg bg-red-50 px-4 py-2 text-sm text-red-700 ring-1 ring-red-200", children: N }),
@@ -3623,7 +3627,7 @@ function Pn() {
3623
3627
  /* @__PURE__ */ r("div", { children: [
3624
3628
  /* @__PURE__ */ r("div", { className: "mb-1.5 flex items-center justify-between", children: [
3625
3629
  /* @__PURE__ */ e("label", { className: "block text-sm font-medium text-fg", children: o("proposal.coverLetter", "Cover letter") }),
3626
- /* @__PURE__ */ e("button", { type: "button", onClick: d, className: "text-xs text-brand hover:underline", children: o("proposal.loadTemplate", "Load from template") })
3630
+ /* @__PURE__ */ e("button", { type: "button", onClick: u, className: "text-xs text-brand hover:underline", children: o("proposal.loadTemplate", "Load from template") })
3627
3631
  ] }),
3628
3632
  /* @__PURE__ */ e(
3629
3633
  "textarea",
@@ -3644,18 +3648,18 @@ function Pn() {
3644
3648
  g.map((f, q) => /* @__PURE__ */ r("div", { className: "rounded-lg p-3 ring-1 ring-line", children: [
3645
3649
  /* @__PURE__ */ r("div", { className: "mb-2 flex items-center gap-2", children: [
3646
3650
  /* @__PURE__ */ e("span", { className: "flex h-6 w-6 items-center justify-center rounded-full bg-brand/10 text-sm font-bold text-brand", children: Hr[q] ?? q + 1 }),
3647
- /* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(Se, { label: "", value: f.quotation, onChange: (D) => I(q, { quotation: D }), linkDoctype: "quotation", readOnly: !1 }) }),
3651
+ /* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(Se, { label: "", value: f.quotation, onChange: (P) => I(q, { quotation: P }), linkDoctype: "quotation", readOnly: !1 }) }),
3648
3652
  /* @__PURE__ */ e("button", { type: "button", onClick: () => G(q, -1), disabled: q === 0, className: "px-1 text-fg-muted disabled:opacity-30", children: "↑" }),
3649
3653
  /* @__PURE__ */ e("button", { type: "button", onClick: () => G(q, 1), disabled: q === g.length - 1, className: "px-1 text-fg-muted disabled:opacity-30", children: "↓" }),
3650
3654
  /* @__PURE__ */ e("button", { type: "button", onClick: () => O(q), className: "px-1 text-red-500 hover:text-red-700", children: "✕" })
3651
3655
  ] }),
3652
3656
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 gap-2 pl-8 sm:grid-cols-2", children: [
3653
- /* @__PURE__ */ e(J, { label: o("proposal.positionTitle", "Position title"), value: f.position_title, onChange: (D) => I(q, { position_title: D.target.value }), placeholder: o("proposal.positionTitleHint", "defaults to the offer's first item") }),
3657
+ /* @__PURE__ */ e(J, { label: o("proposal.positionTitle", "Position title"), value: f.position_title, onChange: (P) => I(q, { position_title: P.target.value }), placeholder: o("proposal.positionTitleHint", "defaults to the offer's first item") }),
3654
3658
  /* @__PURE__ */ r("label", { className: "flex items-center gap-2 self-end pb-2 text-sm text-fg", children: [
3655
- /* @__PURE__ */ e("input", { type: "checkbox", checked: !!f.is_recommended, onChange: (D) => I(q, { is_recommended: D.target.checked ? 1 : 0 }) }),
3659
+ /* @__PURE__ */ e("input", { type: "checkbox", checked: !!f.is_recommended, onChange: (P) => I(q, { is_recommended: P.target.checked ? 1 : 0 }) }),
3656
3660
  o("proposal.recommended", "Mark as recommendation")
3657
3661
  ] }),
3658
- /* @__PURE__ */ e("div", { className: "sm:col-span-2", children: /* @__PURE__ */ e(J, { label: o("proposal.blurb", "Description"), value: f.position_blurb, onChange: (D) => I(q, { position_blurb: D.target.value }), placeholder: o("proposal.blurbHint", "defaults to the offer's notes") }) })
3662
+ /* @__PURE__ */ e("div", { className: "sm:col-span-2", children: /* @__PURE__ */ e(J, { label: o("proposal.blurb", "Description"), value: f.position_blurb, onChange: (P) => I(q, { position_blurb: P.target.value }), placeholder: o("proposal.blurbHint", "defaults to the offer's notes") }) })
3659
3663
  ] })
3660
3664
  ] }, q))
3661
3665
  ] }),
@@ -3668,10 +3672,10 @@ function Pn() {
3668
3672
  ] }),
3669
3673
  /* @__PURE__ */ e("button", { type: "button", onClick: U, disabled: w, className: "text-red-500 hover:underline", children: o("common.remove", "Remove") })
3670
3674
  ] }) : /* @__PURE__ */ r("div", { children: [
3671
- /* @__PURE__ */ e("input", { ref: T, type: "file", accept: "application/pdf", onChange: te, className: "hidden" }),
3675
+ /* @__PURE__ */ e("input", { ref: D, type: "file", accept: "application/pdf", onChange: te, className: "hidden" }),
3672
3676
  /* @__PURE__ */ e(H, { size: "sm", variant: "secondary", disabled: w, onClick: () => {
3673
3677
  var f;
3674
- return (f = T.current) == null ? void 0 : f.click();
3678
+ return (f = D.current) == null ? void 0 : f.click();
3675
3679
  }, children: w ? o("common.uploading", "Uploading…") : o("proposal.uploadAppendix", "Upload appendix PDF") }),
3676
3680
  /* @__PURE__ */ e("p", { className: "mt-1 text-xs text-fg-muted", children: o("proposal.appendixHint", "Appended after the offers — e.g. a price overview.") })
3677
3681
  ] })
@@ -3680,16 +3684,20 @@ function Pn() {
3680
3684
  }
3681
3685
  const Qr = ["25", "50", "100", "200"];
3682
3686
  function Yr() {
3683
- var d;
3684
- const { type: t } = ut(), n = Ie(), s = (d = vt().state) == null ? void 0 : d.notice, [i] = se("per_page", 50), [o] = se("page", 1), l = o - 1, c = Ye(), g = (h) => c({ page: h === 0 ? null : h + 1 }), m = (h) => c({ per_page: h, page: null }), { data: p, isLoading: u } = ie({
3687
+ var u;
3688
+ const { type: t } = ut(), n = Ie(), a = vt(), s = (u = a.state) == null ? void 0 : u.notice;
3689
+ ae(() => {
3690
+ t && ca(`master:${t}`, { filters: {}, search: a.search });
3691
+ }, [t, a.search]);
3692
+ const [i] = se("per_page", 50), [o] = se("page", 1), l = o - 1, c = Ye(), g = (h) => c({ page: h === 0 ? null : h + 1 }), d = (h) => c({ per_page: h, page: null }), { data: p, isLoading: m } = ie({
3685
3693
  queryKey: ["masters", t, l, i],
3686
- queryFn: () => _.listMasters(t, {
3694
+ queryFn: () => T.listMasters(t, {
3687
3695
  include_disabled: 1,
3688
3696
  limit: i,
3689
3697
  offset: l * i
3690
3698
  }),
3691
3699
  enabled: !!t
3692
- }), w = (p == null ? void 0 : p.rows) ?? [], b = (p == null ? void 0 : p.total) ?? 0, N = Math.max(1, Math.ceil(b / i)), y = b === 0 ? 0 : l * i + 1, T = Math.min(b, (l + 1) * i), A = Ce(() => {
3700
+ }), w = (p == null ? void 0 : p.rows) ?? [], x = (p == null ? void 0 : p.total) ?? 0, N = Math.max(1, Math.ceil(x / i)), y = x === 0 ? 0 : l * i + 1, D = Math.min(x, (l + 1) * i), A = Ce(() => {
3693
3701
  if (!w || w.length === 0) return [];
3694
3702
  const h = Yn();
3695
3703
  return Object.keys(w[0]).map(
@@ -3712,7 +3720,7 @@ function Yr() {
3712
3720
  }
3713
3721
  })
3714
3722
  );
3715
- }, [w, t]), x = Jn({
3723
+ }, [w, t]), b = Jn({
3716
3724
  data: w,
3717
3725
  columns: A,
3718
3726
  getCoreRowModel: Zn()
@@ -3720,28 +3728,28 @@ function Yr() {
3720
3728
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
3721
3729
  s && /* @__PURE__ */ e("div", { className: "rounded-md bg-amber-50 px-4 py-3 text-sm text-amber-800", children: s }),
3722
3730
  /* @__PURE__ */ e("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ e(be, { to: `/masters/${t}/new`, children: /* @__PURE__ */ e(H, { children: "New" }) }) }),
3723
- u ? /* @__PURE__ */ e("p", { className: "text-fg-muted", children: "Loading..." }) : w.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-fg-muted", children: "No records found" }) : /* @__PURE__ */ r(we, { children: [
3731
+ m ? /* @__PURE__ */ e("p", { className: "text-fg-muted", children: "Loading..." }) : w.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-fg-muted", children: "No records found" }) : /* @__PURE__ */ r(we, { children: [
3724
3732
  /* @__PURE__ */ e("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: [
3725
- /* @__PURE__ */ e("thead", { className: "bg-surface-subtle", children: x.getHeaderGroups().map((h) => /* @__PURE__ */ e("tr", { children: h.headers.map((P) => /* @__PURE__ */ e(
3733
+ /* @__PURE__ */ e("thead", { className: "bg-surface-subtle", children: b.getHeaderGroups().map((h) => /* @__PURE__ */ e("tr", { children: h.headers.map((_) => /* @__PURE__ */ e(
3726
3734
  "th",
3727
3735
  {
3728
3736
  className: "px-4 py-3 text-left text-xs font-medium uppercase tracking-wide text-fg-muted",
3729
- children: P.isPlaceholder ? null : Bt(
3730
- P.column.columnDef.header,
3731
- P.getContext()
3737
+ children: _.isPlaceholder ? null : Bt(
3738
+ _.column.columnDef.header,
3739
+ _.getContext()
3732
3740
  )
3733
3741
  },
3734
- P.id
3742
+ _.id
3735
3743
  )) }, h.id)) }),
3736
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children: x.getRowModel().rows.map((h) => /* @__PURE__ */ e(
3744
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children: b.getRowModel().rows.map((h) => /* @__PURE__ */ e(
3737
3745
  "tr",
3738
3746
  {
3739
3747
  className: h.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",
3740
3748
  onClick: () => n(`/masters/${t}/${h.original.name}`),
3741
- children: h.getVisibleCells().map((P) => /* @__PURE__ */ e("td", { className: "px-4 py-2.5", children: Bt(
3742
- P.column.columnDef.cell,
3743
- P.getContext()
3744
- ) }, P.id))
3749
+ children: h.getVisibleCells().map((_) => /* @__PURE__ */ e("td", { className: "px-4 py-2.5", children: Bt(
3750
+ _.column.columnDef.cell,
3751
+ _.getContext()
3752
+ ) }, _.id))
3745
3753
  },
3746
3754
  h.id
3747
3755
  )) })
@@ -3752,11 +3760,11 @@ function Yr() {
3752
3760
  /* @__PURE__ */ r("span", { className: "font-medium text-fg", children: [
3753
3761
  y,
3754
3762
  "–",
3755
- T
3763
+ D
3756
3764
  ] }),
3757
3765
  " ",
3758
3766
  "of ",
3759
- /* @__PURE__ */ e("span", { className: "font-medium text-fg", children: b })
3767
+ /* @__PURE__ */ e("span", { className: "font-medium text-fg", children: x })
3760
3768
  ] }),
3761
3769
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
3762
3770
  /* @__PURE__ */ r("label", { className: "flex items-center gap-1.5", children: [
@@ -3765,7 +3773,7 @@ function Yr() {
3765
3773
  "select",
3766
3774
  {
3767
3775
  value: i,
3768
- onChange: (h) => m(Number(h.target.value)),
3776
+ onChange: (h) => d(Number(h.target.value)),
3769
3777
  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",
3770
3778
  children: Qr.map((h) => /* @__PURE__ */ e("option", { value: h, children: h }, h))
3771
3779
  }
@@ -3873,38 +3881,38 @@ const Jr = {
3873
3881
  }, _n = /* @__PURE__ */ new Set(["customer", "supplier", "item", "warehouse"]);
3874
3882
  function Tn() {
3875
3883
  var I;
3876
- const { type: t, name: n } = ut(), a = Ie(), s = We(), { t: i } = Z(), o = !n || n === "new", l = Zr[t ?? ""] ?? t ?? "", c = i(`masters.${t}.one`, { defaultValue: l }), g = Jr[t ?? ""] ?? [], m = (C) => i(`fields.${C.label}`, { defaultValue: C.label }), [p, u] = S({}), { data: w, isLoading: b } = ie({
3884
+ const { type: t, name: n } = ut(), a = Ie(), s = We(), { t: i } = Z(), o = !n || n === "new", l = Zr[t ?? ""] ?? t ?? "", c = i(`masters.${t}.one`, { defaultValue: l }), g = Jr[t ?? ""] ?? [], d = (C) => i(`fields.${C.label}`, { defaultValue: C.label }), [p, m] = S({}), { data: w, isLoading: x } = ie({
3877
3885
  queryKey: ["master", t, n],
3878
- queryFn: () => _.getMaster(t, n),
3886
+ queryFn: () => T.getMaster(t, n),
3879
3887
  enabled: !!t && !!n && !o
3880
3888
  });
3881
- re(() => {
3889
+ ae(() => {
3882
3890
  if (o) {
3883
3891
  const C = {};
3884
3892
  g.forEach((O) => {
3885
3893
  C[O.name] = O.default ?? "";
3886
- }), u(C);
3887
- } else w && u(w);
3894
+ }), m(C);
3895
+ } else w && m(w);
3888
3896
  }, [o, w, g]);
3889
3897
  const N = qe();
3890
- re(() => {
3891
- !o || !N || g.some((C) => C.name === "default_currency") && u((C) => {
3898
+ ae(() => {
3899
+ !o || !N || g.some((C) => C.name === "default_currency") && m((C) => {
3892
3900
  const O = C.default_currency;
3893
3901
  return O && O !== "USD" || O === N ? C : { ...C, default_currency: N };
3894
3902
  });
3895
3903
  }, [o, g, N]);
3896
3904
  const y = oe({
3897
- mutationFn: (C) => _.createMaster(t, C),
3905
+ mutationFn: (C) => T.createMaster(t, C),
3898
3906
  onSuccess: (C) => {
3899
3907
  s.invalidateQueries({ queryKey: ["masters", t] }), a(`/masters/${t}/${C.name}`, { replace: !0 });
3900
3908
  }
3901
- }), T = oe({
3902
- mutationFn: (C) => _.updateMaster(t, n, C),
3909
+ }), D = oe({
3910
+ mutationFn: (C) => T.updateMaster(t, n, C),
3903
3911
  onSuccess: () => {
3904
3912
  s.invalidateQueries({ queryKey: ["master", t, n] }), s.invalidateQueries({ queryKey: ["masters", t] });
3905
3913
  }
3906
3914
  }), A = oe({
3907
- mutationFn: () => _.deleteMaster(t, n),
3915
+ mutationFn: () => T.deleteMaster(t, n),
3908
3916
  onSuccess: (C) => {
3909
3917
  if (s.invalidateQueries({ queryKey: ["masters", t] }), (C == null ? void 0 : C.status) === "disabled") {
3910
3918
  a(`/masters/${t}`, {
@@ -3921,37 +3929,40 @@ function Tn() {
3921
3929
  }
3922
3930
  a(`/masters/${t}`, { replace: !0 });
3923
3931
  }
3924
- }), x = () => {
3932
+ }), b = () => {
3925
3933
  if (v.length > 0) return;
3926
3934
  const C = t === "company" && !p.name ? { ...p, name: p.company_name } : p;
3927
- o ? y.mutate(C) : T.mutate(C);
3928
- }, d = () => {
3935
+ o ? y.mutate(C) : D.mutate(C);
3936
+ }, u = () => {
3929
3937
  window.confirm(i("masterForm.deleteConfirm", { label: c })) && A.mutate();
3930
3938
  }, h = (C, O) => {
3931
- u((G) => ({ ...G, [C]: O }));
3939
+ m((G) => ({ ...G, [C]: O }));
3932
3940
  };
3933
- if (!o && b)
3941
+ if (!o && x)
3934
3942
  return /* @__PURE__ */ e("p", { className: "text-fg-muted", children: i("common.loading") });
3935
- const P = y.isPending || T.isPending, v = g.filter((C) => {
3943
+ const _ = y.isPending || D.isPending, v = g.filter((C) => {
3936
3944
  if (!C.required || C.readOnly || o && C.name === "name" && _n.has(t ?? "")) return !1;
3937
3945
  const O = p[C.name];
3938
3946
  return O == null || String(O).trim() === "";
3939
3947
  });
3940
3948
  return /* @__PURE__ */ r("div", { className: "space-y-6", children: [
3941
- /* @__PURE__ */ e("div", { className: "flex items-center justify-end", children: /* @__PURE__ */ r("div", { className: "flex gap-2", children: [
3942
- /* @__PURE__ */ e(H, { onClick: x, disabled: P || v.length > 0, children: i(P ? "common.saving" : "common.save") }),
3943
- !o && /* @__PURE__ */ e(
3944
- H,
3945
- {
3946
- variant: "danger",
3947
- onClick: d,
3948
- disabled: A.isPending,
3949
- children: i("common.delete")
3950
- }
3951
- )
3952
- ] }) }),
3953
- (y.error || T.error || A.error) && /* @__PURE__ */ e("div", { className: "rounded-lg bg-rose-50 p-4 text-sm text-rose-700 ring-1 ring-rose-200", children: ((I = y.error ?? T.error ?? A.error) == null ? void 0 : I.message) ?? i("common.errorOccurred") }),
3954
- v.length > 0 && /* @__PURE__ */ e("div", { className: "rounded-lg bg-amber-50 p-4 text-sm text-amber-800 ring-1 ring-amber-200", children: i("masterForm.required", { fields: v.map(m).join(", ") }) }),
3949
+ /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
3950
+ o ? /* @__PURE__ */ e("div", {}) : /* @__PURE__ */ e(ua, { kind: "master", slug: t, name: n, onSave: b }),
3951
+ /* @__PURE__ */ r("div", { className: "flex gap-2", children: [
3952
+ /* @__PURE__ */ e(H, { onClick: b, disabled: _ || v.length > 0, children: i(_ ? "common.saving" : "common.save") }),
3953
+ !o && /* @__PURE__ */ e(
3954
+ H,
3955
+ {
3956
+ variant: "danger",
3957
+ onClick: u,
3958
+ disabled: A.isPending,
3959
+ children: i("common.delete")
3960
+ }
3961
+ )
3962
+ ] })
3963
+ ] }),
3964
+ (y.error || D.error || A.error) && /* @__PURE__ */ e("div", { className: "rounded-lg bg-rose-50 p-4 text-sm text-rose-700 ring-1 ring-rose-200", children: ((I = y.error ?? D.error ?? A.error) == null ? void 0 : I.message) ?? i("common.errorOccurred") }),
3965
+ v.length > 0 && /* @__PURE__ */ e("div", { className: "rounded-lg bg-amber-50 p-4 text-sm text-amber-800 ring-1 ring-amber-200", children: i("masterForm.required", { fields: v.map(d).join(", ") }) }),
3955
3966
  p.disabled === 1 && /* @__PURE__ */ e("div", { className: "rounded-lg bg-amber-50 p-4 text-sm text-amber-800 ring-1 ring-amber-200", children: i("masterForm.disabledNotice", { label: c }) }),
3956
3967
  /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: g.map((C) => {
3957
3968
  const G = C.name === "name" && !o || C.readOnly, te = C.required && !(o && C.name === "name" && _n.has(t ?? ""));
@@ -3960,18 +3971,18 @@ function Tn() {
3960
3971
  return /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(
3961
3972
  He,
3962
3973
  {
3963
- label: m(C),
3974
+ label: d(C),
3964
3975
  options: q,
3965
3976
  value: p[C.name] ?? "",
3966
3977
  required: te,
3967
3978
  disabled: G,
3968
- onChange: (D) => h(C.name, D.target.value)
3979
+ onChange: (P) => h(C.name, P.target.value)
3969
3980
  }
3970
3981
  ) }, C.name);
3971
3982
  }
3972
3983
  if (C.type === "textarea")
3973
3984
  return /* @__PURE__ */ r("div", { className: "sm:col-span-2", children: [
3974
- /* @__PURE__ */ e("label", { className: "mb-1.5 block text-sm font-medium text-fg", children: m(C) }),
3985
+ /* @__PURE__ */ e("label", { className: "mb-1.5 block text-sm font-medium text-fg", children: d(C) }),
3975
3986
  /* @__PURE__ */ e(
3976
3987
  "textarea",
3977
3988
  {
@@ -3989,7 +4000,7 @@ function Tn() {
3989
4000
  return /* @__PURE__ */ e(
3990
4001
  J,
3991
4002
  {
3992
- label: m(C),
4003
+ label: d(C),
3993
4004
  type: U,
3994
4005
  step: C.type === "currency" ? "0.01" : void 0,
3995
4006
  required: te,
@@ -4009,70 +4020,70 @@ function Tn() {
4009
4020
  function Xr(t) {
4010
4021
  const { data: n, isLoading: a, error: s, refetch: i } = ie({
4011
4022
  queryKey: ["report", "trial-balance", t],
4012
- queryFn: () => _.trialBalance(t)
4023
+ queryFn: () => T.trialBalance(t)
4013
4024
  });
4014
4025
  return { data: n, isLoading: a, error: s, refetch: i };
4015
4026
  }
4016
4027
  function es(t) {
4017
4028
  const { data: n, isLoading: a, error: s, refetch: i } = ie({
4018
4029
  queryKey: ["report", "chart-of-accounts", t],
4019
- queryFn: () => _.chartOfAccounts(t)
4030
+ queryFn: () => T.chartOfAccounts(t)
4020
4031
  });
4021
4032
  return { data: n, isLoading: a, error: s, refetch: i };
4022
4033
  }
4023
4034
  function ts(t) {
4024
4035
  const { data: n, isLoading: a, error: s, refetch: i } = ie({
4025
4036
  queryKey: ["report", "general-ledger", t],
4026
- queryFn: () => _.generalLedger(t)
4037
+ queryFn: () => T.generalLedger(t)
4027
4038
  });
4028
4039
  return { data: n, isLoading: a, error: s, refetch: i };
4029
4040
  }
4030
4041
  function ns(t) {
4031
4042
  const { data: n, isLoading: a, error: s, refetch: i } = ie({
4032
4043
  queryKey: ["report", "stock-balance", t],
4033
- queryFn: () => _.stockBalance(t)
4044
+ queryFn: () => T.stockBalance(t)
4034
4045
  });
4035
4046
  return { data: n, isLoading: a, error: s, refetch: i };
4036
4047
  }
4037
4048
  function as(t) {
4038
4049
  const { data: n, isLoading: a, error: s, refetch: i } = ie({
4039
4050
  queryKey: ["report", "profit-and-loss", t],
4040
- queryFn: () => _.profitAndLoss(t)
4051
+ queryFn: () => T.profitAndLoss(t)
4041
4052
  });
4042
4053
  return { data: n, isLoading: a, error: s, refetch: i };
4043
4054
  }
4044
4055
  function rs(t) {
4045
4056
  const { data: n, isLoading: a, error: s, refetch: i } = ie({
4046
4057
  queryKey: ["report", "balance-sheet", t],
4047
- queryFn: () => _.balanceSheet(t)
4058
+ queryFn: () => T.balanceSheet(t)
4048
4059
  });
4049
4060
  return { data: n, isLoading: a, error: s, refetch: i };
4050
4061
  }
4051
4062
  function ss(t) {
4052
4063
  const { data: n, isLoading: a, error: s, refetch: i } = ie({
4053
4064
  queryKey: ["report", "ar-aging", t],
4054
- queryFn: () => _.arAging(t)
4065
+ queryFn: () => T.arAging(t)
4055
4066
  });
4056
4067
  return { data: n, isLoading: a, error: s, refetch: i };
4057
4068
  }
4058
4069
  function is(t) {
4059
4070
  const { data: n, isLoading: a, error: s, refetch: i } = ie({
4060
4071
  queryKey: ["report", "ap-aging", t],
4061
- queryFn: () => _.apAging(t)
4072
+ queryFn: () => T.apAging(t)
4062
4073
  });
4063
4074
  return { data: n, isLoading: a, error: s, refetch: i };
4064
4075
  }
4065
4076
  function os() {
4066
- const { t } = Z(), [n] = se("company", ""), [a] = se("from", ""), [s] = se("to", ""), i = Ye(), [o, l] = S(n), [c, g] = S(a), [m, p] = S(s), u = qe(o), w = (d) => Oe(d, u), b = Ce(() => {
4067
- const d = {};
4068
- return n && (d.company = n), a && (d.from_date = a), s && (d.to_date = s), d;
4069
- }, [n, a, s]), { data: N, isLoading: y, refetch: T } = Xr(b), A = () => {
4077
+ const { t } = Z(), [n] = se("company", ""), [a] = se("from", ""), [s] = se("to", ""), i = Ye(), [o, l] = S(n), [c, g] = S(a), [d, p] = S(s), m = qe(o), w = (u) => Oe(u, m), x = Ce(() => {
4078
+ const u = {};
4079
+ return n && (u.company = n), a && (u.from_date = a), s && (u.to_date = s), u;
4080
+ }, [n, a, s]), { data: N, isLoading: y, refetch: D } = Xr(x), A = () => {
4070
4081
  i({
4071
4082
  company: o || null,
4072
4083
  from: c || null,
4073
- to: m || null
4074
- }), T();
4075
- }, x = N ? N.difference === 0 : !1;
4084
+ to: d || null
4085
+ }), D();
4086
+ }, b = N ? N.difference === 0 : !1;
4076
4087
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4077
4088
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
4078
4089
  /* @__PURE__ */ e(
@@ -4091,7 +4102,7 @@ function os() {
4091
4102
  label: t("fields.From Date", { defaultValue: "From Date" }),
4092
4103
  type: "date",
4093
4104
  value: c,
4094
- onChange: (d) => g(d.target.value)
4105
+ onChange: (u) => g(u.target.value)
4095
4106
  }
4096
4107
  ),
4097
4108
  /* @__PURE__ */ e(
@@ -4099,14 +4110,14 @@ function os() {
4099
4110
  {
4100
4111
  label: t("fields.To Date", { defaultValue: "To Date" }),
4101
4112
  type: "date",
4102
- value: m,
4103
- onChange: (d) => p(d.target.value)
4113
+ value: d,
4114
+ onChange: (u) => p(u.target.value)
4104
4115
  }
4105
4116
  ),
4106
4117
  /* @__PURE__ */ e(H, { onClick: A, children: t("common.apply") })
4107
4118
  ] }),
4108
- /* @__PURE__ */ e($t, { onSelect: (d, h) => {
4109
- g(d), p(h), i({ from: d, to: h });
4119
+ /* @__PURE__ */ e($t, { onSelect: (u, h) => {
4120
+ g(u), p(h), i({ from: u, to: h });
4110
4121
  } }),
4111
4122
  y ? /* @__PURE__ */ e("p", { className: "text-fg-muted", children: t("common.loading") }) : !N || !N.rows || N.rows.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-fg-muted", children: t("reports.noData") }) : /* @__PURE__ */ r(F, { children: [
4112
4123
  /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-line text-sm", children: [
@@ -4116,11 +4127,11 @@ function os() {
4116
4127
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-right text-xs font-medium uppercase tracking-wide text-fg-muted", children: t("fields.Credit", { defaultValue: "Credit" }) }),
4117
4128
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-right text-xs font-medium uppercase tracking-wide text-fg-muted", children: t("fields.Balance", { defaultValue: "Balance" }) })
4118
4129
  ] }) }),
4119
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children: N.rows.map((d, h) => /* @__PURE__ */ r("tr", { className: "transition-colors hover:bg-surface-subtle", children: [
4120
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-fg", children: d.account }),
4121
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right tabular-nums text-fg", children: w(d.debit) }),
4122
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right tabular-nums text-fg", children: w(d.credit) }),
4123
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right font-medium tabular-nums text-fg", children: w(d.balance) })
4130
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children: N.rows.map((u, h) => /* @__PURE__ */ r("tr", { className: "transition-colors hover:bg-surface-subtle", children: [
4131
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-fg", children: u.account }),
4132
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right tabular-nums text-fg", children: w(u.debit) }),
4133
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right tabular-nums text-fg", children: w(u.credit) }),
4134
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right font-medium tabular-nums text-fg", children: w(u.balance) })
4124
4135
  ] }, h)) }),
4125
4136
  /* @__PURE__ */ e("tfoot", { className: "border-t border-line bg-surface-subtle font-semibold", children: /* @__PURE__ */ r("tr", { children: [
4126
4137
  /* @__PURE__ */ e("td", { className: "px-4 py-3 text-fg", children: t("common.total") }),
@@ -4129,7 +4140,7 @@ function os() {
4129
4140
  /* @__PURE__ */ e("td", { className: "px-4 py-3 text-right tabular-nums text-fg", children: w(N.difference) })
4130
4141
  ] }) })
4131
4142
  ] }) }),
4132
- /* @__PURE__ */ e("div", { className: "mt-4 text-center", children: x ? /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1.5 rounded-full bg-emerald-50 px-4 py-1.5 text-sm font-semibold text-emerald-700 ring-1 ring-emerald-200", children: [
4143
+ /* @__PURE__ */ e("div", { className: "mt-4 text-center", children: b ? /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1.5 rounded-full bg-emerald-50 px-4 py-1.5 text-sm font-semibold text-emerald-700 ring-1 ring-emerald-200", children: [
4133
4144
  /* @__PURE__ */ e("span", { className: "h-1.5 w-1.5 rounded-full bg-emerald-500" }),
4134
4145
  t("reports.balanced")
4135
4146
  ] }) : /* @__PURE__ */ r("span", { className: "inline-flex items-center gap-1.5 rounded-full bg-rose-50 px-4 py-1.5 text-sm font-semibold text-rose-700 ring-1 ring-rose-200", children: [
@@ -4142,65 +4153,65 @@ function os() {
4142
4153
  const ls = ["Asset", "Liability", "Equity", "Income", "Expense"];
4143
4154
  function cs() {
4144
4155
  const { t } = Z(), n = (/* @__PURE__ */ new Date()).getFullYear(), [a, s] = S(String(n)), [i, o] = S(/* @__PURE__ */ new Set()), l = Ce(() => {
4145
- const x = [];
4146
- for (let d = n; d >= n - 6; d--)
4147
- x.push({ value: String(d), label: String(d) });
4148
- return x.push({ value: "all", label: t("coa.allTime", { defaultValue: "All time" }) }), x;
4156
+ const b = [];
4157
+ for (let u = n; u >= n - 6; u--)
4158
+ b.push({ value: String(u), label: String(u) });
4159
+ return b.push({ value: "all", label: t("coa.allTime", { defaultValue: "All time" }) }), b;
4149
4160
  }, [n, t]), c = Ce(() => {
4150
- const x = {};
4151
- return a !== "all" && (x.from_date = `${a}-01-01`, x.to_date = `${a}-12-31`), x;
4152
- }, [a]), { data: g, isLoading: m } = es(c), p = qe(""), u = (x) => Oe(x, p), w = (g == null ? void 0 : g.accounts) ?? [], { childrenOf: b, rootsByType: N } = Ce(() => {
4153
- const x = new Map(w.map((P) => [P.name, P])), d = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
4154
- for (const P of w)
4155
- if (P.parent_account && x.has(P.parent_account)) {
4156
- const v = d.get(P.parent_account) ?? [];
4157
- v.push(P), d.set(P.parent_account, v);
4161
+ const b = {};
4162
+ return a !== "all" && (b.from_date = `${a}-01-01`, b.to_date = `${a}-12-31`), b;
4163
+ }, [a]), { data: g, isLoading: d } = es(c), p = qe(""), m = (b) => Oe(b, p), w = (g == null ? void 0 : g.accounts) ?? [], { childrenOf: x, rootsByType: N } = Ce(() => {
4164
+ const b = new Map(w.map((_) => [_.name, _])), u = /* @__PURE__ */ new Map(), h = /* @__PURE__ */ new Map();
4165
+ for (const _ of w)
4166
+ if (_.parent_account && b.has(_.parent_account)) {
4167
+ const v = u.get(_.parent_account) ?? [];
4168
+ v.push(_), u.set(_.parent_account, v);
4158
4169
  } else {
4159
- const v = P.root_type ?? "Other", I = h.get(v) ?? [];
4160
- I.push(P), h.set(v, I);
4170
+ const v = _.root_type ?? "Other", I = h.get(v) ?? [];
4171
+ I.push(_), h.set(v, I);
4161
4172
  }
4162
- return { childrenOf: d, rootsByType: h };
4163
- }, [w]), y = (x) => {
4164
- o((d) => {
4165
- const h = new Set(d);
4166
- return h.has(x) ? h.delete(x) : h.add(x), h;
4173
+ return { childrenOf: u, rootsByType: h };
4174
+ }, [w]), y = (b) => {
4175
+ o((u) => {
4176
+ const h = new Set(u);
4177
+ return h.has(b) ? h.delete(b) : h.add(b), h;
4167
4178
  });
4168
- }, T = (x) => {
4169
- const d = new URLSearchParams({ account: x });
4170
- return a !== "all" && (d.set("from", `${a}-01-01`), d.set("to", `${a}-12-31`)), `/reports/general-ledger?${d.toString()}`;
4171
- }, A = (x, d) => {
4172
- const h = b.get(x.name) ?? [], P = i.has(x.name), v = !x.has_entries || x.disabled;
4179
+ }, D = (b) => {
4180
+ const u = new URLSearchParams({ account: b });
4181
+ return a !== "all" && (u.set("from", `${a}-01-01`), u.set("to", `${a}-12-31`)), `/reports/general-ledger?${u.toString()}`;
4182
+ }, A = (b, u) => {
4183
+ const h = x.get(b.name) ?? [], _ = i.has(b.name), v = !b.has_entries || b.disabled;
4173
4184
  return /* @__PURE__ */ r("div", { children: [
4174
4185
  /* @__PURE__ */ r(
4175
4186
  "div",
4176
4187
  {
4177
4188
  className: `flex items-center gap-2 rounded px-2 py-1.5 text-sm hover:bg-surface-subtle ${v ? "text-fg-muted" : "text-fg"}`,
4178
- style: { paddingLeft: `${8 + d * 20}px` },
4189
+ style: { paddingLeft: `${8 + u * 20}px` },
4179
4190
  children: [
4180
4191
  h.length > 0 ? /* @__PURE__ */ e(
4181
4192
  "button",
4182
4193
  {
4183
4194
  type: "button",
4184
- onClick: () => y(x.name),
4195
+ onClick: () => y(b.name),
4185
4196
  className: "shrink-0 text-fg-muted transition-colors hover:text-fg",
4186
- children: P ? /* @__PURE__ */ e(Dt, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ e(Mt, { className: "h-3.5 w-3.5" })
4197
+ children: _ ? /* @__PURE__ */ e(Dt, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ e(Mt, { className: "h-3.5 w-3.5" })
4187
4198
  }
4188
4199
  ) : /* @__PURE__ */ e("span", { className: "w-3.5 shrink-0" }),
4189
- /* @__PURE__ */ r("span", { className: `min-w-0 flex-1 truncate ${x.is_group ? "font-medium" : ""}`, children: [
4190
- x.is_group ? /* @__PURE__ */ e(we, { children: x.account_name || x.name }) : /* @__PURE__ */ r(be, { to: T(x.name), className: "hover:text-brand hover:underline", children: [
4191
- /* @__PURE__ */ e("span", { className: "font-mono text-xs text-fg-muted", children: x.name }),
4200
+ /* @__PURE__ */ r("span", { className: `min-w-0 flex-1 truncate ${b.is_group ? "font-medium" : ""}`, children: [
4201
+ b.is_group ? /* @__PURE__ */ e(we, { children: b.account_name || b.name }) : /* @__PURE__ */ r(be, { to: D(b.name), className: "hover:text-brand hover:underline", children: [
4202
+ /* @__PURE__ */ e("span", { className: "font-mono text-xs text-fg-muted", children: b.name }),
4192
4203
  " ",
4193
- x.account_name || x.name
4204
+ b.account_name || b.name
4194
4205
  ] }),
4195
- x.disabled && /* @__PURE__ */ e("span", { className: "ml-2 text-xs text-fg-muted", children: t("coa.disabled", { defaultValue: "disabled" }) })
4206
+ b.disabled && /* @__PURE__ */ e("span", { className: "ml-2 text-xs text-fg-muted", children: t("coa.disabled", { defaultValue: "disabled" }) })
4196
4207
  ] }),
4197
- x.account_type && /* @__PURE__ */ e("span", { className: "hidden shrink-0 text-xs text-fg-muted sm:inline", children: x.account_type }),
4198
- /* @__PURE__ */ e("span", { className: "w-32 shrink-0 text-right font-mono text-sm tabular-nums", children: x.has_entries || x.is_group ? u(x.balance) : "—" })
4208
+ b.account_type && /* @__PURE__ */ e("span", { className: "hidden shrink-0 text-xs text-fg-muted sm:inline", children: b.account_type }),
4209
+ /* @__PURE__ */ e("span", { className: "w-32 shrink-0 text-right font-mono text-sm tabular-nums", children: b.has_entries || b.is_group ? m(b.balance) : "—" })
4199
4210
  ]
4200
4211
  }
4201
4212
  ),
4202
- !P && h.map((I) => A(I, d + 1))
4203
- ] }, x.name);
4213
+ !_ && h.map((I) => A(I, u + 1))
4214
+ ] }, b.name);
4204
4215
  };
4205
4216
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4206
4217
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
@@ -4210,19 +4221,19 @@ function cs() {
4210
4221
  label: t("coa.period", { defaultValue: "Period" }),
4211
4222
  options: l,
4212
4223
  value: a,
4213
- onChange: (x) => s(x.target.value)
4224
+ onChange: (b) => s(b.target.value)
4214
4225
  }
4215
4226
  ) }),
4216
4227
  /* @__PURE__ */ e("p", { className: "pb-2 text-xs text-fg-muted", children: t("coa.semantics", {
4217
4228
  defaultValue: "Balance-sheet accounts: closing balance at period end. P&L accounts: movement within the period. Click an account for its ledger."
4218
4229
  }) })
4219
4230
  ] }),
4220
- m && /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e("p", { className: "text-sm text-fg-muted", children: t("common.loading", { defaultValue: "Loading…" }) }) }),
4221
- !m && w.length === 0 && /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e("p", { className: "text-sm text-fg-muted", children: t("coa.empty", { defaultValue: "No accounts found. Complete the company setup first." }) }) }),
4222
- !m && ls.filter((x) => (N.get(x) ?? []).length > 0).map((x) => /* @__PURE__ */ r(F, { children: [
4223
- /* @__PURE__ */ e("h3", { className: "mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-fg-muted", children: t(`coa.rootType.${x}`, { defaultValue: x }) }),
4224
- /* @__PURE__ */ e("div", { children: (N.get(x) ?? []).map((d) => A(d, 0)) })
4225
- ] }, x))
4231
+ d && /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e("p", { className: "text-sm text-fg-muted", children: t("common.loading", { defaultValue: "Loading…" }) }) }),
4232
+ !d && w.length === 0 && /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e("p", { className: "text-sm text-fg-muted", children: t("coa.empty", { defaultValue: "No accounts found. Complete the company setup first." }) }) }),
4233
+ !d && ls.filter((b) => (N.get(b) ?? []).length > 0).map((b) => /* @__PURE__ */ r(F, { children: [
4234
+ /* @__PURE__ */ e("h3", { className: "mb-2 px-2 text-xs font-semibold uppercase tracking-wider text-fg-muted", children: t(`coa.rootType.${b}`, { defaultValue: b }) }),
4235
+ /* @__PURE__ */ e("div", { children: (N.get(b) ?? []).map((u) => A(u, 0)) })
4236
+ ] }, b))
4226
4237
  ] });
4227
4238
  }
4228
4239
  function ds(t) {
@@ -4230,13 +4241,13 @@ function ds(t) {
4230
4241
  }
4231
4242
  const us = ["25", "50", "100", "200"];
4232
4243
  function ms() {
4233
- const { t } = Z(), [n] = se("account", ""), [a] = se("party", ""), [s] = se("from", ""), [i] = se("to", ""), [o] = se("per_page", 50), [l] = se("page", 1), c = l - 1, g = Ye(), m = (D) => g({ page: D === 0 ? null : D + 1 }), p = (D) => g({ per_page: D, page: null }), [u, w] = S(n), [b, N] = S(a), [y, T] = S(s), [A, x] = S(i), d = qe(), h = (D) => Oe(D, d), P = Ce(() => {
4234
- const D = {};
4235
- return n && (D.account = n), a && (D.party = a), s && (D.from_date = s), i && (D.to_date = i), D.limit = String(o), D.offset = String(c * o), D;
4236
- }, [n, a, s, i, o, c]), { data: v, isLoading: I, refetch: C } = ts(P), O = (v == null ? void 0 : v.rows) ?? [], G = (v == null ? void 0 : v.total) ?? 0, te = Math.max(1, Math.ceil(G / o)), U = G === 0 ? 0 : c * o + 1, f = Math.min(G, (c + 1) * o), q = () => {
4244
+ const { t } = Z(), [n] = se("account", ""), [a] = se("party", ""), [s] = se("from", ""), [i] = se("to", ""), [o] = se("per_page", 50), [l] = se("page", 1), c = l - 1, g = Ye(), d = (P) => g({ page: P === 0 ? null : P + 1 }), p = (P) => g({ per_page: P, page: null }), [m, w] = S(n), [x, N] = S(a), [y, D] = S(s), [A, b] = S(i), u = qe(), h = (P) => Oe(P, u), _ = Ce(() => {
4245
+ const P = {};
4246
+ return n && (P.account = n), a && (P.party = a), s && (P.from_date = s), i && (P.to_date = i), P.limit = String(o), P.offset = String(c * o), P;
4247
+ }, [n, a, s, i, o, c]), { data: v, isLoading: I, refetch: C } = ts(_), O = (v == null ? void 0 : v.rows) ?? [], G = (v == null ? void 0 : v.total) ?? 0, te = Math.max(1, Math.ceil(G / o)), U = G === 0 ? 0 : c * o + 1, f = Math.min(G, (c + 1) * o), q = () => {
4237
4248
  g({
4238
- account: u || null,
4239
- party: b || null,
4249
+ account: m || null,
4250
+ party: x || null,
4240
4251
  from: y || null,
4241
4252
  to: A || null,
4242
4253
  page: null
@@ -4248,7 +4259,7 @@ function ms() {
4248
4259
  Se,
4249
4260
  {
4250
4261
  label: t("fields.Account", { defaultValue: "Account" }),
4251
- value: u,
4262
+ value: m,
4252
4263
  onChange: w,
4253
4264
  linkDoctype: "account",
4254
4265
  readOnly: !1
@@ -4258,7 +4269,7 @@ function ms() {
4258
4269
  Se,
4259
4270
  {
4260
4271
  label: t("fields.Party", { defaultValue: "Party" }),
4261
- value: b,
4272
+ value: x,
4262
4273
  onChange: N,
4263
4274
  linkDoctype: "customer",
4264
4275
  readOnly: !1
@@ -4270,7 +4281,7 @@ function ms() {
4270
4281
  label: t("fields.From Date", { defaultValue: "From Date" }),
4271
4282
  type: "date",
4272
4283
  value: y,
4273
- onChange: (D) => T(D.target.value)
4284
+ onChange: (P) => D(P.target.value)
4274
4285
  }
4275
4286
  ),
4276
4287
  /* @__PURE__ */ e(
@@ -4279,13 +4290,13 @@ function ms() {
4279
4290
  label: t("fields.To Date", { defaultValue: "To Date" }),
4280
4291
  type: "date",
4281
4292
  value: A,
4282
- onChange: (D) => x(D.target.value)
4293
+ onChange: (P) => b(P.target.value)
4283
4294
  }
4284
4295
  ),
4285
4296
  /* @__PURE__ */ e(H, { onClick: q, children: t("common.apply") })
4286
4297
  ] }),
4287
- /* @__PURE__ */ e($t, { onSelect: (D, L) => {
4288
- T(D), x(L), g({ from: D, to: L, page: null });
4298
+ /* @__PURE__ */ e($t, { onSelect: (P, L) => {
4299
+ D(P), b(L), g({ from: P, to: L, page: null });
4289
4300
  } }),
4290
4301
  I ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : O.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-gray-400", children: t("reports.noEntries") }) : /* @__PURE__ */ r(we, { children: [
4291
4302
  /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
@@ -4299,22 +4310,22 @@ function ms() {
4299
4310
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: t("fields.Voucher Type", { defaultValue: "Voucher Type" }) }),
4300
4311
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: t("fields.Voucher No", { defaultValue: "Voucher No" }) })
4301
4312
  ] }) }),
4302
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: O.map((D, L) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4303
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-500", children: Ft(D.posting_date ?? D.date) }),
4304
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-900", children: D.account }),
4305
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-700", children: D.party ?? "-" }),
4306
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: h(D.debit) }),
4307
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: h(D.credit) }),
4308
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right font-medium", children: h(D.balance) }),
4309
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-700", children: D.voucher_type ?? "-" }),
4310
- /* @__PURE__ */ e("td", { className: "px-4 py-2", children: D.voucher_type && D.voucher_no ? /* @__PURE__ */ e(
4313
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: O.map((P, L) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4314
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-500", children: Ft(P.posting_date ?? P.date) }),
4315
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-900", children: P.account }),
4316
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-700", children: P.party ?? "-" }),
4317
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: h(P.debit) }),
4318
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: h(P.credit) }),
4319
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right font-medium", children: h(P.balance) }),
4320
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-700", children: P.voucher_type ?? "-" }),
4321
+ /* @__PURE__ */ e("td", { className: "px-4 py-2", children: P.voucher_type && P.voucher_no ? /* @__PURE__ */ e(
4311
4322
  be,
4312
4323
  {
4313
- to: `/app/${ds(D.voucher_type)}/${D.voucher_no}`,
4324
+ to: `/app/${ds(P.voucher_type)}/${P.voucher_no}`,
4314
4325
  className: "font-medium text-blue-600 hover:text-blue-800",
4315
- children: D.voucher_no
4326
+ children: P.voucher_no
4316
4327
  }
4317
- ) : D.voucher_no ?? "-" })
4328
+ ) : P.voucher_no ?? "-" })
4318
4329
  ] }, L)) })
4319
4330
  ] }) }) }),
4320
4331
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center justify-between gap-3 text-sm text-gray-600", children: [
@@ -4338,16 +4349,16 @@ function ms() {
4338
4349
  "select",
4339
4350
  {
4340
4351
  value: o,
4341
- onChange: (D) => p(Number(D.target.value)),
4352
+ onChange: (P) => p(Number(P.target.value)),
4342
4353
  className: "rounded border border-gray-300 bg-white px-2 py-1 text-sm",
4343
- children: us.map((D) => /* @__PURE__ */ e("option", { value: D, children: D }, D))
4354
+ children: us.map((P) => /* @__PURE__ */ e("option", { value: P, children: P }, P))
4344
4355
  }
4345
4356
  )
4346
4357
  ] }),
4347
4358
  /* @__PURE__ */ e(
4348
4359
  "button",
4349
4360
  {
4350
- onClick: () => m(Math.max(0, c - 1)),
4361
+ onClick: () => d(Math.max(0, c - 1)),
4351
4362
  disabled: c === 0,
4352
4363
  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",
4353
4364
  children: t("common.prev")
@@ -4365,7 +4376,7 @@ function ms() {
4365
4376
  /* @__PURE__ */ e(
4366
4377
  "button",
4367
4378
  {
4368
- onClick: () => m(Math.min(te - 1, c + 1)),
4379
+ onClick: () => d(Math.min(te - 1, c + 1)),
4369
4380
  disabled: c >= te - 1,
4370
4381
  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",
4371
4382
  children: t("common.next")
@@ -4377,14 +4388,14 @@ function ms() {
4377
4388
  ] });
4378
4389
  }
4379
4390
  function ps() {
4380
- const { t } = Z(), [n] = se("item_code", ""), [a] = se("warehouse", ""), s = Ye(), [i, o] = S(n), [l, c] = S(a), g = qe(), m = (y) => Oe(y, g), p = Ce(() => {
4391
+ const { t } = Z(), [n] = se("item_code", ""), [a] = se("warehouse", ""), s = Ye(), [i, o] = S(n), [l, c] = S(a), g = qe(), d = (y) => Oe(y, g), p = Ce(() => {
4381
4392
  const y = {};
4382
4393
  return n && (y.item_code = n), a && (y.warehouse = a), y;
4383
- }, [n, a]), { data: u, isLoading: w, refetch: b } = ns(p), N = () => {
4394
+ }, [n, a]), { data: m, isLoading: w, refetch: x } = ns(p), N = () => {
4384
4395
  s({
4385
4396
  item_code: i || null,
4386
4397
  warehouse: l || null
4387
- }), b();
4398
+ }), x();
4388
4399
  };
4389
4400
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4390
4401
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
@@ -4410,7 +4421,7 @@ function ps() {
4410
4421
  ),
4411
4422
  /* @__PURE__ */ e(H, { onClick: N, children: t("common.apply") })
4412
4423
  ] }),
4413
- w ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : !u || !u.rows || u.rows.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-gray-400", children: t("reports.noStockData") }) : /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
4424
+ w ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : !m || !m.rows || m.rows.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-gray-400", children: t("reports.noStockData") }) : /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
4414
4425
  /* @__PURE__ */ e("thead", { className: "bg-gray-50", children: /* @__PURE__ */ r("tr", { children: [
4415
4426
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: t("fields.Item Code", { defaultValue: "Item Code" }) }),
4416
4427
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: t("fields.Item Name", { defaultValue: "Item Name" }) }),
@@ -4419,39 +4430,39 @@ function ps() {
4419
4430
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-right font-medium text-gray-500", children: t("fields.Valuation Rate", { defaultValue: "Valuation Rate" }) }),
4420
4431
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-right font-medium text-gray-500", children: t("fields.Stock Value", { defaultValue: "Stock Value" }) })
4421
4432
  ] }) }),
4422
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: u.rows.map((y, T) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4433
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: m.rows.map((y, D) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4423
4434
  /* @__PURE__ */ e("td", { className: "px-4 py-2 font-medium text-gray-900", children: y.item_code }),
4424
4435
  /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-700", children: y.item_name }),
4425
4436
  /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-700", children: y.warehouse }),
4426
4437
  /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: Zt(y.actual_qty) }),
4427
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: m(y.valuation_rate) }),
4428
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right font-medium", children: m(y.stock_value) })
4429
- ] }, T)) })
4438
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: d(y.valuation_rate) }),
4439
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right font-medium", children: d(y.stock_value) })
4440
+ ] }, D)) })
4430
4441
  ] }) }) })
4431
4442
  ] });
4432
4443
  }
4433
4444
  function hs() {
4434
- const { t } = Z(), [n] = se("company", ""), [a] = se("from", ""), [s] = se("to", ""), i = Ye(), [o, l] = S(n), c = qe(o), g = (d) => Oe(d, c), [m, p] = S(a), [u, w] = S(s), b = Ce(() => {
4435
- const d = {};
4436
- return n && (d.company = n), a && (d.from_date = a), s && (d.to_date = s), d;
4437
- }, [n, a, s]), { data: N, isLoading: y, refetch: T } = as(b), A = () => {
4445
+ const { t } = Z(), [n] = se("company", ""), [a] = se("from", ""), [s] = se("to", ""), i = Ye(), [o, l] = S(n), c = qe(o), g = (u) => Oe(u, c), [d, p] = S(a), [m, w] = S(s), x = Ce(() => {
4446
+ const u = {};
4447
+ return n && (u.company = n), a && (u.from_date = a), s && (u.to_date = s), u;
4448
+ }, [n, a, s]), { data: N, isLoading: y, refetch: D } = as(x), A = () => {
4438
4449
  i({
4439
4450
  company: o || null,
4440
- from: m || null,
4441
- to: u || null
4442
- }), T();
4443
- }, x = N && (N.income && N.income.length > 0 || N.expense && N.expense.length > 0);
4451
+ from: d || null,
4452
+ to: m || null
4453
+ }), D();
4454
+ }, b = N && (N.income && N.income.length > 0 || N.expense && N.expense.length > 0);
4444
4455
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4445
4456
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
4446
4457
  /* @__PURE__ */ e(Se, { label: t("fields.Company", { defaultValue: "Company" }), value: o, onChange: l, linkDoctype: "company", readOnly: !1 }),
4447
- /* @__PURE__ */ e(J, { label: t("fields.From Date", { defaultValue: "From Date" }), type: "date", value: m, onChange: (d) => p(d.target.value) }),
4448
- /* @__PURE__ */ e(J, { label: t("fields.To Date", { defaultValue: "To Date" }), type: "date", value: u, onChange: (d) => w(d.target.value) }),
4458
+ /* @__PURE__ */ e(J, { label: t("fields.From Date", { defaultValue: "From Date" }), type: "date", value: d, onChange: (u) => p(u.target.value) }),
4459
+ /* @__PURE__ */ e(J, { label: t("fields.To Date", { defaultValue: "To Date" }), type: "date", value: m, onChange: (u) => w(u.target.value) }),
4449
4460
  /* @__PURE__ */ e(H, { onClick: A, children: t("common.apply") })
4450
4461
  ] }),
4451
- /* @__PURE__ */ e($t, { onSelect: (d, h) => {
4452
- p(d), w(h), i({ from: d, to: h });
4462
+ /* @__PURE__ */ e($t, { onSelect: (u, h) => {
4463
+ p(u), w(h), i({ from: u, to: h });
4453
4464
  } }),
4454
- y ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : x ? /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4465
+ y ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : b ? /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4455
4466
  /* @__PURE__ */ r(F, { children: [
4456
4467
  /* @__PURE__ */ e("h3", { className: "mb-3 text-base font-semibold text-gray-800", children: t("reports.income") }),
4457
4468
  /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
@@ -4459,9 +4470,9 @@ function hs() {
4459
4470
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: t("fields.Account", { defaultValue: "Account" }) }),
4460
4471
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-right font-medium text-gray-500", children: t("fields.Amount", { defaultValue: "Amount" }) })
4461
4472
  ] }) }),
4462
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: (N.income || []).map((d, h) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4463
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-900", children: d.account }),
4464
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: g(d.amount) })
4473
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: (N.income || []).map((u, h) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4474
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-900", children: u.account }),
4475
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: g(u.amount) })
4465
4476
  ] }, h)) }),
4466
4477
  /* @__PURE__ */ e("tfoot", { className: "border-t-2 border-gray-300 bg-gray-50 font-semibold", children: /* @__PURE__ */ r("tr", { children: [
4467
4478
  /* @__PURE__ */ e("td", { className: "px-4 py-3 text-gray-900", children: t("reports.totalIncome") }),
@@ -4476,9 +4487,9 @@ function hs() {
4476
4487
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: t("fields.Account", { defaultValue: "Account" }) }),
4477
4488
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-right font-medium text-gray-500", children: t("fields.Amount", { defaultValue: "Amount" }) })
4478
4489
  ] }) }),
4479
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: (N.expense || []).map((d, h) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4480
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-900", children: d.account }),
4481
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: g(d.amount) })
4490
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: (N.expense || []).map((u, h) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4491
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-900", children: u.account }),
4492
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: g(u.amount) })
4482
4493
  ] }, h)) }),
4483
4494
  /* @__PURE__ */ e("tfoot", { className: "border-t-2 border-gray-300 bg-gray-50 font-semibold", children: /* @__PURE__ */ r("tr", { children: [
4484
4495
  /* @__PURE__ */ e("td", { className: "px-4 py-3 text-gray-900", children: t("reports.totalExpenses") }),
@@ -4515,13 +4526,13 @@ function Gt({ title: t, rows: n, total: a, totalLabel: s, currency: i }) {
4515
4526
  ] });
4516
4527
  }
4517
4528
  function gs() {
4518
- var A, x, d;
4519
- const { t } = Z(), [n] = se("company", ""), [a] = se("as_of_date", ""), s = Ye(), [i, o] = S(n), [l, c] = S(a), g = qe(i), m = (h) => Oe(h, g), p = Ce(() => {
4529
+ var A, b, u;
4530
+ const { t } = Z(), [n] = se("company", ""), [a] = se("as_of_date", ""), s = Ye(), [i, o] = S(n), [l, c] = S(a), g = qe(i), d = (h) => Oe(h, g), p = Ce(() => {
4520
4531
  const h = {};
4521
4532
  return n && (h.company = n), a && (h.as_of_date = a), h;
4522
- }, [n, a]), { data: u, isLoading: w, refetch: b } = rs(p), N = () => {
4523
- s({ company: i || null, as_of_date: l || null }), b();
4524
- }, y = u && (((A = u.assets) == null ? void 0 : A.length) > 0 || ((x = u.liabilities) == null ? void 0 : x.length) > 0 || ((d = u.equity) == null ? void 0 : d.length) > 0), T = u ? Math.abs(u.total_assets - u.total_liabilities_and_equity) < 0.01 : !1;
4533
+ }, [n, a]), { data: m, isLoading: w, refetch: x } = rs(p), N = () => {
4534
+ s({ company: i || null, as_of_date: l || null }), x();
4535
+ }, y = m && (((A = m.assets) == null ? void 0 : A.length) > 0 || ((b = m.liabilities) == null ? void 0 : b.length) > 0 || ((u = m.equity) == null ? void 0 : u.length) > 0), D = m ? Math.abs(m.total_assets - m.total_liabilities_and_equity) < 0.01 : !1;
4525
4536
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4526
4537
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
4527
4538
  /* @__PURE__ */ e(Se, { label: t("fields.Company", { defaultValue: "Company" }), value: i, onChange: o, linkDoctype: "company", readOnly: !1 }),
@@ -4532,33 +4543,33 @@ function gs() {
4532
4543
  c(h), s({ as_of_date: h });
4533
4544
  } }),
4534
4545
  w ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : y ? /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4535
- /* @__PURE__ */ e(Gt, { title: t("reports.assets"), rows: u.assets || [], total: u.total_assets, totalLabel: t("reports.totalAssets"), currency: g }),
4536
- /* @__PURE__ */ e(Gt, { title: t("reports.liabilities"), rows: u.liabilities || [], total: u.total_liabilities, totalLabel: t("reports.totalLiabilities"), currency: g }),
4537
- /* @__PURE__ */ e(Gt, { title: t("reports.equity"), rows: u.equity || [], total: u.total_equity, totalLabel: t("reports.totalEquity"), currency: g }),
4546
+ /* @__PURE__ */ e(Gt, { title: t("reports.assets"), rows: m.assets || [], total: m.total_assets, totalLabel: t("reports.totalAssets"), currency: g }),
4547
+ /* @__PURE__ */ e(Gt, { title: t("reports.liabilities"), rows: m.liabilities || [], total: m.total_liabilities, totalLabel: t("reports.totalLiabilities"), currency: g }),
4548
+ /* @__PURE__ */ e(Gt, { title: t("reports.equity"), rows: m.equity || [], total: m.total_equity, totalLabel: t("reports.totalEquity"), currency: g }),
4538
4549
  /* @__PURE__ */ e(F, { children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
4539
4550
  /* @__PURE__ */ r("div", { className: "text-sm", children: [
4540
4551
  /* @__PURE__ */ r("div", { className: "text-gray-500", children: [
4541
4552
  t("reports.totalAssets"),
4542
4553
  ": ",
4543
- /* @__PURE__ */ e("span", { className: "font-semibold text-gray-900", children: m(u.total_assets) })
4554
+ /* @__PURE__ */ e("span", { className: "font-semibold text-gray-900", children: d(m.total_assets) })
4544
4555
  ] }),
4545
4556
  /* @__PURE__ */ r("div", { className: "text-gray-500", children: [
4546
4557
  t("reports.totalLiabilitiesEquity"),
4547
4558
  ": ",
4548
- /* @__PURE__ */ e("span", { className: "font-semibold text-gray-900", children: m(u.total_liabilities_and_equity) })
4559
+ /* @__PURE__ */ e("span", { className: "font-semibold text-gray-900", children: d(m.total_liabilities_and_equity) })
4549
4560
  ] })
4550
4561
  ] }),
4551
- T ? /* @__PURE__ */ e("span", { className: "inline-flex items-center rounded-full bg-green-100 px-4 py-1.5 text-sm font-semibold text-green-800", children: t("reports.balanced") }) : /* @__PURE__ */ e("span", { className: "inline-flex items-center rounded-full bg-red-100 px-4 py-1.5 text-sm font-semibold text-red-800", children: t("reports.imbalanced") })
4562
+ D ? /* @__PURE__ */ e("span", { className: "inline-flex items-center rounded-full bg-green-100 px-4 py-1.5 text-sm font-semibold text-green-800", children: t("reports.balanced") }) : /* @__PURE__ */ e("span", { className: "inline-flex items-center rounded-full bg-red-100 px-4 py-1.5 text-sm font-semibold text-red-800", children: t("reports.imbalanced") })
4552
4563
  ] }) })
4553
4564
  ] }) : /* @__PURE__ */ e("p", { className: "py-8 text-center text-gray-400", children: t("reports.noData") })
4554
4565
  ] });
4555
4566
  }
4556
4567
  function fs() {
4557
- const { t } = Z(), [n] = se("company", ""), [a] = se("as_of_date", ""), s = Ye(), [i, o] = S(n), [l, c] = S(a), g = qe(i), m = (y) => Oe(y, g), p = Ce(() => {
4568
+ const { t } = Z(), [n] = se("company", ""), [a] = se("as_of_date", ""), s = Ye(), [i, o] = S(n), [l, c] = S(a), g = qe(i), d = (y) => Oe(y, g), p = Ce(() => {
4558
4569
  const y = {};
4559
4570
  return n && (y.company = n), a && (y.as_of_date = a), y;
4560
- }, [n, a]), { data: u, isLoading: w, refetch: b } = ss(p), N = () => {
4561
- s({ company: i || null, as_of_date: l || null }), b();
4571
+ }, [n, a]), { data: m, isLoading: w, refetch: x } = ss(p), N = () => {
4572
+ s({ company: i || null, as_of_date: l || null }), x();
4562
4573
  };
4563
4574
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4564
4575
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
@@ -4569,7 +4580,7 @@ function fs() {
4569
4580
  /* @__PURE__ */ e(dn, { onSelect: (y) => {
4570
4581
  c(y), s({ as_of_date: y });
4571
4582
  } }),
4572
- w ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : !u || !u.rows || u.rows.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-gray-400", children: t("reports.noReceivables") }) : /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
4583
+ w ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : !m || !m.rows || m.rows.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-gray-400", children: t("reports.noReceivables") }) : /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
4573
4584
  /* @__PURE__ */ e("thead", { className: "bg-gray-50", children: /* @__PURE__ */ r("tr", { children: [
4574
4585
  /* @__PURE__ */ e("th", { className: "px-3 py-3 text-left font-medium text-gray-500", children: t("fields.Invoice", { defaultValue: "Invoice" }) }),
4575
4586
  /* @__PURE__ */ e("th", { className: "px-3 py-3 text-left font-medium text-gray-500", children: t("fields.Customer", { defaultValue: "Customer" }) }),
@@ -4581,7 +4592,7 @@ function fs() {
4581
4592
  /* @__PURE__ */ e("th", { className: "px-3 py-3 text-right font-medium text-gray-500", children: "61-90" }),
4582
4593
  /* @__PURE__ */ e("th", { className: "px-3 py-3 text-right font-medium text-gray-500", children: "90+" })
4583
4594
  ] }) }),
4584
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: u.rows.map((y, T) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4595
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: m.rows.map((y, D) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4585
4596
  /* @__PURE__ */ e("td", { className: "px-3 py-2", children: /* @__PURE__ */ e(
4586
4597
  be,
4587
4598
  {
@@ -4592,31 +4603,31 @@ function fs() {
4592
4603
  ) }),
4593
4604
  /* @__PURE__ */ e("td", { className: "px-3 py-2 text-gray-900", children: y.customer_name }),
4594
4605
  /* @__PURE__ */ e("td", { className: "px-3 py-2 text-gray-600", children: y.due_date }),
4595
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right font-medium", children: m(y.outstanding) }),
4596
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.current ? m(y.current) : "" }),
4597
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.b1_30 ? m(y.b1_30) : "" }),
4598
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.b31_60 ? m(y.b31_60) : "" }),
4599
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.b61_90 ? m(y.b61_90) : "" }),
4600
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right text-red-600", children: y.b90_plus ? m(y.b90_plus) : "" })
4601
- ] }, T)) }),
4606
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right font-medium", children: d(y.outstanding) }),
4607
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.current ? d(y.current) : "" }),
4608
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.b1_30 ? d(y.b1_30) : "" }),
4609
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.b31_60 ? d(y.b31_60) : "" }),
4610
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.b61_90 ? d(y.b61_90) : "" }),
4611
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right text-red-600", children: y.b90_plus ? d(y.b90_plus) : "" })
4612
+ ] }, D)) }),
4602
4613
  /* @__PURE__ */ e("tfoot", { className: "border-t-2 border-gray-300 bg-gray-50 font-semibold", children: /* @__PURE__ */ r("tr", { children: [
4603
4614
  /* @__PURE__ */ e("td", { className: "px-3 py-3", colSpan: 3, children: t("common.total") }),
4604
- /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: m(u.totals.outstanding) }),
4605
- /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: m(u.totals.current) }),
4606
- /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: m(u.totals.b1_30) }),
4607
- /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: m(u.totals.b31_60) }),
4608
- /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: m(u.totals.b61_90) }),
4609
- /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right text-red-600", children: m(u.totals.b90_plus) })
4615
+ /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.outstanding) }),
4616
+ /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.current) }),
4617
+ /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.b1_30) }),
4618
+ /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.b31_60) }),
4619
+ /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.b61_90) }),
4620
+ /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right text-red-600", children: d(m.totals.b90_plus) })
4610
4621
  ] }) })
4611
4622
  ] }) }) })
4612
4623
  ] });
4613
4624
  }
4614
4625
  function ys() {
4615
- const { t } = Z(), [n] = se("company", ""), [a] = se("as_of_date", ""), s = Ye(), [i, o] = S(n), [l, c] = S(a), g = qe(i), m = (y) => Oe(y, g), p = Ce(() => {
4626
+ const { t } = Z(), [n] = se("company", ""), [a] = se("as_of_date", ""), s = Ye(), [i, o] = S(n), [l, c] = S(a), g = qe(i), d = (y) => Oe(y, g), p = Ce(() => {
4616
4627
  const y = {};
4617
4628
  return n && (y.company = n), a && (y.as_of_date = a), y;
4618
- }, [n, a]), { data: u, isLoading: w, refetch: b } = is(p), N = () => {
4619
- s({ company: i || null, as_of_date: l || null }), b();
4629
+ }, [n, a]), { data: m, isLoading: w, refetch: x } = is(p), N = () => {
4630
+ s({ company: i || null, as_of_date: l || null }), x();
4620
4631
  };
4621
4632
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4622
4633
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
@@ -4627,7 +4638,7 @@ function ys() {
4627
4638
  /* @__PURE__ */ e(dn, { onSelect: (y) => {
4628
4639
  c(y), s({ as_of_date: y });
4629
4640
  } }),
4630
- w ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : !u || !u.rows || u.rows.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-gray-400", children: t("reports.noPayables") }) : /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
4641
+ w ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : !m || !m.rows || m.rows.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-gray-400", children: t("reports.noPayables") }) : /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
4631
4642
  /* @__PURE__ */ e("thead", { className: "bg-gray-50", children: /* @__PURE__ */ r("tr", { children: [
4632
4643
  /* @__PURE__ */ e("th", { className: "px-3 py-3 text-left font-medium text-gray-500", children: t("fields.Invoice", { defaultValue: "Invoice" }) }),
4633
4644
  /* @__PURE__ */ e("th", { className: "px-3 py-3 text-left font-medium text-gray-500", children: t("fields.Supplier", { defaultValue: "Supplier" }) }),
@@ -4639,7 +4650,7 @@ function ys() {
4639
4650
  /* @__PURE__ */ e("th", { className: "px-3 py-3 text-right font-medium text-gray-500", children: "61-90" }),
4640
4651
  /* @__PURE__ */ e("th", { className: "px-3 py-3 text-right font-medium text-gray-500", children: "90+" })
4641
4652
  ] }) }),
4642
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: u.rows.map((y, T) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4653
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: m.rows.map((y, D) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4643
4654
  /* @__PURE__ */ e("td", { className: "px-3 py-2", children: /* @__PURE__ */ e(
4644
4655
  be,
4645
4656
  {
@@ -4650,26 +4661,26 @@ function ys() {
4650
4661
  ) }),
4651
4662
  /* @__PURE__ */ e("td", { className: "px-3 py-2 text-gray-900", children: y.supplier_name }),
4652
4663
  /* @__PURE__ */ e("td", { className: "px-3 py-2 text-gray-600", children: y.due_date }),
4653
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right font-medium", children: m(y.outstanding) }),
4654
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.current ? m(y.current) : "" }),
4655
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.b1_30 ? m(y.b1_30) : "" }),
4656
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.b31_60 ? m(y.b31_60) : "" }),
4657
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.b61_90 ? m(y.b61_90) : "" }),
4658
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right text-red-600", children: y.b90_plus ? m(y.b90_plus) : "" })
4659
- ] }, T)) }),
4664
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right font-medium", children: d(y.outstanding) }),
4665
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.current ? d(y.current) : "" }),
4666
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.b1_30 ? d(y.b1_30) : "" }),
4667
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.b31_60 ? d(y.b31_60) : "" }),
4668
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.b61_90 ? d(y.b61_90) : "" }),
4669
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right text-red-600", children: y.b90_plus ? d(y.b90_plus) : "" })
4670
+ ] }, D)) }),
4660
4671
  /* @__PURE__ */ e("tfoot", { className: "border-t-2 border-gray-300 bg-gray-50 font-semibold", children: /* @__PURE__ */ r("tr", { children: [
4661
4672
  /* @__PURE__ */ e("td", { className: "px-3 py-3", colSpan: 3, children: t("common.total") }),
4662
- /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: m(u.totals.outstanding) }),
4663
- /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: m(u.totals.current) }),
4664
- /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: m(u.totals.b1_30) }),
4665
- /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: m(u.totals.b31_60) }),
4666
- /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: m(u.totals.b61_90) }),
4667
- /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right text-red-600", children: m(u.totals.b90_plus) })
4673
+ /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.outstanding) }),
4674
+ /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.current) }),
4675
+ /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.b1_30) }),
4676
+ /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.b31_60) }),
4677
+ /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right", children: d(m.totals.b61_90) }),
4678
+ /* @__PURE__ */ e("td", { className: "px-3 py-3 text-right text-red-600", children: d(m.totals.b90_plus) })
4668
4679
  ] }) })
4669
4680
  ] }) }) })
4670
4681
  ] });
4671
4682
  }
4672
- const ua = '(function(){"use strict";function u(r,t){const e=Number(r??0)||0;return t==null?e:Number(e.toFixed(t))}const p={flt:u,sum(r,t){return r.reduce((e,a)=>typeof t=="function"?e+u(t(a)):typeof t=="string"?e+u(a[t]):e+u(a),0)},count(r){return r.length},sortBy(r,t,e="asc"){const n=(e===!0?"desc":e===!1?"asc":e)==="desc"?-1:1;return[...r].sort((s,i)=>{const c=s[t],o=i[t];return c==null&&o==null?0:c==null?1:o==null?-1:c<o?-1*n:c>o?1*n:0})},topN(r,t,e=10){return typeof t=="number"?r.slice(0,t):p.sortBy(r,t,"desc").slice(0,e)},group(r,t,e){if(typeof t=="function"){const s=new Map;for(const i of r){const c=t(i),o=JSON.stringify(c);s.has(o)||s.set(o,{key:c,rows:[]}),s.get(o).rows.push(i)}return Array.from(s.values())}const a=t,n=new Map;for(const s of r){const i=a.map(f=>s[f]),c=JSON.stringify(i);if(!n.has(c)){const f={};a.forEach((l,m)=>{f[l]=i[m]});for(const[l,[m]]of Object.entries(e||{}))f[l]=0;n.set(c,f)}const o=n.get(c);for(const[f,[l,m]]of Object.entries(e||{}))l==="count"?o[f]=u(o[f])+1:o[f]=u(o[f])+u(s[m||f])}return Array.from(n.values())},leftJoin(r,t,e,a=e){const n=new Map(t.map(s=>[s[a],s]));return r.map(s=>({...s,...n.get(s[e])||{}}))},monthKey(r){return String(r??"").slice(0,7)},quarterKey(r){const t=String(r??""),e=t.slice(0,4),a=Number(t.slice(5,7));return!e||!a?"":`${e}-Q${Math.floor((a+2)/3)}`},yearKey(r){return String(r??"").slice(0,4)},pivot(r,t,e,a){const n=new Map;for(const s of r){const i=String(s[t]??"—"),c=String(s[e]??"—");n.has(i)||n.set(i,{[t]:i});const o=n.get(i);o[c]=u(o[c])+u(s[a])}return Array.from(n.values())}};function y(r){if(!r||typeof r!="object")throw new Error("Transform must return an object");if(r.tables&&!Array.isArray(r.tables))throw new Error("tables must be an array");if(r.charts&&!Array.isArray(r.charts))throw new Error("charts must be an array");if(r.kpis&&!Array.isArray(r.kpis))throw new Error("kpis must be an array");return r}self.onmessage=r=>{try{const t=Object.fromEntries(r.data.datasets.map(s=>[s.name,s.rows])),e=r.data.datasets.map(s=>s.name).filter(s=>/^[$A-Z_][0-9A-Z_$]*$/i.test(s)).map(s=>`const ${s} = datasets[${JSON.stringify(s)}];`).join(`\n`),n=new Function("datasets","params","helpers",`"use strict";\n${e}\n${r.data.transformJs}`)(t,r.data.params||{},p);self.postMessage({ok:!0,output:y(n)})}catch(t){self.postMessage({ok:!1,error:t instanceof Error?t.message:String(t)})}}})();\n//# sourceMappingURL=report-runtime.worker-DrBTCfV6.js.map\n', Rn = typeof self < "u" && self.Blob && new Blob([ua], { type: "text/javascript;charset=utf-8" });
4683
+ const pa = '(function(){"use strict";function u(r,t){const e=Number(r??0)||0;return t==null?e:Number(e.toFixed(t))}const p={flt:u,sum(r,t){return r.reduce((e,a)=>typeof t=="function"?e+u(t(a)):typeof t=="string"?e+u(a[t]):e+u(a),0)},count(r){return r.length},sortBy(r,t,e="asc"){const n=(e===!0?"desc":e===!1?"asc":e)==="desc"?-1:1;return[...r].sort((s,i)=>{const c=s[t],o=i[t];return c==null&&o==null?0:c==null?1:o==null?-1:c<o?-1*n:c>o?1*n:0})},topN(r,t,e=10){return typeof t=="number"?r.slice(0,t):p.sortBy(r,t,"desc").slice(0,e)},group(r,t,e){if(typeof t=="function"){const s=new Map;for(const i of r){const c=t(i),o=JSON.stringify(c);s.has(o)||s.set(o,{key:c,rows:[]}),s.get(o).rows.push(i)}return Array.from(s.values())}const a=t,n=new Map;for(const s of r){const i=a.map(f=>s[f]),c=JSON.stringify(i);if(!n.has(c)){const f={};a.forEach((l,m)=>{f[l]=i[m]});for(const[l,[m]]of Object.entries(e||{}))f[l]=0;n.set(c,f)}const o=n.get(c);for(const[f,[l,m]]of Object.entries(e||{}))l==="count"?o[f]=u(o[f])+1:o[f]=u(o[f])+u(s[m||f])}return Array.from(n.values())},leftJoin(r,t,e,a=e){const n=new Map(t.map(s=>[s[a],s]));return r.map(s=>({...s,...n.get(s[e])||{}}))},monthKey(r){return String(r??"").slice(0,7)},quarterKey(r){const t=String(r??""),e=t.slice(0,4),a=Number(t.slice(5,7));return!e||!a?"":`${e}-Q${Math.floor((a+2)/3)}`},yearKey(r){return String(r??"").slice(0,4)},pivot(r,t,e,a){const n=new Map;for(const s of r){const i=String(s[t]??"—"),c=String(s[e]??"—");n.has(i)||n.set(i,{[t]:i});const o=n.get(i);o[c]=u(o[c])+u(s[a])}return Array.from(n.values())}};function y(r){if(!r||typeof r!="object")throw new Error("Transform must return an object");if(r.tables&&!Array.isArray(r.tables))throw new Error("tables must be an array");if(r.charts&&!Array.isArray(r.charts))throw new Error("charts must be an array");if(r.kpis&&!Array.isArray(r.kpis))throw new Error("kpis must be an array");return r}self.onmessage=r=>{try{const t=Object.fromEntries(r.data.datasets.map(s=>[s.name,s.rows])),e=r.data.datasets.map(s=>s.name).filter(s=>/^[$A-Z_][0-9A-Z_$]*$/i.test(s)).map(s=>`const ${s} = datasets[${JSON.stringify(s)}];`).join(`\n`),n=new Function("datasets","params","helpers",`"use strict";\n${e}\n${r.data.transformJs}`)(t,r.data.params||{},p);self.postMessage({ok:!0,output:y(n)})}catch(t){self.postMessage({ok:!1,error:t instanceof Error?t.message:String(t)})}}})();\n//# sourceMappingURL=report-runtime.worker-DrBTCfV6.js.map\n', Rn = typeof self < "u" && self.Blob && new Blob([pa], { type: "text/javascript;charset=utf-8" });
4673
4684
  function bs(t) {
4674
4685
  let n;
4675
4686
  try {
@@ -4682,7 +4693,7 @@ function bs(t) {
4682
4693
  }), a;
4683
4694
  } catch {
4684
4695
  return new Worker(
4685
- "data:text/javascript;charset=utf-8," + encodeURIComponent(ua),
4696
+ "data:text/javascript;charset=utf-8," + encodeURIComponent(pa),
4686
4697
  {
4687
4698
  name: t == null ? void 0 : t.name
4688
4699
  }
@@ -4762,9 +4773,9 @@ return {
4762
4773
  2
4763
4774
  );
4764
4775
  }
4765
- const ma = vs();
4776
+ const ha = vs();
4766
4777
  function xs() {
4767
- const t = Ie(), { sessions: n, createSession: a } = mt(), [s] = se("report_id", ""), [i] = se("metric", ""), [o] = se("group_by", ""), [l] = se("from", ""), [c] = se("to", ""), [g] = se("company", ""), [m, p] = S(ma), [u, w] = S([]), [b, N] = S(null), [y, T] = S(""), [A, x] = S(!1), [d, h] = S(!1), [P, v] = S(""), I = ee(null), C = ee(""), O = ee(""), G = ee(0), te = Ce(() => !i || !o ? "" : JSON.stringify(Ss({
4778
+ const t = Ie(), { sessions: n, createSession: a } = mt(), [s] = se("report_id", ""), [i] = se("metric", ""), [o] = se("group_by", ""), [l] = se("from", ""), [c] = se("to", ""), [g] = se("company", ""), [d, p] = S(ha), [m, w] = S([]), [x, N] = S(null), [y, D] = S(""), [A, b] = S(!1), [u, h] = S(!1), [_, v] = S(""), I = ee(null), C = ee(""), O = ee(""), G = ee(0), te = Ce(() => !i || !o ? "" : JSON.stringify(Ss({
4768
4779
  metric: i,
4769
4780
  groupBy: o,
4770
4781
  fromDate: l || void 0,
@@ -4773,20 +4784,20 @@ function xs() {
4773
4784
  }), null, 2), [i, o, l, c, g]), U = async (L) => {
4774
4785
  var ce;
4775
4786
  const Y = ++G.current, ne = () => G.current === Y;
4776
- T(""), x(!0);
4787
+ D(""), b(!0);
4777
4788
  try {
4778
- const _e = JSON.parse(L ?? m), he = await _.runtimeData({ requests: _e.data_requests || [] });
4789
+ const _e = JSON.parse(L ?? d), he = await T.runtimeData({ requests: _e.data_requests || [] });
4779
4790
  if (!ne()) return;
4780
4791
  w(he.datasets), (ce = I.current) == null || ce.terminate();
4781
4792
  const fe = new bs();
4782
4793
  I.current = fe;
4783
- const Ue = await new Promise((E, ae) => {
4794
+ const Ue = await new Promise((E, re) => {
4784
4795
  const Be = window.setTimeout(() => {
4785
- fe.terminate(), ae(new Error("Report runtime exceeded 4 seconds"));
4796
+ fe.terminate(), re(new Error("Report runtime exceeded 4 seconds"));
4786
4797
  }, 4e3);
4787
4798
  fe.onmessage = (De) => {
4788
4799
  var Ve, Me;
4789
- window.clearTimeout(Be), fe.terminate(), I.current === fe && (I.current = null), (Ve = De.data) != null && Ve.ok ? E(De.data.output) : ae(new Error(((Me = De.data) == null ? void 0 : Me.error) || "Runtime failed"));
4800
+ window.clearTimeout(Be), fe.terminate(), I.current === fe && (I.current = null), (Ve = De.data) != null && Ve.ok ? E(De.data.output) : re(new Error(((Me = De.data) == null ? void 0 : Me.error) || "Runtime failed"));
4790
4801
  }, fe.postMessage({
4791
4802
  datasets: he.datasets,
4792
4803
  params: {},
@@ -4797,19 +4808,19 @@ function xs() {
4797
4808
  N(Ue);
4798
4809
  } catch (de) {
4799
4810
  if (!ne()) return;
4800
- N(null), T(de instanceof Error ? de.message : String(de));
4811
+ N(null), D(de instanceof Error ? de.message : String(de));
4801
4812
  } finally {
4802
- ne() && x(!1);
4813
+ ne() && b(!1);
4803
4814
  }
4804
4815
  };
4805
- re(() => {
4816
+ ae(() => {
4806
4817
  let L = !1;
4807
- return s ? C.current === s ? void 0 : (h(!0), T(""), _.getRuntimeDraft(s).then((Y) => {
4818
+ return s ? C.current === s ? void 0 : (h(!0), D(""), T.getRuntimeDraft(s).then((Y) => {
4808
4819
  if (L) return;
4809
4820
  const ne = JSON.stringify(Y.definition, null, 2);
4810
4821
  return C.current = s, O.current = ne, v(Y.source_chat_session_id || ""), p(ne), U(ne);
4811
4822
  }).catch((Y) => {
4812
- L || (N(null), T(Y instanceof Error ? Y.message : String(Y)));
4823
+ L || (N(null), D(Y instanceof Error ? Y.message : String(Y)));
4813
4824
  }).finally(() => {
4814
4825
  L || h(!1);
4815
4826
  }), () => {
@@ -4818,9 +4829,9 @@ function xs() {
4818
4829
  L = !0;
4819
4830
  });
4820
4831
  }, [s, te]);
4821
- const f = !!(!s && te), q = Ce(() => ks(b), [b]), D = async () => {
4832
+ const f = !!(!s && te), q = Ce(() => ks(x), [x]), P = async () => {
4822
4833
  var he;
4823
- const L = m.trim() !== O.current.trim(), Y = s || "unsaved-runtime-report", ne = u.map((fe) => ({
4834
+ const L = d.trim() !== O.current.trim(), Y = s || "unsaved-runtime-report", ne = m.map((fe) => ({
4824
4835
  name: fe.name,
4825
4836
  dataset: fe.dataset,
4826
4837
  row_count: fe.row_count,
@@ -4838,7 +4849,7 @@ function xs() {
4838
4849
  "",
4839
4850
  "The analytics editor contains unsaved local changes. Use this JSON as the source of truth when repairing the draft:",
4840
4851
  "```json",
4841
- m,
4852
+ d,
4842
4853
  "```"
4843
4854
  ) : ce.push(
4844
4855
  "",
@@ -4852,7 +4863,7 @@ function xs() {
4852
4863
  );
4853
4864
  const de = ce.join(`
4854
4865
  `);
4855
- let _e = P;
4866
+ let _e = _;
4856
4867
  _e || (_e = ((he = n[0]) == null ? void 0 : he.id) || ""), _e || (_e = (await a()).id), t(`/chat/${_e}`, { state: { prefillMessage: de } });
4857
4868
  };
4858
4869
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
@@ -4866,12 +4877,12 @@ function xs() {
4866
4877
  "Loaded draft: ",
4867
4878
  s
4868
4879
  ] }) : f ? /* @__PURE__ */ e("div", { className: "text-xs text-gray-500", children: "Loaded runtime report from legacy URL filters." }) : null,
4869
- s ? /* @__PURE__ */ e(H, { variant: "secondary", onClick: () => void D(), children: "Fix In Chat" }) : null,
4880
+ s ? /* @__PURE__ */ e(H, { variant: "secondary", onClick: () => void P(), children: "Fix In Chat" }) : null,
4870
4881
  /* @__PURE__ */ e(H, { onClick: () => void U(), disabled: A, children: A ? "Running..." : "Run Report" })
4871
4882
  ] })
4872
4883
  ] }) }),
4873
- d ? /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e("p", { className: "text-sm text-gray-600", children: "Loading draft..." }) }) : y ? /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e("p", { className: "text-sm text-red-600", children: y }) }) : b ? /* @__PURE__ */ e(Ns, { output: b }) : /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e("p", { className: "text-sm text-gray-600", children: "Edit the runtime JSON below or open a draft from chat, then run the report." }) }),
4874
- u.length > 0 && /* @__PURE__ */ e(F, { title: "Fetched Datasets", children: /* @__PURE__ */ e("div", { className: "space-y-4", children: u.map((L) => /* @__PURE__ */ r("div", { className: "rounded-md border border-gray-200 p-4", children: [
4884
+ u ? /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e("p", { className: "text-sm text-gray-600", children: "Loading draft..." }) }) : y ? /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e("p", { className: "text-sm text-red-600", children: y }) }) : x ? /* @__PURE__ */ e(Ns, { output: x }) : /* @__PURE__ */ e(F, { children: /* @__PURE__ */ e("p", { className: "text-sm text-gray-600", children: "Edit the runtime JSON below or open a draft from chat, then run the report." }) }),
4885
+ m.length > 0 && /* @__PURE__ */ e(F, { title: "Fetched Datasets", children: /* @__PURE__ */ e("div", { className: "space-y-4", children: m.map((L) => /* @__PURE__ */ r("div", { className: "rounded-md border border-gray-200 p-4", children: [
4875
4886
  /* @__PURE__ */ r("div", { className: "flex items-baseline justify-between gap-4", children: [
4876
4887
  /* @__PURE__ */ r("div", { children: [
4877
4888
  /* @__PURE__ */ e("div", { className: "font-medium text-gray-900", children: L.name }),
@@ -4891,7 +4902,7 @@ function xs() {
4891
4902
  "textarea",
4892
4903
  {
4893
4904
  className: "min-h-[520px] w-full rounded-md border border-gray-300 p-3 font-mono text-xs text-gray-900 outline-none focus:border-blue-500 focus:ring-1 focus:ring-blue-500",
4894
- value: m,
4905
+ value: d,
4895
4906
  onChange: (L) => p(L.target.value),
4896
4907
  spellCheck: !1
4897
4908
  }
@@ -4904,7 +4915,7 @@ function Ns({ output: t }) {
4904
4915
  const n = qe(), a = (t.tables ?? []).map((l, c) => ({
4905
4916
  ...l,
4906
4917
  id: l.id || `table_${c + 1}`
4907
- })), s = pa(a);
4918
+ })), s = ga(a);
4908
4919
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4909
4920
  /* @__PURE__ */ r(F, { children: [
4910
4921
  /* @__PURE__ */ e("div", { className: "flex items-baseline justify-between gap-4", children: /* @__PURE__ */ r("div", { children: [
@@ -4917,13 +4928,13 @@ function Ns({ output: t }) {
4917
4928
  ] }, `${l.label}-${c}`)) }) : null
4918
4929
  ] }),
4919
4930
  (o = t.charts) == null ? void 0 : o.map((l, c) => {
4920
- const g = l.dataTable ? s.get(l.dataTable) : void 0, m = l.data ?? (g == null ? void 0 : g.rows) ?? [];
4921
- if (!m.length)
4931
+ const g = l.dataTable ? s.get(l.dataTable) : void 0, d = l.data ?? (g == null ? void 0 : g.rows) ?? [];
4932
+ if (!d.length)
4922
4933
  return /* @__PURE__ */ e(F, { title: l.title, children: /* @__PURE__ */ e("p", { className: "text-sm text-red-600", children: "Chart has no usable data." }) }, l.id || `chart_${c + 1}`);
4923
- const p = l.type === "pie" ? [] : m.map((b) => String(b[l.x] ?? "")), u = Ps(p), w = Math.max(320, 200 + u.axisHeight);
4934
+ const p = l.type === "pie" ? [] : d.map((x) => String(x[l.x] ?? "")), m = Ps(p), w = Math.max(320, 200 + m.axisHeight);
4924
4935
  return /* @__PURE__ */ r(F, { children: [
4925
4936
  /* @__PURE__ */ e("div", { className: "pb-3 text-sm font-semibold text-gray-700", children: l.title }),
4926
- /* @__PURE__ */ e("div", { style: { height: w }, className: "w-full", children: /* @__PURE__ */ e(Ha, { width: "100%", height: "100%", children: l.type === "line" ? /* @__PURE__ */ r(Qa, { data: m, margin: { top: 10, right: 20, left: 0, bottom: 0 }, children: [
4937
+ /* @__PURE__ */ e("div", { style: { height: w }, className: "w-full", children: /* @__PURE__ */ e(Ya, { width: "100%", height: "100%", children: l.type === "line" ? /* @__PURE__ */ r(Ja, { data: d, margin: { top: 10, right: 20, left: 0, bottom: 0 }, children: [
4927
4938
  /* @__PURE__ */ e(pn, { strokeDasharray: "3 3", stroke: "#f3f4f6" }),
4928
4939
  /* @__PURE__ */ e(
4929
4940
  hn,
@@ -4931,18 +4942,18 @@ function Ns({ output: t }) {
4931
4942
  dataKey: l.x,
4932
4943
  tick: { fill: "#6b7280", fontSize: 12 },
4933
4944
  interval: 0,
4934
- angle: u.angle,
4935
- textAnchor: u.angle === 0 ? "middle" : "end",
4936
- height: u.axisHeight
4945
+ angle: m.angle,
4946
+ textAnchor: m.angle === 0 ? "middle" : "end",
4947
+ height: m.axisHeight
4937
4948
  }
4938
4949
  ),
4939
4950
  /* @__PURE__ */ e(gn, { tick: { fill: "#6b7280", fontSize: 12 }, tickFormatter: In }),
4940
- /* @__PURE__ */ e(Vt, { formatter: (b) => St(b, Wt(g, l.y), n) }),
4941
- /* @__PURE__ */ e(Ya, { type: "monotone", dataKey: l.y, stroke: "#3b82f6", strokeWidth: 2, dot: { r: 3 } })
4942
- ] }) : l.type === "pie" ? /* @__PURE__ */ r(Ja, { children: [
4943
- /* @__PURE__ */ e(Vt, { formatter: (b) => St(b, Wt(g, l.y), n) }),
4944
- /* @__PURE__ */ e(Za, { data: m, dataKey: l.y, nameKey: l.x, outerRadius: 110, children: m.map((b, N) => /* @__PURE__ */ e(Xa, { fill: Bn[N % Bn.length] }, N)) })
4945
- ] }) : /* @__PURE__ */ r(er, { data: m, margin: { top: 10, right: 20, left: 0, bottom: 0 }, children: [
4951
+ /* @__PURE__ */ e(Vt, { formatter: (x) => St(x, Wt(g, l.y), n) }),
4952
+ /* @__PURE__ */ e(Za, { type: "monotone", dataKey: l.y, stroke: "#3b82f6", strokeWidth: 2, dot: { r: 3 } })
4953
+ ] }) : l.type === "pie" ? /* @__PURE__ */ r(Xa, { children: [
4954
+ /* @__PURE__ */ e(Vt, { formatter: (x) => St(x, Wt(g, l.y), n) }),
4955
+ /* @__PURE__ */ e(er, { data: d, dataKey: l.y, nameKey: l.x, outerRadius: 110, children: d.map((x, N) => /* @__PURE__ */ e(tr, { fill: Bn[N % Bn.length] }, N)) })
4956
+ ] }) : /* @__PURE__ */ r(nr, { data: d, margin: { top: 10, right: 20, left: 0, bottom: 0 }, children: [
4946
4957
  /* @__PURE__ */ e(pn, { strokeDasharray: "3 3", stroke: "#f3f4f6" }),
4947
4958
  /* @__PURE__ */ e(
4948
4959
  hn,
@@ -4950,27 +4961,27 @@ function Ns({ output: t }) {
4950
4961
  dataKey: l.x,
4951
4962
  tick: { fill: "#6b7280", fontSize: 12 },
4952
4963
  interval: 0,
4953
- angle: u.angle,
4954
- textAnchor: u.angle === 0 ? "middle" : "end",
4955
- height: u.axisHeight
4964
+ angle: m.angle,
4965
+ textAnchor: m.angle === 0 ? "middle" : "end",
4966
+ height: m.axisHeight
4956
4967
  }
4957
4968
  ),
4958
4969
  /* @__PURE__ */ e(gn, { tick: { fill: "#6b7280", fontSize: 12 }, tickFormatter: In }),
4959
- /* @__PURE__ */ e(Vt, { formatter: (b) => St(b, Wt(g, l.y), n) }),
4960
- /* @__PURE__ */ e(tr, { dataKey: l.y, fill: "#3b82f6", radius: [4, 4, 0, 0] })
4970
+ /* @__PURE__ */ e(Vt, { formatter: (x) => St(x, Wt(g, l.y), n) }),
4971
+ /* @__PURE__ */ e(ar, { dataKey: l.y, fill: "#3b82f6", radius: [4, 4, 0, 0] })
4961
4972
  ] }) }) })
4962
4973
  ] }, l.id || `chart_${c + 1}`);
4963
4974
  }),
4964
4975
  a.map((l) => /* @__PURE__ */ e(F, { title: l.title, children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
4965
4976
  /* @__PURE__ */ e("thead", { className: "bg-gray-50", children: /* @__PURE__ */ e("tr", { children: l.columns.map((c) => /* @__PURE__ */ e("th", { className: "px-4 py-2 text-left font-medium text-gray-500", children: c.label }, c.key)) }) }),
4966
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: l.rows.map((c, g) => /* @__PURE__ */ e("tr", { className: "hover:bg-gray-50", children: l.columns.map((m) => /* @__PURE__ */ e("td", { className: "px-4 py-1.5 text-gray-900", children: St(c[m.key], m.type, n) }, m.key)) }, g)) })
4977
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: l.rows.map((c, g) => /* @__PURE__ */ e("tr", { className: "hover:bg-gray-50", children: l.columns.map((d) => /* @__PURE__ */ e("td", { className: "px-4 py-1.5 text-gray-900", children: St(c[d.key], d.type, n) }, d.key)) }, g)) })
4967
4978
  ] }) }) }, l.id))
4968
4979
  ] });
4969
4980
  }
4970
4981
  function ws(t) {
4971
4982
  return t.replace(/_/g, " ").replace(/\b\w/g, (n) => n.toUpperCase());
4972
4983
  }
4973
- function pa(t) {
4984
+ function ga(t) {
4974
4985
  const n = /* @__PURE__ */ new Map();
4975
4986
  for (const a of t)
4976
4987
  n.set(a.id, a), a.title && n.set(a.title, a);
@@ -4981,7 +4992,7 @@ function ks(t) {
4981
4992
  const n = (t.tables ?? []).map((i, o) => ({
4982
4993
  ...i,
4983
4994
  id: i.id || `table_${o + 1}`
4984
- })), a = pa(n), s = [];
4995
+ })), a = ga(n), s = [];
4985
4996
  for (const i of t.charts ?? []) {
4986
4997
  const o = i.dataTable ? a.get(i.dataTable) : void 0, l = i.data ?? (o == null ? void 0 : o.rows) ?? [];
4987
4998
  if (!l.length) {
@@ -5096,7 +5107,7 @@ function Ss(t) {
5096
5107
  },
5097
5108
  fields: [t.groupBy === "warehouse" ? "warehouse" : "item_code", "stock_value"],
5098
5109
  chartType: "bar"
5099
- }) : JSON.parse(ma);
5110
+ }) : JSON.parse(ha);
5100
5111
  }
5101
5112
  function bt(t) {
5102
5113
  const n = Object.fromEntries(Object.entries(t.filters).filter(([, s]) => s !== void 0)), a = ["month", "quarter", "year"].includes(t.groupBy) ? `${t.timeBucket}(row.${t.keyField})` : `row.${t.keyField} || "—"`;
@@ -5195,7 +5206,7 @@ const _s = ["USD", "EUR", "GBP", "CHF", "JPY", "CAD", "AUD", "CNY", "INR"];
5195
5206
  function Ts() {
5196
5207
  const t = We(), { data: n, isLoading: a } = ie({
5197
5208
  queryKey: ["setup-status"],
5198
- queryFn: () => _.setupStatus()
5209
+ queryFn: () => T.setupStatus()
5199
5210
  }), [s, i] = S(""), [o, l] = S("USD"), [c, g] = S({
5200
5211
  address: "",
5201
5212
  city: "",
@@ -5204,20 +5215,20 @@ function Ts() {
5204
5215
  email: "",
5205
5216
  phone: "",
5206
5217
  tax_id: ""
5207
- }), m = (v) => (I) => g((C) => ({ ...C, [v]: I.target.value })), [p, u] = S("quick"), [w, b] = S(!1), [N, y] = S(null), T = oe({
5208
- mutationFn: () => _.createCompany({ name: s, currency: o, ...c })
5218
+ }), d = (v) => (I) => g((C) => ({ ...C, [v]: I.target.value })), [p, m] = S("quick"), [w, x] = S(!1), [N, y] = S(null), D = oe({
5219
+ mutationFn: () => T.createCompany({ name: s, currency: o, ...c })
5209
5220
  }), A = oe({
5210
- mutationFn: () => _.seedDemo()
5211
- }), x = oe({
5212
- mutationFn: () => _.seedHistory()
5213
- }), d = async () => {
5221
+ mutationFn: () => T.seedDemo()
5222
+ }), b = oe({
5223
+ mutationFn: () => T.seedHistory()
5224
+ }), u = async () => {
5214
5225
  if (s.trim())
5215
5226
  try {
5216
- if (await T.mutateAsync(), p === "history") {
5217
- const v = await x.mutateAsync();
5227
+ if (await D.mutateAsync(), p === "history") {
5228
+ const v = await b.mutateAsync();
5218
5229
  y(v.stats);
5219
5230
  } else p === "quick" && await A.mutateAsync();
5220
- t.invalidateQueries({ queryKey: ["setup-status"] }), b(!0);
5231
+ t.invalidateQueries({ queryKey: ["setup-status"] }), x(!0);
5221
5232
  } catch {
5222
5233
  }
5223
5234
  };
@@ -5241,10 +5252,10 @@ function Ts() {
5241
5252
  ] }),
5242
5253
  /* @__PURE__ */ e("div", { className: "mt-6", children: /* @__PURE__ */ e(be, { to: "/", children: /* @__PURE__ */ e(H, { children: "Go to Dashboard" }) }) })
5243
5254
  ] }) }) });
5244
- const h = T.isPending || A.isPending || x.isPending, P = T.error ?? A.error ?? x.error;
5255
+ const h = D.isPending || A.isPending || b.isPending, _ = D.error ?? A.error ?? b.error;
5245
5256
  return /* @__PURE__ */ r("div", { className: "mx-auto max-w-lg space-y-6", children: [
5246
5257
  /* @__PURE__ */ e("p", { className: "text-sm text-gray-500", children: "Set up your first company to get started." }),
5247
- P && /* @__PURE__ */ e("div", { className: "rounded-md bg-red-50 p-4 text-sm text-red-700", children: P.message ?? "An error occurred during setup" }),
5258
+ _ && /* @__PURE__ */ e("div", { className: "rounded-md bg-red-50 p-4 text-sm text-red-700", children: _.message ?? "An error occurred during setup" }),
5248
5259
  /* @__PURE__ */ e(F, { children: /* @__PURE__ */ r("div", { className: "space-y-4", children: [
5249
5260
  /* @__PURE__ */ e(
5250
5261
  J,
@@ -5273,21 +5284,21 @@ function Ts() {
5273
5284
  {
5274
5285
  label: "Address",
5275
5286
  value: c.address,
5276
- onChange: m("address"),
5287
+ onChange: d("address"),
5277
5288
  placeholder: "e.g. 42 Market Street"
5278
5289
  }
5279
5290
  ),
5280
5291
  /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-3", children: [
5281
- /* @__PURE__ */ e(J, { label: "City", value: c.city, onChange: m("city") }),
5282
- /* @__PURE__ */ e(J, { label: "ZIP / Postal code", value: c.zip_code, onChange: m("zip_code") })
5292
+ /* @__PURE__ */ e(J, { label: "City", value: c.city, onChange: d("city") }),
5293
+ /* @__PURE__ */ e(J, { label: "ZIP / Postal code", value: c.zip_code, onChange: d("zip_code") })
5283
5294
  ] }),
5284
5295
  /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-3", children: [
5285
- /* @__PURE__ */ e(J, { label: "Country", value: c.country, onChange: m("country") }),
5286
- /* @__PURE__ */ e(J, { label: "Tax ID / VAT", value: c.tax_id, onChange: m("tax_id") })
5296
+ /* @__PURE__ */ e(J, { label: "Country", value: c.country, onChange: d("country") }),
5297
+ /* @__PURE__ */ e(J, { label: "Tax ID / VAT", value: c.tax_id, onChange: d("tax_id") })
5287
5298
  ] }),
5288
5299
  /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-3", children: [
5289
- /* @__PURE__ */ e(J, { label: "Email", value: c.email, onChange: m("email") }),
5290
- /* @__PURE__ */ e(J, { label: "Phone", value: c.phone, onChange: m("phone") })
5300
+ /* @__PURE__ */ e(J, { label: "Email", value: c.email, onChange: d("email") }),
5301
+ /* @__PURE__ */ e(J, { label: "Phone", value: c.phone, onChange: d("phone") })
5291
5302
  ] })
5292
5303
  ] }),
5293
5304
  /* @__PURE__ */ r("fieldset", { className: "space-y-2", children: [
@@ -5300,7 +5311,7 @@ function Ts() {
5300
5311
  name: "seed-mode",
5301
5312
  value: "quick",
5302
5313
  checked: p === "quick",
5303
- onChange: () => u("quick"),
5314
+ onChange: () => m("quick"),
5304
5315
  className: "mt-1"
5305
5316
  }
5306
5317
  ),
@@ -5317,7 +5328,7 @@ function Ts() {
5317
5328
  name: "seed-mode",
5318
5329
  value: "history",
5319
5330
  checked: p === "history",
5320
- onChange: () => u("history"),
5331
+ onChange: () => m("history"),
5321
5332
  className: "mt-1"
5322
5333
  }
5323
5334
  ),
@@ -5334,7 +5345,7 @@ function Ts() {
5334
5345
  name: "seed-mode",
5335
5346
  value: "none",
5336
5347
  checked: p === "none",
5337
- onChange: () => u("none"),
5348
+ onChange: () => m("none"),
5338
5349
  className: "mt-1"
5339
5350
  }
5340
5351
  ),
@@ -5347,7 +5358,7 @@ function Ts() {
5347
5358
  /* @__PURE__ */ e("div", { className: "pt-2", children: /* @__PURE__ */ e(
5348
5359
  H,
5349
5360
  {
5350
- onClick: d,
5361
+ onClick: u,
5351
5362
  disabled: h || !s.trim(),
5352
5363
  children: h ? p === "history" ? "Simulating three years..." : "Setting up..." : p === "history" ? "Create Company & Simulate History" : p === "quick" ? "Create Company & Seed Demo Data" : "Create Company"
5353
5364
  }
@@ -5533,7 +5544,7 @@ const Is = [
5533
5544
  ]
5534
5545
  }
5535
5546
  ];
5536
- function ha() {
5547
+ function fa() {
5537
5548
  const t = Ie(), { sessions: n, createSession: a } = mt();
5538
5549
  return async (s) => {
5539
5550
  var o;
@@ -5549,7 +5560,7 @@ function ha() {
5549
5560
  };
5550
5561
  }
5551
5562
  function Bs() {
5552
- const { t } = Z(), n = ha();
5563
+ const { t } = Z(), n = fa();
5553
5564
  return /* @__PURE__ */ e(F, { className: "border-emerald-200 bg-gradient-to-br from-emerald-50 to-white", children: /* @__PURE__ */ r("div", { className: "flex flex-col gap-4 md:flex-row md:items-start", children: [
5554
5565
  /* @__PURE__ */ e("div", { className: "flex h-10 w-10 shrink-0 items-center justify-center rounded-full bg-emerald-100 text-lg font-bold text-emerald-700", children: "▶" }),
5555
5566
  /* @__PURE__ */ r("div", { className: "flex-1 space-y-3", children: [
@@ -5585,7 +5596,7 @@ function Bs() {
5585
5596
  ] }) });
5586
5597
  }
5587
5598
  function Es() {
5588
- const { t } = Z(), n = ha(), a = [
5599
+ const { t } = Z(), n = fa(), a = [
5589
5600
  t("tutorial.caPrompt1"),
5590
5601
  t("tutorial.caPrompt2"),
5591
5602
  t("tutorial.caPrompt3"),
@@ -5879,8 +5890,8 @@ function Ln(t) {
5879
5890
  });
5880
5891
  }
5881
5892
  function On() {
5882
- const { t } = Z(), { sessionId: n } = ut(), a = Ie(), s = vt(), [i] = zt(), o = i.get("demo") === "1", [l, c] = S(""), [g, m] = S(""), [p, u] = S([]), [w, b] = S(""), [N, y] = S(!1), [T, A] = S("idle"), x = ee(null), d = ee(null), h = ee([]), {
5883
- connectionStatus: P,
5893
+ const { t } = Z(), { sessionId: n } = ut(), a = Ie(), s = vt(), [i] = zt(), o = i.get("demo") === "1", [l, c] = S(""), [g, d] = S(""), [p, m] = S([]), [w, x] = S(""), [N, y] = S(!1), [D, A] = S("idle"), b = ee(null), u = ee(null), h = ee([]), {
5894
+ connectionStatus: _,
5884
5895
  connectionVersion: v,
5885
5896
  createSession: I,
5886
5897
  startDemo: C,
@@ -5890,12 +5901,12 @@ function On() {
5890
5901
  sendMessage: U,
5891
5902
  transcribeAudio: f,
5892
5903
  getMessages: q,
5893
- hasMoreHistory: D,
5904
+ hasMoreHistory: P,
5894
5905
  isLoadingOlder: L,
5895
5906
  isThinking: Y,
5896
5907
  getDemoStatus: ne,
5897
5908
  getDemoTypingCue: ce
5898
- } = mt(), de = ee(null), _e = ee(null), he = ee(null), fe = ee(null), [Ue, E] = S(0), ae = ee(!1), Be = ee(null), De = ee(0), Ve = ee(!0), Me = ee(null), xt = ee(!1), pt = ee(null), Je = q(n), ke = P === "connected", Te = Y(n), Ke = ne(n), Qe = ce(n), Ee = o || Ke === "running", ht = D(n), it = L(n), gt = Je[Je.length - 1], R = gt ? `${gt.type}:${gt.timestamp || ""}:${gt.content}` : "empty", V = Pe(() => {
5909
+ } = mt(), de = ee(null), _e = ee(null), he = ee(null), fe = ee(null), [Ue, E] = S(0), re = ee(!1), Be = ee(null), De = ee(0), Ve = ee(!0), Me = ee(null), xt = ee(!1), pt = ee(null), Je = q(n), ke = _ === "connected", Te = Y(n), Ke = ne(n), Qe = ce(n), Ee = o || Ke === "running", ht = P(n), it = L(n), gt = Je[Je.length - 1], R = gt ? `${gt.type}:${gt.timestamp || ""}:${gt.content}` : "empty", V = Pe(() => {
5899
5910
  xt.current = !0, pt.current !== null && window.clearTimeout(pt.current), pt.current = window.setTimeout(() => {
5900
5911
  xt.current = !1, pt.current = null;
5901
5912
  }, 600);
@@ -5914,9 +5925,9 @@ function On() {
5914
5925
  if (!k || $ === null) return;
5915
5926
  const X = k.scrollHeight - $;
5916
5927
  X > 0 && (k.scrollTop = k.scrollTop + X), Me.current = null;
5917
- }, [Je.length]), re(() => {
5928
+ }, [Je.length]), ae(() => {
5918
5929
  Me.current === null && (!Ve.current && !Ee && !Te || W(Ee ? "auto" : "smooth"));
5919
- }, [R, Ee, Te, W]), re(() => {
5930
+ }, [R, Ee, Te, W]), ae(() => {
5920
5931
  const k = de.current;
5921
5932
  if (!k || typeof ResizeObserver > "u") return;
5922
5933
  let $ = 0;
@@ -5943,14 +5954,14 @@ function On() {
5943
5954
  Me.current = null;
5944
5955
  });
5945
5956
  }, [n, it, ht, te]), xe = ee(null);
5946
- re(() => {
5947
- m(""), Be.current = null, De.current += 1, n && sa(n);
5957
+ ae(() => {
5958
+ d(""), Be.current = null, De.current += 1, n && sa(n);
5948
5959
  const k = s.state;
5949
5960
  k != null && k.prefillMessage && xe.current !== k ? (xe.current = k, c(k.prefillMessage), window.setTimeout(() => {
5950
5961
  var $;
5951
5962
  return ($ = he.current) == null ? void 0 : $.focus();
5952
5963
  }, 50)) : k != null && k.prefillMessage || (xe.current = null, c(""));
5953
- }, [n, o, s.state]), re(() => {
5964
+ }, [n, o, s.state]), ae(() => {
5954
5965
  if (n || !ke) return;
5955
5966
  let k = !1;
5956
5967
  return I().then(($) => {
@@ -5961,35 +5972,35 @@ function On() {
5961
5972
  };
5962
5973
  }, [n, ke, a]);
5963
5974
  const Ae = ee(G);
5964
- re(() => {
5975
+ ae(() => {
5965
5976
  Ae.current = G;
5966
- }, [G]), re(() => {
5977
+ }, [G]), ae(() => {
5967
5978
  !n || !ke || o || Ke === "running" || Ae.current(n).catch(() => {
5968
5979
  });
5969
- }, [n, ke, v, o, Ke]), re(() => {
5970
- ae.current && !Te && ke && setTimeout(() => {
5980
+ }, [n, ke, v, o, Ke]), ae(() => {
5981
+ re.current && !Te && ke && setTimeout(() => {
5971
5982
  var k;
5972
5983
  return (k = he.current) == null ? void 0 : k.focus();
5973
- }, 50), ae.current = Te;
5984
+ }, 50), re.current = Te;
5974
5985
  }, [Te, ke]);
5975
5986
  function ot(k) {
5976
5987
  if (xt.current) return;
5977
5988
  const $ = k.currentTarget, X = $.scrollHeight - $.scrollTop - $.clientHeight;
5978
5989
  Ve.current = X < 80;
5979
5990
  }
5980
- re(() => {
5981
- !n || !ke || !o || Be.current !== n && (Be.current = n, m(""), C(n).catch((k) => {
5982
- Be.current = null, m(k instanceof Error ? k.message : t("chat.demoError"));
5991
+ ae(() => {
5992
+ !n || !ke || !o || Be.current !== n && (Be.current = n, d(""), C(n).catch((k) => {
5993
+ Be.current = null, d(k instanceof Error ? k.message : t("chat.demoError"));
5983
5994
  }));
5984
- }, [n, ke, o, C]), re(() => {
5995
+ }, [n, ke, o, C]), ae(() => {
5985
5996
  !n || !o || Ke !== "complete" || (c(""), a(`/chat/${n}`, { replace: !0 }));
5986
5997
  }, [n, o, Ke, a]);
5987
5998
  const K = ee(O);
5988
- re(() => {
5999
+ ae(() => {
5989
6000
  K.current = O;
5990
6001
  }, [O]);
5991
6002
  const Ze = ee(null);
5992
- re(() => {
6003
+ ae(() => {
5993
6004
  if (!Qe || !n || Ze.current === Qe.seq) return;
5994
6005
  Ze.current = Qe.seq;
5995
6006
  const k = n, $ = Qe.content, X = $.length > 0 ? Math.max(8, Qe.typingMs / $.length) : 0, ue = Qe.seq, ge = ++De.current;
@@ -6002,38 +6013,38 @@ function On() {
6002
6013
  ge === De.current && K.current(k, ue);
6003
6014
  }
6004
6015
  et();
6005
- }, [Qe, n]), re(() => {
6016
+ }, [Qe, n]), ae(() => {
6006
6017
  Ke === "complete" && (De.current += 1, c(""));
6007
6018
  }, [Ke]);
6008
6019
  const pe = Pe((k) => {
6009
6020
  if (!n) return;
6010
- b("");
6021
+ x("");
6011
6022
  const $ = Array.from(k);
6012
- u((X) => {
6023
+ m((X) => {
6013
6024
  const ue = [...X];
6014
6025
  for (const ge of $) {
6015
6026
  if (ue.length >= Qt) {
6016
- b(`Maximum ${Qt} attachments per message.`);
6027
+ x(`Maximum ${Qt} attachments per message.`);
6017
6028
  break;
6018
6029
  }
6019
6030
  if (!Ms.has(ge.type)) {
6020
- b(`Unsupported file type: ${ge.type || ge.name}`);
6031
+ x(`Unsupported file type: ${ge.type || ge.name}`);
6021
6032
  continue;
6022
6033
  }
6023
6034
  if (ge.size > zs) {
6024
- b(`"${ge.name}" is too large (max 10 MB).`);
6035
+ x(`"${ge.name}" is too large (max 10 MB).`);
6025
6036
  continue;
6026
6037
  }
6027
6038
  const et = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, yt = ge.type.startsWith("image/") ? URL.createObjectURL(ge) : void 0, je = { localId: et, file: ge, previewUrl: yt, uploading: !0 };
6028
- ue.push(je), _.uploadChatAttachment(n, ge).then((lt) => {
6029
- u(
6039
+ ue.push(je), T.uploadChatAttachment(n, ge).then((lt) => {
6040
+ m(
6030
6041
  (At) => At.map(
6031
6042
  (wt) => wt.localId === et ? { ...wt, uploading: !1, uploadedId: lt.id } : wt
6032
6043
  )
6033
6044
  );
6034
6045
  }).catch((lt) => {
6035
6046
  const At = (lt == null ? void 0 : lt.message) || "Upload failed";
6036
- b(`"${ge.name}": ${At}`), u(
6047
+ x(`"${ge.name}": ${At}`), m(
6037
6048
  (wt) => wt.map(
6038
6049
  (Ut) => Ut.localId === et ? { ...Ut, uploading: !1, error: At } : Ut
6039
6050
  )
@@ -6043,7 +6054,7 @@ function On() {
6043
6054
  return ue;
6044
6055
  });
6045
6056
  }, [n]), z = (k) => {
6046
- u(($) => {
6057
+ m(($) => {
6047
6058
  const X = $.find((ue) => ue.localId === k);
6048
6059
  return X != null && X.previewUrl && URL.revokeObjectURL(X.previewUrl), $.filter((ue) => ue.localId !== k);
6049
6060
  });
@@ -6068,7 +6079,7 @@ function On() {
6068
6079
  if (n && !(!k && me.length === 0) && !Ne && U(n, k, me.length > 0 ? me : void 0)) {
6069
6080
  for (const $ of p)
6070
6081
  $.previewUrl && URL.revokeObjectURL($.previewUrl);
6071
- u([]), b(""), c("");
6082
+ m([]), x(""), c("");
6072
6083
  }
6073
6084
  }
6074
6085
  function Nt(k) {
@@ -6081,24 +6092,24 @@ function On() {
6081
6092
  X && (X.focus(), X.style.height = "auto", X.style.height = Math.min(Math.max(X.scrollHeight, 48), 120) + "px");
6082
6093
  }, 0));
6083
6094
  }
6084
- async function wa() {
6085
- if (T !== "idle") return;
6095
+ async function Sa() {
6096
+ if (D !== "idle") return;
6086
6097
  let k;
6087
6098
  try {
6088
6099
  k = await navigator.mediaDevices.getUserMedia({ audio: !0 });
6089
6100
  } catch {
6090
- b(t("chat.micDenied"));
6101
+ x(t("chat.micDenied"));
6091
6102
  return;
6092
6103
  }
6093
- b("");
6104
+ x("");
6094
6105
  const $ = new MediaRecorder(k);
6095
- d.current = $, h.current = [], $.ondataavailable = (X) => {
6106
+ u.current = $, h.current = [], $.ondataavailable = (X) => {
6096
6107
  X.data.size > 0 && h.current.push(X.data);
6097
6108
  }, $.onstop = async () => {
6098
6109
  var yt;
6099
6110
  k.getTracks().forEach((je) => je.stop());
6100
6111
  const X = h.current;
6101
- if (h.current = [], d.current = null, X.length === 0) {
6112
+ if (h.current = [], u.current = null, X.length === 0) {
6102
6113
  A("idle");
6103
6114
  return;
6104
6115
  }
@@ -6108,18 +6119,18 @@ function On() {
6108
6119
  const je = await $s(ge), lt = await f(je, et, n);
6109
6120
  Xe(lt);
6110
6121
  } catch (je) {
6111
- b(je instanceof Error ? je.message : t("chat.transcribeFailed"));
6122
+ x(je instanceof Error ? je.message : t("chat.transcribeFailed"));
6112
6123
  } finally {
6113
6124
  A("idle");
6114
6125
  }
6115
6126
  }, $.start(), A("recording");
6116
6127
  }
6117
- function ka() {
6118
- const k = d.current;
6128
+ function Ca() {
6129
+ const k = u.current;
6119
6130
  k && k.state !== "inactive" && k.stop();
6120
6131
  }
6121
- function Sa() {
6122
- T === "recording" ? ka() : T === "idle" && wa();
6132
+ function Da() {
6133
+ D === "recording" ? Ca() : D === "idle" && Sa();
6123
6134
  }
6124
6135
  return n ? /* @__PURE__ */ r(
6125
6136
  "div",
@@ -6213,7 +6224,7 @@ function On() {
6213
6224
  /* @__PURE__ */ e(
6214
6225
  "input",
6215
6226
  {
6216
- ref: x,
6227
+ ref: b,
6217
6228
  type: "file",
6218
6229
  accept: "image/png,image/jpeg,image/gif,image/webp,application/pdf",
6219
6230
  multiple: !0,
@@ -6248,7 +6259,7 @@ function On() {
6248
6259
  {
6249
6260
  onClick: () => {
6250
6261
  var k;
6251
- return (k = x.current) == null ? void 0 : k.click();
6262
+ return (k = b.current) == null ? void 0 : k.click();
6252
6263
  },
6253
6264
  disabled: !ke || !n || Te || Ee || p.length >= Qt,
6254
6265
  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",
@@ -6259,11 +6270,11 @@ function On() {
6259
6270
  /* @__PURE__ */ e(
6260
6271
  "button",
6261
6272
  {
6262
- onClick: Sa,
6263
- disabled: !ke || !n || Te || Ee || T === "transcribing",
6264
- 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 ${T === "recording" ? "bg-rose-500/10 text-rose-600 hover:bg-rose-500/20" : "text-fg-muted hover:bg-surface-subtle hover:text-fg"}`,
6265
- title: t(T === "recording" ? "chat.voiceStop" : T === "transcribing" ? "chat.voiceTranscribing" : "chat.voiceStart"),
6266
- children: T === "transcribing" ? /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "animate-spin", children: /* @__PURE__ */ e("path", { d: "M21 12a9 9 0 11-6.219-8.56", strokeLinecap: "round" }) }) : T === "recording" ? /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", width: "18", height: "18", fill: "currentColor", className: "animate-pulse", children: /* @__PURE__ */ e("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: [
6273
+ onClick: Da,
6274
+ disabled: !ke || !n || Te || Ee || D === "transcribing",
6275
+ 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 ${D === "recording" ? "bg-rose-500/10 text-rose-600 hover:bg-rose-500/20" : "text-fg-muted hover:bg-surface-subtle hover:text-fg"}`,
6276
+ title: t(D === "recording" ? "chat.voiceStop" : D === "transcribing" ? "chat.voiceTranscribing" : "chat.voiceStart"),
6277
+ children: D === "transcribing" ? /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", width: "20", height: "20", fill: "none", stroke: "currentColor", strokeWidth: "2", className: "animate-spin", children: /* @__PURE__ */ e("path", { d: "M21 12a9 9 0 11-6.219-8.56", strokeLinecap: "round" }) }) : D === "recording" ? /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", width: "18", height: "18", fill: "currentColor", className: "animate-pulse", children: /* @__PURE__ */ e("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: [
6267
6278
  /* @__PURE__ */ e("path", { d: "M12 1a3 3 0 00-3 3v8a3 3 0 006 0V4a3 3 0 00-3-3z" }),
6268
6279
  /* @__PURE__ */ e("path", { d: "M19 10v2a7 7 0 01-14 0v-2" }),
6269
6280
  /* @__PURE__ */ e("line", { x1: "12", y1: "19", x2: "12", y2: "23" }),
@@ -6297,7 +6308,7 @@ function On() {
6297
6308
  className: `inline-block h-1.5 w-1.5 rounded-full ${ke ? "bg-emerald-500" : "bg-rose-500"} ${ke ? "" : "animate-pulse"}`
6298
6309
  }
6299
6310
  ),
6300
- /* @__PURE__ */ e("span", { className: "text-[11px] text-fg-muted", children: ke ? "Connected" : P === "connecting" ? "Connecting..." : "Disconnected" })
6311
+ /* @__PURE__ */ e("span", { className: "text-[11px] text-fg-muted", children: ke ? "Connected" : _ === "connecting" ? "Connecting..." : "Disconnected" })
6301
6312
  ] })
6302
6313
  ] })
6303
6314
  }
@@ -6308,7 +6319,7 @@ function On() {
6308
6319
  }
6309
6320
  function Us({ attachments: t }) {
6310
6321
  return !t || t.length === 0 ? null : /* @__PURE__ */ e("div", { className: "mt-1 flex flex-wrap gap-1.5", children: t.map((n) => {
6311
- const a = _.getChatAttachmentUrl(n.id), s = n.mime_type.startsWith("image/");
6322
+ const a = T.getChatAttachmentUrl(n.id), s = n.mime_type.startsWith("image/");
6312
6323
  return /* @__PURE__ */ r(
6313
6324
  "a",
6314
6325
  {
@@ -6416,7 +6427,7 @@ function Ks({ content: t }) {
6416
6427
  );
6417
6428
  }), /* @__PURE__ */ e("div", { children: a });
6418
6429
  }
6419
- function ga(t, n, a) {
6430
+ function ya(t, n, a) {
6420
6431
  const s = t.startsWith("/") && !t.startsWith("/api/"), i = "font-medium text-brand underline decoration-brand/40 underline-offset-2 transition-colors hover:decoration-brand";
6421
6432
  return s ? /* @__PURE__ */ e(be, { to: t, className: i, children: n }, a) : /* @__PURE__ */ e(
6422
6433
  "a",
@@ -6436,7 +6447,7 @@ function Ot(t) {
6436
6447
  const i = a.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
6437
6448
  if (i) {
6438
6449
  const [, o, l] = i;
6439
- return ga(l, Ot(o), s);
6450
+ return ya(l, Ot(o), s);
6440
6451
  }
6441
6452
  return a.startsWith("**") && a.endsWith("**") && a.length > 4 ? /* @__PURE__ */ e("strong", { className: "font-semibold", children: Ot(a.slice(2, -2)) }, s) : a.startsWith("`") && a.endsWith("`") ? /* @__PURE__ */ e(
6442
6453
  "code",
@@ -6455,52 +6466,52 @@ function Gs(t, n) {
6455
6466
  let l = 0;
6456
6467
  for (; (i = o.exec(t)) !== null; ) {
6457
6468
  const c = i.index;
6458
- let g = i[0], m = "";
6469
+ let g = i[0], d = "";
6459
6470
  for (; g.length > 0 && /[.,;:!?]$/.test(g); )
6460
- m = g.slice(-1) + m, g = g.slice(0, -1);
6461
- c > s && a.push(t.slice(s, c)), a.push(ga(g, g, `${n}-u${l}`)), m && a.push(m), s = c + i[0].length, l += 1;
6471
+ d = g.slice(-1) + d, g = g.slice(0, -1);
6472
+ c > s && a.push(t.slice(s, c)), a.push(ya(g, g, `${n}-u${l}`)), d && a.push(d), s = c + i[0].length, l += 1;
6462
6473
  }
6463
6474
  return s < t.length && a.push(t.slice(s)), a.length > 0 ? a : [t];
6464
6475
  }
6465
6476
  function Ws() {
6466
- const t = Ie(), [n] = zt(), { user: a, login: s, register: i } = st(), { t: o } = Z(), l = n.get("invite") || "", [c, g] = S(l ? "register" : "login"), [m, p] = S(!1), [u, w] = S(!1), [b, N] = S([]), [y, T] = S(!0), [A, x] = S(""), [d, h] = S(""), [P, v] = S(""), [I, C] = S(""), [O, G] = S("");
6467
- re(() => {
6477
+ const t = Ie(), [n] = zt(), { user: a, login: s, register: i } = st(), { t: o } = Z(), l = n.get("invite") || "", [c, g] = S(l ? "register" : "login"), [d, p] = S(!1), [m, w] = S(!1), [x, N] = S([]), [y, D] = S(!0), [A, b] = S(""), [u, h] = S(""), [_, v] = S(""), [I, C] = S(""), [O, G] = S("");
6478
+ ae(() => {
6468
6479
  a && a.role !== "public_manager" && t("/", { replace: !0 });
6469
- }, [a, t]), re(() => {
6470
- _.authSetupStatus().then((U) => {
6480
+ }, [a, t]), ae(() => {
6481
+ T.authSetupStatus().then((U) => {
6471
6482
  p(U.registration_open), w(U.first_run), N(U.oauth_providers ?? []), U.first_run && g("register");
6472
6483
  }).catch(() => {
6473
- }).finally(() => T(!1));
6474
- }, []), re(() => {
6484
+ }).finally(() => D(!1));
6485
+ }, []), ae(() => {
6475
6486
  const U = n.get("oauth_error");
6476
- U && x(o(`login.oauthError.${U}`, { defaultValue: o("login.oauthError.generic") }));
6487
+ U && b(o(`login.oauthError.${U}`, { defaultValue: o("login.oauthError.generic") }));
6477
6488
  }, [n, o]);
6478
6489
  const te = async (U) => {
6479
- if (U.preventDefault(), x(""), c === "register") {
6490
+ if (U.preventDefault(), b(""), c === "register") {
6480
6491
  if (I !== O) {
6481
- x(o("login.passwordsNoMatch"));
6492
+ b(o("login.passwordsNoMatch"));
6482
6493
  return;
6483
6494
  }
6484
6495
  if (I.length < 6) {
6485
- x(o("login.passwordTooShort"));
6496
+ b(o("login.passwordTooShort"));
6486
6497
  return;
6487
6498
  }
6488
6499
  try {
6489
- await i(d, P, I, l || void 0), t("/", { replace: !0 });
6500
+ await i(u, _, I, l || void 0), t("/", { replace: !0 });
6490
6501
  } catch (f) {
6491
- x(f instanceof $e ? f.message : o("login.registrationFailed"));
6502
+ b(f instanceof $e ? f.message : o("login.registrationFailed"));
6492
6503
  }
6493
6504
  } else
6494
6505
  try {
6495
- await s(d, I), t("/", { replace: !0 });
6506
+ await s(u, I), t("/", { replace: !0 });
6496
6507
  } catch (f) {
6497
- x(f instanceof $e ? f.message : o("login.loginFailed"));
6508
+ b(f instanceof $e ? f.message : o("login.loginFailed"));
6498
6509
  }
6499
6510
  };
6500
6511
  return y ? /* @__PURE__ */ e("div", { className: "flex h-dvh items-center justify-center bg-surface-muted", children: /* @__PURE__ */ e("div", { className: "text-fg-muted", children: o("common.loading") }) }) : /* @__PURE__ */ e("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: [
6501
6512
  /* @__PURE__ */ r("div", { className: "text-center", children: [
6502
6513
  /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-brand", children: "Lambda ERP" }),
6503
- /* @__PURE__ */ e("p", { className: "mt-1 text-sm text-fg-muted", children: o(u ? "login.taglineFirstRun" : c === "register" ? "login.taglineRegister" : "login.taglineSignIn") }),
6514
+ /* @__PURE__ */ e("p", { className: "mt-1 text-sm text-fg-muted", children: o(m ? "login.taglineFirstRun" : c === "register" ? "login.taglineRegister" : "login.taglineSignIn") }),
6504
6515
  (a == null ? void 0 : a.role) === "public_manager" && /* @__PURE__ */ e("p", { className: "mt-2 text-xs text-amber-700", children: o("login.demoBanner") })
6505
6516
  ] }),
6506
6517
  A && /* @__PURE__ */ e("div", { className: "rounded-lg bg-rose-50 px-4 py-3 text-sm text-rose-700 ring-1 ring-rose-200", children: A }),
@@ -6510,7 +6521,7 @@ function Ws() {
6510
6521
  J,
6511
6522
  {
6512
6523
  label: o("login.fullName"),
6513
- value: P,
6524
+ value: _,
6514
6525
  onChange: (U) => v(U.target.value),
6515
6526
  required: !0
6516
6527
  }
@@ -6520,7 +6531,7 @@ function Ws() {
6520
6531
  {
6521
6532
  label: o("login.email"),
6522
6533
  type: "email",
6523
- value: d,
6534
+ value: u,
6524
6535
  onChange: (U) => h(U.target.value),
6525
6536
  required: !0
6526
6537
  }
@@ -6545,20 +6556,20 @@ function Ws() {
6545
6556
  required: !0
6546
6557
  }
6547
6558
  ),
6548
- /* @__PURE__ */ e(H, { type: "submit", className: "w-full", children: o(c === "register" ? u ? "login.createAdmin" : "login.register" : "login.signIn") })
6559
+ /* @__PURE__ */ e(H, { type: "submit", className: "w-full", children: o(c === "register" ? m ? "login.createAdmin" : "login.register" : "login.signIn") })
6549
6560
  ] }),
6550
- b.length > 0 && /* @__PURE__ */ r("div", { className: "mt-4 space-y-3", children: [
6561
+ x.length > 0 && /* @__PURE__ */ r("div", { className: "mt-4 space-y-3", children: [
6551
6562
  /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
6552
6563
  /* @__PURE__ */ e("div", { className: "h-px flex-1 bg-border" }),
6553
6564
  /* @__PURE__ */ e("span", { className: "text-xs uppercase tracking-wide text-fg-muted", children: o("login.orContinueWith") }),
6554
6565
  /* @__PURE__ */ e("div", { className: "h-px flex-1 bg-border" })
6555
6566
  ] }),
6556
- /* @__PURE__ */ e("div", { className: "space-y-2", children: b.map((U) => /* @__PURE__ */ r(
6567
+ /* @__PURE__ */ e("div", { className: "space-y-2", children: x.map((U) => /* @__PURE__ */ r(
6557
6568
  "button",
6558
6569
  {
6559
6570
  type: "button",
6560
6571
  onClick: () => {
6561
- window.location.href = _.oauthLoginUrl(U, { invite: l || void 0 });
6572
+ window.location.href = T.oauthLoginUrl(U, { invite: l || void 0 });
6562
6573
  },
6563
6574
  className: "flex w-full items-center justify-center gap-2 rounded-lg border border-border bg-surface px-4 py-2 text-sm font-medium text-fg transition-colors hover:bg-surface-muted",
6564
6575
  children: [
@@ -6585,7 +6596,7 @@ function Ws() {
6585
6596
  }
6586
6597
  )
6587
6598
  ] }) }),
6588
- !u && !l && m && /* @__PURE__ */ e("p", { className: "text-center text-sm text-fg-muted", children: c === "login" ? /* @__PURE__ */ r(we, { children: [
6599
+ !m && !l && d && /* @__PURE__ */ e("p", { className: "text-center text-sm text-fg-muted", children: c === "login" ? /* @__PURE__ */ r(we, { children: [
6589
6600
  o("login.noAccountPrompt"),
6590
6601
  " ",
6591
6602
  /* @__PURE__ */ e("button", { onClick: () => g("register"), className: "font-medium text-brand transition-colors hover:text-brand/80", children: o("login.registerLink") })
@@ -6609,8 +6620,8 @@ function Qs({ provider: t }) {
6609
6620
  }
6610
6621
  function Ys() {
6611
6622
  const t = Ie(), n = ee(!1), [a, s] = S("");
6612
- return re(() => {
6613
- n.current || (n.current = !0, _.createChatSession().then((i) => {
6623
+ return ae(() => {
6624
+ n.current || (n.current = !0, T.createChatSession().then((i) => {
6614
6625
  t(`/chat/${i.id}?demo=1`, { replace: !0 });
6615
6626
  }).catch((i) => {
6616
6627
  s(i instanceof $e ? i.message : "Could not start demo");
@@ -6640,8 +6651,8 @@ function Mn() {
6640
6651
  return { type: "sales", party: "", amount: "", due_date: "", remarks: "" };
6641
6652
  }
6642
6653
  function Js() {
6643
- const t = Ie(), n = We(), [a, s] = S(""), [i, o] = S((/* @__PURE__ */ new Date()).toISOString().split("T")[0]), [l, c] = S(""), [g, m] = S([qn()]), [p, u] = S([zn()]), [w, b] = S([Mn()]), [N, y] = S({}), T = oe({
6644
- mutationFn: () => _.importAccountBalances({
6654
+ const t = Ie(), n = We(), [a, s] = S(""), [i, o] = S((/* @__PURE__ */ new Date()).toISOString().split("T")[0]), [l, c] = S(""), [g, d] = S([qn()]), [p, m] = S([zn()]), [w, x] = S([Mn()]), [N, y] = S({}), D = oe({
6655
+ mutationFn: () => T.importAccountBalances({
6645
6656
  company: a,
6646
6657
  posting_date: i,
6647
6658
  entries: g.filter((h) => h.account && (h.debit || h.credit)).map((h) => ({
@@ -6652,9 +6663,9 @@ function Js() {
6652
6663
  party: h.party || void 0
6653
6664
  }))
6654
6665
  }),
6655
- onSuccess: (h) => y((P) => ({ ...P, accounts: h }))
6666
+ onSuccess: (h) => y((_) => ({ ..._, accounts: h }))
6656
6667
  }), A = oe({
6657
- mutationFn: () => _.importStockBalances({
6668
+ mutationFn: () => T.importStockBalances({
6658
6669
  company: a,
6659
6670
  posting_date: i,
6660
6671
  warehouse: l,
@@ -6664,9 +6675,9 @@ function Js() {
6664
6675
  rate: parseFloat(h.rate) || 0
6665
6676
  }))
6666
6677
  }),
6667
- onSuccess: (h) => y((P) => ({ ...P, stock: h }))
6668
- }), x = oe({
6669
- mutationFn: () => _.importOutstandingInvoices({
6678
+ onSuccess: (h) => y((_) => ({ ..._, stock: h }))
6679
+ }), b = oe({
6680
+ mutationFn: () => T.importOutstandingInvoices({
6670
6681
  company: a,
6671
6682
  invoices: w.filter((h) => h.party && h.amount).map((h) => ({
6672
6683
  type: h.type,
@@ -6677,11 +6688,11 @@ function Js() {
6677
6688
  posting_date: i
6678
6689
  }))
6679
6690
  }),
6680
- onSuccess: (h) => y((P) => ({ ...P, invoices: h }))
6691
+ onSuccess: (h) => y((_) => ({ ..._, invoices: h }))
6681
6692
  });
6682
- function d(h, P, v, I, C) {
6693
+ function u(h, _, v, I, C) {
6683
6694
  const O = [...h];
6684
- O[v][I] = C, P(O);
6695
+ O[v][I] = C, _(O);
6685
6696
  }
6686
6697
  return /* @__PURE__ */ r("div", { className: "space-y-6", children: [
6687
6698
  /* @__PURE__ */ e("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." }),
@@ -6699,22 +6710,22 @@ function Js() {
6699
6710
  /* @__PURE__ */ e("th", { className: "px-2 py-2 text-right font-medium text-gray-500", children: "Debit" }),
6700
6711
  /* @__PURE__ */ e("th", { className: "px-2 py-2 text-right font-medium text-gray-500", children: "Credit" })
6701
6712
  ] }) }),
6702
- /* @__PURE__ */ e("tbody", { children: g.map((h, P) => /* @__PURE__ */ r("tr", { children: [
6703
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e(Se, { value: h.account, onChange: (v) => d(g, m, P, "account", v), linkDoctype: "account", readOnly: !1, label: "" }) }),
6704
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ r("select", { value: h.party_type, onChange: (v) => d(g, m, P, "party_type", v.target.value), className: "w-full rounded border border-gray-300 px-2 py-1.5 text-sm", children: [
6713
+ /* @__PURE__ */ e("tbody", { children: g.map((h, _) => /* @__PURE__ */ r("tr", { children: [
6714
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e(Se, { value: h.account, onChange: (v) => u(g, d, _, "account", v), linkDoctype: "account", readOnly: !1, label: "" }) }),
6715
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ r("select", { value: h.party_type, onChange: (v) => u(g, d, _, "party_type", v.target.value), className: "w-full rounded border border-gray-300 px-2 py-1.5 text-sm", children: [
6705
6716
  /* @__PURE__ */ e("option", { value: "", children: "—" }),
6706
6717
  /* @__PURE__ */ e("option", { value: "Customer", children: "Customer" }),
6707
6718
  /* @__PURE__ */ e("option", { value: "Supplier", children: "Supplier" })
6708
6719
  ] }) }),
6709
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: h.party_type ? /* @__PURE__ */ e(Se, { label: "", value: h.party, onChange: (v) => d(g, m, P, "party", v), linkDoctype: h.party_type.toLowerCase(), readOnly: !1 }) : /* @__PURE__ */ e("span", { className: "text-gray-300 text-xs", children: "set party type first" }) }),
6710
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.debit, onChange: (v) => d(g, m, P, "debit", v.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) }),
6711
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.credit, onChange: (v) => d(g, m, P, "credit", v.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) })
6712
- ] }, P)) })
6720
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: h.party_type ? /* @__PURE__ */ e(Se, { label: "", value: h.party, onChange: (v) => u(g, d, _, "party", v), linkDoctype: h.party_type.toLowerCase(), readOnly: !1 }) : /* @__PURE__ */ e("span", { className: "text-gray-300 text-xs", children: "set party type first" }) }),
6721
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.debit, onChange: (v) => u(g, d, _, "debit", v.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) }),
6722
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.credit, onChange: (v) => u(g, d, _, "credit", v.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) })
6723
+ ] }, _)) })
6713
6724
  ] }) }),
6714
- /* @__PURE__ */ e("div", { className: "mt-2 flex gap-2", children: /* @__PURE__ */ e("button", { onClick: () => m([...g, qn()]), className: "text-xs text-blue-600 hover:text-blue-800", children: "+ Add Row" }) }),
6725
+ /* @__PURE__ */ e("div", { className: "mt-2 flex gap-2", children: /* @__PURE__ */ e("button", { onClick: () => d([...g, qn()]), className: "text-xs text-blue-600 hover:text-blue-800", children: "+ Add Row" }) }),
6715
6726
  /* @__PURE__ */ r("div", { className: "mt-3 flex items-center gap-3", children: [
6716
- /* @__PURE__ */ e(H, { onClick: () => T.mutate(), disabled: !a || T.isPending, children: T.isPending ? "Importing..." : "Import Account Balances" }),
6717
- T.error && /* @__PURE__ */ e("span", { className: "text-xs text-red-600", children: T.error.message }),
6727
+ /* @__PURE__ */ e(H, { onClick: () => D.mutate(), disabled: !a || D.isPending, children: D.isPending ? "Importing..." : "Import Account Balances" }),
6728
+ D.error && /* @__PURE__ */ e("span", { className: "text-xs text-red-600", children: D.error.message }),
6718
6729
  N.accounts && /* @__PURE__ */ r("span", { className: "text-xs text-green-600", children: [
6719
6730
  "Created ",
6720
6731
  N.accounts.journal_entry
@@ -6730,13 +6741,13 @@ function Js() {
6730
6741
  /* @__PURE__ */ e("th", { className: "px-2 py-2 text-right font-medium text-gray-500", children: "Qty" }),
6731
6742
  /* @__PURE__ */ e("th", { className: "px-2 py-2 text-right font-medium text-gray-500", children: "Rate" })
6732
6743
  ] }) }),
6733
- /* @__PURE__ */ e("tbody", { children: p.map((h, P) => /* @__PURE__ */ r("tr", { children: [
6734
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e(Se, { label: "", value: h.item_code, onChange: (v) => d(p, u, P, "item_code", v), linkDoctype: "item", readOnly: !1 }) }),
6735
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.qty, onChange: (v) => d(p, u, P, "qty", v.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0" }) }),
6736
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.rate, onChange: (v) => d(p, u, P, "rate", v.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) })
6737
- ] }, P)) })
6744
+ /* @__PURE__ */ e("tbody", { children: p.map((h, _) => /* @__PURE__ */ r("tr", { children: [
6745
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e(Se, { label: "", value: h.item_code, onChange: (v) => u(p, m, _, "item_code", v), linkDoctype: "item", readOnly: !1 }) }),
6746
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.qty, onChange: (v) => u(p, m, _, "qty", v.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0" }) }),
6747
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.rate, onChange: (v) => u(p, m, _, "rate", v.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) })
6748
+ ] }, _)) })
6738
6749
  ] }) }),
6739
- /* @__PURE__ */ e("div", { className: "mt-2", children: /* @__PURE__ */ e("button", { onClick: () => u([...p, zn()]), className: "text-xs text-blue-600 hover:text-blue-800", children: "+ Add Row" }) }),
6750
+ /* @__PURE__ */ e("div", { className: "mt-2", children: /* @__PURE__ */ e("button", { onClick: () => m([...p, zn()]), className: "text-xs text-blue-600 hover:text-blue-800", children: "+ Add Row" }) }),
6740
6751
  /* @__PURE__ */ r("div", { className: "mt-3 flex items-center gap-3", children: [
6741
6752
  /* @__PURE__ */ e(H, { onClick: () => A.mutate(), disabled: !a || !l || A.isPending, children: A.isPending ? "Importing..." : "Import Stock Balances" }),
6742
6753
  A.error && /* @__PURE__ */ e("span", { className: "text-xs text-red-600", children: A.error.message }),
@@ -6759,8 +6770,8 @@ function Js() {
6759
6770
  /* @__PURE__ */ e("th", { className: "px-2 py-2 text-left font-medium text-gray-500", children: "Due Date" }),
6760
6771
  /* @__PURE__ */ e("th", { className: "px-2 py-2 text-left font-medium text-gray-500", children: "Ref / Remarks" })
6761
6772
  ] }) }),
6762
- /* @__PURE__ */ e("tbody", { children: w.map((h, P) => /* @__PURE__ */ r("tr", { children: [
6763
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ r("select", { value: h.type, onChange: (v) => d(w, b, P, "type", v.target.value), className: "rounded border border-gray-300 px-2 py-1.5 text-sm", children: [
6773
+ /* @__PURE__ */ e("tbody", { children: w.map((h, _) => /* @__PURE__ */ r("tr", { children: [
6774
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ r("select", { value: h.type, onChange: (v) => u(w, x, _, "type", v.target.value), className: "rounded border border-gray-300 px-2 py-1.5 text-sm", children: [
6764
6775
  /* @__PURE__ */ e("option", { value: "sales", children: "Sales (AR)" }),
6765
6776
  /* @__PURE__ */ e("option", { value: "purchase", children: "Purchase (AP)" })
6766
6777
  ] }) }),
@@ -6769,20 +6780,20 @@ function Js() {
6769
6780
  {
6770
6781
  label: "",
6771
6782
  value: h.party,
6772
- onChange: (v) => d(w, b, P, "party", v),
6783
+ onChange: (v) => u(w, x, _, "party", v),
6773
6784
  linkDoctype: h.type === "sales" ? "customer" : "supplier",
6774
6785
  readOnly: !1
6775
6786
  }
6776
6787
  ) }),
6777
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.amount, onChange: (v) => d(w, b, P, "amount", v.target.value), className: "w-28 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) }),
6778
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "date", value: h.due_date, onChange: (v) => d(w, b, P, "due_date", v.target.value), className: "rounded border border-gray-300 px-2 py-1.5 text-sm" }) }),
6779
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "text", value: h.remarks, onChange: (v) => d(w, b, P, "remarks", v.target.value), className: "w-full rounded border border-gray-300 px-2 py-1.5 text-sm", placeholder: "Old invoice ref" }) })
6780
- ] }, P)) })
6788
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.amount, onChange: (v) => u(w, x, _, "amount", v.target.value), className: "w-28 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) }),
6789
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "date", value: h.due_date, onChange: (v) => u(w, x, _, "due_date", v.target.value), className: "rounded border border-gray-300 px-2 py-1.5 text-sm" }) }),
6790
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "text", value: h.remarks, onChange: (v) => u(w, x, _, "remarks", v.target.value), className: "w-full rounded border border-gray-300 px-2 py-1.5 text-sm", placeholder: "Old invoice ref" }) })
6791
+ ] }, _)) })
6781
6792
  ] }) }),
6782
- /* @__PURE__ */ e("div", { className: "mt-2", children: /* @__PURE__ */ e("button", { onClick: () => b([...w, Mn()]), className: "text-xs text-blue-600 hover:text-blue-800", children: "+ Add Row" }) }),
6793
+ /* @__PURE__ */ e("div", { className: "mt-2", children: /* @__PURE__ */ e("button", { onClick: () => x([...w, Mn()]), className: "text-xs text-blue-600 hover:text-blue-800", children: "+ Add Row" }) }),
6783
6794
  /* @__PURE__ */ r("div", { className: "mt-3 flex items-center gap-3", children: [
6784
- /* @__PURE__ */ e(H, { onClick: () => x.mutate(), disabled: !a || x.isPending, children: x.isPending ? "Importing..." : "Import Outstanding Invoices" }),
6785
- x.error && /* @__PURE__ */ e("span", { className: "text-xs text-red-600", children: x.error.message }),
6795
+ /* @__PURE__ */ e(H, { onClick: () => b.mutate(), disabled: !a || b.isPending, children: b.isPending ? "Importing..." : "Import Outstanding Invoices" }),
6796
+ b.error && /* @__PURE__ */ e("span", { className: "text-xs text-red-600", children: b.error.message }),
6786
6797
  N.invoices && /* @__PURE__ */ r("span", { className: "text-xs text-green-600", children: [
6787
6798
  "Created ",
6788
6799
  N.invoices.invoices_created,
@@ -6796,7 +6807,7 @@ function Js() {
6796
6807
  "button",
6797
6808
  {
6798
6809
  onClick: async () => {
6799
- await _.updateSettings({ opening_balances_enabled: "0" }), n.invalidateQueries({ queryKey: ["settings"] }), t("/");
6810
+ await T.updateSettings({ opening_balances_enabled: "0" }), n.invalidateQueries({ queryKey: ["settings"] }), t("/");
6800
6811
  },
6801
6812
  className: "mt-3 rounded-lg bg-gray-900 px-5 py-2 text-sm font-medium text-white hover:bg-gray-800",
6802
6813
  children: "Finish and Disable Opening Balances"
@@ -6808,29 +6819,29 @@ function Js() {
6808
6819
  function Zs() {
6809
6820
  const { user: t } = st(), n = We(), { data: a, isLoading: s } = ie({
6810
6821
  queryKey: ["auth-users"],
6811
- queryFn: () => _.authListUsers()
6822
+ queryFn: () => T.authListUsers()
6812
6823
  }), { data: i } = ie({
6813
6824
  queryKey: ["auth-invites"],
6814
- queryFn: () => _.authListInvites()
6815
- }), [o, l] = S(""), [c, g] = S("viewer"), [m, p] = S(null), u = oe({
6816
- mutationFn: () => _.authInvite(o, c),
6817
- onSuccess: (d) => {
6818
- p(d), l(""), n.invalidateQueries({ queryKey: ["auth-invites"] });
6825
+ queryFn: () => T.authListInvites()
6826
+ }), [o, l] = S(""), [c, g] = S("viewer"), [d, p] = S(null), m = oe({
6827
+ mutationFn: () => T.authInvite(o, c),
6828
+ onSuccess: (u) => {
6829
+ p(u), l(""), n.invalidateQueries({ queryKey: ["auth-invites"] });
6819
6830
  }
6820
6831
  }), w = oe({
6821
- mutationFn: ({ name: d, role: h }) => _.authChangeRole(d, h),
6832
+ mutationFn: ({ name: u, role: h }) => T.authChangeRole(u, h),
6822
6833
  onSuccess: () => n.invalidateQueries({ queryKey: ["auth-users"] })
6823
- }), b = oe({
6824
- mutationFn: (d) => _.authDisableUser(d),
6834
+ }), x = oe({
6835
+ mutationFn: (u) => T.authDisableUser(u),
6825
6836
  onSuccess: () => n.invalidateQueries({ queryKey: ["auth-users"] })
6826
6837
  }), N = oe({
6827
- mutationFn: (d) => _.authRevokeInvite(d),
6838
+ mutationFn: (u) => T.authRevokeInvite(u),
6828
6839
  onSuccess: () => n.invalidateQueries({ queryKey: ["auth-invites"] })
6829
- }), [y, T] = S(null), A = (d) => `${window.location.origin}/login?invite=${d}`, x = async (d) => {
6840
+ }), [y, D] = S(null), A = (u) => `${window.location.origin}/login?invite=${u}`, b = async (u) => {
6830
6841
  try {
6831
- await navigator.clipboard.writeText(A(d)), T(d), setTimeout(() => T((h) => h === d ? null : h), 2e3);
6842
+ await navigator.clipboard.writeText(A(u)), D(u), setTimeout(() => D((h) => h === u ? null : h), 2e3);
6832
6843
  } catch {
6833
- window.prompt("Invite link", A(d));
6844
+ window.prompt("Invite link", A(u));
6834
6845
  }
6835
6846
  };
6836
6847
  return (t == null ? void 0 : t.role) !== "admin" ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-gray-400", children: "Admin access required" }) : /* @__PURE__ */ r("div", { className: "space-y-6", children: [
@@ -6856,7 +6867,7 @@ function Zs() {
6856
6867
  label: "Email",
6857
6868
  type: "email",
6858
6869
  value: o,
6859
- onChange: (d) => l(d.target.value),
6870
+ onChange: (u) => l(u.target.value),
6860
6871
  placeholder: "colleague@company.com"
6861
6872
  }
6862
6873
  ),
@@ -6866,52 +6877,52 @@ function Zs() {
6866
6877
  label: "Role",
6867
6878
  options: ["viewer", "manager", "admin"],
6868
6879
  value: c,
6869
- onChange: (d) => g(d.target.value)
6880
+ onChange: (u) => g(u.target.value)
6870
6881
  }
6871
6882
  ),
6872
6883
  /* @__PURE__ */ e(
6873
6884
  H,
6874
6885
  {
6875
- onClick: () => u.mutate(),
6876
- disabled: !o.trim() || u.isPending,
6877
- children: u.isPending ? "Sending..." : "Create Invite"
6886
+ onClick: () => m.mutate(),
6887
+ disabled: !o.trim() || m.isPending,
6888
+ children: m.isPending ? "Sending..." : "Create Invite"
6878
6889
  }
6879
6890
  )
6880
6891
  ] }),
6881
- u.error && /* @__PURE__ */ e("p", { className: "mt-2 text-sm text-red-600", children: u.error.message }),
6882
- m && /* @__PURE__ */ r("div", { className: "mt-3 rounded-md bg-green-50 px-4 py-3 text-sm", children: [
6892
+ m.error && /* @__PURE__ */ e("p", { className: "mt-2 text-sm text-red-600", children: m.error.message }),
6893
+ d && /* @__PURE__ */ r("div", { className: "mt-3 rounded-md bg-green-50 px-4 py-3 text-sm", children: [
6883
6894
  /* @__PURE__ */ e("p", { className: "font-medium text-green-800", children: "Invite created!" }),
6884
6895
  /* @__PURE__ */ r("p", { className: "mt-1 text-green-700", children: [
6885
6896
  "Share this link:",
6886
6897
  " ",
6887
6898
  /* @__PURE__ */ r("code", { className: "rounded bg-green-100 px-2 py-0.5 text-xs font-mono", children: [
6888
6899
  window.location.origin,
6889
- m.link
6900
+ d.link
6890
6901
  ] })
6891
6902
  ] })
6892
6903
  ] })
6893
6904
  ] }),
6894
- i && i.filter((d) => !d.used).length > 0 && /* @__PURE__ */ e(F, { title: "Pending Invites", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
6905
+ i && i.filter((u) => !u.used).length > 0 && /* @__PURE__ */ e(F, { title: "Pending Invites", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
6895
6906
  /* @__PURE__ */ e("thead", { className: "bg-gray-50", children: /* @__PURE__ */ r("tr", { children: [
6896
6907
  /* @__PURE__ */ e("th", { className: "px-4 py-2 text-left font-medium text-gray-500", children: "Email" }),
6897
6908
  /* @__PURE__ */ e("th", { className: "px-4 py-2 text-left font-medium text-gray-500", children: "Role" }),
6898
6909
  /* @__PURE__ */ e("th", { className: "px-4 py-2 text-left font-medium text-gray-500", children: "Created" }),
6899
6910
  /* @__PURE__ */ e("th", { className: "px-4 py-2 text-right font-medium text-gray-500", children: "Actions" })
6900
6911
  ] }) }),
6901
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: i.filter((d) => !d.used).map((d) => {
6912
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: i.filter((u) => !u.used).map((u) => {
6902
6913
  var h;
6903
6914
  return /* @__PURE__ */ r("tr", { children: [
6904
- /* @__PURE__ */ e("td", { className: "px-4 py-2", children: d.email }),
6905
- /* @__PURE__ */ e("td", { className: "px-4 py-2", children: /* @__PURE__ */ e("span", { className: "rounded bg-gray-100 px-2 py-0.5 text-xs font-medium", children: d.role }) }),
6906
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-500", children: (h = d.creation) == null ? void 0 : h.split("T")[0] }),
6915
+ /* @__PURE__ */ e("td", { className: "px-4 py-2", children: u.email }),
6916
+ /* @__PURE__ */ e("td", { className: "px-4 py-2", children: /* @__PURE__ */ e("span", { className: "rounded bg-gray-100 px-2 py-0.5 text-xs font-medium", children: u.role }) }),
6917
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-500", children: (h = u.creation) == null ? void 0 : h.split("T")[0] }),
6907
6918
  /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: /* @__PURE__ */ r("div", { className: "flex items-center justify-end gap-2", children: [
6908
6919
  /* @__PURE__ */ e(
6909
6920
  H,
6910
6921
  {
6911
6922
  variant: "secondary",
6912
6923
  size: "sm",
6913
- onClick: () => x(d.token),
6914
- children: y === d.token ? "Copied!" : "Copy link"
6924
+ onClick: () => b(u.token),
6925
+ children: y === u.token ? "Copied!" : "Copy link"
6915
6926
  }
6916
6927
  ),
6917
6928
  /* @__PURE__ */ e(
@@ -6919,13 +6930,13 @@ function Zs() {
6919
6930
  {
6920
6931
  variant: "danger",
6921
6932
  size: "sm",
6922
- onClick: () => N.mutate(d.token),
6933
+ onClick: () => N.mutate(u.token),
6923
6934
  disabled: N.isPending,
6924
6935
  children: "Revoke"
6925
6936
  }
6926
6937
  )
6927
6938
  ] }) })
6928
- ] }, d.token);
6939
+ ] }, u.token);
6929
6940
  }) })
6930
6941
  ] }) }),
6931
6942
  /* @__PURE__ */ e(F, { title: "Team Members", children: s ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: "Loading..." }) : /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
@@ -6936,16 +6947,16 @@ function Zs() {
6936
6947
  /* @__PURE__ */ e("th", { className: "px-4 py-2 text-left font-medium text-gray-500", children: "Status" }),
6937
6948
  /* @__PURE__ */ e("th", { className: "px-4 py-2 text-right font-medium text-gray-500", children: "Actions" })
6938
6949
  ] }) }),
6939
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: (a || []).map((d) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
6940
- /* @__PURE__ */ e("td", { className: "px-4 py-2 font-medium text-gray-900", children: d.full_name }),
6941
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-600", children: d.email }),
6942
- /* @__PURE__ */ e("td", { className: "px-4 py-2", children: d.role === "public_manager" ? /* @__PURE__ */ e("span", { className: "rounded bg-amber-100 px-2 py-0.5 text-xs font-medium text-amber-800", children: "public_manager (system)" }) : /* @__PURE__ */ r(
6950
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: (a || []).map((u) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
6951
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 font-medium text-gray-900", children: u.full_name }),
6952
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-600", children: u.email }),
6953
+ /* @__PURE__ */ e("td", { className: "px-4 py-2", children: u.role === "public_manager" ? /* @__PURE__ */ e("span", { className: "rounded bg-amber-100 px-2 py-0.5 text-xs font-medium text-amber-800", children: "public_manager (system)" }) : /* @__PURE__ */ r(
6943
6954
  "select",
6944
6955
  {
6945
- value: d.role,
6946
- onChange: (h) => w.mutate({ name: d.name, role: h.target.value }),
6947
- disabled: d.name === (t == null ? void 0 : t.name),
6948
- className: `rounded border px-2 py-1 text-xs ${d.name === (t == null ? void 0 : t.name) ? "border-gray-200 bg-gray-50 text-gray-400" : "border-gray-300 bg-white text-gray-900"}`,
6956
+ value: u.role,
6957
+ onChange: (h) => w.mutate({ name: u.name, role: h.target.value }),
6958
+ disabled: u.name === (t == null ? void 0 : t.name),
6959
+ className: `rounded border px-2 py-1 text-xs ${u.name === (t == null ? void 0 : t.name) ? "border-gray-200 bg-gray-50 text-gray-400" : "border-gray-300 bg-white text-gray-900"}`,
6949
6960
  children: [
6950
6961
  /* @__PURE__ */ e("option", { value: "viewer", children: "viewer" }),
6951
6962
  /* @__PURE__ */ e("option", { value: "manager", children: "manager" }),
@@ -6953,16 +6964,16 @@ function Zs() {
6953
6964
  ]
6954
6965
  }
6955
6966
  ) }),
6956
- /* @__PURE__ */ e("td", { className: "px-4 py-2", children: /* @__PURE__ */ e("span", { className: `rounded px-2 py-0.5 text-xs font-medium ${d.enabled ? "bg-green-100 text-green-800" : "bg-red-100 text-red-800"}`, children: d.enabled ? "Active" : "Disabled" }) }),
6957
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: d.name !== (t == null ? void 0 : t.name) && d.enabled ? /* @__PURE__ */ e(
6967
+ /* @__PURE__ */ e("td", { className: "px-4 py-2", children: /* @__PURE__ */ e("span", { className: `rounded px-2 py-0.5 text-xs font-medium ${u.enabled ? "bg-green-100 text-green-800" : "bg-red-100 text-red-800"}`, children: u.enabled ? "Active" : "Disabled" }) }),
6968
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: u.name !== (t == null ? void 0 : t.name) && u.enabled ? /* @__PURE__ */ e(
6958
6969
  "button",
6959
6970
  {
6960
- onClick: () => b.mutate(d.name),
6971
+ onClick: () => x.mutate(u.name),
6961
6972
  className: "text-xs text-red-500 hover:text-red-700",
6962
6973
  children: "Disable"
6963
6974
  }
6964
6975
  ) : null })
6965
- ] }, d.name)) })
6976
+ ] }, u.name)) })
6966
6977
  ] }) })
6967
6978
  ] });
6968
6979
  }
@@ -7029,17 +7040,17 @@ const Xs = { save: "Save", saving: "Saving...", submit: "Submit", cancel: "Cance
7029
7040
  tutorial: ro,
7030
7041
  notesMarkup: so,
7031
7042
  coa: io
7032
- }, fa = [
7043
+ }, ba = [
7033
7044
  { code: "en", label: "English" },
7034
7045
  { code: "de", label: "Deutsch" },
7035
7046
  { code: "fr", label: "Français" }
7036
- ], ya = "lambda-erp:language";
7047
+ ], va = "lambda-erp:language";
7037
7048
  function lo(t) {
7038
- return !!t && fa.some((n) => n.code === t);
7049
+ return !!t && ba.some((n) => n.code === t);
7039
7050
  }
7040
7051
  function co() {
7041
7052
  try {
7042
- const t = localStorage.getItem(ya);
7053
+ const t = localStorage.getItem(va);
7043
7054
  if (lo(t)) return t;
7044
7055
  } catch {
7045
7056
  }
@@ -7047,11 +7058,11 @@ function co() {
7047
7058
  }
7048
7059
  function uo(t) {
7049
7060
  try {
7050
- localStorage.setItem(ya, t);
7061
+ localStorage.setItem(va, t);
7051
7062
  } catch {
7052
7063
  }
7053
7064
  }
7054
- ea.use(Ba).init({
7065
+ ea.use(La).init({
7055
7066
  resources: {
7056
7067
  en: { translation: vi },
7057
7068
  de: { translation: Fi },
@@ -7073,7 +7084,7 @@ function mo({ label: t }) {
7073
7084
  He,
7074
7085
  {
7075
7086
  label: t === null ? void 0 : t ?? n("language.label"),
7076
- options: fa.map((o) => ({ value: o.code, label: o.label })),
7087
+ options: ba.map((o) => ({ value: o.code, label: o.label })),
7077
7088
  value: s,
7078
7089
  onChange: (o) => a.changeLanguage(o.target.value)
7079
7090
  }
@@ -7091,13 +7102,13 @@ function Ge(t) {
7091
7102
  return t === 0 ? "$0.00" : t < 0.01 ? `$${t.toFixed(4)}` : `$${t.toFixed(2)}`;
7092
7103
  }
7093
7104
  function po({ demoActive: t }) {
7094
- var A, x;
7095
- const { t: n } = Z(), [a, s] = S("1h"), { data: i, isLoading: o, isFetching: l, error: c, refetch: g, dataUpdatedAt: m } = ie({
7105
+ var A, b;
7106
+ const { t: n } = Z(), [a, s] = S("1h"), { data: i, isLoading: o, isFetching: l, error: c, refetch: g, dataUpdatedAt: d } = ie({
7096
7107
  queryKey: ["demo-spend"],
7097
- queryFn: () => _.getDemoSpend(),
7108
+ queryFn: () => T.getDemoSpend(),
7098
7109
  // Refresh once a minute — demo spend changes slowly; no need to poll harder.
7099
7110
  refetchInterval: 6e4
7100
- }), p = Fn.find((d) => d.value === a), u = (A = i == null ? void 0 : i.windows) == null ? void 0 : A[a], w = ((x = i == null ? void 0 : i.caps) == null ? void 0 : x.global_hourly_usd) ?? 0, b = u ? u.demo_usd / p.hours : 0, N = u ? u.total_usd / p.hours : 0, y = w > 0 ? Math.min(100, b / w * 100) : 0, T = y >= 90 ? "bg-red-500" : y >= 60 ? "bg-amber-500" : "bg-emerald-500";
7111
+ }), p = Fn.find((u) => u.value === a), m = (A = i == null ? void 0 : i.windows) == null ? void 0 : A[a], w = ((b = i == null ? void 0 : i.caps) == null ? void 0 : b.global_hourly_usd) ?? 0, x = m ? m.demo_usd / p.hours : 0, N = m ? m.total_usd / p.hours : 0, y = w > 0 ? Math.min(100, x / w * 100) : 0, D = y >= 90 ? "bg-red-500" : y >= 60 ? "bg-amber-500" : "bg-emerald-500";
7101
7112
  return /* @__PURE__ */ r(F, { title: n("settings.tokenSpendTitle"), children: [
7102
7113
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end justify-between gap-4", children: [
7103
7114
  /* @__PURE__ */ r("div", { className: "max-w-lg text-sm text-gray-600", children: [
@@ -7116,9 +7127,9 @@ function po({ demoActive: t }) {
7116
7127
  He,
7117
7128
  {
7118
7129
  label: "Time range",
7119
- options: Fn.map((d) => ({ value: d.value, label: d.label })),
7130
+ options: Fn.map((u) => ({ value: u.value, label: u.label })),
7120
7131
  value: a,
7121
- onChange: (d) => s(d.target.value)
7132
+ onChange: (u) => s(u.target.value)
7122
7133
  }
7123
7134
  ) }),
7124
7135
  /* @__PURE__ */ r(
@@ -7127,7 +7138,7 @@ function po({ demoActive: t }) {
7127
7138
  type: "button",
7128
7139
  onClick: () => g(),
7129
7140
  disabled: l,
7130
- title: m ? `Last updated ${new Date(m).toLocaleTimeString()}` : "Refresh now",
7141
+ title: d ? `Last updated ${new Date(d).toLocaleTimeString()}` : "Refresh now",
7131
7142
  className: "inline-flex h-[38px] items-center gap-1.5 rounded-md border border-gray-300 bg-white px-3 text-sm font-medium text-gray-700 shadow-sm hover:bg-gray-50 disabled:cursor-not-allowed disabled:opacity-60",
7132
7143
  children: [
7133
7144
  /* @__PURE__ */ e(
@@ -7158,7 +7169,7 @@ function po({ demoActive: t }) {
7158
7169
  "Failed to load spend data: ",
7159
7170
  c.message
7160
7171
  ] }),
7161
- u && /* @__PURE__ */ r("div", { className: "mt-5 space-y-5", children: [
7172
+ m && /* @__PURE__ */ r("div", { className: "mt-5 space-y-5", children: [
7162
7173
  t ? (
7163
7174
  /* Demo deployments: spend-against-cap is the number that matters. */
7164
7175
  /* @__PURE__ */ r("div", { children: [
@@ -7170,7 +7181,7 @@ function po({ demoActive: t }) {
7170
7181
  ")"
7171
7182
  ] }),
7172
7183
  /* @__PURE__ */ r("div", { className: "mt-1 text-2xl font-semibold text-gray-900", children: [
7173
- Ge(b),
7184
+ Ge(x),
7174
7185
  /* @__PURE__ */ r("span", { className: "ml-2 text-sm font-normal text-gray-500", children: [
7175
7186
  "/ ",
7176
7187
  Ge(w),
@@ -7181,7 +7192,7 @@ function po({ demoActive: t }) {
7181
7192
  /* @__PURE__ */ r("div", { className: "text-right", children: [
7182
7193
  /* @__PURE__ */ e("div", { className: "text-xs font-medium uppercase tracking-wide text-gray-500", children: "Total (all roles)" }),
7183
7194
  /* @__PURE__ */ r("div", { className: "mt-1 text-lg font-semibold text-gray-700", children: [
7184
- Ge(u.total_usd),
7195
+ Ge(m.total_usd),
7185
7196
  /* @__PURE__ */ r("span", { className: "ml-1 text-xs font-normal text-gray-500", children: [
7186
7197
  "(",
7187
7198
  Ge(N),
@@ -7190,7 +7201,7 @@ function po({ demoActive: t }) {
7190
7201
  ] })
7191
7202
  ] })
7192
7203
  ] }),
7193
- /* @__PURE__ */ e("div", { className: "mt-2 h-2 w-full overflow-hidden rounded-full bg-gray-100", children: /* @__PURE__ */ e("div", { className: `h-full ${T} transition-all`, style: { width: `${y}%` } }) }),
7204
+ /* @__PURE__ */ e("div", { className: "mt-2 h-2 w-full overflow-hidden rounded-full bg-gray-100", children: /* @__PURE__ */ e("div", { className: `h-full ${D} transition-all`, style: { width: `${y}%` } }) }),
7194
7205
  /* @__PURE__ */ r("div", { className: "mt-1 text-xs text-gray-400", children: [
7195
7206
  y.toFixed(0),
7196
7207
  "% of the hourly cap",
@@ -7209,7 +7220,7 @@ function po({ demoActive: t }) {
7209
7220
  Ge(N),
7210
7221
  /* @__PURE__ */ r("span", { className: "ml-2 text-sm font-normal text-gray-500", children: [
7211
7222
  "(",
7212
- Ge(u.total_usd),
7223
+ Ge(m.total_usd),
7213
7224
  " over ",
7214
7225
  p.label.toLowerCase(),
7215
7226
  ")"
@@ -7218,18 +7229,18 @@ function po({ demoActive: t }) {
7218
7229
  ] })
7219
7230
  ),
7220
7231
  /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-3 sm:grid-cols-4", children: [
7221
- t ? /* @__PURE__ */ e(Ct, { label: "Demo spend", value: Ge(u.demo_usd) }) : /* @__PURE__ */ e(Ct, { label: "Cost", value: Ge(u.total_usd) }),
7222
- /* @__PURE__ */ e(Ct, { label: "Calls", value: u.call_count.toLocaleString() }),
7223
- /* @__PURE__ */ e(Ct, { label: "Unique IPs", value: u.unique_ips.toLocaleString() }),
7232
+ t ? /* @__PURE__ */ e(Ct, { label: "Demo spend", value: Ge(m.demo_usd) }) : /* @__PURE__ */ e(Ct, { label: "Cost", value: Ge(m.total_usd) }),
7233
+ /* @__PURE__ */ e(Ct, { label: "Calls", value: m.call_count.toLocaleString() }),
7234
+ /* @__PURE__ */ e(Ct, { label: "Unique IPs", value: m.unique_ips.toLocaleString() }),
7224
7235
  /* @__PURE__ */ e(
7225
7236
  Ct,
7226
7237
  {
7227
7238
  label: "Tokens (in/out)",
7228
- value: `${u.prompt_tokens.toLocaleString()} / ${u.completion_tokens.toLocaleString()}`
7239
+ value: `${m.prompt_tokens.toLocaleString()} / ${m.completion_tokens.toLocaleString()}`
7229
7240
  }
7230
7241
  )
7231
7242
  ] }),
7232
- Object.keys(u.by_provider).length > 0 && /* @__PURE__ */ r("div", { children: [
7243
+ Object.keys(m.by_provider).length > 0 && /* @__PURE__ */ r("div", { children: [
7233
7244
  /* @__PURE__ */ e("div", { className: "mb-2 text-xs font-medium uppercase tracking-wide text-gray-500", children: "By provider" }),
7234
7245
  /* @__PURE__ */ e("div", { className: "overflow-hidden rounded-md border border-gray-200", children: /* @__PURE__ */ r("table", { className: "w-full text-sm", children: [
7235
7246
  /* @__PURE__ */ e("thead", { className: "bg-gray-50 text-xs uppercase tracking-wide text-gray-500", children: /* @__PURE__ */ r("tr", { children: [
@@ -7239,13 +7250,13 @@ function po({ demoActive: t }) {
7239
7250
  /* @__PURE__ */ e("th", { className: "px-3 py-2 text-right font-medium", children: "Prompt tok" }),
7240
7251
  /* @__PURE__ */ e("th", { className: "px-3 py-2 text-right font-medium", children: "Completion tok" })
7241
7252
  ] }) }),
7242
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: Object.entries(u.by_provider).map(([d, h]) => /* @__PURE__ */ r("tr", { children: [
7243
- /* @__PURE__ */ e("td", { className: "px-3 py-2 font-medium text-gray-900", children: d }),
7253
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: Object.entries(m.by_provider).map(([u, h]) => /* @__PURE__ */ r("tr", { children: [
7254
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 font-medium text-gray-900", children: u }),
7244
7255
  /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right tabular-nums", children: Ge(h.cost_usd) }),
7245
7256
  /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right tabular-nums", children: h.call_count.toLocaleString() }),
7246
7257
  /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right tabular-nums", children: h.prompt_tokens.toLocaleString() }),
7247
7258
  /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right tabular-nums", children: h.completion_tokens.toLocaleString() })
7248
- ] }, d)) })
7259
+ ] }, u)) })
7249
7260
  ] }) })
7250
7261
  ] }),
7251
7262
  i && i.top_ips_24h.length > 0 && /* @__PURE__ */ r("div", { children: [
@@ -7257,12 +7268,12 @@ function po({ demoActive: t }) {
7257
7268
  /* @__PURE__ */ e("th", { className: "px-3 py-2 text-right font-medium", children: "Cost" }),
7258
7269
  /* @__PURE__ */ e("th", { className: "px-3 py-2 text-right font-medium", children: "Calls" })
7259
7270
  ] }) }),
7260
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: i.top_ips_24h.map((d, h) => /* @__PURE__ */ r("tr", { children: [
7261
- /* @__PURE__ */ e("td", { className: "px-3 py-2 font-mono text-xs text-gray-900", children: d.ip }),
7262
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-gray-600", children: d.role ?? "—" }),
7263
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right tabular-nums", children: Ge(d.cost_usd) }),
7264
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right tabular-nums", children: d.call_count.toLocaleString() })
7265
- ] }, `${d.ip}-${d.role ?? ""}-${h}`)) })
7271
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: i.top_ips_24h.map((u, h) => /* @__PURE__ */ r("tr", { children: [
7272
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 font-mono text-xs text-gray-900", children: u.ip }),
7273
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-gray-600", children: u.role ?? "—" }),
7274
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right tabular-nums", children: Ge(u.cost_usd) }),
7275
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right tabular-nums", children: u.call_count.toLocaleString() })
7276
+ ] }, `${u.ip}-${u.role ?? ""}-${h}`)) })
7266
7277
  ] }) })
7267
7278
  ] })
7268
7279
  ] })
@@ -7275,24 +7286,24 @@ function Ct({ label: t, value: n }) {
7275
7286
  ] });
7276
7287
  }
7277
7288
  function ho() {
7278
- const { t } = Z(), { user: n } = st(), [a, s] = S(""), [i, o] = S(""), [l, c] = S(""), [g, m] = S(""), [p, u] = S(!1), w = oe({
7279
- mutationFn: () => _.authChangePassword(a, i),
7289
+ const { t } = Z(), { user: n } = st(), [a, s] = S(""), [i, o] = S(""), [l, c] = S(""), [g, d] = S(""), [p, m] = S(!1), w = oe({
7290
+ mutationFn: () => T.authChangePassword(a, i),
7280
7291
  onSuccess: () => {
7281
- u(!0), m(""), s(""), o(""), c(""), setTimeout(() => u(!1), 4e3);
7292
+ m(!0), d(""), s(""), o(""), c(""), setTimeout(() => m(!1), 4e3);
7282
7293
  },
7283
- onError: (N) => m(N instanceof $e ? N.message : t("login.registrationFailed"))
7284
- }), b = (N) => {
7285
- if (N.preventDefault(), m(""), u(!1), i !== l) {
7286
- m(t("login.passwordsNoMatch"));
7294
+ onError: (N) => d(N instanceof $e ? N.message : t("login.registrationFailed"))
7295
+ }), x = (N) => {
7296
+ if (N.preventDefault(), d(""), m(!1), i !== l) {
7297
+ d(t("login.passwordsNoMatch"));
7287
7298
  return;
7288
7299
  }
7289
7300
  if (i.length < 6) {
7290
- m(t("login.passwordTooShort"));
7301
+ d(t("login.passwordTooShort"));
7291
7302
  return;
7292
7303
  }
7293
7304
  w.mutate();
7294
7305
  };
7295
- return /* @__PURE__ */ e(F, { title: t("settings.passwordTitle"), children: /* @__PURE__ */ r("form", { onSubmit: b, className: "max-w-sm space-y-3", children: [
7306
+ return /* @__PURE__ */ e(F, { title: t("settings.passwordTitle"), children: /* @__PURE__ */ r("form", { onSubmit: x, className: "max-w-sm space-y-3", children: [
7296
7307
  /* @__PURE__ */ e(
7297
7308
  "input",
7298
7309
  {
@@ -7352,14 +7363,14 @@ function ho() {
7352
7363
  ] }) });
7353
7364
  }
7354
7365
  function go() {
7355
- const { t } = Z(), { user: n, refreshUser: a } = st(), [s, i] = S(""), [o, l] = S(""), [c, g] = S(""), [m, p] = S(!1), u = oe({
7356
- mutationFn: () => _.authSetPassword(s),
7366
+ const { t } = Z(), { user: n, refreshUser: a } = st(), [s, i] = S(""), [o, l] = S(""), [c, g] = S(""), [d, p] = S(!1), m = oe({
7367
+ mutationFn: () => T.authSetPassword(s),
7357
7368
  onSuccess: async () => {
7358
7369
  p(!0), g(""), i(""), l(""), await a();
7359
7370
  },
7360
- onError: (b) => g(b instanceof $e ? b.message : t("login.registrationFailed"))
7361
- }), w = (b) => {
7362
- if (b.preventDefault(), g(""), p(!1), s !== o) {
7371
+ onError: (x) => g(x instanceof $e ? x.message : t("login.registrationFailed"))
7372
+ }), w = (x) => {
7373
+ if (x.preventDefault(), g(""), p(!1), s !== o) {
7363
7374
  g(t("login.passwordsNoMatch"));
7364
7375
  return;
7365
7376
  }
@@ -7367,7 +7378,7 @@ function go() {
7367
7378
  g(t("login.passwordTooShort"));
7368
7379
  return;
7369
7380
  }
7370
- u.mutate();
7381
+ m.mutate();
7371
7382
  };
7372
7383
  return /* @__PURE__ */ r(F, { title: t("settings.setPasswordTitle"), children: [
7373
7384
  /* @__PURE__ */ e("p", { className: "mb-3 max-w-lg text-sm text-gray-600", children: t("settings.setPasswordBody") }),
@@ -7394,7 +7405,7 @@ function go() {
7394
7405
  type: "password",
7395
7406
  autoComplete: "new-password",
7396
7407
  value: s,
7397
- onChange: (b) => i(b.target.value),
7408
+ onChange: (x) => i(x.target.value),
7398
7409
  required: !0
7399
7410
  }
7400
7411
  ),
@@ -7407,23 +7418,23 @@ function go() {
7407
7418
  type: "password",
7408
7419
  autoComplete: "new-password",
7409
7420
  value: o,
7410
- onChange: (b) => l(b.target.value),
7421
+ onChange: (x) => l(x.target.value),
7411
7422
  required: !0
7412
7423
  }
7413
7424
  ),
7414
7425
  c && /* @__PURE__ */ e("p", { className: "text-sm text-red-600", children: c }),
7415
- m && /* @__PURE__ */ e("p", { className: "text-sm text-green-700", children: t("settings.passwordSet") }),
7416
- /* @__PURE__ */ e(H, { type: "submit", disabled: u.isPending || !s || !o, children: u.isPending ? t("settings.changingPassword") : t("settings.setPassword") })
7426
+ d && /* @__PURE__ */ e("p", { className: "text-sm text-green-700", children: t("settings.passwordSet") }),
7427
+ /* @__PURE__ */ e(H, { type: "submit", disabled: m.isPending || !s || !o, children: m.isPending ? t("settings.changingPassword") : t("settings.setPassword") })
7417
7428
  ] })
7418
7429
  ] });
7419
7430
  }
7420
7431
  function fo() {
7421
7432
  const { t } = Z(), { data: n } = ie({
7422
7433
  queryKey: ["auth-setup-status"],
7423
- queryFn: () => _.authSetupStatus()
7434
+ queryFn: () => T.authSetupStatus()
7424
7435
  }), { data: a } = ie({
7425
7436
  queryKey: ["oauth-identities"],
7426
- queryFn: () => _.oauthListIdentities()
7437
+ queryFn: () => T.oauthListIdentities()
7427
7438
  }), s = (n == null ? void 0 : n.oauth_providers) ?? [];
7428
7439
  if (s.length === 0) return null;
7429
7440
  const i = new Set((a ?? []).map((o) => o.provider));
@@ -7441,7 +7452,7 @@ function fo() {
7441
7452
  {
7442
7453
  type: "button",
7443
7454
  onClick: () => {
7444
- window.location.href = _.oauthLoginUrl(o, { link: !0 });
7455
+ window.location.href = T.oauthLoginUrl(o, { link: !0 });
7445
7456
  },
7446
7457
  className: "rounded-md border border-gray-300 bg-white px-3 py-1 text-sm font-medium text-gray-700 hover:bg-gray-50",
7447
7458
  children: t("settings.linkProvider", { provider: l })
@@ -7452,26 +7463,26 @@ function fo() {
7452
7463
  ] });
7453
7464
  }
7454
7465
  const Yt = { viewer: 1, manager: 2, admin: 3 };
7455
- function ba({ ownRole: t }) {
7456
- const { t: n } = Z(), { user: a } = st(), s = We(), [i, o] = S(""), [l, c] = S(t in Yt ? t : "viewer"), [g, m] = S(null), [p, u] = S(null), w = ["viewer", "manager", "admin"].filter(
7466
+ function xa({ ownRole: t }) {
7467
+ const { t: n } = Z(), { user: a } = st(), s = We(), [i, o] = S(""), [l, c] = S(t in Yt ? t : "viewer"), [g, d] = S(null), [p, m] = S(null), w = ["viewer", "manager", "admin"].filter(
7457
7468
  (v) => Yt[v] <= (Yt[t] ?? 1)
7458
- ), { data: b } = ie({
7469
+ ), { data: x } = ie({
7459
7470
  queryKey: ["api-keys"],
7460
- queryFn: () => _.getApiKeys()
7471
+ queryFn: () => T.getApiKeys()
7461
7472
  }), N = oe({
7462
- mutationFn: () => _.createApiKey(i.trim(), l),
7473
+ mutationFn: () => T.createApiKey(i.trim(), l),
7463
7474
  onSuccess: (v) => {
7464
- m(v.token), o(""), s.invalidateQueries({ queryKey: ["api-keys"] });
7475
+ d(v.token), o(""), s.invalidateQueries({ queryKey: ["api-keys"] });
7465
7476
  }
7466
7477
  }), y = oe({
7467
- mutationFn: (v) => _.revokeApiKey(v),
7478
+ mutationFn: (v) => T.revokeApiKey(v),
7468
7479
  onSuccess: () => s.invalidateQueries({ queryKey: ["api-keys"] })
7469
- }), T = oe({
7470
- mutationFn: (v) => _.deleteApiKey(v),
7480
+ }), D = oe({
7481
+ mutationFn: (v) => T.deleteApiKey(v),
7471
7482
  onSuccess: () => s.invalidateQueries({ queryKey: ["api-keys"] })
7472
- }), A = (v) => v.is_mine ?? v.user === (a == null ? void 0 : a.name), x = (v) => v.owner_full_name || v.owner_email || v.user || n("settings.chatApiUnknownUser"), d = Ce(() => {
7483
+ }), A = (v) => v.is_mine ?? v.user === (a == null ? void 0 : a.name), b = (v) => v.owner_full_name || v.owner_email || v.user || n("settings.chatApiUnknownUser"), u = Ce(() => {
7473
7484
  const v = /* @__PURE__ */ new Map();
7474
- for (const I of b ?? []) {
7485
+ for (const I of x ?? []) {
7475
7486
  const C = I.is_mine ?? I.user === (a == null ? void 0 : a.name), O = C ? "__me__" : I.user ?? "__unknown__";
7476
7487
  v.has(O) || v.set(O, {
7477
7488
  label: C ? n("settings.chatApiYourKeys") : I.owner_full_name || I.owner_email || I.user || n("settings.chatApiUnknownUser"),
@@ -7483,10 +7494,10 @@ function ba({ ownRole: t }) {
7483
7494
  return Array.from(v.values()).sort(
7484
7495
  (I, C) => I.isMine ? -1 : C.isMine ? 1 : I.label.localeCompare(C.label)
7485
7496
  );
7486
- }, [b, a, n]), h = (v, I) => {
7487
- I === "revoke" ? y.mutate(v) : T.mutate(v);
7488
- }, P = (v, I) => {
7489
- A(v) ? h(v.id, I) : u({ id: v.id, action: I, owner: x(v), keyName: v.name });
7497
+ }, [x, a, n]), h = (v, I) => {
7498
+ I === "revoke" ? y.mutate(v) : D.mutate(v);
7499
+ }, _ = (v, I) => {
7500
+ A(v) ? h(v.id, I) : m({ id: v.id, action: I, owner: b(v), keyName: v.name });
7490
7501
  };
7491
7502
  return /* @__PURE__ */ r("div", { children: [
7492
7503
  g && /* @__PURE__ */ r("div", { className: "mb-3 rounded-lg bg-amber-50 p-3 ring-1 ring-inset ring-amber-200", children: [
@@ -7507,13 +7518,13 @@ function ba({ ownRole: t }) {
7507
7518
  "button",
7508
7519
  {
7509
7520
  className: "ml-3 mt-2 text-xs text-fg-muted hover:underline",
7510
- onClick: () => m(null),
7521
+ onClick: () => d(null),
7511
7522
  children: n("settings.chatApiDismiss")
7512
7523
  }
7513
7524
  )
7514
7525
  ] }),
7515
7526
  t === "admin" && /* @__PURE__ */ e("p", { className: "mb-3 text-xs text-fg-muted", children: n("settings.chatApiAdminAllNote") }),
7516
- d.length > 0 ? /* @__PURE__ */ e("div", { className: "mb-4 space-y-4", children: d.map((v) => /* @__PURE__ */ r("div", { children: [
7527
+ u.length > 0 ? /* @__PURE__ */ e("div", { className: "mb-4 space-y-4", children: u.map((v) => /* @__PURE__ */ r("div", { children: [
7517
7528
  /* @__PURE__ */ r("div", { className: "mb-1.5 flex items-baseline gap-2", children: [
7518
7529
  /* @__PURE__ */ e("span", { className: "text-xs font-semibold text-fg", children: v.label }),
7519
7530
  v.isMine ? /* @__PURE__ */ e(Rt, { variant: "default", children: n("settings.chatApiYouBadge") }) : v.sublabel && /* @__PURE__ */ e("span", { className: "text-xs text-fg-muted", children: v.sublabel })
@@ -7538,8 +7549,8 @@ function ba({ ownRole: t }) {
7538
7549
  "button",
7539
7550
  {
7540
7551
  className: "shrink-0 text-xs font-medium text-red-600 hover:underline disabled:opacity-50",
7541
- onClick: () => P(I, I.revoked ? "delete" : "revoke"),
7542
- disabled: y.isPending || T.isPending,
7552
+ onClick: () => _(I, I.revoked ? "delete" : "revoke"),
7553
+ disabled: y.isPending || D.isPending,
7543
7554
  children: I.revoked ? n("settings.chatApiDelete") : n("settings.chatApiRevoke")
7544
7555
  }
7545
7556
  )
@@ -7574,7 +7585,7 @@ function ba({ ownRole: t }) {
7574
7585
  "div",
7575
7586
  {
7576
7587
  className: "fixed inset-0 z-50 flex items-center justify-center bg-black/40 p-4",
7577
- onClick: () => u(null),
7588
+ onClick: () => m(null),
7578
7589
  children: /* @__PURE__ */ r(
7579
7590
  "div",
7580
7591
  {
@@ -7589,14 +7600,14 @@ function ba({ ownRole: t }) {
7589
7600
  { name: p.owner, key: p.keyName }
7590
7601
  ) }),
7591
7602
  /* @__PURE__ */ r("div", { className: "mt-4 flex justify-end gap-2", children: [
7592
- /* @__PURE__ */ e(H, { variant: "secondary", size: "sm", onClick: () => u(null), children: n("common.cancel") }),
7603
+ /* @__PURE__ */ e(H, { variant: "secondary", size: "sm", onClick: () => m(null), children: n("common.cancel") }),
7593
7604
  /* @__PURE__ */ e(
7594
7605
  H,
7595
7606
  {
7596
7607
  variant: "danger",
7597
7608
  size: "sm",
7598
7609
  onClick: () => {
7599
- h(p.id, p.action), u(null);
7610
+ h(p.id, p.action), m(null);
7600
7611
  },
7601
7612
  children: p.action === "revoke" ? n("settings.chatApiRevoke") : n("settings.chatApiDelete")
7602
7613
  }
@@ -7666,7 +7677,7 @@ function yo({
7666
7677
  ] }),
7667
7678
  (t || n) && /* @__PURE__ */ r("div", { className: "mt-4 border-t border-gray-100 pt-4", children: [
7668
7679
  /* @__PURE__ */ e("div", { className: "mb-2 text-xs font-medium text-gray-500", children: o("settings.chatApiKeysTitle") }),
7669
- /* @__PURE__ */ e(ba, { ownRole: i })
7680
+ /* @__PURE__ */ e(xa, { ownRole: i })
7670
7681
  ] }),
7671
7682
  l && /* @__PURE__ */ e(
7672
7683
  "div",
@@ -7707,25 +7718,25 @@ function yo({
7707
7718
  function bo() {
7708
7719
  const { user: t } = st(), { t: n } = Z(), a = We(), s = (t == null ? void 0 : t.role) === "admin", { data: i, isLoading: o } = ie({
7709
7720
  queryKey: ["settings"],
7710
- queryFn: () => _.getSettings()
7721
+ queryFn: () => T.getSettings()
7711
7722
  }), l = oe({
7712
- mutationFn: (b) => _.updateSettings(b),
7723
+ mutationFn: (x) => T.updateSettings(x),
7713
7724
  onSuccess: () => a.invalidateQueries({ queryKey: ["settings"] })
7714
7725
  }), { data: c } = ie({
7715
7726
  queryKey: ["public-manager"],
7716
- queryFn: () => _.getPublicManagerStatus()
7727
+ queryFn: () => T.getPublicManagerStatus()
7717
7728
  }), { data: g } = ie({
7718
7729
  queryKey: ["health"],
7719
- queryFn: () => _.getHealth(),
7730
+ queryFn: () => T.getHealth(),
7720
7731
  staleTime: 1 / 0
7721
7732
  // version only changes on deploy
7722
- }), [m, p] = S(!1), u = oe({
7723
- mutationFn: () => _.createPublicManager(),
7733
+ }), [d, p] = S(!1), m = oe({
7734
+ mutationFn: () => T.createPublicManager(),
7724
7735
  onSuccess: () => {
7725
7736
  a.invalidateQueries({ queryKey: ["public-manager"] }), p(!1);
7726
7737
  }
7727
7738
  }), w = oe({
7728
- mutationFn: () => _.removePublicManager(),
7739
+ mutationFn: () => T.removePublicManager(),
7729
7740
  onSuccess: () => a.invalidateQueries({ queryKey: ["public-manager"] })
7730
7741
  });
7731
7742
  return o ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: n("common.loading") }) : /* @__PURE__ */ r("div", { className: "space-y-6", children: [
@@ -7742,7 +7753,7 @@ function bo() {
7742
7753
  label: n("settings.pageSize"),
7743
7754
  options: ["A4", "letter"],
7744
7755
  value: (i == null ? void 0 : i.pdf_page_size) || "A4",
7745
- onChange: (b) => l.mutate({ pdf_page_size: b.target.value })
7756
+ onChange: (x) => l.mutate({ pdf_page_size: x.target.value })
7746
7757
  }
7747
7758
  ) : /* @__PURE__ */ r("div", { children: [
7748
7759
  /* @__PURE__ */ e("div", { className: "text-xs font-medium text-gray-500 mb-1", children: n("settings.pageSize") }),
@@ -7798,7 +7809,7 @@ function bo() {
7798
7809
  ),
7799
7810
  !s && (t == null ? void 0 : t.role) !== "public_manager" && /* @__PURE__ */ r(F, { title: n("settings.chatApiKeysTitle"), children: [
7800
7811
  /* @__PURE__ */ e("p", { className: "mb-3 text-sm text-gray-700", children: n("settings.chatApiPersonal") }),
7801
- /* @__PURE__ */ e(ba, { ownRole: (t == null ? void 0 : t.role) ?? "viewer" })
7812
+ /* @__PURE__ */ e(xa, { ownRole: (t == null ? void 0 : t.role) ?? "viewer" })
7802
7813
  ] }),
7803
7814
  s && /* @__PURE__ */ e(po, { demoActive: !!(c != null && c.active) }),
7804
7815
  s && /* @__PURE__ */ e(F, { title: n("settings.publicTitle"), children: c != null && c.active ? /* @__PURE__ */ r("div", { children: [
@@ -7818,17 +7829,17 @@ function bo() {
7818
7829
  )
7819
7830
  ] }) : /* @__PURE__ */ r("div", { children: [
7820
7831
  /* @__PURE__ */ e("p", { className: "text-sm text-gray-600", children: n("settings.publicInactiveBody") }),
7821
- m ? /* @__PURE__ */ r("div", { className: "mt-3 rounded-lg border border-red-200 bg-red-50 p-4", children: [
7832
+ d ? /* @__PURE__ */ r("div", { className: "mt-3 rounded-lg border border-red-200 bg-red-50 p-4", children: [
7822
7833
  /* @__PURE__ */ e("p", { className: "text-sm font-medium text-red-800", children: n("common.areYouSure") }),
7823
7834
  /* @__PURE__ */ e("p", { className: "mt-1 text-xs text-red-600", children: n("settings.enableWarning") }),
7824
7835
  /* @__PURE__ */ r("div", { className: "mt-3 flex gap-2", children: [
7825
7836
  /* @__PURE__ */ e(
7826
7837
  "button",
7827
7838
  {
7828
- onClick: () => u.mutate(),
7829
- disabled: u.isPending,
7839
+ onClick: () => m.mutate(),
7840
+ disabled: m.isPending,
7830
7841
  className: "rounded-lg bg-red-600 px-4 py-1.5 text-sm font-medium text-white hover:bg-red-700",
7831
- children: u.isPending ? n("settings.enabling") : n("settings.yesEnable")
7842
+ children: m.isPending ? n("settings.enabling") : n("settings.yesEnable")
7832
7843
  }
7833
7844
  ),
7834
7845
  /* @__PURE__ */ e(
@@ -7852,15 +7863,15 @@ function bo() {
7852
7863
  (g == null ? void 0 : g.version) && /* @__PURE__ */ e("p", { className: "pt-2 text-center text-xs text-gray-400", children: n("settings.version", { version: g.version }) })
7853
7864
  ] });
7854
7865
  }
7855
- const va = {};
7866
+ const Na = {};
7856
7867
  function jo(t, n) {
7857
- va[t] = n;
7868
+ Na[t] = n;
7858
7869
  }
7859
7870
  function vo(t, n) {
7860
- return va[t] ?? n;
7871
+ return Na[t] ?? n;
7861
7872
  }
7862
7873
  function xo() {
7863
- const t = vo("Dashboard", Sr);
7874
+ const t = vo("Dashboard", Dr);
7864
7875
  return /* @__PURE__ */ e(t, {});
7865
7876
  }
7866
7877
  const No = [
@@ -7899,9 +7910,9 @@ const No = [
7899
7910
  // Admin
7900
7911
  { path: "admin/users", element: /* @__PURE__ */ e(Zs, {}) },
7901
7912
  { path: "admin/settings", element: /* @__PURE__ */ e(bo, {}) }
7902
- ], xa = [], Na = [];
7913
+ ], wa = [], ka = [];
7903
7914
  function ko(t, n) {
7904
- (n == null ? void 0 : n.area) === "top" ? xa.push(t) : Na.push(t);
7915
+ (n == null ? void 0 : n.area) === "top" ? wa.push(t) : ka.push(t);
7905
7916
  }
7906
7917
  const Un = (t) => t.index ? "__index__" : t.path ?? "";
7907
7918
  function Vn(t, n) {
@@ -7914,19 +7925,19 @@ function Vn(t, n) {
7914
7925
  }
7915
7926
  function So() {
7916
7927
  return [
7917
- ...Vn(No, xa),
7928
+ ...Vn(No, wa),
7918
7929
  {
7919
7930
  path: "/",
7920
- element: /* @__PURE__ */ e(vr, { children: /* @__PURE__ */ e(yr, {}) }),
7921
- children: Vn(wo, Na)
7931
+ element: /* @__PURE__ */ e(Nr, { children: /* @__PURE__ */ e(vr, {}) }),
7932
+ children: Vn(wo, ka)
7922
7933
  }
7923
7934
  ];
7924
7935
  }
7925
7936
  function Co({ slug: t, parentSlug: n, linkField: a }) {
7926
7937
  const { name: s = "" } = ut(), i = Ie();
7927
- return re(() => {
7938
+ return ae(() => {
7928
7939
  let o = !0;
7929
- return _.getDocument(t, s).then((l) => {
7940
+ return T.getDocument(t, s).then((l) => {
7930
7941
  if (!o) return;
7931
7942
  const c = l == null ? void 0 : l[a];
7932
7943
  i(c ? `/app/${n}/${c}` : `/app/${t}`, { replace: !0 });
@@ -7954,7 +7965,7 @@ async function Do() {
7954
7965
  }
7955
7966
  }
7956
7967
  function Ao() {
7957
- return new Pa({
7968
+ return new Ta({
7958
7969
  defaultOptions: {
7959
7970
  queries: { retry: 1, refetchOnWindowFocus: !1 }
7960
7971
  }
@@ -7966,29 +7977,29 @@ async function Go(t = {}) {
7966
7977
  throw new Error('bootstrap: no mount element (pass rootElement or add <div id="root">)');
7967
7978
  const a = t.queryClient ?? Ao();
7968
7979
  await Do();
7969
- const s = Ra(So());
7970
- Da(n).render(
7971
- /* @__PURE__ */ e(Ca, { children: /* @__PURE__ */ e(Aa, { client: a, children: /* @__PURE__ */ e(rr, { children: /* @__PURE__ */ e(Ia, { router: s }) }) }) })
7980
+ const s = Ba(So());
7981
+ Pa(n).render(
7982
+ /* @__PURE__ */ e(Aa, { children: /* @__PURE__ */ e(_a, { client: a, children: /* @__PURE__ */ e(ir, { children: /* @__PURE__ */ e(Ea, { router: s }) }) }) })
7972
7983
  );
7973
7984
  }
7974
7985
  export {
7975
7986
  $e as ApiError,
7976
- yr as AppShell,
7977
- rr as AuthProvider,
7978
- _r as DocPager,
7979
- fa as SUPPORTED_LANGUAGES,
7980
- _ as api,
7987
+ vr as AppShell,
7988
+ ir as AuthProvider,
7989
+ ua as DocPager,
7990
+ ba as SUPPORTED_LANGUAGES,
7991
+ T as api,
7981
7992
  Go as bootstrap,
7982
7993
  So as buildRoutes,
7983
7994
  Mo as configureApiBase,
7984
7995
  Uo as configureBranding,
7985
7996
  Ao as createAppQueryClient,
7986
7997
  Ko as getAllDoctypeConfigs,
7987
- cr as getBranding,
7998
+ ur as getBranding,
7988
7999
  vo as getComponent,
7989
- ca as getDoctypeConfig,
7990
- Dr as getListContext,
7991
- lr as getNavGroups,
8000
+ da as getDoctypeConfig,
8001
+ Ar as getListContext,
8002
+ dr as getNavGroups,
7992
8003
  co as getStoredLanguage,
7993
8004
  Qo as i18n,
7994
8005
  jo as registerComponent,
@@ -7997,7 +8008,7 @@ export {
7997
8008
  $o as registerNavItem,
7998
8009
  ko as registerRoute,
7999
8010
  B as request,
8000
- Cr as setListContext,
8011
+ ca as setListContext,
8001
8012
  st as useAuth
8002
8013
  };
8003
8014
  //# sourceMappingURL=index.js.map