@lambda-development/erp-core 0.1.29 → 0.1.30

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,14 +1,14 @@
1
1
  import { jsx as e, jsxs as r, Fragment as Se } from "react/jsx-runtime";
2
- import { useState as v, useEffect as ie, useCallback as Te, useContext as $n, createContext as Un, useRef as ee, useMemo as Ie, useLayoutEffect as cn, StrictMode as fa } from "react";
3
- import { createRoot as ba } from "react-dom/client";
4
- import { useQueryClient as We, useQuery as le, useMutation as oe, QueryClientProvider as xa, QueryClient as va } from "@tanstack/react-query";
5
- import { NavLink as Et, useLocation as Ct, useNavigate as Oe, Outlet as Na, Navigate as wa, Link as Ne, useSearchParams as Ot, useParams as ft, createBrowserRouter as ka, RouterProvider as Sa } from "react-router-dom";
6
- import { useTranslation as ae, initReactI18next as Ca } from "react-i18next";
7
- import { BookOpen as Da, ShoppingCart as Vn, CreditCard as _a, FileText as Zt, Package as jn, BarChart3 as Pa, Database as Ta, Settings as Aa, MessageCircle as Ra, ChevronDown as Xt, ChevronRight as en, Plus as Gn, Trash2 as Kn, LineChart as Ia, TrendingUp as La, ArrowDownRight as Ba, ArrowUpRight as Ea, Wallet as Oa, Receipt as dn, Info as qa } from "lucide-react";
2
+ import { useState as v, useEffect as se, useCallback as Te, useContext as $n, createContext as Un, useRef as X, useMemo as Ie, useLayoutEffect as cn, StrictMode as ba } from "react";
3
+ import { createRoot as xa } from "react-dom/client";
4
+ import { useQueryClient as We, useQuery as le, useMutation as oe, QueryClientProvider as va, QueryClient as Na } from "@tanstack/react-query";
5
+ import { NavLink as Et, useLocation as Ct, useNavigate as Oe, Outlet as wa, Navigate as ka, Link as Ne, useSearchParams as Ot, useParams as ft, createBrowserRouter as Sa, RouterProvider as Ca } from "react-router-dom";
6
+ import { useTranslation as ae, initReactI18next as Da } from "react-i18next";
7
+ import { BookOpen as _a, ShoppingCart as Vn, CreditCard as Pa, FileText as Zt, Package as jn, BarChart3 as Ta, Database as Aa, Settings as Ra, MessageCircle as Ia, ChevronDown as Xt, ChevronRight as en, Plus as Gn, Trash2 as Kn, LineChart as La, TrendingUp as Ba, ArrowDownRight as Ea, ArrowUpRight as Oa, Wallet as qa, Receipt as dn, Info as Fa } from "lucide-react";
8
8
  import { createColumnHelper as Wn, useReactTable as Hn, getCoreRowModel as Qn, flexRender as Rt } from "@tanstack/react-table";
9
- import { createPortal as Fa } from "react-dom";
9
+ import { createPortal as Jn } from "react-dom";
10
10
  import { ResponsiveContainer as Ma, LineChart as za, CartesianGrid as un, XAxis as mn, YAxis as pn, Tooltip as zt, Line as $a, PieChart as Ua, Pie as Va, Cell as ja, BarChart as Ga, Bar as Ka } from "recharts";
11
- import Jn from "i18next";
11
+ import Yn from "i18next";
12
12
  import { default as wo } from "i18next";
13
13
  let yt = "/api";
