@tesouro/embedded-components-react 0.5.76 → 0.5.77

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.
@@ -14,215 +14,225 @@ import { useCreateCounterpartBankAccountMutation as a, useUpdateCounterpartBankA
14
14
  import { usePayableSuggestionsQuery as s } from "../../data-access/dist/index18.js";
15
15
  import "../../data-access/dist/index.js";
16
16
  import { COUNTERPART_MESSAGE_LABELS_EN as ee } from "../../../shared/counterpart-management/feature/dist/lib/labels.js";
17
- import { counterpartFormBankAccountToCreatePayload as te, counterpartFormBankAccountToUpdatePayload as ne, getAchInstructions as c, getCounterpartEmail as l, getCounterpartName as u, getPayableAchInstructions as re, isAchCompatibleBankAccount as d, resolveCounterpartBankAccountWrite as ie, validateAchFormValues as ae } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
18
- import { useCounterpartDetails as oe } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js";
19
- import { useCounterpartForm as se } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
17
+ import { counterpartFormBankAccountToCreatePayload as te, counterpartFormBankAccountToUpdatePayload as ne, getAchInstructions as re, getCounterpartEmail as c, getCounterpartName as l, getPayableAchInstructions as ie, isAchCompatibleBankAccount as u, resolveCounterpartBankAccountWrite as ae, validateAchFormValues as oe } from "../../../shared/counterpart-management/feature/dist/lib/helpers.js";
18
+ import { useCounterpartDetails as se } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartDetails.js";
19
+ import { useCounterpartForm as ce } from "../../../shared/counterpart-management/feature/dist/lib/useCounterpartForm.js";
20
20
  import "../../../shared/counterpart-management/feature/dist/index.js";
21
- import { VENDOR_SECTION_PROPS_LABELS_EN as ce } from "./index48.js";
22
- import { buildVendorPrefill as le } from "./index50.js";
23
- import { VendorInlineForm as ue } from "./index51.js";
24
- import { useCallback as f, useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
25
- import { jsx as de } from "react/jsx-runtime";
21
+ import { VENDOR_SECTION_PROPS_LABELS_EN as le } from "./index48.js";
22
+ import { buildVendorPrefill as ue } from "./index50.js";
23
+ import { VendorInlineForm as de } from "./index51.js";
24
+ import { useCallback as d, useEffect as f, useMemo as p, useRef as m, useState as h } from "react";
25
+ import { jsx as fe } from "react/jsx-runtime";
26
26
  //#region ../../libs/tesouro-embedded-components-react/bill-pay-widget/feature/dist/index52.js
27
- var fe = 10, pe = 300, _ = {
27
+ var pe = 10, me = 300, g = {
28
28
  accountHolderName: "",
29
29
  routingNumber: "",
30
30
  accountNumber: ""
31
31
  };
32
- function me(e) {
32
+ function he(e) {
33
33
  return {
34
34
  accountHolderName: e.account_holder_name ?? "",
35
35
  routingNumber: e.routing_number ?? "",
36
36
  accountNumber: e.account_number ?? ""
37
37
  };
38
38
  }
39
- function he(e, t) {
39
+ function _(e, t) {
40
40
  return e.accountHolderName.trim() === t.accountHolderName.trim() && e.routingNumber.trim() === t.routingNumber.trim() && e.accountNumber.trim() === t.accountNumber.trim();
41
41
  }
42
42
  function ge(e, t) {
43
- return e?.find((e) => e.id === t && d(e)) ?? c(e);
43
+ return e?.find((e) => e.id === t && u(e)) ?? re(e);
44
44
  }
45
- function v({ payableId: c, counterpartId: d, payableCounterpartId: v, payableCounterpartBankAccountId: _e, isVendorKnown: ve = !0, onCounterpartChange: ye, requiredError: be, extractedVendor: y, readOnly: b = !1, canEditVendor: xe = !0, canEditPaymentInstructions: Se = !0, canAddPaymentInstructions: Ce = !0, confirmDiscard: x = (e) => e(), labels: we }) {
46
- let S = {
47
- ...ce,
48
- ...we
49
- }, { initResponse: Te } = r(), Ee = t(Te?.scopes, [n.CounterpartReadOrg]), [C, De] = g(""), [w, Oe] = g(""), ke = h(w), [T, Ae] = g(), [je, Me] = g("none"), [Ne, Pe] = g(), [Fe, E] = g(!1), [D, O] = g(!1), [k, A] = g(_), Ie = h(k);
50
- Ie.current = k;
51
- let j = h(_), [Le, M] = g(), [N, Re] = g(), P = h(void 0), ze = h(d), [Be, Ve] = g(!1), [He, Ue] = g(!1), F = h(void 0), We = D && !he(k, j.current), I = f(() => {
52
- O(!1), A(_), j.current = _, M(void 0);
53
- }, []), L = f((e) => {
45
+ function v({ payableId: re, counterpartId: u, payableCounterpartId: v, payableCounterpartBankAccountId: _e, isVendorKnown: ve = !0, onCounterpartChange: ye, requiredError: be, extractedVendor: y, readOnly: b = !1, canEditVendor: xe = !0, canEditPaymentInstructions: Se = !0, canAddPaymentInstructions: x = !0, confirmDiscard: S = (e) => e(), labels: Ce }) {
46
+ let C = {
47
+ ...le,
48
+ ...Ce
49
+ }, { initResponse: we } = r(), Te = t(we?.scopes, [n.CounterpartReadOrg]), [w, Ee] = h(""), [T, De] = h(""), Oe = m(T), [E, ke] = h(), [Ae, je] = h("none"), [Me, Ne] = h(), [Pe, D] = h(!1), [O, k] = h(!1), [A, j] = h(g), Fe = m(A);
50
+ Fe.current = A;
51
+ let M = m(g), [Ie, N] = h(), [Le, Re] = h(), P = Le?.bankAccountId, F = m(void 0), ze = m(u), [Be, Ve] = h(!1), [He, Ue] = h(!1), I = m(void 0), We = (O || E === "create") && !_(A, M.current), L = d(() => {
52
+ k(!1), j(g), M.current = g, N(void 0);
53
+ }, []), R = d((e) => {
54
54
  Ve(!0), ye(e);
55
- }, [ye]), Ge = s(c, { enabled: !b && !!c && !d && !v }).data?.suggested_counterpart?.id, Ke = y?.name;
56
- p(() => {
57
- !b && !Be && !d && !v && Ge && L(Ge);
55
+ }, [ye]), Ge = s(re, { enabled: !b && !!re && !u && !v }).data?.suggested_counterpart?.id, Ke = y?.name;
56
+ f(() => {
57
+ !b && !Be && !u && !v && Ge && R(Ge);
58
58
  }, [
59
- d,
59
+ u,
60
60
  v,
61
61
  b,
62
62
  Be,
63
63
  Ge,
64
- L
65
- ]), p(() => {
66
- ze.current !== d && (ze.current = d, I(), Re(void 0));
67
- }, [d, I]), p(() => {
64
+ R
65
+ ]), f(() => {
66
+ ze.current !== u && (ze.current = u, L(), Re((e) => e?.counterpartId === u ? e : void 0));
67
+ }, [u, L]), f(() => {
68
68
  let e = setTimeout(() => {
69
- Oe(C.trim());
70
- }, pe);
69
+ De(w.trim());
70
+ }, me);
71
71
  return () => clearTimeout(e);
72
- }, [C]);
73
- let R = i({
72
+ }, [w]);
73
+ let z = i({
74
74
  sort: "counterpart_name",
75
75
  order: "asc",
76
- limit: fe,
77
- counterpart_name__icontains: w || void 0,
76
+ limit: pe,
77
+ counterpart_name__icontains: T || void 0,
78
78
  is_vendor: !0,
79
- enabled: !b && (T === "edit" || !T && !d) && ve && Ee
79
+ enabled: !b && (E === "edit" || !E && !u) && ve && Te
80
80
  });
81
- p(() => {
82
- R.isPlaceholderData || (ke.current = w);
83
- }, [w, R.isPlaceholderData]);
84
- let qe = R.isPlaceholderData && ke.current !== w, z = oe({
85
- selectedId: d,
86
- enabled: Ee
87
- }), Je = a(), Ye = o(), B = se({
88
- view: je,
89
- setView: Me,
90
- selectedId: Ne,
91
- setSelectedId: Pe,
81
+ f(() => {
82
+ z.isPlaceholderData || (Oe.current = T);
83
+ }, [T, z.isPlaceholderData]);
84
+ let qe = z.isPlaceholderData && Oe.current !== T, B = se({
85
+ selectedId: u,
86
+ enabled: Te
87
+ }), Je = a(), Ye = o(), V = ce({
88
+ view: Ae,
89
+ setView: je,
90
+ selectedId: Me,
91
+ setSelectedId: Ne,
92
92
  messages: ee,
93
93
  counterpartType: "vendor",
94
- counterpart: z.counterpart,
95
- primaryAddress: z.primaryAddress,
94
+ counterpart: B.counterpart,
95
+ primaryAddress: B.primaryAddress,
96
96
  includeBankAccount: !1
97
- }), { openCreate: Xe, openEdit: Ze, close: Qe, setValues: V, submit: $e } = B, H = m(() => {
98
- let e = z.counterpart;
97
+ }), { openCreate: Xe, openEdit: Ze, close: Qe, setValues: H, submit: $e } = V, U = p(() => ue(y), [y]), W = U?.bankAccount, G = p(() => {
98
+ let e = B.counterpart;
99
99
  if (!e) return;
100
- if (z.isBankAccountsLoading) return {
101
- name: u(e),
102
- email: l(e),
103
- methodLabel: S.paymentMethodLoading,
100
+ if (B.isBankAccountsLoading) return {
101
+ name: l(e),
102
+ email: c(e),
103
+ methodLabel: C.paymentMethodLoading,
104
104
  hasPaymentInstructions: !1
105
105
  };
106
- if (z.isBankAccountsError) return {
107
- name: u(e),
108
- email: l(e),
109
- methodLabel: S.paymentMethodUnavailable,
106
+ if (B.isBankAccountsError) return {
107
+ name: l(e),
108
+ email: c(e),
109
+ methodLabel: C.paymentMethodUnavailable,
110
110
  hasPaymentInstructions: !1
111
111
  };
112
- let t = re(z.bankAccounts);
112
+ let t = ie(B.bankAccounts);
113
113
  return {
114
- name: u(e),
115
- email: l(e),
116
- methodLabel: t ? S.paymentInstructionsValue(t.account_number?.slice(-4) ?? "") : S.noMethod,
114
+ name: l(e),
115
+ email: c(e),
116
+ methodLabel: t ? C.paymentInstructionsValue(t.account_number?.slice(-4) ?? "") : C.noMethod,
117
117
  hasPaymentInstructions: !!t
118
118
  };
119
119
  }, [
120
- z.bankAccounts,
121
- z.counterpart,
122
- z.isBankAccountsError,
123
- z.isBankAccountsLoading,
124
- S
125
- ]), et = m(() => {
120
+ B.bankAccounts,
121
+ B.counterpart,
122
+ B.isBankAccountsError,
123
+ B.isBankAccountsLoading,
124
+ C
125
+ ]), et = p(() => {
126
126
  let e = Ke?.trim();
127
- if (!(!e || d || T)) return {
127
+ if (!e || u || E) return;
128
+ let t = W?.accountNumber;
129
+ return {
128
130
  name: e,
129
131
  email: y?.email ?? "",
130
- description: S.pendingVendorDescription,
131
- methodLabel: "",
132
- hasPaymentInstructions: !1
132
+ description: C.pendingVendorDescription,
133
+ methodLabel: t ? C.paymentInstructionsValue(t.slice(-4)) : "",
134
+ hasPaymentInstructions: !!t
133
135
  };
134
136
  }, [
135
- d,
137
+ u,
138
+ W?.accountNumber,
136
139
  y?.email,
137
140
  Ke,
138
- T,
139
- S.pendingVendorDescription
140
- ]), U = d === v ? _e : void 0, W = m(() => ge(z.bankAccounts, U), [z.bankAccounts, U]), tt = m(() => re(z.bankAccounts)?.id, [z.bankAccounts]), G = !z.counterpart || z.isLoading || z.isFetching || z.isError || z.isAddressesLoading || z.isAddressesFetching || z.isAddressesError || z.isBankAccountsLoading || z.isBankAccountsFetching || z.isBankAccountsError, K = f(() => {
141
- Qe(), Ae(void 0), E(!1), P.current = void 0;
142
- }, [Qe]), q = m(() => le(y), [y]), nt = f((e) => {
143
- if (E(!1), P.current = void 0, e === "edit") Pe(d), Ze();
141
+ E,
142
+ C.paymentInstructionsValue,
143
+ C.pendingVendorDescription
144
+ ]), K = u === v ? _e : void 0, q = p(() => ge(B.bankAccounts, K), [B.bankAccounts, K]), tt = p(() => ie(B.bankAccounts)?.id, [B.bankAccounts]), J = !B.counterpart || B.isLoading || B.isFetching || B.isError || B.isAddressesLoading || B.isAddressesFetching || B.isAddressesError || B.isBankAccountsLoading || B.isBankAccountsFetching || B.isBankAccountsError, Y = d(() => {
145
+ Qe(), ke(void 0), D(!1), F.current = void 0;
146
+ }, [Qe]), nt = d((e) => {
147
+ if (D(!1), F.current = void 0, e === "edit") Ne(u), Ze();
144
148
  else {
145
149
  Xe();
146
- let e = C.trim();
147
- V((t) => ({
150
+ let e = w.trim();
151
+ H((t) => ({
148
152
  ...t,
149
153
  entityType: "organization",
150
- legalName: e || q?.legalName || t.legalName,
151
- email: q?.email || t.email,
152
- phone: q?.phone || t.phone,
153
- address: q?.address ?? t.address
154
- }));
154
+ legalName: e || U?.legalName || t.legalName,
155
+ email: U?.email || t.email,
156
+ phone: U?.phone || t.phone,
157
+ address: U?.address ?? t.address
158
+ })), j(W ?? g), N(void 0), M.current = g;
155
159
  }
156
- Ae(e);
160
+ ke(e);
157
161
  }, [
158
- d,
162
+ u,
163
+ W,
159
164
  Xe,
160
165
  Ze,
161
- C,
162
- V,
163
- q
164
- ]), J = f(() => {
165
- let e = W ? me(W) : _;
166
- j.current = e, A(e), M(void 0), O(!0);
167
- }, [W]), rt = f(() => {
168
- We ? x(I) : I();
166
+ w,
167
+ H,
168
+ U
169
+ ]), rt = d(() => {
170
+ let e = q ? he(q) : g;
171
+ M.current = e, j(e), N(void 0), k(!0);
172
+ }, [q]), it = d((e) => {
173
+ j((t) => ({
174
+ ...t,
175
+ ...e
176
+ })), N(void 0);
177
+ }, []), at = d(() => {
178
+ We ? S(L) : L();
169
179
  }, [
170
- I,
171
- x,
180
+ L,
181
+ S,
172
182
  We
173
- ]), Y = f(() => {
174
- K(), I();
175
- }, [I, K]), X = Fe || We, Z = f((e) => {
183
+ ]), X = d(() => {
184
+ Y(), L();
185
+ }, [L, Y]), Z = Pe || We, Q = d((e) => {
176
186
  let t = () => {
177
- Y(), e();
187
+ X(), e();
178
188
  };
179
- X ? x(t) : t();
189
+ Z ? S(t) : t();
180
190
  }, [
181
- x,
182
- Y,
183
- X
184
- ]), it = f(() => {
185
- X ? x(Y) : Y();
191
+ S,
192
+ X,
193
+ Z
194
+ ]), ot = d(() => {
195
+ Z ? S(X) : X();
186
196
  }, [
187
- x,
188
- Y,
189
- X
190
- ]), at = f(async (t) => {
191
- let n = d, r = !1, i = Ie.current;
192
- if (!he(i, j.current)) {
193
- let e = ae(i);
194
- if (Object.keys(e).length > 0) return M(e), O(!0), { ok: !1 };
197
+ S,
198
+ X,
199
+ Z
200
+ ]), st = d(async (t) => {
201
+ let n = u, r = !1, i = Fe.current;
202
+ if (!_(i, M.current)) {
203
+ let e = oe(i);
204
+ if (Object.keys(e).length > 0) return N(e), E !== "create" && k(!0), { ok: !1 };
195
205
  }
196
- if (T === "edit" && G) return { ok: !1 };
197
- if (T) {
198
- if (T === "create" && P.current) n = P.current;
206
+ if (E === "edit" && J) return { ok: !1 };
207
+ if (E) {
208
+ if (E === "create" && F.current) n = F.current;
199
209
  else {
200
210
  let e = await $e();
201
211
  if (!e.ok) return { ok: !1 };
202
- T === "create" ? (n = e.counterpartId, P.current = n) : n = e.counterpartId ?? n;
212
+ E === "create" ? (n = e.counterpartId, F.current = n) : n = e.counterpartId ?? n;
203
213
  }
204
- T === "create" && (r = !0);
214
+ E === "create" && (r = !0);
205
215
  }
206
216
  if (!n) return { ok: !0 };
207
- let a = z.isBankAccountsLoading || z.isBankAccountsFetching || z.isBankAccountsError;
208
- if (he(i, j.current)) {
209
- let e = N ?? U;
210
- return e ? (t && (O(!1), T && K()), r && L(n), {
217
+ let a = B.isBankAccountsLoading || B.isBankAccountsFetching || B.isBankAccountsError;
218
+ if (_(i, M.current)) {
219
+ let e = P ?? K;
220
+ return e ? (t && (k(!1), E && Y()), r && R(n), {
211
221
  ok: !0,
212
222
  counterpartId: n,
213
223
  counterpartBankAccountId: e
214
- }) : r ? (t && K(), L(n), {
224
+ }) : r ? (t && Y(), R(n), {
215
225
  ok: !0,
216
226
  counterpartId: n
217
- }) : a ? { ok: !1 } : (t && (O(!1), T && K()), {
227
+ }) : a ? { ok: !1 } : (t && (k(!1), E && Y()), {
218
228
  ok: !0,
219
229
  counterpartId: n,
220
230
  counterpartBankAccountId: tt
221
231
  });
222
232
  }
223
233
  if (a) return { ok: !1 };
224
- M(void 0);
225
- let o = ie(z.bankAccounts, N ?? W?.id), s;
234
+ N(void 0);
235
+ let o = ae(B.bankAccounts, P ?? q?.id), s;
226
236
  try {
227
237
  o.kind === "update" ? (await Ye.mutateAsync({
228
238
  path: {
@@ -235,58 +245,61 @@ function v({ payableId: c, counterpartId: d, payableCounterpartId: v, payableCou
235
245
  body: te(i, { isDefaultForCurrency: o.isDefaultForCurrency })
236
246
  }))?.id;
237
247
  } catch {
238
- return e.error(S.bankAccountSaveFailed), {
248
+ return e.error(C.bankAccountSaveFailed), {
239
249
  ok: !1,
240
250
  counterpartId: n
241
251
  };
242
252
  }
243
- return j.current = i, Re(s), t && (O(!1), T && K()), r && L(n), {
253
+ return M.current = i, Re(s ? {
254
+ counterpartId: n,
255
+ bankAccountId: s
256
+ } : void 0), t && (k(!1), E && Y()), r && R(n), {
244
257
  ok: !0,
245
258
  counterpartId: n,
246
259
  counterpartBankAccountId: s
247
260
  };
248
261
  }, [
249
- K,
250
- d,
262
+ Y,
263
+ u,
251
264
  Je,
252
- z.bankAccounts,
253
- z.isBankAccountsError,
254
- z.isBankAccountsFetching,
255
- z.isBankAccountsLoading,
256
- T,
257
- G,
258
- U,
265
+ B.bankAccounts,
266
+ B.isBankAccountsError,
267
+ B.isBankAccountsFetching,
268
+ B.isBankAccountsLoading,
269
+ E,
270
+ J,
271
+ K,
259
272
  tt,
260
- L,
261
- W,
273
+ R,
274
+ q,
262
275
  $e,
263
276
  Ye,
264
- N
265
- ]), ot = f((e) => {
266
- if (F.current) return F.current;
277
+ P
278
+ ]), ct = d((e) => {
279
+ if (I.current) return I.current;
267
280
  let t = e?.closeOnSuccess ?? !0, n = (async () => {
268
281
  Ue(!0);
269
282
  try {
270
- return await at(t);
283
+ return await st(t);
271
284
  } finally {
272
- F.current = void 0, Ue(!1);
285
+ I.current = void 0, Ue(!1);
273
286
  }
274
287
  })();
275
- return F.current = n, n;
276
- }, [at]), st = f(() => {
277
- O(!1), T && K();
278
- }, [T, K]), ct = m(() => (R.data?.data ?? []).map((e) => ({
279
- name: u(e),
280
- email: l(e),
288
+ return I.current = n, n;
289
+ }, [st]), lt = d(() => {
290
+ k(!1), E && Y();
291
+ }, [E, Y]), ut = p(() => (z.data?.data ?? []).map((e) => ({
292
+ name: l(e),
293
+ email: c(e),
281
294
  onSelect: () => {
282
- Z(() => L(e.id));
295
+ Q(() => R(e.id));
283
296
  }
284
297
  })), [
285
- R.data,
286
- Z,
287
- L
288
- ]), lt = f((e) => {
289
- E(!0), V((t) => e.entityType === "individual" && t.entityType !== "individual" ? {
298
+ z.data,
299
+ Q,
300
+ R
301
+ ]), dt = d((e) => {
302
+ D(!0), H((t) => e.entityType === "individual" && t.entityType !== "individual" ? {
290
303
  ...t,
291
304
  ...e,
292
305
  firstName: t.firstName || t.legalName,
@@ -299,85 +312,101 @@ function v({ payableId: c, counterpartId: d, payableCounterpartId: v, payableCou
299
312
  ...t,
300
313
  ...e
301
314
  });
302
- }, [V]), ut = f((e) => {
303
- E(!0), V((t) => ({
315
+ }, [H]), ft = d((e) => {
316
+ D(!0), H((t) => ({
304
317
  ...t,
305
318
  address: {
306
319
  ...t.address,
307
320
  ...e
308
321
  }
309
322
  }));
310
- }, [V]), dt = {
311
- query: C,
312
- onQueryChange: De,
313
- isLoading: !ve || !Te || !!d && z.isLoading || R.isLoading || R.isFetching && qe,
323
+ }, [H]), pt = {
324
+ query: w,
325
+ onQueryChange: Ee,
326
+ isLoading: !ve || !we || !!u && B.isLoading || z.isLoading || z.isFetching && qe,
314
327
  onAddVendor: () => {
315
- Z(() => nt("create"));
328
+ Q(() => nt("create"));
316
329
  },
317
- results: ct
318
- }, Q = Ce && (T === "create" || !G) ? {
319
- isOpen: D,
320
- values: k,
321
- errors: Le,
322
- onOpen: J,
323
- onCancel: rt,
324
- onChange: (e) => {
325
- A((t) => ({
326
- ...t,
327
- ...e
328
- })), M(void 0);
329
- }
330
- } : void 0, ft = T !== "create" && Q ? {
331
- ...Q,
332
- onOpen: T === "edit" ? () => Z(J) : Q.onOpen,
330
+ results: ut
331
+ }, mt = x && (E === "create" || !J) ? {
332
+ isOpen: O,
333
+ values: A,
334
+ errors: Ie,
335
+ onOpen: rt,
336
+ onCancel: at,
337
+ onChange: it
338
+ } : void 0, ht = E !== "create" && mt ? {
339
+ ...mt,
340
+ onOpen: E === "edit" ? () => Q(rt) : mt.onOpen,
333
341
  canEditExisting: Se
334
- } : void 0, pt = B.isSubmitting || Je.isPending || Ye.isPending, $ = {
335
- prepareVendorForSave: ot,
336
- isVendorSavePending: He || pt,
337
- hasUnsavedVendorChanges: X,
342
+ } : void 0, gt = V.isSubmitting || Je.isPending || Ye.isPending, $ = {
343
+ prepareVendorForSave: ct,
344
+ isVendorSavePending: He || gt,
345
+ hasUnsavedVendorChanges: Z,
338
346
  isPendingVendor: !!et,
339
- isEditingPayTo: !!T || D,
340
- activePayToOperation: T ? "vendor" : D ? H?.hasPaymentInstructions ? "existingInstructions" : "missingInstructions" : void 0,
341
- discardPayToEdits: Y,
342
- finalizePayToSave: st,
343
- openPaymentInstructions: J,
344
- paymentInstructions: ft
345
- };
346
- return T ? {
347
+ isEditingPayTo: !!E || O,
348
+ activePayToOperation: E ? "vendor" : O ? G?.hasPaymentInstructions ? "existingInstructions" : "missingInstructions" : void 0,
349
+ discardPayToEdits: X,
350
+ finalizePayToSave: lt,
351
+ openPaymentInstructions: rt,
352
+ paymentInstructions: ht
353
+ }, _t = E === "create" && x ? {
354
+ values: A,
355
+ errors: Ie,
356
+ onChange: it,
357
+ isExtracted: !!(W && _(A, W))
358
+ } : void 0;
359
+ if (E) return {
347
360
  mode: "creating",
348
- summary: H,
349
- newVendorForm: /* @__PURE__ */ de(ue, {
350
- mode: T,
351
- values: B.values,
352
- errors: B.errors,
353
- onChange: lt,
354
- onAddressChange: ut,
355
- sectionsToExpand: B.sectionsToExpand,
356
- onAddressExpand: B.expandAddress,
357
- onCancel: it,
358
- onSave: ot,
359
- isSaving: pt,
360
- search: T === "edit" && !b ? dt : void 0
361
+ summary: G,
362
+ newVendorForm: /* @__PURE__ */ fe(de, {
363
+ mode: E,
364
+ values: V.values,
365
+ errors: V.errors,
366
+ onChange: dt,
367
+ onAddressChange: ft,
368
+ sectionsToExpand: V.sectionsToExpand,
369
+ onAddressExpand: V.expandAddress,
370
+ onCancel: ot,
371
+ onSave: ct,
372
+ isSaving: gt,
373
+ search: E === "edit" && !b ? pt : void 0,
374
+ paymentInstructions: _t
361
375
  }),
362
376
  ...$
363
- } : H ? {
377
+ };
378
+ if (G) return {
364
379
  mode: "resolved",
365
- summary: H,
366
- onEdit: xe && !G ? () => Z(() => nt("edit")) : void 0,
380
+ summary: G,
381
+ onEdit: xe && !J ? () => Q(() => nt("edit")) : void 0,
367
382
  ...$
368
- } : et ? {
369
- mode: "resolved",
370
- summary: et,
371
- onEdit: xe ? () => Z(() => {
383
+ };
384
+ if (et) {
385
+ let e = () => Q(() => {
372
386
  Ve(!0), nt("create");
373
- }) : void 0,
374
- showPaymentInstructions: !1,
375
- error: be,
376
- ...$
377
- } : {
387
+ });
388
+ return {
389
+ mode: "resolved",
390
+ summary: et,
391
+ onEdit: xe ? e : void 0,
392
+ error: be,
393
+ ...$,
394
+ showPaymentInstructions: !0,
395
+ paymentInstructions: xe && x ? {
396
+ isOpen: !1,
397
+ values: A,
398
+ errors: Ie,
399
+ onOpen: e,
400
+ onChange: it,
401
+ onCancel: at,
402
+ canEditExisting: !0
403
+ } : void 0
404
+ };
405
+ }
406
+ return {
378
407
  mode: "selecting",
379
- error: R.isError ? S.searchFailed : z.isError ? S.vendorDetailsFailed : be,
380
- search: dt,
408
+ error: z.isError ? C.searchFailed : B.isError ? C.vendorDetailsFailed : be,
409
+ search: pt,
381
410
  ...$
382
411
  };
383
412
  }