@nivaro/react 0.3.57 → 0.3.59

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.
Files changed (69) hide show
  1. package/dist/components/fields/RelationField.js +110 -80
  2. package/dist/full.css +1 -1
  3. package/dist/hooks/useRelationOptions.js +1 -0
  4. package/dist/hooks/useSessionRecorder.js +1 -1
  5. package/dist/index.d.ts +37 -2
  6. package/dist/index.js +523 -520
  7. package/dist/shared/components/CollectionBrowserView.js +2693 -2619
  8. package/dist/shared/components/DataTable.js +538 -495
  9. package/dist/shared/components/ItemEditForm.js +4559 -4386
  10. package/dist/shared/components/PageRenderer.js +537 -508
  11. package/dist/shared/components/ProfileView.js +716 -715
  12. package/dist/shared/components/QueryTable.js +74 -74
  13. package/dist/shared/components/RecordReadView.js +367 -364
  14. package/dist/shared/components/ReportView.js +64 -39
  15. package/dist/shared/components/WidgetSlot.js +543 -520
  16. package/dist/shared/components/alerts/AlertManagerView.js +324 -317
  17. package/dist/shared/components/alerts/types.js +37 -14
  18. package/dist/shared/components/cbv/row-focus.js +19 -0
  19. package/dist/shared/components/help-videos/HelpVideoPlayer.js +152 -147
  20. package/dist/shared/components/integrations/console/SignalCard.js +59 -59
  21. package/dist/shared/components/integrations/console/tone.js +52 -30
  22. package/dist/shared/components/item-edit/CatalogPickerField.js +525 -505
  23. package/dist/shared/components/item-edit/FieldRenderer.js +22 -20
  24. package/dist/shared/components/item-edit/FieldRow.js +175 -173
  25. package/dist/shared/components/item-edit/GridBulkEditDialog.js +55 -54
  26. package/dist/shared/components/item-edit/InlineTableField.js +2487 -2442
  27. package/dist/shared/components/item-edit/M2MCombobox.js +321 -295
  28. package/dist/shared/components/item-edit/MidairCollisionDialog.js +1 -1
  29. package/dist/shared/components/item-edit/PlanGrid.js +973 -894
  30. package/dist/shared/components/item-edit/QuickCreateButton.js +335 -106
  31. package/dist/shared/components/item-edit/RecordLiveSync.js +77 -75
  32. package/dist/shared/components/item-edit/RelationCombobox.js +452 -335
  33. package/dist/shared/components/item-edit/RelationGroupedCombobox.js +262 -141
  34. package/dist/shared/components/item-edit/SummaryPanel.js +385 -358
  35. package/dist/shared/components/item-edit/duplicate-rehearsal.js +47 -0
  36. package/dist/shared/components/item-edit/line-midair.js +82 -75
  37. package/dist/shared/components/item-edit/option-disambiguate.js +44 -32
  38. package/dist/shared/components/item-edit/related-missing.js +45 -0
  39. package/dist/shared/components/item-edit/save-outcome.js +9 -7
  40. package/dist/shared/components/notifications/NotificationRulesEditor.js +130 -123
  41. package/dist/shared/components/panels/AccessDeniedPanel.js +52 -48
  42. package/dist/shared/components/panels/ItemLockBanner.js +213 -211
  43. package/dist/shared/components/panels/PipelinePanel.js +1140 -1053
  44. package/dist/shared/components/panels/RecordIntegrityBanner.js +114 -86
  45. package/dist/shared/components/panels/RevisionsPanel.js +316 -299
  46. package/dist/shared/components/panels/TaskPanel.js +265 -249
  47. package/dist/shared/components/panels/landing-state.js +27 -0
  48. package/dist/shared/components/pipeline/PipelineEditorView.js +110 -92
  49. package/dist/shared/components/profile/AiMemoryCard.js +12 -10
  50. package/dist/shared/components/queue/OwnerAvatars.js +80 -41
  51. package/dist/shared/components/queue/QueueQuickFilters.js +52 -52
  52. package/dist/shared/components/queue/QueueWorklist.js +1050 -1026
  53. package/dist/shared/components/queue/group-sums.js +27 -0
  54. package/dist/shared/components/queue/live-state-aspect.js +9 -5
  55. package/dist/shared/components/widgets/ReviewListWidget.js +175 -154
  56. package/dist/shared/lib/back-closes.js +25 -0
  57. package/dist/shared/lib/display-prefs.js +60 -52
  58. package/dist/shared/lib/draft-store.js +71 -48
  59. package/dist/shared/lib/expression.js +53 -53
  60. package/dist/shared/lib/form-usage-beacon.js +7 -7
  61. package/dist/shared/lib/list-page-memory.js +63 -0
  62. package/dist/shared/lib/live.js +44 -44
  63. package/dist/shared/lib/money-input.js +45 -0
  64. package/dist/shared/lib/own-writes.js +76 -28
  65. package/dist/shared/lib/request-gate.js +110 -109
  66. package/dist/shared/lib/sanitize-html.js +10 -6
  67. package/dist/shared/lib/staged-row-labels.js +18 -0
  68. package/dist/shared/lib/validation-rules.js +34 -19
  69. package/package.json +1 -1
