@tesouro/embedded-components-react 0.9.43 → 0.9.45

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.
@@ -680,11 +680,19 @@ interface ApprovalRequestsListLabels {
680
680
  status: Record<ApprovalRequestStatus, string>;
681
681
  filters: ApprovalRequestsFilterLabels;
682
682
  }
683
+ /** Toast copy for approve and reject; the error copy is the fallback when the API gives no reason. */
684
+ interface ApprovalRequestsMessageLabels {
685
+ approved: string;
686
+ rejected: string;
687
+ approveError: string;
688
+ rejectError: string;
689
+ }
683
690
 
684
691
  interface ApprovalRequestsWidgetOwnProps {
685
692
  screenLabels?: PartialDeep<ApprovalRequestsScreenLabels>;
686
693
  listLabels?: PartialDeep<ApprovalRequestsListLabels>;
687
- rejectDialogLabels?: Partial<RejectApprovalRequestDialogLabels>;
694
+ rejectDialogLabels?: PartialDeep<RejectApprovalRequestDialogLabels>;
695
+ messageLabels?: PartialDeep<ApprovalRequestsMessageLabels>;
688
696
  }
689
697
  /** Public props for {@link ApprovalRequestsWidget}. */
690
698
  type ApprovalRequestsWidgetProps = WidgetProviderProps & ApprovalRequestsWidgetOwnProps;
@@ -692,7 +700,7 @@ type ApprovalRequestsWidgetProps = WidgetProviderProps & ApprovalRequestsWidgetO
692
700
  * Self-contained approval requests widget, a native port of Monite's approval
693
701
  * requests (FOPS-97). Exported only from the package's `/experimental` entry.
694
702
  */
695
- declare function ApprovalRequestsWidget({ screenLabels, listLabels, rejectDialogLabels, ...widgetProviderProps }: ApprovalRequestsWidgetProps): React.JSX.Element;
703
+ declare function ApprovalRequestsWidget({ screenLabels, listLabels, rejectDialogLabels, messageLabels, ...widgetProviderProps }: ApprovalRequestsWidgetProps): React.JSX.Element;
696
704
 
697
705
  export { ApprovalRequestsWidget };
698
706
  export type { ApprovalRequestsWidgetProps };
@@ -680,11 +680,19 @@ interface ApprovalRequestsListLabels {
680
680
  status: Record<ApprovalRequestStatus, string>;
681
681
  filters: ApprovalRequestsFilterLabels;
682
682
  }
683
+ /** Toast copy for approve and reject; the error copy is the fallback when the API gives no reason. */
684
+ interface ApprovalRequestsMessageLabels {
685
+ approved: string;
686
+ rejected: string;
687
+ approveError: string;
688
+ rejectError: string;
689
+ }
683
690
 
684
691
  interface ApprovalRequestsWidgetOwnProps {
685
692
  screenLabels?: PartialDeep<ApprovalRequestsScreenLabels>;
686
693
  listLabels?: PartialDeep<ApprovalRequestsListLabels>;
687
- rejectDialogLabels?: Partial<RejectApprovalRequestDialogLabels>;
694
+ rejectDialogLabels?: PartialDeep<RejectApprovalRequestDialogLabels>;
695
+ messageLabels?: PartialDeep<ApprovalRequestsMessageLabels>;
688
696
  }
689
697
  /** Public props for {@link ApprovalRequestsWidget}. */
690
698
  type ApprovalRequestsWidgetProps = WidgetProviderProps & ApprovalRequestsWidgetOwnProps;
@@ -692,7 +700,7 @@ type ApprovalRequestsWidgetProps = WidgetProviderProps & ApprovalRequestsWidgetO
692
700
  * Self-contained approval requests widget, a native port of Monite's approval
693
701
  * requests (FOPS-97). Exported only from the package's `/experimental` entry.
694
702
  */
695
- declare function ApprovalRequestsWidget({ screenLabels, listLabels, rejectDialogLabels, ...widgetProviderProps }: ApprovalRequestsWidgetProps): React.JSX.Element;
703
+ declare function ApprovalRequestsWidget({ screenLabels, listLabels, rejectDialogLabels, messageLabels, ...widgetProviderProps }: ApprovalRequestsWidgetProps): React.JSX.Element;
696
704
 