14
14
  function uo(t) {
@@ -202,17 +202,17 @@ const L = {
202
202
  getSettings: () => O("/auth/settings"),
203
203
  updateSettings: (t) => O("/auth/settings", { method: "PUT", body: JSON.stringify(t) }),
204
204
  getDemoSpend: () => O("/admin/demo-spend")
205
- }, Yn = Un(null);
205
+ }, Zn = Un(null);
206
206
  function Ha({ children: t }) {
207
207
  const [n, a] = v(null), [s, o] = v(!0);
208
- ie(() => {
209
- L.authMe().then((g) => a(g)).catch(() => a(null)).finally(() => o(!1));
208
+ se(() => {
209
+ L.authMe().then((y) => a(y)).catch(() => a(null)).finally(() => o(!1));
210
210
  }, []);
211
- const i = Te(async (g, d) => {
212
- const p = await L.authLogin(g, d);
211
+ const i = Te(async (y, d) => {
212
+ const p = await L.authLogin(y, d);
213
213
  return a(p), p;
214
- }, []), c = Te(async (g, d, p, m) => {
215
- const f = await L.authRegister({ email: g, full_name: d, password: p, invite_token: m });
214
+ }, []), c = Te(async (y, d, p, m) => {
215
+ const f = await L.authRegister({ email: y, full_name: d, password: p, invite_token: m });
216
216
  return a(f), f;
217
217
  }, []), l = Te(async () => {
218
218
  try {
@@ -221,14 +221,14 @@ function Ha({ children: t }) {
221
221
  }
222
222
  a(null);
223
223
  }, []);
224
- return /* @__PURE__ */ e(Yn.Provider, { value: { user: n, loading: s, login: i, register: c, logout: l }, children: t });
224
+ return /* @__PURE__ */ e(Zn.Provider, { value: { user: n, loading: s, login: i, register: c, logout: l }, children: t });
225
225
  }
226
226
  function bt() {
227
- const t = $n(Yn);
227
+ const t = $n(Zn);
228
228
  if (!t) throw new Error("useAuth must be used within AuthProvider");
229
229
  return t;
230
230
  }
231
- const Zn = Un(null), hn = {
231
+ const Xn = Un(null), hn = {
232
232
  quotation: { group: "Selling", item: "Quotation" },
233
233
  "sales-order": { group: "Selling", item: "Sales Order" },
234
234
  "sales-invoice": { group: "Selling", item: "Sales Invoice" },
@@ -277,11 +277,11 @@ function yn(t) {
277
277
  attachments: t.attachments
278
278
  };
279
279
  }
280
- const Xn = "lambda-erp:known-chat-sessions";
280
+ const ea = "lambda-erp:known-chat-sessions";
281
281
  function tn() {
282
282
  if (typeof localStorage > "u") return /* @__PURE__ */ new Set();
283
283
  try {
284
- const t = localStorage.getItem(Xn);
284
+ const t = localStorage.getItem(ea);
285
285
  if (!t) return /* @__PURE__ */ new Set();
286
286
  const n = JSON.parse(t);
287
287
  return new Set(Array.isArray(n) ? n.filter((a) => typeof a == "string") : []);
@@ -289,20 +289,20 @@ function tn() {
289
289
  return /* @__PURE__ */ new Set();
290
290
  }
291
291
  }
292
- function ea(t) {
292
+ function ta(t) {
293
293
  if (!(typeof localStorage > "u"))
294
294
  try {
295
- localStorage.setItem(Xn, JSON.stringify([...t]));
295
+ localStorage.setItem(ea, JSON.stringify([...t]));
296
296
  } catch {
297
297
  }
298
298
  }
299
- function ta(t) {
299
+ function na(t) {
300
300
  const n = tn();
301
- n.has(t) || (n.add(t), ea(n));
301
+ n.has(t) || (n.add(t), ta(n));
302
302
  }
303
303
  function fn(t) {
304
304
  const n = tn();
305
- n.delete(t) && ea(n);
305
+ n.delete(t) && ta(n);
306
306
  }
307
307
  function Ja() {
308
308
  return typeof crypto < "u" && typeof crypto.randomUUID == "function" ? crypto.randomUUID() : `req-${Date.now()}-${Math.random().toString(36).slice(2, 10)}`;
@@ -313,7 +313,7 @@ function et(t) {
313
313
  return Number.isNaN(a) ? 0 : a;
314
314
  }
315
315
  function Ya({ children: t }) {
316
- const n = We(), [a, s] = v([]), [o, i] = v({}), [c, l] = v({}), [g, d] = v({}), [p, m] = v({}), [f, S] = v({}), [x, y] = v({}), [P, D] = v({}), [T, u] = v(null), [h, A] = v("connecting"), [R, k] = v(0), H = ee(null), $ = ee(null), z = ee(/* @__PURE__ */ new Map()), w = ee(null), K = ee({}), N = ee({}), B = ee(null);
316
+ const n = We(), [a, s] = v([]), [o, i] = v({}), [c, l] = v({}), [y, d] = v({}), [p, m] = v({}), [f, w] = v({}), [b, g] = v({}), [P, D] = v({}), [T, u] = v(null), [h, A] = v("connecting"), [R, S] = v(0), H = X(null), $ = X(null), z = X(/* @__PURE__ */ new Map()), k = X(null), K = X({}), N = X({}), B = X(null);
317
317
  function C(_) {
318
318
  for (const V of z.current.values())
319
319
  V.reject(new Error(_));
@@ -326,10 +326,10 @@ function Ya({ children: t }) {
326
326
  }));
327
327
  }
328
328
  function Z(_, V) {
329
- S((W) => ({ ...W, [_]: V }));
329
+ w((W) => ({ ...W, [_]: V }));
330
330
  }
331
331
  function re(_, V) {
332
- y((W) => ({ ...W, [_]: V }));
332
+ g((W) => ({ ...W, [_]: V }));
333
333
  }
334
334
  function he(_, V) {
335
335
  D((W) => ({ ...W, [_]: V }));
@@ -382,7 +382,7 @@ function Ya({ children: t }) {
382
382
  }
383
383
  });
384
384
  }
385
- ie(() => {
385
+ se(() => {
386
386
  let _ = !1;
387
387
  function V() {
388
388
  if (_) return;
@@ -393,7 +393,7 @@ function Ya({ children: t }) {
393
393
  xe.close();
394
394
  return;
395
395
  }
396
- A("connected"), k((De) => De + 1);
396
+ A("connected"), S((De) => De + 1);
397
397
  }, xe.onmessage = (De) => {
398
398
  var it;
399
399
  try {
@@ -413,16 +413,16 @@ function Ya({ children: t }) {
413
413
  Ee.length > 0 && Promise.all(
414
414
  Ee.map(async (ve) => {
415
415
  try {
416
- const se = await L.getChatSession(ve);
417
- return !se || se.detail || !se.id ? (fn(ve), null) : se;
416
+ const ie = await L.getChatSession(ve);
417
+ return !ie || ie.detail || !ie.id ? (fn(ve), null) : ie;
418
418
  } catch {
419
419
  return null;
420
420
  }
421
421
  })
422
422
  ).then((ve) => {
423
- const se = ve.filter((de) => !!de);
424
- se.length && (ze(se), me((de) => [
425
- ...se.filter((pt) => !de.some((vt) => vt.id === pt.id)),
423
+ const ie = ve.filter((de) => !!de);
424
+ ie.length && (ze(ie), me((de) => [
425
+ ...ie.filter((pt) => !de.some((vt) => vt.id === pt.id)),
426
426
  ...de
427
427
  ]));
428
428
  });
@@ -431,17 +431,17 @@ function Ya({ children: t }) {
431
431
  if (ue === "session_created") {
432
432
  const q = j.session;
433
433
  if (!q) return;
434
- ta(q.id), ze([q]), me((G) => [q, ...G.filter((Q) => Q.id !== q.id)]);
434
+ na(q.id), ze([q]), me((G) => [q, ...G.filter((Q) => Q.id !== q.id)]);
435
435
  return;
436
436
  }
437
437
  if (ue === "session_deleted" && E) {
438
438
  fn(E), me((G) => G.filter((Q) => Q.id !== E)), i((G) => {
439
439
  const Q = { ...G };
440
440
  return delete Q[E], Q;
441
- }), S((G) => {
441
+ }), w((G) => {
442
442
  const Q = { ...G };
443
443
  return delete Q[E], Q;
444
- }), y((G) => {
444
+ }), g((G) => {
445
445
  const Q = { ...G };
446
446
  return delete Q[E], Q;
447
447
  }), D((G) => {
@@ -463,23 +463,23 @@ function Ya({ children: t }) {
463
463
  }
464
464
  if (ue === "history_loaded" && E) {
465
465
  const q = Array.isArray(j.messages) ? j.messages.map(yn) : [], G = j.before_id != null, Q = !!j.has_more, Ee = typeof j.oldest_id == "number" ? j.oldest_id : null;
466
- i((se) => {
466
+ i((ie) => {
467
467
  if (G) {
468
- const de = se[E] ?? [], pt = new Set(
468
+ const de = ie[E] ?? [], pt = new Set(
469
469
  de.map((Ze) => Ze.id).filter((Ze) => typeof Ze == "number")
470
470
  ), vt = q.filter(
471
471
  (Ze) => Ze.id === void 0 || !pt.has(Ze.id)
472
472
  );
473
- return { ...se, [E]: [...vt, ...de] };
473
+ return { ...ie, [E]: [...vt, ...de] };
474
474
  }
475
- return { ...se, [E]: q };
476
- }), l((se) => ({ ...se, [E]: Q })), d((se) => ({ ...se, [E]: Ee })), m((se) => ({ ...se, [E]: !1 }));
475
+ return { ...ie, [E]: q };
476
+ }), l((ie) => ({ ...ie, [E]: Q })), d((ie) => ({ ...ie, [E]: Ee })), m((ie) => ({ ...ie, [E]: !1 }));
477
477
  const ve = typeof j.title == "string" ? j.title : null;
478
478
  if (ve && me(
479
- (se) => se.map((de) => de.id === E ? { ...de, title: ve } : de)
479
+ (ie) => ie.map((de) => de.id === E ? { ...de, title: ve } : de)
480
480
  ), !G) {
481
- const se = q[q.length - 1];
482
- se != null && se.timestamp && (ye(E, se.timestamp), me((de) => de));
481
+ const ie = q[q.length - 1];
482
+ ie != null && ie.timestamp && (ye(E, ie.timestamp), me((de) => de));
483
483
  }
484
484
  return;
485
485
  }
@@ -633,12 +633,12 @@ function Ya({ children: t }) {
633
633
  };
634
634
  }, []);
635
635
  async function Ae() {
636
- if (w.current)
637
- return w.current;
636
+ if (k.current)
637
+ return k.current;
638
638
  const _ = te("create_session", {}, "session_created").then((V) => V.session).finally(() => {
639
- w.current === _ && (w.current = null);
639
+ k.current === _ && (k.current = null);
640
640
  });
641
- return w.current = _, _;
641
+ return k.current = _, _;
642
642
  }
643
643
  async function Ce(_) {
644
644
  re(_, "running"), he(_, null);
@@ -662,7 +662,7 @@ function Ya({ children: t }) {
662
662
  }
663
663
  async function dt(_) {
664
664
  if (p[_]) return;
665
- const V = g[_];
665
+ const V = y[_];
666
666
  if (V != null && c[_]) {
667
667
  m((W) => ({ ...W, [_]: !0 }));
668
668
  try {
@@ -717,13 +717,13 @@ function Ya({ children: t }) {
717
717
  return _ ? !!p[_] : !1;
718
718
  }
719
719
  function st(_) {
720
- return _ ? x[_] ?? "idle" : "idle";
720
+ return _ ? b[_] ?? "idle" : "idle";
721
721
  }
722
722
  function mt(_) {
723
723
  return _ ? P[_] ?? null : null;
724
724
  }
725
725
  return /* @__PURE__ */ e(
726
- Zn.Provider,
726
+ Xn.Provider,
727
727
  {
728
728
  value: {
729
729
  sessions: a,
@@ -751,7 +751,7 @@ function Ya({ children: t }) {
751
751
  );
752
752
  }
753
753
  function ct() {
754
- const t = $n(Zn);
754
+ const t = $n(Xn);
755
755
  if (!t)
756
756
  throw new Error("useChat must be used within ChatProvider.");
757
757
  return t;
@@ -759,7 +759,7 @@ function ct() {
759
759
  const lt = [
760
760
  {
761
761
  label: "Introduction",
762
- icon: /* @__PURE__ */ e(Da, { className: "h-4 w-4" }),
762
+ icon: /* @__PURE__ */ e(_a, { className: "h-4 w-4" }),
763
763
  items: [
764
764
  { label: "Getting Started", path: "/tutorial" },
765
765
  { label: "Company Setup", path: "/setup" },
@@ -779,7 +779,7 @@ const lt = [
779
779
  },
780
780
  {
781
781
  label: "Buying",
782
- icon: /* @__PURE__ */ e(_a, { className: "h-4 w-4" }),
782
+ icon: /* @__PURE__ */ e(Pa, { className: "h-4 w-4" }),
783
783
  items: [
784
784
  { label: "Purchase Order", path: "/app/purchase-order" },
785
785
  { label: "Purchase Invoice", path: "/app/purchase-invoice" }
@@ -807,7 +807,7 @@ const lt = [
807
807
  },
808
808
  {
809
809
  label: "Reports",
810
- icon: /* @__PURE__ */ e(Pa, { className: "h-4 w-4" }),
810
+ icon: /* @__PURE__ */ e(Ta, { className: "h-4 w-4" }),
811
811
  items: [
812
812
  { label: "Trial Balance", path: "/reports/trial-balance" },
813
813
  { label: "Profit & Loss", path: "/reports/profit-and-loss" },
@@ -821,7 +821,7 @@ const lt = [
821
821
  },
822
822
  {
823
823
  label: "Masters",
824
- icon: /* @__PURE__ */ e(Ta, { className: "h-4 w-4" }),
824
+ icon: /* @__PURE__ */ e(Aa, { className: "h-4 w-4" }),
825
825
  items: [
826
826
  { label: "Company", path: "/masters/company" },
827
827
  { label: "Customer", path: "/masters/customer" },
@@ -832,7 +832,7 @@ const lt = [
832
832
  },
833
833
  {
834
834
  label: "Settings",
835
- icon: /* @__PURE__ */ e(Aa, { className: "h-4 w-4" }),
835
+ icon: /* @__PURE__ */ e(Ra, { className: "h-4 w-4" }),
836
836
  items: [
837
837
  { label: "General", path: "/admin/settings" },
838
838
  { label: "Pricing Rule", path: "/app/pricing-rule" },
@@ -893,17 +893,17 @@ function Me(t, n) {
893
893
  const a = parseFloat(String(t ?? 0)) || 0;
894
894
  return n !== void 0 ? parseFloat(a.toFixed(n)) : a;
895
895
  }
896
- const na = "sidebar-collapsed";
896
+ const aa = "sidebar-collapsed";
897
897
  function Ut() {
898
898
  try {
899
- const t = localStorage.getItem(na);
899
+ const t = localStorage.getItem(aa);
900
900
  return t ? new Set(JSON.parse(t)) : /* @__PURE__ */ new Set();
901
901
  } catch {
902
902
  return /* @__PURE__ */ new Set();
903
903
  }
904
904
  }
905
905
  function bn(t) {
906
- localStorage.setItem(na, JSON.stringify([...t]));
906
+ localStorage.setItem(aa, JSON.stringify([...t]));
907
907
  }
908
908
  function nn(t) {
909
909
  const [n, a] = v(() => !Ut().has(t)), s = Te(() => {
@@ -932,7 +932,7 @@ const an = {
932
932
  "Custom Analytics": "bg-indigo-300 text-indigo-950 ring-2 ring-inset ring-indigo-100"
933
933
  };
934
934
  function er() {
935
- const [t, n] = nn("chats"), a = Ct(), s = Oe(), { t: o } = ae(), { sessions: i, createSession: c, deleteSession: l } = ct(), g = async () => {
935
+ const [t, n] = nn("chats"), a = Ct(), s = Oe(), { t: o } = ae(), { sessions: i, createSession: c, deleteSession: l } = ct(), y = async () => {
936
936
  try {
937
937
  const p = await c();
938
938
  s(`/chat/${p.id}`);
@@ -953,7 +953,7 @@ function er() {
953
953
  onClick: n,
954
954
  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",
955
955
  children: [
956
- /* @__PURE__ */ e(Ra, { className: "h-4 w-4" }),
956
+ /* @__PURE__ */ e(Ia, { className: "h-4 w-4" }),
957
957
  /* @__PURE__ */ e("span", { className: "flex-1 text-left", children: o("nav.chats") }),
958
958
  t ? /* @__PURE__ */ e(Xt, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ e(en, { className: "h-3.5 w-3.5" })
959
959
  ]
@@ -963,7 +963,7 @@ function er() {
963
963
  /* @__PURE__ */ e("li", { children: /* @__PURE__ */ r(
964
964
  "button",
965
965
  {
966
- onClick: g,
966
+ onClick: y,
967
967
  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",
968
968
  children: [
969
969
  /* @__PURE__ */ e(Gn, { className: "h-3.5 w-3.5" }),
@@ -1010,25 +1010,25 @@ function rn() {
1010
1010
  );
1011
1011
  }
1012
1012
  function tr() {
1013
- const [t, n, a] = nn("custom-analytics"), s = Ct(), o = Oe(), i = We(), { t: c } = ae(), { navigationFlash: l, sessions: g, createSession: d } = ct(), p = (l == null ? void 0 : l.group) === "Custom Analytics", m = an["Custom Analytics"], { data: f } = le({
1013
+ const [t, n, a] = nn("custom-analytics"), s = Ct(), o = Oe(), i = We(), { t: c } = ae(), { navigationFlash: l, sessions: y, createSession: d } = ct(), p = (l == null ? void 0 : l.group) === "Custom Analytics", m = an["Custom Analytics"], { data: f } = le({
1014
1014
  queryKey: ["runtime-drafts"],
1015
1015
  queryFn: () => L.listRuntimeDrafts(),
1016
1016
  staleTime: 3e4
1017
- }), S = (f == null ? void 0 : f.drafts) ?? [];
1018
- ie(() => {
1017
+ }), w = (f == null ? void 0 : f.drafts) ?? [];
1018
+ se(() => {
1019
1019
  (l == null ? void 0 : l.group) === "Custom Analytics" && (a(), i.invalidateQueries({ queryKey: ["runtime-drafts"] }));
1020
1020
  }, [l == null ? void 0 : l.key, i, a]);
1021
- const x = oe({
1021
+ const b = oe({
1022
1022
  mutationFn: (D) => L.deleteRuntimeDraft(D),
1023
1023
  onSuccess: (D, T) => {
1024
1024
  i.invalidateQueries({ queryKey: ["runtime-drafts"] }), s.search.includes(`report_id=${T}`) && o("/reports/analytics");
1025
1025
  }
1026
- }), y = async (D, T) => {
1027
- D.preventDefault(), D.stopPropagation(), x.mutate(T);
1026
+ }), g = async (D, T) => {
1027
+ D.preventDefault(), D.stopPropagation(), b.mutate(T);
1028
1028
  }, P = async () => {
1029
1029
  var u;
1030
1030
  const D = "Build me a custom analytics report: <describe what you want — e.g. top 10 customers by revenue for the last quarter, or monthly purchases trend by supplier>";
1031
- let T = ((u = g[0]) == null ? void 0 : u.id) || "";
1031
+ let T = ((u = y[0]) == null ? void 0 : u.id) || "";
1032
1032
  if (!T)
1033
1033
  try {
1034
1034
  T = (await d()).id;
@@ -1049,7 +1049,7 @@ function tr() {
1049
1049
  p && m
1050
1050
  ),
1051
1051
  children: [
1052
- /* @__PURE__ */ e(Ia, { className: "h-4 w-4" }),
1052
+ /* @__PURE__ */ e(La, { className: "h-4 w-4" }),
1053
1053
  /* @__PURE__ */ e("span", { className: "flex-1 text-left", children: c("nav.customAnalytics") }),
1054
1054
  t ? /* @__PURE__ */ e(Xt, { className: "h-3.5 w-3.5" }) : /* @__PURE__ */ e(en, { className: "h-3.5 w-3.5" })
1055
1055
  ]
@@ -1067,7 +1067,7 @@ function tr() {
1067
1067
  ]
1068
1068
  }
1069
1069
  ) }),
1070
- S.map((D) => {
1070
+ w.map((D) => {
1071
1071
  const T = `/reports/analytics?report_id=${D.id}`, u = s.pathname === "/reports/analytics" && s.search.includes(`report_id=${D.id}`), h = (l == null ? void 0 : l.group) === "Custom Analytics" && (l == null ? void 0 : l.item) === D.id;
1072
1072
  return /* @__PURE__ */ r("li", { className: "group relative", children: [
1073
1073
  /* @__PURE__ */ e(
@@ -1088,7 +1088,7 @@ function tr() {
1088
1088
  /* @__PURE__ */ e(
1089
1089
  "button",
1090
1090
  {
1091
- onClick: (A) => y(A, D.id),
1091
+ onClick: (A) => g(A, D.id),
1092
1092
  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",
1093
1093
  title: c("nav.deleteReport"),
1094
1094
  children: /* @__PURE__ */ e(Kn, { className: "h-3.5 w-3.5" })
@@ -1119,14 +1119,14 @@ function nr({ group: t }) {
1119
1119
  }
1120
1120
  ),
1121
1121
  n && /* @__PURE__ */ e("ul", { className: "mb-1", children: t.items.map((l) => {
1122
- const g = t.items.some(
1122
+ const y = t.items.some(
1123
1123
  (d) => d.path !== l.path && d.path.startsWith(l.path + "/")
1124
1124
  );
1125
1125
  return /* @__PURE__ */ e("li", { className: "relative", children: /* @__PURE__ */ e(
1126
1126
  Et,
1127
1127
  {
1128
1128
  to: l.path,
1129
- end: g,
1129
+ end: y,
1130
1130
  className: ({ isActive: d }) => Le(
1131
1131
  "relative block px-4 py-1.5 pl-10 text-sm transition-all duration-300",
1132
1132
  !d && "text-fg-muted hover:bg-surface-subtle hover:text-fg",
@@ -1208,7 +1208,7 @@ function rr({ isMobileOpen: t = !1, onClose: n }) {
1208
1208
  /* @__PURE__ */ r("nav", { className: "flex-1 overflow-y-auto py-3", children: [
1209
1209
  /* @__PURE__ */ e(er, {}),
1210
1210
  /* @__PURE__ */ e(tr, {}),
1211
- c.map((g) => /* @__PURE__ */ e(nr, { group: g }, g.label))
1211
+ c.map((y) => /* @__PURE__ */ e(nr, { group: y }, y.label))
1212
1212
  ] })
1213
1213
  ]
1214
1214
  }
@@ -1239,10 +1239,10 @@ function ir() {
1239
1239
  }
1240
1240
  function or() {
1241
1241
  const { pathname: t } = Ct(), { user: n, logout: a } = bt(), { navigationFlash: s } = ct(), { t: o } = ae(), i = sr(t, o), [c, l] = v(!1);
1242
- ie(() => {
1242
+ se(() => {
1243
1243
  l(!1);
1244
1244
  }, [t]);
1245
- const g = s ? an[s.group] : null;
1245
+ const y = s ? an[s.group] : null;
1246
1246
  return /* @__PURE__ */ r("div", { className: "flex h-dvh bg-surface-muted", children: [
1247
1247
  /* @__PURE__ */ e(rr, { isMobileOpen: c, onClose: () => l(!1) }),
1248
1248
  c && /* @__PURE__ */ e(
@@ -1262,7 +1262,7 @@ function or() {
1262
1262
  onClick: () => l(!0),
1263
1263
  className: Le(
1264
1264
  "rounded p-1 text-gray-500 transition-all duration-300 hover:bg-gray-100 hover:text-gray-900 md:hidden",
1265
- g
1265
+ y
1266
1266
  ),
1267
1267
  "aria-label": o("header.openMenu"),
1268
1268
  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" }) })
@@ -1285,13 +1285,13 @@ function or() {
1285
1285
  )
1286
1286
  ] })
1287
1287
  ] }),
1288
- /* @__PURE__ */ e("main", { className: "flex-1 overflow-auto p-4 md:p-6", children: /* @__PURE__ */ e(Na, {}) })
1288
+ /* @__PURE__ */ e("main", { className: "flex-1 overflow-auto p-4 md:p-6", children: /* @__PURE__ */ e(wa, {}) })
1289
1289
  ] })
1290
1290
  ] });
1291
1291
  }
1292
1292
  function lr({ children: t }) {
1293
1293
  const { user: n, loading: a } = bt();
1294
- 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(Se, { children: t }) : /* @__PURE__ */ e(wa, { to: "/login", replace: !0 });
1294
+ 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(Se, { children: t }) : /* @__PURE__ */ e(ka, { to: "/login", replace: !0 });
1295
1295
  }
1296
1296
  function U({ title: t, children: n, className: a, interactive: s }) {
1297
1297
  return /* @__PURE__ */ r(
@@ -1392,7 +1392,7 @@ function Pt() {
1392
1392
  const mr = {
1393
1393
  "Sales Invoice": dn,
1394
1394
  "Purchase Invoice": dn,
1395
- "Payment Entry": Oa,
1395
+ "Payment Entry": qa,
1396
1396
  "Sales Order": Vn,
1397
1397
  Quotation: Zt
1398
1398
  };
@@ -1443,7 +1443,7 @@ function hr() {
1443
1443
  {
1444
1444
  title: t("dashboard.totalRevenue"),
1445
1445
  value: n == null ? void 0 : n.total_revenue,
1446
- icon: La,
1446
+ icon: Ba,
1447
1447
  tone: "text-emerald-600 bg-emerald-500/10"
1448
1448
  }
1449
1449
  ),
@@ -1452,7 +1452,7 @@ function hr() {
1452
1452
  {
1453
1453
  title: t("dashboard.outstandingReceivable"),
1454
1454
  value: n == null ? void 0 : n.outstanding_receivable,
1455
- icon: Ba,
1455
+ icon: Ea,
1456
1456
  tone: "text-sky-600 bg-sky-500/10"
1457
1457
  }
1458
1458
  ),
@@ -1461,7 +1461,7 @@ function hr() {
1461
1461
  {
1462
1462
  title: t("dashboard.outstandingPayable"),
1463
1463
  value: n == null ? void 0 : n.outstanding_payable,
1464
- icon: Ea,
1464
+ icon: Oa,
1465
1465
  tone: "text-amber-600 bg-amber-500/10"
1466
1466
  }
1467
1467
  ),
@@ -1522,8 +1522,8 @@ function ne(t, n) {
1522
1522
  const c = Te(
1523
1523
  (l) => {
1524
1524
  s(
1525
- (g) => {
1526
- const d = new URLSearchParams(g);
1525
+ (y) => {
1526
+ const d = new URLSearchParams(y);
1527
1527
  return l === n || l === "" || l == null ? d.delete(t) : d.set(t, String(l)), d;
1528
1528
  },
1529
1529
  { replace: !0 }
@@ -2177,7 +2177,7 @@ const at = [
2177
2177
  conversions: []
2178
2178
  }
2179
2179
  };
2180
- function aa(t) {
2180
+ function ra(t) {
2181
2181
  return on[t];
2182
2182
  }
2183
2183
  function go(t) {
@@ -2230,7 +2230,7 @@ function J({
2230
2230
  }
2231
2231
  );
2232
2232
  }
2233
- function X({ label: t, hint: n, error: a, className: s, id: o, ...i }) {
2233
+ function ee({ label: t, hint: n, error: a, className: s, id: o, ...i }) {
2234
2234
  const c = o || (t ? t.toLowerCase().replace(/\s+/g, "-") : void 0);
2235
2235
  return /* @__PURE__ */ r("div", { children: [
2236
2236
  t && /* @__PURE__ */ e(
@@ -2309,8 +2309,8 @@ function rt({ label: t, options: n, value: a, onChange: s, className: o, require
2309
2309
  ),
2310
2310
  children: [
2311
2311
  /* @__PURE__ */ e("option", { value: "", children: "Select..." }),
2312
- n.map((g) => {
2313
- const { value: d, label: p } = xr(g);
2312
+ n.map((y) => {
2313
+ const { value: d, label: p } = xr(y);
2314
2314
  return /* @__PURE__ */ e("option", { value: d, children: p }, d);
2315
2315
  })
2316
2316
  ]
@@ -2363,7 +2363,7 @@ function Nr() {
2363
2363
  className: "inline-flex h-4 w-4 items-center justify-center rounded-full text-fg-muted hover:text-fg",
2364
2364
  onClick: () => a((o) => !o),
2365
2365
  "aria-label": t("notesMarkup.title", { defaultValue: "Formatting help" }),
2366
- children: /* @__PURE__ */ e(qa, { className: "h-3.5 w-3.5" })
2366
+ children: /* @__PURE__ */ e(Fa, { className: "h-3.5 w-3.5" })
2367
2367
  }
2368
2368
  ),
2369
2369
  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: [
@@ -2412,40 +2412,62 @@ function Sr({
2412
2412
  disabled: s,
2413
2413
  hideLabel: o
2414
2414
  }) {
2415
- const [i, c] = v(n ?? ""), [l, g] = v(!1), { data: d } = le({
2415
+ const [i, c] = v(n ?? ""), [l, y] = v(!1), d = X(null), [p, m] = v(null), { data: f } = le({
2416
2416
  queryKey: ["link-search", t.linkDoctype, i],
2417
2417
  queryFn: () => L.searchLink(t.linkDoctype, i),
2418
2418
  enabled: !!t.linkDoctype && l
2419
2419
  });
2420
- return ie(() => {
2420
+ return se(() => {
2421
2421
  c(n ?? "");
2422
- }, [n]), s ? /* @__PURE__ */ r("div", { children: [
2422
+ }, [n]), se(() => {
2423
+ if (!l) return;
2424
+ const w = () => {
2425
+ const b = d.current;
2426
+ if (b) {
2427
+ const g = b.getBoundingClientRect();
2428
+ m({ top: g.bottom, left: g.left, width: g.width });
2429
+ }
2430
+ };
2431
+ return w(), window.addEventListener("scroll", w, !0), window.addEventListener("resize", w), () => {
2432
+ window.removeEventListener("scroll", w, !0), window.removeEventListener("resize", w);
2433
+ };
2434
+ }, [l]), s ? /* @__PURE__ */ r("div", { children: [
2423
2435
  !o && /* @__PURE__ */ e("label", { className: "mb-1.5 block text-sm font-medium text-fg", children: t.label }),
2424
2436
  /* @__PURE__ */ e("p", { className: "py-2 text-sm text-fg", children: n || "-" })
2425
- ] }) : /* @__PURE__ */ r("div", { className: "relative", children: [
2437
+ ] }) : /* @__PURE__ */ r("div", { className: "relative", ref: d, children: [
2426
2438
  /* @__PURE__ */ e(
2427
- X,
2439
+ ee,
2428
2440
  {
2429
2441
  label: o ? void 0 : t.label,
2430
2442
  value: i,
2431
- onChange: (p) => {
2432
- c(p.target.value), g(!0);
2443
+ onChange: (w) => {
2444
+ c(w.target.value), y(!0);
2433
2445
  },
2434
- onFocus: () => g(!0),
2435
- onBlur: () => setTimeout(() => g(!1), 200)
2446
+ onFocus: () => y(!0),
2447
+ onBlur: () => setTimeout(() => y(!1), 200)
2436
2448
  }
2437
2449
  ),
2438
- l && d && d.length > 0 && /* @__PURE__ */ e("ul", { className: "absolute z-10 mt-1 max-h-40 w-full overflow-auto rounded-lg bg-surface ring-1 ring-line shadow-card-hover", children: d.map((p) => /* @__PURE__ */ e(
2439
- "li",
2440
- {
2441
- className: "cursor-pointer px-3 py-2 text-sm text-fg transition-colors hover:bg-surface-subtle",
2442
- onMouseDown: () => {
2443
- a(p.name), c(p.name), g(!1);
2444
- },
2445
- children: p.name
2446
- },
2447
- p.name
2448
- )) })
2450
+ l && f && f.length > 0 && p && Jn(
2451
+ /* @__PURE__ */ e(
2452
+ "ul",
2453
+ {
2454
+ className: "fixed z-50 mt-1 max-h-40 overflow-auto rounded-lg bg-surface ring-1 ring-line shadow-card-hover",
2455
+ style: { top: p.top, left: p.left, width: p.width },
2456
+ children: f.map((w) => /* @__PURE__ */ e(
2457
+ "li",
2458
+ {
2459
+ className: "cursor-pointer px-3 py-2 text-sm text-fg transition-colors hover:bg-surface-subtle",
2460
+ onMouseDown: () => {
2461
+ a(w.name), c(w.name), y(!1);
2462
+ },
2463
+ children: w.name
2464
+ },
2465
+ w.name
2466
+ ))
2467
+ }
2468
+ ),
2469
+ document.body
2470
+ )
2449
2471
  ] });
2450
2472
  }
2451
2473
  function At({
@@ -2457,11 +2479,11 @@ function At({
2457
2479
  hideLabel: i,
2458
2480
  currency: c = "USD"
2459
2481
  }) {
2460
- var S;
2461
- const { t: l } = ae(), g = s || !!t.readOnly, d = () => i ? null : /* @__PURE__ */ e(vn, { label: l(`fields.${t.label}`, { defaultValue: t.label }), hint: t.hint }), p = t.type === "select" && t.optionsSource === "currency", m = wr(void 0, p);
2462
- if (g) {
2482
+ var w;
2483
+ const { t: l } = ae(), y = s || !!t.readOnly, d = () => i ? null : /* @__PURE__ */ e(vn, { label: l(`fields.${t.label}`, { defaultValue: t.label }), hint: t.hint }), p = t.type === "select" && t.optionsSource === "currency", m = wr(void 0, p);
2484
+ if (y) {
2463
2485
  if (t.type === "link" && n) {
2464
- const y = t.linkDoctypeField && o ? String(o[t.linkDoctypeField] ?? "").toLowerCase().replace(/\s+/g, "-") : t.linkDoctype, P = Qt(y, String(n));
2486
+ const g = t.linkDoctypeField && o ? String(o[t.linkDoctypeField] ?? "").toLowerCase().replace(/\s+/g, "-") : t.linkDoctype, P = Qt(g, String(n));
2465
2487
  if (P)
2466
2488
  return /* @__PURE__ */ r("div", { children: [
2467
2489
  /* @__PURE__ */ e(d, {}),
@@ -2475,51 +2497,51 @@ function At({
2475
2497
  ) })
2476
2498
  ] });
2477
2499
  }
2478
- let x = n ?? "-";
2479
- return t.type === "currency" && typeof n == "number" && (x = qe(n, c)), /* @__PURE__ */ r("div", { children: [
2500
+ let b = n ?? "-";
2501
+ return t.type === "currency" && typeof n == "number" && (b = qe(n, c)), /* @__PURE__ */ r("div", { children: [
2480
2502
  /* @__PURE__ */ e(d, {}),
2481
- /* @__PURE__ */ e("p", { className: i ? "text-sm text-fg" : "py-2 text-sm text-fg", children: x })
2503
+ /* @__PURE__ */ e("p", { className: i ? "text-sm text-fg" : "py-2 text-sm text-fg", children: b })
2482
2504
  ] });
2483
2505
  }
2484
2506
  if (t.type === "link") {
2485
- const x = t.linkDoctypeField && o ? { ...t, linkDoctype: (S = o[t.linkDoctypeField]) == null ? void 0 : S.toLowerCase().replace(/\s+/g, "-") } : t;
2507
+ const b = t.linkDoctypeField && o ? { ...t, linkDoctype: (w = o[t.linkDoctypeField]) == null ? void 0 : w.toLowerCase().replace(/\s+/g, "-") } : t;
2486
2508
  return /* @__PURE__ */ r("div", { children: [
2487
2509
  /* @__PURE__ */ e(d, {}),
2488
2510
  /* @__PURE__ */ e(
2489
2511
  Sr,
2490
2512
  {
2491
- field: x,
2513
+ field: b,
2492
2514
  value: n ?? "",
2493
2515
  onChange: a,
2494
- disabled: g,
2516
+ disabled: y,
2495
2517
  hideLabel: !0
2496
2518
  }
2497
2519
  )
2498
2520
  ] });
2499
2521
  }
2500
2522
  if (t.type === "select" && (t.options || p)) {
2501
- const x = p ? n && !m.includes(n) ? [n, ...m] : m : t.options;
2523
+ const b = p ? n && !m.includes(n) ? [n, ...m] : m : t.options;
2502
2524
  return /* @__PURE__ */ r("div", { children: [
2503
2525
  /* @__PURE__ */ e(d, {}),
2504
2526
  /* @__PURE__ */ e(
2505
2527
  rt,
2506
2528
  {
2507
- options: x,
2529
+ options: b,
2508
2530
  value: n ?? "",
2509
- onChange: (y) => a(y.target.value)
2531
+ onChange: (g) => a(g.target.value)
2510
2532
  }
2511
2533
  )
2512
2534
  ] });
2513
2535
  }
2514
2536
  if (t.type === "textarea") {
2515
- const x = t.name === "remarks";
2537
+ const b = t.name === "remarks";
2516
2538
  return /* @__PURE__ */ r("div", { children: [
2517
2539
  !i && /* @__PURE__ */ e(
2518
2540
  vn,
2519
2541
  {
2520
2542
  label: l(`fields.${t.label}`, { defaultValue: t.label }),
2521
2543
  hint: t.hint,
2522
- extra: x ? /* @__PURE__ */ e(Nr, {}) : void 0
2544
+ extra: b ? /* @__PURE__ */ e(Nr, {}) : void 0
2523
2545
  }
2524
2546
  ),
2525
2547
  /* @__PURE__ */ e(
@@ -2528,7 +2550,7 @@ function At({
2528
2550
  className: "block w-full rounded-lg bg-surface px-3 py-2 text-sm text-fg ring-1 ring-line transition-all placeholder:text-fg-muted/70 focus:outline-none focus:ring-2 focus:ring-brand/30",
2529
2551
  rows: i ? 3 : 7,
2530
2552
  value: n ?? "",
2531
- onChange: (y) => a(y.target.value)
2553
+ onChange: (g) => a(g.target.value)
2532
2554
  }
2533
2555
  )
2534
2556
  ] });
@@ -2537,13 +2559,13 @@ function At({
2537
2559
  return /* @__PURE__ */ r("div", { children: [
2538
2560
  /* @__PURE__ */ e(d, {}),
2539
2561
  /* @__PURE__ */ e(
2540
- X,
2562
+ ee,
2541
2563
  {
2542
2564
  type: f,
2543
2565
  step: t.type === "currency" ? "0.01" : void 0,
2544
2566
  value: n ?? "",
2545
- onChange: (x) => a(
2546
- f === "number" ? parseFloat(x.target.value) || 0 : x.target.value
2567
+ onChange: (b) => a(
2568
+ f === "number" ? parseFloat(b.target.value) || 0 : b.target.value
2547
2569
  )
2548
2570
  }
2549
2571
  )
@@ -2558,7 +2580,7 @@ function Cr({
2558
2580
  }) {
2559
2581
  const { t: i } = ae(), c = (d, p, m) => {
2560
2582
  const f = n.map(
2561
- (S, x) => x === d ? { ...S, [p]: m } : S
2583
+ (w, b) => b === d ? { ...w, [p]: m } : w
2562
2584
  );
2563
2585
  a(f);
2564
2586
  }, l = () => {
@@ -2566,7 +2588,7 @@ function Cr({
2566
2588
  t.fields.forEach((p) => {
2567
2589
  d[p.name] = p.default ?? (p.type === "number" || p.type === "currency" ? 0 : "");
2568
2590
  }), a([...n, d]);
2569
- }, g = (d) => {
2591
+ }, y = (d) => {
2570
2592
  a(n.filter((p, m) => m !== d));
2571
2593
  };
2572
2594
  return /* @__PURE__ */ r(U, { title: i(`tables.${t.key}`, { defaultValue: t.label }), children: [
@@ -2602,7 +2624,7 @@ function Cr({
2602
2624
  {
2603
2625
  variant: "ghost",
2604
2626
  size: "sm",
2605
- onClick: () => g(p),
2627
+ onClick: () => y(p),
2606
2628
  children: "Remove"
2607
2629
  }
2608
2630
  ) })
@@ -2620,19 +2642,19 @@ function Dr({
2620
2642
  saving: i,
2621
2643
  config: c,
2622
2644
  onSave: l,
2623
- onSubmit: g,
2645
+ onSubmit: y,
2624
2646
  onCancel: d,
2625
2647
  onConvert: p,
2626
2648
  onDiscard: m
2627
2649
  }) {
2628
- const { t: f } = ae(), [S, x] = v(!1), [y, P] = v(!1);
2650
+ const { t: f } = ae(), [w, b] = v(!1), [g, P] = v(!1);
2629
2651
  if (!c) return null;
2630
2652
  const D = !t && n && a ? `/api/documents/${n}/${encodeURIComponent(a)}/pdf` : null, T = !t && c.canCancel && s === 1;
2631
2653
  return /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center gap-2", children: [
2632
2654
  D && /* @__PURE__ */ e(J, { variant: "secondary", onClick: () => window.open(D, "_blank"), children: f("common.pdf") }),
2633
2655
  s < 1 && !o && /* @__PURE__ */ e(J, { onClick: l, disabled: i, children: f(i ? "common.saving" : "common.save") }),
2634
- !t && c.canSubmit && s === 0 && !o && /* @__PURE__ */ e(J, { variant: "secondary", onClick: g, children: f("common.submit") }),
2635
- !t && c.canSubmit && s === 0 && !o && (y ? /* @__PURE__ */ r(Se, { children: [
2656
+ !t && c.canSubmit && s === 0 && !o && /* @__PURE__ */ e(J, { variant: "secondary", onClick: y, children: f("common.submit") }),
2657
+ !t && c.canSubmit && s === 0 && !o && (g ? /* @__PURE__ */ r(Se, { children: [
2636
2658
  /* @__PURE__ */ e(J, { variant: "secondary", onClick: () => P(!1), children: f("common.keepDraft") }),
2637
2659
  /* @__PURE__ */ e(
2638
2660
  J,
@@ -2645,8 +2667,8 @@ function Dr({
2645
2667
  }
2646
2668
  )
2647
2669
  ] }) : /* @__PURE__ */ e(J, { variant: "ghost", onClick: () => P(!0), children: f("common.discardDraft") })),
2648
- T && (S ? /* @__PURE__ */ e(J, { variant: "secondary", onClick: () => x(!1), children: f("common.cancelDocAbort") }) : /* @__PURE__ */ e(J, { variant: "danger", onClick: () => x(!0), children: f("common.cancelDoc") })),
2649
- !t && s === 1 && !S && c.conversions.map((u) => /* @__PURE__ */ e(
2670
+ T && (w ? /* @__PURE__ */ e(J, { variant: "secondary", onClick: () => b(!1), children: f("common.cancelDocAbort") }) : /* @__PURE__ */ e(J, { variant: "danger", onClick: () => b(!0), children: f("common.cancelDoc") })),
2671
+ !t && s === 1 && !w && c.conversions.map((u) => /* @__PURE__ */ e(
2650
2672
  J,
2651
2673
  {
2652
2674
  variant: "secondary",
@@ -2655,13 +2677,13 @@ function Dr({
2655
2677
  },
2656
2678
  u.targetDoctype
2657
2679
  )),
2658
- T && S && /* @__PURE__ */ e(
2680
+ T && w && /* @__PURE__ */ e(
2659
2681
  J,
2660
2682
  {
2661
2683
  variant: "danger",
2662
2684
  className: "ml-auto",
2663
2685
  onClick: () => {
2664
- x(!1), d();
2686
+ b(!1), d();
2665
2687
  },
2666
2688
  children: f("common.cancelDocConfirmBtn")
2667
2689
  }
@@ -2692,45 +2714,45 @@ function Nn(t, n) {
2692
2714
  }
2693
2715
  function wn() {
2694
2716
  var ze;
2695
- const { doctype: t, name: n } = ft(), a = Oe(), s = We(), { t: o } = ae(), i = aa(t ?? ""), c = !n, [l, g] = v({}), [d, p] = v(!1), { data: m, isLoading: f } = le({
2717
+ const { doctype: t, name: n } = ft(), a = Oe(), s = We(), { t: o } = ae(), i = ra(t ?? ""), c = !n, [l, y] = v({}), [d, p] = v(!1), { data: m, isLoading: f } = le({
2696
2718
  queryKey: ["document", t, n],
2697
2719
  queryFn: () => L.getDocument(t, n),
2698
2720
  enabled: !!t && !!n && !c
2699
- }), S = Ie(
2721
+ }), w = Ie(
2700
2722
  () => !!(i != null && i.fields.some((I) => I.name === "currency")),
2701
2723
  [i]
2702
- ), x = i == null ? void 0 : i.partyField, y = x ? l[x] : void 0, P = He(l.company), { data: D } = le({
2703
- queryKey: ["master", x, y],
2704
- queryFn: () => L.getMaster(x, y),
2705
- enabled: c && S && !!x && !!y,
2724
+ ), b = i == null ? void 0 : i.partyField, g = b ? l[b] : void 0, P = He(l.company), { data: D } = le({
2725
+ queryKey: ["master", b, g],
2726
+ queryFn: () => L.getMaster(b, g),
2727
+ enabled: c && w && !!b && !!g,
2706
2728
  staleTime: 300 * 1e3
2707
2729
  });
2708
- ie(() => {
2709
- if (!c || !S || d) return;
2730
+ se(() => {
2731
+ if (!c || !w || d) return;
2710
2732
  let I;
2711
- if (y) {
2733
+ if (g) {
2712
2734
  if (!D) return;
2713
2735
  I = D.default_currency || P;
2714
2736
  } else
2715
2737
  I = P;
2716
- I && I !== l.currency && g((te) => ({ ...te, currency: I }));
2738
+ I && I !== l.currency && y((te) => ({ ...te, currency: I }));
2717
2739
  }, [
2718
2740
  c,
2719
- S,
2741
+ w,
2720
2742
  d,
2721
- y,
2743
+ g,
2722
2744
  D,
2723
2745
  P,
2724
2746
  l.currency
2725
- ]), ie(() => {
2747
+ ]), se(() => {
2726
2748
  if (c && i) {
2727
2749
  const I = {};
2728
2750
  i.fields.forEach((te) => {
2729
2751
  te.type === "date" ? I[te.name] = (/* @__PURE__ */ new Date()).toISOString().split("T")[0] : I[te.name] = te.default ?? "";
2730
2752
  }), i.childTables.forEach((te) => {
2731
2753
  I[te.key] = [];
2732
- }), I.docstatus = 0, g(I);
2733
- } else m && g(m);
2754
+ }), I.docstatus = 0, y(I);
2755
+ } else m && y(m);
2734
2756
  }, [c, m, i]);
2735
2757
  const T = oe({
2736
2758
  mutationFn: (I) => L.createDocument(t, I),
@@ -2740,24 +2762,24 @@ function wn() {
2740
2762
  }), u = oe({
2741
2763
  mutationFn: (I) => L.updateDocument(t, n, I),
2742
2764
  onSuccess: (I) => {
2743
- s.invalidateQueries({ queryKey: ["document", t, n] }), s.invalidateQueries({ queryKey: ["documents", t] }), g(I);
2765
+ s.invalidateQueries({ queryKey: ["document", t, n] }), s.invalidateQueries({ queryKey: ["documents", t] }), y(I);
2744
2766
  }
2745
2767
  }), h = oe({
2746
2768
  mutationFn: () => L.submitDocument(t, n),
2747
2769
  onSuccess: (I) => {
2748
- g(I), s.invalidateQueries({ queryKey: ["document", t, n] }), s.invalidateQueries({ queryKey: ["documents", t] });
2770
+ y(I), s.invalidateQueries({ queryKey: ["document", t, n] }), s.invalidateQueries({ queryKey: ["documents", t] });
2749
2771
  }
2750
2772
  }), A = oe({
2751
2773
  mutationFn: () => L.cancelDocument(t, n),
2752
2774
  onSuccess: (I) => {
2753
- g(I), s.invalidateQueries({ queryKey: ["document", t, n] }), s.invalidateQueries({ queryKey: ["documents", t] });
2775
+ y(I), s.invalidateQueries({ queryKey: ["document", t, n] }), s.invalidateQueries({ queryKey: ["documents", t] });
2754
2776
  }
2755
2777
  }), R = oe({
2756
2778
  mutationFn: () => L.discardDocument(t, n),
2757
2779
  onSuccess: () => {
2758
2780
  s.invalidateQueries({ queryKey: ["documents", t] }), a(`/app/${t}`, { replace: !0 });
2759
2781
  }
2760
- }), k = oe({
2782
+ }), S = oe({
2761
2783
  mutationFn: (I) => L.convertDocument(t, n, I),
2762
2784
  onSuccess: (I, te) => {
2763
2785
  const Ae = te.toLowerCase().replace(/\s+/g, "-");
@@ -2765,7 +2787,7 @@ function wn() {
2765
2787
  }
2766
2788
  }), H = Te(
2767
2789
  (I, te) => {
2768
- I === "currency" && p(!0), g((Ae) => {
2790
+ I === "currency" && p(!0), y((Ae) => {
2769
2791
  const Ce = { ...Ae, [I]: te };
2770
2792
  return I === "currency" && (Ce.conversion_rate = 0), Nn(Ce, i);
2771
2793
  });
@@ -2773,7 +2795,7 @@ function wn() {
2773
2795
  [i]
2774
2796
  ), $ = Te(
2775
2797
  (I, te) => {
2776
- g((Ae) => {
2798
+ y((Ae) => {
2777
2799
  const Ce = { ...Ae, [I]: te };
2778
2800
  return Nn(Ce, i);
2779
2801
  });
@@ -2781,12 +2803,12 @@ function wn() {
2781
2803
  [i]
2782
2804
  ), z = () => {
2783
2805
  c ? T.mutate(l) : u.mutate(l);
2784
- }, w = () => {
2806
+ }, k = () => {
2785
2807
  h.mutate();
2786
2808
  }, K = () => {
2787
2809
  A.mutate();
2788
2810
  }, N = (I) => {
2789
- k.mutate(I);
2811
+ S.mutate(I);
2790
2812
  }, B = () => {
2791
2813
  R.mutate();
2792
2814
  };
@@ -2828,7 +2850,7 @@ function wn() {
2828
2850
  config: i,
2829
2851
  discarded: F,
2830
2852
  onSave: z,
2831
- onSubmit: w,
2853
+ onSubmit: k,
2832
2854
  onCancel: K,
2833
2855
  onConvert: N,
2834
2856
  onDiscard: B
@@ -2890,12 +2912,12 @@ function wn() {
2890
2912
  function fe(t) {
2891
2913
  return t.toISOString().split("T")[0];
2892
2914
  }
2893
- function ra(t) {
2915
+ function sa(t) {
2894
2916
  const n = new Date(t), a = n.getDay(), s = a === 0 ? 6 : a - 1;
2895
2917
  return n.setDate(n.getDate() - s), n;
2896
2918
  }
2897
2919
  function _r(t) {
2898
- const n = ra(t);
2920
+ const n = sa(t);
2899
2921
  return n.setDate(n.getDate() + 6), n;
2900
2922
  }
2901
2923
  function kn(t) {
@@ -2928,7 +2950,7 @@ const Pr = [
2928
2950
  },
2929
2951
  {
2930
2952
  label: "This Week",
2931
- range: () => [fe(ra(/* @__PURE__ */ new Date())), fe(_r(/* @__PURE__ */ new Date()))]
2953
+ range: () => [fe(sa(/* @__PURE__ */ new Date())), fe(_r(/* @__PURE__ */ new Date()))]
2932
2954
  },
2933
2955
  {
2934
2956
  label: "This Month",
@@ -3032,18 +3054,18 @@ function Ir(t) {
3032
3054
  }
3033
3055
  const Lr = ["25", "50", "100", "200"];
3034
3056
  function Br() {
3035
- const { t } = ae(), { doctype: n } = ft(), a = aa(n ?? ""), [s] = ne("status", "All"), [o] = ne("from", ""), [i] = ne("to", ""), [c] = ne("discarded", ""), [l] = ne("per_page", 50), [g] = ne("page", 1), d = g - 1, p = Qe(), m = (w) => p({ page: w === 0 ? null : w + 1 }), f = (w) => p({ status: w === "All" ? null : w, page: null }), S = (w) => p({ from: w || null, page: null }), x = (w) => p({ to: w || null, page: null }), y = (w) => p({ discarded: w ? "1" : null, page: null }), P = (w) => p({ per_page: w, page: null }), D = Ie(() => {
3036
- const w = {};
3037
- return s !== "All" && (w.status = s), o && (w.from_date = o), i && (w.to_date = i), c && (w.include_discarded = "true"), w.limit = l, w.offset = d * l, w;
3038
- }, [s, o, i, c, l, d]), { data: T, isLoading: u } = gr(n ?? "", D), h = (T == null ? void 0 : T.rows) ?? [], A = (T == null ? void 0 : T.total) ?? 0, R = Math.max(1, Math.ceil(A / l)), k = A === 0 ? 0 : d * l + 1, H = Math.min(A, (d + 1) * l), $ = Ie(() => {
3057
+ const { t } = ae(), { doctype: n } = ft(), a = ra(n ?? ""), [s] = ne("status", "All"), [o] = ne("from", ""), [i] = ne("to", ""), [c] = ne("discarded", ""), [l] = ne("per_page", 50), [y] = ne("page", 1), d = y - 1, p = Qe(), m = (k) => p({ page: k === 0 ? null : k + 1 }), f = (k) => p({ status: k === "All" ? null : k, page: null }), w = (k) => p({ from: k || null, page: null }), b = (k) => p({ to: k || null, page: null }), g = (k) => p({ discarded: k ? "1" : null, page: null }), P = (k) => p({ per_page: k, page: null }), D = Ie(() => {
3058
+ const k = {};
3059
+ return s !== "All" && (k.status = s), o && (k.from_date = o), i && (k.to_date = i), c && (k.include_discarded = "true"), k.limit = l, k.offset = d * l, k;
3060
+ }, [s, o, i, c, l, d]), { data: T, isLoading: u } = gr(n ?? "", D), h = (T == null ? void 0 : T.rows) ?? [], A = (T == null ? void 0 : T.total) ?? 0, R = Math.max(1, Math.ceil(A / l)), S = A === 0 ? 0 : d * l + 1, H = Math.min(A, (d + 1) * l), $ = Ie(() => {
3039
3061
  if (!a) return [];
3040
- const w = Wn(), K = (N) => {
3062
+ const k = Wn(), K = (N) => {
3041
3063
  const B = N.split("_").map((C) => C.charAt(0).toUpperCase() + C.slice(1)).join(" ");
3042
3064
  return t(`fields.${B}`, { defaultValue: B });
3043
3065
  };
3044
3066
  return a.listColumns.map((N) => {
3045
3067
  if (N === "name")
3046
- return w.accessor("name", {
3068
+ return k.accessor("name", {
3047
3069
  header: t("fields.Name", { defaultValue: "Name" }),
3048
3070
  cell: (B) => /* @__PURE__ */ e(
3049
3071
  Ne,
@@ -3055,12 +3077,12 @@ function Br() {
3055
3077
  )
3056
3078
  });
3057
3079
  if (N === "status")
3058
- return w.accessor("status", {
3080
+ return k.accessor("status", {
3059
3081
  header: t("fields.Status", { defaultValue: "Status" }),
3060
3082
  cell: (B) => /* @__PURE__ */ e(sn, { status: B.getValue() })
3061
3083
  });
3062
3084
  if (Ar.has(N))
3063
- return w.accessor(N, {
3085
+ return k.accessor(N, {
3064
3086
  header: K(N),
3065
3087
  cell: (B) => {
3066
3088
  var C;
@@ -3068,7 +3090,7 @@ function Br() {
3068
3090
  }
3069
3091
  });
3070
3092
  if (N === "party")
3071
- return w.accessor("party", {
3093
+ return k.accessor("party", {
3072
3094
  header: t("fields.Party", { defaultValue: "Party" }),
3073
3095
  cell: (B) => {
3074
3096
  const C = B.getValue();
@@ -3087,7 +3109,7 @@ function Br() {
3087
3109
  });
3088
3110
  if (Cn[N]) {
3089
3111
  const B = Cn[N];
3090
- return w.accessor(N, {
3112
+ return k.accessor(N, {
3091
3113
  header: K(N),
3092
3114
  cell: (C) => {
3093
3115
  const F = C.getValue();
@@ -3105,10 +3127,10 @@ function Br() {
3105
3127
  }
3106
3128
  });
3107
3129
  }
3108
- return Rr.has(N) ? w.accessor(N, {
3130
+ return Rr.has(N) ? k.accessor(N, {
3109
3131
  header: K(N),
3110
3132
  cell: (B) => qt(B.getValue())
3111
- }) : w.accessor(N, {
3133
+ }) : k.accessor(N, {
3112
3134
  header: K(N)
3113
3135
  });
3114
3136
  });
@@ -3124,30 +3146,30 @@ function Br() {
3124
3146
  rt,
3125
3147
  {
3126
3148
  label: t("fields.Status", { defaultValue: "Status" }),
3127
- options: Tr.map((w) => ({
3128
- value: w,
3129
- label: w === "All" ? t("common.all") : t(`status.${w}`, { defaultValue: w })
3149
+ options: Tr.map((k) => ({
3150
+ value: k,
3151
+ label: k === "All" ? t("common.all") : t(`status.${k}`, { defaultValue: k })
3130
3152
  })),
3131
3153
  value: s,
3132
- onChange: (w) => f(w.target.value)
3154
+ onChange: (k) => f(k.target.value)
3133
3155
  }
3134
3156
  ),
3135
3157
  /* @__PURE__ */ e(
3136
- X,
3158
+ ee,
3137
3159
  {
3138
3160
  label: t("fields.From Date", { defaultValue: "From Date" }),
3139
3161
  type: "date",
3140
3162
  value: o,
3141
- onChange: (w) => S(w.target.value)
3163
+ onChange: (k) => w(k.target.value)
3142
3164
  }
3143
3165
  ),
3144
3166
  /* @__PURE__ */ e(
3145
- X,
3167
+ ee,
3146
3168
  {
3147
3169
  label: t("fields.To Date", { defaultValue: "To Date" }),
3148
3170
  type: "date",
3149
3171
  value: i,
3150
- onChange: (w) => x(w.target.value)
3172
+ onChange: (k) => b(k.target.value)
3151
3173
  }
3152
3174
  ),
3153
3175
  /* @__PURE__ */ r("label", { className: "flex h-10 items-center gap-2 text-sm text-fg-muted", children: [
@@ -3157,16 +3179,16 @@ function Br() {
3157
3179
  type: "checkbox",
3158
3180
  className: "h-4 w-4 rounded border-line text-brand focus:ring-brand/30",
3159
3181
  checked: !!c,
3160
- onChange: (w) => y(w.target.checked)
3182
+ onChange: (k) => g(k.target.checked)
3161
3183
  }
3162
3184
  ),
3163
3185
  t("common.showDiscarded")
3164
3186
  ] })
3165
3187
  ] }),
3166
- /* @__PURE__ */ e(Ft, { onSelect: (w, K) => p({ from: w, to: K, page: null }) }),
3188
+ /* @__PURE__ */ e(Ft, { onSelect: (k, K) => p({ from: k, to: K, page: null }) }),
3167
3189
  u ? /* @__PURE__ */ e("p", { className: "text-fg-muted", children: t("common.loading") }) : h.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-fg-muted", children: t("reports.noDocuments") }) : /* @__PURE__ */ r(Se, { children: [
3168
3190
  /* @__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: [
3169
- /* @__PURE__ */ e("thead", { className: "bg-surface-subtle", children: z.getHeaderGroups().map((w) => /* @__PURE__ */ e("tr", { children: w.headers.map((K) => /* @__PURE__ */ e(
3191
+ /* @__PURE__ */ e("thead", { className: "bg-surface-subtle", children: z.getHeaderGroups().map((k) => /* @__PURE__ */ e("tr", { children: k.headers.map((K) => /* @__PURE__ */ e(
3170
3192
  "th",
3171
3193
  {
3172
3194
  className: "px-4 py-3 text-left text-xs font-medium uppercase tracking-wide text-fg-muted",
@@ -3176,18 +3198,18 @@ function Br() {
3176
3198
  )
3177
3199
  },
3178
3200
  K.id
3179
- )) }, w.id)) }),
3180
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children: z.getRowModel().rows.map((w) => /* @__PURE__ */ e("tr", { className: "transition-colors hover:bg-surface-subtle", children: w.getVisibleCells().map((K) => /* @__PURE__ */ e("td", { className: "px-4 py-2.5 text-fg", children: Rt(
3201
+ )) }, k.id)) }),
3202
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children: z.getRowModel().rows.map((k) => /* @__PURE__ */ e("tr", { className: "transition-colors hover:bg-surface-subtle", children: k.getVisibleCells().map((K) => /* @__PURE__ */ e("td", { className: "px-4 py-2.5 text-fg", children: Rt(
3181
3203
  K.column.columnDef.cell,
3182
3204
  K.getContext()
3183
- ) }, K.id)) }, w.id)) })
3205
+ ) }, K.id)) }, k.id)) })
3184
3206
  ] }) }),
3185
3207
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center justify-between gap-3 text-sm text-fg-muted", children: [
3186
3208
  /* @__PURE__ */ r("div", { children: [
3187
3209
  t("common.showing"),
3188
3210
  " ",
3189
3211
  /* @__PURE__ */ r("span", { className: "font-medium text-fg", children: [
3190
- k,
3212
+ S,
3191
3213
  "–",
3192
3214
  H
3193
3215
  ] }),
@@ -3203,9 +3225,9 @@ function Br() {
3203
3225
  "select",
3204
3226
  {
3205
3227
  value: l,
3206
- onChange: (w) => P(Number(w.target.value)),
3228
+ onChange: (k) => P(Number(k.target.value)),
3207
3229
  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",
3208
- children: Lr.map((w) => /* @__PURE__ */ e("option", { value: w, children: w }, w))
3230
+ children: Lr.map((k) => /* @__PURE__ */ e("option", { value: k, children: k }, k))
3209
3231
  }
3210
3232
  )
3211
3233
  ] }),
@@ -3251,14 +3273,14 @@ function ke({
3251
3273
  linkDoctype: s,
3252
3274
  readOnly: o
3253
3275
  }) {
3254
- const [i, c] = v(n ?? ""), [l, g] = v([]), [d, p] = v(!1), [m, f] = v(!1), [S, x] = v({}), y = ee(null), P = ee(null), D = ee(null), T = ee(null), u = ee(!1);
3255
- ie(() => {
3276
+ const [i, c] = v(n ?? ""), [l, y] = v([]), [d, p] = v(!1), [m, f] = v(!1), [w, b] = v({}), g = X(null), P = X(null), D = X(null), T = X(null), u = X(!1);
3277
+ se(() => {
3256
3278
  c(n ?? "");
3257
3279
  }, [n]);
3258
3280
  const h = Te(() => {
3259
3281
  if (T.current) {
3260
3282
  const $ = T.current.getBoundingClientRect();
3261
- x({
3283
+ b({
3262
3284
  position: "fixed",
3263
3285
  top: $.bottom + 4,
3264
3286
  left: $.left,
@@ -3268,13 +3290,13 @@ function ke({
3268
3290
  }
3269
3291
  }, []), A = Te(
3270
3292
  ($) => {
3271
- y.current && clearTimeout(y.current), y.current = setTimeout(async () => {
3293
+ g.current && clearTimeout(g.current), g.current = setTimeout(async () => {
3272
3294
  f(!0);
3273
3295
  try {
3274
3296
  const z = await L.searchLink(s, $);
3275
- g(z), p(!0);
3297
+ y(z), p(!0);
3276
3298
  } catch {
3277
- g([]);
3299
+ y([]);
3278
3300
  } finally {
3279
3301
  f(!1);
3280
3302
  }
@@ -3284,9 +3306,9 @@ function ke({
3284
3306
  ), R = ($) => {
3285
3307
  const z = $.target.value;
3286
3308
  c(z), A(z);
3287
- }, k = ($) => {
3309
+ }, S = ($) => {
3288
3310
  const z = $.name ?? $.id ?? String($);
3289
- c(z), a(z), p(!1), g([]);
3311
+ c(z), a(z), p(!1), y([]);
3290
3312
  }, H = () => {
3291
3313
  setTimeout(() => {
3292
3314
  if (u.current) {
@@ -3296,11 +3318,11 @@ function ke({
3296
3318
  p(!1), i !== n && a(i);
3297
3319
  }, 150);
3298
3320
  };
3299
- return ie(() => {
3321
+ return se(() => {
3300
3322
  const $ = (z) => {
3301
3323
  var K, N;
3302
- const w = z.target;
3303
- (K = P.current) != null && K.contains(w) || (N = D.current) != null && N.contains(w) || p(!1);
3324
+ const k = z.target;
3325
+ (K = P.current) != null && K.contains(k) || (N = D.current) != null && N.contains(k) || p(!1);
3304
3326
  };
3305
3327
  return document.addEventListener("mousedown", $), () => document.removeEventListener("mousedown", $);
3306
3328
  }, []), o ? /* @__PURE__ */ r("div", { children: [
@@ -3326,9 +3348,9 @@ function ke({
3326
3348
  )
3327
3349
  }
3328
3350
  ),
3329
- d && l.length > 0 && Fa(
3330
- /* @__PURE__ */ e("div", { ref: D, style: S, className: "max-h-48 overflow-y-auto rounded-lg bg-surface ring-1 ring-line shadow-card-hover", children: l.map(($, z) => {
3331
- const w = $.name ?? $.id ?? String($);
3351
+ d && l.length > 0 && Jn(
3352
+ /* @__PURE__ */ e("div", { ref: D, style: w, className: "max-h-48 overflow-y-auto rounded-lg bg-surface ring-1 ring-line shadow-card-hover", children: l.map(($, z) => {
3353
+ const k = $.name ?? $.id ?? String($);
3332
3354
  return /* @__PURE__ */ e(
3333
3355
  "button",
3334
3356
  {
@@ -3336,9 +3358,9 @@ function ke({
3336
3358
  onMouseDown: () => {
3337
3359
  u.current = !0;
3338
3360
  },
3339
- onClick: () => k($),
3361
+ onClick: () => S($),
3340
3362
  className: "block w-full px-3 py-1.5 text-left text-sm text-fg transition-colors hover:bg-surface-subtle",
3341
- children: w
3363
+ children: k
3342
3364
  },
3343
3365
  z
3344
3366
  );
@@ -3362,12 +3384,12 @@ function Dn() {
3362
3384
  partner_name: "",
3363
3385
  partner_email: "",
3364
3386
  cover_letter: ""
3365
- }), [g, d] = v([Tt()]), [p, m] = v(null), [f, S] = v(!1), [x, y] = v(null), P = ee(null), D = (N, B) => l((C) => ({ ...C, [N]: B })), { data: T } = le({
3387
+ }), [y, d] = v([Tt()]), [p, m] = v(null), [f, w] = v(!1), [b, g] = v(null), P = X(null), D = (N, B) => l((C) => ({ ...C, [N]: B })), { data: T } = le({
3366
3388
  queryKey: ["document", "proposal", t],
3367
3389
  queryFn: () => L.getDocument("proposal", t),
3368
3390
  enabled: !n
3369
3391
  });
3370
- ie(() => {
3392
+ se(() => {
3371
3393
  if (!T) return;
3372
3394
  l({
3373
3395
  title: T.title ?? "Offerte",
@@ -3388,52 +3410,52 @@ function Dn() {
3388
3410
  } catch {
3389
3411
  }
3390
3412
  };
3391
- ie(() => {
3413
+ se(() => {
3392
3414
  n && c.customer && !c.cover_letter && u();
3393
3415
  }, [c.customer, c.company]);
3394
3416
  const h = () => ({
3395
3417
  ...c,
3396
- quotations: g.filter((N) => N.quotation).map((N, B) => ({ ...N, idx: B + 1, is_recommended: N.is_recommended ? 1 : 0 }))
3418
+ quotations: y.filter((N) => N.quotation).map((N, B) => ({ ...N, idx: B + 1, is_recommended: N.is_recommended ? 1 : 0 }))
3397
3419
  }), A = oe({
3398
3420
  mutationFn: async () => n ? L.createDocument("proposal", h()) : L.updateDocument("proposal", t, h()),
3399
3421
  onSuccess: (N) => {
3400
- y(null), s.invalidateQueries({ queryKey: ["documents", "proposal"] }), s.invalidateQueries({ queryKey: ["document", "proposal", N.name] }), n && a(`/app/proposal/${encodeURIComponent(N.name)}`);
3422
+ g(null), s.invalidateQueries({ queryKey: ["documents", "proposal"] }), s.invalidateQueries({ queryKey: ["document", "proposal", N.name] }), n && a(`/app/proposal/${encodeURIComponent(N.name)}`);
3401
3423
  },
3402
- onError: (N) => y((N == null ? void 0 : N.message) ?? "Save failed")
3424
+ onError: (N) => g((N == null ? void 0 : N.message) ?? "Save failed")
3403
3425
  }), R = oe({
3404
3426
  mutationFn: () => L.discardDocument("proposal", t),
3405
3427
  onSuccess: () => {
3406
3428
  s.invalidateQueries({ queryKey: ["documents", "proposal"] }), a("/app/proposal");
3407
3429
  },
3408
- onError: (N) => y((N == null ? void 0 : N.message) ?? "Discard failed")
3409
- }), k = (N, B) => d((C) => C.map((F, Z) => Z === N ? { ...F, ...B } : F)), H = () => d((N) => [...N, Tt()]), $ = (N) => d((B) => B.length > 1 ? B.filter((C, F) => F !== N) : B), z = (N, B) => d((C) => {
3430
+ onError: (N) => g((N == null ? void 0 : N.message) ?? "Discard failed")
3431
+ }), S = (N, B) => d((C) => C.map((F, Z) => Z === N ? { ...F, ...B } : F)), H = () => d((N) => [...N, Tt()]), $ = (N) => d((B) => B.length > 1 ? B.filter((C, F) => F !== N) : B), z = (N, B) => d((C) => {
3410
3432
  const F = N + B;
3411
3433
  if (F < 0 || F >= C.length) return C;
3412
3434
  const Z = [...C];
3413
3435
  return [Z[N], Z[F]] = [Z[F], Z[N]], Z;
3414
- }), w = async (N) => {
3436
+ }), k = async (N) => {
3415
3437
  var C;
3416
3438
  const B = (C = N.target.files) == null ? void 0 : C[0];
3417
3439
  if (N.target.value = "", !(!B || n)) {
3418
- S(!0), y(null);
3440
+ w(!0), g(null);
3419
3441
  try {
3420
3442
  const F = await L.uploadProposalAppendix(t, B);
3421
3443
  m(F.appendix_filename), s.invalidateQueries({ queryKey: ["document", "proposal", t] });
3422
3444
  } catch (F) {
3423
- y((F == null ? void 0 : F.message) ?? "Upload failed");
3445
+ g((F == null ? void 0 : F.message) ?? "Upload failed");
3424
3446
  } finally {
3425
- S(!1);
3447
+ w(!1);
3426
3448
  }
3427
3449
  }
3428
3450
  }, K = async () => {
3429
3451
  if (!n) {
3430
- S(!0);
3452
+ w(!0);
3431
3453
  try {
3432
3454
  await L.deleteProposalAppendix(t), m(null);
3433
3455
  } catch (N) {
3434
- y((N == null ? void 0 : N.message) ?? "Failed");
3456
+ g((N == null ? void 0 : N.message) ?? "Failed");
3435
3457
  } finally {
3436
- S(!1);
3458
+ w(!1);
3437
3459
  }
3438
3460
  }
3439
3461
  };
@@ -3459,15 +3481,15 @@ function Dn() {
3459
3481
  /* @__PURE__ */ e(J, { onClick: () => A.mutate(), disabled: A.isPending, children: A.isPending ? i("common.saving", "Saving…") : i("common.save", "Save") })
3460
3482
  ] })
3461
3483
  ] }),
3462
- x && /* @__PURE__ */ e("div", { className: "rounded-lg bg-red-50 px-4 py-2 text-sm text-red-700 ring-1 ring-red-200", children: x }),
3484
+ b && /* @__PURE__ */ e("div", { className: "rounded-lg bg-red-50 px-4 py-2 text-sm text-red-700 ring-1 ring-red-200", children: b }),
3463
3485
  /* @__PURE__ */ r(U, { className: "space-y-4 p-5", children: [
3464
3486
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: [
3465
- /* @__PURE__ */ e(X, { label: i("fields.Title", "Title"), value: c.title, onChange: (N) => D("title", N.target.value) }),
3466
- /* @__PURE__ */ e(X, { label: i("fields.Date", "Date"), type: "date", value: c.proposal_date, onChange: (N) => D("proposal_date", N.target.value) }),
3487
+ /* @__PURE__ */ e(ee, { label: i("fields.Title", "Title"), value: c.title, onChange: (N) => D("title", N.target.value) }),
3488
+ /* @__PURE__ */ e(ee, { label: i("fields.Date", "Date"), type: "date", value: c.proposal_date, onChange: (N) => D("proposal_date", N.target.value) }),
3467
3489
  /* @__PURE__ */ e(ke, { label: i("fields.Customer", "Customer"), value: c.customer, onChange: (N) => D("customer", N), linkDoctype: "customer", readOnly: !1 }),
3468
3490
  /* @__PURE__ */ e(ke, { label: i("fields.Company", "Company"), value: c.company, onChange: (N) => D("company", N), linkDoctype: "company", readOnly: !1 }),
3469
- /* @__PURE__ */ e(X, { label: i("fields.Partner", "Account Manager"), value: c.partner_name, onChange: (N) => D("partner_name", N.target.value) }),
3470
- /* @__PURE__ */ e(X, { label: i("fields.Partner Email", "Account Manager Email"), value: c.partner_email, onChange: (N) => D("partner_email", N.target.value) })
3491
+ /* @__PURE__ */ e(ee, { label: i("fields.Partner", "Account Manager"), value: c.partner_name, onChange: (N) => D("partner_name", N.target.value) }),
3492
+ /* @__PURE__ */ e(ee, { label: i("fields.Partner Email", "Account Manager Email"), value: c.partner_email, onChange: (N) => D("partner_email", N.target.value) })
3471
3493
  ] }),
3472
3494
  /* @__PURE__ */ r("div", { children: [
3473
3495
  /* @__PURE__ */ r("div", { className: "mb-1.5 flex items-center justify-between", children: [
@@ -3490,21 +3512,21 @@ function Dn() {
3490
3512
  /* @__PURE__ */ e("h2", { className: "font-semibold text-fg", children: i("proposal.offers", "Offers") }),
3491
3513
  /* @__PURE__ */ e(J, { size: "sm", variant: "secondary", onClick: H, children: i("proposal.addOffer", "Add offer") })
3492
3514
  ] }),
3493
- g.map((N, B) => /* @__PURE__ */ r("div", { className: "rounded-lg p-3 ring-1 ring-line", children: [
3515
+ y.map((N, B) => /* @__PURE__ */ r("div", { className: "rounded-lg p-3 ring-1 ring-line", children: [
3494
3516
  /* @__PURE__ */ r("div", { className: "mb-2 flex items-center gap-2", children: [
3495
3517
  /* @__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: Er[B] ?? B + 1 }),
3496
- /* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(ke, { label: "", value: N.quotation, onChange: (C) => k(B, { quotation: C }), linkDoctype: "quotation", readOnly: !1 }) }),
3518
+ /* @__PURE__ */ e("div", { className: "flex-1", children: /* @__PURE__ */ e(ke, { label: "", value: N.quotation, onChange: (C) => S(B, { quotation: C }), linkDoctype: "quotation", readOnly: !1 }) }),
3497
3519
  /* @__PURE__ */ e("button", { type: "button", onClick: () => z(B, -1), disabled: B === 0, className: "px-1 text-fg-muted disabled:opacity-30", children: "↑" }),
3498
- /* @__PURE__ */ e("button", { type: "button", onClick: () => z(B, 1), disabled: B === g.length - 1, className: "px-1 text-fg-muted disabled:opacity-30", children: "↓" }),
3520
+ /* @__PURE__ */ e("button", { type: "button", onClick: () => z(B, 1), disabled: B === y.length - 1, className: "px-1 text-fg-muted disabled:opacity-30", children: "↓" }),
3499
3521
  /* @__PURE__ */ e("button", { type: "button", onClick: () => $(B), className: "px-1 text-red-500 hover:text-red-700", children: "✕" })
3500
3522
  ] }),
3501
3523
  /* @__PURE__ */ r("div", { className: "grid grid-cols-1 gap-2 pl-8 sm:grid-cols-2", children: [
3502
- /* @__PURE__ */ e(X, { label: i("proposal.positionTitle", "Position title"), value: N.position_title, onChange: (C) => k(B, { position_title: C.target.value }), placeholder: i("proposal.positionTitleHint", "defaults to the offer's first item") }),
3524
+ /* @__PURE__ */ e(ee, { label: i("proposal.positionTitle", "Position title"), value: N.position_title, onChange: (C) => S(B, { position_title: C.target.value }), placeholder: i("proposal.positionTitleHint", "defaults to the offer's first item") }),
3503
3525
  /* @__PURE__ */ r("label", { className: "flex items-center gap-2 self-end pb-2 text-sm text-fg", children: [
3504
- /* @__PURE__ */ e("input", { type: "checkbox", checked: !!N.is_recommended, onChange: (C) => k(B, { is_recommended: C.target.checked ? 1 : 0 }) }),
3526
+ /* @__PURE__ */ e("input", { type: "checkbox", checked: !!N.is_recommended, onChange: (C) => S(B, { is_recommended: C.target.checked ? 1 : 0 }) }),
3505
3527
  i("proposal.recommended", "Mark as recommendation")
3506
3528
  ] }),
3507
- /* @__PURE__ */ e("div", { className: "sm:col-span-2", children: /* @__PURE__ */ e(X, { label: i("proposal.blurb", "Description"), value: N.position_blurb, onChange: (C) => k(B, { position_blurb: C.target.value }), placeholder: i("proposal.blurbHint", "defaults to the offer's notes") }) })
3529
+ /* @__PURE__ */ e("div", { className: "sm:col-span-2", children: /* @__PURE__ */ e(ee, { label: i("proposal.blurb", "Description"), value: N.position_blurb, onChange: (C) => S(B, { position_blurb: C.target.value }), placeholder: i("proposal.blurbHint", "defaults to the offer's notes") }) })
3508
3530
  ] })
3509
3531
  ] }, B))
3510
3532
  ] }),
@@ -3517,7 +3539,7 @@ function Dn() {
3517
3539
  ] }),
3518
3540
  /* @__PURE__ */ e("button", { type: "button", onClick: K, disabled: f, className: "text-red-500 hover:underline", children: i("common.remove", "Remove") })
3519
3541
  ] }) : /* @__PURE__ */ r("div", { children: [
3520
- /* @__PURE__ */ e("input", { ref: P, type: "file", accept: "application/pdf", onChange: w, className: "hidden" }),
3542
+ /* @__PURE__ */ e("input", { ref: P, type: "file", accept: "application/pdf", onChange: k, className: "hidden" }),
3521
3543
  /* @__PURE__ */ e(J, { size: "sm", variant: "secondary", disabled: f, onClick: () => {
3522
3544
  var N;
3523
3545
  return (N = P.current) == null ? void 0 : N.click();
@@ -3530,7 +3552,7 @@ function Dn() {
3530
3552
  const Or = ["25", "50", "100", "200"];
3531
3553
  function qr() {
3532
3554
  var u;
3533
- const { type: t } = ft(), n = Oe(), s = (u = Ct().state) == null ? void 0 : u.notice, [o] = ne("per_page", 50), [i] = ne("page", 1), c = i - 1, l = Qe(), g = (h) => l({ page: h === 0 ? null : h + 1 }), d = (h) => l({ per_page: h, page: null }), { data: p, isLoading: m } = le({
3555
+ const { type: t } = ft(), n = Oe(), s = (u = Ct().state) == null ? void 0 : u.notice, [o] = ne("per_page", 50), [i] = ne("page", 1), c = i - 1, l = Qe(), y = (h) => l({ page: h === 0 ? null : h + 1 }), d = (h) => l({ per_page: h, page: null }), { data: p, isLoading: m } = le({
3534
3556
  queryKey: ["masters", t, c, o],
3535
3557
  queryFn: () => L.listMasters(t, {
3536
3558
  include_disabled: 1,
@@ -3538,16 +3560,16 @@ function qr() {
3538
3560
  offset: c * o
3539
3561
  }),
3540
3562
  enabled: !!t
3541
- }), f = (p == null ? void 0 : p.rows) ?? [], S = (p == null ? void 0 : p.total) ?? 0, x = Math.max(1, Math.ceil(S / o)), y = S === 0 ? 0 : c * o + 1, P = Math.min(S, (c + 1) * o), D = Ie(() => {
3563
+ }), f = (p == null ? void 0 : p.rows) ?? [], w = (p == null ? void 0 : p.total) ?? 0, b = Math.max(1, Math.ceil(w / o)), g = w === 0 ? 0 : c * o + 1, P = Math.min(w, (c + 1) * o), D = Ie(() => {
3542
3564
  if (!f || f.length === 0) return [];
3543
3565
  const h = Wn();
3544
3566
  return Object.keys(f[0]).map(
3545
3567
  (R) => h.accessor(R, {
3546
- header: R.split("_").map((k) => k.charAt(0).toUpperCase() + k.slice(1)).join(" "),
3547
- cell: (k) => {
3548
- const H = k.getValue();
3568
+ header: R.split("_").map((S) => S.charAt(0).toUpperCase() + S.slice(1)).join(" "),
3569
+ cell: (S) => {
3570
+ const H = S.getValue();
3549
3571
  if (R === "name") {
3550
- const $ = k.row.original.disabled === 1;
3572
+ const $ = S.row.original.disabled === 1;
3551
3573
  return /* @__PURE__ */ e(
3552
3574
  Ne,
3553
3575
  {
@@ -3599,13 +3621,13 @@ function qr() {
3599
3621
  /* @__PURE__ */ r("div", { children: [
3600
3622
  "Showing ",
3601
3623
  /* @__PURE__ */ r("span", { className: "font-medium text-fg", children: [
3602
- y,
3624
+ g,
3603
3625
  "–",
3604
3626
  P
3605
3627
  ] }),
3606
3628
  " ",
3607
3629
  "of ",
3608
- /* @__PURE__ */ e("span", { className: "font-medium text-fg", children: S })
3630
+ /* @__PURE__ */ e("span", { className: "font-medium text-fg", children: w })
3609
3631
  ] }),
3610
3632
  /* @__PURE__ */ r("div", { className: "flex items-center gap-2", children: [
3611
3633
  /* @__PURE__ */ r("label", { className: "flex items-center gap-1.5", children: [
@@ -3623,7 +3645,7 @@ function qr() {
3623
3645
  /* @__PURE__ */ e(
3624
3646
  "button",
3625
3647
  {
3626
- onClick: () => g(Math.max(0, c - 1)),
3648
+ onClick: () => y(Math.max(0, c - 1)),
3627
3649
  disabled: c === 0,
3628
3650
  className: "rounded-md bg-surface px-3 py-1 text-sm text-fg ring-1 ring-line transition-colors hover:bg-surface-subtle disabled:cursor-not-allowed disabled:opacity-40",
3629
3651
  children: "Prev"
@@ -3634,13 +3656,13 @@ function qr() {
3634
3656
  /* @__PURE__ */ e("span", { className: "font-medium text-fg", children: c + 1 }),
3635
3657
  " of",
3636
3658
  " ",
3637
- /* @__PURE__ */ e("span", { className: "font-medium text-fg", children: x })
3659
+ /* @__PURE__ */ e("span", { className: "font-medium text-fg", children: b })
3638
3660
  ] }),
3639
3661
  /* @__PURE__ */ e(
3640
3662
  "button",
3641
3663
  {
3642
- onClick: () => g(Math.min(x - 1, c + 1)),
3643
- disabled: c >= x - 1,
3664
+ onClick: () => y(Math.min(b - 1, c + 1)),
3665
+ disabled: c >= b - 1,
3644
3666
  className: "rounded-md bg-surface px-3 py-1 text-sm text-fg ring-1 ring-line transition-colors hover:bg-surface-subtle disabled:cursor-not-allowed disabled:opacity-40",
3645
3667
  children: "Next"
3646
3668
  }
@@ -3720,40 +3742,40 @@ const Fr = {
3720
3742
  }, _n = /* @__PURE__ */ new Set(["customer", "supplier", "item", "warehouse"]);
3721
3743
  function Pn() {
3722
3744
  var R;
3723
- const { type: t, name: n } = ft(), a = Oe(), s = We(), { t: o } = ae(), i = !n || n === "new", c = Mr[t ?? ""] ?? t ?? "", l = o(`masters.${t}.one`, { defaultValue: c }), g = Fr[t ?? ""] ?? [], d = (k) => o(`fields.${k.label}`, { defaultValue: k.label }), [p, m] = v({}), { data: f, isLoading: S } = le({
3745
+ const { type: t, name: n } = ft(), a = Oe(), s = We(), { t: o } = ae(), i = !n || n === "new", c = Mr[t ?? ""] ?? t ?? "", l = o(`masters.${t}.one`, { defaultValue: c }), y = Fr[t ?? ""] ?? [], d = (S) => o(`fields.${S.label}`, { defaultValue: S.label }), [p, m] = v({}), { data: f, isLoading: w } = le({
3724
3746
  queryKey: ["master", t, n],
3725
3747
  queryFn: () => L.getMaster(t, n),
3726
3748
  enabled: !!t && !!n && !i
3727
3749
  });
3728
- ie(() => {
3750
+ se(() => {
3729
3751
  if (i) {
3730
- const k = {};
3731
- g.forEach((H) => {
3732
- k[H.name] = H.default ?? "";
3733
- }), m(k);
3752
+ const S = {};
3753
+ y.forEach((H) => {
3754
+ S[H.name] = H.default ?? "";
3755
+ }), m(S);
3734
3756
  } else f && m(f);
3735
- }, [i, f, g]);
3736
- const x = oe({
3737
- mutationFn: (k) => L.createMaster(t, k),
3738
- onSuccess: (k) => {
3739
- s.invalidateQueries({ queryKey: ["masters", t] }), a(`/masters/${t}/${k.name}`, { replace: !0 });
3757
+ }, [i, f, y]);
3758
+ const b = oe({
3759
+ mutationFn: (S) => L.createMaster(t, S),
3760
+ onSuccess: (S) => {
3761
+ s.invalidateQueries({ queryKey: ["masters", t] }), a(`/masters/${t}/${S.name}`, { replace: !0 });
3740
3762
  }
3741
- }), y = oe({
3742
- mutationFn: (k) => L.updateMaster(t, n, k),
3763
+ }), g = oe({
3764
+ mutationFn: (S) => L.updateMaster(t, n, S),
3743
3765
  onSuccess: () => {
3744
3766
  s.invalidateQueries({ queryKey: ["master", t, n] }), s.invalidateQueries({ queryKey: ["masters", t] });
3745
3767
  }
3746
3768
  }), P = oe({
3747
3769
  mutationFn: () => L.deleteMaster(t, n),
3748
- onSuccess: (k) => {
3749
- if (s.invalidateQueries({ queryKey: ["masters", t] }), (k == null ? void 0 : k.status) === "disabled") {
3770
+ onSuccess: (S) => {
3771
+ if (s.invalidateQueries({ queryKey: ["masters", t] }), (S == null ? void 0 : S.status) === "disabled") {
3750
3772
  a(`/masters/${t}`, {
3751
3773
  replace: !0,
3752
3774
  state: {
3753
3775
  notice: o("masterForm.disabledOnDelete", {
3754
3776
  label: l,
3755
3777
  name: n,
3756
- reason: k.reason ?? "other records"
3778
+ reason: S.reason ?? "other records"
3757
3779
  })
3758
3780
  }
3759
3781
  });
@@ -3763,18 +3785,18 @@ function Pn() {
3763
3785
  }
3764
3786
  }), D = () => {
3765
3787
  if (A.length > 0) return;
3766
- const k = t === "company" && !p.name ? { ...p, name: p.company_name } : p;
3767
- i ? x.mutate(k) : y.mutate(k);
3788
+ const S = t === "company" && !p.name ? { ...p, name: p.company_name } : p;
3789
+ i ? b.mutate(S) : g.mutate(S);
3768
3790
  }, T = () => {
3769
3791
  window.confirm(o("masterForm.deleteConfirm", { label: l })) && P.mutate();
3770
- }, u = (k, H) => {
3771
- m(($) => ({ ...$, [k]: H }));
3792
+ }, u = (S, H) => {
3793
+ m(($) => ({ ...$, [S]: H }));
3772
3794
  };
3773
- if (!i && S)
3795
+ if (!i && w)
3774
3796
  return /* @__PURE__ */ e("p", { className: "text-fg-muted", children: o("common.loading") });
3775
- const h = x.isPending || y.isPending, A = g.filter((k) => {
3776
- if (!k.required || k.readOnly || i && k.name === "name" && _n.has(t ?? "")) return !1;
3777
- const H = p[k.name];
3797
+ const h = b.isPending || g.isPending, A = y.filter((S) => {
3798
+ if (!S.required || S.readOnly || i && S.name === "name" && _n.has(t ?? "")) return !1;
3799
+ const H = p[S.name];
3778
3800
  return H == null || String(H).trim() === "";
3779
3801
  });
3780
3802
  return /* @__PURE__ */ r("div", { className: "space-y-6", children: [
@@ -3790,56 +3812,56 @@ function Pn() {
3790
3812
  }
3791
3813
  )
3792
3814
  ] }) }),
3793
- (x.error || y.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: ((R = x.error ?? y.error ?? P.error) == null ? void 0 : R.message) ?? o("common.errorOccurred") }),
3815
+ (b.error || g.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: ((R = b.error ?? g.error ?? P.error) == null ? void 0 : R.message) ?? o("common.errorOccurred") }),
3794
3816
  A.length > 0 && /* @__PURE__ */ e("div", { className: "rounded-lg bg-amber-50 p-4 text-sm text-amber-800 ring-1 ring-amber-200", children: o("masterForm.required", { fields: A.map(d).join(", ") }) }),
3795
3817
  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: o("masterForm.disabledNotice", { label: l }) }),
3796
- /* @__PURE__ */ e(U, { children: /* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: g.map((k) => {
3797
- const $ = k.name === "name" && !i || k.readOnly, z = k.required && !(i && k.name === "name" && _n.has(t ?? ""));
3798
- if (k.type === "select" && k.options)
3818
+ /* @__PURE__ */ e(U, { children: /* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: y.map((S) => {
3819
+ const $ = S.name === "name" && !i || S.readOnly, z = S.required && !(i && S.name === "name" && _n.has(t ?? ""));
3820
+ if (S.type === "select" && S.options)
3799
3821
  return /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(
3800
3822
  rt,
3801
3823
  {
3802
- label: d(k),
3803
- options: k.options,
3804
- value: p[k.name] ?? "",
3824
+ label: d(S),
3825
+ options: S.options,
3826
+ value: p[S.name] ?? "",
3805
3827
  required: z,
3806
3828
  disabled: $,
3807
- onChange: (K) => u(k.name, K.target.value)
3829
+ onChange: (K) => u(S.name, K.target.value)
3808
3830
  }
3809
- ) }, k.name);
3810
- if (k.type === "textarea")
3831
+ ) }, S.name);
3832
+ if (S.type === "textarea")
3811
3833
  return /* @__PURE__ */ r("div", { className: "sm:col-span-2", children: [
3812
- /* @__PURE__ */ e("label", { className: "mb-1.5 block text-sm font-medium text-fg", children: d(k) }),
3834
+ /* @__PURE__ */ e("label", { className: "mb-1.5 block text-sm font-medium text-fg", children: d(S) }),
3813
3835
  /* @__PURE__ */ e(
3814
3836
  "textarea",
3815
3837
  {
3816
3838
  className: "block w-full rounded-lg bg-surface px-3 py-2 text-sm text-fg ring-1 ring-line transition-all placeholder:text-fg-muted/70 focus:outline-none focus:ring-2 focus:ring-brand/30 disabled:bg-surface-subtle disabled:text-fg-muted",
3817
3839
  rows: 3,
3818
- value: p[k.name] ?? "",
3840
+ value: p[S.name] ?? "",
3819
3841
  required: z,
3820
3842
  readOnly: $,
3821
3843
  disabled: $,
3822
- onChange: (K) => u(k.name, K.target.value)
3844
+ onChange: (K) => u(S.name, K.target.value)
3823
3845
  }
3824
3846
  )
3825
- ] }, k.name);
3826
- const w = k.type === "number" || k.type === "currency" ? "number" : k.type === "date" ? "date" : "text";
3847
+ ] }, S.name);
3848
+ const k = S.type === "number" || S.type === "currency" ? "number" : S.type === "date" ? "date" : "text";
3827
3849
  return /* @__PURE__ */ e(
3828
- X,
3850
+ ee,
3829
3851
  {
3830
- label: d(k),
3831
- type: w,
3832
- step: k.type === "currency" ? "0.01" : void 0,
3852
+ label: d(S),
3853
+ type: k,
3854
+ step: S.type === "currency" ? "0.01" : void 0,
3833
3855
  required: z,
3834
3856
  readOnly: $,
3835
3857
  disabled: $,
3836
- value: p[k.name] ?? "",
3858
+ value: p[S.name] ?? "",
3837
3859
  onChange: (K) => u(
3838
- k.name,
3839
- w === "number" ? parseFloat(K.target.value) || 0 : K.target.value
3860
+ S.name,
3861
+ k === "number" ? parseFloat(K.target.value) || 0 : K.target.value
3840
3862
  )
3841
3863
  },
3842
- k.name
3864
+ S.name
3843
3865
  );
3844
3866
  }) }) })
3845
3867
  ] });
@@ -3894,16 +3916,16 @@ function Kr(t) {
3894
3916
  return { data: n, isLoading: a, error: s, refetch: o };
3895
3917
  }
3896
3918
  function Wr() {
3897
- const { t } = ae(), [n] = ne("company", ""), [a] = ne("from", ""), [s] = ne("to", ""), o = Qe(), [i, c] = v(n), [l, g] = v(a), [d, p] = v(s), m = He(i), f = (u) => qe(u, m), S = Ie(() => {
3919
+ const { t } = ae(), [n] = ne("company", ""), [a] = ne("from", ""), [s] = ne("to", ""), o = Qe(), [i, c] = v(n), [l, y] = v(a), [d, p] = v(s), m = He(i), f = (u) => qe(u, m), w = Ie(() => {
3898
3920
  const u = {};
3899
3921
  return n && (u.company = n), a && (u.from_date = a), s && (u.to_date = s), u;
3900
- }, [n, a, s]), { data: x, isLoading: y, refetch: P } = zr(S), D = () => {
3922
+ }, [n, a, s]), { data: b, isLoading: g, refetch: P } = zr(w), D = () => {
3901
3923
  o({
3902
3924
  company: i || null,
3903
3925
  from: l || null,
3904
3926
  to: d || null
3905
3927
  }), P();
3906
- }, T = x ? x.difference === 0 : !1;
3928
+ }, T = b ? b.difference === 0 : !1;
3907
3929
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
3908
3930
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
3909
3931
  /* @__PURE__ */ e(
@@ -3917,16 +3939,16 @@ function Wr() {
3917
3939
  }
3918
3940
  ),
3919
3941
  /* @__PURE__ */ e(
3920
- X,
3942
+ ee,
3921
3943
  {
3922
3944
  label: t("fields.From Date", { defaultValue: "From Date" }),
3923
3945
  type: "date",
3924
3946
  value: l,
3925
- onChange: (u) => g(u.target.value)
3947
+ onChange: (u) => y(u.target.value)
3926
3948
  }
3927
3949
  ),
3928
3950
  /* @__PURE__ */ e(
3929
- X,
3951
+ ee,
3930
3952
  {
3931
3953
  label: t("fields.To Date", { defaultValue: "To Date" }),
3932
3954
  type: "date",
@@ -3937,9 +3959,9 @@ function Wr() {
3937
3959
  /* @__PURE__ */ e(J, { onClick: D, children: t("common.apply") })
3938
3960
  ] }),
3939
3961
  /* @__PURE__ */ e(Ft, { onSelect: (u, h) => {
3940
- g(u), p(h), o({ from: u, to: h });
3962
+ y(u), p(h), o({ from: u, to: h });
3941
3963
  } }),
3942
- y ? /* @__PURE__ */ e("p", { className: "text-fg-muted", children: t("common.loading") }) : !x || !x.rows || x.rows.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-fg-muted", children: t("reports.noData") }) : /* @__PURE__ */ r(U, { children: [
3964
+ g ? /* @__PURE__ */ e("p", { className: "text-fg-muted", children: t("common.loading") }) : !b || !b.rows || b.rows.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-fg-muted", children: t("reports.noData") }) : /* @__PURE__ */ r(U, { children: [
3943
3965
  /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-line text-sm", children: [
3944
3966
  /* @__PURE__ */ e("thead", { className: "bg-surface-subtle", children: /* @__PURE__ */ r("tr", { children: [
3945
3967
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-left text-xs font-medium uppercase tracking-wide text-fg-muted", children: t("fields.Account", { defaultValue: "Account" }) }),
@@ -3947,7 +3969,7 @@ function Wr() {
3947
3969
  /* @__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" }) }),
3948
3970
  /* @__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" }) })
3949
3971
  ] }) }),
3950
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children: x.rows.map((u, h) => /* @__PURE__ */ r("tr", { className: "transition-colors hover:bg-surface-subtle", children: [
3972
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children: b.rows.map((u, h) => /* @__PURE__ */ r("tr", { className: "transition-colors hover:bg-surface-subtle", children: [
3951
3973
  /* @__PURE__ */ e("td", { className: "px-4 py-2 text-fg", children: u.account }),
3952
3974
  /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right tabular-nums text-fg", children: f(u.debit) }),
3953
3975
  /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right tabular-nums text-fg", children: f(u.credit) }),
@@ -3955,9 +3977,9 @@ function Wr() {
3955
3977
  ] }, h)) }),
3956
3978
  /* @__PURE__ */ e("tfoot", { className: "border-t border-line bg-surface-subtle font-semibold", children: /* @__PURE__ */ r("tr", { children: [
3957
3979
  /* @__PURE__ */ e("td", { className: "px-4 py-3 text-fg", children: t("common.total") }),
3958
- /* @__PURE__ */ e("td", { className: "px-4 py-3 text-right tabular-nums text-fg", children: f(x.total_debit) }),
3959
- /* @__PURE__ */ e("td", { className: "px-4 py-3 text-right tabular-nums text-fg", children: f(x.total_credit) }),
3960
- /* @__PURE__ */ e("td", { className: "px-4 py-3 text-right tabular-nums text-fg", children: f(x.difference) })
3980
+ /* @__PURE__ */ e("td", { className: "px-4 py-3 text-right tabular-nums text-fg", children: f(b.total_debit) }),
3981
+ /* @__PURE__ */ e("td", { className: "px-4 py-3 text-right tabular-nums text-fg", children: f(b.total_credit) }),
3982
+ /* @__PURE__ */ e("td", { className: "px-4 py-3 text-right tabular-nums text-fg", children: f(b.difference) })
3961
3983
  ] }) })
3962
3984
  ] }) }),
3963
3985
  /* @__PURE__ */ e("div", { className: "mt-4 text-center", children: T ? /* @__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: [
@@ -3975,14 +3997,14 @@ function Hr(t) {
3975
3997
  }
3976
3998
  const Qr = ["25", "50", "100", "200"];
3977
3999
  function Jr() {
3978
- const { t } = ae(), [n] = ne("account", ""), [a] = ne("party", ""), [s] = ne("from", ""), [o] = ne("to", ""), [i] = ne("per_page", 50), [c] = ne("page", 1), l = c - 1, g = Qe(), d = (C) => g({ page: C === 0 ? null : C + 1 }), p = (C) => g({ per_page: C, page: null }), [m, f] = v(n), [S, x] = v(a), [y, P] = v(s), [D, T] = v(o), u = He(), h = (C) => qe(C, u), A = Ie(() => {
4000
+ const { t } = ae(), [n] = ne("account", ""), [a] = ne("party", ""), [s] = ne("from", ""), [o] = ne("to", ""), [i] = ne("per_page", 50), [c] = ne("page", 1), l = c - 1, y = Qe(), d = (C) => y({ page: C === 0 ? null : C + 1 }), p = (C) => y({ per_page: C, page: null }), [m, f] = v(n), [w, b] = v(a), [g, P] = v(s), [D, T] = v(o), u = He(), h = (C) => qe(C, u), A = Ie(() => {
3979
4001
  const C = {};
3980
4002
  return n && (C.account = n), a && (C.party = a), s && (C.from_date = s), o && (C.to_date = o), C.limit = String(i), C.offset = String(l * i), C;
3981
- }, [n, a, s, o, i, l]), { data: R, isLoading: k, refetch: H } = $r(A), $ = (R == null ? void 0 : R.rows) ?? [], z = (R == null ? void 0 : R.total) ?? 0, w = Math.max(1, Math.ceil(z / i)), K = z === 0 ? 0 : l * i + 1, N = Math.min(z, (l + 1) * i), B = () => {
3982
- g({
4003
+ }, [n, a, s, o, i, l]), { data: R, isLoading: S, refetch: H } = $r(A), $ = (R == null ? void 0 : R.rows) ?? [], z = (R == null ? void 0 : R.total) ?? 0, k = Math.max(1, Math.ceil(z / i)), K = z === 0 ? 0 : l * i + 1, N = Math.min(z, (l + 1) * i), B = () => {
4004
+ y({
3983
4005
  account: m || null,
3984
- party: S || null,
3985
- from: y || null,
4006
+ party: w || null,
4007
+ from: g || null,
3986
4008
  to: D || null,
3987
4009
  page: null
3988
4010
  }), H();
@@ -4003,23 +4025,23 @@ function Jr() {
4003
4025
  ke,
4004
4026
  {
4005
4027
  label: t("fields.Party", { defaultValue: "Party" }),
4006
- value: S,
4007
- onChange: x,
4028
+ value: w,
4029
+ onChange: b,
4008
4030
  linkDoctype: "customer",
4009
4031
  readOnly: !1
4010
4032
  }
4011
4033
  ),
4012
4034
  /* @__PURE__ */ e(
4013
- X,
4035
+ ee,
4014
4036
  {
4015
4037
  label: t("fields.From Date", { defaultValue: "From Date" }),
4016
4038
  type: "date",
4017
- value: y,
4039
+ value: g,
4018
4040
  onChange: (C) => P(C.target.value)
4019
4041
  }
4020
4042
  ),
4021
4043
  /* @__PURE__ */ e(
4022
- X,
4044
+ ee,
4023
4045
  {
4024
4046
  label: t("fields.To Date", { defaultValue: "To Date" }),
4025
4047
  type: "date",
@@ -4030,9 +4052,9 @@ function Jr() {
4030
4052
  /* @__PURE__ */ e(J, { onClick: B, children: t("common.apply") })
4031
4053
  ] }),
4032
4054
  /* @__PURE__ */ e(Ft, { onSelect: (C, F) => {
4033
- P(C), T(F), g({ from: C, to: F, page: null });
4055
+ P(C), T(F), y({ from: C, to: F, page: null });
4034
4056
  } }),
4035
- k ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : $.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-gray-400", children: t("reports.noEntries") }) : /* @__PURE__ */ r(Se, { children: [
4057
+ S ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : $.length === 0 ? /* @__PURE__ */ e("p", { className: "py-8 text-center text-gray-400", children: t("reports.noEntries") }) : /* @__PURE__ */ r(Se, { children: [
4036
4058
  /* @__PURE__ */ e(U, { children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
4037
4059
  /* @__PURE__ */ e("thead", { className: "bg-gray-50", children: /* @__PURE__ */ r("tr", { children: [
4038
4060
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: t("fields.Date", { defaultValue: "Date" }) }),
@@ -4105,13 +4127,13 @@ function Jr() {
4105
4127
  " ",
4106
4128
  t("common.of"),
4107
4129
  " ",
4108
- /* @__PURE__ */ e("span", { className: "font-medium text-gray-900", children: w })
4130
+ /* @__PURE__ */ e("span", { className: "font-medium text-gray-900", children: k })
4109
4131
  ] }),
4110
4132
  /* @__PURE__ */ e(
4111
4133
  "button",
4112
4134
  {
4113
- onClick: () => d(Math.min(w - 1, l + 1)),
4114
- disabled: l >= w - 1,
4135
+ onClick: () => d(Math.min(k - 1, l + 1)),
4136
+ disabled: l >= k - 1,
4115
4137
  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",
4116
4138
  children: t("common.next")
4117
4139
  }
@@ -4122,14 +4144,14 @@ function Jr() {
4122
4144
  ] });
4123
4145
  }
4124
4146
  function Yr() {
4125
- const { t } = ae(), [n] = ne("item_code", ""), [a] = ne("warehouse", ""), s = Qe(), [o, i] = v(n), [c, l] = v(a), g = He(), d = (y) => qe(y, g), p = Ie(() => {
4126
- const y = {};
4127
- return n && (y.item_code = n), a && (y.warehouse = a), y;
4128
- }, [n, a]), { data: m, isLoading: f, refetch: S } = Ur(p), x = () => {
4147
+ const { t } = ae(), [n] = ne("item_code", ""), [a] = ne("warehouse", ""), s = Qe(), [o, i] = v(n), [c, l] = v(a), y = He(), d = (g) => qe(g, y), p = Ie(() => {
4148
+ const g = {};
4149
+ return n && (g.item_code = n), a && (g.warehouse = a), g;
4150
+ }, [n, a]), { data: m, isLoading: f, refetch: w } = Ur(p), b = () => {
4129
4151
  s({
4130
4152
  item_code: o || null,
4131
4153
  warehouse: c || null
4132
- }), S();
4154
+ }), w();
4133
4155
  };
4134
4156
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4135
4157
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
@@ -4153,7 +4175,7 @@ function Yr() {
4153
4175
  readOnly: !1
4154
4176
  }
4155
4177
  ),
4156
- /* @__PURE__ */ e(J, { onClick: x, children: t("common.apply") })
4178
+ /* @__PURE__ */ e(J, { onClick: b, children: t("common.apply") })
4157
4179
  ] }),
4158
4180
  f ? /* @__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(U, { children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
4159
4181
  /* @__PURE__ */ e("thead", { className: "bg-gray-50", children: /* @__PURE__ */ r("tr", { children: [
@@ -4164,39 +4186,39 @@ function Yr() {
4164
4186
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-right font-medium text-gray-500", children: t("fields.Valuation Rate", { defaultValue: "Valuation Rate" }) }),
4165
4187
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-right font-medium text-gray-500", children: t("fields.Stock Value", { defaultValue: "Stock Value" }) })
4166
4188
  ] }) }),
4167
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: m.rows.map((y, P) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4168
- /* @__PURE__ */ e("td", { className: "px-4 py-2 font-medium text-gray-900", children: y.item_code }),
4169
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-700", children: y.item_name }),
4170
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-700", children: y.warehouse }),
4171
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: Ht(y.actual_qty) }),
4172
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: d(y.valuation_rate) }),
4173
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right font-medium", children: d(y.stock_value) })
4189
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: m.rows.map((g, P) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4190
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 font-medium text-gray-900", children: g.item_code }),
4191
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-700", children: g.item_name }),
4192
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-700", children: g.warehouse }),
4193
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: Ht(g.actual_qty) }),
4194
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: d(g.valuation_rate) }),
4195
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right font-medium", children: d(g.stock_value) })
4174
4196
  ] }, P)) })
4175
4197
  ] }) }) })
4176
4198
  ] });
4177
4199
  }
4178
4200
  function Zr() {
4179
- const { t } = ae(), [n] = ne("company", ""), [a] = ne("from", ""), [s] = ne("to", ""), o = Qe(), [i, c] = v(n), l = He(i), g = (u) => qe(u, l), [d, p] = v(a), [m, f] = v(s), S = Ie(() => {
4201
+ const { t } = ae(), [n] = ne("company", ""), [a] = ne("from", ""), [s] = ne("to", ""), o = Qe(), [i, c] = v(n), l = He(i), y = (u) => qe(u, l), [d, p] = v(a), [m, f] = v(s), w = Ie(() => {
4180
4202
  const u = {};
4181
4203
  return n && (u.company = n), a && (u.from_date = a), s && (u.to_date = s), u;
4182
- }, [n, a, s]), { data: x, isLoading: y, refetch: P } = Vr(S), D = () => {
4204
+ }, [n, a, s]), { data: b, isLoading: g, refetch: P } = Vr(w), D = () => {
4183
4205
  o({
4184
4206
  company: i || null,
4185
4207
  from: d || null,
4186
4208
  to: m || null
4187
4209
  }), P();
4188
- }, T = x && (x.income && x.income.length > 0 || x.expense && x.expense.length > 0);
4210
+ }, T = b && (b.income && b.income.length > 0 || b.expense && b.expense.length > 0);
4189
4211
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4190
4212
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
4191
4213
  /* @__PURE__ */ e(ke, { label: t("fields.Company", { defaultValue: "Company" }), value: i, onChange: c, linkDoctype: "company", readOnly: !1 }),
4192
- /* @__PURE__ */ e(X, { label: t("fields.From Date", { defaultValue: "From Date" }), type: "date", value: d, onChange: (u) => p(u.target.value) }),
4193
- /* @__PURE__ */ e(X, { label: t("fields.To Date", { defaultValue: "To Date" }), type: "date", value: m, onChange: (u) => f(u.target.value) }),
4214
+ /* @__PURE__ */ e(ee, { label: t("fields.From Date", { defaultValue: "From Date" }), type: "date", value: d, onChange: (u) => p(u.target.value) }),
4215
+ /* @__PURE__ */ e(ee, { label: t("fields.To Date", { defaultValue: "To Date" }), type: "date", value: m, onChange: (u) => f(u.target.value) }),
4194
4216
  /* @__PURE__ */ e(J, { onClick: D, children: t("common.apply") })
4195
4217
  ] }),
4196
4218
  /* @__PURE__ */ e(Ft, { onSelect: (u, h) => {
4197
4219
  p(u), f(h), o({ from: u, to: h });
4198
4220
  } }),
4199
- y ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : T ? /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4221
+ g ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : T ? /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4200
4222
  /* @__PURE__ */ r(U, { children: [
4201
4223
  /* @__PURE__ */ e("h3", { className: "mb-3 text-base font-semibold text-gray-800", children: t("reports.income") }),
4202
4224
  /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
@@ -4204,13 +4226,13 @@ function Zr() {
4204
4226
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: t("fields.Account", { defaultValue: "Account" }) }),
4205
4227
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-right font-medium text-gray-500", children: t("fields.Amount", { defaultValue: "Amount" }) })
4206
4228
  ] }) }),
4207
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: (x.income || []).map((u, h) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4229
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: (b.income || []).map((u, h) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4208
4230
  /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-900", children: u.account }),
4209
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: g(u.amount) })
4231
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: y(u.amount) })
4210
4232
  ] }, h)) }),
4211
4233
  /* @__PURE__ */ e("tfoot", { className: "border-t-2 border-gray-300 bg-gray-50 font-semibold", children: /* @__PURE__ */ r("tr", { children: [
4212
4234
  /* @__PURE__ */ e("td", { className: "px-4 py-3 text-gray-900", children: t("reports.totalIncome") }),
4213
- /* @__PURE__ */ e("td", { className: "px-4 py-3 text-right", children: g(x.total_income) })
4235
+ /* @__PURE__ */ e("td", { className: "px-4 py-3 text-right", children: y(b.total_income) })
4214
4236
  ] }) })
4215
4237
  ] })
4216
4238
  ] }),
@@ -4221,20 +4243,20 @@ function Zr() {
4221
4243
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: t("fields.Account", { defaultValue: "Account" }) }),
4222
4244
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-right font-medium text-gray-500", children: t("fields.Amount", { defaultValue: "Amount" }) })
4223
4245
  ] }) }),
4224
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: (x.expense || []).map((u, h) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4246
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: (b.expense || []).map((u, h) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4225
4247
  /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-900", children: u.account }),
4226
- /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: g(u.amount) })
4248
+ /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: y(u.amount) })
4227
4249
  ] }, h)) }),
4228
4250
  /* @__PURE__ */ e("tfoot", { className: "border-t-2 border-gray-300 bg-gray-50 font-semibold", children: /* @__PURE__ */ r("tr", { children: [
4229
4251
  /* @__PURE__ */ e("td", { className: "px-4 py-3 text-gray-900", children: t("reports.totalExpenses") }),
4230
- /* @__PURE__ */ e("td", { className: "px-4 py-3 text-right", children: g(x.total_expense) })
4252
+ /* @__PURE__ */ e("td", { className: "px-4 py-3 text-right", children: y(b.total_expense) })
4231
4253
  ] }) })
4232
4254
  ] })
4233
4255
  ] }),
4234
- /* @__PURE__ */ e("div", { className: "text-center", children: /* @__PURE__ */ r("span", { className: `inline-flex items-center rounded-full px-5 py-2 text-sm font-semibold ${x.net_profit >= 0 ? "bg-green-100 text-green-800" : "bg-red-100 text-red-800"}`, children: [
4235
- x.net_profit >= 0 ? t("reports.netProfit") : t("reports.netLoss"),
4256
+ /* @__PURE__ */ e("div", { className: "text-center", children: /* @__PURE__ */ r("span", { className: `inline-flex items-center rounded-full px-5 py-2 text-sm font-semibold ${b.net_profit >= 0 ? "bg-green-100 text-green-800" : "bg-red-100 text-red-800"}`, children: [
4257
+ b.net_profit >= 0 ? t("reports.netProfit") : t("reports.netLoss"),
4236
4258
  ": ",
4237
- g(Math.abs(x.net_profit))
4259
+ y(Math.abs(b.net_profit))
4238
4260
  ] }) })
4239
4261
  ] }) : /* @__PURE__ */ e("p", { className: "py-8 text-center text-gray-400", children: t("reports.noData") })
4240
4262
  ] });
@@ -4248,10 +4270,10 @@ function Vt({ title: t, rows: n, total: a, totalLabel: s, currency: o }) {
4248
4270
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-left font-medium text-gray-500", children: i("fields.Account", { defaultValue: "Account" }) }),
4249
4271
  /* @__PURE__ */ e("th", { className: "px-4 py-3 text-right font-medium text-gray-500", children: i("fields.Balance", { defaultValue: "Balance" }) })
4250
4272
  ] }) }),
4251
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: n.map((l, g) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4273
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: n.map((l, y) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4252
4274
  /* @__PURE__ */ e("td", { className: "px-4 py-2 text-gray-900", children: l.account }),
4253
4275
  /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: c(l.balance) })
4254
- ] }, g)) }),
4276
+ ] }, y)) }),
4255
4277
  /* @__PURE__ */ e("tfoot", { className: "border-t-2 border-gray-300 bg-gray-50 font-semibold", children: /* @__PURE__ */ r("tr", { children: [
4256
4278
  /* @__PURE__ */ e("td", { className: "px-4 py-3 text-gray-900", children: s }),
4257
4279
  /* @__PURE__ */ e("td", { className: "px-4 py-3 text-right", children: c(a) })
@@ -4261,25 +4283,25 @@ function Vt({ title: t, rows: n, total: a, totalLabel: s, currency: o }) {
4261
4283
  }
4262
4284
  function Xr() {
4263
4285
  var D, T, u;
4264
- const { t } = ae(), [n] = ne("company", ""), [a] = ne("as_of_date", ""), s = Qe(), [o, i] = v(n), [c, l] = v(a), g = He(o), d = (h) => qe(h, g), p = Ie(() => {
4286
+ const { t } = ae(), [n] = ne("company", ""), [a] = ne("as_of_date", ""), s = Qe(), [o, i] = v(n), [c, l] = v(a), y = He(o), d = (h) => qe(h, y), p = Ie(() => {
4265
4287
  const h = {};
4266
4288
  return n && (h.company = n), a && (h.as_of_date = a), h;
4267
- }, [n, a]), { data: m, isLoading: f, refetch: S } = jr(p), x = () => {
4268
- s({ company: o || null, as_of_date: c || null }), S();
4269
- }, y = m && (((D = m.assets) == null ? void 0 : D.length) > 0 || ((T = m.liabilities) == null ? void 0 : T.length) > 0 || ((u = m.equity) == null ? void 0 : u.length) > 0), P = m ? Math.abs(m.total_assets - m.total_liabilities_and_equity) < 0.01 : !1;
4289
+ }, [n, a]), { data: m, isLoading: f, refetch: w } = jr(p), b = () => {
4290
+ s({ company: o || null, as_of_date: c || null }), w();
4291
+ }, g = m && (((D = m.assets) == null ? void 0 : D.length) > 0 || ((T = m.liabilities) == null ? void 0 : T.length) > 0 || ((u = m.equity) == null ? void 0 : u.length) > 0), P = m ? Math.abs(m.total_assets - m.total_liabilities_and_equity) < 0.01 : !1;
4270
4292
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4271
4293
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
4272
4294
  /* @__PURE__ */ e(ke, { label: t("fields.Company", { defaultValue: "Company" }), value: o, onChange: i, linkDoctype: "company", readOnly: !1 }),
4273
- /* @__PURE__ */ e(X, { label: t("fields.As of Date", { defaultValue: "As of Date" }), type: "date", value: c, onChange: (h) => l(h.target.value) }),
4274
- /* @__PURE__ */ e(J, { onClick: x, children: t("common.apply") })
4295
+ /* @__PURE__ */ e(ee, { label: t("fields.As of Date", { defaultValue: "As of Date" }), type: "date", value: c, onChange: (h) => l(h.target.value) }),
4296
+ /* @__PURE__ */ e(J, { onClick: b, children: t("common.apply") })
4275
4297
  ] }),
4276
4298
  /* @__PURE__ */ e(ln, { onSelect: (h) => {
4277
4299
  l(h), s({ as_of_date: h });
4278
4300
  } }),
4279
- f ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : y ? /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4280
- /* @__PURE__ */ e(Vt, { title: t("reports.assets"), rows: m.assets || [], total: m.total_assets, totalLabel: t("reports.totalAssets"), currency: g }),
4281
- /* @__PURE__ */ e(Vt, { title: t("reports.liabilities"), rows: m.liabilities || [], total: m.total_liabilities, totalLabel: t("reports.totalLiabilities"), currency: g }),
4282
- /* @__PURE__ */ e(Vt, { title: t("reports.equity"), rows: m.equity || [], total: m.total_equity, totalLabel: t("reports.totalEquity"), currency: g }),
4301
+ f ? /* @__PURE__ */ e("p", { className: "text-gray-500", children: t("common.loading") }) : g ? /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4302
+ /* @__PURE__ */ e(Vt, { title: t("reports.assets"), rows: m.assets || [], total: m.total_assets, totalLabel: t("reports.totalAssets"), currency: y }),
4303
+ /* @__PURE__ */ e(Vt, { title: t("reports.liabilities"), rows: m.liabilities || [], total: m.total_liabilities, totalLabel: t("reports.totalLiabilities"), currency: y }),
4304
+ /* @__PURE__ */ e(Vt, { title: t("reports.equity"), rows: m.equity || [], total: m.total_equity, totalLabel: t("reports.totalEquity"), currency: y }),
4283
4305
  /* @__PURE__ */ e(U, { children: /* @__PURE__ */ r("div", { className: "flex items-center justify-between", children: [
4284
4306
  /* @__PURE__ */ r("div", { className: "text-sm", children: [
4285
4307
  /* @__PURE__ */ r("div", { className: "text-gray-500", children: [
@@ -4299,20 +4321,20 @@ function Xr() {
4299
4321
  ] });
4300
4322
  }
4301
4323
  function es() {
4302
- const { t } = ae(), [n] = ne("company", ""), [a] = ne("as_of_date", ""), s = Qe(), [o, i] = v(n), [c, l] = v(a), g = He(o), d = (y) => qe(y, g), p = Ie(() => {
4303
- const y = {};
4304
- return n && (y.company = n), a && (y.as_of_date = a), y;
4305
- }, [n, a]), { data: m, isLoading: f, refetch: S } = Gr(p), x = () => {
4306
- s({ company: o || null, as_of_date: c || null }), S();
4324
+ const { t } = ae(), [n] = ne("company", ""), [a] = ne("as_of_date", ""), s = Qe(), [o, i] = v(n), [c, l] = v(a), y = He(o), d = (g) => qe(g, y), p = Ie(() => {
4325
+ const g = {};
4326
+ return n && (g.company = n), a && (g.as_of_date = a), g;
4327
+ }, [n, a]), { data: m, isLoading: f, refetch: w } = Gr(p), b = () => {
4328
+ s({ company: o || null, as_of_date: c || null }), w();
4307
4329
  };
4308
4330
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4309
4331
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
4310
4332
  /* @__PURE__ */ e(ke, { label: t("fields.Company", { defaultValue: "Company" }), value: o, onChange: i, linkDoctype: "company", readOnly: !1 }),
4311
- /* @__PURE__ */ e(X, { label: t("fields.As of Date", { defaultValue: "As of Date" }), type: "date", value: c, onChange: (y) => l(y.target.value) }),
4312
- /* @__PURE__ */ e(J, { onClick: x, children: t("common.apply") })
4333
+ /* @__PURE__ */ e(ee, { label: t("fields.As of Date", { defaultValue: "As of Date" }), type: "date", value: c, onChange: (g) => l(g.target.value) }),
4334
+ /* @__PURE__ */ e(J, { onClick: b, children: t("common.apply") })
4313
4335
  ] }),
4314
- /* @__PURE__ */ e(ln, { onSelect: (y) => {
4315
- l(y), s({ as_of_date: y });
4336
+ /* @__PURE__ */ e(ln, { onSelect: (g) => {
4337
+ l(g), s({ as_of_date: g });
4316
4338
  } }),
4317
4339
  f ? /* @__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(U, { children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
4318
4340
  /* @__PURE__ */ e("thead", { className: "bg-gray-50", children: /* @__PURE__ */ r("tr", { children: [
@@ -4326,23 +4348,23 @@ function es() {
4326
4348
  /* @__PURE__ */ e("th", { className: "px-3 py-3 text-right font-medium text-gray-500", children: "61-90" }),
4327
4349
  /* @__PURE__ */ e("th", { className: "px-3 py-3 text-right font-medium text-gray-500", children: "90+" })
4328
4350
  ] }) }),
4329
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: m.rows.map((y, P) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4351
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: m.rows.map((g, P) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4330
4352
  /* @__PURE__ */ e("td", { className: "px-3 py-2", children: /* @__PURE__ */ e(
4331
4353
  Ne,
4332
4354
  {
4333
- to: `/app/sales-invoice/${encodeURIComponent(y.invoice)}`,
4355
+ to: `/app/sales-invoice/${encodeURIComponent(g.invoice)}`,
4334
4356
  className: "font-medium text-blue-600 hover:text-blue-800",
4335
- children: y.invoice
4357
+ children: g.invoice
4336
4358
  }
4337
4359
  ) }),
4338
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-gray-900", children: y.customer_name }),
4339
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-gray-600", children: y.due_date }),
4340
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right font-medium", children: d(y.outstanding) }),
4341
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.current ? d(y.current) : "" }),
4342
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.b1_30 ? d(y.b1_30) : "" }),
4343
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.b31_60 ? d(y.b31_60) : "" }),
4344
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.b61_90 ? d(y.b61_90) : "" }),
4345
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right text-red-600", children: y.b90_plus ? d(y.b90_plus) : "" })
4360
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-gray-900", children: g.customer_name }),
4361
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-gray-600", children: g.due_date }),
4362
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right font-medium", children: d(g.outstanding) }),
4363
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: g.current ? d(g.current) : "" }),
4364
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: g.b1_30 ? d(g.b1_30) : "" }),
4365
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: g.b31_60 ? d(g.b31_60) : "" }),
4366
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: g.b61_90 ? d(g.b61_90) : "" }),
4367
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right text-red-600", children: g.b90_plus ? d(g.b90_plus) : "" })
4346
4368
  ] }, P)) }),
4347
4369
  /* @__PURE__ */ e("tfoot", { className: "border-t-2 border-gray-300 bg-gray-50 font-semibold", children: /* @__PURE__ */ r("tr", { children: [
4348
4370
  /* @__PURE__ */ e("td", { className: "px-3 py-3", colSpan: 3, children: t("common.total") }),
@@ -4357,20 +4379,20 @@ function es() {
4357
4379
  ] });
4358
4380
  }
4359
4381
  function ts() {
4360
- const { t } = ae(), [n] = ne("company", ""), [a] = ne("as_of_date", ""), s = Qe(), [o, i] = v(n), [c, l] = v(a), g = He(o), d = (y) => qe(y, g), p = Ie(() => {
4361
- const y = {};
4362
- return n && (y.company = n), a && (y.as_of_date = a), y;
4363
- }, [n, a]), { data: m, isLoading: f, refetch: S } = Kr(p), x = () => {
4364
- s({ company: o || null, as_of_date: c || null }), S();
4382
+ const { t } = ae(), [n] = ne("company", ""), [a] = ne("as_of_date", ""), s = Qe(), [o, i] = v(n), [c, l] = v(a), y = He(o), d = (g) => qe(g, y), p = Ie(() => {
4383
+ const g = {};
4384
+ return n && (g.company = n), a && (g.as_of_date = a), g;
4385
+ }, [n, a]), { data: m, isLoading: f, refetch: w } = Kr(p), b = () => {
4386
+ s({ company: o || null, as_of_date: c || null }), w();
4365
4387
  };
4366
4388
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4367
4389
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
4368
4390
  /* @__PURE__ */ e(ke, { label: t("fields.Company", { defaultValue: "Company" }), value: o, onChange: i, linkDoctype: "company", readOnly: !1 }),
4369
- /* @__PURE__ */ e(X, { label: t("fields.As of Date", { defaultValue: "As of Date" }), type: "date", value: c, onChange: (y) => l(y.target.value) }),
4370
- /* @__PURE__ */ e(J, { onClick: x, children: t("common.apply") })
4391
+ /* @__PURE__ */ e(ee, { label: t("fields.As of Date", { defaultValue: "As of Date" }), type: "date", value: c, onChange: (g) => l(g.target.value) }),
4392
+ /* @__PURE__ */ e(J, { onClick: b, children: t("common.apply") })
4371
4393
  ] }),
4372
- /* @__PURE__ */ e(ln, { onSelect: (y) => {
4373
- l(y), s({ as_of_date: y });
4394
+ /* @__PURE__ */ e(ln, { onSelect: (g) => {
4395
+ l(g), s({ as_of_date: g });
4374
4396
  } }),
4375
4397
  f ? /* @__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(U, { children: /* @__PURE__ */ e("div", { className: "overflow-x-auto", children: /* @__PURE__ */ r("table", { className: "min-w-full divide-y divide-gray-200 text-sm", children: [
4376
4398
  /* @__PURE__ */ e("thead", { className: "bg-gray-50", children: /* @__PURE__ */ r("tr", { children: [
@@ -4384,23 +4406,23 @@ function ts() {
4384
4406
  /* @__PURE__ */ e("th", { className: "px-3 py-3 text-right font-medium text-gray-500", children: "61-90" }),
4385
4407
  /* @__PURE__ */ e("th", { className: "px-3 py-3 text-right font-medium text-gray-500", children: "90+" })
4386
4408
  ] }) }),
4387
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: m.rows.map((y, P) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4409
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: m.rows.map((g, P) => /* @__PURE__ */ r("tr", { className: "hover:bg-gray-50", children: [
4388
4410
  /* @__PURE__ */ e("td", { className: "px-3 py-2", children: /* @__PURE__ */ e(
4389
4411
  Ne,
4390
4412
  {
4391
- to: `/app/purchase-invoice/${encodeURIComponent(y.invoice)}`,
4413
+ to: `/app/purchase-invoice/${encodeURIComponent(g.invoice)}`,
4392
4414
  className: "font-medium text-blue-600 hover:text-blue-800",
4393
- children: y.invoice
4415
+ children: g.invoice
4394
4416
  }
4395
4417
  ) }),
4396
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-gray-900", children: y.supplier_name }),
4397
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-gray-600", children: y.due_date }),
4398
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right font-medium", children: d(y.outstanding) }),
4399
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.current ? d(y.current) : "" }),
4400
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.b1_30 ? d(y.b1_30) : "" }),
4401
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.b31_60 ? d(y.b31_60) : "" }),
4402
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: y.b61_90 ? d(y.b61_90) : "" }),
4403
- /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right text-red-600", children: y.b90_plus ? d(y.b90_plus) : "" })
4418
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-gray-900", children: g.supplier_name }),
4419
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-gray-600", children: g.due_date }),
4420
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right font-medium", children: d(g.outstanding) }),
4421
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: g.current ? d(g.current) : "" }),
4422
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: g.b1_30 ? d(g.b1_30) : "" }),
4423
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: g.b31_60 ? d(g.b31_60) : "" }),
4424
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right", children: g.b61_90 ? d(g.b61_90) : "" }),
4425
+ /* @__PURE__ */ e("td", { className: "px-3 py-2 text-right text-red-600", children: g.b90_plus ? d(g.b90_plus) : "" })
4404
4426
  ] }, P)) }),
4405
4427
  /* @__PURE__ */ e("tfoot", { className: "border-t-2 border-gray-300 bg-gray-50 font-semibold", children: /* @__PURE__ */ r("tr", { children: [
4406
4428
  /* @__PURE__ */ e("td", { className: "px-3 py-3", colSpan: 3, children: t("common.total") }),
@@ -4414,7 +4436,7 @@ function ts() {
4414
4436
  ] }) }) })
4415
4437
  ] });
4416
4438
  }
4417
- const sa = '(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', Tn = typeof self < "u" && self.Blob && new Blob([sa], { type: "text/javascript;charset=utf-8" });
4439
+ const ia = '(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', Tn = typeof self < "u" && self.Blob && new Blob([ia], { type: "text/javascript;charset=utf-8" });
4418
4440
  function ns(t) {
4419
4441
  let n;
4420
4442
  try {
@@ -4427,7 +4449,7 @@ function ns(t) {
4427
4449
  }), a;
4428
4450
  } catch {
4429
4451
  return new Worker(
4430
- "data:text/javascript;charset=utf-8," + encodeURIComponent(sa),
4452
+ "data:text/javascript;charset=utf-8," + encodeURIComponent(ia),
4431
4453
  {
4432
4454
  name: t == null ? void 0 : t.name
4433
4455
  }
@@ -4507,31 +4529,31 @@ return {
4507
4529
  2
4508
4530
  );
4509
4531
  }
4510
- const ia = as();
4532
+ const oa = as();
4511
4533
  function rs() {
4512
- const t = Oe(), { sessions: n, createSession: a } = ct(), [s] = ne("report_id", ""), [o] = ne("metric", ""), [i] = ne("group_by", ""), [c] = ne("from", ""), [l] = ne("to", ""), [g] = ne("company", ""), [d, p] = v(ia), [m, f] = v([]), [S, x] = v(null), [y, P] = v(""), [D, T] = v(!1), [u, h] = v(!1), [A, R] = v(""), k = ee(null), H = ee(""), $ = ee(""), z = ee(0), w = Ie(() => !o || !i ? "" : JSON.stringify(ls({
4534
+ const t = Oe(), { sessions: n, createSession: a } = ct(), [s] = ne("report_id", ""), [o] = ne("metric", ""), [i] = ne("group_by", ""), [c] = ne("from", ""), [l] = ne("to", ""), [y] = ne("company", ""), [d, p] = v(oa), [m, f] = v([]), [w, b] = v(null), [g, P] = v(""), [D, T] = v(!1), [u, h] = v(!1), [A, R] = v(""), S = X(null), H = X(""), $ = X(""), z = X(0), k = Ie(() => !o || !i ? "" : JSON.stringify(ls({
4513
4535
  metric: o,
4514
4536
  groupBy: i,
4515
4537
  fromDate: c || void 0,
4516
4538
  toDate: l || void 0,
4517
- company: g || void 0
4518
- }), null, 2), [o, i, c, l, g]), K = async (F) => {
4539
+ company: y || void 0
4540
+ }), null, 2), [o, i, c, l, y]), K = async (F) => {
4519
4541
  var he;
4520
4542
  const Z = ++z.current, re = () => z.current === Z;
4521
4543
  P(""), T(!0);
4522
4544
  try {
4523
4545
  const _e = JSON.parse(F ?? d), me = await L.runtimeData({ requests: _e.data_requests || [] });
4524
4546
  if (!re()) return;
4525
- f(me.datasets), (he = k.current) == null || he.terminate();
4547
+ f(me.datasets), (he = S.current) == null || he.terminate();
4526
4548
  const ye = new ns();
4527
- k.current = ye;
4549
+ S.current = ye;
4528
4550
  const ze = await new Promise((I, te) => {
4529
4551
  const Ae = window.setTimeout(() => {
4530
4552
  ye.terminate(), te(new Error("Report runtime exceeded 4 seconds"));
4531
4553
  }, 4e3);
4532
4554
  ye.onmessage = (Ce) => {
4533
4555
  var $e, Fe;
4534
- window.clearTimeout(Ae), ye.terminate(), k.current === ye && (k.current = null), ($e = Ce.data) != null && $e.ok ? I(Ce.data.output) : te(new Error(((Fe = Ce.data) == null ? void 0 : Fe.error) || "Runtime failed"));
4556
+ window.clearTimeout(Ae), ye.terminate(), S.current === ye && (S.current = null), ($e = Ce.data) != null && $e.ok ? I(Ce.data.output) : te(new Error(((Fe = Ce.data) == null ? void 0 : Fe.error) || "Runtime failed"));
4535
4557
  }, ye.postMessage({
4536
4558
  datasets: me.datasets,
4537
4559
  params: {},
@@ -4539,31 +4561,31 @@ function rs() {
4539
4561
  });
4540
4562
  });
4541
4563
  if (!re()) return;
4542
- x(ze);
4564
+ b(ze);
4543
4565
  } catch (ge) {
4544
4566
  if (!re()) return;
4545
- x(null), P(ge instanceof Error ? ge.message : String(ge));
4567
+ b(null), P(ge instanceof Error ? ge.message : String(ge));
4546
4568
  } finally {
4547
4569
  re() && T(!1);
4548
4570
  }
4549
4571
  };
4550
- ie(() => {
4572
+ se(() => {
4551
4573
  let F = !1;
4552
4574
  return s ? H.current === s ? void 0 : (h(!0), P(""), L.getRuntimeDraft(s).then((Z) => {
4553
4575
  if (F) return;
4554
4576
  const re = JSON.stringify(Z.definition, null, 2);
4555
4577
  return H.current = s, $.current = re, R(Z.source_chat_session_id || ""), p(re), K(re);
4556
4578
  }).catch((Z) => {
4557
- F || (x(null), P(Z instanceof Error ? Z.message : String(Z)));
4579
+ F || (b(null), P(Z instanceof Error ? Z.message : String(Z)));
4558
4580
  }).finally(() => {
4559
4581
  F || h(!1);
4560
4582
  }), () => {
4561
4583
  F = !0;
4562
- }) : (H.current = "", $.current = "", R(""), w && ($.current = w, p(w), K(w)), () => {
4584
+ }) : (H.current = "", $.current = "", R(""), k && ($.current = k, p(k), K(k)), () => {
4563
4585
  F = !0;
4564
4586
  });
4565
- }, [s, w]);
4566
- const N = !!(!s && w), B = Ie(() => os(S), [S]), C = async () => {
4587
+ }, [s, k]);
4588
+ const N = !!(!s && k), B = Ie(() => os(w), [w]), C = async () => {
4567
4589
  var me;
4568
4590
  const F = d.trim() !== $.current.trim(), Z = s || "unsaved-runtime-report", re = m.map((ye) => ({
4569
4591
  name: ye.name,
@@ -4576,7 +4598,7 @@ function rs() {
4576
4598
  `Report ID: ${Z}`,
4577
4599
  "",
4578
4600
  "Current issue summary:",
4579
- y || B.join(`
4601
+ g || B.join(`
4580
4602
  `) || "No runtime error captured; please review and improve the report definition."
4581
4603
  ];
4582
4604
  F ? he.push(
@@ -4615,7 +4637,7 @@ function rs() {
4615
4637
  /* @__PURE__ */ e(J, { onClick: () => void K(), disabled: D, children: D ? "Running..." : "Run Report" })
4616
4638
  ] })
4617
4639
  ] }) }),
4618
- u ? /* @__PURE__ */ e(U, { children: /* @__PURE__ */ e("p", { className: "text-sm text-gray-600", children: "Loading draft..." }) }) : y ? /* @__PURE__ */ e(U, { children: /* @__PURE__ */ e("p", { className: "text-sm text-red-600", children: y }) }) : S ? /* @__PURE__ */ e(ss, { output: S }) : /* @__PURE__ */ e(U, { 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." }) }),
4640
+ u ? /* @__PURE__ */ e(U, { children: /* @__PURE__ */ e("p", { className: "text-sm text-gray-600", children: "Loading draft..." }) }) : g ? /* @__PURE__ */ e(U, { children: /* @__PURE__ */ e("p", { className: "text-sm text-red-600", children: g }) }) : w ? /* @__PURE__ */ e(ss, { output: w }) : /* @__PURE__ */ e(U, { 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." }) }),
4619
4641
  m.length > 0 && /* @__PURE__ */ e(U, { title: "Fetched Datasets", children: /* @__PURE__ */ e("div", { className: "space-y-4", children: m.map((F) => /* @__PURE__ */ r("div", { className: "rounded-md border border-gray-200 p-4", children: [
4620
4642
  /* @__PURE__ */ r("div", { className: "flex items-baseline justify-between gap-4", children: [
4621
4643
  /* @__PURE__ */ r("div", { children: [
@@ -4649,7 +4671,7 @@ function ss({ output: t }) {
4649
4671
  const n = (t.tables ?? []).map((i, c) => ({
4650
4672
  ...i,
4651
4673
  id: i.id || `table_${c + 1}`
4652
- })), a = oa(n);
4674
+ })), a = la(n);
4653
4675
  return /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4654
4676
  /* @__PURE__ */ r(U, { children: [
4655
4677
  /* @__PURE__ */ e("div", { className: "flex items-baseline justify-between gap-4", children: /* @__PURE__ */ r("div", { children: [
@@ -4662,13 +4684,13 @@ function ss({ output: t }) {
4662
4684
  ] }, `${i.label}-${c}`)) }) : null
4663
4685
  ] }),
4664
4686
  (o = t.charts) == null ? void 0 : o.map((i, c) => {
4665
- const l = i.dataTable ? a.get(i.dataTable) : void 0, g = i.data ?? (l == null ? void 0 : l.rows) ?? [];
4666
- if (!g.length)
4687
+ const l = i.dataTable ? a.get(i.dataTable) : void 0, y = i.data ?? (l == null ? void 0 : l.rows) ?? [];
4688
+ if (!y.length)
4667
4689
  return /* @__PURE__ */ e(U, { title: i.title, children: /* @__PURE__ */ e("p", { className: "text-sm text-red-600", children: "Chart has no usable data." }) }, i.id || `chart_${c + 1}`);
4668
- const d = i.type === "pie" ? [] : g.map((f) => String(f[i.x] ?? "")), p = ms(d), m = Math.max(320, 200 + p.axisHeight);
4690
+ const d = i.type === "pie" ? [] : y.map((f) => String(f[i.x] ?? "")), p = ms(d), m = Math.max(320, 200 + p.axisHeight);
4669
4691
  return /* @__PURE__ */ r(U, { children: [
4670
4692
  /* @__PURE__ */ e("div", { className: "pb-3 text-sm font-semibold text-gray-700", children: i.title }),
4671
- /* @__PURE__ */ e("div", { style: { height: m }, className: "w-full", children: /* @__PURE__ */ e(Ma, { width: "100%", height: "100%", children: i.type === "line" ? /* @__PURE__ */ r(za, { data: g, margin: { top: 10, right: 20, left: 0, bottom: 0 }, children: [
4693
+ /* @__PURE__ */ e("div", { style: { height: m }, className: "w-full", children: /* @__PURE__ */ e(Ma, { width: "100%", height: "100%", children: i.type === "line" ? /* @__PURE__ */ r(za, { data: y, margin: { top: 10, right: 20, left: 0, bottom: 0 }, children: [
4672
4694
  /* @__PURE__ */ e(un, { strokeDasharray: "3 3", stroke: "#f3f4f6" }),
4673
4695
  /* @__PURE__ */ e(
4674
4696
  mn,
@@ -4686,8 +4708,8 @@ function ss({ output: t }) {
4686
4708
  /* @__PURE__ */ e($a, { type: "monotone", dataKey: i.y, stroke: "#3b82f6", strokeWidth: 2, dot: { r: 3 } })
4687
4709
  ] }) : i.type === "pie" ? /* @__PURE__ */ r(Ua, { children: [
4688
4710
  /* @__PURE__ */ e(zt, { formatter: (f) => kt(f, jt(l, i.y)) }),
4689
- /* @__PURE__ */ e(Va, { data: g, dataKey: i.y, nameKey: i.x, outerRadius: 110, children: g.map((f, S) => /* @__PURE__ */ e(ja, { fill: Rn[S % Rn.length] }, S)) })
4690
- ] }) : /* @__PURE__ */ r(Ga, { data: g, margin: { top: 10, right: 20, left: 0, bottom: 0 }, children: [
4711
+ /* @__PURE__ */ e(Va, { data: y, dataKey: i.y, nameKey: i.x, outerRadius: 110, children: y.map((f, w) => /* @__PURE__ */ e(ja, { fill: Rn[w % Rn.length] }, w)) })
4712
+ ] }) : /* @__PURE__ */ r(Ga, { data: y, margin: { top: 10, right: 20, left: 0, bottom: 0 }, children: [
4691
4713
  /* @__PURE__ */ e(un, { strokeDasharray: "3 3", stroke: "#f3f4f6" }),
4692
4714
  /* @__PURE__ */ e(
4693
4715
  mn,
@@ -4708,14 +4730,14 @@ function ss({ output: t }) {
4708
4730
  }),
4709
4731
  n.map((i) => /* @__PURE__ */ e(U, { title: i.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: [
4710
4732
  /* @__PURE__ */ e("thead", { className: "bg-gray-50", children: /* @__PURE__ */ e("tr", { children: i.columns.map((c) => /* @__PURE__ */ e("th", { className: "px-4 py-2 text-left font-medium text-gray-500", children: c.label }, c.key)) }) }),
4711
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: i.rows.map((c, l) => /* @__PURE__ */ e("tr", { className: "hover:bg-gray-50", children: i.columns.map((g) => /* @__PURE__ */ e("td", { className: "px-4 py-1.5 text-gray-900", children: kt(c[g.key], g.type) }, g.key)) }, l)) })
4733
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-gray-100", children: i.rows.map((c, l) => /* @__PURE__ */ e("tr", { className: "hover:bg-gray-50", children: i.columns.map((y) => /* @__PURE__ */ e("td", { className: "px-4 py-1.5 text-gray-900", children: kt(c[y.key], y.type) }, y.key)) }, l)) })
4712
4734
  ] }) }) }, i.id))
4713
4735
  ] });
4714
4736
  }
4715
4737
  function is(t) {
4716
4738
  return t.replace(/_/g, " ").replace(/\b\w/g, (n) => n.toUpperCase());
4717
4739
  }
4718
- function oa(t) {
4740
+ function la(t) {
4719
4741
  const n = /* @__PURE__ */ new Map();
4720
4742
  for (const a of t)
4721
4743
  n.set(a.id, a), a.title && n.set(a.title, a);
@@ -4726,7 +4748,7 @@ function os(t) {
4726
4748
  const n = (t.tables ?? []).map((o, i) => ({
4727
4749
  ...o,
4728
4750
  id: o.id || `table_${i + 1}`
4729
- })), a = oa(n), s = [];
4751
+ })), a = la(n), s = [];
4730
4752
  for (const o of t.charts ?? []) {
4731
4753
  const i = o.dataTable ? a.get(o.dataTable) : void 0, c = o.data ?? (i == null ? void 0 : i.rows) ?? [];
4732
4754
  if (!c.length) {
@@ -4841,7 +4863,7 @@ function ls(t) {
4841
4863
  },
4842
4864
  fields: [t.groupBy === "warehouse" ? "warehouse" : "item_code", "stock_value"],
4843
4865
  chartType: "bar"
4844
- }) : JSON.parse(ia);
4866
+ }) : JSON.parse(oa);
4845
4867
  }
4846
4868
  function gt(t) {
4847
4869
  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} || "—"`;
@@ -4941,7 +4963,7 @@ function hs() {
4941
4963
  const t = We(), { data: n, isLoading: a } = le({
4942
4964
  queryKey: ["setup-status"],
4943
4965
  queryFn: () => L.setupStatus()
4944
- }), [s, o] = v(""), [i, c] = v("USD"), [l, g] = v({
4966
+ }), [s, o] = v(""), [i, c] = v("USD"), [l, y] = v({
4945
4967
  address: "",
4946
4968
  city: "",
4947
4969
  zip_code: "",
@@ -4949,7 +4971,7 @@ function hs() {
4949
4971
  email: "",
4950
4972
  phone: "",
4951
4973
  tax_id: ""
4952
- }), d = (R) => (k) => g((H) => ({ ...H, [R]: k.target.value })), [p, m] = v("quick"), [f, S] = v(!1), [x, y] = v(null), P = oe({
4974
+ }), d = (R) => (S) => y((H) => ({ ...H, [R]: S.target.value })), [p, m] = v("quick"), [f, w] = v(!1), [b, g] = v(null), P = oe({
4953
4975
  mutationFn: () => L.createCompany({ name: s, currency: i, ...l })
4954
4976
  }), D = oe({
4955
4977
  mutationFn: () => L.seedDemo()
@@ -4960,9 +4982,9 @@ function hs() {
4960
4982
  try {
4961
4983
  if (await P.mutateAsync(), p === "history") {
4962
4984
  const R = await T.mutateAsync();
4963
- y(R.stats);
4985
+ g(R.stats);
4964
4986
  } else p === "quick" && await D.mutateAsync();
4965
- t.invalidateQueries({ queryKey: ["setup-status"] }), S(!0);
4987
+ t.invalidateQueries({ queryKey: ["setup-status"] }), w(!0);
4966
4988
  } catch {
4967
4989
  }
4968
4990
  };
@@ -4970,18 +4992,18 @@ function hs() {
4970
4992
  return /* @__PURE__ */ e("p", { className: "text-gray-500", children: "Loading..." });
4971
4993
  if (n != null && n.setup_complete && !f)
4972
4994
  return /* @__PURE__ */ r("div", { className: "space-y-6", children: [
4973
- /* @__PURE__ */ e(U, { title: "Companies", children: n.companies && n.companies.length > 0 ? /* @__PURE__ */ e("ul", { className: "divide-y divide-gray-100", children: n.companies.map((R, k) => /* @__PURE__ */ e("li", { className: "py-3", children: /* @__PURE__ */ e(gs, { company: R }) }, k)) }) : /* @__PURE__ */ e("p", { className: "text-gray-400", children: "No companies found" }) }),
4995
+ /* @__PURE__ */ e(U, { title: "Companies", children: n.companies && n.companies.length > 0 ? /* @__PURE__ */ e("ul", { className: "divide-y divide-gray-100", children: n.companies.map((R, S) => /* @__PURE__ */ e("li", { className: "py-3", children: /* @__PURE__ */ e(gs, { company: R }) }, S)) }) : /* @__PURE__ */ e("p", { className: "text-gray-400", children: "No companies found" }) }),
4974
4996
  /* @__PURE__ */ e(Ne, { to: "/", className: "text-blue-600 hover:text-blue-800 text-sm font-medium", children: "Go to Dashboard" })
4975
4997
  ] });
4976
4998
  if (f)
4977
4999
  return /* @__PURE__ */ e("div", { className: "space-y-6", children: /* @__PURE__ */ e(U, { children: /* @__PURE__ */ r("div", { className: "py-8 text-center", children: [
4978
5000
  /* @__PURE__ */ e("p", { className: "text-lg font-semibold text-green-700", children: "Setup complete!" }),
4979
5001
  /* @__PURE__ */ e("p", { className: "mt-2 text-sm text-gray-500", children: p === "history" ? "Your company has been created and three years of history has been simulated." : p === "quick" ? "Your company has been created and demo data has been seeded." : "Your company has been created. No demo data was added." }),
4980
- x && /* @__PURE__ */ r("div", { className: "mx-auto mt-6 max-w-sm text-left", children: [
5002
+ b && /* @__PURE__ */ r("div", { className: "mx-auto mt-6 max-w-sm text-left", children: [
4981
5003
  /* @__PURE__ */ e("p", { className: "mb-2 text-sm font-medium text-gray-700", children: "Generated documents:" }),
4982
- /* @__PURE__ */ e("ul", { className: "divide-y divide-gray-100 text-sm", children: Object.entries(x).sort(([R], [k]) => R.localeCompare(k)).map(([R, k]) => /* @__PURE__ */ r("li", { className: "flex justify-between py-1", children: [
5004
+ /* @__PURE__ */ e("ul", { className: "divide-y divide-gray-100 text-sm", children: Object.entries(b).sort(([R], [S]) => R.localeCompare(S)).map(([R, S]) => /* @__PURE__ */ r("li", { className: "flex justify-between py-1", children: [
4983
5005
  /* @__PURE__ */ e("span", { className: "text-gray-600", children: R.replace(/_/g, " ") }),
4984
- /* @__PURE__ */ e("span", { className: "font-mono text-gray-900", children: k.toLocaleString() })
5006
+ /* @__PURE__ */ e("span", { className: "font-mono text-gray-900", children: S.toLocaleString() })
4985
5007
  ] }, R)) })
4986
5008
  ] }),
4987
5009
  /* @__PURE__ */ e("div", { className: "mt-6", children: /* @__PURE__ */ e(Ne, { to: "/", children: /* @__PURE__ */ e(J, { children: "Go to Dashboard" }) }) })
@@ -4992,7 +5014,7 @@ function hs() {
4992
5014
  A && /* @__PURE__ */ e("div", { className: "rounded-md bg-red-50 p-4 text-sm text-red-700", children: A.message ?? "An error occurred during setup" }),
4993
5015
  /* @__PURE__ */ e(U, { children: /* @__PURE__ */ r("div", { className: "space-y-4", children: [
4994
5016
  /* @__PURE__ */ e(
4995
- X,
5017
+ ee,
4996
5018
  {
4997
5019
  label: "Company Name",
4998
5020
  value: s,
@@ -5014,7 +5036,7 @@ function hs() {
5014
5036
  /* @__PURE__ */ e("legend", { className: "mb-1 text-sm font-medium text-gray-700", children: "Company details" }),
5015
5037
  /* @__PURE__ */ e("p", { className: "text-xs text-gray-500", children: "These appear on your invoices and other PDFs. Optional now — you can fill or change them later under Masters → Company." }),
5016
5038
  /* @__PURE__ */ e(
5017
- X,
5039
+ ee,
5018
5040
  {
5019
5041
  label: "Address",
5020
5042
  value: l.address,
@@ -5023,16 +5045,16 @@ function hs() {
5023
5045
  }
5024
5046
  ),
5025
5047
  /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-3", children: [
5026
- /* @__PURE__ */ e(X, { label: "City", value: l.city, onChange: d("city") }),
5027
- /* @__PURE__ */ e(X, { label: "ZIP / Postal code", value: l.zip_code, onChange: d("zip_code") })
5048
+ /* @__PURE__ */ e(ee, { label: "City", value: l.city, onChange: d("city") }),
5049
+ /* @__PURE__ */ e(ee, { label: "ZIP / Postal code", value: l.zip_code, onChange: d("zip_code") })
5028
5050
  ] }),
5029
5051
  /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-3", children: [
5030
- /* @__PURE__ */ e(X, { label: "Country", value: l.country, onChange: d("country") }),
5031
- /* @__PURE__ */ e(X, { label: "Tax ID / VAT", value: l.tax_id, onChange: d("tax_id") })
5052
+ /* @__PURE__ */ e(ee, { label: "Country", value: l.country, onChange: d("country") }),
5053
+ /* @__PURE__ */ e(ee, { label: "Tax ID / VAT", value: l.tax_id, onChange: d("tax_id") })
5032
5054
  ] }),
5033
5055
  /* @__PURE__ */ r("div", { className: "grid grid-cols-2 gap-3", children: [
5034
- /* @__PURE__ */ e(X, { label: "Email", value: l.email, onChange: d("email") }),
5035
- /* @__PURE__ */ e(X, { label: "Phone", value: l.phone, onChange: d("phone") })
5056
+ /* @__PURE__ */ e(ee, { label: "Email", value: l.email, onChange: d("email") }),
5057
+ /* @__PURE__ */ e(ee, { label: "Phone", value: l.phone, onChange: d("phone") })
5036
5058
  ] })
5037
5059
  ] }),
5038
5060
  /* @__PURE__ */ r("fieldset", { className: "space-y-2", children: [
@@ -5280,8 +5302,8 @@ const ys = [
5280
5302
  ];
5281
5303
  function fs() {
5282
5304
  const t = Oe(), { t: n } = ae(), { sessions: a, createSession: s } = ct(), o = async (c) => {
5283
- var g;
5284
- let l = ((g = a[0]) == null ? void 0 : g.id) || "";
5305
+ var y;
5306
+ let l = ((y = a[0]) == null ? void 0 : y.id) || "";
5285
5307
  if (!l)
5286
5308
  try {
5287
5309
  l = (await s()).id;
@@ -5583,14 +5605,14 @@ function Ln(t) {
5583
5605
  });
5584
5606
  }
5585
5607
  function Bn() {
5586
- const { t } = ae(), { sessionId: n } = ft(), a = Oe(), s = Ct(), [o] = Ot(), i = o.get("demo") === "1", [c, l] = v(""), [g, d] = v(""), [p, m] = v([]), [f, S] = v(""), [x, y] = v(!1), [P, D] = v("idle"), T = ee(null), u = ee(null), h = ee([]), {
5608
+ const { t } = ae(), { sessionId: n } = ft(), a = Oe(), s = Ct(), [o] = Ot(), i = o.get("demo") === "1", [c, l] = v(""), [y, d] = v(""), [p, m] = v([]), [f, w] = v(""), [b, g] = v(!1), [P, D] = v("idle"), T = X(null), u = X(null), h = X([]), {
5587
5609
  connectionStatus: A,
5588
5610
  connectionVersion: R,
5589
- createSession: k,
5611
+ createSession: S,
5590
5612
  startDemo: H,
5591
5613
  completeDemoTyping: $,
5592
5614
  loadHistory: z,
5593
- loadMoreHistory: w,
5615
+ loadMoreHistory: k,
5594
5616
  sendMessage: K,
5595
5617
  transcribeAudio: N,
5596
5618
  getMessages: B,
@@ -5599,14 +5621,14 @@ function Bn() {
5599
5621
  isThinking: Z,
5600
5622
  getDemoStatus: re,
5601
5623
  getDemoTypingCue: he
5602
- } = ct(), ge = ee(null), _e = ee(null), me = ee(null), ye = ee(null), [ze, I] = v(0), te = ee(!1), Ae = ee(null), Ce = ee(0), $e = ee(!0), Fe = ee(null), xt = ee(!1), dt = ee(null), Je = B(n), we = A === "connected", Pe = Z(n), Ue = re(n), Ke = he(n), Re = i || Ue === "running", ut = C(n), st = F(n), mt = Je[Je.length - 1], _ = mt ? `${mt.type}:${mt.timestamp || ""}:${mt.content}` : "empty", V = Te(() => {
5624
+ } = ct(), ge = X(null), _e = X(null), me = X(null), ye = X(null), [ze, I] = v(0), te = X(!1), Ae = X(null), Ce = X(0), $e = X(!0), Fe = X(null), xt = X(!1), dt = X(null), Je = B(n), we = A === "connected", Pe = Z(n), Ue = re(n), Ke = he(n), Re = i || Ue === "running", ut = C(n), st = F(n), mt = Je[Je.length - 1], _ = mt ? `${mt.type}:${mt.timestamp || ""}:${mt.content}` : "empty", V = Te(() => {
5603
5625
  xt.current = !0, dt.current !== null && window.clearTimeout(dt.current), dt.current = window.setTimeout(() => {
5604
5626
  xt.current = !1, dt.current = null;
5605
5627
  }, 600);
5606
- }, []), W = Te((b = "smooth") => {
5628
+ }, []), W = Te((x = "smooth") => {
5607
5629
  const M = ge.current;
5608
5630
  if (!M) return;
5609
- V(), M.scrollTo({ top: M.scrollHeight, behavior: b });
5631
+ V(), M.scrollTo({ top: M.scrollHeight, behavior: x });
5610
5632
  const Y = () => {
5611
5633
  const ce = ge.current;
5612
5634
  ce && (!$e.current && !Re && !Pe || ce.scrollTop + ce.clientHeight >= ce.scrollHeight - 2 || (V(), ce.scrollTo({ top: ce.scrollHeight, behavior: "auto" })));
@@ -5614,15 +5636,15 @@ function Bn() {
5614
5636
  requestAnimationFrame(Y), window.setTimeout(Y, 120);
5615
5637
  }, [Re, Pe, V]);
5616
5638
  cn(() => {
5617
- const b = ge.current, M = Fe.current;
5618
- if (!b || M === null) return;
5619
- const Y = b.scrollHeight - M;
5620
- Y > 0 && (b.scrollTop = b.scrollTop + Y), Fe.current = null;
5621
- }, [Je.length]), ie(() => {
5639
+ const x = ge.current, M = Fe.current;
5640
+ if (!x || M === null) return;
5641
+ const Y = x.scrollHeight - M;
5642
+ Y > 0 && (x.scrollTop = x.scrollTop + Y), Fe.current = null;
5643
+ }, [Je.length]), se(() => {
5622
5644
  Fe.current === null && (!$e.current && !Re && !Pe || W(Re ? "auto" : "smooth"));
5623
- }, [_, Re, Pe, W]), ie(() => {
5624
- const b = ge.current;
5625
- if (!b || typeof ResizeObserver > "u") return;
5645
+ }, [_, Re, Pe, W]), se(() => {
5646
+ const x = ge.current;
5647
+ if (!x || typeof ResizeObserver > "u") return;
5626
5648
  let M = 0;
5627
5649
  const Y = new ResizeObserver(() => {
5628
5650
  Fe.current === null && (!$e.current && !Re && !Pe || (cancelAnimationFrame(M), M = requestAnimationFrame(() => {
@@ -5630,102 +5652,102 @@ function Bn() {
5630
5652
  if (!pe) return;
5631
5653
  pe.scrollHeight - pe.scrollTop - pe.clientHeight <= 120 && (V(), pe.scrollTo({ top: pe.scrollHeight, behavior: "auto" }));
5632
5654
  })));
5633
- }), ce = b.firstElementChild;
5634
- return ce && Y.observe(ce), Y.observe(b), () => {
5655
+ }), ce = x.firstElementChild;
5656
+ return ce && Y.observe(ce), Y.observe(x), () => {
5635
5657
  Y.disconnect(), cancelAnimationFrame(M);
5636
5658
  };
5637
5659
  }, [Re, Pe, V]), cn(() => {
5638
- const b = ye.current;
5639
- if (!b || (I(b.offsetHeight), typeof ResizeObserver > "u")) return;
5640
- const M = new ResizeObserver(() => I(b.offsetHeight));
5641
- return M.observe(b), () => M.disconnect();
5660
+ const x = ye.current;
5661
+ if (!x || (I(x.offsetHeight), typeof ResizeObserver > "u")) return;
5662
+ const M = new ResizeObserver(() => I(x.offsetHeight));
5663
+ return M.observe(x), () => M.disconnect();
5642
5664
  }, []);
5643
5665
  const be = Te(() => {
5644
5666
  if (!n || st || !ut) return;
5645
- const b = ge.current;
5646
- Fe.current = b ? b.scrollHeight : null, $e.current = !1, w(n).catch(() => {
5667
+ const x = ge.current;
5668
+ Fe.current = x ? x.scrollHeight : null, $e.current = !1, k(n).catch(() => {
5647
5669
  Fe.current = null;
5648
5670
  });
5649
- }, [n, st, ut, w]), xe = ee(null);
5650
- ie(() => {
5651
- d(""), Ae.current = null, Ce.current += 1, n && ta(n);
5652
- const b = s.state;
5653
- b != null && b.prefillMessage && xe.current !== b ? (xe.current = b, l(b.prefillMessage), window.setTimeout(() => {
5671
+ }, [n, st, ut, k]), xe = X(null);
5672
+ se(() => {
5673
+ d(""), Ae.current = null, Ce.current += 1, n && na(n);
5674
+ const x = s.state;
5675
+ x != null && x.prefillMessage && xe.current !== x ? (xe.current = x, l(x.prefillMessage), window.setTimeout(() => {
5654
5676
  var M;
5655
5677
  return (M = me.current) == null ? void 0 : M.focus();
5656
- }, 50)) : b != null && b.prefillMessage || (xe.current = null, l(""));
5657
- }, [n, i, s.state]), ie(() => {
5678
+ }, 50)) : x != null && x.prefillMessage || (xe.current = null, l(""));
5679
+ }, [n, i, s.state]), se(() => {
5658
5680
  if (n || !we) return;
5659
- let b = !1;
5660
- return k().then((M) => {
5661
- b || a(`/chat/${M.id}`, { replace: !0 });
5681
+ let x = !1;
5682
+ return S().then((M) => {
5683
+ x || a(`/chat/${M.id}`, { replace: !0 });
5662
5684
  }).catch(() => {
5663
5685
  }), () => {
5664
- b = !0;
5686
+ x = !0;
5665
5687
  };
5666
5688
  }, [n, we, a]);
5667
- const De = ee(z);
5668
- ie(() => {
5689
+ const De = X(z);
5690
+ se(() => {
5669
5691
  De.current = z;
5670
- }, [z]), ie(() => {
5692
+ }, [z]), se(() => {
5671
5693
  !n || !we || i || Ue === "running" || De.current(n).catch(() => {
5672
5694
  });
5673
- }, [n, we, R, i, Ue]), ie(() => {
5695
+ }, [n, we, R, i, Ue]), se(() => {
5674
5696
  te.current && !Pe && we && setTimeout(() => {
5675
- var b;
5676
- return (b = me.current) == null ? void 0 : b.focus();
5697
+ var x;
5698
+ return (x = me.current) == null ? void 0 : x.focus();
5677
5699
  }, 50), te.current = Pe;
5678
5700
  }, [Pe, we]);
5679
- function it(b) {
5701
+ function it(x) {
5680
5702
  if (xt.current) return;
5681
- const M = b.currentTarget, Y = M.scrollHeight - M.scrollTop - M.clientHeight;
5703
+ const M = x.currentTarget, Y = M.scrollHeight - M.scrollTop - M.clientHeight;
5682
5704
  $e.current = Y < 80;
5683
5705
  }
5684
- ie(() => {
5685
- !n || !we || !i || Ae.current !== n && (Ae.current = n, d(""), H(n).catch((b) => {
5686
- Ae.current = null, d(b instanceof Error ? b.message : t("chat.demoError"));
5706
+ se(() => {
5707
+ !n || !we || !i || Ae.current !== n && (Ae.current = n, d(""), H(n).catch((x) => {
5708
+ Ae.current = null, d(x instanceof Error ? x.message : t("chat.demoError"));
5687
5709
  }));
5688
- }, [n, we, i, H]), ie(() => {
5710
+ }, [n, we, i, H]), se(() => {
5689
5711
  !n || !i || Ue !== "complete" || (l(""), a(`/chat/${n}`, { replace: !0 }));
5690
5712
  }, [n, i, Ue, a]);
5691
- const j = ee($);
5692
- ie(() => {
5713
+ const j = X($);
5714
+ se(() => {
5693
5715
  j.current = $;
5694
5716
  }, [$]);
5695
- const Ye = ee(null);
5696
- ie(() => {
5717
+ const Ye = X(null);
5718
+ se(() => {
5697
5719
  if (!Ke || !n || Ye.current === Ke.seq) return;
5698
5720
  Ye.current = Ke.seq;
5699
- const b = n, M = Ke.content, Y = M.length > 0 ? Math.max(8, Ke.typingMs / M.length) : 0, ce = Ke.seq, pe = ++Ce.current;
5721
+ const x = n, M = Ke.content, Y = M.length > 0 ? Math.max(8, Ke.typingMs / M.length) : 0, ce = Ke.seq, pe = ++Ce.current;
5700
5722
  async function Xe() {
5701
5723
  l("");
5702
5724
  for (const ht of M) {
5703
5725
  if (pe !== Ce.current) return;
5704
5726
  l((Ve) => Ve + ht), await ks(Y);
5705
5727
  }
5706
- pe === Ce.current && j.current(b, ce);
5728
+ pe === Ce.current && j.current(x, ce);
5707
5729
  }
5708
5730
  Xe();
5709
- }, [Ke, n]), ie(() => {
5731
+ }, [Ke, n]), se(() => {
5710
5732
  Ue === "complete" && (Ce.current += 1, l(""));
5711
5733
  }, [Ue]);
5712
- const ue = Te((b) => {
5734
+ const ue = Te((x) => {
5713
5735
  if (!n) return;
5714
- S("");
5715
- const M = Array.from(b);
5736
+ w("");
5737
+ const M = Array.from(x);
5716
5738
  m((Y) => {
5717
5739
  const ce = [...Y];
5718
5740
  for (const pe of M) {
5719
5741
  if (ce.length >= Kt) {
5720
- S(`Maximum ${Kt} attachments per message.`);
5742
+ w(`Maximum ${Kt} attachments per message.`);
5721
5743
  break;
5722
5744
  }
5723
5745
  if (!ws.has(pe.type)) {
5724
- S(`Unsupported file type: ${pe.type || pe.name}`);
5746
+ w(`Unsupported file type: ${pe.type || pe.name}`);
5725
5747
  continue;
5726
5748
  }
5727
5749
  if (pe.size > Ns) {
5728
- S(`"${pe.name}" is too large (max 10 MB).`);
5750
+ w(`"${pe.name}" is too large (max 10 MB).`);
5729
5751
  continue;
5730
5752
  }
5731
5753
  const Xe = `${Date.now()}-${Math.random().toString(36).slice(2, 8)}`, ht = pe.type.startsWith("image/") ? URL.createObjectURL(pe) : void 0, Ve = { localId: Xe, file: pe, previewUrl: ht, uploading: !0 };
@@ -5737,7 +5759,7 @@ function Bn() {
5737
5759
  );
5738
5760
  }).catch((ot) => {
5739
5761
  const Dt = (ot == null ? void 0 : ot.message) || "Upload failed";
5740
- S(`"${pe.name}": ${Dt}`), m(
5762
+ w(`"${pe.name}": ${Dt}`), m(
5741
5763
  (Nt) => Nt.map(
5742
5764
  (Mt) => Mt.localId === Xe ? { ...Mt, uploading: !1, error: Dt } : Mt
5743
5765
  )
@@ -5746,61 +5768,61 @@ function Bn() {
5746
5768
  }
5747
5769
  return ce;
5748
5770
  });
5749
- }, [n]), E = (b) => {
5771
+ }, [n]), E = (x) => {
5750
5772
  m((M) => {
5751
- const Y = M.find((ce) => ce.localId === b);
5752
- return Y != null && Y.previewUrl && URL.revokeObjectURL(Y.previewUrl), M.filter((ce) => ce.localId !== b);
5773
+ const Y = M.find((ce) => ce.localId === x);
5774
+ return Y != null && Y.previewUrl && URL.revokeObjectURL(Y.previewUrl), M.filter((ce) => ce.localId !== x);
5753
5775
  });
5754
- }, q = (b) => {
5755
- b.dataTransfer.types.includes("Files") && (b.preventDefault(), y(!0));
5756
- }, G = (b) => {
5757
- const M = b.relatedTarget;
5758
- (!M || !b.currentTarget.contains(M)) && y(!1);
5759
- }, Q = (b) => {
5760
- b.preventDefault(), y(!1), b.dataTransfer.files && b.dataTransfer.files.length > 0 && ue(b.dataTransfer.files);
5761
- }, Ee = (b) => {
5776
+ }, q = (x) => {
5777
+ x.dataTransfer.types.includes("Files") && (x.preventDefault(), g(!0));
5778
+ }, G = (x) => {
5779
+ const M = x.relatedTarget;
5780
+ (!M || !x.currentTarget.contains(M)) && g(!1);
5781
+ }, Q = (x) => {
5782
+ x.preventDefault(), g(!1), x.dataTransfer.files && x.dataTransfer.files.length > 0 && ue(x.dataTransfer.files);
5783
+ }, Ee = (x) => {
5762
5784
  const M = [];
5763
- for (const Y of b.clipboardData.items)
5785
+ for (const Y of x.clipboardData.items)
5764
5786
  if (Y.kind === "file") {
5765
5787
  const ce = Y.getAsFile();
5766
5788
  ce && M.push(ce);
5767
5789
  }
5768
- M.length > 0 && (b.preventDefault(), ue(M));
5769
- }, ve = p.some((b) => b.uploading), se = p.some((b) => b.error), de = p.filter((b) => b.uploadedId && !b.error).map((b) => b.uploadedId);
5790
+ M.length > 0 && (x.preventDefault(), ue(M));
5791
+ }, ve = p.some((x) => x.uploading), ie = p.some((x) => x.error), de = p.filter((x) => x.uploadedId && !x.error).map((x) => x.uploadedId);
5770
5792
  function pt() {
5771
- const b = c.trim();
5772
- if (n && !(!b && de.length === 0) && !ve && K(n, b, de.length > 0 ? de : void 0)) {
5793
+ const x = c.trim();
5794
+ if (n && !(!x && de.length === 0) && !ve && K(n, x, de.length > 0 ? de : void 0)) {
5773
5795
  for (const M of p)
5774
5796
  M.previewUrl && URL.revokeObjectURL(M.previewUrl);
5775
- m([]), S(""), l("");
5797
+ m([]), w(""), l("");
5776
5798
  }
5777
5799
  }
5778
- function vt(b) {
5779
- b.key === "Enter" && !b.shiftKey && (b.preventDefault(), pt());
5800
+ function vt(x) {
5801
+ x.key === "Enter" && !x.shiftKey && (x.preventDefault(), pt());
5780
5802
  }
5781
- function Ze(b) {
5782
- const M = b.trim();
5803
+ function Ze(x) {
5804
+ const M = x.trim();
5783
5805
  M && (l((Y) => Y.trim() ? `${Y.trim()} ${M}` : M), window.setTimeout(() => {
5784
5806
  const Y = me.current;
5785
5807
  Y && (Y.focus(), Y.style.height = "auto", Y.style.height = Math.min(Math.max(Y.scrollHeight, 48), 120) + "px");
5786
5808
  }, 0));
5787
5809
  }
5788
- async function ha() {
5810
+ async function ga() {
5789
5811
  if (P !== "idle") return;
5790
- let b;
5812
+ let x;
5791
5813
  try {
5792
- b = await navigator.mediaDevices.getUserMedia({ audio: !0 });
5814
+ x = await navigator.mediaDevices.getUserMedia({ audio: !0 });
5793
5815
  } catch {
5794
- S(t("chat.micDenied"));
5816
+ w(t("chat.micDenied"));
5795
5817
  return;
5796
5818
  }
5797
- S("");
5798
- const M = new MediaRecorder(b);
5819
+ w("");
5820
+ const M = new MediaRecorder(x);
5799
5821
  u.current = M, h.current = [], M.ondataavailable = (Y) => {
5800
5822
  Y.data.size > 0 && h.current.push(Y.data);
5801
5823
  }, M.onstop = async () => {
5802
5824
  var ht;
5803
- b.getTracks().forEach((Ve) => Ve.stop());
5825
+ x.getTracks().forEach((Ve) => Ve.stop());
5804
5826
  const Y = h.current;
5805
5827
  if (h.current = [], u.current = null, Y.length === 0) {
5806
5828
  D("idle");
@@ -5812,18 +5834,18 @@ function Bn() {
5812
5834
  const Ve = await Ss(pe), ot = await N(Ve, Xe, n);
5813
5835
  Ze(ot);
5814
5836
  } catch (Ve) {
5815
- S(Ve instanceof Error ? Ve.message : t("chat.transcribeFailed"));
5837
+ w(Ve instanceof Error ? Ve.message : t("chat.transcribeFailed"));
5816
5838
  } finally {
5817
5839
  D("idle");
5818
5840
  }
5819
5841
  }, M.start(), D("recording");
5820
5842
  }
5821
- function ga() {
5822
- const b = u.current;
5823
- b && b.state !== "inactive" && b.stop();
5824
- }
5825
5843
  function ya() {
5826
- P === "recording" ? ga() : P === "idle" && ha();
5844
+ const x = u.current;
5845
+ x && x.state !== "inactive" && x.stop();
5846
+ }
5847
+ function fa() {
5848
+ P === "recording" ? ya() : P === "idle" && ga();
5827
5849
  }
5828
5850
  return n ? /* @__PURE__ */ r(
5829
5851
  "div",
@@ -5833,7 +5855,7 @@ function Bn() {
5833
5855
  onDragLeave: G,
5834
5856
  onDrop: Q,
5835
5857
  children: [
5836
- x && /* @__PURE__ */ e("div", { className: "pointer-events-none absolute inset-3 z-50 flex items-center justify-center rounded-lg border-2 border-dashed border-brand bg-brand/5 text-sm font-medium text-brand", children: t("chat.dropToAttach") }),
5858
+ b && /* @__PURE__ */ e("div", { className: "pointer-events-none absolute inset-3 z-50 flex items-center justify-center rounded-lg border-2 border-dashed border-brand bg-brand/5 text-sm font-medium text-brand", children: t("chat.dropToAttach") }),
5837
5859
  /* @__PURE__ */ e(
5838
5860
  "div",
5839
5861
  {
@@ -5855,7 +5877,7 @@ function Bn() {
5855
5877
  children: t(st ? "common.loading" : "chat.loadOlder")
5856
5878
  }
5857
5879
  ) }),
5858
- g && /* @__PURE__ */ e("div", { className: "rounded-md bg-rose-50 px-4 py-3 text-sm text-rose-700 ring-1 ring-rose-200", children: g }),
5880
+ y && /* @__PURE__ */ e("div", { className: "rounded-md bg-rose-50 px-4 py-3 text-sm text-rose-700 ring-1 ring-rose-200", children: y }),
5859
5881
  Je.length === 0 && Ue !== "running" && !i && /* @__PURE__ */ r("div", { className: "py-20 text-center", children: [
5860
5882
  /* @__PURE__ */ e("h3", { className: "text-lg font-semibold text-fg-muted", children: t("chat.title") }),
5861
5883
  /* @__PURE__ */ e("p", { className: "mt-2 text-sm text-fg-muted", children: t("chat.subtitle") }),
@@ -5864,20 +5886,20 @@ function Bn() {
5864
5886
  t("chat.s2"),
5865
5887
  t("chat.s3"),
5866
5888
  t("chat.s4")
5867
- ].map((b) => /* @__PURE__ */ e(
5889
+ ].map((x) => /* @__PURE__ */ e(
5868
5890
  "button",
5869
5891
  {
5870
5892
  onClick: () => {
5871
5893
  var M;
5872
- l(b), (M = me.current) == null || M.focus();
5894
+ l(x), (M = me.current) == null || M.focus();
5873
5895
  },
5874
5896
  className: "rounded-full bg-surface px-3 py-1.5 text-xs text-fg-muted ring-1 ring-line transition-all hover:bg-surface-subtle hover:text-fg hover:ring-brand/30",
5875
- children: b
5897
+ children: x
5876
5898
  },
5877
- b
5899
+ x
5878
5900
  )) })
5879
5901
  ] }),
5880
- Je.map((b, M) => /* @__PURE__ */ e(Ds, { message: b }, M)),
5902
+ Je.map((x, M) => /* @__PURE__ */ e(Ds, { message: x }, M)),
5881
5903
  /* @__PURE__ */ e("div", { ref: _e })
5882
5904
  ]
5883
5905
  }
@@ -5890,20 +5912,20 @@ function Bn() {
5890
5912
  ref: ye,
5891
5913
  className: "absolute bottom-0 left-0 right-0 bg-surface-muted px-4 pb-[max(0.75rem,env(safe-area-inset-bottom))] md:right-6 md:pl-6 md:pr-0",
5892
5914
  children: /* @__PURE__ */ r("div", { className: "mx-auto max-w-3xl", children: [
5893
- p.length > 0 && /* @__PURE__ */ e("div", { className: "mb-2 flex flex-wrap gap-2", children: p.map((b) => /* @__PURE__ */ r(
5915
+ p.length > 0 && /* @__PURE__ */ e("div", { className: "mb-2 flex flex-wrap gap-2", children: p.map((x) => /* @__PURE__ */ r(
5894
5916
  "div",
5895
5917
  {
5896
5918
  className: "relative flex items-center gap-2 rounded-lg bg-surface px-2 py-1.5 text-xs ring-1 ring-line shadow-card",
5897
5919
  children: [
5898
- b.previewUrl ? /* @__PURE__ */ e("img", { src: b.previewUrl, alt: "", className: "h-10 w-10 rounded object-cover" }) : /* @__PURE__ */ e("div", { className: "flex h-10 w-10 items-center justify-center rounded bg-rose-100 text-[10px] font-bold text-rose-700", children: "PDF" }),
5920
+ x.previewUrl ? /* @__PURE__ */ e("img", { src: x.previewUrl, alt: "", className: "h-10 w-10 rounded object-cover" }) : /* @__PURE__ */ e("div", { className: "flex h-10 w-10 items-center justify-center rounded bg-rose-100 text-[10px] font-bold text-rose-700", children: "PDF" }),
5899
5921
  /* @__PURE__ */ r("div", { className: "flex min-w-0 flex-col", children: [
5900
- /* @__PURE__ */ e("span", { className: "max-w-[160px] truncate text-fg", children: b.file.name }),
5901
- /* @__PURE__ */ e("span", { className: "text-[10px] text-fg-muted", children: b.uploading ? t("chat.uploading") : b.error ? t("chat.failed") : `${Math.round(b.file.size / 1024)} KB` })
5922
+ /* @__PURE__ */ e("span", { className: "max-w-[160px] truncate text-fg", children: x.file.name }),
5923
+ /* @__PURE__ */ e("span", { className: "text-[10px] text-fg-muted", children: x.uploading ? t("chat.uploading") : x.error ? t("chat.failed") : `${Math.round(x.file.size / 1024)} KB` })
5902
5924
  ] }),
5903
5925
  /* @__PURE__ */ e(
5904
5926
  "button",
5905
5927
  {
5906
- onClick: () => E(b.localId),
5928
+ onClick: () => E(x.localId),
5907
5929
  className: "ml-1 text-fg-muted transition-colors hover:text-red-500",
5908
5930
  title: t("chat.remove"),
5909
5931
  children: /* @__PURE__ */ e("svg", { viewBox: "0 0 24 24", width: "14", height: "14", fill: "currentColor", children: /* @__PURE__ */ e("path", { d: "M19 6.41L17.59 5 12 10.59 6.41 5 5 6.41 10.59 12 5 17.59 6.41 19 12 13.41 17.59 19 19 17.59 13.41 12z" }) })
@@ -5911,7 +5933,7 @@ function Bn() {
5911
5933
  )
5912
5934
  ]
5913
5935
  },
5914
- b.localId
5936
+ x.localId
5915
5937
  )) }),
5916
5938
  f && /* @__PURE__ */ e("div", { className: "mb-2 rounded-md bg-rose-50 px-3 py-1.5 text-xs text-rose-700 ring-1 ring-rose-200 shadow-card", children: f }),
5917
5939
  /* @__PURE__ */ e(
@@ -5922,8 +5944,8 @@ function Bn() {
5922
5944
  accept: "image/png,image/jpeg,image/gif,image/webp,application/pdf",
5923
5945
  multiple: !0,
5924
5946
  className: "hidden",
5925
- onChange: (b) => {
5926
- b.target.files && b.target.files.length > 0 && (ue(b.target.files), b.target.value = "");
5947
+ onChange: (x) => {
5948
+ x.target.files && x.target.files.length > 0 && (ue(x.target.files), x.target.value = "");
5927
5949
  }
5928
5950
  }
5929
5951
  ),
@@ -5933,7 +5955,7 @@ function Bn() {
5933
5955
  {
5934
5956
  ref: me,
5935
5957
  value: c,
5936
- onChange: (b) => l(b.target.value),
5958
+ onChange: (x) => l(x.target.value),
5937
5959
  onKeyDown: vt,
5938
5960
  onPaste: Ee,
5939
5961
  placeholder: t(Re ? "chat.placeholderDemo" : we ? "chat.placeholderType" : "chat.placeholderConnecting"),
@@ -5941,8 +5963,8 @@ function Bn() {
5941
5963
  rows: 2,
5942
5964
  className: "block flex-1 resize-none bg-transparent px-2.5 py-1.5 text-sm text-fg outline-none placeholder:text-fg-muted/70 disabled:text-fg-muted",
5943
5965
  style: { minHeight: "3rem", maxHeight: "120px" },
5944
- onInput: (b) => {
5945
- const M = b.target;
5966
+ onInput: (x) => {
5967
+ const M = x.target;
5946
5968
  M.style.height = "auto", M.style.height = Math.min(Math.max(M.scrollHeight, 48), 120) + "px";
5947
5969
  }
5948
5970
  }
@@ -5951,8 +5973,8 @@ function Bn() {
5951
5973
  "button",
5952
5974
  {
5953
5975
  onClick: () => {
5954
- var b;
5955
- return (b = T.current) == null ? void 0 : b.click();
5976
+ var x;
5977
+ return (x = T.current) == null ? void 0 : x.click();
5956
5978
  },
5957
5979
  disabled: !we || !n || Pe || Re || p.length >= Kt,
5958
5980
  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",
@@ -5963,7 +5985,7 @@ function Bn() {
5963
5985
  /* @__PURE__ */ e(
5964
5986
  "button",
5965
5987
  {
5966
- onClick: ya,
5988
+ onClick: fa,
5967
5989
  disabled: !we || !n || Pe || Re || P === "transcribing",
5968
5990
  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 ${P === "recording" ? "bg-rose-500/10 text-rose-600 hover:bg-rose-500/20" : "text-fg-muted hover:bg-surface-subtle hover:text-fg"}`,
5969
5991
  title: t(P === "recording" ? "chat.voiceStop" : P === "transcribing" ? "chat.voiceTranscribing" : "chat.voiceStart"),
@@ -5979,7 +6001,7 @@ function Bn() {
5979
6001
  "button",
5980
6002
  {
5981
6003
  onClick: pt,
5982
- disabled: !c.trim() && de.length === 0 || !we || !n || Pe || Re || ve || se,
6004
+ disabled: !c.trim() && de.length === 0 || !we || !n || Pe || Re || ve || ie,
5983
6005
  className: "flex h-11 w-11 shrink-0 items-center justify-center rounded-lg text-brand transition-all hover:bg-brand/10 active:translate-y-px disabled:cursor-not-allowed disabled:text-fg-muted disabled:active:translate-y-0 md:h-10 md:w-10",
5984
6006
  children: /* @__PURE__ */ e(
5985
6007
  "svg",
@@ -6120,7 +6142,7 @@ function _s({ content: t }) {
6120
6142
  );
6121
6143
  }), /* @__PURE__ */ e("div", { children: a });
6122
6144
  }
6123
- function la(t, n, a) {
6145
+ function ca(t, n, a) {
6124
6146
  const s = t.startsWith("/") && !t.startsWith("/api/"), o = "font-medium text-brand underline decoration-brand/40 underline-offset-2 transition-colors hover:decoration-brand";
6125
6147
  return s ? /* @__PURE__ */ e(Ne, { to: t, className: o, children: n }, a) : /* @__PURE__ */ e(
6126
6148
  "a",
@@ -6140,7 +6162,7 @@ function Bt(t) {
6140
6162
  const o = a.match(/^\[([^\]]+)\]\(([^)]+)\)$/);
6141
6163
  if (o) {
6142
6164
  const [, i, c] = o;
6143
- return la(c, Bt(i), s);
6165
+ return ca(c, Bt(i), s);
6144
6166
  }
6145
6167
  return a.startsWith("**") && a.endsWith("**") && a.length > 4 ? /* @__PURE__ */ e("strong", { className: "font-semibold", children: Bt(a.slice(2, -2)) }, s) : a.startsWith("`") && a.endsWith("`") ? /* @__PURE__ */ e(
6146
6168
  "code",
@@ -6159,26 +6181,26 @@ function Ts(t, n) {
6159
6181
  let c = 0;
6160
6182
  for (; (o = i.exec(t)) !== null; ) {
6161
6183
  const l = o.index;
6162
- let g = o[0], d = "";
6163
- for (; g.length > 0 && /[.,;:!?]$/.test(g); )
6164
- d = g.slice(-1) + d, g = g.slice(0, -1);
6165
- l > s && a.push(t.slice(s, l)), a.push(la(g, g, `${n}-u${c}`)), d && a.push(d), s = l + o[0].length, c += 1;
6184
+ let y = o[0], d = "";
6185
+ for (; y.length > 0 && /[.,;:!?]$/.test(y); )
6186
+ d = y.slice(-1) + d, y = y.slice(0, -1);
6187
+ l > s && a.push(t.slice(s, l)), a.push(ca(y, y, `${n}-u${c}`)), d && a.push(d), s = l + o[0].length, c += 1;
6166
6188
  }
6167
6189
  return s < t.length && a.push(t.slice(s)), a.length > 0 ? a : [t];
6168
6190
  }
6169
6191
  function As() {
6170
- const t = Oe(), [n] = Ot(), { user: a, login: s, register: o } = bt(), { t: i } = ae(), c = n.get("invite") || "", [l, g] = v(c ? "register" : "login"), [d, p] = v(!1), [m, f] = v(!1), [S, x] = v(!0), [y, P] = v(""), [D, T] = v(""), [u, h] = v(""), [A, R] = v(""), [k, H] = v("");
6171
- ie(() => {
6192
+ const t = Oe(), [n] = Ot(), { user: a, login: s, register: o } = bt(), { t: i } = ae(), c = n.get("invite") || "", [l, y] = v(c ? "register" : "login"), [d, p] = v(!1), [m, f] = v(!1), [w, b] = v(!0), [g, P] = v(""), [D, T] = v(""), [u, h] = v(""), [A, R] = v(""), [S, H] = v("");
6193
+ se(() => {
6172
6194
  a && a.role !== "public_manager" && t("/", { replace: !0 });
6173
- }, [a, t]), ie(() => {
6195
+ }, [a, t]), se(() => {
6174
6196
  L.authSetupStatus().then((z) => {
6175
- p(z.registration_open), f(z.first_run), z.first_run && g("register");
6197
+ p(z.registration_open), f(z.first_run), z.first_run && y("register");
6176
6198
  }).catch(() => {
6177
- }).finally(() => x(!1));
6199
+ }).finally(() => b(!1));
6178
6200
  }, []);
6179
6201
  const $ = async (z) => {
6180
6202
  if (z.preventDefault(), P(""), l === "register") {
6181
- if (A !== k) {
6203
+ if (A !== S) {
6182
6204
  P(i("login.passwordsNoMatch"));
6183
6205
  return;
6184
6206
  }
@@ -6188,26 +6210,26 @@ function As() {
6188
6210
  }
6189
6211
  try {
6190
6212
  await o(D, u, A, c || void 0), t("/", { replace: !0 });
6191
- } catch (w) {
6192
- P(w instanceof Ge ? w.message : i("login.registrationFailed"));
6213
+ } catch (k) {
6214
+ P(k instanceof Ge ? k.message : i("login.registrationFailed"));
6193
6215
  }
6194
6216
  } else
6195
6217
  try {
6196
6218
  await s(D, A), t("/", { replace: !0 });
6197
- } catch (w) {
6198
- P(w instanceof Ge ? w.message : i("login.loginFailed"));
6219
+ } catch (k) {
6220
+ P(k instanceof Ge ? k.message : i("login.loginFailed"));
6199
6221
  }
6200
6222
  };
6201
- return S ? /* @__PURE__ */ e("div", { className: "flex h-dvh items-center justify-center bg-surface-muted", children: /* @__PURE__ */ e("div", { className: "text-fg-muted", children: i("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: [
6223
+ return w ? /* @__PURE__ */ e("div", { className: "flex h-dvh items-center justify-center bg-surface-muted", children: /* @__PURE__ */ e("div", { className: "text-fg-muted", children: i("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: [
6202
6224
  /* @__PURE__ */ r("div", { className: "text-center", children: [
6203
6225
  /* @__PURE__ */ e("h1", { className: "text-2xl font-bold text-brand", children: "Lambda ERP" }),
6204
6226
  /* @__PURE__ */ e("p", { className: "mt-1 text-sm text-fg-muted", children: i(m ? "login.taglineFirstRun" : l === "register" ? "login.taglineRegister" : "login.taglineSignIn") }),
6205
6227
  (a == null ? void 0 : a.role) === "public_manager" && /* @__PURE__ */ e("p", { className: "mt-2 text-xs text-amber-700", children: i("login.demoBanner") })
6206
6228
  ] }),
6207
- y && /* @__PURE__ */ e("div", { className: "rounded-lg bg-rose-50 px-4 py-3 text-sm text-rose-700 ring-1 ring-rose-200", children: y }),
6229
+ g && /* @__PURE__ */ e("div", { className: "rounded-lg bg-rose-50 px-4 py-3 text-sm text-rose-700 ring-1 ring-rose-200", children: g }),
6208
6230
  /* @__PURE__ */ e(U, { children: /* @__PURE__ */ r("form", { onSubmit: $, className: "space-y-4", children: [
6209
6231
  l === "register" && /* @__PURE__ */ e(
6210
- X,
6232
+ ee,
6211
6233
  {
6212
6234
  label: i("login.fullName"),
6213
6235
  value: u,
@@ -6216,7 +6238,7 @@ function As() {
6216
6238
  }
6217
6239
  ),
6218
6240
  /* @__PURE__ */ e(
6219
- X,
6241
+ ee,
6220
6242
  {
6221
6243
  label: i("login.email"),
6222
6244
  type: "email",
@@ -6226,7 +6248,7 @@ function As() {
6226
6248
  }
6227
6249
  ),
6228
6250
  /* @__PURE__ */ e(
6229
- X,
6251
+ ee,
6230
6252
  {
6231
6253
  label: i("login.password"),
6232
6254
  type: "password",
@@ -6236,11 +6258,11 @@ function As() {
6236
6258
  }
6237
6259
  ),
6238
6260
  l === "register" && /* @__PURE__ */ e(
6239
- X,
6261
+ ee,
6240
6262
  {
6241
6263
  label: i("login.confirmPassword"),
6242
6264
  type: "password",
6243
- value: k,
6265
+ value: S,
6244
6266
  onChange: (z) => H(z.target.value),
6245
6267
  required: !0
6246
6268
  }
@@ -6265,17 +6287,17 @@ function As() {
6265
6287
  !m && !c && /* @__PURE__ */ e("p", { className: "text-center text-sm text-fg-muted", children: l === "login" ? /* @__PURE__ */ r(Se, { children: [
6266
6288
  i(d ? "login.noAccountPrompt" : "login.haveInvite"),
6267
6289
  " ",
6268
- /* @__PURE__ */ e("button", { onClick: () => g("register"), className: "font-medium text-brand transition-colors hover:text-brand/80", children: i("login.registerLink") })
6290
+ /* @__PURE__ */ e("button", { onClick: () => y("register"), className: "font-medium text-brand transition-colors hover:text-brand/80", children: i("login.registerLink") })
6269
6291
  ] }) : /* @__PURE__ */ r(Se, { children: [
6270
6292
  i("login.alreadyHaveAccount"),
6271
6293
  " ",
6272
- /* @__PURE__ */ e("button", { onClick: () => g("login"), className: "font-medium text-brand transition-colors hover:text-brand/80", children: i("login.signInLink") })
6294
+ /* @__PURE__ */ e("button", { onClick: () => y("login"), className: "font-medium text-brand transition-colors hover:text-brand/80", children: i("login.signInLink") })
6273
6295
  ] }) })
6274
6296
  ] }) });
6275
6297
  }
6276
6298
  function Rs() {
6277
- const t = Oe(), n = ee(!1), [a, s] = v("");
6278
- return ie(() => {
6299
+ const t = Oe(), n = X(!1), [a, s] = v("");
6300
+ return se(() => {
6279
6301
  n.current || (n.current = !0, L.createChatSession().then((o) => {
6280
6302
  t(`/chat/${o.id}?demo=1`, { replace: !0 });
6281
6303
  }).catch((o) => {
@@ -6306,11 +6328,11 @@ function qn() {
6306
6328
  return { type: "sales", party: "", amount: "", due_date: "", remarks: "" };
6307
6329
  }
6308
6330
  function Is() {
6309
- const t = Oe(), n = We(), [a, s] = v(""), [o, i] = v((/* @__PURE__ */ new Date()).toISOString().split("T")[0]), [c, l] = v(""), [g, d] = v([En()]), [p, m] = v([On()]), [f, S] = v([qn()]), [x, y] = v({}), P = oe({
6331
+ const t = Oe(), n = We(), [a, s] = v(""), [o, i] = v((/* @__PURE__ */ new Date()).toISOString().split("T")[0]), [c, l] = v(""), [y, d] = v([En()]), [p, m] = v([On()]), [f, w] = v([qn()]), [b, g] = v({}), P = oe({
6310
6332
  mutationFn: () => L.importAccountBalances({
6311
6333
  company: a,
6312
6334
  posting_date: o,
6313
- entries: g.filter((h) => h.account && (h.debit || h.credit)).map((h) => ({
6335
+ entries: y.filter((h) => h.account && (h.debit || h.credit)).map((h) => ({
6314
6336
  account: h.account,
6315
6337
  debit: parseFloat(h.debit) || 0,
6316
6338
  credit: parseFloat(h.credit) || 0,
@@ -6318,7 +6340,7 @@ function Is() {
6318
6340
  party: h.party || void 0
6319
6341
  }))
6320
6342
  }),
6321
- onSuccess: (h) => y((A) => ({ ...A, accounts: h }))
6343
+ onSuccess: (h) => g((A) => ({ ...A, accounts: h }))
6322
6344
  }), D = oe({
6323
6345
  mutationFn: () => L.importStockBalances({
6324
6346
  company: a,
@@ -6330,7 +6352,7 @@ function Is() {
6330
6352
  rate: parseFloat(h.rate) || 0
6331
6353
  }))
6332
6354
  }),
6333
- onSuccess: (h) => y((A) => ({ ...A, stock: h }))
6355
+ onSuccess: (h) => g((A) => ({ ...A, stock: h }))
6334
6356
  }), T = oe({
6335
6357
  mutationFn: () => L.importOutstandingInvoices({
6336
6358
  company: a,
@@ -6343,17 +6365,17 @@ function Is() {
6343
6365
  posting_date: o
6344
6366
  }))
6345
6367
  }),
6346
- onSuccess: (h) => y((A) => ({ ...A, invoices: h }))
6368
+ onSuccess: (h) => g((A) => ({ ...A, invoices: h }))
6347
6369
  });
6348
- function u(h, A, R, k, H) {
6370
+ function u(h, A, R, S, H) {
6349
6371
  const $ = [...h];
6350
- $[R][k] = H, A($);
6372
+ $[R][S] = H, A($);
6351
6373
  }
6352
6374
  return /* @__PURE__ */ r("div", { className: "space-y-6", children: [
6353
6375
  /* @__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." }),
6354
6376
  /* @__PURE__ */ e(U, { title: "Common Settings", children: /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
6355
6377
  /* @__PURE__ */ e(ke, { label: "Company", value: a, onChange: s, linkDoctype: "company", readOnly: !1 }),
6356
- /* @__PURE__ */ e(X, { label: "As-of Date", type: "date", value: o, onChange: (h) => i(h.target.value) })
6378
+ /* @__PURE__ */ e(ee, { label: "As-of Date", type: "date", value: o, onChange: (h) => i(h.target.value) })
6357
6379
  ] }) }),
6358
6380
  /* @__PURE__ */ r(U, { title: "1. Account Balances", children: [
6359
6381
  /* @__PURE__ */ e("p", { className: "mb-3 text-xs text-gray-500", children: "Enter your trial balance from the old system. The difference will be automatically balanced against Opening Balance Equity. For receivable/payable accounts, also set the party type and party." }),
@@ -6365,25 +6387,25 @@ function Is() {
6365
6387
  /* @__PURE__ */ e("th", { className: "px-2 py-2 text-right font-medium text-gray-500", children: "Debit" }),
6366
6388
  /* @__PURE__ */ e("th", { className: "px-2 py-2 text-right font-medium text-gray-500", children: "Credit" })
6367
6389
  ] }) }),
6368
- /* @__PURE__ */ e("tbody", { children: g.map((h, A) => /* @__PURE__ */ r("tr", { children: [
6369
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e(ke, { value: h.account, onChange: (R) => u(g, d, A, "account", R), linkDoctype: "account", readOnly: !1, label: "" }) }),
6370
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ r("select", { value: h.party_type, onChange: (R) => u(g, d, A, "party_type", R.target.value), className: "w-full rounded border border-gray-300 px-2 py-1.5 text-sm", children: [
6390
+ /* @__PURE__ */ e("tbody", { children: y.map((h, A) => /* @__PURE__ */ r("tr", { children: [
6391
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e(ke, { value: h.account, onChange: (R) => u(y, d, A, "account", R), linkDoctype: "account", readOnly: !1, label: "" }) }),
6392
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ r("select", { value: h.party_type, onChange: (R) => u(y, d, A, "party_type", R.target.value), className: "w-full rounded border border-gray-300 px-2 py-1.5 text-sm", children: [
6371
6393
  /* @__PURE__ */ e("option", { value: "", children: "—" }),
6372
6394
  /* @__PURE__ */ e("option", { value: "Customer", children: "Customer" }),
6373
6395
  /* @__PURE__ */ e("option", { value: "Supplier", children: "Supplier" })
6374
6396
  ] }) }),
6375
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: h.party_type ? /* @__PURE__ */ e(ke, { label: "", value: h.party, onChange: (R) => u(g, d, A, "party", R), linkDoctype: h.party_type.toLowerCase(), readOnly: !1 }) : /* @__PURE__ */ e("span", { className: "text-gray-300 text-xs", children: "set party type first" }) }),
6376
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.debit, onChange: (R) => u(g, d, A, "debit", R.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) }),
6377
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.credit, onChange: (R) => u(g, d, A, "credit", R.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) })
6397
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: h.party_type ? /* @__PURE__ */ e(ke, { label: "", value: h.party, onChange: (R) => u(y, d, A, "party", R), linkDoctype: h.party_type.toLowerCase(), readOnly: !1 }) : /* @__PURE__ */ e("span", { className: "text-gray-300 text-xs", children: "set party type first" }) }),
6398
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.debit, onChange: (R) => u(y, d, A, "debit", R.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) }),
6399
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.credit, onChange: (R) => u(y, d, A, "credit", R.target.value), className: "w-24 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) })
6378
6400
  ] }, A)) })
6379
6401
  ] }) }),
6380
- /* @__PURE__ */ e("div", { className: "mt-2 flex gap-2", children: /* @__PURE__ */ e("button", { onClick: () => d([...g, En()]), className: "text-xs text-blue-600 hover:text-blue-800", children: "+ Add Row" }) }),
6402
+ /* @__PURE__ */ e("div", { className: "mt-2 flex gap-2", children: /* @__PURE__ */ e("button", { onClick: () => d([...y, En()]), className: "text-xs text-blue-600 hover:text-blue-800", children: "+ Add Row" }) }),
6381
6403
  /* @__PURE__ */ r("div", { className: "mt-3 flex items-center gap-3", children: [
6382
6404
  /* @__PURE__ */ e(J, { onClick: () => P.mutate(), disabled: !a || P.isPending, children: P.isPending ? "Importing..." : "Import Account Balances" }),
6383
6405
  P.error && /* @__PURE__ */ e("span", { className: "text-xs text-red-600", children: P.error.message }),
6384
- x.accounts && /* @__PURE__ */ r("span", { className: "text-xs text-green-600", children: [
6406
+ b.accounts && /* @__PURE__ */ r("span", { className: "text-xs text-green-600", children: [
6385
6407
  "Created ",
6386
- x.accounts.journal_entry
6408
+ b.accounts.journal_entry
6387
6409
  ] })
6388
6410
  ] })
6389
6411
  ] }),
@@ -6406,11 +6428,11 @@ function Is() {
6406
6428
  /* @__PURE__ */ r("div", { className: "mt-3 flex items-center gap-3", children: [
6407
6429
  /* @__PURE__ */ e(J, { onClick: () => D.mutate(), disabled: !a || !c || D.isPending, children: D.isPending ? "Importing..." : "Import Stock Balances" }),
6408
6430
  D.error && /* @__PURE__ */ e("span", { className: "text-xs text-red-600", children: D.error.message }),
6409
- x.stock && /* @__PURE__ */ r("span", { className: "text-xs text-green-600", children: [
6431
+ b.stock && /* @__PURE__ */ r("span", { className: "text-xs text-green-600", children: [
6410
6432
  "Created ",
6411
- x.stock.stock_entry,
6433
+ b.stock.stock_entry,
6412
6434
  " (",
6413
- x.stock.items_count,
6435
+ b.stock.items_count,
6414
6436
  " items)"
6415
6437
  ] })
6416
6438
  ] })
@@ -6426,7 +6448,7 @@ function Is() {
6426
6448
  /* @__PURE__ */ e("th", { className: "px-2 py-2 text-left font-medium text-gray-500", children: "Ref / Remarks" })
6427
6449
  ] }) }),
6428
6450
  /* @__PURE__ */ e("tbody", { children: f.map((h, A) => /* @__PURE__ */ r("tr", { children: [
6429
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ r("select", { value: h.type, onChange: (R) => u(f, S, A, "type", R.target.value), className: "rounded border border-gray-300 px-2 py-1.5 text-sm", children: [
6451
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ r("select", { value: h.type, onChange: (R) => u(f, w, A, "type", R.target.value), className: "rounded border border-gray-300 px-2 py-1.5 text-sm", children: [
6430
6452
  /* @__PURE__ */ e("option", { value: "sales", children: "Sales (AR)" }),
6431
6453
  /* @__PURE__ */ e("option", { value: "purchase", children: "Purchase (AP)" })
6432
6454
  ] }) }),
@@ -6435,23 +6457,23 @@ function Is() {
6435
6457
  {
6436
6458
  label: "",
6437
6459
  value: h.party,
6438
- onChange: (R) => u(f, S, A, "party", R),
6460
+ onChange: (R) => u(f, w, A, "party", R),
6439
6461
  linkDoctype: h.type === "sales" ? "customer" : "supplier",
6440
6462
  readOnly: !1
6441
6463
  }
6442
6464
  ) }),
6443
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.amount, onChange: (R) => u(f, S, A, "amount", R.target.value), className: "w-28 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) }),
6444
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "date", value: h.due_date, onChange: (R) => u(f, S, A, "due_date", R.target.value), className: "rounded border border-gray-300 px-2 py-1.5 text-sm" }) }),
6445
- /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "text", value: h.remarks, onChange: (R) => u(f, S, A, "remarks", R.target.value), className: "w-full rounded border border-gray-300 px-2 py-1.5 text-sm", placeholder: "Old invoice ref" }) })
6465
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "number", value: h.amount, onChange: (R) => u(f, w, A, "amount", R.target.value), className: "w-28 rounded border border-gray-300 px-2 py-1.5 text-right text-sm", placeholder: "0.00" }) }),
6466
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "date", value: h.due_date, onChange: (R) => u(f, w, A, "due_date", R.target.value), className: "rounded border border-gray-300 px-2 py-1.5 text-sm" }) }),
6467
+ /* @__PURE__ */ e("td", { className: "px-2 py-1", children: /* @__PURE__ */ e("input", { type: "text", value: h.remarks, onChange: (R) => u(f, w, A, "remarks", R.target.value), className: "w-full rounded border border-gray-300 px-2 py-1.5 text-sm", placeholder: "Old invoice ref" }) })
6446
6468
  ] }, A)) })
6447
6469
  ] }) }),
6448
- /* @__PURE__ */ e("div", { className: "mt-2", children: /* @__PURE__ */ e("button", { onClick: () => S([...f, qn()]), className: "text-xs text-blue-600 hover:text-blue-800", children: "+ Add Row" }) }),
6470
+ /* @__PURE__ */ e("div", { className: "mt-2", children: /* @__PURE__ */ e("button", { onClick: () => w([...f, qn()]), className: "text-xs text-blue-600 hover:text-blue-800", children: "+ Add Row" }) }),
6449
6471
  /* @__PURE__ */ r("div", { className: "mt-3 flex items-center gap-3", children: [
6450
6472
  /* @__PURE__ */ e(J, { onClick: () => T.mutate(), disabled: !a || T.isPending, children: T.isPending ? "Importing..." : "Import Outstanding Invoices" }),
6451
6473
  T.error && /* @__PURE__ */ e("span", { className: "text-xs text-red-600", children: T.error.message }),
6452
- x.invoices && /* @__PURE__ */ r("span", { className: "text-xs text-green-600", children: [
6474
+ b.invoices && /* @__PURE__ */ r("span", { className: "text-xs text-green-600", children: [
6453
6475
  "Created ",
6454
- x.invoices.invoices_created,
6476
+ b.invoices.invoices_created,
6455
6477
  " invoices"
6456
6478
  ] })
6457
6479
  ] })
@@ -6478,7 +6500,7 @@ function Ls() {
6478
6500
  }), { data: o } = le({
6479
6501
  queryKey: ["auth-invites"],
6480
6502
  queryFn: () => L.authListInvites()
6481
- }), [i, c] = v(""), [l, g] = v("viewer"), [d, p] = v(null), m = oe({
6503
+ }), [i, c] = v(""), [l, y] = v("viewer"), [d, p] = v(null), m = oe({
6482
6504
  mutationFn: () => L.authInvite(i, l),
6483
6505
  onSuccess: (u) => {
6484
6506
  p(u), c(""), n.invalidateQueries({ queryKey: ["auth-invites"] });
@@ -6486,13 +6508,13 @@ function Ls() {
6486
6508
  }), f = oe({
6487
6509
  mutationFn: ({ name: u, role: h }) => L.authChangeRole(u, h),
6488
6510
  onSuccess: () => n.invalidateQueries({ queryKey: ["auth-users"] })
6489
- }), S = oe({
6511
+ }), w = oe({
6490
6512
  mutationFn: (u) => L.authDisableUser(u),
6491
6513
  onSuccess: () => n.invalidateQueries({ queryKey: ["auth-users"] })
6492
- }), x = oe({
6514
+ }), b = oe({
6493
6515
  mutationFn: (u) => L.authRevokeInvite(u),
6494
6516
  onSuccess: () => n.invalidateQueries({ queryKey: ["auth-invites"] })
6495
- }), [y, P] = v(null), D = (u) => `${window.location.origin}/login?invite=${u}`, T = async (u) => {
6517
+ }), [g, P] = v(null), D = (u) => `${window.location.origin}/login?invite=${u}`, T = async (u) => {
6496
6518
  try {
6497
6519
  await navigator.clipboard.writeText(D(u)), P(u), setTimeout(() => P((h) => h === u ? null : h), 2e3);
6498
6520
  } catch {
@@ -6517,7 +6539,7 @@ function Ls() {
6517
6539
  /* @__PURE__ */ r(U, { title: "Invite User", children: [
6518
6540
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end gap-4", children: [
6519
6541
  /* @__PURE__ */ e(
6520
- X,
6542
+ ee,
6521
6543
  {
6522
6544
  label: "Email",
6523
6545
  type: "email",
@@ -6532,7 +6554,7 @@ function Ls() {
6532
6554
  label: "Role",
6533
6555
  options: ["viewer", "manager", "admin"],
6534
6556
  value: l,
6535
- onChange: (u) => g(u.target.value)
6557
+ onChange: (u) => y(u.target.value)
6536
6558
  }
6537
6559
  ),
6538
6560
  /* @__PURE__ */ e(
@@ -6577,7 +6599,7 @@ function Ls() {
6577
6599
  variant: "secondary",
6578
6600
  size: "sm",
6579
6601
  onClick: () => T(u.token),
6580
- children: y === u.token ? "Copied!" : "Copy link"
6602
+ children: g === u.token ? "Copied!" : "Copy link"
6581
6603
  }
6582
6604
  ),
6583
6605
  /* @__PURE__ */ e(
@@ -6585,8 +6607,8 @@ function Ls() {
6585
6607
  {
6586
6608
  variant: "danger",
6587
6609
  size: "sm",
6588
- onClick: () => x.mutate(u.token),
6589
- disabled: x.isPending,
6610
+ onClick: () => b.mutate(u.token),
6611
+ disabled: b.isPending,
6590
6612
  children: "Revoke"
6591
6613
  }
6592
6614
  )
@@ -6623,7 +6645,7 @@ function Ls() {
6623
6645
  /* @__PURE__ */ e("td", { className: "px-4 py-2 text-right", children: u.name !== (t == null ? void 0 : t.name) && u.enabled ? /* @__PURE__ */ e(
6624
6646
  "button",
6625
6647
  {
6626
- onClick: () => S.mutate(u.name),
6648
+ onClick: () => w.mutate(u.name),
6627
6649
  className: "text-xs text-red-500 hover:text-red-700",
6628
6650
  children: "Disable"
6629
6651
  }
@@ -6692,17 +6714,17 @@ const Bs = { save: "Save", saving: "Saving...", submit: "Submit", cancel: "Cance
6692
6714
  chat: Oi,
6693
6715
  tutorial: qi,
6694
6716
  notesMarkup: Fi
6695
- }, ca = [
6717
+ }, da = [
6696
6718
  { code: "en", label: "English" },
6697
6719
  { code: "de", label: "Deutsch" },
6698
6720
  { code: "fr", label: "Français" }
6699
- ], da = "lambda-erp:language";
6721
+ ], ua = "lambda-erp:language";
6700
6722
  function zi(t) {
6701
- return !!t && ca.some((n) => n.code === t);
6723
+ return !!t && da.some((n) => n.code === t);
6702
6724
  }
6703
6725
  function $i() {
6704
6726
  try {
6705
- const t = localStorage.getItem(da);
6727
+ const t = localStorage.getItem(ua);
6706
6728
  if (zi(t)) return t;
6707
6729
  } catch {
6708
6730
  }
@@ -6710,11 +6732,11 @@ function $i() {
6710
6732
  }
6711
6733
  function Ui(t) {
6712
6734
  try {
6713
- localStorage.setItem(da, t);
6735
+ localStorage.setItem(ua, t);
6714
6736
  } catch {
6715
6737
  }
6716
6738
  }
6717
- Jn.use(Ca).init({
6739
+ Yn.use(Da).init({
6718
6740
  resources: {
6719
6741
  en: { translation: Xs },
6720
6742
  de: { translation: xi },
@@ -6728,7 +6750,7 @@ Jn.use(Ca).init({
6728
6750
  react: { useSuspense: !1 }
6729
6751
  // resources are bundled synchronously — no Suspense needed
6730
6752
  });
6731
- Jn.on("languageChanged", Ui);
6753
+ Yn.on("languageChanged", Ui);
6732
6754
  function Vi({ label: t }) {
6733
6755
  var o;
6734
6756
  const { t: n, i18n: a } = ae(), s = ((o = a.language) == null ? void 0 : o.split("-")[0]) ?? "en";
@@ -6736,7 +6758,7 @@ function Vi({ label: t }) {
6736
6758
  rt,
6737
6759
  {
6738
6760
  label: t === null ? void 0 : t ?? n("language.label"),
6739
- options: ca.map((i) => ({ value: i.code, label: i.label })),
6761
+ options: da.map((i) => ({ value: i.code, label: i.label })),
6740
6762
  value: s,
6741
6763
  onChange: (i) => a.changeLanguage(i.target.value)
6742
6764
  }
@@ -6755,12 +6777,12 @@ function je(t) {
6755
6777
  }
6756
6778
  function ji({ demoActive: t }) {
6757
6779
  var D, T;
6758
- const { t: n } = ae(), [a, s] = v("1h"), { data: o, isLoading: i, isFetching: c, error: l, refetch: g, dataUpdatedAt: d } = le({
6780
+ const { t: n } = ae(), [a, s] = v("1h"), { data: o, isLoading: i, isFetching: c, error: l, refetch: y, dataUpdatedAt: d } = le({
6759
6781
  queryKey: ["demo-spend"],
6760
6782
  queryFn: () => L.getDemoSpend(),
6761
6783
  // Refresh once a minute — demo spend changes slowly; no need to poll harder.
6762
6784
  refetchInterval: 6e4
6763
- }), p = Fn.find((u) => u.value === a), m = (D = o == null ? void 0 : o.windows) == null ? void 0 : D[a], f = ((T = o == null ? void 0 : o.caps) == null ? void 0 : T.global_hourly_usd) ?? 0, S = m ? m.demo_usd / p.hours : 0, x = m ? m.total_usd / p.hours : 0, y = f > 0 ? Math.min(100, S / f * 100) : 0, P = y >= 90 ? "bg-red-500" : y >= 60 ? "bg-amber-500" : "bg-emerald-500";
6785
+ }), p = Fn.find((u) => u.value === a), m = (D = o == null ? void 0 : o.windows) == null ? void 0 : D[a], f = ((T = o == null ? void 0 : o.caps) == null ? void 0 : T.global_hourly_usd) ?? 0, w = m ? m.demo_usd / p.hours : 0, b = m ? m.total_usd / p.hours : 0, g = f > 0 ? Math.min(100, w / f * 100) : 0, P = g >= 90 ? "bg-red-500" : g >= 60 ? "bg-amber-500" : "bg-emerald-500";
6764
6786
  return /* @__PURE__ */ r(U, { title: n("settings.tokenSpendTitle"), children: [
6765
6787
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-end justify-between gap-4", children: [
6766
6788
  /* @__PURE__ */ r("div", { className: "max-w-lg text-sm text-gray-600", children: [
@@ -6788,7 +6810,7 @@ function ji({ demoActive: t }) {
6788
6810
  "button",
6789
6811
  {
6790
6812
  type: "button",
6791
- onClick: () => g(),
6813
+ onClick: () => y(),
6792
6814
  disabled: c,
6793
6815
  title: d ? `Last updated ${new Date(d).toLocaleTimeString()}` : "Refresh now",
6794
6816
  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",
@@ -6833,7 +6855,7 @@ function ji({ demoActive: t }) {
6833
6855
  ")"
6834
6856
  ] }),
6835
6857
  /* @__PURE__ */ r("div", { className: "mt-1 text-2xl font-semibold text-gray-900", children: [
6836
- je(S),
6858
+ je(w),
6837
6859
  /* @__PURE__ */ r("span", { className: "ml-2 text-sm font-normal text-gray-500", children: [
6838
6860
  "/ ",
6839
6861
  je(f),
@@ -6847,17 +6869,17 @@ function ji({ demoActive: t }) {
6847
6869
  je(m.total_usd),
6848
6870
  /* @__PURE__ */ r("span", { className: "ml-1 text-xs font-normal text-gray-500", children: [
6849
6871
  "(",
6850
- je(x),
6872
+ je(b),
6851
6873
  "/hr)"
6852
6874
  ] })
6853
6875
  ] })
6854
6876
  ] })
6855
6877
  ] }),
6856
- /* @__PURE__ */ e("div", { className: "mt-2 h-2 w-full overflow-hidden rounded-full bg-gray-100", children: /* @__PURE__ */ e("div", { className: `h-full ${P} transition-all`, style: { width: `${y}%` } }) }),
6878
+ /* @__PURE__ */ e("div", { className: "mt-2 h-2 w-full overflow-hidden rounded-full bg-gray-100", children: /* @__PURE__ */ e("div", { className: `h-full ${P} transition-all`, style: { width: `${g}%` } }) }),
6857
6879
  /* @__PURE__ */ r("div", { className: "mt-1 text-xs text-gray-400", children: [
6858
- y.toFixed(0),
6880
+ g.toFixed(0),
6859
6881
  "% of the hourly cap",
6860
- y >= 100 && " — demo visitors are currently blocked"
6882
+ g >= 100 && " — demo visitors are currently blocked"
6861
6883
  ] })
6862
6884
  ] })
6863
6885
  ) : (
@@ -6869,7 +6891,7 @@ function ji({ demoActive: t }) {
6869
6891
  ")"
6870
6892
  ] }),
6871
6893
  /* @__PURE__ */ r("div", { className: "mt-1 text-2xl font-semibold text-gray-900", children: [
6872
- je(x),
6894
+ je(b),
6873
6895
  /* @__PURE__ */ r("span", { className: "ml-2 text-sm font-normal text-gray-500", children: [
6874
6896
  "(",
6875
6897
  je(m.total_usd),
@@ -6938,14 +6960,14 @@ function St({ label: t, value: n }) {
6938
6960
  ] });
6939
6961
  }
6940
6962
  function Gi() {
6941
- const { t } = ae(), { user: n } = bt(), [a, s] = v(""), [o, i] = v(""), [c, l] = v(""), [g, d] = v(""), [p, m] = v(!1), f = oe({
6963
+ const { t } = ae(), { user: n } = bt(), [a, s] = v(""), [o, i] = v(""), [c, l] = v(""), [y, d] = v(""), [p, m] = v(!1), f = oe({
6942
6964
  mutationFn: () => L.authChangePassword(a, o),
6943
6965
  onSuccess: () => {
6944
6966
  m(!0), d(""), s(""), i(""), l(""), setTimeout(() => m(!1), 4e3);
6945
6967
  },
6946
- onError: (x) => d(x instanceof Ge ? x.message : t("login.registrationFailed"))
6947
- }), S = (x) => {
6948
- if (x.preventDefault(), d(""), m(!1), o !== c) {
6968
+ onError: (b) => d(b instanceof Ge ? b.message : t("login.registrationFailed"))
6969
+ }), w = (b) => {
6970
+ if (b.preventDefault(), d(""), m(!1), o !== c) {
6949
6971
  d(t("login.passwordsNoMatch"));
6950
6972
  return;
6951
6973
  }
@@ -6955,7 +6977,7 @@ function Gi() {
6955
6977
  }
6956
6978
  f.mutate();
6957
6979
  };
6958
- return /* @__PURE__ */ e(U, { title: t("settings.passwordTitle"), children: /* @__PURE__ */ r("form", { onSubmit: S, className: "max-w-sm space-y-3", children: [
6980
+ return /* @__PURE__ */ e(U, { title: t("settings.passwordTitle"), children: /* @__PURE__ */ r("form", { onSubmit: w, className: "max-w-sm space-y-3", children: [
6959
6981
  /* @__PURE__ */ e(
6960
6982
  "input",
6961
6983
  {
@@ -6971,7 +6993,7 @@ function Gi() {
6971
6993
  }
6972
6994
  ),
6973
6995
  /* @__PURE__ */ e(
6974
- X,
6996
+ ee,
6975
6997
  {
6976
6998
  label: t("settings.currentPassword"),
6977
6999
  id: "current-password",
@@ -6979,12 +7001,12 @@ function Gi() {
6979
7001
  type: "password",
6980
7002
  autoComplete: "current-password",
6981
7003
  value: a,
6982
- onChange: (x) => s(x.target.value),
7004
+ onChange: (b) => s(b.target.value),
6983
7005
  required: !0
6984
7006
  }
6985
7007
  ),
6986
7008
  /* @__PURE__ */ e(
6987
- X,
7009
+ ee,
6988
7010
  {
6989
7011
  label: t("settings.newPassword"),
6990
7012
  id: "new-password",
@@ -6992,12 +7014,12 @@ function Gi() {
6992
7014
  type: "password",
6993
7015
  autoComplete: "new-password",
6994
7016
  value: o,
6995
- onChange: (x) => i(x.target.value),
7017
+ onChange: (b) => i(b.target.value),
6996
7018
  required: !0
6997
7019
  }
6998
7020
  ),
6999
7021
  /* @__PURE__ */ e(
7000
- X,
7022
+ ee,
7001
7023
  {
7002
7024
  label: t("settings.confirmNewPassword"),
7003
7025
  id: "confirm-password",
@@ -7005,11 +7027,11 @@ function Gi() {
7005
7027
  type: "password",
7006
7028
  autoComplete: "new-password",
7007
7029
  value: c,
7008
- onChange: (x) => l(x.target.value),
7030
+ onChange: (b) => l(b.target.value),
7009
7031
  required: !0
7010
7032
  }
7011
7033
  ),
7012
- g && /* @__PURE__ */ e("p", { className: "text-sm text-red-600", children: g }),
7034
+ y && /* @__PURE__ */ e("p", { className: "text-sm text-red-600", children: y }),
7013
7035
  p && /* @__PURE__ */ e("p", { className: "text-sm text-green-700", children: t("settings.passwordChanged") }),
7014
7036
  /* @__PURE__ */ e(J, { type: "submit", disabled: f.isPending || !a || !o || !c, children: f.isPending ? t("settings.changingPassword") : t("settings.changePassword") })
7015
7037
  ] }) });
@@ -7024,7 +7046,7 @@ function Ki() {
7024
7046
  }), { data: l } = le({
7025
7047
  queryKey: ["public-manager"],
7026
7048
  queryFn: () => L.getPublicManagerStatus()
7027
- }), [g, d] = v(!1), p = oe({
7049
+ }), [y, d] = v(!1), p = oe({
7028
7050
  mutationFn: () => L.createPublicManager(),
7029
7051
  onSuccess: () => {
7030
7052
  a.invalidateQueries({ queryKey: ["public-manager"] }), d(!1);
@@ -7104,7 +7126,7 @@ function Ki() {
7104
7126
  )
7105
7127
  ] }) : /* @__PURE__ */ r("div", { children: [
7106
7128
  /* @__PURE__ */ e("p", { className: "text-sm text-gray-600", children: n("settings.publicInactiveBody") }),
7107
- g ? /* @__PURE__ */ r("div", { className: "mt-3 rounded-lg border border-red-200 bg-red-50 p-4", children: [
7129
+ y ? /* @__PURE__ */ r("div", { className: "mt-3 rounded-lg border border-red-200 bg-red-50 p-4", children: [
7108
7130
  /* @__PURE__ */ e("p", { className: "text-sm font-medium text-red-800", children: n("common.areYouSure") }),
7109
7131
  /* @__PURE__ */ e("p", { className: "mt-1 text-xs text-red-600", children: n("settings.enableWarning") }),
7110
7132
  /* @__PURE__ */ r("div", { className: "mt-3 flex gap-2", children: [
@@ -7137,12 +7159,12 @@ function Ki() {
7137
7159
  ] }) })
7138
7160
  ] });
7139
7161
  }
7140
- const ua = {};
7162
+ const ma = {};
7141
7163
  function fo(t, n) {
7142
- ua[t] = n;
7164
+ ma[t] = n;
7143
7165
  }
7144
7166
  function Wi(t, n) {
7145
- return ua[t] ?? n;
7167
+ return ma[t] ?? n;
7146
7168
  }
7147
7169
  function Hi() {
7148
7170
  const t = Wi("Dashboard", hr);
@@ -7183,9 +7205,9 @@ const Qi = [
7183
7205
  // Admin
7184
7206
  { path: "admin/users", element: /* @__PURE__ */ e(Ls, {}) },
7185
7207
  { path: "admin/settings", element: /* @__PURE__ */ e(Ki, {}) }
7186
- ], ma = [], pa = [];
7208
+ ], pa = [], ha = [];
7187
7209
  function bo(t, n) {
7188
- (n == null ? void 0 : n.area) === "top" ? ma.push(t) : pa.push(t);
7210
+ (n == null ? void 0 : n.area) === "top" ? pa.push(t) : ha.push(t);
7189
7211
  }
7190
7212
  const Mn = (t) => t.index ? "__index__" : t.path ?? "";
7191
7213
  function zn(t, n) {
@@ -7198,16 +7220,16 @@ function zn(t, n) {
7198
7220
  }
7199
7221
  function Yi() {
7200
7222
  return [
7201
- ...zn(Qi, ma),
7223
+ ...zn(Qi, pa),
7202
7224
  {
7203
7225
  path: "/",
7204
7226
  element: /* @__PURE__ */ e(lr, { children: /* @__PURE__ */ e(ir, {}) }),
7205
- children: zn(Ji, pa)
7227
+ children: zn(Ji, ha)
7206
7228
  }
7207
7229
  ];
7208
7230
  }
7209
7231
  function Zi() {
7210
- return new va({
7232
+ return new Na({
7211
7233
  defaultOptions: {
7212
7234
  queries: { retry: 1, refetchOnWindowFocus: !1 }
7213
7235
  }
@@ -7217,16 +7239,16 @@ function xo(t = {}) {
7217
7239
  const n = t.rootElement ?? document.getElementById("root");
7218
7240
  if (!n)
7219
7241
  throw new Error('bootstrap: no mount element (pass rootElement or add <div id="root">)');
7220
- const a = t.queryClient ?? Zi(), s = ka(Yi());
7221
- ba(n).render(
7222
- /* @__PURE__ */ e(fa, { children: /* @__PURE__ */ e(xa, { client: a, children: /* @__PURE__ */ e(Ha, { children: /* @__PURE__ */ e(Sa, { router: s }) }) }) })
7242
+ const a = t.queryClient ?? Zi(), s = Sa(Yi());
7243
+ xa(n).render(
7244
+ /* @__PURE__ */ e(ba, { children: /* @__PURE__ */ e(va, { client: a, children: /* @__PURE__ */ e(Ha, { children: /* @__PURE__ */ e(Ca, { router: s }) }) }) })
7223
7245
  );
7224
7246
  }
7225
7247
  export {
7226
7248
  Ge as ApiError,
7227
7249
  ir as AppShell,
7228
7250
  Ha as AuthProvider,
7229
- ca as SUPPORTED_LANGUAGES,
7251
+ da as SUPPORTED_LANGUAGES,
7230
7252
  L as api,
7231
7253
  xo as bootstrap,
7232
7254
  Yi as buildRoutes,
@@ -7236,7 +7258,7 @@ export {
7236
7258
  yo as getAllDoctypeConfigs,
7237
7259
  Xa as getBranding,
7238
7260
  Wi as getComponent,
7239
- aa as getDoctypeConfig,
7261
+ ra as getDoctypeConfig,
7240
7262
  Za as getNavGroups,
7241
7263
  $i as getStoredLanguage,
7242
7264
  wo as i18n,