@tesouro/embedded-components-react 0.5.215 → 0.5.216

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 (53) hide show
  1. package/dist/index.d.ts +56 -2
  2. package/dist/index.js +13 -12
  3. package/dist/lib/BankAccountOnboardingWidget.d.ts +56 -2
  4. package/dist/lib/BankAccountOnboardingWidget.js +4 -3
  5. package/dist/lib/MarketingWidget.js +1 -1
  6. package/dist/lib/WidgetSuite.d.ts +53 -0
  7. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index.js +3 -2
  8. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index11.js +72 -72
  9. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index12.js +4 -1
  10. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index13.js +15 -15
  11. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index14.js +60 -60
  12. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index15.js +12 -12
  13. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index16.js +16 -16
  14. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index18.js +11 -11
  15. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index21.js +8 -8
  16. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index22.js +71 -5
  17. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index23.js +95 -33
  18. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index24.js +6 -17
  19. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index25.js +16 -616
  20. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index26.js +669 -0
  21. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index.js +15 -13
  22. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index10.js +52 -37
  23. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index11.js +31 -37
  24. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index12.js +33 -89
  25. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index13.js +39 -12
  26. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index14.js +98 -2
  27. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index15.js +14 -4
  28. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index16.js +2 -185
  29. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index17.js +4 -30
  30. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index18.js +183 -21
  31. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index19.js +26 -66
  32. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index20.js +21 -233
  33. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index21.js +66 -27
  34. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index22.js +233 -26
  35. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index23.js +27 -72
  36. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index24.js +26 -85
  37. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index25.js +74 -8
  38. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index26.js +83 -55
  39. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index27.js +6 -7
  40. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index28.js +37 -42
  41. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index29.js +11 -0
  42. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index30.js +64 -0
  43. package/dist/libs/tesouro-embedded-components-react/bank-account-onboarding-widget/ui/dist/index9.js +7 -33
  44. package/dist/libs/tesouro-embedded-components-react/marketing-widget/feature/dist/index.js +1 -1
  45. package/dist/libs/tesouro-embedded-components-react/marketing-widget/feature/dist/index5.js +16 -19
  46. package/dist/libs/tesouro-embedded-components-react/marketing-widget/feature/dist/index6.js +157 -16
  47. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/onboardingSuppressionReason.js +3 -1
  48. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/index.js +2 -1
  49. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  50. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/application/bankAccountApplication.js +26 -0
  51. package/dist/libs/tesouro-embedded-components-react/widget-suite/feature/dist/index16.js +1 -1
  52. package/package.json +1 -1
  53. package/dist/libs/tesouro-embedded-components-react/marketing-widget/feature/dist/index7.js +0 -161