697
705
  interface CheckAmountAndDetailScreenLabels {
698
706
  title: string;
@@ -5,76 +5,86 @@
5
5
  import { isOrganizationOnItsWay as e } from "../../../../../shared/data-access/dist/lib/organizationStatus.js";
6
6
  import { useEmbedApi as t } from "../../../../../shared/data-access/dist/lib/EmbedApiContext.js";
7
7
  import "../../../../../shared/data-access/dist/index.js";
8
- import { useAnalyticsTrack as n } from "../../../../../shared/feature/dist/lib/analytics/hooks.js";
9
- import { WidgetProvider as r } from "../../../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
10
- import { useRefetchWidget as i, useWidgetConfig as a, useWidgetError as o, useWidgetInitStaleForToken as s, useWidgetLoading as c } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
8
+ import { EmbeddedToaster as n } from "../../../../../shared/ui/dist/lib/EmbeddedToaster.js";
9
+ import "../../../../../shared/ui/dist/index.js";
10
+ import { useAnalyticsTrack as r } from "../../../../../shared/feature/dist/lib/analytics/hooks.js";
11
+ import { WidgetProvider as i } from "../../../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
12
+ import { useRefetchWidget as a, useWidgetConfig as o, useWidgetError as s, useWidgetInitStaleForToken as c, useWidgetLoading as l } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
11
13
  import "../../../../../shared/feature/dist/index.js";
12
- import { ApprovalRequestsWidgetAnalyticsEvent as l, WIDGET_NAME as u } from "../analytics/events.js";
13
- import { APPROVAL_REQUESTS_LIST_LABELS_EN as d } from "./labels.js";
14
- import { getApprovalRequestPermissions as f } from "./permissions.js";
15
- import { useApprovalRequestDecisions as p } from "./useApprovalRequestDecisions.js";
16
- import { ApprovalRequestsScreen as m } from "../../../../ui/dist/index4.js";
17
- import { RejectApprovalRequestDialog as h } from "../../../../ui/dist/index5.js";
14
+ import { ApprovalRequestsWidgetAnalyticsEvent as u, WIDGET_NAME as d } from "../analytics/events.js";
15
+ import { APPROVAL_REQUESTS_LIST_LABELS_EN as f, APPROVAL_REQUESTS_MESSAGE_LABELS_EN as p } from "./labels.js";
16
+ import { getApprovalRequestPermissions as m } from "./permissions.js";
17
+ import { useApprovalRequestDecisions as h } from "./useApprovalRequestDecisions.js";
18
+ import { ApprovalRequestsScreen as g } from "../../../../ui/dist/index4.js";
19
+ import { RejectApprovalRequestDialog as _ } from "../../../../ui/dist/index5.js";
18
20
  import "../../../../ui/dist/index.js";
19
- import { useApprovalRequestsTable as g } from "./useApprovalRequestsTable.js";
20
- import { useEffect as _, useMemo as v } from "react";
21
- import { Fragment as y, jsx as b, jsxs as x } from "react/jsx-runtime";
21
+ import { useApprovalRequestsTable as v } from "./useApprovalRequestsTable.js";
22
+ import { useEffect as y, useMemo as b } from "react";
23
+ import { Fragment as x, jsx as S, jsxs as C } from "react/jsx-runtime";
22
24
  //#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/ApprovalRequestsWidget.js
23
- function S({ screenLabels: r, listLabels: u, rejectDialogLabels: S }) {
24
- let C = n();
25
- _(() => {
26
- C(l.Mounted);
27
- }, [C]);
28
- let w = v(() => ({
25
+ function w({ screenLabels: i, listLabels: d, rejectDialogLabels: w, messageLabels: T }) {
26
+ let E = r();
27
+ y(() => {
28
+ E(u.Mounted);
29
+ }, [E]);
30
+ let D = b(() => ({
31
+ ...f,
29
32
  ...d,
30
- ...u,
31
33
  status: {
32
- ...d.status,
33
- ...u?.status
34
+ ...f.status,
35
+ ...d?.status
34
36
  },
35
37
  filters: {
36
- ...d.filters,
37
- ...u?.filters
38
+ ...f.filters,
39
+ ...d?.filters
38
40
  }
39
- }), [u]), { initResponse: T, widgetToken: E } = a(), D = c(), O = o(), k = s(), A = i(), { organizationStatus: j } = t(), M = v(() => f(k ? void 0 : T?.scopes), [k, T?.scopes]), N = !(!E || T || O) || D && !T || k, P = !!O && (!T || k), F = p(), I = g({
40
- labels: w,
41
- enabled: M.canRead,
42
- pendingRequestIds: F.pendingRequestIds,
43
- areDecisionsPaused: F.areDecisionsPaused
41
+ }), [d]), { initResponse: O, widgetToken: k } = o(), A = l(), j = s(), M = c(), N = a(), { organizationStatus: P } = t(), F = b(() => m(M ? void 0 : O?.scopes), [M, O?.scopes]), I = !(!k || O || j) || A && !O || M, L = !!j && (!O || M), R = b(() => ({
42
+ ...p,
43
+ ...T
44
+ }), [T]), z = h({ messages: R }), B = v({
45
+ labels: D,
46
+ enabled: F.canRead,
47
+ pendingRequestIds: z.pendingRequestIds,
48
+ areDecisionsPaused: z.areDecisionsPaused
44
49
  });
45
- return /* @__PURE__ */ x(y, { children: [/* @__PURE__ */ b(m, {
46
- rows: I.rows,
47
- isLoading: I.isLoading || (N || e(j)) && I.rows.length === 0,
48
- isError: P || I.isError,
49
- isAccessRestricted: !N && !P && !M.canRead,
50
- pageSize: I.pageSize,
51
- onPageSizeChange: I.onPageSizeChange,
52
- pageSizeOptions: I.pageSizeOptions,
53
- hasNextPage: I.hasNextPage,
54
- hasPrevPage: I.hasPrevPage,
55
- onNextPage: I.onNextPage,
56
- onPrevPage: I.onPrevPage,
57
- emptyState: I.emptyState,
58
- filters: I.filters,
59
- onRetry: P ? A : I.onRetry,
60
- onApprove: F.onApprove,
61
- onReject: F.onReject,
62
- labels: r
63
- }), /* @__PURE__ */ b(h, {
64
- ...F.rejectDialog,
65
- labels: S
66
- })] });
50
+ return /* @__PURE__ */ C(x, { children: [
51
+ /* @__PURE__ */ S(n, {}),
52
+ /* @__PURE__ */ S(g, {
53
+ rows: B.rows,
54
+ isLoading: B.isLoading || (I || e(P)) && B.rows.length === 0,
55
+ isError: L || B.isError,
56
+ isAccessRestricted: !I && !L && !F.canRead,
57
+ pageSize: B.pageSize,
58
+ onPageSizeChange: B.onPageSizeChange,
59
+ pageSizeOptions: B.pageSizeOptions,
60
+ hasNextPage: B.hasNextPage,
61
+ hasPrevPage: B.hasPrevPage,
62
+ onNextPage: B.onNextPage,
63
+ onPrevPage: B.onPrevPage,
64
+ emptyState: B.emptyState,
65
+ filters: B.filters,
66
+ onRetry: L ? N : B.onRetry,
67
+ onApprove: z.onApprove,
68
+ onReject: z.onReject,
69
+ labels: i
70
+ }),
71
+ /* @__PURE__ */ S(_, {
72
+ ...z.rejectDialog,
73
+ labels: w
74
+ })
75
+ ] });
67
76
  }
68
- function C({ screenLabels: e, listLabels: t, rejectDialogLabels: n, ...i }) {
69
- return /* @__PURE__ */ b(r, {
70
- ...i,
71
- widgetName: u,
72
- children: /* @__PURE__ */ b(S, {
77
+ function T({ screenLabels: e, listLabels: t, rejectDialogLabels: n, messageLabels: r, ...a }) {
78
+ return /* @__PURE__ */ S(i, {
79
+ ...a,
80
+ widgetName: d,
81
+ children: /* @__PURE__ */ S(w, {
73
82
  screenLabels: e,
74
83
  listLabels: t,
75
- rejectDialogLabels: n
84
+ rejectDialogLabels: n,
85
+ messageLabels: r
76
86
  })
77
87
  });
78
88
  }
79
89
  //#endregion
80
- export { C as ApprovalRequestsWidget, C as default };
90
+ export { T as ApprovalRequestsWidget, T as default };
@@ -19,6 +19,11 @@ var e = {
19
19
  moreSelected: (e, t) => `${e} + ${t} more`,
20
20
  dateRange: (e, t) => `${e} - ${t}`
21
21
  }
22
+ }, t = {
23
+ approved: "Request was approved",
24
+ rejected: "Request was rejected",
25
+ approveError: "Couldn't approve the request. Try again.",
26
+ rejectError: "Couldn't reject the request. Try again."
22
27
  };
23
28
  //#endregion
24
- export { e as APPROVAL_REQUESTS_LIST_LABELS_EN };
29
+ export { e as APPROVAL_REQUESTS_LIST_LABELS_EN, t as APPROVAL_REQUESTS_MESSAGE_LABELS_EN };
@@ -2,75 +2,93 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { isOrganizationOnItsWay as e } from "../../../../../shared/data-access/dist/lib/organizationStatus.js";
6
- import { useEmbedApi as t } from "../../../../../shared/data-access/dist/lib/EmbedApiContext.js";
5
+ import { toast as e } from "../../../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import { extractApiErrorMessage as t } from "../../../../../shared/util/dist/lib/apiErrors.js";
7
+ import "../../../../../shared/util/dist/index.js";
8
+ import { isOrganizationOnItsWay as n } from "../../../../../shared/data-access/dist/lib/organizationStatus.js";
9
+ import { useEmbedApi as r } from "../../../../../shared/data-access/dist/lib/EmbedApiContext.js";
7
10
  import "../../../../../shared/data-access/dist/index.js";
8
- import { useWidgetConfig as n, useWidgetInitStaleForToken as r } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
11
+ import "../../../../../shared/ui/dist/index.js";
12
+ import { useWidgetConfig as i, useWidgetInitStaleForToken as a } from "../../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
9
13
  import "../../../../../shared/feature/dist/index.js";
10
- import { useApproveApprovalRequestMutation as i } from "../../../../data-access/dist/index4.js";
11
- import { useRejectApprovalRequestMutation as a } from "../../../../data-access/dist/index5.js";
14
+ import { useApproveApprovalRequestMutation as o } from "../../../../data-access/dist/index4.js";
15
+ import { useRejectApprovalRequestMutation as s } from "../../../../data-access/dist/index5.js";
12
16
  import "../../../../data-access/dist/index.js";
13
- import { useCallback as o, useState as s } from "react";
17
+ import { useCallback as c, useState as l } from "react";
14
18
  //#region ../../libs/tesouro-embedded-components-react/approval-requests-widget/feature/dist/lib/ApprovalRequestsWidget/useApprovalRequestDecisions.js
15
- var c = /* @__PURE__ */ new Set();
16
- function l() {
17
- let { mutateAsync: l } = i(), { mutateAsync: u } = a(), [d, f] = s(c), [p, m] = s(), [h, g] = s(""), { client: _, organizationId: v, organizationStatus: y } = t(), b = r(), x = e(y) || b, S = n().initResponse?.userId, C = b ? void 0 : S, [w, T] = s({
18
- client: _,
19
- organizationId: v,
20
- userId: C
19
+ var u = /* @__PURE__ */ new Set();
20
+ function d({ messages: d }) {
21
+ let { mutateAsync: f } = o(), { mutateAsync: p } = s(), [m, h] = l(u), [g, _] = l(), [v, y] = l(""), { client: b, organizationId: x, organizationStatus: S } = r(), C = a(), w = n(S) || C, T = i().initResponse?.userId, E = C ? void 0 : T, [D, O] = l({
22
+ client: b,
23
+ organizationId: x,
24
+ userId: E
21
25
  });
22
- (_ !== w.client || v !== void 0 && v !== w.organizationId || C !== void 0 && C !== w.userId) && (T({
23
- client: _,
24
- organizationId: v === void 0 ? w.organizationId : v,
25
- userId: C === void 0 ? w.userId : C
26
- }), m(void 0));
27
- let E = o(async (e, t) => {
28
- f((t) => new Set(t).add(e));
26
+ (b !== D.client || x !== void 0 && x !== D.organizationId || E !== void 0 && E !== D.userId) && (O({
27
+ client: b,
28
+ organizationId: x === void 0 ? D.organizationId : x,
29
+ userId: E === void 0 ? D.userId : E
30
+ }), _(void 0));
31
+ let k = c(async (n, { decide: r, successMessage: i, errorFallback: a }) => {
32
+ h((e) => new Set(e).add(n));
29
33
  try {
30
- return await t(), !0;
31
- } catch {
32
- return !1;
34
+ return await r(), e.success(i), !0;
35
+ } catch (n) {
36
+ return e.error(t(n) ?? a), !1;
33
37
  } finally {
34
- f((t) => {
35
- let n = new Set(t);
36
- return n.delete(e), n;
38
+ h((e) => {
39
+ let t = new Set(e);
40
+ return t.delete(n), t;
37
41
  });
38
42
  }
39
- }, []), D = o((e) => {
40
- E(e, () => l({ approvalRequestId: e }));
41
- }, [l, E]), O = o((e) => {
42
- m(e), g("");
43
- }, []), k = !!(p && d.has(p)), A = o(() => {
44
- p && !x && E(p, () => u({
45
- approvalRequestId: p,
46
- rejectReason: h
47
- })).then((e) => {
48
- e && m((e) => e === p ? void 0 : e);
43
+ }, []), A = c((e) => {
44
+ w || k(e, {
45
+ decide: () => f({ approvalRequestId: e }),
46
+ successMessage: d.approved,
47
+ errorFallback: d.approveError
49
48
  });
50
49
  }, [
51
- x,
52
- u,
53
- h,
50
+ f,
51
+ w,
52
+ d,
53
+ k
54
+ ]), j = c((e) => {
55
+ _(e), y("");
56
+ }, []), M = !!(g && m.has(g)), N = c(() => {
57
+ g && !w && k(g, {
58
+ decide: () => p({
59
+ approvalRequestId: g,
60
+ rejectReason: v
61
+ }),
62
+ successMessage: d.rejected,
63
+ errorFallback: d.rejectError
64
+ }).then((e) => {
65
+ e && _((e) => e === g ? void 0 : e);
66
+ });
67
+ }, [
68
+ w,
69
+ d,
54
70
  p,
55
- E
56
- ]), j = o(() => {
57
- k || m(void 0);
58
- }, [k]);
71
+ v,
72
+ g,
73
+ k
74
+ ]), P = c(() => {
75
+ M || _(void 0);
76
+ }, [M]);
59
77
  return {
60
- pendingRequestIds: d,
61
- areDecisionsPaused: x,
62
- onApprove: D,
63
- onReject: O,
78
+ pendingRequestIds: m,
79
+ areDecisionsPaused: w,
80
+ onApprove: A,
81
+ onReject: j,
64
82
  rejectDialog: {
65
- open: !!p,
66
- reason: h,
67
- onReasonChange: g,
68
- onConfirm: A,
69
- onCancel: j,
70
- isPending: k,
71
- isConfirmDisabled: x
83
+ open: !!g,
84
+ reason: v,
85
+ onReasonChange: y,
86
+ onConfirm: N,
87
+ onCancel: P,
88
+ isPending: M,
89
+ isConfirmDisabled: w
72
90
  }
73
91
  };
74
92
  }
75
93
  //#endregion
76
- export { l as useApprovalRequestDecisions };
94
+ export { d as useApprovalRequestDecisions };
@@ -5,18 +5,19 @@
5
5
  import { toast as e } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
6
6
  import { isOrganizationOnItsWay as t } from "../../../../shared/data-access/dist/lib/organizationStatus.js";
7
7
  import { useEmbedApi as n } from "../../../../shared/data-access/dist/lib/EmbedApiContext.js";
8
+ import { isApiUnprocessableError as r } from "../../../../shared/data-access/dist/lib/isApiUnprocessableError.js";
8
9
  import "../../../../shared/data-access/dist/index.js";
9
10
  import "../../../../shared/ui/dist/index.js";
10
- import { useAnalyticsTrack as r } from "../../../../shared/feature/dist/lib/analytics/hooks.js";
11
- import { useWidgetConfig as ee, useWidgetError as te, useWidgetLoading as ne } from "../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
11
+ import { useAnalyticsTrack as ee } from "../../../../shared/feature/dist/lib/analytics/hooks.js";
12
+ import { useWidgetConfig as te, useWidgetError as ne, useWidgetLoading as re } from "../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
12
13
  import "../../../../shared/feature/dist/index.js";
13
14
  import { AccountDetailsWidgetAnalyticsEvent as i } from "./index2.js";
14
- import { formatDateParam as re, getDefaultExportDateRange as ie, isExportRangeValid as a, startOfLocalDay as o, triggerCsvDownload as ae, yesterdayLocal as s } from "./index3.js";
15
- import { copyTextToClipboard as oe, formatAmountLabel as c, formatSignedTransactionAmountLabel as se, formatStatementPeriodLabel as ce, formatTransactionDateLabel as le, maskAccountNumber as ue } from "./index4.js";
15
+ import { formatDateParam as a, getDefaultExportDateRange as ie, isExportRangeValid as o, startOfLocalDay as s, triggerCsvDownload as ae, yesterdayLocal as c } from "./index3.js";
16
+ import { copyTextToClipboard as oe, formatAmountLabel as l, formatSignedTransactionAmountLabel as se, formatStatementPeriodLabel as ce, formatTransactionDateLabel as le, maskAccountNumber as ue } from "./index4.js";
16
17
  import { DEFAULT_FEATURE_LABELS as de } from "./index5.js";
17
18
  import { getBankAccountsPermissions as fe } from "./index6.js";
18
19
  import { getStatementsStartDate as pe } from "./index7.js";
19
- import { interpolateLabel as l } from "./index8.js";
20
+ import { interpolateLabel as u } from "./index8.js";
20
21
  import { useBankAccountDetailsQuery as me } from "../../data-access/dist/index2.js";
21
22
  import { useBankAccountStatementsQuery as he } from "../../data-access/dist/index3.js";
22
23
  import { useBankAccountTransactionsQuery as ge } from "../../data-access/dist/index4.js";
@@ -27,7 +28,7 @@ import "../../data-access/dist/index.js";
27
28
  import { DEFAULT_LABELS as be } from "../../ui/dist/index7.js";
28
29
  import { AccountDetailsWidgetUi as xe } from "../../ui/dist/index8.js";
29
30
  import "../../ui/dist/index.js";
30
- import { useCallback as u, useEffect as Se, useMemo as d, useState as f } from "react";
31
+ import { useCallback as d, useEffect as Se, useMemo as f, useState as p } from "react";
31
32
  import { jsx as Ce } from "react/jsx-runtime";
32
33
  //#region ../../libs/tesouro-embedded-components-react/bank-accounts-widget/account-details/feature/dist/index9.js
33
34
  var we = 3e3, Te = 5e3, Ee = [
@@ -35,255 +36,255 @@ var we = 3e3, Te = 5e3, Ee = [
35
36
  25,
36
37
  50
37
38
  ], De = 10, Oe = 6e5, ke = { nickname: "" };
38
- function p({ accountId: p, onBack: Ae, labels: je, featureLabels: Me, isBankingTaglineVisible: Ne = !0, bankLogoSrc: Pe, bankLogoAlt: Fe, bankAddress: Ie, supportTeamUrl: Le }) {
39
- let m = {
39
+ function m({ accountId: m, onBack: Ae, labels: je, featureLabels: Me, isBankingTaglineVisible: Ne = !0, bankLogoSrc: Pe, bankLogoAlt: Fe, bankAddress: Ie, supportTeamUrl: Le }) {
40
+ let h = {
40
41
  ...be,
41
42
  ...je
42
- }, h = {
43
+ }, g = {
43
44
  ...de,
44
45
  ...Me
45
- }, g = r(), { organizationId: Re, widgetToken: ze, initResponse: _ } = ee(), Be = ne(), Ve = t(n().organizationStatus), v = !!te(), y = !!(Re && ze), b = d(() => fe(_?.scopes), [_?.scopes]), x = b.canRead && !!_, S = y && x, C = x && !y, [w, He] = f("transactions"), [Ue, T] = f(!1), [E, D] = f(ke), [We, Ge] = f(!1), [Ke, qe] = f(!1), [Je, Ye] = f(!1), [Xe, Ze] = f(!1), [Qe, $e] = f(!1), [O, k] = f(), [A, j] = f(), [M, et] = f(De), [N, P] = f(() => ({
46
- accountId: p,
46
+ }, _ = ee(), { organizationId: Re, widgetToken: ze, initResponse: v } = te(), Be = re(), Ve = t(n().organizationStatus), y = !!ne(), b = !!(Re && ze), x = f(() => fe(v?.scopes), [v?.scopes]), S = x.canRead && !!v, C = b && S, w = S && !b, [T, He] = p("transactions"), [Ue, E] = p(!1), [D, O] = p(ke), [We, Ge] = p(!1), [Ke, k] = p(!1), [qe, A] = p(!1), [Je, Ye] = p(!1), [Xe, j] = p(!1), [M, N] = p(), [P, F] = p(), [I, Ze] = p(De), [L, R] = p(() => ({
47
+ accountId: m,
47
48
  token: void 0
48
49
  }));
49
- N.accountId !== p && P({
50
- accountId: p,
50
+ L.accountId !== m && R({
51
+ accountId: m,
51
52
  token: void 0
52
53
  });
53
- let tt = N.accountId === p ? N.token : void 0, F = u((e) => {
54
- P((t) => ({
54
+ let Qe = L.accountId === m ? L.token : void 0, z = d((e) => {
55
+ R((t) => ({
55
56
  ...t,
56
57
  token: e
57
58
  }));
58
- }, []), [I, L] = f(() => /* @__PURE__ */ new Set());
59
+ }, []), [B, V] = p(() => /* @__PURE__ */ new Set());
59
60
  Se(() => {
60
- g(i.Mounted);
61
- }, [g]);
62
- let R = me({
63
- id: p,
64
- enabled: S
65
- }), z = ge({
66
- id: p,
67
- enabled: S && w === "transactions",
61
+ _(i.Mounted);
62
+ }, [_]);
63
+ let H = me({
64
+ id: m,
65
+ enabled: C
66
+ }), U = ge({
67
+ id: m,
68
+ enabled: C && T === "transactions",
68
69
  limit: 25,
69
70
  sortBy: "DATE",
70
71
  sortOrder: "DESC"
71
- }), [nt] = f(pe), B = he({
72
- id: p,
73
- startDate: nt,
74
- enabled: S && w === "statements",
75
- limit: M,
76
- pagination_token: tt,
72
+ }), [$e] = p(pe), W = he({
73
+ id: m,
74
+ startDate: $e,
75
+ enabled: C && T === "statements",
76
+ limit: I,
77
+ pagination_token: Qe,
77
78
  category: "STATEMENTS"
78
- }), rt = ye(), it = _e(), at = ve(), { mutate: ot, isPending: st, isError: V, reset: H } = rt, { mutateAsync: U, isPending: ct } = it, { mutateAsync: W } = at, G = x ? R.data : void 0, K = _?.bankName?.trim() ?? "", q = Ie?.trim() || void 0, J = { bankName: K }, lt = d(() => l(m.domesticWireIntro, J), [m.domesticWireIntro, K]), ut = d(() => l(m.domesticWireNote, J), [m.domesticWireNote, K]), dt = d(() => l(m.thingsToKnowBody, J), [m.thingsToKnowBody, K]), ft = G?.nickname?.trim() || h.accountFallback, pt = c(G?.balance), Y = d(() => (z.data?.data ?? []).map((e, t) => ({
79
+ }), et = ye(), tt = _e(), nt = ve(), { mutate: rt, isPending: it, isError: G, reset: K } = et, { mutateAsync: at, isPending: ot } = tt, { mutateAsync: st } = nt, q = S ? H.data : void 0, J = v?.bankName?.trim() ?? "", ct = Ie?.trim() || void 0, Y = { bankName: J }, lt = f(() => u(h.domesticWireIntro, Y), [h.domesticWireIntro, J]), ut = f(() => u(h.domesticWireNote, Y), [h.domesticWireNote, J]), dt = f(() => u(h.thingsToKnowBody, Y), [h.thingsToKnowBody, J]), ft = q?.nickname?.trim() || g.accountFallback, pt = l(q?.balance), mt = f(() => (U.data?.data ?? []).map((e, t) => ({
79
80
  key: `${e.date}-${t}`,
80
81
  descriptionLabel: e.description,
81
82
  dateLabel: le(e.date),
82
83
  amountLabel: se(e.amount, e.direction),
83
84
  amountVariant: e.direction === "CREDIT" ? "positive" : "default",
84
- balanceLabel: c(e.runningBalance)
85
- })), [z.data?.data]), mt = b.canRead && Y.length > 0, X = u((t) => {
86
- if (!y || !b.canRead) return;
85
+ balanceLabel: l(e.runningBalance)
86
+ })), [U.data?.data]), ht = x.canRead && mt.length > 0, gt = d((t) => {
87
+ if (!b || !x.canRead) return;
87
88
  let n = window.open("", "_blank");
88
89
  if (!n) {
89
- e.error(h.viewStatementErrorToast);
90
+ e.error(g.viewStatementErrorToast);
90
91
  return;
91
92
  }
92
- n.opener = null, L((e) => new Set(e).add(t)), W({
93
- id: p,
93
+ n.opener = null, V((e) => new Set(e).add(t)), st({
94
+ id: m,
94
95
  statementId: t
95
96
  }).then((e) => {
96
97
  let t = URL.createObjectURL(e);
97
98
  n.location.href = t, window.setTimeout(() => URL.revokeObjectURL(t), Oe);
98
99
  }).catch(() => {
99
- n.close(), e.error(h.viewStatementErrorToast);
100
+ n.close(), e.error(g.viewStatementErrorToast);
100
101
  }).finally(() => {
101
- L((e) => {
102
+ V((e) => {
102
103
  if (!e.has(t)) return e;
103
104
  let n = new Set(e);
104
105
  return n.delete(t), n;
105
106
  });
106
107
  });
107
108
  }, [
108
- p,
109
- h.viewStatementErrorToast,
110
- y,
111
- b.canRead,
112
- W
113
- ]), ht = d(() => (B.data?.data ?? []).map((e) => {
109
+ m,
110
+ g.viewStatementErrorToast,
111
+ b,
112
+ x.canRead,
113
+ st
114
+ ]), _t = f(() => (W.data?.data ?? []).map((e) => {
114
115
  let t = ce(e.statementDate);
115
116
  return {
116
117
  key: e.statementId,
117
118
  label: t,
118
- viewButtonAriaLabel: l(m.viewStatementButtonAriaLabel, { date: t }),
119
- isViewDisabled: I.has(e.statementId),
120
- onView: () => X(e.statementId)
119
+ viewButtonAriaLabel: u(h.viewStatementButtonAriaLabel, { date: t }),
120
+ isViewDisabled: B.has(e.statementId),
121
+ onView: () => gt(e.statementId)
121
122
  };
122
123
  }), [
123
- B.data?.data,
124
- m.viewStatementButtonAriaLabel,
125
- I,
126
- X
127
- ]), Z = B.data?.nextPaginationToken ?? void 0, Q = B.data?.prevPaginationToken ?? void 0, gt = S && w === "statements" && !!B.data && !B.isError, _t = S && w === "statements" && B.isLoading, vt = S && w === "statements" && B.isError, yt = u(() => {
128
- B.refetch();
129
- }, [B.refetch]), bt = u((e) => {
130
- et(e), F(void 0);
131
- }, []), xt = u(() => {
132
- F(Q);
133
- }, [Q]), St = u(() => {
134
- F(Z);
135
- }, [Z]), Ct = C || !a(O, A), wt = d(() => {
136
- let e = [{ after: s() }];
137
- return A && e.push({ after: o(A) }), e;
138
- }, [A]), Tt = d(() => {
139
- let e = [{ after: s() }];
140
- return O && e.push({ before: o(O) }), e;
141
- }, [O]), Et = u((e) => {
124
+ W.data?.data,
125
+ h.viewStatementButtonAriaLabel,
126
+ B,
127
+ gt
128
+ ]), X = W.data?.nextPaginationToken ?? void 0, Z = W.data?.prevPaginationToken ?? void 0, vt = C && T === "statements" && !!W.data && !W.isError, yt = C && T === "statements" && W.isLoading, bt = C && T === "statements" && W.isError && !r(W.error), xt = d(() => {
129
+ W.refetch();
130
+ }, [W.refetch]), St = d((e) => {
131
+ Ze(e), z(void 0);
132
+ }, []), Ct = d(() => {
133
+ z(Z);
134
+ }, [Z]), wt = d(() => {
135
+ z(X);
136
+ }, [X]), Tt = w || !o(M, P), Et = f(() => {
137
+ let e = [{ after: c() }];
138
+ return P && e.push({ after: s(P) }), e;
139
+ }, [P]), Dt = f(() => {
140
+ let e = [{ after: c() }];
141
+ return M && e.push({ before: s(M) }), e;
142
+ }, [M]), Ot = d((e) => {
142
143
  if (e) {
143
144
  let { startDate: e, endDate: t } = ie();
144
- k(e), j(t);
145
+ N(e), F(t);
145
146
  }
146
- $e(e);
147
- }, []), Dt = u(async () => {
148
- if (!y || !b.canRead || !O || !A || !a(O, A)) return;
149
- $e(!1);
150
- let t = e.loading(h.exportLoadingToast);
147
+ j(e);
148
+ }, []), kt = d(async () => {
149
+ if (!b || !x.canRead || !M || !P || !o(M, P)) return;
150
+ j(!1);
151
+ let t = e.loading(g.exportLoadingToast);
151
152
  try {
152
- let n = await U({
153
- id: p,
154
- startDate: re(O),
155
- endDate: re(A)
153
+ let n = await at({
154
+ id: m,
155
+ startDate: a(M),
156
+ endDate: a(P)
156
157
  });
157
- ae(n.csv, n.filename), e.success(h.exportSuccessToast, {
158
+ ae(n.csv, n.filename), e.success(g.exportSuccessToast, {
158
159
  id: t,
159
160
  duration: we
160
161
  });
161
162
  } catch {
162
- e.error(h.exportErrorToast, {
163
+ e.error(g.exportErrorToast, {
163
164
  id: t,
164
165
  duration: Te
165
166
  });
166
167
  }
167
168
  }, [
168
- p,
169
- U,
170
- A,
171
- O,
172
- h.exportErrorToast,
173
- h.exportLoadingToast,
174
- h.exportSuccessToast,
175
- y,
176
- b.canRead
177
- ]), $ = u(async (t, n) => {
169
+ m,
170
+ at,
171
+ P,
172
+ M,
173
+ g.exportErrorToast,
174
+ g.exportLoadingToast,
175
+ g.exportSuccessToast,
176
+ b,
177
+ x.canRead
178
+ ]), Q = d(async (t, n) => {
178
179
  if (!await oe(t)) return;
179
180
  let r = {
180
- account: h.copyAccountNumberToast,
181
- routing: h.copyRoutingNumberToast,
182
- bankName: h.copyBankNameToast,
183
- bankAddress: h.copyBankAddressToast
181
+ account: g.copyAccountNumberToast,
182
+ routing: g.copyRoutingNumberToast,
183
+ bankName: g.copyBankNameToast,
184
+ bankAddress: g.copyBankAddressToast
184
185
  };
185
186
  if (e.success(r[n]), n === "account") {
186
- qe(!0), window.setTimeout(() => qe(!1), 2e3);
187
+ k(!0), window.setTimeout(() => k(!1), 2e3);
187
188
  return;
188
189
  }
189
- n === "routing" && (Ye(!0), window.setTimeout(() => Ye(!1), 2e3));
190
+ n === "routing" && (A(!0), window.setTimeout(() => A(!1), 2e3));
190
191
  }, [
191
- h.copyAccountNumberToast,
192
- h.copyBankAddressToast,
193
- h.copyBankNameToast,
194
- h.copyRoutingNumberToast
195
- ]), Ot = (e) => {
196
- e && (D({ nickname: G?.nickname?.trim() ?? "" }), H()), T(e);
192
+ g.copyAccountNumberToast,
193
+ g.copyBankAddressToast,
194
+ g.copyBankNameToast,
195
+ g.copyRoutingNumberToast
196
+ ]), $ = (e) => {
197
+ e && (O({ nickname: q?.nickname?.trim() ?? "" }), K()), E(e);
197
198
  };
198
199
  return /* @__PURE__ */ Ce(xe, {
199
- labels: m,
200
+ labels: h,
200
201
  title: ft,
201
- bankDisplayName: K,
202
+ bankDisplayName: J,
202
203
  bankLogoSrc: Pe,
203
204
  bankLogoAlt: Fe,
204
205
  balanceLabel: pt,
205
206
  balanceTestId: "bank-accounts-widget-detail-balance",
206
207
  isBankingTaglineVisible: Ne,
207
- activeTab: w,
208
- transactionRows: Y,
209
- statementRows: ht,
210
- isStatementsLoading: _t,
211
- isStatementsError: vt,
212
- onStatementsRetry: yt,
213
- isStatementsPaginationVisible: gt,
214
- statementsPageSize: M,
208
+ activeTab: T,
209
+ transactionRows: mt,
210
+ statementRows: _t,
211
+ isStatementsLoading: yt,
212
+ isStatementsError: bt,
213
+ onStatementsRetry: xt,
214
+ isStatementsPaginationVisible: vt,
215
+ statementsPageSize: I,
215
216
  statementsPageSizeOptions: Ee,
216
- isStatementsPreviousPageDisabled: !Q,
217
- isStatementsNextPageDisabled: !Z,
218
- onStatementsPageSizeChange: bt,
219
- onStatementsPreviousPageClick: xt,
220
- onStatementsNextPageClick: St,
221
- showExport: mt,
222
- isExportOpen: Qe,
223
- exportStartDate: O,
224
- exportEndDate: A,
225
- isExportDownloading: ct,
226
- isExportDownloadDisabled: Ct,
227
- disabledExportStartDates: wt,
228
- disabledExportEndDates: Tt,
229
- accountNumberLabel: G?.accountNumber ?? "",
230
- maskedAccountNumberLabel: ue(G?.accountNumber ?? ""),
217
+ isStatementsPreviousPageDisabled: !Z,
218
+ isStatementsNextPageDisabled: !X,
219
+ onStatementsPageSizeChange: St,
220
+ onStatementsPreviousPageClick: Ct,
221
+ onStatementsNextPageClick: wt,
222
+ showExport: ht,
223
+ isExportOpen: Xe,
224
+ exportStartDate: M,
225
+ exportEndDate: P,
226
+ isExportDownloading: ot,
227
+ isExportDownloadDisabled: Tt,
228
+ disabledExportStartDates: Et,
229
+ disabledExportEndDates: Dt,
230
+ accountNumberLabel: q?.accountNumber ?? "",
231
+ maskedAccountNumberLabel: ue(q?.accountNumber ?? ""),
231
232
  accountNumberTestId: "bank-accounts-widget-detail-account-number",
232
- wireAccountNumberLabel: G?.accountNumber ?? "",
233
- routingNumberLabel: G?.routingNumber ?? "",
234
- bankAddressLabel: q,
233
+ wireAccountNumberLabel: q?.accountNumber ?? "",
234
+ routingNumberLabel: q?.routingNumber ?? "",
235
+ bankAddressLabel: ct,
235
236
  domesticWireIntroLabel: lt,
236
237
  domesticWireNoteLabel: ut,
237
238
  thingsToKnowBodyLabel: dt,
238
239
  supportTeamHref: Le,
239
240
  isAccountNumberVisible: We,
240
241
  isAccountNumberCopied: Ke,
241
- isRoutingNumberCopied: Je,
242
- isDomesticWireExpanded: Xe,
243
- isLoading: !v && (Ve && !G || Be && !_ || S && (R.isLoading || w === "transactions" && z.isLoading)),
244
- isError: v || S && (R.isError || w === "transactions" && z.isError),
242
+ isRoutingNumberCopied: qe,
243
+ isDomesticWireExpanded: Je,
244
+ isLoading: !y && (Ve && !q || Be && !v || C && (H.isLoading || T === "transactions" && U.isLoading)),
245
+ isError: y || C && (H.isError || T === "transactions" && U.isError),
245
246
  isEditOpen: Ue,
246
- isEditDisabled: !b.canWrite,
247
- isEditError: V,
248
- isSubmitting: st,
249
- isEditSaveDisabled: C,
250
- editForm: E,
251
- canEdit: b.canWrite,
247
+ isEditDisabled: !x.canWrite,
248
+ isEditError: G,
249
+ isSubmitting: it,
250
+ isEditSaveDisabled: w,
251
+ editForm: D,
252
+ canEdit: x.canWrite,
252
253
  onBack: Ae,
253
254
  onTabChange: He,
254
255
  onToggleAccountNumberVisibility: () => Ge((e) => !e),
255
- onCopyAccountNumber: () => void $(G?.accountNumber ?? "", "account"),
256
- onCopyRoutingNumber: () => void $(G?.routingNumber ?? "", "routing"),
257
- onCopyBankName: () => void $(K, "bankName"),
258
- onCopyBankAddress: () => void $(q ?? "", "bankAddress"),
259
- onDomesticWireExpandedChange: Ze,
260
- onEditOpenChange: Ot,
256
+ onCopyAccountNumber: () => void Q(q?.accountNumber ?? "", "account"),
257
+ onCopyRoutingNumber: () => void Q(q?.routingNumber ?? "", "routing"),
258
+ onCopyBankName: () => void Q(J, "bankName"),
259
+ onCopyBankAddress: () => void Q(ct ?? "", "bankAddress"),
260
+ onDomesticWireExpandedChange: Ye,
261
+ onEditOpenChange: $,
261
262
  onEditFormChange: (e) => {
262
- V && H(), D(e);
263
+ G && K(), O(e);
263
264
  },
264
265
  onEditSubmit: () => {
265
- if (!y || !b.canWrite) return;
266
- let t = E.nickname.trim();
267
- t && ot({
268
- path: { id: p },
266
+ if (!b || !x.canWrite) return;
267
+ let t = D.nickname.trim();
268
+ t && rt({
269
+ path: { id: m },
269
270
  body: { nickname: t }
270
271
  }, {
271
272
  onSuccess: () => {
272
- g(i.AccountUpdated, { accountId: p }), e.success(h.editSuccessToast), T(!1);
273
+ _(i.AccountUpdated, { accountId: m }), e.success(g.editSuccessToast), E(!1);
273
274
  },
274
275
  onError: () => {
275
- e.error(h.editErrorToast);
276
+ e.error(g.editErrorToast);
276
277
  }
277
278
  });
278
279
  },
279
- onEditNicknameClick: () => Ot(!0),
280
- onExportOpenChange: Et,
281
- onExportStartDateChange: k,
282
- onExportEndDateChange: j,
280
+ onEditNicknameClick: () => $(!0),
281
+ onExportOpenChange: Ot,
282
+ onExportStartDateChange: N,
283
+ onExportEndDateChange: F,
283
284
  onExportDownload: () => {
284
- Dt();
285
+ kt();
285
286
  }
286
287
  });
287
288
  }
288
289
  //#endregion
289
- export { p as AccountDetailsWidget };
290
+ export { m as AccountDetailsWidget };
@@ -7,6 +7,7 @@ var e = {
7
7
  failedCaption: (e) => `${e} failed to upload`,
8
8
  tooManyFilesError: (e) => `You can only upload up to ${e} files at a time`,
9
9
  remainingCapacityError: (e) => e === 0 ? "Wait for the current uploads to finish before adding more files" : `You can upload ${e} more ${e === 1 ? "file" : "files"} right now`,
10
+ fileTooLargeError: (e) => `Each file must be ${e} MB or smaller`,
10
11
  billDeletedError: "This bill was already deleted"
11
12
  };
12
13
  //#endregion
@@ -23,110 +23,115 @@ function g({ onOpenBill: g, labels: _ } = {}) {
23
23
  let v = {
24
24
  ...s,
25
25
  ..._
26
- }, y = _?.tooManyFilesError ?? s.tooManyFilesError, b = _?.remainingCapacityError ?? s.remainingCapacityError, { client: x, organizationId: S, authEpoch: C, organizationStatus: w } = r(), T = h(), E = f(() => o(S), [S]), D = l(), [O, k] = p(!1), { data: A = [] } = m({
27
- queryKey: E,
28
- queryFn: () => T.getQueryData(E) ?? [],
26
+ }, y = _?.tooManyFilesError ?? s.tooManyFilesError, b = _?.remainingCapacityError ?? s.remainingCapacityError, x = _?.fileTooLargeError ?? s.fileTooLargeError, { client: S, organizationId: C, authEpoch: w, organizationStatus: T } = r(), E = h(), D = f(() => o(C), [C]), O = l(), [k, A] = p(!1), { data: j = [] } = m({
27
+ queryKey: D,
28
+ queryFn: () => E.getQueryData(D) ?? [],
29
29
  staleTime: Infinity,
30
30
  gcTime: Infinity,
31
31
  initialData: []
32
- }), j = u((e, t) => {
33
- T.setQueryData(E, (n) => (n ?? []).map((n) => n.localId === e ? {
32
+ }), M = u((e, t) => {
33
+ E.setQueryData(D, (n) => (n ?? []).map((n) => n.localId === e ? {
34
34
  ...n,
35
35
  ...t
36
36
  } : n));
37
- }, [T, E]), M = u((e) => {
38
- T.setQueryData(E, (t) => (t ?? []).filter((t) => t.localId !== e));
39
- }, [T, E]), N = u((t) => {
40
- let n = (T.getQueryData(E) ?? []).filter((e) => e.status === "uploading").length;
37
+ }, [E, D]), N = u((e) => {
38
+ E.setQueryData(D, (t) => (t ?? []).filter((t) => t.localId !== e));
39
+ }, [E, D]), P = u((t) => {
40
+ let n = (E.getQueryData(D) ?? []).filter((e) => e.status === "uploading").length;
41
41
  if (t.length + n > 10) {
42
42
  e.error(n > 0 ? b(10 - n) : y(10));
43
43
  return;
44
44
  }
45
- k(!1);
45
+ if (t.some((e) => e.size > 20971520)) {
46
+ e.error(x(20));
47
+ return;
48
+ }
49
+ A(!1);
46
50
  for (let e of t) {
47
51
  let t = crypto.randomUUID();
48
- T.setQueryData(E, (n) => [...n ?? [], {
52
+ E.setQueryData(D, (n) => [...n ?? [], {
49
53
  localId: t,
50
54
  fileName: e.name,
51
55
  status: "uploading"
52
- }]), D.mutateAsync({ file: e }).then((e) => j(t, { payableId: e?.id })).catch(() => j(t, { status: "failed" }));
56
+ }]), O.mutateAsync({ file: e }).then((e) => M(t, { payableId: e?.id })).catch(() => M(t, { status: "failed" }));
53
57
  }
54
58
  }, [
55
- j,
56
- T,
59
+ x,
60
+ M,
57
61
  E,
62
+ D,
58
63
  b,
59
64
  y,
60
- D
61
- ]), P = c({ payableIds: A.filter((e) => e.status === "uploading" && e.payableId).map((e) => e.payableId) });
65
+ O
66
+ ]), F = c({ payableIds: j.filter((e) => e.status === "uploading" && e.payableId).map((e) => e.payableId) });
62
67
  d(() => {
63
68
  let e = /* @__PURE__ */ new Set();
64
- for (let t of P) if (t.suspectedDuplicateOf.length !== 0) {
69
+ for (let t of F) if (t.suspectedDuplicateOf.length !== 0) {
65
70
  e.add(t.payableId);
66
71
  for (let n of t.suspectedDuplicateOf) e.add(n);
67
72
  }
68
- for (let { payableId: t, ocrStatus: n, isError: r } of P) {
69
- let i = A.find((e) => e.payableId === t && e.status === "uploading");
70
- i && (n === "success" ? j(i.localId, { status: e.has(t) ? "duplicate" : "ready" }) : (r || n === "error" || n === "canceled") && j(i.localId, { status: "failed" }));
73
+ for (let { payableId: t, ocrStatus: n, isError: r } of F) {
74
+ let i = j.find((e) => e.payableId === t && e.status === "uploading");
75
+ i && (n === "success" ? M(i.localId, { status: e.has(t) ? "duplicate" : "ready" }) : (r || n === "error" || n === "canceled") && M(i.localId, { status: "failed" }));
71
76
  }
72
- for (let t of A) t.status === "ready" && t.payableId && e.has(t.payableId) && j(t.localId, { status: "duplicate" });
77
+ for (let t of j) t.status === "ready" && t.payableId && e.has(t.payableId) && M(t.localId, { status: "duplicate" });
73
78
  }, [
74
- A,
75
- P,
76
- j
79
+ j,
80
+ F,
81
+ M
77
82
  ]);
78
- let F = A.filter((e) => e.status === "uploading"), I = A.filter((e) => e.status === "ready"), L = A.filter((e) => e.status === "duplicate"), R = A.filter((e) => e.status === "failed"), z = (r) => ({
83
+ let I = j.filter((e) => e.status === "uploading"), L = j.filter((e) => e.status === "ready"), R = j.filter((e) => e.status === "duplicate"), z = j.filter((e) => e.status === "failed"), B = (r) => ({
79
84
  id: r.localId,
80
85
  fileName: r.fileName,
81
86
  status: r.status,
82
87
  onOpen: (r.status === "ready" || r.status === "duplicate") && r.payableId && g ? () => {
83
88
  let o = r.payableId;
84
- T.fetchQuery({
89
+ E.fetchQuery({
85
90
  ...n(t({
86
- client: x,
87
- headers: i(S),
91
+ client: S,
92
+ headers: i(C),
88
93
  path: { payable_id: o }
89
94
  }), {
90
- authEpoch: C,
91
- organizationStatus: w
95
+ authEpoch: w,
96
+ organizationStatus: T
92
97
  }),
93
98
  retry: !1
94
99
  }).catch((e) => {
95
100
  if (a(e)) return "deleted";
96
101
  }).then((t) => {
97
- t === "deleted" ? e.error(v.billDeletedError) : g(o), M(r.localId);
102
+ t === "deleted" ? e.error(v.billDeletedError) : g(o), N(r.localId);
98
103
  });
99
104
  } : void 0
100
- }), B = F.length ? [{
105
+ }), V = I.length ? [{
101
106
  id: "in-progress",
102
- items: A.map(z)
107
+ items: j.map(B)
103
108
  }] : [
104
- ...I.length ? [{
109
+ ...L.length ? [{
105
110
  id: "ready",
106
- caption: v.readyCaption(I.length),
107
- items: I.map(z)
111
+ caption: v.readyCaption(L.length),
112
+ items: L.map(B)
108
113
  }] : [],
109
- ...L.length ? [{
114
+ ...R.length ? [{
110
115
  id: "duplicate",
111
- caption: v.duplicateCaption(L.length),
112
- items: L.map(z)
116
+ caption: v.duplicateCaption(R.length),
117
+ items: R.map(B)
113
118
  }] : [],
114
- ...R.length ? [{
119
+ ...z.length ? [{
115
120
  id: "failed",
116
- caption: v.failedCaption(R.length),
117
- items: R.map(z)
121
+ caption: v.failedCaption(z.length),
122
+ items: z.map(B)
118
123
  }] : []
119
- ], V = I.length + L.length, H = F.length ? v.uploadingSummary(A.length) : V ? v.completeSummary(V) : v.failedCaption(R.length), U = u(() => {
120
- T.setQueryData(E, []);
121
- }, [T, E]);
124
+ ], H = L.length + R.length, U = I.length ? v.uploadingSummary(j.length) : H ? v.completeSummary(H) : v.failedCaption(z.length), W = u(() => {
125
+ E.setQueryData(D, []);
126
+ }, [E, D]);
122
127
  return {
123
- enqueue: N,
124
- sections: B,
125
- summaryLabel: H,
126
- collapsed: O,
127
- onToggleCollapsed: u(() => k((e) => !e), []),
128
- onClose: U,
129
- isVisible: A.length > 0
128
+ enqueue: P,
129
+ sections: V,
130
+ summaryLabel: U,
131
+ collapsed: k,
132
+ onToggleCollapsed: u(() => A((e) => !e), []),
133
+ onClose: W,
134
+ isVisible: j.length > 0
130
135
  };
131
136
  }
132
137
  //#endregion
@@ -1,5 +1,5 @@
1
1
  //#region ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js
2
- var e = "@tesouro/embedded-components-react", t = "0.9.43", n = "9668341fe5f04f3088135bcce7a51a576e5b6661", r = Object.freeze({
2
+ var e = "@tesouro/embedded-components-react", t = "0.9.45", n = "0d9dec8b8927b2abd568eb61986dd26ca14843b6", r = Object.freeze({
3
3
  library_name: e,
4
4
  library_version: t,
5
5
  library_sha: n
@@ -0,0 +1,7 @@
1
+ //#region ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/expectedApiUnprocessable.js
2
+ var e = /* @__PURE__ */ new Set(["GET /embedded-banking/v1/bank-accounts/{id}/statements"]);
3
+ function t(t, n, r) {
4
+ return t === 422 && n !== void 0 && r !== void 0 && e.has(`${n.toUpperCase()} ${r}`);
5
+ }
6
+ //#endregion
7
+ export { t as isExpectedApiUnprocessable };
@@ -3,65 +3,68 @@ import "../../../../data-access/dist/index.js";
3
3
  import { EmbeddedAnalyticsEvent as t, MUTATION_METHODS as n } from "./events.js";
4
4
  import { captureExceptionWithContext as r, trackWithContext as i } from "./runtime.js";
5
5
  import { isExpectedApiNotFound as a } from "./expectedApiNotFound.js";
6
- import { extractTraceIdFromHeaders as o, resolveTraceId as s } from "./traceId.js";
6
+ import { isExpectedApiUnprocessable as o } from "./expectedApiUnprocessable.js";
7
+ import { extractTraceIdFromHeaders as s, resolveTraceId as c } from "./traceId.js";
7
8
  //#region ../../libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/interceptor.js
8
- function c(c, m) {
9
- let h = /* @__PURE__ */ new WeakMap(), g = /* @__PURE__ */ new Set();
10
- return c.interceptors.request.use((e) => (h.set(e, f()), e)), c.interceptors.response.use((e, r, a) => {
9
+ function l(l, h) {
10
+ let g = /* @__PURE__ */ new WeakMap(), _ = /* @__PURE__ */ new Set();
11
+ return l.interceptors.request.use((e) => (g.set(e, p()), e)), l.interceptors.response.use((e, r, a) => {
11
12
  if (!e.ok || !n.has(r.method.toUpperCase())) return e;
12
- let s = o(e);
13
+ let o = s(e);
13
14
  return i(t.ApiRequestCompleted, {
14
15
  method: r.method,
15
16
  route: a.url,
16
17
  status: e.status,
17
- duration_ms: p(h.get(r)),
18
- ...s ? { trace_id: s } : {}
19
- }, m.current), e;
20
- }), c.interceptors.error.use((n, o, c, f) => {
21
- if (d(n, c)) return n;
22
- let _ = s(o, n);
23
- if (i(t.ApiRequestFailed, {
24
- method: c?.method ?? f.method,
25
- route: f.url,
26
- status: o?.status,
27
- duration_ms: c ? p(h.get(c)) : void 0,
28
- error_kind: o ? "http" : "network",
18
+ duration_ms: m(g.get(r)),
19
+ ...o ? { trace_id: o } : {}
20
+ }, h.current), e;
21
+ }), l.interceptors.error.use((n, s, l, p) => {
22
+ if (f(n, l)) return n;
23
+ let v = c(s, n);
24
+ i(t.ApiRequestFailed, {
25
+ method: l?.method ?? p.method,
26
+ route: p.url,
27
+ status: s?.status,
28
+ duration_ms: l ? m(g.get(l)) : void 0,
29
+ error_kind: s ? "http" : "network",
29
30
  error_name: n instanceof Error ? n.name : "unknown",
30
- ..._ ? { trace_id: _ } : {}
31
- }, m.current), a(o?.status, c?.method ?? f.method, f.url)) return n;
32
- if (o?.status === 401) {
33
- let t = e(u(c));
34
- if (g.has(t)) return n;
35
- g.add(t);
31
+ ...v ? { trace_id: v } : {}
32
+ }, h.current);
33
+ let y = l?.method ?? p.method;
34
+ if (a(s?.status, y, p.url) || o(s?.status, y, p.url)) return n;
35
+ if (s?.status === 401) {
36
+ let t = e(d(l));
37
+ if (_.has(t)) return n;
38
+ _.add(t);
36
39
  }
37
- return r(l(o, f.url), {
38
- method: c?.method ?? f.method,
39
- route: f.url,
40
- status: o?.status,
41
- error_kind: o ? "http" : "network",
40
+ return r(u(s, p.url), {
41
+ method: l?.method ?? p.method,
42
+ route: p.url,
43
+ status: s?.status,
44
+ error_kind: s ? "http" : "network",
42
45
  error_name: n instanceof Error ? n.name : "unknown",
43
- ..._ ? { trace_id: _ } : {}
44
- }, m.current), n;
45
- }), c;
46
+ ...v ? { trace_id: v } : {}
47
+ }, h.current), n;
48
+ }), l;
46
49
  }
47
- function l(e, t) {
50
+ function u(e, t) {
48
51
  let n = /* @__PURE__ */ Error(`API request failed (${e?.status ?? "network"}): ${t ?? "unknown route"}`);
49
52
  return n.name = "ApiRequestError", n;
50
53
  }
51
- function u(e) {
54
+ function d(e) {
52
55
  let t = e?.headers.get("X-Widget-Token");
53
56
  if (t) return t;
54
57
  let n = e?.headers.get("Authorization");
55
58
  return n?.startsWith("Bearer ") ? n.slice(7) : void 0;
56
59
  }
57
- function d(e, t) {
60
+ function f(e, t) {
58
61
  return t?.signal.aborted ? !0 : e instanceof Error && e.name === "AbortError";
59
62
  }
60
- function f() {
63
+ function p() {
61
64
  return typeof performance < "u" ? performance.now() : Date.now();
62
65
  }
63
- function p(e) {
64
- return e === void 0 ? void 0 : Math.round(f() - e);
66
+ function m(e) {
67
+ return e === void 0 ? void 0 : Math.round(p() - e);
65
68
  }
66
69
  //#endregion
67
- export { c as attachAnalyticsInterceptors };
70
+ export { l as attachAnalyticsInterceptors };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tesouro/embedded-components-react",
3
- "version": "0.9.43",
3
+ "version": "0.9.45",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "sideEffects": [