@tesouro/embedded-components-react 0.3.16 → 0.3.18

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 (111) hide show
  1. package/dist/index.d.ts +22 -1
  2. package/dist/index.js +10 -10
  3. package/dist/lib/AcceptDisclosuresWidget.d.ts +11 -1
  4. package/dist/lib/AcceptDisclosuresWidget.js +1 -1
  5. package/dist/lib/BalancesWidget.js +1 -1
  6. package/dist/lib/BankAccountOnboardingWidget.d.ts +21 -21
  7. package/dist/lib/BankAccountOnboardingWidget.js +1 -1
  8. package/dist/lib/CardsWidget.js +1 -1
  9. package/dist/lib/ExpenseApprovalPoliciesWidget.js +1 -1
  10. package/dist/lib/ExpenseManagementWidget.js +1 -1
  11. package/dist/lib/InsightsWidget.js +1 -1
  12. package/dist/lib/ReceiptMatchWidget.js +1 -1
  13. package/dist/lib/TransfersWidget.js +1 -1
  14. package/dist/lib/UploadReceiptWidget.js +1 -1
  15. package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/index.js +1 -1
  16. package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/index4.js +10 -140
  17. package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/feature/dist/index5.js +152 -0
  18. package/dist/libs/tesouro-embedded-components-react/accept-disclosures-widget/ui/dist/lib/AcceptDisclosuresWidget/AcceptDisclosuresWidget.js +19 -19
  19. package/dist/libs/tesouro-embedded-components-react/balances-widget/feature/dist/index.js +1 -1
  20. package/dist/libs/tesouro-embedded-components-react/balances-widget/feature/dist/index4.js +10 -11
  21. package/dist/libs/tesouro-embedded-components-react/balances-widget/feature/dist/index5.js +15 -64
  22. package/dist/libs/tesouro-embedded-components-react/balances-widget/feature/dist/index6.js +75 -0
  23. package/dist/libs/tesouro-embedded-components-react/balances-widget/ui/dist/lib/BalancesWidget/BalancesWidget.js +16 -16
  24. package/dist/libs/tesouro-embedded-components-react/balances-widget/ui/dist/lib/BalancesWidget/SingleBalance/SingleBalance.js +7 -7
  25. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index.js +1 -1
  26. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index10.js +109 -169
  27. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index11.js +170 -63
  28. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index12.js +73 -81
  29. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index13.js +77 -101
  30. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index14.js +110 -83
  31. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index15.js +91 -7
  32. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index16.js +7 -28
  33. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index17.js +26 -320
  34. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index18.js +341 -0
  35. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index9.js +29 -100
  36. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index.js +0 -1
  37. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index11.js +3 -3
  38. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index15.js +32 -32
  39. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index16.js +2 -2
  40. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index18.js +14 -10
  41. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index19.js +42 -42
  42. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index2.js +80 -77
  43. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index20.js +2 -2
  44. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index22.js +14 -10
  45. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index23.js +16 -16
  46. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index27.js +5 -5
  47. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index3.js +7 -6
  48. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index5.js +23 -18
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index.js +0 -1
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index63.js +28 -28
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index64.js +0 -1
  52. package/dist/libs/tesouro-embedded-components-react/card-details-widget/ui/dist/index.js +0 -1
  53. package/dist/libs/tesouro-embedded-components-react/card-details-widget/ui/dist/lib/CardDetailsPanel/CardDetailsHeader.js +5 -5
  54. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index.js +3 -3
  55. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index3.js +4 -23
  56. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index4.js +23 -24
  57. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index5.js +24 -30
  58. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index6.js +28 -55
  59. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index7.js +54 -209
  60. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index8.js +206 -81
  61. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index9.js +95 -0
  62. package/dist/libs/tesouro-embedded-components-react/cards-widget/ui/dist/lib/CardsList/CardFaceSwatch.js +2 -2
  63. package/dist/libs/tesouro-embedded-components-react/cards-widget/ui/dist/lib/CardsList/CardsList.js +31 -30
  64. package/dist/libs/tesouro-embedded-components-react/cards-widget/ui/dist/lib/CardsList/CardsListRow.js +11 -10
  65. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index.js +5 -5
  66. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index10.js +1 -255
  67. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index11.js +253 -2
  68. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index12.js +2 -71
  69. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index13.js +73 -0
  70. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index5.js +7 -218
  71. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index6.js +219 -79
  72. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index7.js +89 -2
  73. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index8.js +2 -47
  74. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index9.js +49 -1
  75. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/ApprovalRuleCard.js +2 -2
  76. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/ApprovalRuleForm.js +32 -32
  77. package/dist/libs/tesouro-embedded-components-react/expense-management-widget/ui/dist/lib/ExpenseApprovalPoliciesWidget/lib/ExpenseApprovalsPage.js +11 -8
  78. package/dist/libs/tesouro-embedded-components-react/insights-widget/feature/dist/index.js +1 -1
  79. package/dist/libs/tesouro-embedded-components-react/insights-widget/feature/dist/index10.js +12 -14
  80. package/dist/libs/tesouro-embedded-components-react/insights-widget/feature/dist/index11.js +21 -62
  81. package/dist/libs/tesouro-embedded-components-react/insights-widget/feature/dist/index12.js +73 -0
  82. package/dist/libs/tesouro-embedded-components-react/insights-widget/ui/dist/lib/InsightsWidget/InsightsWidget.js +6 -6
  83. package/dist/libs/tesouro-embedded-components-react/insights-widget/ui/dist/lib/InsightsWidget/SingleInsight/SingleInsight.js +10 -10
  84. package/dist/libs/tesouro-embedded-components-react/settings-widget/feature/dist/index5.js +1 -1
  85. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/ApprovalPoliciesSettings.js +67 -46
  86. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/testIds.js +26 -0
  87. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/feature/dist/lib/useApprovalPolicyRules.js +151 -135
  88. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index11.js +11 -11
  89. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index14.js +17 -17
  90. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index16.js +17 -15
  91. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index18.js +9 -9
  92. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index20.js +16 -13
  93. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index3.js +13 -13
  94. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index5.js +11 -11
  95. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index7.js +5 -5
  96. package/dist/libs/tesouro-embedded-components-react/shared/approval-policy/ui/dist/index9.js +6 -6
  97. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  98. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/OnboardingShell/OnboardingShell.js +21 -20
  99. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/OnboardingShell/OnboardingShellOverlayPortal.js +10 -10
  100. package/dist/libs/tesouro-embedded-components-react/shared/ui/dist/lib/OnboardingShell/OnboardingShellScrollRegion.js +17 -17
  101. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/index.js +1 -1
  102. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/index5.js +18 -99
  103. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/index6.js +116 -19
  104. package/dist/libs/tesouro-embedded-components-react/transfers-widget/feature/dist/index7.js +28 -0
  105. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransferMoneyModal/ReviewTransferStep.js +9 -9
  106. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransferMoneyModal/TransferMoneyModal.js +13 -11
  107. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransferMoneyModal/TransferResultStep.js +7 -7
  108. package/dist/libs/tesouro-embedded-components-react/transfers-widget/ui/dist/lib/TransfersWidget/TransfersWidget.js +19 -19
  109. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index7.js +4 -4
  110. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index8.js +1 -1
  111. package/package.json +1 -1
