@lambda-development/erp-core 0.1.43 → 0.1.44

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
@@ -344,7 +344,7 @@ function tt(t) {
344
344
  return Number.isNaN(a) ? 0 : a;
345
345
  }
346
346
  function Za({ children: t }) {
347
- const n = We(), [a, i] = N([]), [o, s] = N({}), [c, l] = N({}), [g, d] = N({}), [p, u] = N({}), [b, f] = N({}), [v, y] = N({}), [I, P] = N({}), [C, m] = N(null), [h, R] = N("connecting"), [T, k] = N(0), G = ee(null), $ = ee(null), Q = ee(/* @__PURE__ */ new Map()), S = ee(null), B = ee({}), w = ee({}), O = ee(null);
347
+ const n = We(), [a, i] = N([]), [o, s] = N({}), [c, l] = N({}), [g, d] = N({}), [p, u] = N({}), [b, f] = N({}), [v, y] = N({}), [I, P] = N({}), [C, m] = N(null), [h, R] = N("connecting"), [T, k] = N(0), G = ee(null), $ = ee(null), Q = ee(/* @__PURE__ */ new Map()), S = ee(null), L = ee({}), w = ee({}), O = ee(null);
348
348
  function D(A) {
349
349
  for (const V of Q.current.values())
350
350
  V.reject(new Error(A));
@@ -372,27 +372,27 @@ function Za({ children: t }) {
372
372
  }
373
373
  function Ae(A) {
374
374
  return [...A].sort((V, W) => {
375
- const be = tt(B.current[V.id]) || tt(V.last_message_at || void 0) || tt(V.created_at);
376
- return (tt(B.current[W.id]) || tt(W.last_message_at || void 0) || tt(W.created_at)) - be;
375
+ const be = tt(L.current[V.id]) || tt(V.last_message_at || void 0) || tt(V.created_at);
376
+ return (tt(L.current[W.id]) || tt(W.last_message_at || void 0) || tt(W.created_at)) - be;
377
377
  });
378
378
  }
379
379
  function me(A) {
380
380
  i((V) => Ae(A(V)));
381
381
  }
382
382
  function ye(A, V) {
383
- const W = V || (/* @__PURE__ */ new Date()).toISOString(), be = B.current[A];
384
- tt(W) >= tt(be) && (B.current = {
385
- ...B.current,
383
+ const W = V || (/* @__PURE__ */ new Date()).toISOString(), be = L.current[A];
384
+ tt(W) >= tt(be) && (L.current = {
385
+ ...L.current,
386
386
  [A]: W
387
387
  });
388
388
  }
389
389
  function $e(A) {
390
- const V = { ...B.current };
390
+ const V = { ...L.current };
391
391
  for (const W of A)
392
392
  W.last_message_at && !V[W.id] && (V[W.id] = W.last_message_at);
393
- B.current = V;
393
+ L.current = V;
394
394
  }
395
- function L(A) {
395
+ function B(A) {
396
396
  const V = G.current;
397
397
  if (!V || V.readyState !== WebSocket.OPEN)
398
398
  throw new Error("Chat is disconnected.");
@@ -407,7 +407,7 @@ function Za({ children: t }) {
407
407
  reject: ve
408
408
  });
409
409
  try {
410
- L({ type: A, request_id: De, ...V });
410
+ B({ type: A, request_id: De, ...V });
411
411
  } catch (it) {
412
412
  Q.current.delete(De), ve(it instanceof Error ? it : new Error("Chat request failed."));
413
413
  }
@@ -488,8 +488,8 @@ function Za({ children: t }) {
488
488
  const H = { ...j };
489
489
  return delete H[q], H;
490
490
  });
491
- const F = { ...B.current };
492
- delete F[q], B.current = F;
491
+ const F = { ...L.current };
492
+ delete F[q], L.current = F;
493
493
  return;
494
494
  }
495
495
  if (ue === "history_loaded" && q) {
@@ -681,7 +681,7 @@ function Za({ children: t }) {
681
681
  }
682
682
  function Ue(A, V) {
683
683
  try {
684
- L({ type: "demo_typing_done", session_id: A, seq: V });
684
+ B({ type: "demo_typing_done", session_id: A, seq: V });
685
685
  } catch {
686
686
  }
687
687
  }
@@ -720,7 +720,7 @@ function Za({ children: t }) {
720
720
  session_id: A,
721
721
  content: be
722
722
  };
723
- return ve && (De.attachment_ids = W), L(De), !0;
723
+ return ve && (De.attachment_ids = W), B(De), !0;
724
724
  } catch {
725
725
  return X(A, !1), !1;
726
726
  }
@@ -2756,7 +2756,7 @@ function wn() {
2756
2756
  queryFn: () => _.getDocument(t, n),
2757
2757
  enabled: !!t && !!n && !c
2758
2758
  }), f = Ie(
2759
- () => !!(s != null && s.fields.some((L) => L.name === "currency")),
2759
+ () => !!(s != null && s.fields.some((B) => B.name === "currency")),
2760
2760
  [s]
2761
2761
  ), v = s == null ? void 0 : s.partyField, y = v ? l[v] : void 0, I = He(l.company), { data: P } = oe({
2762
2762
  queryKey: ["master", v, y],
@@ -2766,13 +2766,13 @@ function wn() {
2766
2766
  });
2767
2767
  se(() => {
2768
2768
  if (!c || !f || d) return;
2769
- let L;
2769
+ let B;
2770
2770
  if (y) {
2771
2771
  if (!P) return;
2772
- L = P.default_currency || I;
2772
+ B = P.default_currency || I;
2773
2773
  } else
2774
- L = I;
2775
- L && L !== l.currency && g((ne) => ({ ...ne, currency: L }));
2774
+ B = I;
2775
+ B && B !== l.currency && g((ne) => ({ ...ne, currency: B }));
2776
2776
  }, [
2777
2777
  c,
2778
2778
  f,
@@ -2783,33 +2783,33 @@ function wn() {
2783
2783
  l.currency
2784
2784
  ]), se(() => {
2785
2785
  if (c && s) {
2786
- const L = {};
2786
+ const B = {};
2787
2787
  s.fields.forEach((ne) => {
2788
- ne.type === "date" ? L[ne.name] = (/* @__PURE__ */ new Date()).toISOString().split("T")[0] : L[ne.name] = ne.default ?? "";
2788
+ ne.type === "date" ? B[ne.name] = (/* @__PURE__ */ new Date()).toISOString().split("T")[0] : B[ne.name] = ne.default ?? "";
2789
2789
  }), s.childTables.forEach((ne) => {
2790
- L[ne.key] = [];
2791
- }), L.docstatus = 0, g(L);
2790
+ B[ne.key] = [];
2791
+ }), B.docstatus = 0, g(B);
2792
2792
  } else u && g(u);
2793
2793
  }, [c, u, s]);
2794
2794
  const C = ie({
2795
- mutationFn: (L) => _.createDocument(t, L),
2796
- onSuccess: (L) => {
2797
- i.invalidateQueries({ queryKey: ["documents", t] }), a(`/app/${t}/${L.name}`, { replace: !0 });
2795
+ mutationFn: (B) => _.createDocument(t, B),
2796
+ onSuccess: (B) => {
2797
+ i.invalidateQueries({ queryKey: ["documents", t] }), a(`/app/${t}/${B.name}`, { replace: !0 });
2798
2798
  }
2799
2799
  }), m = ie({
2800
- mutationFn: (L) => _.updateDocument(t, n, L),
2801
- onSuccess: (L) => {
2802
- i.invalidateQueries({ queryKey: ["document", t, n] }), i.invalidateQueries({ queryKey: ["documents", t] }), g(L);
2800
+ mutationFn: (B) => _.updateDocument(t, n, B),
2801
+ onSuccess: (B) => {
2802
+ i.invalidateQueries({ queryKey: ["document", t, n] }), i.invalidateQueries({ queryKey: ["documents", t] }), g(B);
2803
2803
  }
2804
2804
  }), h = ie({
2805
2805
  mutationFn: () => _.submitDocument(t, n),
2806
- onSuccess: (L) => {
2807
- g(L), i.invalidateQueries({ queryKey: ["document", t, n] }), i.invalidateQueries({ queryKey: ["documents", t] });
2806
+ onSuccess: (B) => {
2807
+ g(B), i.invalidateQueries({ queryKey: ["document", t, n] }), i.invalidateQueries({ queryKey: ["documents", t] });
2808
2808
  }
2809
2809
  }), R = ie({
2810
2810
  mutationFn: () => _.cancelDocument(t, n),
2811
- onSuccess: (L) => {
2812
- g(L), i.invalidateQueries({ queryKey: ["document", t, n] }), i.invalidateQueries({ queryKey: ["documents", t] });
2811
+ onSuccess: (B) => {
2812
+ g(B), i.invalidateQueries({ queryKey: ["document", t, n] }), i.invalidateQueries({ queryKey: ["documents", t] });
2813
2813
  }
2814
2814
  }), T = ie({
2815
2815
  mutationFn: () => _.discardDocument(t, n),
@@ -2817,23 +2817,23 @@ function wn() {
2817
2817
  i.invalidateQueries({ queryKey: ["documents", t] }), a(`/app/${t}`, { replace: !0 });
2818
2818
  }
2819
2819
  }), k = ie({
2820
- mutationFn: (L) => _.convertDocument(t, n, L),
2821
- onSuccess: (L, ne) => {
2820
+ mutationFn: (B) => _.convertDocument(t, n, B),
2821
+ onSuccess: (B, ne) => {
2822
2822
  const Te = ne.toLowerCase().replace(/\s+/g, "-");
2823
- a(`/app/${Te}/${L.name}`);
2823
+ a(`/app/${Te}/${B.name}`);
2824
2824
  }
2825
2825
  }), G = Pe(
2826
- (L, ne) => {
2827
- L === "currency" && p(!0), g((Te) => {
2828
- const Ce = { ...Te, [L]: ne };
2829
- return L === "currency" && (Ce.conversion_rate = 0), Nn(Ce, s);
2826
+ (B, ne) => {
2827
+ B === "currency" && p(!0), g((Te) => {
2828
+ const Ce = { ...Te, [B]: ne };
2829
+ return B === "currency" && (Ce.conversion_rate = 0), Nn(Ce, s);
2830
2830
  });
2831
2831
  },
2832
2832
  [s]
2833
2833
  ), $ = Pe(
2834
- (L, ne) => {
2834
+ (B, ne) => {
2835
2835
  g((Te) => {
2836
- const Ce = { ...Te, [L]: ne };
2836
+ const Ce = { ...Te, [B]: ne };
2837
2837
  return Nn(Ce, s);
2838
2838
  });
2839
2839
  },
@@ -2842,10 +2842,10 @@ function wn() {
2842
2842
  c ? C.mutate(l) : m.mutate(l);
2843
2843
  }, S = () => {
2844
2844
  h.mutate();
2845
- }, B = () => {
2845
+ }, L = () => {
2846
2846
  R.mutate();
2847
- }, w = (L) => {
2848
- k.mutate(L);
2847
+ }, w = (B) => {
2848
+ k.mutate(B);
2849
2849
  }, O = () => {
2850
2850
  T.mutate();
2851
2851
  };
@@ -2856,7 +2856,7 @@ function wn() {
2856
2856
  ] });
2857
2857
  if (!c && b)
2858
2858
  return /* @__PURE__ */ e("p", { className: "text-fg-muted", children: o("common.loading") });
2859
- const D = l.docstatus ?? 0, M = !!l.discarded, X = D >= 1 || M, re = l.currency || "USD", he = Me(l.conversion_rate ?? 1), ge = s.fields.filter((L) => !L.readOnly), Ae = ge.filter((L) => L.type !== "textarea"), me = ge.filter((L) => L.type === "textarea"), ye = s.fields.filter((L) => L.readOnly);
2859
+ const D = l.docstatus ?? 0, M = !!l.discarded, X = D >= 1 || M, re = l.currency || "USD", he = Me(l.conversion_rate ?? 1), ge = s.fields.filter((B) => !B.readOnly), Ae = ge.filter((B) => B.type !== "textarea"), me = ge.filter((B) => B.type === "textarea"), ye = s.fields.filter((B) => B.readOnly);
2860
2860
  return /* @__PURE__ */ r("div", { className: "space-y-6", children: [
2861
2861
  /* @__PURE__ */ r("div", { className: "flex flex-col gap-3 sm:flex-row sm:items-center sm:justify-between", children: [
2862
2862
  /* @__PURE__ */ r("div", { className: "flex items-center gap-3", children: [
@@ -2888,7 +2888,7 @@ function wn() {
2888
2888
  discarded: M,
2889
2889
  onSave: Q,
2890
2890
  onSubmit: S,
2891
- onCancel: B,
2891
+ onCancel: L,
2892
2892
  onConvert: w,
2893
2893
  onDiscard: O
2894
2894
  }
@@ -2896,53 +2896,53 @@ function wn() {
2896
2896
  ] }),
2897
2897
  (C.error || m.error || h.error || R.error) && /* @__PURE__ */ e("div", { className: "rounded-lg bg-rose-50 p-4 text-sm text-rose-700 ring-1 ring-rose-200", children: (($e = C.error ?? m.error ?? h.error ?? R.error) == null ? void 0 : $e.message) ?? o("common.errorOccurred") }),
2898
2898
  /* @__PURE__ */ r(U, { children: [
2899
- /* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3", children: Ae.map((L) => /* @__PURE__ */ e(
2899
+ /* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2 lg:grid-cols-3", children: Ae.map((B) => /* @__PURE__ */ e(
2900
2900
  Tt,
2901
2901
  {
2902
- field: L,
2903
- value: l[L.name],
2904
- onChange: (ne) => G(L.name, ne),
2902
+ field: B,
2903
+ value: l[B.name],
2904
+ onChange: (ne) => G(B.name, ne),
2905
2905
  readOnly: X,
2906
2906
  rowData: l,
2907
2907
  currency: re
2908
2908
  },
2909
- L.name
2909
+ B.name
2910
2910
  )) }),
2911
- me.length > 0 && /* @__PURE__ */ e("div", { className: "mt-4 space-y-4", children: me.map((L) => /* @__PURE__ */ e(
2911
+ me.length > 0 && /* @__PURE__ */ e("div", { className: "mt-4 space-y-4", children: me.map((B) => /* @__PURE__ */ e(
2912
2912
  Tt,
2913
2913
  {
2914
- field: L,
2915
- value: l[L.name],
2916
- onChange: (ne) => G(L.name, ne),
2914
+ field: B,
2915
+ value: l[B.name],
2916
+ onChange: (ne) => G(B.name, ne),
2917
2917
  readOnly: X,
2918
2918
  rowData: l,
2919
2919
  currency: re
2920
2920
  },
2921
- L.name
2921
+ B.name
2922
2922
  )) })
2923
2923
  ] }),
2924
- s.childTables.map((L) => /* @__PURE__ */ e(
2924
+ s.childTables.map((B) => /* @__PURE__ */ e(
2925
2925
  Dr,
2926
2926
  {
2927
- tableDef: L,
2928
- rows: l[L.key] ?? [],
2929
- onChange: (ne) => $(L.key, ne),
2927
+ tableDef: B,
2928
+ rows: l[B.key] ?? [],
2929
+ onChange: (ne) => $(B.key, ne),
2930
2930
  readOnly: X,
2931
2931
  currency: re
2932
2932
  },
2933
- L.key
2933
+ B.key
2934
2934
  )),
2935
- ye.length > 0 && /* @__PURE__ */ e(U, { title: o("common.totals"), children: /* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-3", children: ye.map((L) => /* @__PURE__ */ e(
2935
+ ye.length > 0 && /* @__PURE__ */ e(U, { title: o("common.totals"), children: /* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-3", children: ye.map((B) => /* @__PURE__ */ e(
2936
2936
  Tt,
2937
2937
  {
2938
- field: L,
2939
- value: l[L.name],
2938
+ field: B,
2939
+ value: l[B.name],
2940
2940
  onChange: () => {
2941
2941
  },
2942
2942
  readOnly: !0,
2943
2943
  currency: re
2944
2944
  },
2945
- L.name
2945
+ B.name
2946
2946
  )) }) })
2947
2947
  ] });
2948
2948
  }
@@ -3096,7 +3096,7 @@ function Er() {
3096
3096
  return i !== "All" && (S.status = i), o && (S.from_date = o), s && (S.to_date = s), c && (S.include_discarded = "true"), S.limit = l, S.offset = d * l, S;
3097
3097
  }, [i, o, s, c, l, d]), { data: C, isLoading: m } = yr(n ?? "", P), h = (C == null ? void 0 : C.rows) ?? [], R = (C == null ? void 0 : C.total) ?? 0, T = Math.max(1, Math.ceil(R / l)), k = R === 0 ? 0 : d * l + 1, G = Math.min(R, (d + 1) * l), $ = Ie(() => {
3098
3098
  if (!a) return [];
3099
- const S = Gn(), B = (w) => {
3099
+ const S = Gn(), L = (w) => {
3100
3100
  const O = w.split("_").map((D) => D.charAt(0).toUpperCase() + D.slice(1)).join(" ");
3101
3101
  return t(`fields.${O}`, { defaultValue: O });
3102
3102
  };
@@ -3120,7 +3120,7 @@ function Er() {
3120
3120
  });
3121
3121
  if (Rr.has(w))
3122
3122
  return S.accessor(w, {
3123
- header: B(w),
3123
+ header: L(w),
3124
3124
  cell: (O) => {
3125
3125
  var D;
3126
3126
  return qe(O.getValue(), ((D = O.row.original) == null ? void 0 : D.currency) || "USD");
@@ -3147,7 +3147,7 @@ function Er() {
3147
3147
  if (Cn[w]) {
3148
3148
  const O = Cn[w];
3149
3149
  return S.accessor(w, {
3150
- header: B(w),
3150
+ header: L(w),
3151
3151
  cell: (D) => {
3152
3152
  const M = D.getValue();
3153
3153
  if (!M) return "-";
@@ -3165,10 +3165,10 @@ function Er() {
3165
3165
  });
3166
3166
  }
3167
3167
  return Ir.has(w) ? S.accessor(w, {
3168
- header: B(w),
3168
+ header: L(w),
3169
3169
  cell: (O) => qt(O.getValue())
3170
3170
  }) : S.accessor(w, {
3171
- header: B(w)
3171
+ header: L(w)
3172
3172
  });
3173
3173
  });
3174
3174
  }, [a, t]), Q = Hn({
@@ -3222,24 +3222,24 @@ function Er() {
3222
3222
  t("common.showDiscarded")
3223
3223
  ] })
3224
3224
  ] }),
3225
- /* @__PURE__ */ e(Ft, { onSelect: (S, B) => p({ from: S, to: B, page: null }) }),
3225
+ /* @__PURE__ */ e(Ft, { onSelect: (S, L) => p({ from: S, to: L, page: null }) }),
3226
3226
  m ? /* @__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: [
3227
3227
  /* @__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: [
3228
- /* @__PURE__ */ e("thead", { className: "bg-surface-subtle", children: Q.getHeaderGroups().map((S) => /* @__PURE__ */ e("tr", { children: S.headers.map((B) => /* @__PURE__ */ e(
3228
+ /* @__PURE__ */ e("thead", { className: "bg-surface-subtle", children: Q.getHeaderGroups().map((S) => /* @__PURE__ */ e("tr", { children: S.headers.map((L) => /* @__PURE__ */ e(
3229
3229
  "th",
3230
3230
  {
3231
3231
  className: "px-4 py-3 text-left text-xs font-medium uppercase tracking-wide text-fg-muted",
3232
- children: B.isPlaceholder ? null : Rt(
3233
- B.column.columnDef.header,
3234
- B.getContext()
3232
+ children: L.isPlaceholder ? null : Rt(
3233
+ L.column.columnDef.header,
3234
+ L.getContext()
3235
3235
  )
3236
3236
  },
3237
- B.id
3237
+ L.id
3238
3238
  )) }, S.id)) }),
3239
- /* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children: Q.getRowModel().rows.map((S) => /* @__PURE__ */ e("tr", { className: "transition-colors hover:bg-surface-subtle", children: S.getVisibleCells().map((B) => /* @__PURE__ */ e("td", { className: "px-4 py-2.5 text-fg", children: Rt(
3240
- B.column.columnDef.cell,
3241
- B.getContext()
3242
- ) }, B.id)) }, S.id)) })
3239
+ /* @__PURE__ */ e("tbody", { className: "divide-y divide-line", children: Q.getRowModel().rows.map((S) => /* @__PURE__ */ e("tr", { className: "transition-colors hover:bg-surface-subtle", children: S.getVisibleCells().map((L) => /* @__PURE__ */ e("td", { className: "px-4 py-2.5 text-fg", children: Rt(
3240
+ L.column.columnDef.cell,
3241
+ L.getContext()
3242
+ ) }, L.id)) }, S.id)) })
3243
3243
  ] }) }),
3244
3244
  /* @__PURE__ */ r("div", { className: "flex flex-wrap items-center justify-between gap-3 text-sm text-fg-muted", children: [
3245
3245
  /* @__PURE__ */ r("div", { children: [
@@ -3357,9 +3357,9 @@ function ke({
3357
3357
  };
3358
3358
  return se(() => {
3359
3359
  const $ = (Q) => {
3360
- var B, w;
3360
+ var L, w;
3361
3361
  const S = Q.target;
3362
- (B = I.current) != null && B.contains(S) || (w = P.current) != null && w.contains(S) || p(!1);
3362
+ (L = I.current) != null && L.contains(S) || (w = P.current) != null && w.contains(S) || p(!1);
3363
3363
  };
3364
3364
  return document.addEventListener("mousedown", $), () => document.removeEventListener("mousedown", $);
3365
3365
  }, []), o ? /* @__PURE__ */ r("div", { children: [
@@ -3484,7 +3484,7 @@ function Dn() {
3484
3484
  f(!1);
3485
3485
  }
3486
3486
  }
3487
- }, B = async () => {
3487
+ }, L = async () => {
3488
3488
  if (!n) {
3489
3489
  f(!0);
3490
3490
  try {
@@ -3574,7 +3574,7 @@ function Dn() {
3574
3574
  "📎 ",
3575
3575
  p
3576
3576
  ] }),
3577
- /* @__PURE__ */ e("button", { type: "button", onClick: B, disabled: b, className: "text-red-500 hover:underline", children: s("common.remove", "Remove") })
3577
+ /* @__PURE__ */ e("button", { type: "button", onClick: L, disabled: b, className: "text-red-500 hover:underline", children: s("common.remove", "Remove") })
3578
3578
  ] }) : /* @__PURE__ */ r("div", { children: [
3579
3579
  /* @__PURE__ */ e("input", { ref: I, type: "file", accept: "application/pdf", onChange: S, className: "hidden" }),
3580
3580
  /* @__PURE__ */ e(J, { size: "sm", variant: "secondary", disabled: b, onClick: () => {
@@ -3854,18 +3854,20 @@ function An() {
3854
3854
  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 }) }),
3855
3855
  /* @__PURE__ */ e(U, { children: /* @__PURE__ */ e("div", { className: "grid grid-cols-1 gap-4 sm:grid-cols-2", children: g.map((k) => {
3856
3856
  const $ = k.name === "name" && !s || k.readOnly, Q = k.required && !(s && k.name === "name" && Pn.has(t ?? ""));
3857
- if (k.type === "select" && k.options)
3857
+ if (k.type === "select" && k.options) {
3858
+ const L = p[k.name], w = typeof L == "string" && L !== "" && !k.options.includes(L) ? [...k.options, L] : k.options;
3858
3859
  return /* @__PURE__ */ e("div", { children: /* @__PURE__ */ e(
3859
3860
  Je,
3860
3861
  {
3861
3862
  label: d(k),
3862
- options: k.options,
3863
+ options: w,
3863
3864
  value: p[k.name] ?? "",
3864
3865
  required: Q,
3865
3866
  disabled: $,
3866
- onChange: (B) => m(k.name, B.target.value)
3867
+ onChange: (O) => m(k.name, O.target.value)
3867
3868
  }
3868
3869
  ) }, k.name);
3870
+ }
3869
3871
  if (k.type === "textarea")
3870
3872
  return /* @__PURE__ */ r("div", { className: "sm:col-span-2", children: [
3871
3873
  /* @__PURE__ */ e("label", { className: "mb-1.5 block text-sm font-medium text-fg", children: d(k) }),
@@ -3878,7 +3880,7 @@ function An() {
3878
3880
  required: Q,
3879
3881
  readOnly: $,
3880
3882
  disabled: $,
3881
- onChange: (B) => m(k.name, B.target.value)
3883
+ onChange: (L) => m(k.name, L.target.value)
3882
3884
  }
3883
3885
  )
3884
3886
  ] }, k.name);
@@ -3893,9 +3895,9 @@ function An() {
3893
3895
  readOnly: $,
3894
3896
  disabled: $,
3895
3897
  value: p[k.name] ?? "",
3896
- onChange: (B) => m(
3898
+ onChange: (L) => m(
3897
3899
  k.name,
3898
- S === "number" ? parseFloat(B.target.value) || 0 : B.target.value
3900
+ S === "number" ? parseFloat(L.target.value) || 0 : L.target.value
3899
3901
  )
3900
3902
  },
3901
3903
  k.name
@@ -4037,7 +4039,7 @@ function Yr() {
4037
4039
  const { t } = te(), [n] = ae("account", ""), [a] = ae("party", ""), [i] = ae("from", ""), [o] = ae("to", ""), [s] = ae("per_page", 50), [c] = ae("page", 1), l = c - 1, g = Qe(), d = (D) => g({ page: D === 0 ? null : D + 1 }), p = (D) => g({ per_page: D, page: null }), [u, b] = N(n), [f, v] = N(a), [y, I] = N(i), [P, C] = N(o), m = He(), h = (D) => qe(D, m), R = Ie(() => {
4038
4040
  const D = {};
4039
4041
  return n && (D.account = n), a && (D.party = a), i && (D.from_date = i), o && (D.to_date = o), D.limit = String(s), D.offset = String(l * s), D;
4040
- }, [n, a, i, o, s, l]), { data: T, isLoading: k, refetch: G } = Ur(R), $ = (T == null ? void 0 : T.rows) ?? [], Q = (T == null ? void 0 : T.total) ?? 0, S = Math.max(1, Math.ceil(Q / s)), B = Q === 0 ? 0 : l * s + 1, w = Math.min(Q, (l + 1) * s), O = () => {
4042
+ }, [n, a, i, o, s, l]), { data: T, isLoading: k, refetch: G } = Ur(R), $ = (T == null ? void 0 : T.rows) ?? [], Q = (T == null ? void 0 : T.total) ?? 0, S = Math.max(1, Math.ceil(Q / s)), L = Q === 0 ? 0 : l * s + 1, w = Math.min(Q, (l + 1) * s), O = () => {
4041
4043
  g({
4042
4044
  account: u || null,
4043
4045
  party: f || null,
@@ -4126,7 +4128,7 @@ function Yr() {
4126
4128
  t("common.showing"),
4127
4129
  " ",
4128
4130
  /* @__PURE__ */ r("span", { className: "font-medium text-gray-900", children: [
4129
- B,
4131
+ L,
4130
4132
  "–",
4131
4133
  w
4132
4134
  ] }),
@@ -4574,7 +4576,7 @@ function ss() {
4574
4576
  fromDate: c || void 0,
4575
4577
  toDate: l || void 0,
4576
4578
  company: g || void 0
4577
- }), null, 2), [o, s, c, l, g]), B = async (M) => {
4579
+ }), null, 2), [o, s, c, l, g]), L = async (M) => {
4578
4580
  var he;
4579
4581
  const X = ++Q.current, re = () => Q.current === X;
4580
4582
  I(""), C(!0);
@@ -4584,13 +4586,13 @@ function ss() {
4584
4586
  b(me.datasets), (he = k.current) == null || he.terminate();
4585
4587
  const ye = new as();
4586
4588
  k.current = ye;
4587
- const $e = await new Promise((L, ne) => {
4589
+ const $e = await new Promise((B, ne) => {
4588
4590
  const Te = window.setTimeout(() => {
4589
4591
  ye.terminate(), ne(new Error("Report runtime exceeded 4 seconds"));
4590
4592
  }, 4e3);
4591
4593
  ye.onmessage = (Ce) => {
4592
4594
  var Ue, Fe;
4593
- window.clearTimeout(Te), ye.terminate(), k.current === ye && (k.current = null), (Ue = Ce.data) != null && Ue.ok ? L(Ce.data.output) : ne(new Error(((Fe = Ce.data) == null ? void 0 : Fe.error) || "Runtime failed"));
4595
+ window.clearTimeout(Te), ye.terminate(), k.current === ye && (k.current = null), (Ue = Ce.data) != null && Ue.ok ? B(Ce.data.output) : ne(new Error(((Fe = Ce.data) == null ? void 0 : Fe.error) || "Runtime failed"));
4594
4596
  }, ye.postMessage({
4595
4597
  datasets: me.datasets,
4596
4598
  params: {},
@@ -4611,14 +4613,14 @@ function ss() {
4611
4613
  return i ? G.current === i ? void 0 : (h(!0), I(""), _.getRuntimeDraft(i).then((X) => {
4612
4614
  if (M) return;
4613
4615
  const re = JSON.stringify(X.definition, null, 2);
4614
- return G.current = i, $.current = re, T(X.source_chat_session_id || ""), p(re), B(re);
4616
+ return G.current = i, $.current = re, T(X.source_chat_session_id || ""), p(re), L(re);
4615
4617
  }).catch((X) => {
4616
4618
  M || (v(null), I(X instanceof Error ? X.message : String(X)));
4617
4619
  }).finally(() => {
4618
4620
  M || h(!1);
4619
4621
  }), () => {
4620
4622
  M = !0;
4621
- }) : (G.current = "", $.current = "", T(""), S && ($.current = S, p(S), B(S)), () => {
4623
+ }) : (G.current = "", $.current = "", T(""), S && ($.current = S, p(S), L(S)), () => {
4622
4624
  M = !0;
4623
4625
  });
4624
4626
  }, [i, S]);
@@ -4671,7 +4673,7 @@ function ss() {
4671
4673
  i
4672
4674
  ] }) : w ? /* @__PURE__ */ e("div", { className: "text-xs text-gray-500", children: "Loaded runtime report from legacy URL filters." }) : null,
4673
4675
  i ? /* @__PURE__ */ e(J, { variant: "secondary", onClick: () => void D(), children: "Fix In Chat" }) : null,
4674
- /* @__PURE__ */ e(J, { onClick: () => void B(), disabled: P, children: P ? "Running..." : "Run Report" })
4676
+ /* @__PURE__ */ e(J, { onClick: () => void L(), disabled: P, children: P ? "Running..." : "Run Report" })
4675
4677
  ] })
4676
4678
  ] }) }),
4677
4679
  m ? /* @__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 }) }) : f ? /* @__PURE__ */ e(is, { output: f }) : /* @__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." }) }),
@@ -5650,7 +5652,7 @@ function Bn() {
5650
5652
  completeDemoTyping: $,
5651
5653
  loadHistory: Q,
5652
5654
  loadMoreHistory: S,
5653
- sendMessage: B,
5655
+ sendMessage: L,
5654
5656
  transcribeAudio: w,
5655
5657
  getMessages: O,
5656
5658
  hasMoreHistory: D,
@@ -5658,7 +5660,7 @@ function Bn() {
5658
5660
  isThinking: X,
5659
5661
  getDemoStatus: re,
5660
5662
  getDemoTypingCue: he
5661
- } = ut(), ge = ee(null), Ae = ee(null), me = ee(null), ye = ee(null), [$e, L] = N(0), ne = ee(!1), Te = ee(null), Ce = ee(0), Ue = ee(!0), Fe = ee(null), vt = ee(!1), mt = ee(null), Ye = O(n), we = R === "connected", _e = X(n), Ve = re(n), Ge = he(n), Re = s || Ve === "running", pt = D(n), st = M(n), ht = Ye[Ye.length - 1], A = ht ? `${ht.type}:${ht.timestamp || ""}:${ht.content}` : "empty", V = Pe(() => {
5663
+ } = ut(), ge = ee(null), Ae = ee(null), me = ee(null), ye = ee(null), [$e, B] = N(0), ne = ee(!1), Te = ee(null), Ce = ee(0), Ue = ee(!0), Fe = ee(null), vt = ee(!1), mt = ee(null), Ye = O(n), we = R === "connected", _e = X(n), Ve = re(n), Ge = he(n), Re = s || Ve === "running", pt = D(n), st = M(n), ht = Ye[Ye.length - 1], A = ht ? `${ht.type}:${ht.timestamp || ""}:${ht.content}` : "empty", V = Pe(() => {
5662
5664
  vt.current = !0, mt.current !== null && window.clearTimeout(mt.current), mt.current = window.setTimeout(() => {
5663
5665
  vt.current = !1, mt.current = null;
5664
5666
  }, 600);
@@ -5695,8 +5697,8 @@ function Bn() {
5695
5697
  };
5696
5698
  }, [Re, _e, V]), cn(() => {
5697
5699
  const x = ye.current;
5698
- if (!x || (L(x.offsetHeight), typeof ResizeObserver > "u")) return;
5699
- const z = new ResizeObserver(() => L(x.offsetHeight));
5700
+ if (!x || (B(x.offsetHeight), typeof ResizeObserver > "u")) return;
5701
+ const z = new ResizeObserver(() => B(x.offsetHeight));
5700
5702
  return z.observe(x), () => z.disconnect();
5701
5703
  }, []);
5702
5704
  const be = Pe(() => {
@@ -5828,7 +5830,7 @@ function Bn() {
5828
5830
  }, xe = p.some((x) => x.uploading), le = p.some((x) => x.error), de = p.filter((x) => x.uploadedId && !x.error).map((x) => x.uploadedId);
5829
5831
  function gt() {
5830
5832
  const x = c.trim();
5831
- if (n && !(!x && de.length === 0) && !xe && B(n, x, de.length > 0 ? de : void 0)) {
5833
+ if (n && !(!x && de.length === 0) && !xe && L(n, x, de.length > 0 ? de : void 0)) {
5832
5834
  for (const z of p)
5833
5835
  z.previewUrl && URL.revokeObjectURL(z.previewUrl);
5834
5836
  u([]), f(""), l("");
@@ -6230,16 +6232,16 @@ function Rs() {
6230
6232
  se(() => {
6231
6233
  a && a.role !== "public_manager" && t("/", { replace: !0 });
6232
6234
  }, [a, t]), se(() => {
6233
- _.authSetupStatus().then((B) => {
6234
- p(B.registration_open), b(B.first_run), v(B.oauth_providers ?? []), B.first_run && g("register");
6235
+ _.authSetupStatus().then((L) => {
6236
+ p(L.registration_open), b(L.first_run), v(L.oauth_providers ?? []), L.first_run && g("register");
6235
6237
  }).catch(() => {
6236
6238
  }).finally(() => I(!1));
6237
6239
  }, []), se(() => {
6238
- const B = n.get("oauth_error");
6239
- B && C(s(`login.oauthError.${B}`, { defaultValue: s("login.oauthError.generic") }));
6240
+ const L = n.get("oauth_error");
6241
+ L && C(s(`login.oauthError.${L}`, { defaultValue: s("login.oauthError.generic") }));
6240
6242
  }, [n, s]);
6241
- const S = async (B) => {
6242
- if (B.preventDefault(), C(""), l === "register") {
6243
+ const S = async (L) => {
6244
+ if (L.preventDefault(), C(""), l === "register") {
6243
6245
  if (k !== $) {
6244
6246
  C(s("login.passwordsNoMatch"));
6245
6247
  return;
@@ -6274,7 +6276,7 @@ function Rs() {
6274
6276
  {
6275
6277
  label: s("login.fullName"),
6276
6278
  value: R,
6277
- onChange: (B) => T(B.target.value),
6279
+ onChange: (L) => T(L.target.value),
6278
6280
  required: !0
6279
6281
  }
6280
6282
  ),
@@ -6284,7 +6286,7 @@ function Rs() {
6284
6286
  label: s("login.email"),
6285
6287
  type: "email",
6286
6288
  value: m,
6287
- onChange: (B) => h(B.target.value),
6289
+ onChange: (L) => h(L.target.value),
6288
6290
  required: !0
6289
6291
  }
6290
6292
  ),
@@ -6294,7 +6296,7 @@ function Rs() {
6294
6296
  label: s("login.password"),
6295
6297
  type: "password",
6296
6298
  value: k,
6297
- onChange: (B) => G(B.target.value),
6299
+ onChange: (L) => G(L.target.value),
6298
6300
  required: !0
6299
6301
  }
6300
6302
  ),
@@ -6304,7 +6306,7 @@ function Rs() {
6304
6306
  label: s("login.confirmPassword"),
6305
6307
  type: "password",
6306
6308
  value: $,
6307
- onChange: (B) => Q(B.target.value),
6309
+ onChange: (L) => Q(L.target.value),
6308
6310
  required: !0
6309
6311
  }
6310
6312
  ),
@@ -6316,20 +6318,20 @@ function Rs() {
6316
6318
  /* @__PURE__ */ e("span", { className: "text-xs uppercase tracking-wide text-fg-muted", children: s("login.orContinueWith") }),
6317
6319
  /* @__PURE__ */ e("div", { className: "h-px flex-1 bg-border" })
6318
6320
  ] }),
6319
- /* @__PURE__ */ e("div", { className: "space-y-2", children: f.map((B) => /* @__PURE__ */ r(
6321
+ /* @__PURE__ */ e("div", { className: "space-y-2", children: f.map((L) => /* @__PURE__ */ r(
6320
6322
  "button",
6321
6323
  {
6322
6324
  type: "button",
6323
6325
  onClick: () => {
6324
- window.location.href = _.oauthLoginUrl(B, { invite: c || void 0 });
6326
+ window.location.href = _.oauthLoginUrl(L, { invite: c || void 0 });
6325
6327
  },
6326
6328
  className: "flex w-full items-center justify-center gap-2 rounded-lg border border-border bg-surface px-4 py-2 text-sm font-medium text-fg transition-colors hover:bg-surface-muted",
6327
6329
  children: [
6328
- /* @__PURE__ */ e(Ls, { provider: B }),
6329
- s("login.continueWithProvider", { provider: Is(B) })
6330
+ /* @__PURE__ */ e(Ls, { provider: L }),
6331
+ s("login.continueWithProvider", { provider: Is(L) })
6330
6332
  ]
6331
6333
  },
6332
- B
6334
+ L
6333
6335
  )) })
6334
6336
  ] })
6335
6337
  ] }),