@@ -1,90 +1,98 @@
1
- import { useQuery as b } from "@tanstack/react-query";
2
- import { useEffect as f } from "react";
3
- import { useOptionalNivaroClient as h } from "../context.js";
4
- import { get as z } from "./commands.js";
5
- import { resolveAccentColor as g, parseThemeAccents as _ } from "./theme-accents.js";
6
- import { setDisplayTimezone as k, setTimeDisplay as S, setNumberFormat as N } from "./utils.js";
7
- function v(n) {
1
+ import { useQuery as g } from "@tanstack/react-query";
2
+ import { useEffect as a } from "react";
3
+ import { useOptionalNivaroClient as z } from "../context.js";
4
+ import { get as S } from "./commands.js";
5
+ import { resolveAccentColor as _, parseThemeAccents as h } from "./theme-accents.js";
6
+ import { setDisplayTimezone as k, setTimeDisplay as N, setNumberFormat as v } from "./utils.js";
7
+ function P(n) {
8
8
  return n === "small" ? "15px" : n === "large" ? "17.5px" : "";
9
9
  }
10
- function m(n, r = null, l = typeof document > "u" ? null : document.documentElement) {
10
+ function m(n, r = null, f = typeof document > "u" ? null : document.documentElement) {
11
11
  const e = n ?? {};
12
- k(typeof e.timezone == "string" && e.timezone ? e.timezone : r), S(e.time_display ?? null), N(e.number_format ?? null), l && (l.style.fontSize = v(e.font_size));
12
+ k(typeof e.timezone == "string" && e.timezone ? e.timezone : r), N(e.time_display ?? null), v(e.number_format ?? null), f && (f.style.fontSize = P(e.font_size));
13
13
  }
14
- function c(n) {
14
+ function i(n) {
15
15
  const r = /^#?([0-9a-f]{3}|[0-9a-f]{6})$/i.exec(n.trim());
16
16
  if (!r) return null;
17
- const l = r[1].length === 3 ? r[1].split("").map((t) => t + t).join("") : r[1], e = Number.parseInt(l, 16);
17
+ const f = r[1].length === 3 ? r[1].split("").map((t) => t + t).join("") : r[1], e = Number.parseInt(f, 16);
18
18
  return `${e >> 16 & 255} ${e >> 8 & 255} ${e & 255}`;
19
19
  }
20
- function y(n) {
21
- const r = c(n);
20
+ function p(n) {
21
+ const r = i(n);
22
22
  if (!r) return 0;
23
- const [l, e, t] = r.split(" ").map((i) => {
24
- const u = Number(i) / 255;
23
+ const [f, e, t] = r.split(" ").map((l) => {
24
+ const u = Number(l) / 255;
25
25
  return u <= 0.03928 ? u / 12.92 : ((u + 0.055) / 1.055) ** 2.4;
26
26
  });
27
- return 0.2126 * l + 0.7152 * e + 0.0722 * t;
27
+ return 0.2126 * f + 0.7152 * e + 0.0722 * t;
28
28
  }
29
- function a(n, r) {
30
- const [l, e] = [y(n), y(r)].sort((t, i) => i - t);
31
- return (l + 0.05) / (e + 0.05);
29
+ function c(n, r) {
30
+ const [f, e] = [p(n), p(r)].sort((t, l) => l - t);
31
+ return (f + 0.05) / (e + 0.05);
32
32
  }
33
- function P(n, r, l) {
34
- const e = (c(n) ?? "0 0 0").split(" ").map(Number), t = (c(r) ?? "0 0 0").split(" ").map(Number);
35
- return `#${e.map((i, u) => Math.round(i + (t[u] - i) * l)).map((i) => i.toString(16).padStart(2, "0")).join("")}`;
33
+ function d(n, r, f) {
34
+ const e = (i(n) ?? "0 0 0").split(" ").map(Number), t = (i(r) ?? "0 0 0").split(" ").map(Number);
35
+ return `#${e.map((l, u) => Math.round(l + (t[u] - l) * f)).map((l) => l.toString(16).padStart(2, "0")).join("")}`;
36
36
  }
37
- function x(n, r, l = 4.5) {
37
+ function D(n, r, f = 4.5) {
38
38
  let e = n;
39
- for (let t = 1; t <= 20 && a(e, r) < l; t++)
40
- e = P(n, "#ffffff", t * 0.05);
39
+ for (let t = 1; t <= 20 && c(e, r) < f; t++)
40
+ e = d(n, "#ffffff", t * 0.05);
41
41
  return e;
42
42
  }
43
- function D(n, r = "#080f1c") {
44
- return a(n, "#ffffff") >= a(n, r) ? "light" : "dark";
43
+ function E(n, r = "#ffffff", f = 4.5) {
44
+ if (!i(n)) return n;
45
+ let e = n;
46
+ for (let t = 1; t <= 20 && c(e, r) < f; t++)
47
+ e = d(n, "#000000", t * 0.05);
48
+ return e;
49
+ }
50
+ function F(n, r = "#080f1c") {
51
+ return c(n, "#ffffff") >= c(n, r) ? "light" : "dark";
45
52
  }
46
- function p(n, r, l = typeof document > "u" ? null : document.documentElement) {
47
- if (!l) return;
48
- const e = n ? c(n) : null;
53
+ function y(n, r, f = typeof document > "u" ? null : document.documentElement) {
54
+ if (!f) return;
55
+ const e = n ? i(n) : null;
49
56
  for (const t of r.hex ?? [])
50
- n && e ? l.style.setProperty(t, n) : l.style.removeProperty(t);
57
+ n && e ? f.style.setProperty(t, n) : f.style.removeProperty(t);
51
58
  for (const t of r.rgb ?? [])
52
- e ? l.style.setProperty(t, e) : l.style.removeProperty(t);
53
- n && e ? l.dataset.accentInk = D(n) : delete l.dataset.accentInk;
59
+ e ? f.style.setProperty(t, e) : f.style.removeProperty(t);
60
+ n && e ? f.dataset.accentInk = F(n) : delete f.dataset.accentInk;
54
61
  }
55
- function C(n, r = {}) {
56
- const l = h(), { data: e } = b({
62
+ function K(n, r = {}) {
63
+ const f = z(), { data: e } = g({
57
64
  queryKey: ["nvr-display-settings"],
58
- queryFn: () => l.request(
59
- z("/settings")
65
+ queryFn: () => f.request(
66
+ S("/settings")
60
67
  ).then((o) => o.data ?? {}),
61
- enabled: !!l && !!n,
68
+ enabled: !!f && !!n,
62
69
  staleTime: 5 * 6e4,
63
70
  retry: !1
64
- }), t = n ?? null, i = JSON.stringify([
71
+ }), t = n ?? null, l = JSON.stringify([
65
72
  (t == null ? void 0 : t.timezone) ?? null,
66
73
  (t == null ? void 0 : t.time_display) ?? null,
67
74
  (t == null ? void 0 : t.number_format) ?? null,
68
75
  (t == null ? void 0 : t.font_size) ?? null,
69
76
  (e == null ? void 0 : e.default_timezone) ?? null
70
77
  ]);
71
- f(() => {
78
+ a(() => {
72
79
  t && m(t, (e == null ? void 0 : e.default_timezone) ?? null);
73
- }, [i]), f(() => () => m(null), []);
74
- const u = t ? g(t.theme_accent, _(e == null ? void 0 : e.theme_accents)) : null, s = u && r.dark && r.darkSurface ? x(u, r.darkSurface) : u, d = JSON.stringify(r.accent ?? {});
75
- f(() => {
80
+ }, [l]), a(() => () => m(null), []);
81
+ const u = t ? _(t.theme_accent, h(e == null ? void 0 : e.theme_accents)) : null, s = u && r.dark && r.darkSurface ? D(u, r.darkSurface) : u, b = JSON.stringify(r.accent ?? {});
82
+ a(() => {
76
83
  if (!r.accent) return;
77
84
  const o = r.accent;
78
- return p(s, o), () => p(null, o);
79
- }, [s, d]);
85
+ return y(s, o), () => y(null, o);
86
+ }, [s, b]);
80
87
  }
81
88
  export {
82
- D as accentInk,
83
- p as applyAccentVars,
89
+ F as accentInk,
90
+ y as applyAccentVars,
84
91
  m as applyDisplayPrefs,
85
- a as contrastRatio,
86
- c as hexToRgbChannels,
87
- x as liftForDarkSurface,
88
- v as rootFontSize,
89
- C as useDisplayPreferences
92
+ c as contrastRatio,
93
+ E as deepenForLightSurface,
94
+ i as hexToRgbChannels,
95
+ D as liftForDarkSurface,
96
+ P as rootFontSize,
97
+ K as useDisplayPreferences
90
98
  };
@@ -1,68 +1,68 @@
1
- const f = "nivaro-drafts", l = "drafts";
1
+ const d = "nivaro-drafts", a = "drafts";
2
2
  function m(e) {
3
3
  if (e.item_id !== "new") return /* @__PURE__ */ new Set();
4
- const t = Object.keys(e.fields ?? {}), n = new Set((e.filled ?? []).filter((i) => t.includes(i)));
4
+ const t = Object.keys(e.fields ?? {}), n = new Set((e.filled ?? []).filter((r) => t.includes(r)));
5
5
  return n.size === t.length ? /* @__PURE__ */ new Set() : n;
6
6
  }
7
- function y(e) {
7
+ function b(e) {
8
8
  if (e == null) return null;
9
9
  const t = JSON.stringify(
10
10
  e,
11
- (i, r) => r && typeof r == "object" && !Array.isArray(r) ? Object.fromEntries(Object.entries(r).sort(([o], [s]) => o < s ? -1 : o > s ? 1 : 0)) : r
11
+ (r, i) => i && typeof i == "object" && !Array.isArray(i) ? Object.fromEntries(Object.entries(i).sort(([s], [o]) => s < o ? -1 : s > o ? 1 : 0)) : i
12
12
  );
13
13
  if (!t || t === "{}" || t === "[]") return null;
14
14
  let n = 5381;
15
- for (let i = 0; i < t.length; i++) n = (n << 5) + n + t.charCodeAt(i) | 0;
15
+ for (let r = 0; r < t.length; r++) n = (n << 5) + n + t.charCodeAt(r) | 0;
16
16
  return `p${(n >>> 0).toString(36)}:${t.length}`;
17
17
  }
18
- function S(e, t) {
18
+ function w(e, t) {
19
19
  return (e.prefill_sig ?? null) === t;
20
20
  }
21
- function b(e, t, n) {
21
+ function S(e, t, n) {
22
22
  return `${e}:${t && t !== "new" ? t : "new"}:${n || "anon"}`;
23
23
  }
24
- function d() {
24
+ function g() {
25
25
  return new Promise((e) => {
26
26
  try {
27
27
  if (typeof indexedDB > "u") return e(null);
28
- const t = indexedDB.open(f, 1);
28
+ const t = indexedDB.open(d, 1);
29
29
  t.onupgradeneeded = () => {
30
30
  const n = t.result;
31
- n.objectStoreNames.contains(l) || n.createObjectStore(l, { keyPath: "key" });
31
+ n.objectStoreNames.contains(a) || n.createObjectStore(a, { keyPath: "key" });
32
32
  }, t.onsuccess = () => e(t.result), t.onerror = () => e(null), t.onblocked = () => e(null);
33
33
  } catch {
34
34
  e(null);
35
35
  }
36
36
  });
37
37
  }
38
- async function c(e, t) {
39
- const n = await d();
40
- return n ? new Promise((i) => {
38
+ async function u(e, t) {
39
+ const n = await g();
40
+ return n ? new Promise((r) => {
41
41
  try {
42
- const r = n.transaction(l, e), o = t(r.objectStore(l));
43
- o.onsuccess = () => i(o.result), o.onerror = () => i(null), r.oncomplete = () => n.close(), r.onerror = () => {
44
- n.close(), i(null);
42
+ const i = n.transaction(a, e), s = t(i.objectStore(a));
43
+ s.onsuccess = () => r(s.result), s.onerror = () => r(null), i.oncomplete = () => n.close(), i.onerror = () => {
44
+ n.close(), r(null);
45
45
  };
46
46
  } catch {
47
- n.close(), i(null);
47
+ n.close(), r(null);
48
48
  }
49
49
  }) : null;
50
50
  }
51
- async function w(e) {
52
- return await c("readwrite", (n) => n.put(e)) != null;
51
+ async function O(e) {
52
+ return await u("readwrite", (n) => n.put(e)) != null;
53
53
  }
54
- async function _(e) {
55
- const t = await c("readonly", (n) => n.get(e));
54
+ async function h(e) {
55
+ const t = await u("readonly", (n) => n.get(e));
56
56
  return t && typeof t == "object" && t.key === e ? t : null;
57
57
  }
58
- async function O(e) {
59
- await c("readwrite", (t) => t.delete(e));
58
+ async function _(e) {
59
+ await u("readwrite", (t) => t.delete(e));
60
60
  }
61
- const a = "nvr:draft-created:", g = 7 * 864e5;
62
- function h(e, t, n = /* @__PURE__ */ new Date()) {
61
+ const l = "nvr:draft-created:", y = 7 * 864e5;
62
+ function p(e, t, n = /* @__PURE__ */ new Date()) {
63
63
  try {
64
64
  localStorage.setItem(
65
- a + e,
65
+ l + e,
66
66
  JSON.stringify({ id: t, at: n.toISOString() })
67
67
  );
68
68
  } catch {
@@ -70,23 +70,44 @@ function h(e, t, n = /* @__PURE__ */ new Date()) {
70
70
  }
71
71
  function k(e, t, n = /* @__PURE__ */ new Date()) {
72
72
  try {
73
- const i = localStorage.getItem(a + e);
74
- if (!i) return null;
75
- const r = JSON.parse(i);
76
- if (!r || typeof r.id != "string" || typeof r.at != "string") return null;
77
- const o = Date.parse(r.at);
78
- if (!Number.isFinite(o) || n.getTime() - o > g)
79
- return localStorage.removeItem(a + e), null;
80
- const s = t ? Date.parse(t) : Number.NaN;
81
- return !Number.isFinite(s) || s > o ? null : { id: r.id, at: r.at };
73
+ const r = localStorage.getItem(l + e);
74
+ if (!r) return null;
75
+ const i = JSON.parse(r);
76
+ if (!i || typeof i.id != "string" || typeof i.at != "string") return null;
77
+ const s = Date.parse(i.at);
78
+ if (!Number.isFinite(s) || n.getTime() - s > y)
79
+ return localStorage.removeItem(l + e), null;
80
+ const o = t ? Date.parse(t) : Number.NaN;
81
+ return !Number.isFinite(o) || o > s ? null : { id: i.id, at: i.at };
82
82
  } catch {
83
83
  return null;
84
84
  }
85
85
  }
86
- function p(e) {
86
+ async function D(e, t) {
87
+ const n = {};
88
+ for (const [r, i] of Object.entries(e ?? {})) {
89
+ const s = r.includes(".") ? r.slice(0, r.indexOf(".")) : r;
90
+ for (const o of Object.keys(i ?? {})) {
91
+ if (!o || o === "new" || o.startsWith("pending:")) continue;
92
+ let c;
93
+ try {
94
+ c = await t(s, o);
95
+ } catch {
96
+ c = null;
97
+ }
98
+ typeof c == "number" && Number.isFinite(c) && c > 0 && (n[`${s}:${o}`] = c);
99
+ }
100
+ }
101
+ return n;
102
+ }
103
+ function j(e) {
104
+ const { isDirty: t, forReload: n, staged: r, stagedLines: i } = e;
105
+ return t ? "store" : n && r > 0 ? "hold" : i > 0 ? "store" : "drop";
106
+ }
107
+ function N(e) {
87
108
  return Object.keys(e.fields ?? {}).length > 0 || Object.values(e.pending_rows ?? {}).some((t) => t.length > 0) || Object.values(e.pending_edits ?? {}).some((t) => Object.keys(t).length > 0) || Object.values(e.pending_deletes ?? {}).some((t) => t.length > 0) || Object.values(e.m2m_links ?? {}).some((t) => t.length > 0) || Object.values(e.m2m_unlinks ?? {}).some((t) => t.length > 0);
88
109
  }
89
- function u(e) {
110
+ function f(e) {
90
111
  return JSON.stringify([
91
112
  e.fields ?? {},
92
113
  e.pending_rows ?? {},
@@ -96,19 +117,21 @@ function u(e) {
96
117
  e.m2m_unlinks ?? {}
97
118
  ]);
98
119
  }
99
- function j(e, t) {
100
- return !(t != null && t.saved_at) || t.key !== e.key ? e : u(t) === u(e) ? { ...e, saved_at: t.saved_at } : e;
120
+ function E(e, t) {
121
+ return !(t != null && t.saved_at) || t.key !== e.key ? e : f(t) === f(e) ? { ...e, saved_at: t.saved_at } : e;
101
122
  }
102
123
  export {
103
- O as deleteDraft,
124
+ _ as deleteDraft,
104
125
  k as draftCreatedAs,
105
126
  m as draftFilledBack,
106
- p as draftHasContent,
107
- b as draftKey,
108
- S as draftMatchesPrefill,
109
- j as keepDraftSavedAt,
110
- _ as loadDraft,
111
- h as markDraftCreated,
112
- y as prefillSignature,
113
- w as saveDraft
127
+ N as draftHasContent,
128
+ S as draftKey,
129
+ w as draftMatchesPrefill,
130
+ j as draftPersistDecision,
131
+ E as keepDraftSavedAt,
132
+ D as lineBasesForDraft,
133
+ h as loadDraft,
134
+ p as markDraftCreated,
135
+ b as prefillSignature,
136
+ O as saveDraft
114
137
  };
@@ -1,6 +1,6 @@
1
1
  import { fiscalYearOf as N, fiscalQuarterOf as $ } from "./fiscal.js";
2
2
  const v = /^[A-Za-z_$][\w$]*(?:\.[A-Za-z_$][\w$]*|\[\d+\])*/;
3
- class h extends Error {
3
+ class g extends Error {
4
4
  constructor(i, n) {
5
5
  super(i), this.at = n;
6
6
  }
@@ -17,29 +17,29 @@ function D(e) {
17
17
  }
18
18
  if (o === "{" && e[n + 1] === "{") {
19
19
  const s = e.indexOf("}}", n + 2);
20
- if (s === -1) throw new h("Unclosed {{", n);
20
+ if (s === -1) throw new g("Unclosed {{", n);
21
21
  const a = e.slice(n + 2, s).trim();
22
- if (!a) throw new h("Empty {{ }}", n);
22
+ if (!a) throw new g("Empty {{ }}", n);
23
23
  const p = v.exec(a);
24
- if (!p || p[0] !== a) throw new h(`Invalid field path: ${a}`, n + 2);
24
+ if (!p || p[0] !== a) throw new g(`Invalid field path: ${a}`, n + 2);
25
25
  i.push({ t: "tok", v: a, at: n }), n = s + 2;
26
26
  continue;
27
27
  }
28
28
  if (o === "'" || o === '"') {
29
29
  const s = e.indexOf(o, n + 1);
30
- if (s === -1) throw new h("Unclosed string", n);
30
+ if (s === -1) throw new g("Unclosed string", n);
31
31
  i.push({ t: "str", v: e.slice(n + 1, s), at: n }), n = s + 1;
32
32
  continue;
33
33
  }
34
34
  if (o >= "0" && o <= "9") {
35
35
  const s = /^\d+(\.\d+)?/.exec(e.slice(n));
36
- if (!s) throw new h("Bad number", n);
36
+ if (!s) throw new g("Bad number", n);
37
37
  i.push({ t: "num", v: Number(s[0]), at: n }), n += s[0].length;
38
38
  continue;
39
39
  }
40
40
  if (/[A-Za-z_$]/.test(o)) {
41
41
  const s = v.exec(e.slice(n));
42
- if (!s) throw new h("Bad identifier", n);
42
+ if (!s) throw new g("Bad identifier", n);
43
43
  i.push({ t: "word", v: s[0], at: n }), n += s[0].length;
44
44
  continue;
45
45
  }
@@ -52,7 +52,7 @@ function D(e) {
52
52
  i.push({ t: "op", v: o, at: n }), n++;
53
53
  continue;
54
54
  }
55
- throw o === "=" ? new h("Use == for comparison", n) : new h(`Unexpected character: ${o}`, n);
55
+ throw o === "=" ? new g("Use == for comparison", n) : new g(`Unexpected character: ${o}`, n);
56
56
  }
57
57
  return i.push({ t: "end", at: e.length }), i;
58
58
  }
@@ -75,7 +75,7 @@ function b(e) {
75
75
  try {
76
76
  i = D(e);
77
77
  } catch (t) {
78
- return t instanceof h ? { ok: !1, error: t.message, position: t.at } : { ok: !1, error: "Could not read the expression", position: 0 };
78
+ return t instanceof g ? { ok: !1, error: t.message, position: t.at } : { ok: !1, error: "Could not read the expression", position: 0 };
79
79
  }
80
80
  let n = 0;
81
81
  const o = () => i[n], l = [];
@@ -89,11 +89,11 @@ function b(e) {
89
89
  for (; ; ) {
90
90
  const u = o();
91
91
  if (u.t !== "op") break;
92
- const f = T[u.v];
93
- if (f === void 0 || f < t) break;
92
+ const c = T[u.v];
93
+ if (c === void 0 || c < t) break;
94
94
  n++;
95
- const c = a(f + 1);
96
- r = { kind: "binary", op: u.v, left: r, right: c };
95
+ const f = a(c + 1);
96
+ r = { kind: "binary", op: u.v, left: r, right: f };
97
97
  }
98
98
  return r;
99
99
  }
@@ -113,20 +113,20 @@ function b(e) {
113
113
  const r = i[n + 1];
114
114
  if (r && r.t === "op" && r.v === "(") {
115
115
  n += 2;
116
- const f = [];
116
+ const c = [];
117
117
  if (!(o().t === "op" && o().v === ")"))
118
118
  for (; ; ) {
119
- f.push(a(0));
120
- const m = o();
121
- if (m.t === "op" && m.v === ",") {
119
+ c.push(a(0));
120
+ const h = o();
121
+ if (h.t === "op" && h.v === ",") {
122
122
  n++;
123
123
  continue;
124
124
  }
125
125
  break;
126
126
  }
127
- const c = o();
128
- if (c.t !== "op" || c.v !== ")") throw new s("Expected )", c.at);
129
- return n++, { kind: "call", name: t.v, args: f };
127
+ const f = o();
128
+ if (f.t !== "op" || f.v !== ")") throw new s("Expected )", f.at);
129
+ return n++, { kind: "call", name: t.v, args: c };
130
130
  }
131
131
  if (n++, t.v === "true" || t.v === "false")
132
132
  return { kind: "boolean", value: t.v === "true" };
@@ -207,7 +207,7 @@ function C(e, i, n = {}) {
207
207
  const r = i(t.path);
208
208
  if (_(r)) {
209
209
  if (/^[A-Z][A-Z0-9_]*$/.test(t.path)) {
210
- const u = M(t.path);
210
+ const u = U(t.path);
211
211
  if (u !== null) return u;
212
212
  }
213
213
  return null;
@@ -217,8 +217,8 @@ function C(e, i, n = {}) {
217
217
  case "call": {
218
218
  const r = t.name.toLowerCase();
219
219
  if (r === "networkdays" && t.args.length >= 2) {
220
- const u = y(s(t.args[0])), f = y(s(t.args[1]));
221
- return !u || !f ? null : U(u, f);
220
+ const u = y(s(t.args[0])), c = y(s(t.args[1]));
221
+ return !u || !c ? null : M(u, c);
222
222
  }
223
223
  if (r === "abs" && t.args.length === 1) {
224
224
  const u = l(t.args[0]);
@@ -233,8 +233,8 @@ function C(e, i, n = {}) {
233
233
  if (u === null) return null;
234
234
  if (r === "floor") return Math.floor(u);
235
235
  if (r === "ceil") return Math.ceil(u);
236
- const c = 10 ** (t.args[1] ? l(t.args[1]) ?? 0 : 0);
237
- return Math.round(u * c) / c;
236
+ const f = 10 ** (t.args[1] ? l(t.args[1]) ?? 0 : 0), h = Number((u * f).toPrecision(15));
237
+ return Math.sign(h) * Math.round(Math.abs(h)) / f;
238
238
  }
239
239
  return null;
240
240
  }
@@ -255,40 +255,40 @@ function C(e, i, n = {}) {
255
255
  if (r === "&&") return a(s(t.left)) ? a(s(t.right)) : !1;
256
256
  if (r === "||") return a(s(t.left)) ? !0 : a(s(t.right));
257
257
  if (r === "==" || r === "!=") {
258
- const c = s(t.left), m = s(t.right), g = d(c, m);
259
- return r === "==" ? g : !g;
258
+ const f = s(t.left), h = s(t.right), m = d(f, h);
259
+ return r === "==" ? m : !m;
260
260
  }
261
261
  if (r === "<" || r === "<=" || r === ">" || r === ">=") {
262
- const c = s(t.left), m = s(t.right), g = k(c), w = k(m);
263
- if (g === null || w === null) return !1;
262
+ const f = s(t.left), h = s(t.right), m = k(f), w = k(h);
263
+ if (m === null || w === null) return !1;
264
264
  switch (r) {
265
265
  case "<":
266
- return g < w;
266
+ return m < w;
267
267
  case "<=":
268
- return g <= w;
268
+ return m <= w;
269
269
  case ">":
270
- return g > w;
270
+ return m > w;
271
271
  default:
272
- return g >= w;
272
+ return m >= w;
273
273
  }
274
274
  }
275
- const u = l(t.left), f = l(t.right);
276
- if (u === null || f === null) return null;
275
+ const u = l(t.left), c = l(t.right);
276
+ if (u === null || c === null) return null;
277
277
  switch (r) {
278
278
  case "+":
279
- return u + f;
279
+ return u + c;
280
280
  case "-":
281
- return u - f;
281
+ return u - c;
282
282
  case "*":
283
- return u * f;
283
+ return u * c;
284
284
  default:
285
- return f === 0 ? null : u / f;
285
+ return c === 0 ? null : u / c;
286
286
  }
287
287
  }
288
288
  function d(t, r) {
289
289
  if (t === null || r === null) return t === r;
290
- const u = k(t), f = k(r);
291
- return u !== null && f !== null ? u === f : String(t) === String(r);
290
+ const u = k(t), c = k(r);
291
+ return u !== null && c !== null ? u === c : String(t) === String(r);
292
292
  }
293
293
  return s(e);
294
294
  }
@@ -298,15 +298,15 @@ function x(e, i, n = {}) {
298
298
  const l = typeof i == "function" ? i : (s) => A(i, s);
299
299
  return C(o.ast, l, n);
300
300
  }
301
- function B(e, i, n = {}) {
301
+ function z(e, i, n = {}) {
302
302
  const o = x(e, i, n);
303
303
  return typeof o == "number" ? Number.isFinite(o) ? o : null : typeof o == "boolean" ? o ? 1 : 0 : null;
304
304
  }
305
- function F(e, i, n = {}) {
305
+ function B(e, i, n = {}) {
306
306
  const o = x(e, i, n);
307
307
  return o === null ? !1 : typeof o == "boolean" ? o : typeof o == "number" ? o !== 0 : o !== "";
308
308
  }
309
- function O(e, i) {
309
+ function F(e, i) {
310
310
  if (!e.trim())
311
311
  return { ok: !1, error: "Expression is empty", position: 0, tokens: [], unknownTokens: [] };
312
312
  const n = b(e);
@@ -323,7 +323,7 @@ function O(e, i) {
323
323
  ) : [];
324
324
  return { ok: !0, tokens: n.tokens, unknownTokens: o };
325
325
  }
326
- function P(e) {
326
+ function O(e) {
327
327
  const i = b(e);
328
328
  return i.ok ? i.tokens : [];
329
329
  }
@@ -332,7 +332,7 @@ function y(e) {
332
332
  const i = e.length === 10 ? /* @__PURE__ */ new Date(`${e}T00:00:00`) : new Date(e);
333
333
  return Number.isNaN(i.getTime()) ? null : i;
334
334
  }
335
- function U(e, i) {
335
+ function M(e, i) {
336
336
  const n = i.getTime() >= e.getTime() ? 1 : -1;
337
337
  let [o, l] = n === 1 ? [e, i] : [i, e];
338
338
  o = new Date(o.getFullYear(), o.getMonth(), o.getDate()), l = new Date(l.getFullYear(), l.getMonth(), l.getDate());
@@ -348,20 +348,20 @@ let E = {};
348
348
  function Z(e) {
349
349
  E = e && typeof e == "object" ? e : {};
350
350
  }
351
- function M(e) {
351
+ function U(e) {
352
352
  const i = E[e];
353
353
  return Number.isFinite(i) ? i : null;
354
354
  }
355
355
  export {
356
356
  C as evaluateAst,
357
- F as evaluateBoolean,
357
+ B as evaluateBoolean,
358
358
  x as evaluateExpression,
359
- B as evaluateNumeric,
360
- P as extractExpressionTokens,
361
- M as formulaConstant,
362
- U as networkdaysBetween,
359
+ z as evaluateNumeric,
360
+ O as extractExpressionTokens,
361
+ U as formulaConstant,
362
+ M as networkdaysBetween,
363
363
  b as parseExpression,
364
364
  A as readPath,
365
365
  Z as setFormulaConstants,
366
- O as validateExpression
366
+ F as validateExpression
367
367
  };
@@ -4,7 +4,7 @@ var o = (t, e, n) => g(t, typeof e != "symbol" ? e + "" : e, n);
4
4
  const l = [];
5
5
  let h = null, c = null, p = !1;
6
6
  const v = 20, m = 15e3;
7
- function a() {
7
+ function d() {
8
8
  if (c && (clearTimeout(c), c = null), !h || l.length === 0) return;
9
9
  const { apiBase: t, authHeaders: e, credentials: n } = h;
10
10
  for (; l.length; ) {
@@ -24,12 +24,12 @@ function a() {
24
24
  }
25
25
  }
26
26
  function y() {
27
- p || typeof window > "u" || (p = !0, window.addEventListener("pagehide", a), document.addEventListener("visibilitychange", () => {
28
- document.visibilityState === "hidden" && a();
27
+ p || typeof window > "u" || (p = !0, window.addEventListener("pagehide", d), document.addEventListener("visibilitychange", () => {
28
+ document.visibilityState === "hidden" && d();
29
29
  }));
30
30
  }
31
31
  function O(t, e) {
32
- h = e, l.push(t), y(), l.length >= v ? a() : c || (c = setTimeout(a, m));
32
+ h = e, l.push(t), y(), l.length >= v ? d() : c || (c = setTimeout(d, m));
33
33
  }
34
34
  class _ {
35
35
  constructor(e, n, i = !0) {
@@ -78,8 +78,8 @@ class A {
78
78
  this.tries++;
79
79
  for (const s of i.slice(0, 60)) {
80
80
  this.fields[s] || (this.fields[s] = { required: 0, invalid: 0 });
81
- const d = this.fields[s], u = e[s] ?? "";
82
- n === "required" || n == null && (u === "This field is required" || /^At least one .+ is required$/.test(u)) ? d.required++ : d.invalid++;
81
+ const u = this.fields[s], a = e[s] ?? "";
82
+ n === "required" || n == null && (a === "This field is required" || a === "Add at least one line" || /^At least one .+ is required$/.test(a)) ? u.required++ : u.invalid++;
83
83
  }
84
84
  }
85
85
  }
@@ -161,7 +161,7 @@ export {
161
161
  A as RefusalTally,
162
162
  N as SectionTally,
163
163
  _ as StepClock,
164
- a as flushFormUsage,
164
+ d as flushFormUsage,
165
165
  B as onSectionUse,
166
166
  O as queueFormUsage,
167
167
  j as reportSectionUse,