@@ -1,255 +1 @@
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 "../../../shared/ui/dist/index.js";
7
- import { useWidgetConfig as t, useWidgetLoading as n } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
8
- import "../../../shared/feature/dist/index.js";
9
- import { ReceiptMatchLabels as r } from "../../ui/dist/lib/ReceiptMatchWidget/lib/labels.js";
10
- import "../../ui/dist/index.js";
11
- import { useGetReceiptsQuery as i } from "../../data-access/dist/index2.js";
12
- import { useGetTransactionsQuery as a } from "../../data-access/dist/index3.js";
13
- import { usePatchReceiptMutation as ee } from "../../data-access/dist/index5.js";
14
- import { useDeleteReceiptMutation as te } from "../../data-access/dist/index6.js";
15
- import "../../data-access/dist/index.js";
16
- import { useCallback as o, useEffect as ne, useMemo as s, useState as c } from "react";
17
- //#region ../../libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index10.js
18
- function l(e, t) {
19
- if (typeof e == "object" && e) {
20
- let t = e.error;
21
- if (typeof t == "object" && t) {
22
- let e = t.message;
23
- if (typeof e == "string") return e;
24
- }
25
- }
26
- return e instanceof Error && e.message ? e.message : t;
27
- }
28
- function u(e, t) {
29
- let n = e / 100;
30
- try {
31
- return new Intl.NumberFormat("en-US", {
32
- style: "currency",
33
- currency: t
34
- }).format(n);
35
- } catch {
36
- return `${t} ${n.toFixed(2)}`;
37
- }
38
- }
39
- function d(e) {
40
- if (!e) return "";
41
- let t = new Date(e);
42
- return Number.isNaN(t.getTime()) ? "" : t.toLocaleDateString("en-US", {
43
- month: "short",
44
- day: "numeric",
45
- year: "numeric"
46
- });
47
- }
48
- function re(e) {
49
- if (!e) return "";
50
- let t = new Date(e);
51
- return Number.isNaN(t.getTime()) ? "" : t.toLocaleDateString("en-US", {
52
- month: "long",
53
- day: "numeric",
54
- year: "numeric"
55
- });
56
- }
57
- function f(e) {
58
- if (!e) return "";
59
- let t = new Date(e);
60
- return Number.isNaN(t.getTime()) ? "" : t.toLocaleTimeString("en-US", {
61
- hour: "numeric",
62
- minute: "2-digit",
63
- second: "2-digit",
64
- hour12: !0
65
- });
66
- }
67
- function ie(e) {
68
- let t = e.ocr_status === "processing";
69
- return {
70
- id: e.id,
71
- primaryText: t ? r.ReceiptScanningTitle : e.merchant_name?.trim() || r.ReceiptScanningTitle,
72
- secondaryText: t ? r.ReceiptScanningSubtitle : d(e.issued_at),
73
- thumbnailUrl: e.file_url ?? void 0
74
- };
75
- }
76
- function p(e) {
77
- return {
78
- id: e.id,
79
- merchantName: e.merchant_name,
80
- date: d(e.started_at),
81
- formattedAmount: u(e.amount, e.currency)
82
- };
83
- }
84
- var m = .5, h = 3, g = .25, _ = 5e3, v = !1;
85
- function y({ preSelectedIds: d, onClose: y, targetTransactionId: b, onSingleTransactionUpdate: x }) {
86
- let { initResponse: S } = t(), C = n(), w = S?.userId ?? void 0, T = !!w && !C, [E, D] = c(1), [O, k] = c(0), [A, j] = c([]), [M, N] = c(() => d), [P, F] = c(""), [I, L] = c([]), R = s(() => I.map((e) => e.id), [I]), [z, B] = c(1), V = i({
87
- has_transaction: !1,
88
- created_by_entity_user_id: w,
89
- enabled: T
90
- }), H = a({
91
- merchant_name__icontains: P || void 0,
92
- has_receipt: !1,
93
- enabled: E === 2
94
- }), U = ee(), W = te(), G = V.data?.data ?? [], K = s(() => w ? G.filter((e) => e.created_by_entity_user_id == null || e.created_by_entity_user_id === w) : [], [G, w]);
95
- ne(() => {
96
- if (!K.some((e) => e.ocr_status === "processing")) return;
97
- let e = window.setInterval(() => {
98
- V.isFetching || V.refetch();
99
- }, _);
100
- return () => window.clearInterval(e);
101
- }, [
102
- V.isFetching,
103
- V.refetch,
104
- K
105
- ]);
106
- let q = s(() => K.map(ie), [K]), J = s(() => new Set(A.flatMap((e) => e.transactionIds)), [A]), ae = s(() => (H.data?.data ?? []).filter((e) => !J.has(e.id)).map(p), [H.data, J]), Y = H.data?.data ?? [], X = M[O], Z = s(() => K.find((e) => e.id === X), [K, X]), oe = Z?.file_url ?? void 0, se = Z?.file_name ?? void 0, ce = s(() => {
107
- if (b) return "Attach";
108
- if (!(M.length <= 1)) return `Review (${O + 1}/${M.length})`;
109
- }, [
110
- b,
111
- M.length,
112
- O
113
- ]), le = s(() => A.filter((e) => e.receiptId === X).flatMap((e) => e.transactionDetails), [A, X]), ue = O >= M.length - 1 ? r.Done : r.ReviewNextReceipt(O + 2, M.length), Q = o(() => {
114
- F(""), L([]), B(1);
115
- }, []), de = o((e) => {
116
- if (b) {
117
- N((t) => t.includes(e) ? [] : [e]);
118
- return;
119
- }
120
- N((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
121
- }, [b]), fe = o(() => {
122
- N(q.map((e) => e.id));
123
- }, [q]), pe = o(() => {
124
- N([]);
125
- }, []), me = o((e) => {
126
- let t = K.find((t) => t.id === e);
127
- t?.file_url && window.open(t.file_url, "_blank", "noopener,noreferrer");
128
- }, [K]), $ = o(async (t) => {
129
- try {
130
- await W.mutateAsync({ path: { receipt_id: t } });
131
- } catch (t) {
132
- e.error(l(t, "Failed to delete receipt"));
133
- return;
134
- }
135
- N((e) => e.filter((e) => e !== t));
136
- }, [W]), he = o(async () => {
137
- if (M.length !== 0) {
138
- if (b) {
139
- try {
140
- await U.mutateAsync({
141
- path: { receipt_id: M[0] },
142
- body: { transaction_id: b }
143
- }), x?.(), y();
144
- } catch (t) {
145
- e.error(l(t, "Failed to attach receipt"));
146
- }
147
- return;
148
- }
149
- k(0), j([]), Q(), D(2);
150
- }
151
- }, [
152
- M,
153
- b,
154
- U,
155
- x,
156
- y,
157
- Q
158
- ]), ge = o((e) => {
159
- F(e);
160
- }, []), _e = o((e) => {
161
- L((t) => {
162
- let n = t.find((t) => t.id === e), r = Y.find((t) => t.id === e);
163
- return n ? [] : r ? [r] : [];
164
- });
165
- }, [Y]), ve = o(async () => {
166
- if (I.length === 0 || !X) return;
167
- let t = I, n = (e) => ({
168
- merchant: e.merchant_name,
169
- location: e.merchant_location,
170
- date: re(e.started_at),
171
- time: f(e.started_at),
172
- formattedAmount: u(e.amount, e.currency)
173
- }), r = [], i = [];
174
- for (let a of t) try {
175
- await U.mutateAsync({
176
- path: { receipt_id: X },
177
- body: { transaction_id: a.id }
178
- }), r.push(a.id), i.push(n(a));
179
- } catch (t) {
180
- r.length > 0 && j((e) => [...e, {
181
- receiptId: X,
182
- transactionIds: r,
183
- transactionDetails: i
184
- }]), L((e) => e.filter((e) => !r.includes(e.id))), e.error(l(t, "Failed to match receipt"));
185
- return;
186
- }
187
- j((e) => [...e, {
188
- receiptId: X,
189
- transactionIds: r,
190
- transactionDetails: i
191
- }]), D(3);
192
- }, [
193
- I,
194
- X,
195
- U
196
- ]), ye = o(() => {
197
- B((e) => Math.min(e + g, h));
198
- }, []), be = o(() => {
199
- B((e) => Math.max(e - g, m));
200
- }, []), xe = o(() => {
201
- let e = O + 1;
202
- if (e < M.length) {
203
- k(e), Q(), D(2);
204
- return;
205
- }
206
- y();
207
- }, [
208
- O,
209
- M.length,
210
- Q,
211
- y
212
- ]), Se = o(() => {
213
- if (A.length > 0) {
214
- let e = new Set(A.map((e) => e.receiptId));
215
- N((t) => t.filter((t) => !e.has(t)));
216
- }
217
- Q(), k(0), j([]), D(1);
218
- }, [Q, A]);
219
- return {
220
- step: E,
221
- receipts: q,
222
- selectedReceiptIds: M,
223
- onSelectAll: fe,
224
- onReset: pe,
225
- onReceiptToggle: de,
226
- onViewAttachment: me,
227
- onDeleteReceipt: $,
228
- onReview: he,
229
- isReceiptsLoading: V.isLoading,
230
- showSelectAllButton: !b,
231
- receiptPreviewUrl: oe,
232
- receiptFileName: se,
233
- transactions: ae,
234
- isTransactionsLoading: H.isLoading,
235
- selectedTransactionIds: R,
236
- allowMultipleTransactions: v,
237
- searchValue: P,
238
- onSearchChange: ge,
239
- onTransactionSelect: _e,
240
- onConfirmMatch: ve,
241
- isConfirming: U.isPending,
242
- zoom: z,
243
- onZoomIn: ye,
244
- onZoomOut: be,
245
- canZoomIn: z < h,
246
- canZoomOut: z > m,
247
- matchedTransactions: le,
248
- primaryLabel: ue,
249
- onPrimary: xe,
250
- onCancel: Se,
251
- reviewLabel: ce
252
- };
253
- }
254
- //#endregion
255
- export { y as useReceiptMatch };
1
+ import "./index9.js";
@@ -1,4 +1,255 @@
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 "../../../shared/ui/dist/index.js";
7
+ import { useWidgetConfig as t, useWidgetLoading as n } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
8
+ import "../../../shared/feature/dist/index.js";
9
+ import { ReceiptMatchLabels as r } from "../../ui/dist/lib/ReceiptMatchWidget/lib/labels.js";
10
+ import "../../ui/dist/index.js";
11
+ import { useGetReceiptsQuery as i } from "../../data-access/dist/index2.js";
12
+ import { useGetTransactionsQuery as a } from "../../data-access/dist/index3.js";
13
+ import { usePatchReceiptMutation as ee } from "../../data-access/dist/index5.js";
14
+ import { useDeleteReceiptMutation as te } from "../../data-access/dist/index6.js";
15
+ import "../../data-access/dist/index.js";
16
+ import { useCallback as o, useEffect as ne, useMemo as s, useState as c } from "react";
1
17
  //#region ../../libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index11.js
2
- var e = { Mounted: "receipt_match.mounted" }, t = "receipt_match";
18
+ function l(e, t) {
19
+ if (typeof e == "object" && e) {
20
+ let t = e.error;
21
+ if (typeof t == "object" && t) {
22
+ let e = t.message;
23
+ if (typeof e == "string") return e;
24
+ }
25
+ }
26
+ return e instanceof Error && e.message ? e.message : t;
27
+ }
28
+ function u(e, t) {
29
+ let n = e / 100;
30
+ try {
31
+ return new Intl.NumberFormat("en-US", {
32
+ style: "currency",
33
+ currency: t
34
+ }).format(n);
35
+ } catch {
36
+ return `${t} ${n.toFixed(2)}`;
37
+ }
38
+ }
39
+ function d(e) {
40
+ if (!e) return "";
41
+ let t = new Date(e);
42
+ return Number.isNaN(t.getTime()) ? "" : t.toLocaleDateString("en-US", {
43
+ month: "short",
44
+ day: "numeric",
45
+ year: "numeric"
46
+ });
47
+ }
48
+ function re(e) {
49
+ if (!e) return "";
50
+ let t = new Date(e);
51
+ return Number.isNaN(t.getTime()) ? "" : t.toLocaleDateString("en-US", {
52
+ month: "long",
53
+ day: "numeric",
54
+ year: "numeric"
55
+ });
56
+ }
57
+ function f(e) {
58
+ if (!e) return "";
59
+ let t = new Date(e);
60
+ return Number.isNaN(t.getTime()) ? "" : t.toLocaleTimeString("en-US", {
61
+ hour: "numeric",
62
+ minute: "2-digit",
63
+ second: "2-digit",
64
+ hour12: !0
65
+ });
66
+ }
67
+ function ie(e) {
68
+ let t = e.ocr_status === "processing";
69
+ return {
70
+ id: e.id,
71
+ primaryText: t ? r.ReceiptScanningTitle : e.merchant_name?.trim() || r.ReceiptScanningTitle,
72
+ secondaryText: t ? r.ReceiptScanningSubtitle : d(e.issued_at),
73
+ thumbnailUrl: e.file_url ?? void 0
74
+ };
75
+ }
76
+ function p(e) {
77
+ return {
78
+ id: e.id,
79
+ merchantName: e.merchant_name,
80
+ date: d(e.started_at),
81
+ formattedAmount: u(e.amount, e.currency)
82
+ };
83
+ }
84
+ var m = .5, h = 3, g = .25, _ = 5e3, v = !1;
85
+ function y({ preSelectedIds: d, onClose: y, targetTransactionId: b, onSingleTransactionUpdate: x }) {
86
+ let { initResponse: S } = t(), C = n(), w = S?.userId ?? void 0, T = !!w && !C, [E, D] = c(1), [O, k] = c(0), [A, j] = c([]), [M, N] = c(() => d), [P, F] = c(""), [I, L] = c([]), R = s(() => I.map((e) => e.id), [I]), [z, B] = c(1), V = i({
87
+ has_transaction: !1,
88
+ created_by_entity_user_id: w,
89
+ enabled: T
90
+ }), H = a({
91
+ merchant_name__icontains: P || void 0,
92
+ has_receipt: !1,
93
+ enabled: E === 2
94
+ }), U = ee(), W = te(), G = V.data?.data ?? [], K = s(() => w ? G.filter((e) => e.created_by_entity_user_id == null || e.created_by_entity_user_id === w) : [], [G, w]);
95
+ ne(() => {
96
+ if (!K.some((e) => e.ocr_status === "processing")) return;
97
+ let e = window.setInterval(() => {
98
+ V.isFetching || V.refetch();
99
+ }, _);
100
+ return () => window.clearInterval(e);
101
+ }, [
102
+ V.isFetching,
103
+ V.refetch,
104
+ K
105
+ ]);
106
+ let q = s(() => K.map(ie), [K]), J = s(() => new Set(A.flatMap((e) => e.transactionIds)), [A]), ae = s(() => (H.data?.data ?? []).filter((e) => !J.has(e.id)).map(p), [H.data, J]), Y = H.data?.data ?? [], X = M[O], Z = s(() => K.find((e) => e.id === X), [K, X]), oe = Z?.file_url ?? void 0, se = Z?.file_name ?? void 0, ce = s(() => {
107
+ if (b) return "Attach";
108
+ if (!(M.length <= 1)) return `Review (${O + 1}/${M.length})`;
109
+ }, [
110
+ b,
111
+ M.length,
112
+ O
113
+ ]), le = s(() => A.filter((e) => e.receiptId === X).flatMap((e) => e.transactionDetails), [A, X]), ue = O >= M.length - 1 ? r.Done : r.ReviewNextReceipt(O + 2, M.length), Q = o(() => {
114
+ F(""), L([]), B(1);
115
+ }, []), de = o((e) => {
116
+ if (b) {
117
+ N((t) => t.includes(e) ? [] : [e]);
118
+ return;
119
+ }
120
+ N((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
121
+ }, [b]), fe = o(() => {
122
+ N(q.map((e) => e.id));
123
+ }, [q]), pe = o(() => {
124
+ N([]);
125
+ }, []), me = o((e) => {
126
+ let t = K.find((t) => t.id === e);
127
+ t?.file_url && window.open(t.file_url, "_blank", "noopener,noreferrer");
128
+ }, [K]), $ = o(async (t) => {
129
+ try {
130
+ await W.mutateAsync({ path: { receipt_id: t } });
131
+ } catch (t) {
132
+ e.error(l(t, "Failed to delete receipt"));
133
+ return;
134
+ }
135
+ N((e) => e.filter((e) => e !== t));
136
+ }, [W]), he = o(async () => {
137
+ if (M.length !== 0) {
138
+ if (b) {
139
+ try {
140
+ await U.mutateAsync({
141
+ path: { receipt_id: M[0] },
142
+ body: { transaction_id: b }
143
+ }), x?.(), y();
144
+ } catch (t) {
145
+ e.error(l(t, "Failed to attach receipt"));
146
+ }
147
+ return;
148
+ }
149
+ k(0), j([]), Q(), D(2);
150
+ }
151
+ }, [
152
+ M,
153
+ b,
154
+ U,
155
+ x,
156
+ y,
157
+ Q
158
+ ]), ge = o((e) => {
159
+ F(e);
160
+ }, []), _e = o((e) => {
161
+ L((t) => {
162
+ let n = t.find((t) => t.id === e), r = Y.find((t) => t.id === e);
163
+ return n ? [] : r ? [r] : [];
164
+ });
165
+ }, [Y]), ve = o(async () => {
166
+ if (I.length === 0 || !X) return;
167
+ let t = I, n = (e) => ({
168
+ merchant: e.merchant_name,
169
+ location: e.merchant_location,
170
+ date: re(e.started_at),
171
+ time: f(e.started_at),
172
+ formattedAmount: u(e.amount, e.currency)
173
+ }), r = [], i = [];
174
+ for (let a of t) try {
175
+ await U.mutateAsync({
176
+ path: { receipt_id: X },
177
+ body: { transaction_id: a.id }
178
+ }), r.push(a.id), i.push(n(a));
179
+ } catch (t) {
180
+ r.length > 0 && j((e) => [...e, {
181
+ receiptId: X,
182
+ transactionIds: r,
183
+ transactionDetails: i
184
+ }]), L((e) => e.filter((e) => !r.includes(e.id))), e.error(l(t, "Failed to match receipt"));
185
+ return;
186
+ }
187
+ j((e) => [...e, {
188
+ receiptId: X,
189
+ transactionIds: r,
190
+ transactionDetails: i
191
+ }]), D(3);
192
+ }, [
193
+ I,
194
+ X,
195
+ U
196
+ ]), ye = o(() => {
197
+ B((e) => Math.min(e + g, h));
198
+ }, []), be = o(() => {
199
+ B((e) => Math.max(e - g, m));
200
+ }, []), xe = o(() => {
201
+ let e = O + 1;
202
+ if (e < M.length) {
203
+ k(e), Q(), D(2);
204
+ return;
205
+ }
206
+ y();
207
+ }, [
208
+ O,
209
+ M.length,
210
+ Q,
211
+ y
212
+ ]), Se = o(() => {
213
+ if (A.length > 0) {
214
+ let e = new Set(A.map((e) => e.receiptId));
215
+ N((t) => t.filter((t) => !e.has(t)));
216
+ }
217
+ Q(), k(0), j([]), D(1);
218
+ }, [Q, A]);
219
+ return {
220
+ step: E,
221
+ receipts: q,
222
+ selectedReceiptIds: M,
223
+ onSelectAll: fe,
224
+ onReset: pe,
225
+ onReceiptToggle: de,
226
+ onViewAttachment: me,
227
+ onDeleteReceipt: $,
228
+ onReview: he,
229
+ isReceiptsLoading: V.isLoading,
230
+ showSelectAllButton: !b,
231
+ receiptPreviewUrl: oe,
232
+ receiptFileName: se,
233
+ transactions: ae,
234
+ isTransactionsLoading: H.isLoading,
235
+ selectedTransactionIds: R,
236
+ allowMultipleTransactions: v,
237
+ searchValue: P,
238
+ onSearchChange: ge,
239
+ onTransactionSelect: _e,
240
+ onConfirmMatch: ve,
241
+ isConfirming: U.isPending,
242
+ zoom: z,
243
+ onZoomIn: ye,
244
+ onZoomOut: be,
245
+ canZoomIn: z < h,
246
+ canZoomOut: z > m,
247
+ matchedTransactions: le,
248
+ primaryLabel: ue,
249
+ onPrimary: xe,
250
+ onCancel: Se,
251
+ reviewLabel: ce
252
+ };
253
+ }
3
254
  //#endregion
4
- export { e as ReceiptMatchAnalyticsEvent, t as WIDGET_NAME };
255
+ export { y as useReceiptMatch };
@@ -1,73 +1,4 @@
1
- "use client";
2
- "use client";
3
- "use client";
4
- "use client";
5
- import { EmbeddedToaster as e } from "../../../shared/ui/dist/lib/EmbeddedToaster.js";
6
- import "../../../shared/ui/dist/index.js";
7
- import { useAnalyticsTrack as t } from "../../../shared/feature/dist/lib/analytics/hooks.js";
8
- import { WidgetProvider as n } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
9
- import "../../../shared/feature/dist/index.js";
10
- import { ReceiptMatchSidebar as r } from "../../ui/dist/lib/ReceiptMatchWidget/lib/ReceiptMatchSidebar.js";
11
- import "../../ui/dist/index.js";
12
- import { useReceiptMatch as i } from "./index10.js";
13
- import { ReceiptMatchAnalyticsEvent as a, WIDGET_NAME as o } from "./index11.js";
14
- import { useCallback as s, useEffect as c, useState as l } from "react";
15
- import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
16
1
  //#region ../../libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index12.js
17
- function p({ preSelectedReceiptIds: n = [], onClose: o, targetTransactionId: l, onSingleTransactionUpdate: p }) {
18
- let m = t();
19
- c(() => {
20
- m(a.Mounted);
21
- }, [m]);
22
- let h = i({
23
- preSelectedIds: n,
24
- onClose: o,
25
- targetTransactionId: l,
26
- onSingleTransactionUpdate: p
27
- }), g = s(() => {
28
- h.onCancel(), o();
29
- }, [h.onCancel, o]);
30
- return /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(e, {}), /* @__PURE__ */ d(r, {
31
- open: !0,
32
- onClose: g,
33
- ...h
34
- })] });
35
- }
36
- function m({ isOpen: e, onClose: t, ...n }) {
37
- let [r, i] = l(!!e);
38
- c(() => {
39
- i(!!e);
40
- }, [e]);
41
- let a = s(() => {
42
- i(!1), t?.();
43
- }, [t]);
44
- return r ? /* @__PURE__ */ d(p, {
45
- onClose: a,
46
- ...n
47
- }) : null;
48
- }
49
- function h({ baseUrl: e, widgetToken: t, organizationId: r, configClient: i, gatewayRouting: a, linkComponent: s, implementation: c, uiFramework: l, errorFallback: u, onError: f, disclosuresAcceptance: p, isOpen: h, preSelectedReceiptIds: g, onClose: _, targetTransactionId: v, onSingleTransactionUpdate: y }) {
50
- return /* @__PURE__ */ d(n, {
51
- widgetName: o,
52
- baseUrl: e,
53
- widgetToken: t,
54
- organizationId: r,
55
- configClient: i,
56
- gatewayRouting: a,
57
- linkComponent: s,
58
- implementation: c,
59
- uiFramework: l,
60
- errorFallback: u,
61
- onError: f,
62
- disclosuresAcceptance: p,
63
- children: /* @__PURE__ */ d(m, {
64
- isOpen: h,
65
- preSelectedReceiptIds: g,
66
- onClose: _,
67
- targetTransactionId: v,
68
- onSingleTransactionUpdate: y
69
- })
70
- });
71
- }
2
+ var e = { Mounted: "receipt_match.mounted" }, t = "receipt_match";
72
3
  //#endregion
73
- export { h as ReceiptMatchWidget };
4
+ export { e as ReceiptMatchAnalyticsEvent, t as WIDGET_NAME };
@@ -0,0 +1,73 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { EmbeddedToaster as e } from "../../../shared/ui/dist/lib/EmbeddedToaster.js";
6
+ import "../../../shared/ui/dist/index.js";
7
+ import { useAnalyticsTrack as t } from "../../../shared/feature/dist/lib/analytics/hooks.js";
8
+ import { WidgetProvider as n } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
9
+ import "../../../shared/feature/dist/index.js";
10
+ import { ReceiptMatchSidebar as r } from "../../ui/dist/lib/ReceiptMatchWidget/lib/ReceiptMatchSidebar.js";
11
+ import "../../ui/dist/index.js";
12
+ import { useReceiptMatch as i } from "./index11.js";
13
+ import { ReceiptMatchAnalyticsEvent as a, WIDGET_NAME as o } from "./index12.js";
14
+ import { useCallback as s, useEffect as c, useState as l } from "react";
15
+ import { Fragment as u, jsx as d, jsxs as f } from "react/jsx-runtime";
16
+ //#region ../../libs/tesouro-embedded-components-react/expense-management-widget/feature/dist/index13.js
17
+ function p({ preSelectedReceiptIds: n = [], onClose: o, targetTransactionId: l, onSingleTransactionUpdate: p }) {
18
+ let m = t();
19
+ c(() => {
20
+ m(a.Mounted);
21
+ }, [m]);
22
+ let h = i({
23
+ preSelectedIds: n,
24
+ onClose: o,
25
+ targetTransactionId: l,
26
+ onSingleTransactionUpdate: p
27
+ }), g = s(() => {
28
+ h.onCancel(), o();
29
+ }, [h.onCancel, o]);
30
+ return /* @__PURE__ */ f(u, { children: [/* @__PURE__ */ d(e, {}), /* @__PURE__ */ d(r, {
31
+ open: !0,
32
+ onClose: g,
33
+ ...h
34
+ })] });
35
+ }
36
+ function m({ isOpen: e, onClose: t, ...n }) {
37
+ let [r, i] = l(!!e);
38
+ c(() => {
39
+ i(!!e);
40
+ }, [e]);
41
+ let a = s(() => {
42
+ i(!1), t?.();
43
+ }, [t]);
44
+ return r ? /* @__PURE__ */ d(p, {
45
+ onClose: a,
46
+ ...n
47
+ }) : null;
48
+ }
49
+ function h({ baseUrl: e, widgetToken: t, organizationId: r, configClient: i, gatewayRouting: a, linkComponent: s, implementation: c, uiFramework: l, errorFallback: u, onError: f, disclosuresAcceptance: p, isOpen: h, preSelectedReceiptIds: g, onClose: _, targetTransactionId: v, onSingleTransactionUpdate: y }) {
50
+ return /* @__PURE__ */ d(n, {
51
+ widgetName: o,
52
+ baseUrl: e,
53
+ widgetToken: t,
54
+ organizationId: r,
55
+ configClient: i,
56
+ gatewayRouting: a,
57
+ linkComponent: s,
58
+ implementation: c,
59
+ uiFramework: l,
60
+ errorFallback: u,
61
+ onError: f,
62
+ disclosuresAcceptance: p,
63
+ children: /* @__PURE__ */ d(m, {
64
+ isOpen: h,
65
+ preSelectedReceiptIds: g,
66
+ onClose: _,
67
+ targetTransactionId: v,
68
+ onSingleTransactionUpdate: y
69
+ })
70
+ });
71
+ }
72
+ //#endregion
73
+ export { h as ReceiptMatchWidget };