@tesouro/embedded-components-react 0.3.32 → 0.3.33

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 (27) hide show
  1. package/README.md +11 -10
  2. package/dist/index.d.ts +38 -0
  3. package/dist/index.js +2 -2
  4. package/dist/lib/CardsWidget.d.ts +36 -0
  5. package/dist/lib/CreateCardWidget.d.ts +38 -0
  6. package/dist/lib/CreateCardWidget.js +2 -2
  7. package/dist/libs/tesouro-embedded-components-react/cards-widget/feature/dist/index9.js +1 -1
  8. package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index.js +4 -3
  9. package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index3.js +9 -3
  10. package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index5.js +3 -3
  11. package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index6.js +19 -12
  12. package/dist/libs/tesouro-embedded-components-react/create-card-widget/data-access/dist/index7.js +22 -0
  13. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index.js +2 -2
  14. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index4.js +35 -30
  15. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index5.js +52 -10
  16. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index6.js +12 -31
  17. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index7.js +25 -248
  18. package/dist/libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index8.js +389 -0
  19. package/dist/libs/tesouro-embedded-components-react/create-card-widget/ui/dist/lib/CreateCardWidget/CardControls/CardControlRow.js +10 -9
  20. package/dist/libs/tesouro-embedded-components-react/create-card-widget/ui/dist/lib/CreateCardWidget/CardControls/CardControls.js +13 -12
  21. package/dist/libs/tesouro-embedded-components-react/create-card-widget/ui/dist/lib/CreateCardWidget/CardControls/MerchantCategoriesControl.js +2 -1
  22. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/index.js +19 -18
  23. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/merchant-category-group/useAllMerchantCategoryGroupsQuery.js +53 -0
  24. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/@tanstack/react-query.gen.js +224 -206
  25. package/dist/libs/tesouro-embedded-components-react/shared/data-access/dist/lib/rest/sdk.gen.js +174 -146
  26. package/dist/libs/tesouro-embedded-components-react/shared/feature/dist/lib/analytics/build-info.js +1 -1
  27. package/package.json +1 -1
@@ -2,259 +2,36 @@
2
2
  "use client";
3
3
  "use client";
4
4
  "use client";
5
- import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
- import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
7
- import { useAllBankAccountsQuery as n } from "../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
8
- import { useAllOrganizationUsersQuery as r } from "../../../shared/data-access/dist/lib/user/useAllOrganizationUsersQuery.js";
5
+ import { Scope as e } from "../../../shared/data-access/dist/lib/scopes.js";
6
+ import { useAllOrganizationUsersQuery as t } from "../../../shared/data-access/dist/lib/user/useAllOrganizationUsersQuery.js";
9
7
  import "../../../shared/data-access/dist/index.js";
10
- import { EmbeddedToaster as i } from "../../../shared/ui/dist/lib/EmbeddedToaster.js";
11
- import "../../../shared/ui/dist/index.js";
12
- import { useAnalyticsTrack as a } from "../../../shared/feature/dist/lib/analytics/hooks.js";
13
- import { WidgetProvider as o } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
14
- import { getStateOptions as s } from "../../../shared/util/dist/lib/usStates.js";
15
- import { useWidgetConfig as c } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
16
- import "../../../shared/feature/dist/index.js";
17
- import { CREATE_CARD_WIDGET_LABELS_EN as l } from "../../ui/dist/lib/CreateCardWidget/labels.js";
18
- import { CreateCardView as u, MailingOptionValue as d } from "../../ui/dist/lib/CreateCardWidget/types.js";
19
- import { CreateCardWidget as f } from "../../ui/dist/lib/CreateCardWidget/CreateCardWidget.js";
20
- import "../../ui/dist/index.js";
21
- import { CardFormatValue as p, buildCreateDebitCardRequest as m, createDebitCardReference as ee, formatBusinessAddress as te, isBusinessAddressComplete as ne, isManualAddressComplete as re } from "./index3.js";
22
- import { resolveCreateCardFeatureLabels as ie } from "./index4.js";
23
- import { CreateCardWidgetAnalyticsEvent as ae, WIDGET_NAME as oe } from "./index2.js";
24
- import { getCreateCardPermissions as se } from "./index5.js";
25
- import { useCreateCardCardholderOptions as ce } from "./index6.js";
26
- import { useCreateCard as le } from "../../data-access/dist/index2.js";
27
- import { useCreateDebitCardMutation as ue } from "../../data-access/dist/index4.js";
28
- import { useManageDebitCardAccessMutation as de } from "../../data-access/dist/index5.js";
29
- import { useCreateCardOrganizationQuery as fe } from "../../data-access/dist/index6.js";
30
- import "../../data-access/dist/index.js";
31
- import { useEffect as h, useMemo as g, useRef as _, useState as v } from "react";
32
- import { Fragment as pe, jsx as y, jsxs as me } from "react/jsx-runtime";
8
+ import { useCallback as n, useMemo as r } from "react";
33
9
  //#region ../../libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index7.js