@@ -0,0 +1,669 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { Dialog as e, DialogContent as t, DialogTitle as n, cn as r, toast as i } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import { getStateOptions as a } from "../../../shared/util/dist/lib/usStates.js";
7
+ import { extractApiErrorMessage as o } from "../../../shared/util/dist/lib/apiErrors.js";
8
+ import { useEmbedApi as s } from "../../../shared/data-access/dist/lib/EmbedApiContext.js";
9
+ import { personDisclosure as c } from "../../../shared/data-access/dist/lib/disclosures/personDisclosure.js";
10
+ import { useAcceptWidgetDisclosures as l } from "../../../shared/data-access/dist/lib/disclosures/useAcceptWidgetDisclosures.js";
11
+ import { useDisclosuresQuery as u } from "../../../shared/data-access/dist/lib/disclosures/useDisclosuresQuery.js";
12
+ import { OnboardingSuppressionReason as d } from "../../../shared/data-access/dist/lib/onboardingSuppressionReason.js";
13
+ import { useOrganizationOnboardingSuppression as ee } from "../../../shared/data-access/dist/lib/useOrganizationOnboardingSuppression.js";
14
+ import { useOrganizationApplicationStatus as f } from "../../../shared/data-access/dist/lib/useOrganizationApplicationStatus.js";
15
+ import "../../../shared/data-access/dist/index.js";
16
+ import { EmbeddedToaster as te } from "../../../shared/ui/dist/lib/EmbeddedToaster.js";
17
+ import { OnboardingShell as ne } from "../../../shared/ui/dist/lib/OnboardingShell/OnboardingShell.js";
18
+ import "../../../shared/ui/dist/index.js";
19
+ import { useAnalyticsTrack as re } from "../../../shared/feature/dist/lib/analytics/hooks.js";
20
+ import { WidgetProvider as ie } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
21
+ import { useRefetchWidget as ae, useWidgetConfig as oe, useWidgetInitStaleForToken as se } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
22
+ import { getNaicsOptions as ce } from "../../../shared/feature/dist/lib/naicsCodeMap.js";
23
+ import { deniedNoticeExpiresAt as le, selectBankAccountApplication as ue } from "../../../shared/feature/dist/lib/application/bankAccountApplication.js";
24
+ import "../../../shared/feature/dist/index.js";
25
+ import { ADDITIONAL_OWNERS_LABELS_EN as de } from "../../ui/dist/index5.js";
26
+ import { interpolateBankName as fe } from "../../ui/dist/index7.js";
27
+ import { ApplicationStatusCard as pe } from "../../ui/dist/index10.js";
28
+ import { ResultStep as me } from "../../ui/dist/index14.js";
29
+ import { UnsavedApplicationDialog as he } from "../../ui/dist/index28.js";
30
+ import { DeleteApplicationDialog as ge } from "../../ui/dist/index30.js";
31
+ import "../../ui/dist/index.js";
32
+ import { DEFAULT_LABELS as p } from "./index22.js";
33
+ import { identifierLast4 as _e, isIdentifierEnteredOrStored as m } from "./index7.js";
34
+ import { bankAccountOnboardingTestIds as h } from "./index12.js";
35
+ import { BusinessDetailsStep as ve } from "./index13.js";
36
+ import { PersonalDetailsStep as ye } from "./index15.js";
37
+ import { valuesKey as g } from "./index17.js";
38
+ import { AdditionalOwnersStep as be } from "./index18.js";
39
+ import { buildCreateApplicationBody as xe, buildUpdateApplicationBody as Se } from "./index19.js";
40
+ import { buildOnboardingPrefill as Ce } from "./index20.js";
41
+ import { acceptDraftedValues as we, asCreateBody as Te, buildDraftApplicationBody as Ee, draftOwners as De } from "./index21.js";
42
+ import { OnboardingApplicationView as Oe, applicationStatusNoticeFor as ke, hiddenViewReason as Ae, isNoticeView as je, mergeApplicationStatusLabels as Me, onboardingApplicationViewFor as Ne } from "./index23.js";
43
+ import { OnboardingAnalyticsEvent as Pe, WIDGET_NAME as Fe } from "./index24.js";
44
+ import { withoutResumeOnlyOwnerFields as Ie, withoutStoredIdentifierMarkers as Le } from "./index25.js";
45
+ import { ApplicationClientSecretProvider as Re, useApplicationClientSecret as ze } from "../../data-access/dist/index3.js";
46
+ import { useCreateApplication as Be } from "../../data-access/dist/index5.js";
47
+ import { useUpdateApplication as Ve } from "../../data-access/dist/index6.js";
48
+ import { useSubmitApplication as He } from "../../data-access/dist/index7.js";
49
+ import { useDeleteApplication as Ue } from "../../data-access/dist/index8.js";
50
+ import { usePollApplicationCompletion as We } from "../../data-access/dist/index9.js";
51
+ import { useResumableBankAccountApplication as Ge } from "../../data-access/dist/index11.js";
52
+ import { useStartedBankAccountApplication as Ke } from "../../data-access/dist/index12.js";
53
+ import "../../data-access/dist/index.js";
54
+ import { useCallback as qe, useEffect as _, useMemo as v, useReducer as Je, useRef as Ye, useState as y } from "react";
55
+ import { Fragment as Xe, jsx as b, jsxs as x } from "react/jsx-runtime";
56
+ //#region ../../libs/tesouro-embedded-components-react/bank-account-onboarding-widget/feature/dist/index26.js
57
+ var Ze = 2 ** 31 - 1, Qe = "DRAFT", $e = [], S = (e) => m(e, void 0);
58
+ function et(e) {
59
+ return {
60
+ ...e,
61
+ taxId: "",
62
+ taxIdOnFileLast4: _e(e.taxId),
63
+ taxIdOnFileStructure: e.companyStructure === "" ? void 0 : e.companyStructure
64
+ };
65
+ }
66
+ function C(e) {
67
+ return {
68
+ ...e,
69
+ ssn: "",
70
+ ssnOnFileLast4: _e(e.ssn)
71
+ };
72
+ }
73
+ function tt(e, t) {
74
+ return t ? t.index === null ? [...e, t.owner] : e.map((e, n) => n === t.index ? t.owner : e) : e;
75
+ }
76
+ var nt = {
77
+ companyLegalName: "",
78
+ companyDbaName: "",
79
+ businessAddress: "",
80
+ city: "",
81
+ state: "",
82
+ zipCode: "",
83
+ companyPhoneNumber: "",
84
+ companyStructure: "",
85
+ website: "",
86
+ taxId: "",
87
+ naicsCode: "",
88
+ isAuthorized: null,
89
+ isCheckboxChecked: !1
90
+ }, rt = {
91
+ firstName: "",
92
+ lastName: "",
93
+ dateOfBirth: void 0,
94
+ ssn: "",
95
+ homeAddress: "",
96
+ city: "",
97
+ state: "",
98
+ zipCode: "",
99
+ mobilePhoneNumber: "",
100
+ workEmail: "",
101
+ ownsOver25Percent: null,
102
+ ownershipPercentage: null
103
+ };
104
+ function it(e, t) {
105
+ if (e === 0) return {
106
+ title: t.businessReviewTitle,
107
+ subtitle: t.businessReviewSubtitle
108
+ };
109
+ if (e === 1) return {
110
+ title: t.personalReviewTitle,
111
+ subtitle: t.personalReviewSubtitle
112
+ };
113
+ let n = {
114
+ ...de,
115
+ ...t.additionalOwners
116
+ };
117
+ return {
118
+ title: n.heading,
119
+ subtitle: n.subheading
120
+ };
121
+ }
122
+ function at({ onEmbeddedOnboardingCompletedSuccessfully: ie, onNavigateToDashboard: de, labels: m, initialBusinessDetails: Ce, initialPersonalDetails: Fe, initialAdditionalOwners: Le, initialApplicationId: Re = null, initialBoundAuthEpoch: Ge, onEditableDraftChange: Ke, onApplicationDeleted: Qe, bankLogoSrc: at, disclosureLinks: ot, open: st, defaultOpen: ct, onOpenChange: w, isFullScreenInline: T = !1 }) {
123
+ let E = re(), { authEpoch: lt } = s();
124
+ _(() => {
125
+ E(Pe.Mounted);
126
+ }, [E]);
127
+ let D = {
128
+ ...p,
129
+ ...m,
130
+ stepIndicator: {
131
+ ...p.stepIndicator,
132
+ ...m?.stepIndicator
133
+ },
134
+ businessDetails: m?.businessDetails ?? {},
135
+ personalDetails: m?.personalDetails ?? {},
136
+ additionalOwners: m?.additionalOwners ?? {},
137
+ result: {
138
+ ...p.result,
139
+ ...m?.result
140
+ },
141
+ unsavedApplicationDialog: m?.unsavedApplicationDialog ?? {},
142
+ deleteApplicationDialog: m?.deleteApplicationDialog ?? {},
143
+ applicationStatus: Me(m?.applicationStatus)
144
+ }, O = oe().initResponse, { termsHref: ut, privacyHref: dt, electronicCommunicationHref: ft, patriotActHref: pt } = ot ?? {}, mt = st === void 0, [ht, gt] = y(() => ct ?? !1), k = mt ? ht : st, _t = ct ?? !1, A = qe((e) => {
145
+ mt && gt(e), w?.(e);
146
+ }, [w, mt]), vt = qe(() => {
147
+ ie();
148
+ }, [ie]), yt = ae(), [j, bt] = y(0), [M, N] = y(() => ({
149
+ ...nt,
150
+ ...Ce
151
+ })), [P, F] = y(() => ({
152
+ ...rt,
153
+ ...Fe
154
+ })), [I, L] = y(() => Le ?? []), [R, xt] = y(() => ({
155
+ business: M,
156
+ personal: P,
157
+ owners: I
158
+ })), [St, Ct] = y(null);
159
+ _(() => {
160
+ if (!St) return;
161
+ let e = {
162
+ business: M,
163
+ personal: P,
164
+ owners: I
165
+ };
166
+ xt((t) => St.next(e, t)), Ct(null);
167
+ }, [
168
+ St,
169
+ M,
170
+ P,
171
+ I
172
+ ]);
173
+ let wt = (e, { owners: t = "none" } = {}) => Ct({ next: (n, r) => ({
174
+ business: e.includes("business") ? n.business : r.business,
175
+ personal: e.includes("personal") ? n.personal : r.personal,
176
+ owners: t === "cleared" ? $e : t === "restored" ? we({
177
+ current: n,
178
+ saved: r,
179
+ dirty: {
180
+ business: !1,
181
+ personal: !1,
182
+ owners: !1
183
+ },
184
+ ownersWrite: "list"
185
+ }).owners : e.includes("owners") ? n.owners : r.owners
186
+ }) }), [Tt, Et] = y(null), [Dt, Ot] = y(0), [kt, At] = y(!1), [jt, Mt] = y(!1), [z, Nt] = y(null), [B, Pt] = y(null), [Ft, It] = y(null), [V, Lt] = y(Re), [Rt, zt] = y(!1), [H, Bt] = y({}), Vt = (e) => Bt((t) => ({
187
+ ...t,
188
+ ...e.taxId && S(e.taxId) && e.taxIdStructure ? {
189
+ taxId: e.taxId,
190
+ taxIdStructure: e.taxIdStructure
191
+ } : {},
192
+ ...e.ssn && S(e.ssn) ? { ssn: e.ssn } : {}
193
+ })), Ht = (e) => {
194
+ let { taxId: t, taxIdStructure: n } = H, r = t !== void 0 && n !== void 0 && e.companyStructure !== M.companyStructure && e.companyStructure !== "" && e.companyStructure === "SOLE_PROPRIETORSHIP" != (n === "SOLE_PROPRIETORSHIP");
195
+ N(r ? {
196
+ ...e,
197
+ taxId: e.taxId === t ? "" : e.taxId,
198
+ taxIdOnFileLast4: _e(t),
199
+ taxIdOnFileStructure: n
200
+ } : e);
201
+ }, [Ut, Wt] = y(Ge ?? lt), [Gt, U] = y(null), [Kt, qt] = y(!1), [Jt, Yt] = y(!1);
202
+ !T && !k && Jt && Yt(!1);
203
+ let [Xt, Zt] = y(!1), [Qt, $t] = y(null), en = Be(), W = Ve(), tn = He(), nn = Ue(), rn = We(), { setClientSecret: an } = ze(), { data: on, refetch: sn } = u(), { mutateAsync: cn } = l(), ln = ee(), G = f(), un = se(), [dn, fn] = Je((e) => e + 1, 0), pn = v(() => ue(G.applications), [G.applications]), mn = Ye(null);
204
+ G.isResolved && (mn.current = { application: pn });
205
+ let K = G.isResolved ? pn : mn.current?.application ?? null, hn = le(K), q = Ne(K), gn = G.isResolved || mn.current !== null && q === Oe.Form;
206
+ _(() => {
207
+ if (hn === null) return;
208
+ let e = hn - Date.now();
209
+ if (e < 0) return;
210
+ let t = setTimeout(fn, Math.min(e + 1, Ze));
211
+ return () => clearTimeout(t);
212
+ }, [hn, dn]);
213
+ let _n = Ye(null);
214
+ _(() => () => _n.current?.abort(), []);
215
+ let vn = v(() => ce(D.businessDetails.naicsTitles), [D.businessDetails.naicsTitles]), yn = v(() => a(D.businessDetails.stateTitles), [D.businessDetails.stateTitles]), bn = v(() => a(D.personalDetails.stateTitles), [D.personalDetails.stateTitles]), xn = v(() => a(D.additionalOwners.stateTitles), [D.additionalOwners.stateTitles]), J = Xt || Qt !== null, Sn = O?.status === "ACTIVE" || O?.status === "INACTIVE", Cn = O?.status === "INVITED", wn = Sn || Cn, Tn = ln.isResolved && gn, En = O && !J && !wn && Tn && je(q) ? q : null, Dn = !!O && !J && En === null && (wn || Tn && (ln.isSuppressed || q === Oe.Hidden)), On = Dn ? Sn ? d.UserAlreadyOnboarded : Cn ? d.UserInvitedToOrganization : q === Oe.Hidden ? Ae(K) : ln.reason ?? Ae(K) : null;
216
+ _(() => {
217
+ Dn && On && (E(Pe.Suppressed, { reason: On }), console.info(`[onboarding] not shown: ${On}`));
218
+ }, [
219
+ Dn,
220
+ On,
221
+ E
222
+ ]);
223
+ let kn = un || !(T || k) ? null : En;
224
+ _(() => {
225
+ kn && E(Pe.ApplicationStatusShown, { view: kn });
226
+ }, [kn, E]), _(() => {
227
+ Ke?.(J || V === null ? null : {
228
+ applicationId: V,
229
+ authEpoch: Ut
230
+ });
231
+ }, [
232
+ Ke,
233
+ J,
234
+ V,
235
+ Ut
236
+ ]);
237
+ let An = Ye(lt);
238
+ if (An.current = lt, !O) return null;
239
+ if (!J) {
240
+ if (Dn || !Tn) return null;
241
+ if (En) {
242
+ if (un) return null;
243
+ let i = ke(En, K, O.bankName?.trim() || D.fallbackBankName, D.applicationStatus), a = /* @__PURE__ */ b(pe, {
244
+ ...i,
245
+ className: r("ttw:max-w-2xl", !T && "ttw:pr-12"),
246
+ testIds: {
247
+ root: h.statusCard,
248
+ chip: h.statusCardChip
249
+ }
250
+ });
251
+ return T ? /* @__PURE__ */ b("div", {
252
+ className: "ttw:grid ttw:h-full ttw:w-full ttw:place-items-center ttw:overflow-auto ttw:bg-background ttw:p-6",
253
+ children: a
254
+ }) : /* @__PURE__ */ b(e, {
255
+ open: k,
256
+ onOpenChange: A,
257
+ children: /* @__PURE__ */ x(t, {
258
+ showCloseButton: !0,
259
+ closeButtonTestId: h.statusCardClose,
260
+ labels: { close: D.applicationStatus.close },
261
+ className: "ttw:max-h-[90vh] ttw:w-[720px] ttw:max-w-[calc(100vw-2rem)] ttw:gap-0 ttw:overflow-y-auto ttw:rounded-2xl ttw:border-0 ttw:p-0",
262
+ children: [/* @__PURE__ */ b(n, {
263
+ className: "ttw:sr-only",
264
+ children: D.modalTitle
265
+ }), a]
266
+ })
267
+ });
268
+ }
269
+ }
270
+ let Y = z?.companyStructure === "SOLE_PROPRIETORSHIP", jn = [
271
+ D.stepIndicator.business,
272
+ D.stepIndicator.personal,
273
+ D.stepIndicator.ownership
274
+ ], Mn = j === 0 ? z : j === 1 ? B : j === 2 ? Ft : null, X = en.isPending || W.isPending || tn.isPending || nn.isPending || Xt, Nn = () => {
275
+ U(null), bt((e) => e === 0 ? 0 : e - 1);
276
+ }, Z = {
277
+ business: g(M) !== g(R.business),
278
+ personal: g(P) !== g(R.personal),
279
+ owners: g(M.companyStructure === "SOLE_PROPRIETORSHIP" ? $e : tt(I, Tt)) !== g(R.owners)
280
+ }, Pn = Z.business || Z.personal || Z.owners, Q = {
281
+ business: (e) => H.taxId && e.taxId === H.taxId ? et(e) : e,
282
+ personal: (e) => H.ssn && e.ssn === H.ssn ? C(e) : e,
283
+ owners: (e) => e.map((e) => e.id && S(e.ssn) ? C(e) : e)
284
+ }, Fn = () => xt((e) => ({
285
+ business: Q.business(e.business),
286
+ personal: Q.personal(e.personal),
287
+ owners: Q.owners(e.owners)
288
+ })), In = () => {
289
+ X || (Pn ? At(!0) : (N(Q.business), F(Q.personal), L(Q.owners), Fn(), A(!1)));
290
+ }, Ln = (e) => {
291
+ e ? A(!0) : In();
292
+ }, Rn = In, zn = async (e) => {
293
+ Zt(!0), A(!0);
294
+ let t = new AbortController();
295
+ _n.current = t;
296
+ let n = !1;
297
+ try {
298
+ let r = await tn.mutateAsync({ path: { id: e } });
299
+ if (t.signal.aborted) return;
300
+ if (!r.id) throw Error(D.submitFailedError);
301
+ if (n = !0, (await rn(e, { signal: t.signal })).status === "complete") {
302
+ let e = on;
303
+ if (e === void 0 && (e = (await sn()).data), t.signal.aborted) return;
304
+ if (e !== void 0) try {
305
+ await cn({ displayedVersion: c(e)?.disclosureId ?? null });
306
+ } catch {}
307
+ if (t.signal.aborted) return;
308
+ $t("success"), yt(), vt();
309
+ } else $t("pending");
310
+ } catch (e) {
311
+ if (e instanceof DOMException && e.name === "AbortError") return;
312
+ if (!n) throw e;
313
+ $t("pending");
314
+ } finally {
315
+ _n.current = null, Zt(!1);
316
+ }
317
+ }, Bn = ({ evenWithoutMarker: e = !1 } = {}) => {
318
+ N((t) => (t.taxIdOnFileLast4 || e) && S(t.taxId) ? et(t) : t);
319
+ }, Vn = ({ evenWithoutMarker: e = !1 } = {}) => {
320
+ F((t) => (t.ssnOnFileLast4 || e) && S(t.ssn) ? C(t) : t);
321
+ }, Hn = ({ evenWithoutMarker: e = !1 } = {}) => {
322
+ L((t) => t.map((t) => (t.ssnOnFileLast4 || e && t.id) && S(t.ssn) ? C(t) : t));
323
+ }, Un = () => {
324
+ L((e) => e.map(Ie));
325
+ }, Wn = async (e) => {
326
+ let t = An.current, n = await en.mutateAsync({ body: e });
327
+ return Lt(n.id), Wt(t), n.clientSecret && an(n.id, n.clientSecret), n.id;
328
+ }, Gn = async () => {
329
+ let e = R.business.companyStructure === "SOLE_PROPRIETORSHIP" && !Y ? De(I) : [], t = e.length > 0 ? { businessOwners: e } : {};
330
+ if (j === 0) {
331
+ if (!z) return null;
332
+ let e = V;
333
+ return e ? await W.mutateAsync({
334
+ path: { id: e },
335
+ body: {
336
+ ...Se({
337
+ businessDetails: z,
338
+ carryConsent: !Rt
339
+ }),
340
+ ...t
341
+ }
342
+ }) : (e = await Wn(xe(z)), zt(!0)), Vt({
343
+ taxId: z.taxId,
344
+ taxIdStructure: z.companyStructure
345
+ }), Bn(), Y && Un(), wt(["business"], { owners: Y ? "cleared" : t.businessOwners ? "restored" : "none" }), e;
346
+ }
347
+ return j === 1 ? !B || !z || !V ? null : (await W.mutateAsync({
348
+ path: { id: V },
349
+ body: {
350
+ ...Se({
351
+ businessDetails: z,
352
+ applicant: B,
353
+ carryConsent: !Rt
354
+ }),
355
+ ...t
356
+ }
357
+ }), Vt({
358
+ taxId: z.taxId,
359
+ taxIdStructure: z.companyStructure,
360
+ ssn: B.ssn
361
+ }), Bn(), Vn(), wt(["business", "personal"], { owners: Y ? "cleared" : t.businessOwners ? "restored" : "none" }), V) : j === 2 ? !Ft || !V ? null : (await W.mutateAsync({
362
+ path: { id: V },
363
+ body: Se({ businessOwners: Ft })
364
+ }), Hn(), wt(["owners"]), V) : null;
365
+ }, $ = (e) => o(e) ?? (e instanceof Error ? e.message : void 0) ?? D.genericRetryError, Kn = async () => {
366
+ U(null);
367
+ try {
368
+ let e = await Gn();
369
+ if (e === null) return;
370
+ j === 2 ? await zn(e) : bt(j + 1);
371
+ } catch (e) {
372
+ U($(e));
373
+ }
374
+ }, qn = async () => {
375
+ U(null), qt(!0);
376
+ try {
377
+ if (await Gn() === null) return;
378
+ Bn({ evenWithoutMarker: !0 }), j >= 1 && Vn({ evenWithoutMarker: !0 }), j === 2 && Hn({ evenWithoutMarker: !0 }), i.success(D.applicationSavedToast), A(!1);
379
+ } catch (e) {
380
+ i.error($(e));
381
+ } finally {
382
+ qt(!1);
383
+ }
384
+ }, Jn = async () => {
385
+ let e = tt(I, Tt), t = Ee({
386
+ businessDetails: M,
387
+ applicant: P,
388
+ businessOwners: e,
389
+ savedBusinessDetails: R.business,
390
+ savedOwners: R.owners,
391
+ dirty: Z
392
+ }), n = Z;
393
+ Mt(!0);
394
+ try {
395
+ if (!t) {
396
+ i.error(D.saveDraftNothingValidError);
397
+ return;
398
+ }
399
+ let r = !V;
400
+ V ? await W.mutateAsync({
401
+ path: { id: V },
402
+ body: t
403
+ }) : await Wn(Te(t)), Tt && L(e), i.success(D.applicationSavedToast);
404
+ let a = t;
405
+ r && a.applicant?.isLegallyAuthorized && a.applicant?.hasAcceptedDisclosures && zt(!0), Vt({
406
+ taxId: a.businessDetails?.taxId?.value,
407
+ taxIdStructure: M.companyStructure,
408
+ ssn: a.applicant?.personalIdentificationNumber?.value
409
+ }), a.businessDetails?.taxId !== void 0 && Bn({ evenWithoutMarker: !0 }), a.applicant?.personalIdentificationNumber !== void 0 && Vn({ evenWithoutMarker: !0 }), Array.isArray(a.businessOwners) && Hn({ evenWithoutMarker: !0 }), a.businessOwners === null && e.length > 0 && Un();
410
+ let o = Array.isArray(a.businessOwners) ? "list" : a.businessOwners === null ? "cleared" : "none";
411
+ Ct({ next: (e, t) => we({
412
+ current: e,
413
+ saved: t,
414
+ dirty: n,
415
+ ownersWrite: o
416
+ }) }), Et(null), Ot((e) => e + 1), At(!1), A(!1);
417
+ } catch (e) {
418
+ i.error($(e));
419
+ } finally {
420
+ Mt(!1);
421
+ }
422
+ }, Yn = () => {
423
+ N(Q.business(R.business)), F(Q.personal(R.personal)), L(Q.owners(R.owners)), Fn(), Et(null), Ot((e) => e + 1), U(null), At(!1), A(!1);
424
+ }, Xn = async () => {
425
+ if (V !== null) {
426
+ try {
427
+ await nn.mutateAsync({ path: { id: V } });
428
+ } catch (e) {
429
+ i.error($(e));
430
+ return;
431
+ }
432
+ i.success(D.applicationDeletedToast);
433
+ }
434
+ Yt(!1), A(!1), Qe?.();
435
+ }, Zn = it(Math.min(j, 2), D), Qn = O.bankName?.trim() || D.fallbackBankName, $n = fe(D.shellFdicDisclaimer, Qn);
436
+ if (J) {
437
+ let r = z?.companyLegalName ?? "", i = O.bankName?.trim() || D.fallbackBankName, a = Qt ?? "pending", o = a === "success", s = {
438
+ ...p.result,
439
+ ...D.result
440
+ }, c = /* @__PURE__ */ b(me, {
441
+ testIds: {
442
+ processing: h.resultProcessing,
443
+ dashboardButton: h.resultDashboardButton
444
+ },
445
+ status: a,
446
+ isLoading: Xt,
447
+ loadingMessage: s.loadingMessage,
448
+ headingLine1: o ? s.successHeadingLine1 : s.pendingHeadingLine1,
449
+ headingLine2: `${r}!`,
450
+ body: o ? s.successBody : s.pendingBody,
451
+ followUpEmail: B?.workEmail ?? "",
452
+ emailBoxLead: s.pendingEmailBoxLead,
453
+ navigateToDashboardLabel: s.navigateToDashboard,
454
+ bankLogoSrc: at,
455
+ bankLogoAlt: fe(s.bankLogoAlt, i),
456
+ fdicDisclaimer: fe(s.fdicDisclaimer, i),
457
+ onNavigateToDashboard: de
458
+ });
459
+ return T ? /* @__PURE__ */ b("div", {
460
+ className: "ttw:grid ttw:h-full ttw:w-full ttw:grid-rows-[1fr] ttw:place-items-center ttw:gap-0 ttw:overflow-auto ttw:bg-background",
461
+ children: c
462
+ }) : /* @__PURE__ */ b(e, {
463
+ open: k,
464
+ onOpenChange: A,
465
+ children: /* @__PURE__ */ x(t, {
466
+ className: "ttw:grid ttw:max-h-[95vh] ttw:w-[720px] ttw:max-w-[calc(100vw-2rem)] ttw:grid-rows-[1fr] ttw:gap-0 ttw:overflow-hidden ttw:rounded-2xl ttw:p-0",
467
+ children: [/* @__PURE__ */ b(n, {
468
+ className: "ttw:sr-only",
469
+ children: D.modalTitle
470
+ }), c]
471
+ })
472
+ });
473
+ }
474
+ let er = j === 2 ? D.submit : D.next, tr = Mn === null || X;
475
+ return /* @__PURE__ */ x(Xe, { children: [
476
+ /* @__PURE__ */ x(ne, {
477
+ open: k,
478
+ defaultOpen: _t,
479
+ onOpenChange: Ln,
480
+ isFullScreenInline: T,
481
+ title: Zn.title,
482
+ subtitle: Zn.subtitle,
483
+ stepLabels: jn,
484
+ activeStep: j,
485
+ disclaimerText: $n,
486
+ onBack: j === 0 ? Rn : Nn,
487
+ onCancel: j > 0 ? Rn : void 0,
488
+ onNext: Kn,
489
+ onSaveAndClose: qn,
490
+ onDelete: () => Yt(!0),
491
+ showDismissButton: !1,
492
+ isNextDisabled: tr,
493
+ isNextLoading: X && !Kt,
494
+ isSaveAndCloseDisabled: tr,
495
+ isSaveAndCloseLoading: Kt,
496
+ nextLabel: er,
497
+ nextIcon: null,
498
+ errorMessage: Gt,
499
+ labels: {
500
+ backButton: j === 0 ? D.cancel : D.back,
501
+ cancelButton: D.cancel,
502
+ saveAndCloseButton: D.saveAndClose,
503
+ deleteButton: D.deleteApplication
504
+ },
505
+ testIds: {
506
+ root: h.shell,
507
+ dismiss: h.shellDismiss,
508
+ back: h.shellBack,
509
+ cancel: h.shellCancel,
510
+ saveAndClose: h.shellSaveAndClose,
511
+ delete: h.shellDelete,
512
+ next: h.shellNext,
513
+ scrollRegion: {
514
+ root: h.shellScrollRegion,
515
+ fade: h.shellScrollFade,
516
+ hint: h.shellScrollHint
517
+ }
518
+ },
519
+ children: [
520
+ j === 0 ? /* @__PURE__ */ b(ve, {
521
+ value: M,
522
+ onValueChange: Ht,
523
+ onSnapshotChange: Nt,
524
+ naicsOptions: vn,
525
+ stateOptions: yn,
526
+ isSubmitting: X,
527
+ labels: D.businessDetails,
528
+ bankName: Qn,
529
+ termsHref: ut,
530
+ privacyHref: dt,
531
+ electronicCommunicationHref: ft,
532
+ patriotActHref: pt
533
+ }, "business") : null,
534
+ j === 1 ? /* @__PURE__ */ b(ye, {
535
+ value: P,
536
+ onValueChange: F,
537
+ onSnapshotChange: Pt,
538
+ stateOptions: bn,
539
+ isSubmitting: X,
540
+ labels: D.personalDetails
541
+ }, "personal") : null,
542
+ j === 2 ? /* @__PURE__ */ b(be, {
543
+ owners: Y ? $e : I,
544
+ onOwnersChange: L,
545
+ primaryOwnerName: `${P.firstName} ${P.lastName}`.trim(),
546
+ primaryOwnerPercentage: Y ? 100 : B?.ownsOver25Percent === !0 ? B.ownershipPercentage ?? 0 : 0,
547
+ stateOptions: xn,
548
+ onSnapshotChange: It,
549
+ onPendingOwnerChange: Et,
550
+ isSubmitting: X,
551
+ labels: D.additionalOwners
552
+ }, Dt) : null
553
+ ]
554
+ }),
555
+ /* @__PURE__ */ b(he, {
556
+ open: kt,
557
+ onSaveDraft: Jn,
558
+ onDiscard: Yn,
559
+ onCancel: () => At(!1),
560
+ isSaving: jt,
561
+ labels: D.unsavedApplicationDialog,
562
+ testIds: {
563
+ root: h.unsavedDialog,
564
+ saveDraft: h.unsavedDialogSaveDraft,
565
+ discard: h.unsavedDialogDiscard,
566
+ close: h.unsavedDialogClose
567
+ }
568
+ }),
569
+ /* @__PURE__ */ b(ge, {
570
+ open: Jt,
571
+ onConfirm: Xn,
572
+ onCancel: () => Yt(!1),
573
+ isDeleting: nn.isPending,
574
+ labels: {
575
+ descriptionEmphasis: D.saveAndClose,
576
+ ...D.deleteApplicationDialog
577
+ },
578
+ testIds: {
579
+ root: h.deleteDialog,
580
+ confirm: h.deleteDialogConfirm,
581
+ cancel: h.deleteDialogCancel
582
+ }
583
+ }),
584
+ /* @__PURE__ */ b(te, {})
585
+ ] });
586
+ }
587
+ function ot({ baseUrl: e, widgetToken: t, organizationId: n, configClient: r, gatewayRouting: i, linkComponent: a, implementation: o, uiFramework: s, errorFallback: c, onError: l, analytics: u, disclosuresAcceptance: d, providerLabels: ee, ...f }) {
588
+ return /* @__PURE__ */ b(ie, {
589
+ baseUrl: e,
590
+ widgetToken: t,
591
+ organizationId: n,
592
+ configClient: r,
593
+ gatewayRouting: i,
594
+ linkComponent: a,
595
+ implementation: o,
596
+ uiFramework: s,
597
+ errorFallback: c,
598
+ onError: l,
599
+ analytics: u,
600
+ disclosuresAcceptance: d,
601
+ providerLabels: ee,
602
+ widgetName: Fe,
603
+ children: /* @__PURE__ */ b(st, { ...f })
604
+ });
605
+ }
606
+ function st(e) {
607
+ let { initResponse: t } = oe(), { client: n } = s(), r = t?.userId ?? null, [i, a] = y(r), [o, c] = y(0);
608
+ r !== i && (a(r), i !== null && r !== null && c((e) => e + 1));
609
+ let [l, u] = y(n);
610
+ return n !== l && (u(n), c((e) => e + 1)), /* @__PURE__ */ b(ct, { ...e }, o);
611
+ }
612
+ function ct(e) {
613
+ let { authEpoch: t } = s(), { ownApplicationIds: n } = Ge(), [r, i] = y(null), [a, o] = y(0), [c, l] = y(!1), u = qe(() => {
614
+ i(null), l(!0), o((e) => e + 1);
615
+ }, []);
616
+ return r !== null && t !== r.authEpoch && n !== null && !n.includes(r.applicationId) && (i(null), o((e) => e + 1)), /* @__PURE__ */ b(Re, { children: /* @__PURE__ */ b(T, {
617
+ ...e,
618
+ defaultOpen: !c && e.defaultOpen,
619
+ onEditableDraftChange: i,
620
+ onApplicationDeleted: u
621
+ }, a) }, a);
622
+ }
623
+ var w = { canRender: !1 };
624
+ function T(e) {
625
+ let { authEpoch: t } = s(), { applicationId: n, clientSecret: r, isResolved: i } = Ge(), { application: a, isResolved: o, isUnavailable: c } = Ke(n, r), [l, u] = y(null);
626
+ if (_(() => {
627
+ if (l?.canRender !== !0 && i && o) {
628
+ if (c) {
629
+ u(w);
630
+ return;
631
+ }
632
+ if (a !== null && a.status !== void 0 && a.status !== Qe) {
633
+ u(w);
634
+ return;
635
+ }
636
+ u({
637
+ canRender: !0,
638
+ applicationId: a === null ? null : n,
639
+ authEpoch: t,
640
+ prefill: Ce(a)
641
+ });
642
+ }
643
+ }, [
644
+ t,
645
+ l,
646
+ i,
647
+ o,
648
+ c,
649
+ a,
650
+ n
651
+ ]), l === null || !l.canRender) return null;
652
+ let { applicationId: d, authEpoch: ee, prefill: f } = l;
653
+ return /* @__PURE__ */ b(at, {
654
+ ...e,
655
+ initialApplicationId: d,
656
+ initialBoundAuthEpoch: ee,
657
+ initialBusinessDetails: {
658
+ ...Le(e.initialBusinessDetails),
659
+ ...f?.businessDetails
660
+ },
661
+ initialPersonalDetails: {
662
+ ...Le(e.initialPersonalDetails),
663
+ ...f?.personalDetails
664
+ },
665
+ initialAdditionalOwners: f?.additionalOwners ?? e.initialAdditionalOwners?.map(Ie)
666
+ });
667
+ }
668
+ //#endregion
669
+ export { ot as BankAccountOnboardingWidget, ot as default };