@tesouro/embedded-components-react 0.9.24 → 0.9.26

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 (118) hide show
  1. package/README.md +13 -0
  2. package/dist/index.css +93 -55
  3. package/dist/index.d.ts +53 -3
  4. package/dist/index.js +9 -7
  5. package/dist/lib/AccountsQuickViewWidget.d.ts +650 -0
  6. package/dist/lib/AccountsQuickViewWidget.js +4 -0
  7. package/dist/libs/tesouro-embedded-components-react/accounts-quick-view-widget/data-access/dist/index.js +2 -0
  8. package/dist/libs/tesouro-embedded-components-react/accounts-quick-view-widget/data-access/dist/index2.js +21 -0
  9. package/dist/libs/tesouro-embedded-components-react/accounts-quick-view-widget/feature/dist/index.js +3 -0
  10. package/dist/libs/tesouro-embedded-components-react/accounts-quick-view-widget/feature/dist/lib/AccountsQuickViewWidget/AccountsQuickViewWidgetFeature.js +82 -0
  11. package/dist/libs/tesouro-embedded-components-react/accounts-quick-view-widget/feature/dist/lib/AccountsQuickViewWidget/labels.js +10 -0
  12. package/dist/libs/tesouro-embedded-components-react/accounts-quick-view-widget/feature/dist/lib/AccountsQuickViewWidget/testIds.js +8 -0
  13. package/dist/libs/tesouro-embedded-components-react/accounts-quick-view-widget/feature/dist/lib/accountsBalanceSummary/summarizeAccountBalances.js +22 -0
  14. package/dist/libs/tesouro-embedded-components-react/accounts-quick-view-widget/feature/dist/lib/accountsBalanceSummary/useAccountsBalanceSummary.js +27 -0
  15. package/dist/libs/tesouro-embedded-components-react/accounts-quick-view-widget/feature/dist/lib/analytics/events.js +4 -0
  16. package/dist/libs/tesouro-embedded-components-react/accounts-quick-view-widget/ui/dist/index.js +3 -0
  17. package/dist/libs/tesouro-embedded-components-react/accounts-quick-view-widget/ui/dist/index2.js +10 -0
  18. package/dist/libs/tesouro-embedded-components-react/accounts-quick-view-widget/ui/dist/index3.js +31 -0
  19. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index.js +7 -7
  20. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index10.js +14 -8
  21. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index11.js +59 -7
  22. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index12.js +10 -65
  23. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index13.js +9 -10
  24. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index14.js +7 -8
  25. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index15.js +9 -7
  26. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index16.js +29 -11
  27. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index17.js +24 -24
  28. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index18.js +14 -22
  29. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index19.js +155 -14
  30. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index20.js +13 -157
  31. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index21.js +18 -12
  32. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index22.js +32 -15
  33. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index23.js +99 -39
  34. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index24.js +69 -85
  35. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index25.js +3 -85
  36. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index26.js +57 -4
  37. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index27.js +114 -57
  38. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index28.js +190 -111
  39. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index29.js +75 -187
  40. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index3.js +35 -15
  41. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index30.js +67 -75
  42. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index31.js +111 -69
  43. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index32.js +461 -108
  44. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index33.js +102 -452
  45. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index34.js +12 -116
  46. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index35.js +85 -12
  47. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index36.js +67 -73
  48. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index37.js +231 -73
  49. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index38.js +38 -232
  50. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index39.js +245 -38
  51. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index4.js +169 -38
  52. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index40.js +21 -252
  53. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index41.js +534 -23
  54. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index42.js +4 -542
  55. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index43.js +43 -4
  56. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index44.js +236 -39
  57. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index45.js +3 -240
  58. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index46.js +6 -3
  59. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index47.js +63 -4
  60. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index48.js +1 -65
  61. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index5.js +82 -225
  62. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index6.js +45 -83
  63. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index7.js +4 -47
  64. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index8.js +13 -4
  65. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index9.js +8 -13
  66. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index14.js +1 -1
  67. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index15.js +1 -1
  68. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index31.js +1 -1
  69. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index33.js +1 -1
  70. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index34.js +2 -2
  71. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index36.js +5 -5
  72. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index37.js +138 -155
  73. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index48.js +1 -1
  74. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index49.js +1 -1
  75. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/ui/dist/index5.js +1 -1
  76. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-upload/ui/dist/index3.js +2 -2
  77. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index16.js +48 -43
  78. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index17.js +219 -207
  79. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index4.js +13 -13
  80. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index6.js +5 -4
  81. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/feature/dist/index7.js +6 -6
  82. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index18.js +1 -5
  83. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index2.js +1 -1
  84. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index20.js +278 -322
  85. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bills-list/ui/dist/index3.js +1 -1
  86. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidget/BillPayWidget.js +1 -1
  87. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/lib/BillPayWidget/BillsTab.js +1 -1
  88. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/mocks/labels.js +1 -1
  89. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/pay-bill/ui/dist/index5.js +1 -1
  90. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/pay-bill/ui/dist/index6.js +1 -1
  91. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index.js +18 -16
  92. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index10.js +2 -41
  93. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index11.js +4 -2
  94. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index12.js +39 -9
  95. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index13.js +2 -78
  96. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index14.js +11 -0
  97. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index15.js +78 -2
  98. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index17.js +2 -4
  99. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index18.js +25 -26
  100. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index19.js +4 -2
  101. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index20.js +28 -5
  102. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index21.js +2 -34
  103. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index22.js +7 -2
  104. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index23.js +34 -0
  105. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index24.js +2 -0
  106. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index6.js +31 -15
  107. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index7.js +1 -54
  108. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index8.js +18 -2
  109. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index9.js +52 -2
  110. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  111. package/dist/libs/tesouro-embedded-components-react/shared/quick-view/ui/dist/index.js +3 -0
  112. package/dist/libs/tesouro-embedded-components-react/shared/quick-view/ui/dist/index2.js +8 -0
  113. package/dist/libs/tesouro-embedded-components-react/shared/quick-view/ui/dist/index3.js +100 -0
  114. package/dist/libs/tesouro-embedded-components-react/shared/util/dist/lib/theme/themeTokens.js +1 -1
  115. package/dist/packages/shared-ui-shadcn/dist/index.js +4696 -4681
  116. package/package.json +1 -1
  117. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index49.js +0 -1
  118. package/dist/libs/tesouro-embedded-components-react/bill-pay-widget/ui/dist/index16.js +0 -29
