@tesouro/embedded-components-react 0.9.22 → 0.9.25

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 (98) hide show
  1. package/dist/index.css +82 -55
  2. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index.js +7 -7
  3. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index10.js +14 -8
  4. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index11.js +59 -7
  5. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index12.js +10 -65
  6. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index13.js +9 -10
  7. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index14.js +7 -8
  8. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index15.js +9 -7
  9. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index16.js +29 -11
  10. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index17.js +24 -24
  11. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index18.js +14 -22
  12. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index19.js +155 -14
  13. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index20.js +13 -157
  14. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index21.js +18 -12
  15. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index22.js +32 -15
  16. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index23.js +99 -39
  17. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index24.js +69 -85
  18. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index25.js +3 -85
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index26.js +57 -4
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index27.js +114 -57
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index28.js +190 -111
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index29.js +75 -187
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index3.js +35 -15
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index30.js +67 -75
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index31.js +111 -69
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index32.js +461 -108
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index33.js +102 -452
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index34.js +12 -116
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index35.js +85 -12
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index36.js +67 -73
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index37.js +231 -73
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index38.js +38 -232
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index39.js +245 -38
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index4.js +169 -38
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index40.js +21 -252
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index41.js +534 -23
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index42.js +4 -542
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index43.js +43 -4
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index44.js +236 -39
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index45.js +3 -240
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index46.js +6 -3
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index47.js +63 -4
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index48.js +1 -65
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index5.js +82 -225
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index6.js +45 -83
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index7.js +4 -47
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index8.js +13 -4
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index9.js +8 -13
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index14.js +1 -1
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index15.js +1 -1
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index31.js +1 -1
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index33.js +1 -1
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index34.js +2 -2
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index36.js +5 -5
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index37.js +138 -155
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index48.js +1 -1
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index49.js +1 -1
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index5.js +1 -1
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-upload/ui/dist/index3.js +2 -2
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index16.js +48 -43
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index17.js +219 -207
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index4.js +13 -13
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index6.js +5 -4
  64. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index7.js +6 -6
  65. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index18.js +1 -5
  66. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index2.js +1 -1
  67. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index20.js +278 -322
  68. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index3.js +1 -1
  69. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidget/BillPayWidget.js +1 -1
  70. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidget/BillsTab.js +1 -1
  71. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/mocks/labels.js +1 -1
  72. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/pay-bill/ui/dist/index5.js +1 -1
  73. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/pay-bill/ui/dist/index6.js +1 -1
  74. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +18 -16
  75. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index10.js +2 -41
  76. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index11.js +4 -2
  77. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index12.js +39 -9
  78. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index13.js +2 -78
  79. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index14.js +11 -0
  80. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index15.js +78 -2
  81. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index17.js +2 -4
  82. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index18.js +25 -26
  83. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index19.js +4 -2
  84. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index20.js +28 -5
  85. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index21.js +2 -34
  86. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index22.js +7 -2
  87. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index23.js +34 -0
  88. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index24.js +2 -0
  89. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index6.js +31 -15
  90. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index7.js +1 -54
  91. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index8.js +18 -2
  92. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index9.js +52 -2
  93. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  94. package/dist/libs/tesouro-embedded-components-react/shared/util/dist/lib/theme/themeTokens.js +1 -1
  95. package/dist/packages/shared-ui-shadcn/dist/index.js +4696 -4681
  96. package/package.json +1 -1
  97. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index49.js +0 -1
  98. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index16.js +0 -29