34
- var he = t.DebitCardIssueOrg, ge = {
35
- street: "",
36
- city: "",
37
- state: "",
38
- zip: ""
39
- }, _e = 3e3, b = 5e3;
40
- function ve(e, t) {
41
- if (e === "PENDING_ACTIVATION") return {
42
- title: t.success.pendingActivationTitle,
43
- description: t.success.pendingActivationDescription
44
- };
45
- if (e !== null && e !== "ACTIVE") return {
46
- title: t.success.createdTitle,
47
- description: t.success.createdDescription
48
- };
49
- }
50
- function x(e) {
51
- let t = e?.trim().slice(-4);
52
- return t ? `••••${t}` : void 0;
10
+ var i = e.DebitCardReadOrg;
11
+ function a(e) {
12
+ let t = e.name?.trim(), n = e.email?.trim();
13
+ return t && n ? `${t} (${n})` : t || n || e.id;
53
14
  }
54
- function S(e, t) {
55
- let n = e.nickname?.trim(), r = x(e.accountNumber);
56
- return n && r ? `${n} (${r})` : n || r || t;
57
- }
58
- function C({ cardArtSrc: t, labels: o, featureLabels: oe, className: x, onClose: C, onCancel: w, onViewCard: T }) {
59
- let E = a(), { isReady: D } = le(), { initResponse: O, organizationId: k } = c(), A = g(() => se(O?.scopes), [O?.scopes]), j = ie(oe), M = {
60
- ...l,
61
- ...o,
62
- setup: {
63
- ...l.setup,
64
- ...o?.setup
65
- }
66
- }, ye = g(() => [{
67
- value: p.Virtual,
68
- label: M.setup.cardFormatVirtual
69
- }, {
70
- value: p.Physical,
71
- label: M.setup.cardFormatPhysical
72
- }], [M.setup.cardFormatPhysical, M.setup.cardFormatVirtual]), be = g(() => s(), []), [xe, N] = v(u.Setup), [P, F] = v(null), [I, L] = v(null), [Se, R] = v(null), [z, B] = v(null), [V, H] = v(ge), [Ce, we] = v(null), [Te, Ee] = v(null), De = () => {
73
- F(null), L(null), R(null), B(null), H(ge), we(null), Ee(null), N(u.Setup);
74
- }, Oe = _(k);
75
- k && k !== Oe.current && (Oe.current = k, De());
76
- let U = _(!0);
77
- h(() => (U.current = !0, () => {
78
- U.current = !1;
79
- }), []), h(() => {
80
- E(ae.Mounted);
81
- }, [E]);
82
- let { options: ke, isError: W, refetch: Ae } = ce({ enabled: D && A.canReadUsers }), G = r({
83
- enabled: D && A.canReadUsers,
84
- permissions: [he]
85
- }), je = g(() => !D || !A.canReadUsers || G.isResolving || G.isError ? [] : (G.data?.data ?? []).filter((e) => e.organizationId === k).map((e) => e.id), [
86
- G.data?.data,
87
- G.isError,
88
- G.isResolving,
89
- D,
90
- k,
91
- A.canReadUsers
92
- ]), K = !!G.isError && D && A.canReadUsers, Me = D && A.canReadUsers && G.isResolving, q = _(null);
93
- h(() => {
94
- if (!K) {
95
- q.current !== null && (e.dismiss(q.current), q.current = null);
96
- return;
97
- }
98
- return q.current = e.error(j.toast.debitCardIssuersError, {
99
- duration: Infinity,
100
- action: {
101
- label: j.toast.retry,
102
- onClick: () => {
103
- G.refetch();
104
- }
105
- }
106
- }), () => {
107
- q.current !== null && (e.dismiss(q.current), q.current = null);
108
- };
109
- }, [
110
- G.refetch,
111
- j.toast.debitCardIssuersError,
112
- j.toast.retry,
113
- K
114
- ]);
115
- let Ne = fe({ enabled: D && A.canReadOrganization }), J = n({ enabled: D && A.canReadFundingAccounts }), Pe = ue(), Fe = de(), Y = !!J.isError && D && A.canReadFundingAccounts, X = g(() => Y ? [] : (J.data?.data ?? []).map((e) => ({
15
+ function o({ enabled: e = !0 } = {}) {
16
+ let o = t({
17
+ enabled: e,
18
+ permissions: [i]
19
+ }), s = o.data?.data, c = r(() => !e || o.isResolving ? [] : [...s ?? []].sort((e, t) => e.name.localeCompare(t.name)).map((e) => ({
116
20
  value: e.id,
117
- label: S(e, j.untitledFundingAccount)
21
+ label: a(e)
118
22
  })), [
119
- J.data?.data,
120
- j.untitledFundingAccount,
121
- Y
122
- ]), Z = Se ?? (X.length === 1 ? X[0].value : null), Q = Ne.data?.address, Ie = te(Q), Le = ne(Q), $ = I === p.Physical, Re = $ && z === d.BusinessAddress && !!Ie, ze = $ && z === d.DifferentAddress, Be = Y || X.length > 0, Ve = !D || !A.canIssue || Pe.isPending || W || Y || K || Me || !P || !I || !Z || I === p.Physical && (!z || z === d.BusinessAddress && !Le || z === d.DifferentAddress && !re(V)), He = g(() => {
123
- let e = ve(Te, j);
124
- return {
125
- ...o,
126
- success: {
127
- ...o?.success,
128
- ...e
129
- }
130
- };
131
- }, [
132
- Te,
133
- j,
134
- o
135
- ]), Ue = async () => {
136
- if (!D) return;
137
- let t = ee(), n = m({
138
- cardholderUserId: P,
139
- format: I,
140
- bankAccountId: Z,
141
- reference: t,
142
- mailingOption: z,
143
- orgAddress: Q,
144
- manualAddress: V
145
- });
146
- if (!n) return;
147
- N(u.Preparing);
148
- let r = e.loading(j.toast.creating);
149
- try {
150
- let t = await Pe.mutateAsync({ body: n });
151
- if (!U.current) {
152
- e.dismiss(r);
153
- return;
154
- }
155
- if (we(t.id), Ee(t.cardStatus), je.length > 0) try {
156
- await Fe.mutateAsync({ body: {
157
- debitCardIds: [t.id],
158
- type: "GRANT",
159
- userIds: je
160
- } });
161
- } catch {
162
- if (!U.current) {
163
- e.dismiss(r);
164
- return;
165
- }
166
- N(u.Success), e.warning(j.toast.companyAdminAccessWarning, {
167
- id: r,
168
- duration: b
169
- });
170
- return;
171
- }
172
- if (!U.current) {
173
- e.dismiss(r);
174
- return;
175
- }
176
- N(u.Success), e.success(j.toast.success, {
177
- id: r,
178
- duration: _e
179
- });
180
- } catch {
181
- if (!U.current) {
182
- e.dismiss(r);
183
- return;
184
- }
185
- N(u.Setup), e.error(j.toast.error, {
186
- id: r,
187
- duration: b
188
- });
189
- }
23
+ e,
24
+ s,
25
+ o.isResolving
26
+ ]), l = o.refetch, u = n(() => {
27
+ l();
28
+ }, [l]);
29
+ return {
30
+ options: c,
31
+ isResolving: e && o.isResolving,
32
+ isError: e && o.isError,
33
+ refetch: u
190
34
  };
191
- return /* @__PURE__ */ me(pe, { children: [/* @__PURE__ */ y(i, {}), /* @__PURE__ */ y(f, {
192
- view: xe,
193
- cardArtSrc: t,
194
- labels: He,
195
- className: x,
196
- cardholderOptions: ke,
197
- selectedCardholder: P,
198
- onCardholderSelect: F,
199
- isCardholderError: W,
200
- onCardholderRetry: W ? Ae : void 0,
201
- cardFormatOptions: ye,
202
- selectedCardFormat: I,
203
- onCardFormatSelect: (e) => {
204
- L(e), B(null);
205
- },
206
- isFundingAccountVisible: Be,
207
- fundingAccountOptions: X,
208
- selectedFundingAccount: Z,
209
- onFundingAccountSelect: R,
210
- isFundingAccountError: Y,
211
- onFundingAccountRetry: Y ? () => {
212
- J.refetch();
213
- } : void 0,
214
- isMailingSectionVisible: $,
215
- selectedMailingOption: z,
216
- onMailingOptionSelect: B,
217
- businessAddress: Ie,
218
- isBusinessAddressVisible: Re,
219
- isManualAddressVisible: ze,
220
- manualAddress: V,
221
- onManualAddressChange: (e) => H((t) => ({
222
- ...t,
223
- ...e
224
- })),
225
- stateOptions: be,
226
- isCreateDisabled: Ve,
227
- onCreateClick: () => {
228
- Ue();
229
- },
230
- onCancelClick: () => {
231
- w?.(), C?.();
232
- },
233
- onClose: C,
234
- onCreateAnotherClick: De,
235
- onViewCardClick: T && Ce ? () => {
236
- T(Ce);
237
- } : void 0
238
- })] });
239
- }
240
- function w({ baseUrl: e, widgetToken: t, organizationId: n, configClient: r, gatewayRouting: i, linkComponent: a, implementation: s, uiFramework: c, errorFallback: l, onError: u, analytics: d, disclosuresAcceptance: f, providerLabels: p, ...m }) {
241
- return /* @__PURE__ */ y(o, {
242
- widgetName: oe,
243
- baseUrl: e,
244
- widgetToken: t,
245
- organizationId: n,
246
- configClient: r,
247
- gatewayRouting: i,
248
- linkComponent: a,
249
- implementation: s,
250
- uiFramework: c,
251
- errorFallback: l,
252
- onError: u,
253
- analytics: d,
254
- disclosuresAcceptance: f,
255
- providerLabels: p,
256
- children: /* @__PURE__ */ y(C, { ...m })
257
- });
258
35
  }
259
36
  //#endregion
260
- export { w as CreateCardWidget, S as formatFundingAccountLabel };
37
+ export { i as CARDHOLDER_PERMISSION_KEY, a as formatCardholderOptionLabel, o as useCreateCardCardholderOptions };
@@ -0,0 +1,389 @@
1
+ "use client";
2
+ "use client";
3
+ "use client";
4
+ "use client";
5
+ import { toast as e } from "../../../../../packages/shared-ui-shadcn/dist/index.js";
6
+ import { Scope as t } from "../../../shared/data-access/dist/lib/scopes.js";
7
+ import { useAllBankAccountsQuery as n } from "../../../shared/data-access/dist/lib/bank-account/useAllBankAccountsQuery.js";
8
+ import { useAllMerchantCategoryGroupsQuery as r } from "../../../shared/data-access/dist/lib/merchant-category-group/useAllMerchantCategoryGroupsQuery.js";
9
+ import { useAllOrganizationUsersQuery as i } from "../../../shared/data-access/dist/lib/user/useAllOrganizationUsersQuery.js";
10
+ import "../../../shared/data-access/dist/index.js";
11
+ import { EmbeddedToaster as a } from "../../../shared/ui/dist/lib/EmbeddedToaster.js";
12
+ import "../../../shared/ui/dist/index.js";
13
+ import { useAnalyticsTrack as o } from "../../../shared/feature/dist/lib/analytics/hooks.js";
14
+ import { WidgetProvider as s } from "../../../shared/feature/dist/lib/WidgetProvider/WidgetProvider.js";
15
+ import { getStateOptions as ee } from "../../../shared/util/dist/lib/usStates.js";
16
+ import { useWidgetConfig as te } from "../../../shared/feature/dist/lib/WidgetProvider/hooks.js";
17
+ import "../../../shared/feature/dist/index.js";
18
+ import { CREATE_CARD_WIDGET_LABELS_EN as c } from "../../ui/dist/lib/CreateCardWidget/labels.js";
19
+ import { CreateCardView as l, MailingOptionValue as u } from "../../ui/dist/lib/CreateCardWidget/types.js";
20
+ import { CreateCardWidget as ne } from "../../ui/dist/lib/CreateCardWidget/CreateCardWidget.js";
21
+ import "../../ui/dist/index.js";
22
+ import { CardFormatValue as d, buildCreateDebitCardRequest as re, createDebitCardReference as ie, formatBusinessAddress as ae, isBusinessAddressComplete as oe, isManualAddressComplete as se } from "./index3.js";
23
+ import { resolveCreateCardFeatureLabels as ce } from "./index5.js";
24
+ import { CreateCardWidgetAnalyticsEvent as le, WIDGET_NAME as ue } from "./index2.js";
25
+ import { SpendLimitPeriodValue as f, buildPerTransactionMaximumVelocityControlRequest as de, buildSpendLimitVelocityControlRequest as fe, parseControlAmountToMinorUnits as pe } from "./index4.js";
26
+ import { getCreateCardPermissions as me } from "./index6.js";
27
+ import { useCreateCardCardholderOptions as he } from "./index7.js";
28
+ import { useCreateCard as ge } from "../../data-access/dist/index2.js";
29
+ import { useCreateDebitCardMutation as _e } from "../../data-access/dist/index4.js";
30
+ import { useCreateVelocityControlMutation as ve } from "../../data-access/dist/index5.js";
31
+ import { useManageDebitCardAccessMutation as ye } from "../../data-access/dist/index6.js";
32
+ import { useCreateCardOrganizationQuery as be } from "../../data-access/dist/index7.js";
33
+ import "../../data-access/dist/index.js";
34
+ import { useEffect as p, useMemo as m, useRef as h, useState as g } from "react";
35
+ import { Fragment as xe, jsx as _, jsxs as Se } from "react/jsx-runtime";
36
+ //#region ../../libs/tesouro-embedded-components-react/create-card-widget/feature/dist/index8.js
37
+ var Ce = t.DebitCardIssueOrg, we = {
38
+ street: "",
39
+ city: "",
40
+ state: "",
41
+ zip: ""
42
+ }, Te = 3e3, v = 5e3;
43
+ function Ee(e, t) {
44
+ if (e === "PENDING_ACTIVATION") return {
45
+ title: t.success.pendingActivationTitle,
46
+ description: t.success.pendingActivationDescription
47
+ };
48
+ if (e !== null && e !== "ACTIVE") return {
49
+ title: t.success.createdTitle,
50
+ description: t.success.createdDescription
51
+ };
52
+ }
53
+ function De(e) {
54
+ let t = e?.trim().slice(-4);
55
+ return t ? `••••${t}` : void 0;
56
+ }
57
+ function Oe(e, t) {
58
+ let n = e.nickname?.trim(), r = De(e.accountNumber);
59
+ return n && r ? `${n} (${r})` : n || r || t;
60
+ }
61
+ function y({ cardArtSrc: t, labels: s, featureLabels: ue, className: De, onClose: y, onCancel: ke, onViewCard: Ae }) {
62
+ let je = o(), { isReady: b } = ge(), { initResponse: Me, organizationId: x } = te(), S = m(() => me(Me?.scopes), [Me?.scopes]), C = ce(ue), w = {
63
+ ...c,
64
+ ...s,
65
+ setup: {
66
+ ...c.setup,
67
+ ...s?.setup
68
+ }
69
+ }, Ne = m(() => [{
70
+ value: d.Virtual,
71
+ label: w.setup.cardFormatVirtual
72
+ }, {
73
+ value: d.Physical,
74
+ label: w.setup.cardFormatPhysical
75
+ }], [w.setup.cardFormatPhysical, w.setup.cardFormatVirtual]), Pe = m(() => ee(), []), [Fe, T] = g(l.Setup), [E, Ie] = g(null), [D, Le] = g(null), [Re, ze] = g(null), [O, k] = g(null), [A, Be] = g(we), [Ve, He] = g(null), [Ue, We] = g(null), [j, M] = g(!1), [N, P] = g(""), [F, I] = g(null), [L, R] = g(!1), [z, B] = g(""), [V, H] = g(!1), [U, W] = g([]), Ge = () => {
76
+ Ie(null), Le(null), ze(null), k(null), Be(we), He(null), We(null), M(!1), P(""), I(null), R(!1), B(""), H(!1), W([]), T(l.Setup);
77
+ }, Ke = h(x);
78
+ x && x !== Ke.current && (Ke.current = x, Ge());
79
+ let G = h(!0);
80
+ p(() => (G.current = !0, () => {
81
+ G.current = !1;
82
+ }), []), p(() => {
83
+ je(le.Mounted);
84
+ }, [je]);
85
+ let { options: qe, isError: K, refetch: Je } = he({ enabled: b && S.canReadUsers }), q = i({
86
+ enabled: b && S.canReadUsers,
87
+ permissions: [Ce]
88
+ }), Ye = m(() => !b || !S.canReadUsers || q.isResolving || q.isError ? [] : (q.data?.data ?? []).filter((e) => e.organizationId === x).map((e) => e.id), [
89
+ q.data?.data,
90
+ q.isError,
91
+ q.isResolving,
92
+ b,
93
+ x,
94
+ S.canReadUsers
95
+ ]), J = !!q.isError && b && S.canReadUsers, Xe = b && S.canReadUsers && q.isResolving, Y = h(null);
96
+ p(() => {
97
+ if (!J) {
98
+ Y.current !== null && (e.dismiss(Y.current), Y.current = null);
99
+ return;
100
+ }
101
+ return Y.current = e.error(C.toast.debitCardIssuersError, {
102
+ duration: Infinity,
103
+ action: {
104
+ label: C.toast.retry,
105
+ onClick: () => {
106
+ q.refetch();
107
+ }
108
+ }
109
+ }), () => {
110
+ Y.current !== null && (e.dismiss(Y.current), Y.current = null);
111
+ };
112
+ }, [
113
+ q.refetch,
114
+ C.toast.debitCardIssuersError,
115
+ C.toast.retry,
116
+ J
117
+ ]);
118
+ let Ze = be({ enabled: b && S.canReadOrganization }), X = n({ enabled: b && S.canReadFundingAccounts }), Qe = r({ enabled: b && S.canReadMerchantCategoryGroups }), $e = _e(), et = ve(), tt = ye(), Z = !!X.isError && b && S.canReadFundingAccounts, Q = m(() => Z ? [] : (X.data?.data ?? []).map((e) => ({
119
+ value: e.id,
120
+ label: Oe(e, C.untitledFundingAccount)
121
+ })), [
122
+ X.data?.data,
123
+ C.untitledFundingAccount,
124
+ Z
125
+ ]), nt = m(() => (Qe.data?.data ?? []).map((e) => ({
126
+ value: e.id,
127
+ label: e.name
128
+ })), [Qe.data?.data]), rt = Re ?? (Q.length === 1 ? Q[0].value : null), it = Ze.data?.address, at = ae(it), ot = oe(it), $ = D === d.Physical, st = $ && O === u.BusinessAddress && !!at, ct = $ && O === u.DifferentAddress, lt = Z || Q.length > 0, ut = b && S.canWriteAuthorizationControls, dt = m(() => [
129
+ {
130
+ value: f.OneTime,
131
+ label: C.spendLimit.periodOneTime
132
+ },
133
+ {
134
+ value: f.Daily,
135
+ label: C.spendLimit.periodDaily
136
+ },
137
+ {
138
+ value: f.Monthly,
139
+ label: C.spendLimit.periodMonthly
140
+ }
141
+ ], [
142
+ C.spendLimit.periodDaily,
143
+ C.spendLimit.periodMonthly,
144
+ C.spendLimit.periodOneTime
145
+ ]), ft = m(() => [
146
+ {
147
+ value: f.OneTime,
148
+ variant: "warning",
149
+ title: C.spendLimit.oneTimeWarningTitle,
150
+ description: C.spendLimit.oneTimeWarningDescription
151
+ },
152
+ {
153
+ value: f.Daily,
154
+ variant: "info",
155
+ description: C.spendLimit.dailyResetNotice
156
+ },
157
+ {
158
+ value: f.Monthly,
159
+ variant: "info",
160
+ description: C.spendLimit.monthlyResetNotice
161
+ }
162
+ ], [
163
+ C.spendLimit.dailyResetNotice,
164
+ C.spendLimit.monthlyResetNotice,
165
+ C.spendLimit.oneTimeWarningDescription,
166
+ C.spendLimit.oneTimeWarningTitle
167
+ ]), pt = j && (pe(N) === null || F === null), mt = L && pe(z) === null, ht = V && U.length === 0, gt = nt.length === 0 && !V;
168
+ ut || (j && M(!1), N !== "" && P(""), F !== null && I(null), L && R(!1), z !== "" && B(""), V && H(!1), U.length > 0 && W([]));
169
+ let _t = m(() => ({
170
+ isSpendLimitEnabled: j,
171
+ onSpendLimitEnabledChange: (e) => {
172
+ M(e), e && I((e) => e ?? f.Monthly);
173
+ },
174
+ spendLimitAmount: N,
175
+ onSpendLimitAmountChange: P,
176
+ spendLimitPeriodOptions: dt,
177
+ selectedSpendLimitPeriod: F,
178
+ onSpendLimitPeriodSelect: I,
179
+ spendLimitPeriodNotices: ft,
180
+ isMerchantCategoriesEnabled: V,
181
+ onMerchantCategoriesEnabledChange: H,
182
+ merchantCategoryOptions: nt,
183
+ selectedMerchantCategories: U,
184
+ onMerchantCategoryToggle: (e) => {
185
+ W((t) => t.includes(e) ? t.filter((t) => t !== e) : [...t, e]);
186
+ },
187
+ isMerchantCategoriesToggleDisabled: gt,
188
+ isPerTransactionMaximumEnabled: L,
189
+ onPerTransactionMaximumEnabledChange: R,
190
+ perTransactionMaximumAmount: z,
191
+ onPerTransactionMaximumAmountChange: B
192
+ }), [
193
+ V,
194
+ gt,
195
+ L,
196
+ j,
197
+ nt,
198
+ z,
199
+ U,
200
+ F,
201
+ N,
202
+ ft,
203
+ dt
204
+ ]), vt = !b || !S.canIssue || $e.isPending || et.isPending || tt.isPending || K || Z || J || Xe || !E || !D || !rt || pt || mt || ht || D === d.Physical && (!O || O === u.BusinessAddress && !ot || O === u.DifferentAddress && !se(A)), yt = m(() => {
205
+ let e = Ee(Ue, C);
206
+ return {
207
+ ...s,
208
+ success: {
209
+ ...s?.success,
210
+ ...e
211
+ }
212
+ };
213
+ }, [
214
+ Ue,
215
+ C,
216
+ s
217
+ ]), bt = async () => {
218
+ if (!b) return;
219
+ let t = ie(), n = re({
220
+ cardholderUserId: E,
221
+ format: D,
222
+ bankAccountId: rt,
223
+ reference: t,
224
+ mailingOption: O,
225
+ orgAddress: it,
226
+ manualAddress: A
227
+ });
228
+ if (!n) return;
229
+ T(l.Preparing);
230
+ let r = e.loading(C.toast.creating);
231
+ try {
232
+ let t = await $e.mutateAsync({ body: n });
233
+ if (!G.current) {
234
+ e.dismiss(r);
235
+ return;
236
+ }
237
+ He(t.id), We(t.cardStatus);
238
+ let i = [];
239
+ if (j) {
240
+ let e = fe({
241
+ cardId: t.id,
242
+ amount: N,
243
+ period: F,
244
+ id: crypto.randomUUID(),
245
+ name: C.velocityControlNames.spendLimit
246
+ });
247
+ e && i.push(e);
248
+ }
249
+ if (L) {
250
+ let e = de({
251
+ cardId: t.id,
252
+ amount: z,
253
+ id: crypto.randomUUID(),
254
+ name: C.velocityControlNames.perTransactionMaximum
255
+ });
256
+ e && i.push(e);
257
+ }
258
+ let a = !1;
259
+ if (i.length > 0) try {
260
+ await Promise.all(i.map((e) => et.mutateAsync({ body: e })));
261
+ } catch {
262
+ a = !0;
263
+ }
264
+ if (!G.current) {
265
+ e.dismiss(r);
266
+ return;
267
+ }
268
+ let o = !1;
269
+ if (Ye.length > 0) try {
270
+ await tt.mutateAsync({ body: {
271
+ debitCardIds: [t.id],
272
+ type: "GRANT",
273
+ userIds: Ye
274
+ } });
275
+ } catch {
276
+ o = !0;
277
+ }
278
+ if (!G.current) {
279
+ e.dismiss(r);
280
+ return;
281
+ }
282
+ if (T(l.Success), a && o) {
283
+ e.warning(C.toast.controlsAndAccessWarning, {
284
+ id: r,
285
+ duration: v
286
+ });
287
+ return;
288
+ }
289
+ if (a) {
290
+ e.warning(C.toast.controlsWarning, {
291
+ id: r,
292
+ duration: v
293
+ });
294
+ return;
295
+ }
296
+ if (o) {
297
+ e.warning(C.toast.companyAdminAccessWarning, {
298
+ id: r,
299
+ duration: v
300
+ });
301
+ return;
302
+ }
303
+ e.success(C.toast.success, {
304
+ id: r,
305
+ duration: Te
306
+ });
307
+ } catch {
308
+ if (!G.current) {
309
+ e.dismiss(r);
310
+ return;
311
+ }
312
+ T(l.Setup), e.error(C.toast.error, {
313
+ id: r,
314
+ duration: v
315
+ });
316
+ }
317
+ };
318
+ return /* @__PURE__ */ Se(xe, { children: [/* @__PURE__ */ _(a, {}), /* @__PURE__ */ _(ne, {
319
+ view: Fe,
320
+ cardArtSrc: t,
321
+ labels: yt,
322
+ className: De,
323
+ cardholderOptions: qe,
324
+ selectedCardholder: E,
325
+ onCardholderSelect: Ie,
326
+ isCardholderError: K,
327
+ onCardholderRetry: K ? Je : void 0,
328
+ cardFormatOptions: Ne,
329
+ selectedCardFormat: D,
330
+ onCardFormatSelect: (e) => {
331
+ Le(e), k(null);
332
+ },
333
+ isFundingAccountVisible: lt,
334
+ fundingAccountOptions: Q,
335
+ selectedFundingAccount: rt,
336
+ onFundingAccountSelect: ze,
337
+ isFundingAccountError: Z,
338
+ onFundingAccountRetry: Z ? () => {
339
+ X.refetch();
340
+ } : void 0,
341
+ isMailingSectionVisible: $,
342
+ selectedMailingOption: O,
343
+ onMailingOptionSelect: k,
344
+ businessAddress: at,
345
+ isBusinessAddressVisible: st,
346
+ isManualAddressVisible: ct,
347
+ manualAddress: A,
348
+ onManualAddressChange: (e) => Be((t) => ({
349
+ ...t,
350
+ ...e
351
+ })),
352
+ stateOptions: Pe,
353
+ isCardControlsSectionVisible: ut,
354
+ cardControls: _t,
355
+ isCreateDisabled: vt,
356
+ onCreateClick: () => {
357
+ bt();
358
+ },
359
+ onCancelClick: () => {
360
+ ke?.(), y?.();
361
+ },
362
+ onClose: y,
363
+ onCreateAnotherClick: Ge,
364
+ onViewCardClick: Ae && Ve ? () => {
365
+ Ae(Ve);
366
+ } : void 0
367
+ })] });
368
+ }
369
+ function ke({ baseUrl: e, widgetToken: t, organizationId: n, configClient: r, gatewayRouting: i, linkComponent: a, implementation: o, uiFramework: ee, errorFallback: te, onError: c, analytics: l, disclosuresAcceptance: u, providerLabels: ne, ...d }) {
370
+ return /* @__PURE__ */ _(s, {
371
+ widgetName: ue,
372
+ baseUrl: e,
373
+ widgetToken: t,
374
+ organizationId: n,
375
+ configClient: r,
376
+ gatewayRouting: i,
377
+ linkComponent: a,
378
+ implementation: o,
379
+ uiFramework: ee,
380
+ errorFallback: te,
381
+ onError: c,
382
+ analytics: l,
383
+ disclosuresAcceptance: u,
384
+ providerLabels: ne,
385
+ children: /* @__PURE__ */ _(y, { ...d })
386
+ });
387
+ }
388
+ //#endregion
389
+ export { ke as CreateCardWidget, Oe as formatFundingAccountLabel };