@@ -2,116 +2,469 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { Button as e } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
6
- import { getStateOptions as t } from "../../../../shared/util/dist/lib/usStates.js";
7
- import "../../../../shared/util/dist/index.js";
8
- import { AchFieldGroup as n } from "../../../../shared/counterpart-management/ui/dist/index5.js";
9
- import { CounterpartFormFields as r, countErrors as i, useFocusFirstInvalidField as a } from "../../../../shared/counterpart-management/ui/dist/index10.js";
10
- import "../../../../shared/counterpart-management/ui/dist/index.js";
11
- import { VendorSearchCombobox as o } from "../../ui/dist/index24.js";
12
- import "../../ui/dist/index.js";
13
- import { mergeVendorInlineFormLabels as s } from "./index29.js";
5
+ import { toast as e } from "../../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import { hasAnyScope as t } from "../../../../shared/data-access/dist/lib/hasAnyScope.js";
7
+ import { Scope as ee } from "../../../../shared/data-access/dist/lib/scopes.js";
8
+ import "../../../../shared/data-access/dist/index.js";
9
+ import "../../../../shared/ui/dist/index.js";
10
+ import { useWidgetConfig as n } from "../../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
11
+ import "../../../../shared/feature/dist/index.js";
12
+ import { VENDOR_SECTION_PROPS_LABELS_EN as r } from "./index28.js";
13
+ import { usePayableSuggestionsQuery as i } from "../../data-access/dist/index19.js";
14
+ import "../../data-access/dist/index.js";
15
+ import { resolvePaymentInstructionsGestures as a } from "./index14.js";
16
+ import { COUNTERPART_MESSAGE_LABELS_EN as o } from "../../../../shared/counterpart-management/feature/dist/lib/labels.js";
17
+ import { counterpartFormBankAccountToCreatePayload as te, counterpartFormBankAccountToUpdatePayload as ne, getAchInstructions as s, getCounterpartEmail as re, getCounterpartName as ie, getPayableAchInstructions as ae, hasCounterpartFormErrors as oe, isAchCompatibleBankAccount as c, resolveCounterpartBankAccountWrite as se, validateAchFormValues as ce, validateCounterpartForm as le } from "../../../../shared/counterpart-management/feature/dist/lib/helpers.js";
18
+ import { useCounterpartsQuery as ue } from "../../../../shared/counterpart-management/data-access/dist/index3.js";
19
+ import { useCreateCounterpartBankAccountMutation as de, useUpdateCounterpartBankAccountMutation as fe } from "../../../../shared/counterpart-management/data-access/dist/index4.js";
20
+ import { useCounterpartDetails as pe } from "../../../../shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js";
21
+ import { useCounterpartForm as me } from "../../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
14
22
  import "../../../../shared/counterpart-management/feature/dist/index.js";