@@ -1,47 +1,254 @@
1
- import { resolveLineItemAmountMinorUnits as e } from "../../../util/dist/lib/resolveLineItemAmount.js";
2
- import { resolveLineItemQuantity as t } from "../../../util/dist/lib/resolveLineItemQuantity.js";
3
- import "../../../util/dist/index.js";
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { BILL_CREATE_MESSAGE_LABELS_EN as e } from "./index28.js";
6
+ import { calculateTotal as t, displayLineAmount as n, normalizeMoneyOnBlur as r, parseMoneyToMinorUnits as i, parseQuantity as a } from "./index35.js";
7
+ import { validateBillTotals as o } from "./index36.js";
8
+ import { emptyLineItem as s, mapPayableToBillForm as c } from "./index38.js";
9
+ import { useCallback as l, useEffect as u, useMemo as d, useRef as f, useState as p } from "react";
4
10
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index39.js
5
- function n() {
6
- return {
7
- id: crypto.randomUUID(),
8
- description: "",
9
- glCode: "",
10
- quantity: "1",
11
- price: "",
12
- amount: ""
13
- };
11
+ var m = /^[0-9.,-]+$/;
12
+ function h(e) {
13
+ let t = e.trim().replace(/^\$\s*/, "");
14
+ return t ? m.test(t) ? t : null : "";
14
15
  }
15
- function r(e) {
16
- return typeof e == "number" ? (e / 100).toFixed(2) : "";
16
+ var g = [
17
+ "quantity",
18
+ "price",
19
+ "amount"
20
+ ];
21
+ function _(e) {
22
+ let t = e.trim(), n = /[.,]$/.test(t) ? t.slice(0, -1) : t;
23
+ return t && !n ? null : n;
17
24
  }
18
- function i(e) {
19
- return typeof e == "string" ? e : "";
25
+ function v(e, t, n) {
26
+ if (t === void 0) return;
27
+ let r = _(t);
28
+ if (r !== null) return o(e === "discount" ? r : "", e === "tax" ? r : "", e === "total" ? r : void 0, n)?.[e];
29
+ }
30
+ function y(e, t) {
31
+ let n = {}, r = {
32
+ price: null,
33
+ amount: null
34
+ };
35
+ for (let a of ["price", "amount"]) {
36
+ let o = _(e[a]);
37
+ o !== null && (r[a] = i(o), o && r[a] === null && (n[a] = t.unreadableMoney));
38
+ }
39
+ let o = _(e.quantity);
40
+ if (o !== null) {
41
+ let e = r.price !== null || r.amount !== null;
42
+ a(o) === null && (o || e) && (n.quantity = t.unusableQuantity);
43
+ }
44
+ return n;
20
45
  }
21
- function a(e) {
22
- return e.total_amount ?? e.amount_due ?? void 0;
46
+ function b(e, t, r) {
47
+ return i(t) === null ? r : n(e, t);
23
48
  }
24
- function o({ payable: o, lineItems: s }) {
25
- let c = {
26
- invoiceNumber: o.document_id ?? "",
27
- invoiceDate: o.issued_at ?? "",
28
- dueDate: o.due_date ?? "",
29
- poNumber: i(o.purchase_order_number)
30
- }, l = s.map((n) => ({
31
- id: n.id,
32
- description: n.name ?? "",
33
- glCode: n.ledger_account_id ?? "",
34
- quantity: String(t(n)),
35
- price: r(n.unit_price),
36
- amount: r(e(n))
37
- })), u = a(o);
49
+ function x({ payable: n, lineItems: i, labels: a = e } = {}) {
50
+ let o = d(() => c({
51
+ payable: n ?? {},
52
+ lineItems: i ?? []
53
+ }), [n, i]), [m, _] = p(o.values), [x, S] = p(o.lineItems), [C, w] = p(o.discount), [T, E] = p(o.tax), [D, O] = p(o.total || void 0), [ee, k] = p(), A = f(void 0), te = l((e) => {
54
+ k((t) => {
55
+ let n = typeof e == "function" ? e(t) : e;
56
+ return n?.form !== A.current && (A.current = void 0), n;
57
+ });
58
+ }, []), ne = l((e) => {
59
+ A.current = e, k((t) => ({
60
+ ...t,
61
+ form: e
62
+ }));
63
+ }, []), j = l(() => {
64
+ k((e) => {
65
+ if (!e?.form || e.form !== A.current) return e;
66
+ A.current = void 0;
67
+ let t = { ...e };
68
+ return delete t.form, Object.keys(t).length ? t : void 0;
69
+ });
70
+ }, []), [re, M] = p(), [N, P] = p(), [F, I] = p(!1), [L, R] = p(!1), [z, B] = p(!1);
71
+ u(() => {
72
+ F || _(o.values);
73
+ }, [o]), u(() => {
74
+ L || S(o.lineItems);
75
+ }, [o]), u(() => {
76
+ z || (w(o.discount), E(o.tax), O(o.total || void 0));
77
+ }, [o]);
78
+ let ie = l((e) => {
79
+ _((t) => ({
80
+ ...t,
81
+ ...e
82
+ })), I(!0), k((t) => {
83
+ if (!t) return t;
84
+ let n = { ...t };
85
+ for (let t of Object.keys(e)) delete n[t];
86
+ return Object.keys(n).length ? n : void 0;
87
+ }), j();
88
+ }, [j]), V = l((e, t) => {
89
+ M((n) => {
90
+ if (!n?.[e] && !t) return n;
91
+ let r = {
92
+ ...n,
93
+ [e]: t
94
+ };
95
+ return t || delete r[e], Object.keys(r).length ? r : void 0;
96
+ });
97
+ }, []), H = l((e, t) => {
98
+ V(e, v(e, t, a));
99
+ }, [a, V]), U = l(() => {
100
+ O(void 0), H("total", void 0), j();
101
+ }, [H, j]), W = l((e, t = []) => {
102
+ let n = y(e, a);
103
+ P((r) => {
104
+ let i = r?.[e.id], a = { ...i };
105
+ for (let e of [
106
+ "price",
107
+ "amount",
108
+ "quantity"
109
+ ]) n[e] ? a[e] = n[e] : delete a[e];
110
+ t.includes("description") && delete a.description;
111
+ let o = Object.keys(a).length > 0;
112
+ if (!i && !o) return r;
113
+ let s = { ...r };
114
+ return o ? s[e.id] = a : delete s[e.id], Object.keys(s).length ? s : void 0;
115
+ });
116
+ }, [a]), G = l((e, t, n) => {
117
+ P((r) => ({
118
+ ...r,
119
+ [e]: {
120
+ ...r?.[e],
121
+ [t]: n
122
+ }
123
+ }));
124
+ }, []), K = l((e, t, n = []) => {
125
+ let r = x.find((t) => t.id === e);
126
+ if (!r) return;
127
+ let i = t(r);
128
+ S(x.map((t) => t.id === e ? i : t)), W(i, n), R(!0), U();
129
+ }, [
130
+ U,
131
+ x,
132
+ W
133
+ ]), q = l((e, t) => {
134
+ let n = { ...t };
135
+ for (let r of g) {
136
+ let i = t[r];
137
+ if (i === void 0) continue;
138
+ let o = h(i);
139
+ if (o === null) {
140
+ G(e, r, a.numbersOnly);
141
+ return;
142
+ }
143
+ n[r] = o;
144
+ }
145
+ K(e, (e) => {
146
+ let t = {
147
+ ...e,
148
+ ...n
149
+ };
150
+ return "amount" in n ? t : {
151
+ ...t,
152
+ amount: b(t.quantity, t.price, t.amount)
153
+ };
154
+ }, Object.keys(n));
155
+ }, [
156
+ K,
157
+ a,
158
+ G
159
+ ]), J = l((e, t) => {
160
+ S((n) => n.map((n) => n.id === e ? {
161
+ ...n,
162
+ [t]: r(n[t])
163
+ } : n));
164
+ }, []), Y = l((e, t) => {
165
+ K(e, (e) => {
166
+ let n = Number.parseFloat(e.quantity), r = String(Math.max(1, (Number.isFinite(n) ? n : 0) + t));
167
+ return {
168
+ ...e,
169
+ quantity: r,
170
+ amount: b(r, e.price, e.amount)
171
+ };
172
+ });
173
+ }, [K]), X = l((e) => {
174
+ P((t) => {
175
+ if (!t?.[e]) return t;
176
+ let n = { ...t };
177
+ return delete n[e], Object.keys(n).length ? n : void 0;
178
+ });
179
+ }, []), Z = l((e) => {
180
+ X(e), S((t) => t.length <= 1 ? t : t.filter((t) => t.id !== e)), R(!0), U();
181
+ }, [X, U]), ae = l(() => {
182
+ S((e) => [...e, s()]), R(!0), U();
183
+ }, [U]), Q = l((e, t, n) => {
184
+ let r = h(t);
185
+ if (r === null) {
186
+ V(e, a.numbersOnly);
187
+ return;
188
+ }
189
+ n(r), B(!0), U(), H(e, r);
190
+ }, [
191
+ U,
192
+ a,
193
+ H,
194
+ V
195
+ ]), oe = l((e) => Q("discount", e, w), [Q]), se = l((e) => Q("tax", e, E), [Q]), $ = l(() => w((e) => r(e)), []), ce = l(() => E((e) => r(e)), []), le = l((e) => {
196
+ let t = h(e);
197
+ if (t === null) {
198
+ V("total", a.numbersOnly);
199
+ return;
200
+ }
201
+ O(t), B(!0), H("total", t), j();
202
+ }, [
203
+ j,
204
+ a,
205
+ H,
206
+ V
207
+ ]), ue = l(() => {
208
+ O((e) => e === void 0 ? e : r(e));
209
+ }, []), de = d(() => x.map((e) => ({
210
+ ...e,
211
+ onChange: (t) => q(e.id, t),
212
+ onBlur: (t) => J(e.id, t),
213
+ onQuantityStep: (t) => Y(e.id, t),
214
+ onRemove: () => Z(e.id)
215
+ })), [
216
+ J,
217
+ x,
218
+ q,
219
+ Z,
220
+ Y
221
+ ]), fe = d(() => t(x, T, C), [
222
+ x,
223
+ T,
224
+ C
225
+ ]);
38
226
  return {
39
- values: c,
40
- lineItems: l.length ? l : [n()],
41
- discount: r(o.discount),
42
- tax: r(o.tax_amount),
43
- total: u ? r(u) : ""
227
+ values: m,
228
+ errors: ee,
229
+ setErrors: te,
230
+ setSaveFailureMessage: ne,
231
+ lineItemErrors: N,
232
+ setLineItemErrors: P,
233
+ totalsErrors: re,
234
+ setTotalsErrors: M,
235
+ onChange: ie,
236
+ lineItems: x,
237
+ lineItemRows: de,
238
+ discount: C,
239
+ onDiscountChange: oe,
240
+ onDiscountBlur: $,
241
+ tax: T,
242
+ onTaxChange: se,
243
+ onTaxBlur: ce,
244
+ total: D ?? fe,
245
+ totalOverride: D,
246
+ onTotalChange: le,
247
+ onTotalBlur: ue,
248
+ onAddLineItem: ae,
249
+ isTotalsDirty: z,
250
+ isDirty: F || L || z
44
251
  };
45
252
  }
46
253
  //#endregion
47
- export { n as emptyLineItem, o as mapPayableToBillForm };
254
+ export { x as useBillForm };
@@ -1,40 +1,171 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { toast as e } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import { formatCalendarDate as t } from "../../../../shared/util/dist/lib/formatCalendarDate.js";
7
+ import { formatMoneyExact as n } from "../../../../shared/util/dist/lib/formatMoneyExact.js";
8
+ import "../../../../shared/util/dist/index.js";
9
+ import "../../../../shared/ui/dist/index.js";
10
+ import { DuplicateVerdict as r } from "../../../util/dist/lib/duplicateVerdict.js";
11
+ import { suspectedPayableDuplicates as i } from "../../../util/dist/lib/payableDuplicates.js";
12
+ import { duplicateVerdictMatches as a, groupSuspectedDuplicates as o } from "../../../util/dist/lib/groupDuplicates.js";
13
+ import { isEditablePayableStatus as s } from "../../../util/dist/lib/isEditablePayableStatus.js";
14
+ import { payableRemoval as c } from "../../../util/dist/lib/payableRemoval.js";
15
+ import { resolveVendorName as l } from "../../../util/dist/lib/resolveVendor.js";
16
+ import "../../../util/dist/index.js";
17
+ import { derivePayableStatus as u } from "../../../../shared/document-status/util/dist/lib/derivePayableStatus.js";
18
+ import { useApplyDuplicateVerdictsMutation as d } from "../../../data-access/dist/lib/useApplyDuplicateVerdictsMutation.js";
19
+ import "../../../data-access/dist/index.js";
20
+ import { usePayablesByIdsQueries as f } from "../../data-access/dist/index22.js";
21
+ import "../../data-access/dist/index.js";
22
+ import { DUPLICATE_BILLS_LABELS_EN as p } from "./index3.js";
23
+ import { useCallback as m, useMemo as h, useState as g } from "react";
24
+ import { FileCheckIcon as _ } from "lucide-react";
1
25
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index4.js
2
- var e = {
3
- selectRow: ({ vendorLabel: e, invoiceNumberLabel: t, addedOnLabel: n }) => `Select bill — ${e}, invoice ${t}, added ${n}`,
4
- openRow: ({ vendorLabel: e, invoiceNumberLabel: t, addedOnLabel: n }) => `View bill — ${e}, invoice ${t}, added ${n}`,
5
- reviewGroup: ({ vendorLabel: e, count: t }) => `${e} — ${t} possible duplicate bills`,
6
- selectGroup: ({ vendorLabel: e }) => `Select every bill from ${e}`,
7
- deleteBillButton: "Remove this bill",
8
- deleteConfirmTitle: "Remove duplicate bill?",
9
- deleteConfirmDescription: "You can't undo this action.",
10
- deleteConfirmButton: "Remove duplicate bill",
11
- deleteConfirmBackButton: "Cancel",
12
- cancelBillButton: "Cancel this bill",
13
- confirmBillButton: "Confirm duplicate",
14
- cancelConfirmTitle: "Cancel duplicate bill?",
15
- cancelConfirmDescription: "You can't undo this action.",
16
- cancelConfirmButton: "Cancel this bill",
17
- cancelConfirmBackButton: "Back",
18
- confirmDuplicateTitle: "Confirm duplicate?",
19
- confirmDuplicateDescription: "This bill is already cancelled. This records it as a duplicate.",
20
- notDuplicateAction: "Not a duplicate",
21
- notDuplicateConfirmTitle: "Mark as not a duplicate?",
22
- notDuplicateConfirmDescription: "You can't undo this action.",
23
- notDuplicateConfirmButton: "Not a duplicate",
24
- notDuplicateConfirmBackButton: "Back",
25
- deleteAction: "Remove bill",
26
- cancelAction: "Cancel bill",
27
- confirmAction: "Confirm duplicate",
28
- currentBillBadge: "This bill",
29
- originalBillBadge: "Original bill",
30
- showMoreRows: (e) => `Show ${e} more`,
31
- deletedToast: "Duplicate removed",
32
- cancelledToast: "Duplicate cancelled",
33
- confirmedToast: "Duplicate confirmed",
34
- dismissedToast: "Marked as “not a duplicate”.",
35
- removedToast: "Duplicate removed",
36
- verdictFailedToast: "Couldn't update this duplicate. Try again.",
37
- allResolvedToast: "All possible duplicates resolved"
38
- };
26
+ var v = 5;
27
+ function y(e, t) {
28
+ return t ? o(e).map(({ members: e }) => e).find((e) => e.some((e) => e.id === t)) ?? [] : [];
29
+ }
30
+ function b({ payable: o, canManage: b = !0, onRemoved: x, onOpenPayable: S, labels: C }) {
31
+ let w = h(() => ({
32
+ ...p,
33
+ ...C
34
+ }), [C]), T = i(o), [E] = T, D = o?.id, O = h(() => [...new Set(T.map((e) => e.matched_payable_id))], [T]), k = f(O, { enabled: !!(E && D) }), A = d(), [j, M] = g(!1), [N, P] = g(), F = c(o?.status), I = m(async (t, n, r, i, o) => {
35
+ let s = a(t, n, o);
36
+ if (s.length && t?.id) try {
37
+ await A.mutateAsync({
38
+ verdict: n,
39
+ targets: s.map((e) => ({
40
+ payableId: t.id,
41
+ duplicateId: e.id,
42
+ matchedPayableId: e.matched_payable_id,
43
+ removeBy: c(t.status)
44
+ }))
45
+ }), e.success(r), i?.();
46
+ } catch {
47
+ e.error(w.verdictFailedToast);
48
+ }
49
+ }, [A, w]), L = m((e, t, n) => I(o, e, t, n), [I, o]), R = F === "delete" ? {
50
+ button: w.deleteBillButton,
51
+ title: w.deleteConfirmTitle,
52
+ description: w.deleteConfirmDescription,
53
+ confirmButton: w.deleteConfirmButton,
54
+ backButton: w.deleteConfirmBackButton,
55
+ toast: w.deletedToast
56
+ } : F === "confirm" ? {
57
+ button: w.confirmBillButton,
58
+ title: w.confirmDuplicateTitle,
59
+ description: w.confirmDuplicateDescription,
60
+ confirmButton: w.confirmBillButton,
61
+ backButton: w.cancelConfirmBackButton,
62
+ toast: w.confirmedToast
63
+ } : {
64
+ button: w.cancelBillButton,
65
+ title: w.cancelConfirmTitle,
66
+ description: w.cancelConfirmDescription,
67
+ confirmButton: w.cancelConfirmButton,
68
+ backButton: w.cancelConfirmBackButton,
69
+ toast: w.cancelledToast
70
+ }, z = F !== "confirm", B = m(async () => {
71
+ await L(r.Remove, R.toast, x), M(!1);
72
+ }, [
73
+ L,
74
+ x,
75
+ R.toast
76
+ ]), V = m(async () => {
77
+ N && (await I(N.payable, r.Keep, w.dismissedToast, void 0, N.originalPayableId), P(void 0));
78
+ }, [
79
+ I,
80
+ w.dismissedToast,
81
+ N
82
+ ]), H = b && !!(E && D), U = H && !!F, W = h(() => {
83
+ let e = new Map(k.flatMap((e) => e.data ? [[e.data.id, e.data]] : []));
84
+ o?.id && e.set(o.id, o);
85
+ let r = y([...e.values()], D);
86
+ if (r.length < 2) return [];
87
+ let i = (e) => {
88
+ let t = e.total_amount ?? e.amount_due;
89
+ return t == null ? "" : n(t / 100, { currencyCode: e.currency ?? "USD" });
90
+ };
91
+ return [...r.filter((e) => e.id === D), ...r.filter((e) => e.id !== D)].map((e) => {
92
+ let n = e.status ? u({
93
+ apiStatus: e.status,
94
+ dueDate: e.due_date,
95
+ scheduledPaymentDate: e.scheduled_payment_date
96
+ }) : void 0, r = e.id === D, a = t(e.created_at?.slice(0, 10));
97
+ return {
98
+ id: e.id,
99
+ isCurrent: r,
100
+ badges: r ? [w.currentBillBadge] : [],
101
+ createdOnLabel: a,
102
+ dueDateLabel: t(e.due_date),
103
+ amountLabel: i(e),
104
+ status: n?.status,
105
+ statusTone: n?.tone,
106
+ onOpen: !r && S ? () => S(e.id, s(e.status ?? void 0)) : void 0,
107
+ openLabel: w.openRow({
108
+ vendorLabel: l(e),
109
+ invoiceNumberLabel: e.document_id ?? "",
110
+ addedOnLabel: a
111
+ })
112
+ };
113
+ });
114
+ }, [
115
+ k,
116
+ w,
117
+ S,
118
+ o,
119
+ D
120
+ ]), G = l(o), K = o?.document_id ?? "", q = W.length > 1 ? w.possibleDuplicateTitle({
121
+ otherCount: W.length - 1,
122
+ vendorLabel: G,
123
+ invoiceNumberLabel: K
124
+ }) : void 0;
125
+ return {
126
+ isPossibleDuplicate: !!E,
127
+ onNotADuplicate: H ? () => P({ payable: o }) : void 0,
128
+ onRemoveBill: U ? () => M(!0) : void 0,
129
+ removeBillLabel: U ? R.button : void 0,
130
+ isRemoveBillDestructive: z,
131
+ removeConfirmation: {
132
+ open: j,
133
+ copy: {
134
+ title: R.title,
135
+ description: R.description,
136
+ confirmButton: R.confirmButton,
137
+ ...z ? { presentation: { tone: "destructive" } } : {}
138
+ },
139
+ onConfirm: () => void B(),
140
+ onCancel: () => M(!1),
141
+ isPending: A.isPending,
142
+ cancelButtonLabel: R.backButton
143
+ },
144
+ keepRowConfirmation: {
145
+ open: !!N,
146
+ copy: {
147
+ title: w.notDuplicateConfirmTitle,
148
+ description: w.notDuplicateConfirmDescription,
149
+ confirmButton: w.notDuplicateConfirmButton,
150
+ presentation: {
151
+ alignment: "center",
152
+ icon: _,
153
+ actionWidth: "equal"
154
+ }
155
+ },
156
+ onConfirm: () => void V(),
157
+ onCancel: () => P(void 0),
158
+ isPending: A.isPending,
159
+ cancelButtonLabel: w.notDuplicateConfirmBackButton
160
+ },
161
+ isBusy: A.isPending,
162
+ message: q,
163
+ rows: W,
164
+ isLoadingRows: W.length === 0 && k.some((e) => e.isLoading),
165
+ loadingRowCount: Math.min(O.length + 1, v),
166
+ collapsedRowCount: v,
167
+ showMoreLabel: W.length > v ? w.showMoreRows(W.length - v) : void 0
168
+ };
169
+ }
39
170
  //#endregion
40
- export { e as DUPLICATE_BILLS_LABELS_EN };
171
+ export { b as usePayableDuplicateReview };