15
- import { useMemo as c } from "react";
16
- import { jsx as l, jsxs as u } from "react/jsx-runtime";
23
+ import { buildVendorPrefill as he, canAutoCreateVendor as ge, toCounterpartRawData as _e } from "./index30.js";
24
+ import { VendorInlineForm as ve } from "./index31.js";
25
+ import { useCallback as l, useEffect as u, useLayoutEffect as ye, useMemo as d, useRef as f, useState as p } from "react";
26
+ import { jsx as be } from "react/jsx-runtime";
17
27
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/bill-detail/feature/dist/index32.js
18
- function d({ mode: d, values: f, errors: p, onChange: m, onAddressChange: h, onCancel: g, onSave: _, isSaving: v = !1, search: y, paymentInstructions: b, labels: x }) {
19
- let S = c(() => s(x), [x]), C = c(() => t(), []), w = a(p ?? {}), T = i({
20
- ...p,
21
- form: void 0,
22
- bankAccount: void 0
23
- }) + i(b?.errors), E = y?.query.trim() ?? "", D = f.entityType === "individual" ? `${f.firstName} ${f.lastName}`.trim() : f.legalName, O = y && d === "create" ? /* @__PURE__ */ l(o, {
24
- ...y,
25
- onAddVendor: E && E !== D.trim() ? y.onAddVendor : void 0,
26
- selectedLabel: D,
27
- badge: S.newVendorBadge,
28
- helperText: S.unmatchedVendorHelper,
29
- resultsHeading: S.resultsHeading,
30
- addVendorDescription: S.addAsNewVendorDescription,
31
- labels: {
32
- fieldLabel: S.vendorFieldLabel,
33
- addVendorAction: S.addAsNewVendor(E)
34
- }
35
- }) : null;
36
- return /* @__PURE__ */ u("div", {
37
- ref: w,
38
- className: "ttw:flex ttw:flex-col ttw:gap-4",
39
- children: [O, /* @__PURE__ */ u("div", {
40
- className: "ttw:flex ttw:flex-col ttw:gap-6 ttw:rounded-lg ttw:border ttw:border-primary ttw:bg-surface-subtle ttw:p-6 ttw:[&_[data-slot=input]]:bg-background ttw:[&_[data-slot=select-trigger]]:bg-background",
41
- children: [
42
- /* @__PURE__ */ u("div", {
43
- className: "ttw:flex ttw:items-baseline ttw:justify-between ttw:gap-2",
44
- children: [/* @__PURE__ */ l("p", {
45
- className: "ttw:text-base ttw:font-semibold ttw:text-foreground",
46
- children: d === "edit" ? S.editTitle : S.createTitle
47
- }), T > 0 ? /* @__PURE__ */ l("p", {
48
- className: "ttw:text-sm ttw:text-destructive",
49
- children: S.fieldsNeedAttention(T)
50
- }) : null]
51
- }),
52
- y && d === "edit" ? /* @__PURE__ */ l(o, {
53
- ...y,
54
- labels: { fieldLabel: S.switchVendorFieldLabel }
55
- }) : null,
56
- /* @__PURE__ */ l(r, {
57
- mode: d,
58
- counterpartMode: "vendor",
59
- values: f,
60
- errors: p,
61
- stateOptions: C,
62
- onChange: m,
63
- onAddressChange: h,
64
- sections: {
65
- entityType: !0,
66
- profileHeading: !1,
67
- addressHeading: !1,
68
- title: !1,
69
- taxId: !1,
70
- address: !0,
71
- bankAccount: !1
72
- },
73
- labels: { businessNameLabel: S.nameLabel }
74
- }),
75
- b ? /* @__PURE__ */ u("div", {
76
- className: "ttw:flex ttw:flex-col ttw:gap-3",
77
- children: [/* @__PURE__ */ u("div", {
78
- className: "ttw:flex ttw:flex-col ttw:gap-1",
79
- children: [/* @__PURE__ */ l("p", {
80
- className: "ttw:text-sm ttw:font-semibold ttw:text-foreground",
81
- children: S.paymentInstructionsHeading
82
- }), /* @__PURE__ */ l("p", {
83
- className: "ttw:text-sm ttw:text-muted-foreground",
84
- children: b.isExtracted ? S.paymentInstructionsExtracted : S.paymentInstructionsDescription
85
- })]
86
- }), /* @__PURE__ */ l(n, {
87
- idPrefix: "vendor-inline-ach",
88
- values: b.values,
89
- errors: b.errors,
90
- onChange: b.onChange,
91
- labels: S.ach
92
- })]
93
- }) : null,
94
- /* @__PURE__ */ u("div", {
95
- className: "ttw:flex ttw:justify-end ttw:gap-2",
96
- children: [/* @__PURE__ */ l(e, {
97
- type: "button",
98
- variant: "outline",
99
- onClick: g,
100
- "aria-label": S.cancelAriaLabel,
101
- disabled: v,
102
- children: S.cancel
103
- }), _ ? /* @__PURE__ */ l(e, {
104
- type: "button",
105
- onClick: _,
106
- "aria-label": S.saveAriaLabel,
107
- loading: v,
108
- disabled: v,
109
- children: S.save
110
- }) : null]
111
- })
112
- ]
113
- })]
28
+ var xe = 10, Se = 300, m = {
29
+ accountHolderName: "",
30
+ routingNumber: "",
31
+ accountNumber: ""
32
+ };
33
+ function Ce(e) {
34
+ return {
35
+ accountHolderName: e.account_holder_name ?? "",
36
+ routingNumber: e.routing_number ?? "",
37
+ accountNumber: e.account_number ?? ""
38
+ };
39
+ }
40
+ function h(e, t) {
41
+ return e.accountHolderName.trim() === t.accountHolderName.trim() && e.routingNumber.trim() === t.routingNumber.trim() && e.accountNumber.trim() === t.accountNumber.trim();
42
+ }
43
+ function we(e, t) {
44
+ return e?.find((e) => e.id === t && c(e)) ?? s(e);
45
+ }
46
+ function g({ payableId: s, counterpartId: c, payableCounterpartId: g, payableCounterpartBankAccountId: Te, isVendorKnown: Ee = !0, onCounterpartChange: De, requiredError: Oe, extractedVendor: _, readOnly: v = !1, canEditVendor: y = !0, canEditPaymentInstructions: ke = !0, canAddPaymentInstructions: Ae = !0, confirmDiscard: b = (e) => e(), labels: x }) {
47
+ let S = d(() => ({
48
+ ...r,
49
+ ...x
50
+ }), [x]), je = x?.messages, C = d(() => ({
51
+ ...o,
52
+ ...je
53
+ }), [je]), { initResponse: Me } = n(), Ne = t(Me?.scopes, [ee.CounterpartReadOrg]), [w, Pe] = p(""), [T, Fe] = p(""), Ie = f(T), [E, Le] = p(), [Re, ze] = p("none"), [Be, Ve] = p(), [He, D] = p(!1), [O, k] = p(!1), [A, Ue] = p(m), j = f(A);
54
+ j.current = A;
55
+ let M = f(m), [We, N] = p(), [Ge, Ke] = p(), qe = Ge?.bankAccountId, P = f(void 0), Je = f(c), [Ye, Xe] = p(!1), [Ze, Qe] = p(!1), F = f(void 0), I = l(() => {
56
+ k(!1), Ue(m), M.current = m, N(void 0);
57
+ }, []), L = l((e) => {
58
+ Xe(!0), De(e);
59
+ }, [De]), $e = i(s, { enabled: !v && !!s && !c && !g }), R = $e.data?.suggested_counterpart?.id, et = _?.name;
60
+ u(() => {
61
+ !v && !Ye && !c && !g && R && L(R);
62
+ }, [
63
+ c,
64
+ g,
65
+ v,
66
+ Ye,
67
+ R,
68
+ L
69
+ ]), u(() => {
70
+ Je.current !== c && (Je.current = c, I(), Ke((e) => e?.counterpartId === c ? e : void 0));
71
+ }, [c, I]), u(() => {
72
+ let e = setTimeout(() => {
73
+ Fe(w.trim());
74
+ }, Se);
75
+ return () => clearTimeout(e);
76
+ }, [w]);
77
+ let z = d(() => he(_), [_]), B = z?.bankAccount, tt = d(() => ge(_), [_]), nt = E === "create" ? !h(A, B ?? m) : O && !h(A, M.current), rt = !v && (E === "edit" || E === "create" && !!z), V = ue({
78
+ sort: "counterpart_name",
79
+ order: "asc",
80
+ limit: xe,
81
+ counterpart_name__icontains: T || void 0,
82
+ is_vendor: !0,
83
+ enabled: (rt || !v && !E && !c) && Ee && Ne
114
84
  });
85
+ u(() => {
86
+ V.isPlaceholderData || (Ie.current = T);
87
+ }, [T, V.isPlaceholderData]);
88
+ let it = V.isPlaceholderData && Ie.current !== T, H = pe({
89
+ selectedId: c,
90
+ enabled: Ne
91
+ }), at = de(), ot = fe(), U = me({
92
+ view: Re,
93
+ setView: ze,
94
+ selectedId: Be,
95
+ setSelectedId: Ve,
96
+ messages: C,
97
+ counterpartType: "vendor",
98
+ counterpart: H.counterpart,
99
+ primaryAddress: H.primaryAddress,
100
+ includeBankAccount: !1
101
+ }), { openCreate: st, openEdit: ct, close: lt, setValues: W, submit: ut, values: dt } = U, G = d(() => {
102
+ let e = H.counterpart;
103
+ if (!e) return;
104
+ if (H.isBankAccountsLoading) return {
105
+ name: ie(e),
106
+ email: re(e),
107
+ methodLabel: S.paymentMethodLoading,
108
+ hasPaymentInstructions: !1
109
+ };
110
+ if (H.isBankAccountsError) return {
111
+ name: ie(e),
112
+ email: re(e),
113
+ methodLabel: S.paymentMethodUnavailable,
114
+ hasPaymentInstructions: !1
115
+ };
116
+ let t = ae(H.bankAccounts);
117
+ return {
118
+ name: ie(e),
119
+ email: re(e),
120
+ methodLabel: t ? S.paymentInstructionsValue(t.account_number?.slice(-4) ?? "") : S.noMethod,
121
+ hasPaymentInstructions: !!t
122
+ };
123
+ }, [
124
+ H.bankAccounts,
125
+ H.counterpart,
126
+ H.isBankAccountsError,
127
+ H.isBankAccountsLoading,
128
+ S
129
+ ]), K = d(() => {
130
+ let e = et?.trim();
131
+ if (!e || c || E) return;
132
+ let t = B?.accountNumber;
133
+ return {
134
+ name: e,
135
+ email: _?.email ?? "",
136
+ description: tt ? S.pendingVendorDescription : S.pendingVendorIncompleteDescription,
137
+ methodLabel: t ? S.paymentInstructionsValue(t.slice(-4)) : "",
138
+ hasPaymentInstructions: !!t
139
+ };
140
+ }, [
141
+ c,
142
+ B?.accountNumber,
143
+ _?.email,
144
+ et,
145
+ E,
146
+ tt,
147
+ S
148
+ ]), ft = !!K && !tt, q = c === g ? Te : void 0, J = d(() => we(H.bankAccounts, q), [H.bankAccounts, q]), pt = d(() => ae(H.bankAccounts)?.id, [H.bankAccounts]), mt = !H.counterpart || H.isLoading || H.isFetching || H.isError || H.isBankAccountsLoading || H.isBankAccountsFetching || H.isBankAccountsError, ht = mt || H.isAddressesLoading || H.isAddressesFetching || H.isAddressesError, gt = y && !mt && H.isAddressesError ? { onRetry: H.refetchAddresses } : void 0, Y = l(() => {
149
+ lt(), Le(void 0), D(!1), P.current = void 0;
150
+ }, [lt]), X = l((e) => {
151
+ if (D(!1), P.current = void 0, e === "edit") Ve(c), ct();
152
+ else {
153
+ st();
154
+ let e = w.trim();
155
+ W((t) => ({
156
+ ...t,
157
+ entityType: "organization",
158
+ legalName: e || z?.legalName || t.legalName,
159
+ email: z?.email || t.email,
160
+ phone: z?.phone || t.phone,
161
+ address: z?.address ?? t.address
162
+ })), Ue(B ?? m), N(void 0), M.current = m;
163
+ }
164
+ Le(e);
165
+ }, [
166
+ c,
167
+ B,
168
+ st,
169
+ ct,
170
+ w,
171
+ W,
172
+ z
173
+ ]), _t = U.revealErrors, vt = l(() => {
174
+ Xe(!0), X("create"), _t();
175
+ let e = B ? ce(B, C) : {};
176
+ Object.keys(e).length && N(e);
177
+ }, [
178
+ B,
179
+ C,
180
+ X,
181
+ _t
182
+ ]), yt = f(!1), bt = !yt.current && !v && y && Ee && !g && !R && !Ye && ft, xt = bt && !$e.isLoading;
183
+ ye(() => {
184
+ xt && (yt.current = !0, vt());
185
+ }, [vt, xt]);
186
+ let St = l(() => {
187
+ let e = J ? Ce(J) : m;
188
+ M.current = e, Ue(e), N(void 0), k(!0);
189
+ }, [J]), Ct = l((e) => {
190
+ let t = {
191
+ ...j.current,
192
+ ...e
193
+ };
194
+ j.current = t, Ue(t);
195
+ let ee = ce(t, C);
196
+ N((e) => {
197
+ if (!e) return e;
198
+ let t = { ...e };
199
+ for (let e of Object.keys(t)) ee[e] || delete t[e];
200
+ return Object.keys(t).length ? t : void 0;
201
+ });
202
+ }, [C]), wt = l(() => {
203
+ nt ? b(I) : I();
204
+ }, [
205
+ I,
206
+ b,
207
+ nt
208
+ ]), Z = l(() => {
209
+ Y(), I();
210
+ }, [I, Y]), Q = He || nt, $ = l((e) => {
211
+ let t = () => {
212
+ Z(), e();
213
+ };
214
+ Q ? b(t) : t();
215
+ }, [
216
+ b,
217
+ Z,
218
+ Q
219
+ ]), Tt = l(() => {
220
+ Q ? b(Z) : Z();
221
+ }, [
222
+ b,
223
+ Z,
224
+ Q
225
+ ]), Et = l(async ({ closeOnSuccess: t = !0, allowIncompleteVendor: ee = !1 } = {}) => {
226
+ if (ee && E === "create" && !P.current) {
227
+ let e = j.current, t = le({
228
+ ...dt,
229
+ bankAccount: e
230
+ }, C, "vendor");
231
+ if (oe(t)) return He || !h(e, B ?? m) ? {
232
+ ok: !0,
233
+ counterpartRawData: _e(dt, e, _)
234
+ } : { ok: !0 };
235
+ }
236
+ let n = c, r = !1, i = j.current;
237
+ if (!h(i, M.current)) {
238
+ let e = ce(i, C);
239
+ if (Object.keys(e).length > 0) return N(e), E !== "create" && k(!0), { ok: !1 };
240
+ }
241
+ if (E === "edit" && ht) return { ok: !1 };
242
+ if (E) {
243
+ if (E === "create" && P.current) n = P.current;
244
+ else {
245
+ let e = await ut();
246
+ if (!e.ok) return { ok: !1 };
247
+ E === "create" ? (n = e.counterpartId, P.current = n) : n = e.counterpartId ?? n;
248
+ }
249
+ E === "create" && (r = !0);
250
+ }
251
+ if (!n) return { ok: !0 };
252
+ let a = H.isBankAccountsLoading || H.isBankAccountsFetching || H.isBankAccountsError;
253
+ if (h(i, M.current)) {
254
+ let e = qe ?? q;
255
+ return e ? (t && (k(!1), E && Y()), r && L(n), {
256
+ ok: !0,
257
+ counterpartId: n,
258
+ counterpartBankAccountId: e
259
+ }) : r ? (t && Y(), L(n), {
260
+ ok: !0,
261
+ counterpartId: n
262
+ }) : a ? { ok: !1 } : (t && (k(!1), E && Y()), {
263
+ ok: !0,
264
+ counterpartId: n,
265
+ counterpartBankAccountId: pt
266
+ });
267
+ }
268
+ if (a) return { ok: !1 };
269
+ N(void 0);
270
+ let o = se(H.bankAccounts, qe ?? J?.id), s;
271
+ try {
272
+ o.kind === "update" ? (await ot.mutateAsync({
273
+ path: {
274
+ counterpart_id: n,
275
+ bank_account_id: o.bankAccountId
276
+ },
277
+ body: ne(i, { includeAchDefaults: o.includeAchDefaults })
278
+ }), s = o.bankAccountId) : s = (await at.mutateAsync({
279
+ path: { counterpart_id: n },
280
+ body: te(i, { isDefaultForCurrency: o.isDefaultForCurrency })
281
+ }))?.id;
282
+ } catch {
283
+ return e.error(S.bankAccountSaveFailed), {
284
+ ok: !1,
285
+ counterpartId: n
286
+ };
287
+ }
288
+ return M.current = i, Ke(s ? {
289
+ counterpartId: n,
290
+ bankAccountId: s
291
+ } : void 0), t && (k(!1), E && Y()), r && L(n), {
292
+ ok: !0,
293
+ counterpartId: n,
294
+ counterpartBankAccountId: s
295
+ };
296
+ }, [
297
+ Y,
298
+ c,
299
+ at,
300
+ H.bankAccounts,
301
+ H.isBankAccountsError,
302
+ H.isBankAccountsFetching,
303
+ H.isBankAccountsLoading,
304
+ B,
305
+ _,
306
+ E,
307
+ dt,
308
+ He,
309
+ ht,
310
+ S.bankAccountSaveFailed,
311
+ q,
312
+ C,
313
+ pt,
314
+ L,
315
+ J,
316
+ ut,
317
+ ot,
318
+ qe
319
+ ]), Dt = l((e) => {
320
+ if (F.current) return F.current;
321
+ let t = (async () => {
322
+ Qe(!0);
323
+ try {
324
+ return await Et(e);
325
+ } finally {
326
+ F.current = void 0, Qe(!1);
327
+ }
328
+ })();
329
+ return F.current = t, t;
330
+ }, [Et]), Ot = l(() => {
331
+ k(!1), E && Y();
332
+ }, [E, Y]), kt = d(() => (V.data?.data ?? []).map((e) => ({
333
+ name: ie(e),
334
+ email: re(e),
335
+ onSelect: () => {
336
+ $(() => L(e.id));
337
+ }
338
+ })), [
339
+ V.data,
340
+ $,
341
+ L
342
+ ]), At = l((e) => {
343
+ D(!0), W((t) => e.entityType === "individual" && t.entityType !== "individual" ? {
344
+ ...t,
345
+ ...e,
346
+ firstName: t.firstName || t.legalName,
347
+ legalName: t.legalName
348
+ } : e.entityType === "organization" && t.entityType !== "organization" ? {
349
+ ...t,
350
+ ...e,
351
+ legalName: t.legalName || [t.firstName, t.lastName].filter(Boolean).join(" ")
352
+ } : {
353
+ ...t,
354
+ ...e
355
+ });
356
+ }, [W]), jt = l((e) => {
357
+ D(!0), W((t) => ({
358
+ ...t,
359
+ address: {
360
+ ...t.address,
361
+ ...e
362
+ }
363
+ }));
364
+ }, [W]), Mt = {
365
+ query: w,
366
+ onQueryChange: Pe,
367
+ isLoading: bt || !Ee || !Me || !!c && H.isLoading || V.isLoading || V.isFetching && it,
368
+ onAddVendor: () => {
369
+ if (E === "create") {
370
+ let e = w.trim(), [t, ...ee] = e.split(/\s+/);
371
+ W((n) => n.entityType === "individual" ? {
372
+ ...n,
373
+ firstName: t,
374
+ lastName: ee.join(" ")
375
+ } : {
376
+ ...n,
377
+ legalName: e
378
+ }), D(!0);
379
+ return;
380
+ }
381
+ $(() => X("create"));
382
+ },
383
+ results: kt
384
+ }, Nt = Ae && (E === "create" || !mt) ? {
385
+ isOpen: O,
386
+ values: A,
387
+ errors: We,
388
+ onOpen: St,
389
+ onCancel: wt,
390
+ onChange: Ct
391
+ } : void 0, Pt = E !== "create" && Nt ? {
392
+ ...Nt,
393
+ onOpen: E === "edit" ? () => $(St) : Nt.onOpen,
394
+ canEditExisting: ke
395
+ } : void 0, Ft = U.isSubmitting || at.isPending || ot.isPending, It = {
396
+ prepareVendorForSave: Dt,
397
+ isVendorSavePending: Ze || Ft,
398
+ hasUnsavedVendorChanges: Q,
399
+ isPendingVendor: !!K && !ft,
400
+ revealIncompleteVendor: ft ? vt : void 0,
401
+ isEditingPayTo: !!E || O,
402
+ activePayToOperation: E ? "vendor" : O ? G?.hasPaymentInstructions ? "existingInstructions" : "missingInstructions" : void 0,
403
+ discardPayToEdits: Z,
404
+ finalizePayToSave: Ot,
405
+ openPaymentInstructions: St,
406
+ paymentInstructions: a(Pt, !!G?.hasPaymentInstructions),
407
+ paymentInstructionsEditor: Pt,
408
+ detailsWarning: gt
409
+ }, Lt = E === "create" && Ae ? {
410
+ values: A,
411
+ errors: We,
412
+ onChange: Ct,
413
+ isExtracted: !!(B && h(A, B))
414
+ } : void 0;
415
+ if (E) return {
416
+ mode: "creating",
417
+ summary: G,
418
+ newVendorForm: /* @__PURE__ */ be(ve, {
419
+ mode: E,
420
+ values: U.values,
421
+ errors: U.errors,
422
+ onChange: At,
423
+ onAddressChange: jt,
424
+ onCancel: Tt,
425
+ onSave: Dt,
426
+ isSaving: Ft,
427
+ search: rt ? Mt : void 0,
428
+ paymentInstructions: Lt,
429
+ labels: x?.inlineForm
430
+ }),
431
+ ...It
432
+ };
433
+ if (G) return {
434
+ mode: "resolved",
435
+ summary: G,
436
+ onEdit: y && !ht ? () => $(() => X("edit")) : void 0,
437
+ ...It
438
+ };
439
+ if (K && !bt) {
440
+ let e = () => $(() => {
441
+ Xe(!0), X("create");
442
+ }), t = y && Ae ? {
443
+ isOpen: !1,
444
+ values: A,
445
+ errors: We,
446
+ onOpen: e,
447
+ onChange: Ct,
448
+ onCancel: wt,
449
+ canEditExisting: !0
450
+ } : void 0;
451
+ return {
452
+ mode: "resolved",
453
+ summary: K,
454
+ onEdit: y ? e : void 0,
455
+ error: Oe,
456
+ ...It,
457
+ showPaymentInstructions: !0,
458
+ paymentInstructions: a(t, K.hasPaymentInstructions),
459
+ paymentInstructionsEditor: t
460
+ };
461
+ }
462
+ return {
463
+ mode: "selecting",
464
+ error: V.isError ? S.searchFailed : H.isError ? S.vendorDetailsFailed : Oe,
465
+ search: Mt,
466
+ ...It
467
+ };
115
468
  }
116
469
  //#endregion
117
- export { d as VendorInlineForm, d as default };
470
+ export { g as useVendorSectionProps };