@capitalos/react 1.6.0 → 1.8.0
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.
- package/dist/index.d.mts +328 -52
- package/dist/index.d.mts.map +1 -0
- package/dist/index.d.ts +328 -52
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +11 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +18 -7
- package/dist/_tsup-dts-rollup.d.mts +0 -1733
- package/dist/_tsup-dts-rollup.d.ts +0 -1733
- package/dist/esm/index.js +0 -11
- package/dist/esm/index.js.map +0 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,52 +1,328 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
import React, { ReactNode } from "react";
|
|
4
|
+
import * as z$1 from "zod";
|
|
5
|
+
import { z } from "zod";
|
|
6
|
+
import "schemas";
|
|
7
|
+
import "utils";
|
|
8
|
+
|
|
9
|
+
//#region ../../client/common/rendering-context-schema.d.ts
|
|
10
|
+
declare const issueCardDefaultValuesSchema: z.ZodUnion<[z.ZodObject<{
|
|
11
|
+
firstName: z.ZodString;
|
|
12
|
+
lastName: z.ZodString;
|
|
13
|
+
phone: z.ZodString;
|
|
14
|
+
}, "strip", z.ZodTypeAny, {
|
|
15
|
+
firstName: string;
|
|
16
|
+
lastName: string;
|
|
17
|
+
phone: string;
|
|
18
|
+
}, {
|
|
19
|
+
firstName: string;
|
|
20
|
+
lastName: string;
|
|
21
|
+
phone: string;
|
|
22
|
+
}>, z.ZodObject<{
|
|
23
|
+
userId: z.ZodString;
|
|
24
|
+
}, "strip", z.ZodTypeAny, {
|
|
25
|
+
userId: string;
|
|
26
|
+
}, {
|
|
27
|
+
userId: string;
|
|
28
|
+
}>]>;
|
|
29
|
+
type IssueCardDefaultValues = z.infer<typeof issueCardDefaultValuesSchema>;
|
|
30
|
+
|
|
31
|
+
//#endregion
|
|
32
|
+
//#region ../../server/src/core/common.schema.d.ts
|
|
33
|
+
|
|
34
|
+
declare const accountStatusSchema: z$1.ZodEnum<["eligible", "ineligible", "engaged", "onboarding", "approved", "processing", "pending", "declined", "closed", "waiting"]>;
|
|
35
|
+
type AccountStatus = z$1.infer<typeof accountStatusSchema>; //#endregion
|
|
36
|
+
//#region src/types.d.ts
|
|
37
|
+
type ThemeColorScheme = 'light' | 'dark' | 'system';
|
|
38
|
+
declare const LogLevel: {
|
|
39
|
+
readonly log: "log";
|
|
40
|
+
readonly warn: "warn";
|
|
41
|
+
readonly error: "error";
|
|
42
|
+
};
|
|
43
|
+
type LogLevel = (typeof LogLevel)[keyof typeof LogLevel];
|
|
44
|
+
type Logger = {
|
|
45
|
+
[LogLevel.log]: (message: string) => void;
|
|
46
|
+
[LogLevel.warn]: (message: string) => void;
|
|
47
|
+
[LogLevel.error]: (message: string) => void;
|
|
48
|
+
};
|
|
49
|
+
type CommonProps = {
|
|
50
|
+
token?: string;
|
|
51
|
+
className?: string;
|
|
52
|
+
enableLogging?: boolean;
|
|
53
|
+
logger?: Logger;
|
|
54
|
+
onError?: (error: Error) => void;
|
|
55
|
+
loadingComponent?: ReactNode;
|
|
56
|
+
theme?: ThemeColorScheme;
|
|
57
|
+
};
|
|
58
|
+
type Account = {
|
|
59
|
+
status: AccountStatus;
|
|
60
|
+
};
|
|
61
|
+
type Card = {
|
|
62
|
+
status: 'active' | 'inactive' | 'canceled' | 'frozen';
|
|
63
|
+
};
|
|
64
|
+
|
|
65
|
+
//#endregion
|
|
66
|
+
//#region src/iframe-connection/types.d.ts
|
|
67
|
+
|
|
68
|
+
type ClientActionResult<T> = {
|
|
69
|
+
success: true;
|
|
70
|
+
canceled: false;
|
|
71
|
+
data: T;
|
|
72
|
+
} | {
|
|
73
|
+
success: false;
|
|
74
|
+
canceled: true;
|
|
75
|
+
} | {
|
|
76
|
+
success: false;
|
|
77
|
+
canceled: false;
|
|
78
|
+
error: string;
|
|
79
|
+
};
|
|
80
|
+
type ChildFunctions = {
|
|
81
|
+
freezeCard: (cardId: string) => Promise<ClientActionResult<Card>>;
|
|
82
|
+
unfreezeCard: (cardId: string) => Promise<ClientActionResult<Card>>;
|
|
83
|
+
}; //#endregion
|
|
84
|
+
//#region src/context/capital-os-authentication-context.d.ts
|
|
85
|
+
|
|
86
|
+
//# sourceMappingURL=types.d.ts.map
|
|
87
|
+
type ProviderProps = {
|
|
88
|
+
getToken: () => Promise<string>;
|
|
89
|
+
enableLogging?: boolean | undefined;
|
|
90
|
+
logger?: Logger | undefined;
|
|
91
|
+
children: React.ReactNode;
|
|
92
|
+
};
|
|
93
|
+
declare const CapitalOsAuthenticationProvider: React.FC<ProviderProps>;
|
|
94
|
+
|
|
95
|
+
//#endregion
|
|
96
|
+
//#region src/dev-tools.d.ts
|
|
97
|
+
type DevToolsProps = CommonProps;
|
|
98
|
+
declare function DevTools(props: DevToolsProps): JSX.Element;
|
|
99
|
+
|
|
100
|
+
//#endregion
|
|
101
|
+
//#region src/index.d.ts
|
|
102
|
+
//# sourceMappingURL=dev-tools.d.ts.map
|
|
103
|
+
declare function CardsApp(props: CommonProps): JSX.Element;
|
|
104
|
+
declare const App: typeof CardsApp;
|
|
105
|
+
type IssueCardResult = {
|
|
106
|
+
cardId: string;
|
|
107
|
+
};
|
|
108
|
+
type IssueCardProps = CommonProps & {
|
|
109
|
+
cardholder?: IssueCardDefaultValues;
|
|
110
|
+
onCreate?: (result: IssueCardResult) => void;
|
|
111
|
+
onDone: (result: IssueCardResult) => void;
|
|
112
|
+
onCancel: () => void;
|
|
113
|
+
};
|
|
114
|
+
declare function IssueCard({
|
|
115
|
+
cardholder,
|
|
116
|
+
onCreate,
|
|
117
|
+
onDone,
|
|
118
|
+
onCancel,
|
|
119
|
+
...restOfProps
|
|
120
|
+
}: IssueCardProps): JSX.Element;
|
|
121
|
+
type DisputeTransactionProps = CommonProps & {
|
|
122
|
+
transactionId: string;
|
|
123
|
+
onDone: () => void;
|
|
124
|
+
onCancel: () => void;
|
|
125
|
+
};
|
|
126
|
+
declare function DisputeTransaction({
|
|
127
|
+
transactionId,
|
|
128
|
+
onDone,
|
|
129
|
+
onCancel,
|
|
130
|
+
...restOfProps
|
|
131
|
+
}: DisputeTransactionProps): JSX.Element;
|
|
132
|
+
type BillPayAppProps = CommonProps;
|
|
133
|
+
declare function BillPayApp(props: BillPayAppProps): JSX.Element;
|
|
134
|
+
type CardDetailsConditionalProps = {
|
|
135
|
+
cardOnly?: false;
|
|
136
|
+
backOnly?: never;
|
|
137
|
+
} | {
|
|
138
|
+
cardOnly: true;
|
|
139
|
+
backOnly?: boolean;
|
|
140
|
+
};
|
|
141
|
+
type CardDetailsProps = CommonProps & {
|
|
142
|
+
cardId: string;
|
|
143
|
+
hideAddress?: boolean | undefined;
|
|
144
|
+
onCardCanceled?: () => void;
|
|
145
|
+
onHideSensitiveDetails?: () => void;
|
|
146
|
+
} & CardDetailsConditionalProps;
|
|
147
|
+
declare function CardDetails(props: CardDetailsProps): JSX.Element;
|
|
148
|
+
type AccountDetailsProps = CommonProps;
|
|
149
|
+
declare function AccountDetails(props: AccountDetailsProps): JSX.Element;
|
|
150
|
+
type AccountActionsProps = CommonProps;
|
|
151
|
+
declare function AccountActions(props: AccountActionsProps): JSX.Element;
|
|
152
|
+
type ManageBankConnectionsExternalAccount = {
|
|
153
|
+
id: string;
|
|
154
|
+
name: string;
|
|
155
|
+
last4: string;
|
|
156
|
+
status: 'enabled' | 'revoked' | 'disabled';
|
|
157
|
+
type: string;
|
|
158
|
+
};
|
|
159
|
+
type ManageBankConnectionsSummary = {
|
|
160
|
+
id: string;
|
|
161
|
+
bankName: string;
|
|
162
|
+
provider: 'fake' | 'plaid' | 'manual' | 'stripeTreasury' | 'treasuryPrime' | 'platformManagedBaas';
|
|
163
|
+
status: 'healthy' | 'actionRequired' | 'temporarilyUnavailable' | 'disabled';
|
|
164
|
+
externalAccounts: ManageBankConnectionsExternalAccount[];
|
|
165
|
+
};
|
|
166
|
+
type ManageBankConnectionsResult = {
|
|
167
|
+
bankConnections: ManageBankConnectionsSummary[];
|
|
168
|
+
};
|
|
169
|
+
type ManageBankConnectionsProps = CommonProps & {
|
|
170
|
+
onClose: () => void;
|
|
171
|
+
onChange?: (result: ManageBankConnectionsResult) => void;
|
|
172
|
+
hideTopLevelBackButton?: boolean;
|
|
173
|
+
hideTopLevelHeader?: boolean;
|
|
174
|
+
};
|
|
175
|
+
declare function ManageBankConnections({
|
|
176
|
+
onClose,
|
|
177
|
+
onChange,
|
|
178
|
+
hideTopLevelBackButton,
|
|
179
|
+
hideTopLevelHeader,
|
|
180
|
+
...restOfProps
|
|
181
|
+
}: ManageBankConnectionsProps): JSX.Element;
|
|
182
|
+
type ConfigureAutoPayProps = CommonProps & {
|
|
183
|
+
onClose: () => void;
|
|
184
|
+
};
|
|
185
|
+
declare function ConfigureAutoPay({
|
|
186
|
+
onClose,
|
|
187
|
+
...restOfProps
|
|
188
|
+
}: ConfigureAutoPayProps): JSX.Element;
|
|
189
|
+
type PolicySettingsProps = CommonProps & {
|
|
190
|
+
onClose: () => void;
|
|
191
|
+
};
|
|
192
|
+
declare function PolicySettings({
|
|
193
|
+
onClose,
|
|
194
|
+
...restOfProps
|
|
195
|
+
}: PolicySettingsProps): JSX.Element;
|
|
196
|
+
type ConnectToVendorsProps = CommonProps & {
|
|
197
|
+
cardId?: string;
|
|
198
|
+
onClose: () => void;
|
|
199
|
+
inlineCardOnFile?: boolean;
|
|
200
|
+
};
|
|
201
|
+
declare function ConnectToVendors({
|
|
202
|
+
cardId,
|
|
203
|
+
onClose,
|
|
204
|
+
inlineCardOnFile,
|
|
205
|
+
...restOfProps
|
|
206
|
+
}: ConnectToVendorsProps): JSX.Element;
|
|
207
|
+
type ApplicationStatus = 'ineligible' | 'eligible' | 'preapproved';
|
|
208
|
+
type BankAccount = {
|
|
209
|
+
id: string;
|
|
210
|
+
bankName: string;
|
|
211
|
+
accountName: string;
|
|
212
|
+
accountNumberMask: string;
|
|
213
|
+
accountNumber: string;
|
|
214
|
+
routingNumber: string;
|
|
215
|
+
type: string;
|
|
216
|
+
status: 'enabled' | 'disabled';
|
|
217
|
+
};
|
|
218
|
+
type ConnectBankAccountsResult = {
|
|
219
|
+
accounts: BankAccount[];
|
|
220
|
+
applicationStatus: ApplicationStatus;
|
|
221
|
+
};
|
|
222
|
+
type ConnectBankAccountsProps = CommonProps & {
|
|
223
|
+
onClose: () => void;
|
|
224
|
+
onDone: (result: ConnectBankAccountsResult) => void;
|
|
225
|
+
};
|
|
226
|
+
declare function ConnectBankAccounts({
|
|
227
|
+
onClose,
|
|
228
|
+
onDone,
|
|
229
|
+
...restOfProps
|
|
230
|
+
}: ConnectBankAccountsProps): JSX.Element;
|
|
231
|
+
type InsightsDashboardProps = CommonProps;
|
|
232
|
+
declare function InsightsDashboard(props: InsightsDashboardProps): JSX.Element;
|
|
233
|
+
type InsightsWidgetProps = CommonProps & {
|
|
234
|
+
widget: 'over-time-spend-by-card-per-month' | 'over-time-spend-by-category-per-month' | 'top-cards-by-spend-this-month' | 'top-categories-by-spend-this-month' | 'top-transactions-by-amount-this-month' | 'comparison-spend-this-month-vs-last-month';
|
|
235
|
+
hideTitle?: boolean | undefined;
|
|
236
|
+
height?: number | undefined;
|
|
237
|
+
width?: number | undefined;
|
|
238
|
+
};
|
|
239
|
+
declare function InsightsWidget(props: InsightsWidgetProps): JSX.Element;
|
|
240
|
+
type AllowedExitPoints = {
|
|
241
|
+
welcome: 'application' | 'activation';
|
|
242
|
+
application: 'application' | 'activation';
|
|
243
|
+
};
|
|
244
|
+
type OnboardingEntryPoint = keyof AllowedExitPoints;
|
|
245
|
+
type OnboardingProps<T extends keyof AllowedExitPoints> = CommonProps & {
|
|
246
|
+
entryPoint?: T;
|
|
247
|
+
exitPoint?: AllowedExitPoints[T];
|
|
248
|
+
allowExitOnNonApproved?: boolean | undefined;
|
|
249
|
+
doneButtonText?: string | undefined;
|
|
250
|
+
product?: 'billPay' | 'card' | undefined;
|
|
251
|
+
onDone: (account: Account) => void;
|
|
252
|
+
};
|
|
253
|
+
declare function Onboarding<T extends OnboardingEntryPoint>({
|
|
254
|
+
onDone,
|
|
255
|
+
entryPoint: onboardingEntryPoint,
|
|
256
|
+
exitPoint: onboardingExitPoint,
|
|
257
|
+
allowExitOnNonApproved,
|
|
258
|
+
doneButtonText,
|
|
259
|
+
product,
|
|
260
|
+
...restOfProps
|
|
261
|
+
}: OnboardingProps<T>): JSX.Element;
|
|
262
|
+
type MakePaymentProps = CommonProps & {
|
|
263
|
+
onDone: () => void;
|
|
264
|
+
};
|
|
265
|
+
declare function MakePayment({
|
|
266
|
+
onDone,
|
|
267
|
+
...restOfProps
|
|
268
|
+
}: MakePaymentProps): JSX.Element;
|
|
269
|
+
type ContactSupportProps = CommonProps & {
|
|
270
|
+
onDone: () => void;
|
|
271
|
+
onCancel: () => void;
|
|
272
|
+
};
|
|
273
|
+
declare function ContactSupport({
|
|
274
|
+
onDone,
|
|
275
|
+
onCancel,
|
|
276
|
+
...restOfProps
|
|
277
|
+
}: ContactSupportProps): JSX.Element;
|
|
278
|
+
type StatementsProps = CommonProps & {
|
|
279
|
+
onDone: () => void;
|
|
280
|
+
};
|
|
281
|
+
declare function Statements({
|
|
282
|
+
onDone,
|
|
283
|
+
...restOfProps
|
|
284
|
+
}: StatementsProps): JSX.Element;
|
|
285
|
+
type LegalDocumentsProps = CommonProps & {
|
|
286
|
+
onDone: () => void;
|
|
287
|
+
};
|
|
288
|
+
declare function LegalDocuments({
|
|
289
|
+
onDone,
|
|
290
|
+
...restOfProps
|
|
291
|
+
}: LegalDocumentsProps): JSX.Element;
|
|
292
|
+
type ReplaceCardProps = CommonProps & {
|
|
293
|
+
cardId: string;
|
|
294
|
+
onDone: (result: {
|
|
295
|
+
oldCardId: string;
|
|
296
|
+
newCardId: string;
|
|
297
|
+
}) => void;
|
|
298
|
+
onClose: () => void;
|
|
299
|
+
};
|
|
300
|
+
declare function ReplaceCard({
|
|
301
|
+
cardId,
|
|
302
|
+
onDone,
|
|
303
|
+
onClose,
|
|
304
|
+
...restOfProps
|
|
305
|
+
}: ReplaceCardProps): JSX.Element;
|
|
306
|
+
type TerminateCardProps = CommonProps & {
|
|
307
|
+
cardId: string;
|
|
308
|
+
onDone: () => void;
|
|
309
|
+
onClose: () => void;
|
|
310
|
+
};
|
|
311
|
+
declare function TerminateCard({
|
|
312
|
+
cardId,
|
|
313
|
+
onDone,
|
|
314
|
+
onClose,
|
|
315
|
+
...restOfProps
|
|
316
|
+
}: TerminateCardProps): JSX.Element;
|
|
317
|
+
type TransactionsProps = CommonProps;
|
|
318
|
+
declare function Transactions(props: TransactionsProps): JSX.Element;
|
|
319
|
+
declare function useActions(): {
|
|
320
|
+
actions: ChildFunctions | null;
|
|
321
|
+
isLoading: boolean;
|
|
322
|
+
};
|
|
323
|
+
|
|
324
|
+
//#endregion
|
|
325
|
+
//# sourceMappingURL=index.d.ts.map
|
|
326
|
+
|
|
327
|
+
export { Account, AccountActions, AccountActionsProps, AccountDetails, AccountDetailsProps, App, ApplicationStatus, BankAccount, BillPayApp, BillPayAppProps, CapitalOsAuthenticationProvider, CardDetails, CardDetailsProps, CardsApp, ConfigureAutoPay, ConfigureAutoPayProps, ConnectBankAccounts, ConnectBankAccountsProps, ConnectBankAccountsResult, ConnectToVendors, ConnectToVendorsProps, ContactSupport, ContactSupportProps, DevTools, DisputeTransaction, DisputeTransactionProps, InsightsDashboard, InsightsDashboardProps, InsightsWidget, InsightsWidgetProps, IssueCard, IssueCardProps, IssueCardResult, LegalDocuments, LegalDocumentsProps, LogLevel, Logger, MakePayment, MakePaymentProps, ManageBankConnections, ManageBankConnectionsExternalAccount, ManageBankConnectionsProps, ManageBankConnectionsResult, ManageBankConnectionsSummary, Onboarding, PolicySettings, PolicySettingsProps, ReplaceCard, ReplaceCardProps, Statements, StatementsProps, TerminateCard, TerminateCardProps, ThemeColorScheme, Transactions, TransactionsProps, useActions };
|
|
328
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","names":[],"sources":["../../../client/common/rendering-context-schema.ts","../../../server/src/core/common.schema.ts","../src/types.ts","../src/iframe-connection/types.ts","../src/context/capital-os-authentication-context.tsx","../src/dev-tools.tsx","../src/index.tsx"],"sourcesContent":null,"mappings":";;;;;;;;;cAEM,8BAA4B,CAAA,CAAA,UAAA,CAAA,CAAA;aAOhC,CAAA,CAAA;;;;;;EAPI,KAAA,EAAA,MAAA;CAOJ,EAAA;EAAA,SAAA,EAAA,MAAA;;;;QAPgC,EAAA,CAAA,CAAA,SAAA;CAAA,EAAA,OAAA,cAAA,EAAA;;;QAAA,EAAA,MAAA;AAAA,CAAA,CAAA,CAAA,CAAA;AAStB,KAAA,sBAAA,GAAyB,CAAA,CAAE,KAAL,CAAA,OAAkB,4BAAlB,CAAA;;;;;AMuLH,cL7HlB,mBK6HkB,EL7HC,GAAA,CAAA,OK6HD,CAAA,CAAA,UAAA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D;AAAmB,KA0gB7C,kBAAA,GAAqB,WA1gBwB,GAAA;EAAA,MAAA,EAAA,MAAA;EAS7C,MAAA,EAAA,GAAA,GAAA,IAAA;EAKI,OAAA,EAAA,GAAA,GAAA,IAAc;CAAA;AAAQ,iBAkgBtB,aAAA,CAlgBsB;EAAA,MAAA;EAAA,MAAA;EAAA,OAAA;EAAA,GAAA;AAAA,CAAA,EAkgBqC,kBAlgBrC,CAAA,EAkgBuD,GAAA,CAAA,OAlgBvD;AAAmB,KA6gB7C,iBAAA,GAAoB,WA7gByB;AAAA,iBAkhBzC,YAAA,CAlhByC,KAAA,EAkhBrB,iBAlhBqB,CAAA,EAkhBJ,GAAA,CAAA,OAlhBI;AAoE7C,iBA8eI,UAAA,CAAA,CA9euB,EAAA;EAO3B,OAAA,EAuec,cAAA,GAveY,IAAA;EAAA,SAAA,EAAA,OAAA;CAAA"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use strict";"use client";var De=Object.create;var W=Object.defineProperty,Re=Object.defineProperties,Fe=Object.getOwnPropertyDescriptor,ze=Object.getOwnPropertyDescriptors,Be=Object.getOwnPropertyNames,K=Object.getOwnPropertySymbols,$e=Object.getPrototypeOf,te=Object.prototype.hasOwnProperty,pe=Object.prototype.propertyIsEnumerable;var ue=(e,n,t)=>n in e?W(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,d=(e,n)=>{for(var t in n||(n={}))te.call(n,t)&&ue(e,t,n[t]);if(K)for(var t of K(n))pe.call(n,t)&&ue(e,t,n[t]);return e},m=(e,n)=>Re(e,ze(n));var k=(e,n)=>{var t={};for(var o in e)te.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(e!=null&&K)for(var o of K(e))n.indexOf(o)<0&&pe.call(e,o)&&(t[o]=e[o]);return t};var He=(e,n)=>{for(var t in n)W(e,t,{get:n[t],enumerable:!0})},me=(e,n,t,o)=>{if(n&&typeof n=="object"||typeof n=="function")for(let r of Be(n))!te.call(e,r)&&r!==t&&W(e,r,{get:()=>n[r],enumerable:!(o=Fe(n,r))||o.enumerable});return e};var S=(e,n,t)=>(t=e!=null?De($e(e)):{},me(n||!e||!e.__esModule?W(t,"default",{value:e,enumerable:!0}):t,e)),Ue=e=>me(W({},"__esModule",{value:!0}),e);var U=(e,n,t)=>new Promise((o,r)=>{var i=u=>{try{a(t.next(u))}catch(f){r(f)}},s=u=>{try{a(t.throw(u))}catch(f){r(f)}},a=u=>u.done?o(u.value):Promise.resolve(u.value).then(i,s);a((t=t.apply(e,n)).next())});var Ln={};He(Ln,{AccountActions:()=>cn,AccountDetails:()=>an,App:()=>nn,BillPayApp:()=>rn,CapitalOsAuthenticationProvider:()=>Me,CardDetails:()=>sn,CardsApp:()=>Se,ConfigureAutoPay:()=>ln,ConnectBankAccounts:()=>mn,ConnectToVendors:()=>pn,ContactSupport:()=>hn,DevTools:()=>we,DisputeTransaction:()=>on,InsightsDashboard:()=>fn,InsightsWidget:()=>gn,IssueCard:()=>tn,LegalDocuments:()=>Pn,MakePayment:()=>xn,ManageBankConnections:()=>dn,Onboarding:()=>Cn,PolicySettings:()=>un,ReplaceCard:()=>bn,Statements:()=>yn,TerminateCard:()=>kn,Transactions:()=>Tn,useActions:()=>vn});module.exports=Ue(Ln);var c=S(require("react"));var _=S(require("react"));var h=S(require("react"));var R=S(require("react"));var T=class extends Error{constructor({message:n,code:t}){super(n),this.name="CapitalOSError",this.code=t}},I={unauthorized:"unauthorized",invalid_account_status:"invalid_account_status",unsupported_entry_point:"unsupported_entry_point",internal_error:"internal_error"},z=class extends T{constructor(n){super({message:`Invalid token ${n!=null?n:""}`,code:I.unauthorized}),this.name="CapitalOSInvalidTokenError"}};var G=require("penpal"),P=require("react");var fe=require("react");function N(e){let n=(0,fe.useRef)(e);return n.current=e,n}var Ne={enableLogging:!1},_e="[CapitalOS] ";function oe(e){return(n,t=Ne)=>{try{let o=`${_e}${n}`;t.logger?t.logger[e](o):t.enableLogging&&console[e](o)}catch(o){}}}var J={log:oe("log"),warn:oe("warn"),error:oe("error")};function re(e){return e?e.length<=12?"***":`${e.substring(0,4)}...${e.substring(e.length-4)}`:"undefined"}function X(e){try{return e.replace(/([?&#])(token|access_token)=([^&\s#]+)/gi,(n,t,o,r)=>!r||r.length<=12?`${t}${o}=***`:`${t}${o}=${re(r)}`)}catch(n){return"[URL redacted due to processing error]"}}function ie(e){try{let n=decodeURIComponent(e),t=atob(n);return JSON.parse(t)}catch(n){throw new z}}function Z(e){let t=ie(e).path;if(!t||typeof t!="string")throw new z;return{token:e,tokenType:"oneTime",baseUrl:t,paramKey:"token",paramLocation:"search"}}var ge="1.6.0";function Ke(e){let n=JSON.stringify(e),t=btoa(n);return encodeURIComponent(t)}function Je(e){try{return decodeURIComponent(e)}catch(n){return e}}function Ce({tokenData:e,renderingContext:n,theme:t,onError:o}){try{let r=n?m(d({},n),{referer:window.location.href}):null,i=r?Ke(r):null,s=new URL(e.baseUrl),a=Je(e.token);return e.paramLocation==="search"?s.searchParams.set(e.paramKey,a):e.paramLocation==="hash"&&(s.hash=e.paramKey+"="+encodeURIComponent(a)),s.searchParams.set("sdkVersion",ge),i&&s.searchParams.set("renderingContext",i),t&&s.searchParams.set("theme",t),s.toString()}catch(r){o==null||o(new z);return}}var xe=1e4;function Xe(e){return(...n)=>{try{let t=n.map(o=>{if(typeof o=="string")return o;if(o instanceof Error)return o.message;try{return JSON.stringify(o)}catch(r){return String(o)}}).join(" ");e(t)}catch(t){}}}function se({iframeRef:e,token:n,onError:t,methods:o,iframeLabel:r}){let[i,s]=(0,P.useState)(null),{log:a}=O(),u=N(o),f=N(t),l=N(r),g=(0,P.useMemo)(()=>Xe(a),[a]);return(0,P.useEffect)(()=>{let y=l.current?`[${l.current}] `:"";if(!e.current){a(`${y}Iframe ref not available - iframe element may not be mounted`);return}if(!e.current.contentWindow){a(`${y}Iframe contentWindow not accessible - may be blocked by browser security policy or CSP`);return}a(`${y}Establishing Penpal connection to iframe`);let b=!0,M=new G.WindowMessenger({remoteWindow:e.current.contentWindow,allowedOrigins:["*"]}),C=(0,G.connect)({messenger:M,methods:u.current,timeout:xe,log:g});return C.promise.then(()=>{b&&(a(`${y}Penpal connection established successfully`),s(C))}).catch(A=>{var v;b&&(a(`${y}Penpal connection failed: ${A.message}. Timeout: ${xe}ms`),(v=f.current)==null||v.call(f,A),s(null))}),()=>{b=!1,a(`${y}Destroying Penpal connection (cleanup triggered - likely due to token or iframeRef change, or component unmount)`),C.destroy(),s(null)}},[n,a,g]),i}function ae({tokenData:e,renderingContext:n,theme:t,onError:o}){let r=(0,P.useRef)(o),i=(0,P.useRef)(n);return(0,P.useMemo)(()=>{if(e)return Ce({tokenData:e,renderingContext:i.current,theme:t,onError:r.current})},[e,t,r,i])}function Q(e){let{oneTimeToken:n,enableLogging:t,onError:o,renderingContext:r,theme:i,methods:s}=e,{tokenData:a,error:u,invalidateToken:f}=Y(),{log:l,warn:g}=O(t),[y,b]=(0,P.useState)(!1),M=(0,P.useRef)(null);Ze(u,o);let C=(0,P.useMemo)(()=>n?Z(n):a,[n,a]);(0,P.useEffect)(()=>{C&&l(`[${r.entryPoint}] Token data available, type: ${C.tokenType}, token: ${re(C.token)}, location: ${C.paramLocation}, key: ${C.paramKey}, baseUrl: ${C.baseUrl}`)},[C,l,r.entryPoint]);let A=(0,P.useCallback)(()=>{if(l("Token expired, invalidating..."),n){o==null||o(new T({message:"Token expired. Cannot automatically refresh when using token prop.",code:I.unauthorized}));return}f(),b(!1)},[l,n,f,o]);(0,P.useEffect)(()=>{n&&a&&g("token was provided both from provider and from the token prop. the prop will take precedence")},[n,a,g]);let v=ae({tokenData:C,renderingContext:r,theme:i,onError:o});(0,P.useEffect)(()=>{v?l(`Iframe URL generated: ${X(v).substring(0,1024)}...`):C&&g("Failed to generate iframe URL despite having token data")},[v,C,l,g]);let L=se({iframeRef:M,token:C==null?void 0:C.token,iframeLabel:r.entryPoint,onError:p=>{l(`Connection error: ${p.message}`),o==null||o(p),b(!0)},methods:d({onLoad:()=>{l("Iframe called onLoad()"),b(!0)},onError:p=>{let V=new T(p);l(`Iframe error: ${V.message}`),o==null||o(V)},onTokenExpired:A},s)});return{isLoaded:y,url:v,tokenData:C,iframeRef:M,connection:L}}function Ze(e,n){let t=(0,P.useRef)(!1);(0,P.useEffect)(()=>{e&&!t.current&&(n==null||n(e),t.current=!0)},[e,n])}var he=require("iframe-resizer"),D=S(require("react"));var B=(0,D.forwardRef)((e,n)=>{let t=e.title||"iframe",{iframeHTMLAttributes:o,resizerOptions:r}=Ye(e),i=(0,D.useRef)(null);return(0,D.useEffect)(()=>{let s=i.current;return(0,he.iframeResizer)(d({},r),s),()=>s.iFrameResizer&&s.iFrameResizer.removeListeners()}),(0,D.useImperativeHandle)(n,()=>i.current),D.default.createElement("iframe",m(d({},o),{title:t,ref:i}))});B.displayName="IframeResizer";var Ge=["autoResize","bodyBackground","bodyMargin","bodyPadding","checkOrigin","inPageLinks","heightCalculationMethod","interval","log","maxHeight","maxWidth","minHeight","minWidth","resizeFrom","scrolling","sizeHeight","sizeWidth","warningTimeout","tolerance","widthCalculationMethod","onClosed","onInit","onMessage","onResized","onScroll"],Qe=new Set(Ge);function Ye(e){return Object.keys(e).reduce((t,o)=>{let r=e[o];return Qe.has(o)?r!==void 0&&(t.resizerOptions[o]=e[o]):t.iframeHTMLAttributes[o]=e[o],t},{resizerOptions:{},iframeHTMLAttributes:{}})}function ye(e){let{oneTimeToken:n,enableLogging:t,onExchangeComplete:o,onExchangeError:r}=e,i=$(t),{log:s}=O(t),a=(0,R.useRef)(null),u=(0,R.useMemo)(()=>Z(n),[n]),l=ae({tokenData:u,onError:r,renderingContext:{entryPoint:"tokenExchange"}});return(0,R.useEffect)(()=>{if(l){let g=X(l),y=g.substring(0,1024),b=g.length>1024;s(`Token exchange iframe URL: ${y}${b?"...":""}`)}},[l,s]),se({iframeRef:a,token:n,iframeLabel:"token-exchange",onError:g=>{s(`Token exchange connection error: ${g.message}`),r==null||r(g)},methods:{onLoad:()=>{s("Token exchange iframe loaded")},onError:g=>{s(`Token exchange iframe error: ${g.message}`),r==null||r(new T(g))},tokenExchange:{onLongLivedToken:g=>{s("Token exchange complete: received long-lived token"),o(g)}}}}),R.default.createElement(B,{src:l,checkOrigin:!1,style:{display:"none"},log:i,ref:a,onLoad:()=>{s("Token exchange iframe HTML loaded successfully")},onError:g=>{s(`Token exchange iframe failed to load: ${g}`)}})}var ee=require("react");function ne(e){let n=(0,ee.useRef)(e);return n.current=e,(0,ee.useCallback)((...t)=>n.current(...t),[])}var E=S(require("react"));var Pe=S(require("react")),be=require("react");function ke(u){var f=u,{onDone:e,onCancel:n,mfaId:t,destination:o,codeLength:r,canResendAfter:i,operationName:s}=f,a=k(f,["onDone","onCancel","mfaId","destination","codeLength","canResendAfter","operationName"]);let l="mfa",g=(0,be.useMemo)(()=>({entryPoint:l,mfaId:t,destination:o,codeLength:r,canResendAfter:i,operationName:s}),[l,t,o,r,i,s]);return Pe.default.createElement(x,m(d({},a),{renderingContext:g,methods:{mfa:{onDone:e,onCancel:n}}}))}var j=S(require("react")),Te={backdrop:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(2px)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:"20px"},container:{backgroundColor:"white",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.05)",maxWidth:"600px",width:"100%",maxHeight:"90vh",overflow:"hidden",position:"relative"}};function ve({onClose:e,children:n,ariaLabel:t="Modal dialog"}){(0,j.useEffect)(()=>{let r=i=>{i.key==="Escape"&&e()};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[e]);let o=r=>{r.target===r.currentTarget&&e()};return j.default.createElement("div",{style:Te.backdrop,onClick:o,role:"dialog","aria-modal":"true","aria-label":t},j.default.createElement("div",{style:Te.container},n))}var H=require("react");function Le(){var f;let[e,n]=(0,H.useState)(null),{log:t}=O(),o=(0,H.useCallback)(l=>(t("MFA requested"),new Promise((g,y)=>{n({context:l,resolve:g,reject:y})})),[t]),r=(0,H.useCallback)(()=>{e&&(t("MFA completed successfully"),e.resolve({success:!0,canceled:!1,data:void 0}),n(null))},[e,t]),i=(0,H.useCallback)(()=>{e&&(t("MFA canceled"),e.resolve({success:!1,canceled:!0}),n(null))},[e,t]),s=(0,H.useCallback)(l=>{e&&(t("MFA error: "+l.message),e.resolve({success:!1,canceled:!1,error:l}),n(null))},[e,t]),a=!!e,u=(f=e==null?void 0:e.context)!=null?f:null;return{activeMfaRequest:e,isMfaActive:a,mfaContext:u,requestMfa:o,handleMfaDone:r,handleMfaCancel:i,handleMfaError:s}}var ce=(0,E.createContext)(null);function Ee({children:e}){let[n,t]=(0,E.useState)(null),o=$(),{log:r}=O(),{requestMfa:i,handleMfaDone:s,handleMfaCancel:a,isMfaActive:u,mfaContext:f}=Le(),l=(0,E.useCallback)(L=>U(null,null,function*(){let p=yield i(L);return p.success?{success:!0}:p.canceled?{success:!1,canceled:!0}:{success:!1,error:p.error.message}}),[i]),g=(0,E.useMemo)(()=>n?{freezeCard:L=>U(null,null,function*(){try{let p=yield n.freezeCard(L);return p.success?{success:!0,canceled:!1,data:p.data}:p.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new T({code:I.internal_error,message:p.error})}}catch(p){return{success:!1,canceled:!1,error:new T({code:I.internal_error,message:p instanceof Error?p.message:"Communication error with iframe"})}}}),unfreezeCard:L=>U(null,null,function*(){try{let p=yield n.unfreezeCard(L);return p.success?{success:!0,canceled:!1,data:p.data}:p.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new T({code:I.internal_error,message:p.error})}}catch(p){return{success:!1,canceled:!1,error:new T({code:I.internal_error,message:p instanceof Error?p.message:"Communication error with iframe"})}}})}:null,[n]),y=(0,E.useMemo)(()=>({"system-messages":{requestMfa:l},mfa:{onDone:s,onCancel:a}}),[l,s,a]),{isLoaded:b,url:M,connection:C,iframeRef:A}=Q({renderingContext:{entryPoint:"actions"},methods:y});E.default.useEffect(()=>{let L=!0;return C&&C.promise.then(p=>{L&&(t(p),r("Actions iframe child functions loaded"))}),()=>{L=!1}},[C,r]);let v=!b||!n;return E.default.createElement(ce.Provider,{value:{childFunctions:n,actions:g,isLoading:v}},e,M&&E.default.createElement(B,{src:M,style:{display:"none"},checkOrigin:!1,log:o,ref:A,onLoad:()=>{r("Actions iframe HTML loaded successfully")},onError:L=>{r(`Actions iframe failed to load: ${L}. This may indicate network issues or security policy blocking.`)}}),u&&f&&E.default.createElement(ve,{onClose:a,ariaLabel:"Multi-factor authentication"},E.default.createElement(ke,m(d({mfaId:f.mfaId,destination:f.destination,codeLength:f.codeLength,canResendAfter:f.canResendAfter},f.operationName&&{operationName:f.operationName}),{onDone:s,onCancel:a}))))}var Ie=(0,h.createContext)({isLoading:!1,invalidateToken:()=>{},enableLogging:!1,loggerRef:{current:void 0}}),Me=({getToken:e,enableLogging:n,logger:t,children:o})=>{let[r,i]=(0,h.useState)(void 0),[s,a]=(0,h.useState)(void 0),[u,f]=(0,h.useState)(void 0),[l,g]=(0,h.useState)(!1),[y,b]=(0,h.useState)(void 0),M=N(t),C=(0,h.useCallback)(()=>U(null,null,function*(){g(!0);try{let p=yield e();i(p),b(void 0);let V=ie(p),le=new URL(V.path);le.pathname="",a(le.toString())}catch(p){b(p)}finally{g(!1)}}),[e]),A=(0,h.useCallback)(()=>{f(void 0)},[]);(0,h.useEffect)(()=>{u||C()},[u,C]);let v=(0,h.useCallback)(p=>{f(p),i(void 0),b(void 0)},[]),L=(0,h.useMemo)(()=>{if(u&&!s)throw new T({message:"baseUrl is required for long lived tokens",code:I.unauthorized});return{tokenData:u?{token:u,tokenType:"longLived",baseUrl:s,paramKey:"access_token",paramLocation:"hash"}:void 0,isLoading:l,error:y,invalidateToken:A,enableLogging:n!=null?n:!1,loggerRef:M}},[u,l,y,A,s,n]);return h.default.createElement(h.default.Fragment,null,h.default.createElement(Ie.Provider,{value:L},h.default.createElement(Ee,null,o)),r&&!u&&h.default.createElement(ye,{oneTimeToken:r,onExchangeComplete:v,enableLogging:n,onExchangeError:b}))},Y=()=>(0,h.useContext)(Ie);function $(e){let{enableLogging:n}=Y();return e!==void 0?e:n}function O(e){let n=$(e),{loggerRef:t}=Y(),o=ne(s=>{var a;J.log(s,{enableLogging:n,logger:(a=t.current)!=null?a:void 0})}),r=ne(s=>{var a;J.warn(s,{enableLogging:n,logger:(a=t.current)!=null?a:void 0})}),i=ne(s=>{var a;J.error(s,{enableLogging:n,logger:(a=t.current)!=null?a:void 0})});return(0,h.useMemo)(()=>({log:o,warn:r,error:i}),[o,r,i])}function x(e){let{token:n,className:t,enableLogging:o,onError:r,loadingComponent:i,renderingContext:s,methods:a,theme:u,sizeWidth:f}=e,l=$(o),{log:g}=O(o),{isLoaded:y,url:b,tokenData:M,iframeRef:C}=Q({oneTimeToken:n,enableLogging:l,onError:r,renderingContext:s,theme:u,methods:a});if(!M||!b)return _.default.createElement(_.default.Fragment,null,i||null);let A=s.entryPoint!=="insightsWidget";return _.default.createElement(_.default.Fragment,null,!y&&i,_.default.createElement(B,{src:b,allow:"clipboard-write",checkOrigin:!1,style:{width:"1px",height:"0px",minWidth:"100%"},className:t,log:l,ref:C,hidden:!y,onLoad:()=>{g(`Main iframe HTML loaded successfully for entry point: ${s.entryPoint}`)},onError:v=>{g(`Main iframe failed to load: ${v}. This may indicate network issues, firewall blocking, or CSP violations.`)},onResized:v=>{if(!A)return;let L=`${parseInt(v.height)+12}px`;v.iframe.style.height=L},sizeWidth:f}))}var F=S(require("react")),Oe=require("react");var w=S(require("react"));var q={bugButton:{position:"fixed",left:"12px",bottom:"12px",margin:"12px",padding:"4px",display:"inline-flex",alignItems:"center",borderRadius:"9999px",border:"1px solid transparent",backgroundColor:"#2563eb",color:"white",opacity:.4,boxShadow:"0 1px 3px 0 rgb(0 0 0 / 0.1)",cursor:"pointer",zIndex:50,transition:"opacity 0.3s ease-in-out"},bugButtonHover:{backgroundColor:"#1d4ed8",opacity:1},bugButtonFocus:{outline:"none",boxShadow:"0 0 0 2px white, 0 0 0 4px #3b82f6"},bugIcon:{width:"20px",height:"20px"},loadingButton:{cursor:"default",opacity:1,animation:"pulse 1s cubic-bezier(0.4, 0, 0.6, 1) infinite"}},Ae=()=>w.default.createElement("svg",{style:q.bugIcon,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor"},w.default.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 12.75c1.148 0 2.278.08 3.383.237 1.037.146 1.866.966 1.866 2.013 0 3.728-2.35 6.75-5.25 6.75S6.75 18.728 6.75 15c0-1.046.83-1.867 1.866-2.013A24.204 24.204 0 0 1 12 12.75Zm0 0c2.883 0 5.647.508 8.207 1.44a23.91 23.91 0 0 1-1.152 6.06M12 12.75c-2.883 0-5.647.508-8.208 1.44.125 2.104.52 4.136 1.153 6.06M12 12.75a2.25 2.25 0 0 0 2.248-2.354M12 12.75a2.25 2.25 0 0 1-2.248-2.354M12 8.25c.995 0 1.971-.08 2.922-.236.403-.066.74-.358.795-.762a3.778 3.778 0 0 0-.399-2.25M12 8.25c-.995 0-1.97-.08-2.922-.236-.402-.066-.74-.358-.795-.762a3.734 3.734 0 0 1 .4-2.253M12 8.25a2.25 2.25 0 0 0-2.248 2.146M12 8.25a2.25 2.25 0 0 1 2.248 2.146M8.683 5a6.032 6.032 0 0 1-1.155-1.002c.07-.63.27-1.222.574-1.747m.581 2.749A3.75 3.75 0 0 1 15.318 5m0 0c.427-.283.815-.62 1.155-.999a4.471 4.471 0 0 0-.575-1.752M4.921 6a24.048 24.048 0 0 0-.392 3.314c1.668.546 3.416.914 5.223 1.082M19.08 6c.205 1.08.337 2.187.392 3.314a23.882 23.882 0 0 1-5.223 1.082"}));function de({onClick:e,isLoading:n=!1}){let[t,o]=(0,w.useState)(!1),[r,i]=(0,w.useState)(!1),s=d(d(d(d({},q.bugButton),n&&q.loadingButton),!n&&t&&q.bugButtonHover),!n&&r&&q.bugButtonFocus);return n?w.default.createElement("div",{style:s},w.default.createElement("style",null,`
|
|
1
|
+
"use client";"use strict";var e=Object.create,t=Object.defineProperty,n=Object.getOwnPropertyDescriptor,r=Object.getOwnPropertyNames,i=Object.getPrototypeOf,a=Object.prototype.hasOwnProperty,o=(e,i,o,s)=>{if(i&&typeof i==`object`||typeof i==`function`)for(var c=r(i),l=0,u=c.length,d;l<u;l++)d=c[l],!a.call(e,d)&&d!==o&&t(e,d,{get:(e=>i[e]).bind(null,d),enumerable:!(s=n(i,d))||s.enumerable});return e},s=(n,r,a)=>(a=n==null?{}:e(i(n)),o(r||!n||!n.__esModule?t(a,`default`,{value:n,enumerable:!0}):a,n));const c=s(require(`react`)),l=s(require(`penpal`)),u=s(require(`iframe-resizer`));var d=class extends Error{code;constructor({message:e,code:t}){super(e),this.name=`CapitalOSError`,this.code=t}};const f={unauthorized:`unauthorized`,invalid_account_status:`invalid_account_status`,unsupported_entry_point:`unsupported_entry_point`,internal_error:`internal_error`};var p=class extends d{constructor(e){super({message:`Invalid token ${e??``}`,code:f.unauthorized}),this.name=`CapitalOSInvalidTokenError`}};function m(e){let t=(0,c.useRef)(e);return t.current=e,t}const h={enableLogging:!1},g=`[CapitalOS] `;function _(e){return(t,n=h)=>{try{let r=`${g}${t}`;n.logger?n.logger[e](r):n.enableLogging&&console[e](r)}catch{}}}const v={log:_(`log`),warn:_(`warn`),error:_(`error`)};function y(e){return e?e.length<=12?`***`:`${e.substring(0,4)}...${e.substring(e.length-4)}`:`undefined`}function b(e){try{return e.replace(/([?&#])(token|access_token)=([^&\s#]+)/gi,(e,t,n,r)=>!r||r.length<=12?`${t}${n}=***`:`${t}${n}=${y(r)}`)}catch{return`[URL redacted due to processing error]`}}let x=function(e){return e.oneTime=`oneTime`,e.longLived=`longLived`,e}({}),S=function(e){return e.search=`search`,e.hash=`hash`,e}({}),C=function(e){return e.token=`token`,e.accessToken=`access_token`,e}({});function w(e){try{let t=decodeURIComponent(e),n=atob(t);return JSON.parse(n)}catch{throw new p}}function T(e){let t=w(e),n=t.path;if(!n||typeof n!=`string`)throw new p;let r={token:e,tokenType:x.oneTime,baseUrl:n,paramKey:C.token,paramLocation:S.search};return r}var E=`1.8.0`;function D(e){let t=JSON.stringify(e),n=btoa(t),r=encodeURIComponent(n);return r}function ee(e){try{return decodeURIComponent(e)}catch{return e}}function te({tokenData:e,renderingContext:t,theme:n,onError:r}){try{let r=t?{...t,referer:window.location.href}:null,i=r?D(r):null,a=new URL(e.baseUrl),o=ee(e.token);e.paramLocation===`search`?a.searchParams.set(e.paramKey,o):e.paramLocation===`hash`&&(a.hash=e.paramKey+`=`+encodeURIComponent(o)),a.searchParams.set(`sdkVersion`,E),i&&a.searchParams.set(`renderingContext`,i),n&&a.searchParams.set(`theme`,n);let s=a.toString();return s}catch{r?.(new p);return}}const O=1e4;function k(e){return(...t)=>{try{let n=t.map(e=>{if(typeof e==`string`)return e;if(e instanceof Error)return e.message;try{return JSON.stringify(e)}catch{return String(e)}}).join(` `);e(n)}catch{}}}function A({iframeRef:e,token:t,onError:n,methods:r,iframeLabel:i}){let[a,o]=(0,c.useState)(null),{log:s}=q(),u=m(r),d=m(n),f=m(i),p=(0,c.useMemo)(()=>k(s),[s]);return(0,c.useEffect)(()=>{let t=f.current?`[${f.current}] `:``;if(!e.current){s(`${t}Iframe ref not available - iframe element may not be mounted`);return}if(!e.current.contentWindow){s(`${t}Iframe contentWindow not accessible - may be blocked by browser security policy or CSP`);return}s(`${t}Establishing Penpal connection to iframe`);let n=!0,r=new l.WindowMessenger({remoteWindow:e.current.contentWindow,allowedOrigins:[`*`]}),i=(0,l.connect)({messenger:r,methods:u.current,timeout:O,log:p});return i.promise.then(()=>{n&&(s(`${t}Penpal connection established successfully`),o(i))}).catch(e=>{n&&(s(`${t}Penpal connection failed: ${e.message}. Timeout: ${O}ms`),d.current?.(e),o(null))}),()=>{n=!1,s(`${t}Destroying Penpal connection (cleanup triggered - likely due to token or iframeRef change, or component unmount)`),i.destroy(),o(null)}},[t,s,p]),a}function j({tokenData:e,renderingContext:t,theme:n,onError:r}){let i=(0,c.useRef)(r),a=(0,c.useRef)(t);return(0,c.useMemo)(()=>{if(e)return te({tokenData:e,renderingContext:a.current,theme:n,onError:i.current})},[e,n,i,a])}function M(e){let{oneTimeToken:t,enableLogging:n,onError:r,renderingContext:i,theme:a,methods:o}=e,{tokenData:s,error:l,invalidateToken:u}=G(),{log:p,warn:m}=q(n),[h,g]=(0,c.useState)(!1),_=(0,c.useRef)(null);N(l,r);let v=(0,c.useMemo)(()=>t?T(t):s,[t,s]);(0,c.useEffect)(()=>{v&&p(`[${i.entryPoint}] Token data available, type: ${v.tokenType}, token: ${y(v.token)}, location: ${v.paramLocation}, key: ${v.paramKey}, baseUrl: ${v.baseUrl}`)},[v,p,i.entryPoint]);let x=(0,c.useCallback)(()=>{if(p(`Token expired, invalidating...`),t){r?.(new d({message:`Token expired. Cannot automatically refresh when using token prop.`,code:f.unauthorized}));return}u(),g(!1)},[p,t,u,r]);(0,c.useEffect)(()=>{t&&s&&m(`token was provided both from provider and from the token prop. the prop will take precedence`)},[t,s,m]);let S=j({tokenData:v,renderingContext:i,theme:a,onError:r});(0,c.useEffect)(()=>{S?p(`Iframe URL generated: ${b(S).substring(0,1024)}...`):v&&m(`Failed to generate iframe URL despite having token data`)},[S,v,p,m]);let C=A({iframeRef:_,token:v?.token,iframeLabel:i.entryPoint,onError:e=>{p(`Connection error: ${e.message}`),r?.(e),g(!0)},methods:{onLoad:()=>{p(`Iframe called onLoad()`),g(!0)},onError:e=>{let t=new d(e);p(`Iframe error: ${t.message}`),r?.(t)},onTokenExpired:x,...o}});return{isLoaded:h,url:S,tokenData:v,iframeRef:_,connection:C}}function N(e,t){let n=(0,c.useRef)(!1);(0,c.useEffect)(()=>{e&&!n.current&&(t?.(e),n.current=!0)},[e,t])}const P=(0,c.forwardRef)((e,t)=>{let n=e.title||`iframe`,{iframeHTMLAttributes:r,resizerOptions:i}=L(e),a=(0,c.useRef)(null);return(0,c.useEffect)(()=>{let e=a.current;return(0,u.iframeResizer)({...i},e),()=>e.iFrameResizer&&e.iFrameResizer.removeListeners()}),(0,c.useImperativeHandle)(t,()=>a.current),c.default.createElement(`iframe`,{...r,title:n,ref:a})});P.displayName=`IframeResizer`;const F=[`autoResize`,`bodyBackground`,`bodyMargin`,`bodyPadding`,`checkOrigin`,`inPageLinks`,`heightCalculationMethod`,`interval`,`log`,`maxHeight`,`maxWidth`,`minHeight`,`minWidth`,`resizeFrom`,`scrolling`,`sizeHeight`,`sizeWidth`,`warningTimeout`,`tolerance`,`widthCalculationMethod`,`onClosed`,`onInit`,`onMessage`,`onResized`,`onScroll`],I=new Set(F);function L(e){let t=Object.keys(e).reduce((t,n)=>{let r=e[n];return I.has(n)?r!==void 0&&(t.resizerOptions[n]=e[n]):t.iframeHTMLAttributes[n]=e[n],t},{resizerOptions:{},iframeHTMLAttributes:{}});return t}function R(e){let{oneTimeToken:t,enableLogging:n,onExchangeComplete:r,onExchangeError:i}=e,a=K(n),{log:o}=q(n),s=(0,c.useRef)(null),l=(0,c.useMemo)(()=>T(t),[t]),u={entryPoint:`tokenExchange`},f=j({tokenData:l,onError:i,renderingContext:u});return(0,c.useEffect)(()=>{if(f){let e=b(f),t=e.substring(0,1024),n=e.length>1024;o(`Token exchange iframe URL: ${t}${n?`...`:``}`)}},[f,o]),A({iframeRef:s,token:t,iframeLabel:`token-exchange`,onError:e=>{o(`Token exchange connection error: ${e.message}`),i?.(e)},methods:{onLoad:()=>{o(`Token exchange iframe loaded`)},onError:e=>{o(`Token exchange iframe error: ${e.message}`),i?.(new d(e))},tokenExchange:{onLongLivedToken:e=>{o(`Token exchange complete: received long-lived token`),r(e)}}}}),c.default.createElement(P,{src:f,checkOrigin:!1,style:{display:`none`},log:a,ref:s,onLoad:()=>{o(`Token exchange iframe HTML loaded successfully`)},onError:e=>{o(`Token exchange iframe failed to load: ${e}`)}})}function z(e){let t=(0,c.useRef)(e);return t.current=e,(0,c.useCallback)((...e)=>t.current(...e),[])}function ne({onDone:e,onCancel:t,mfaId:n,destination:r,codeLength:i,canResendAfter:a,operationName:o,...s}){let l=`mfa`,u=(0,c.useMemo)(()=>({entryPoint:l,mfaId:n,destination:r,codeLength:i,canResendAfter:a,operationName:o}),[l,n,r,i,a,o]);return c.default.createElement(J,{...s,renderingContext:u,methods:{mfa:{onDone:e,onCancel:t}}})}const B={backdrop:{position:`fixed`,top:0,left:0,right:0,bottom:0,backgroundColor:`rgba(0, 0, 0, 0.4)`,backdropFilter:`blur(2px)`,zIndex:1e3,display:`flex`,alignItems:`center`,justifyContent:`center`,padding:`20px`},container:{backgroundColor:`white`,borderRadius:`8px`,boxShadow:`0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.05)`,maxWidth:`600px`,width:`100%`,maxHeight:`90vh`,overflow:`hidden`,position:`relative`}};function re({onClose:e,children:t,ariaLabel:n=`Modal dialog`}){(0,c.useEffect)(()=>{let t=t=>{t.key===`Escape`&&e()};return document.addEventListener(`keydown`,t),()=>{document.removeEventListener(`keydown`,t)}},[e]);let r=t=>{t.target===t.currentTarget&&e()};return c.default.createElement(`div`,{style:B.backdrop,onClick:r,role:`dialog`,"aria-modal":`true`,"aria-label":n},c.default.createElement(`div`,{style:B.container},t))}function ie(){let[e,t]=(0,c.useState)(null),{log:n}=q(),r=(0,c.useCallback)(e=>(n(`MFA requested`),new Promise((n,r)=>{t({context:e,resolve:n,reject:r})})),[n]),i=(0,c.useCallback)(()=>{e&&(n(`MFA completed successfully`),e.resolve({success:!0,canceled:!1,data:void 0}),t(null))},[e,n]),a=(0,c.useCallback)(()=>{e&&(n(`MFA canceled`),e.resolve({success:!1,canceled:!0}),t(null))},[e,n]),o=(0,c.useCallback)(r=>{e&&(n(`MFA error: `+r.message),e.resolve({success:!1,canceled:!1,error:r}),t(null))},[e,n]),s=!!e,l=e?.context??null;return{activeMfaRequest:e,isMfaActive:s,mfaContext:l,requestMfa:r,handleMfaDone:i,handleMfaCancel:a,handleMfaError:o}}const V=(0,c.createContext)(null);function H({children:e}){let[t,n]=(0,c.useState)(null),r=K(),{log:i}=q(),{requestMfa:a,handleMfaDone:o,handleMfaCancel:s,isMfaActive:l,mfaContext:u}=ie(),p=(0,c.useCallback)(async e=>{let t=await a(e);return t.success?{success:!0}:t.canceled?{success:!1,canceled:!0}:{success:!1,error:t.error.message}},[a]),m=(0,c.useMemo)(()=>t?{freezeCard:async e=>{try{let n=await t.freezeCard(e);return n.success?{success:!0,canceled:!1,data:n.data}:n.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new d({code:f.internal_error,message:n.error})}}catch(e){return{success:!1,canceled:!1,error:new d({code:f.internal_error,message:e instanceof Error?e.message:`Communication error with iframe`})}}},unfreezeCard:async e=>{try{let n=await t.unfreezeCard(e);return n.success?{success:!0,canceled:!1,data:n.data}:n.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new d({code:f.internal_error,message:n.error})}}catch(e){return{success:!1,canceled:!1,error:new d({code:f.internal_error,message:e instanceof Error?e.message:`Communication error with iframe`})}}}}:null,[t]),h=(0,c.useMemo)(()=>({"system-messages":{requestMfa:p},mfa:{onDone:o,onCancel:s}}),[p,o,s]),{isLoaded:g,url:_,connection:v,iframeRef:y}=M({renderingContext:{entryPoint:`actions`},methods:h});c.default.useEffect(()=>{let e=!0;return v&&v.promise.then(t=>{e&&(n(t),i(`Actions iframe child functions loaded`))}),()=>{e=!1}},[v,i]);let b=!g||!t;return c.default.createElement(V.Provider,{value:{childFunctions:t,actions:m,isLoading:b}},e,_&&c.default.createElement(P,{src:_,style:{display:`none`},checkOrigin:!1,log:r,ref:y,onLoad:()=>{i(`Actions iframe HTML loaded successfully`)},onError:e=>{i(`Actions iframe failed to load: ${e}. This may indicate network issues or security policy blocking.`)}}),l&&u&&c.default.createElement(re,{onClose:s,ariaLabel:`Multi-factor authentication`},c.default.createElement(ne,{mfaId:u.mfaId,destination:u.destination,codeLength:u.codeLength,canResendAfter:u.canResendAfter,...u.operationName&&{operationName:u.operationName},onDone:o,onCancel:s})))}const U=(0,c.createContext)({isLoading:!1,invalidateToken:()=>{},enableLogging:!1,loggerRef:{current:void 0}}),W=({getToken:e,enableLogging:t,logger:n,children:r})=>{let[i,a]=(0,c.useState)(void 0),[o,s]=(0,c.useState)(void 0),[l,u]=(0,c.useState)(void 0),[p,h]=(0,c.useState)(!1),[g,_]=(0,c.useState)(void 0),v=m(n),y=(0,c.useCallback)(async()=>{h(!0);try{let t=await e();a(t),_(void 0);let n=w(t),r=new URL(n.path);r.pathname=``,s(r.toString())}catch(e){_(e)}finally{h(!1)}},[e]),b=(0,c.useCallback)(()=>{u(void 0)},[]);(0,c.useEffect)(()=>{l||y()},[l,y]);let T=(0,c.useCallback)(e=>{u(e),a(void 0),_(void 0)},[]),E=(0,c.useMemo)(()=>{if(l&&!o)throw new d({message:`baseUrl is required for long lived tokens`,code:f.unauthorized});let e=l?{token:l,tokenType:x.longLived,baseUrl:o,paramKey:C.accessToken,paramLocation:S.hash}:void 0;return{tokenData:e,isLoading:p,error:g,invalidateToken:b,enableLogging:t??!1,loggerRef:v}},[l,p,g,b,o,t]);return c.default.createElement(c.default.Fragment,null,c.default.createElement(U.Provider,{value:E},c.default.createElement(H,null,r)),i&&!l&&c.default.createElement(R,{oneTimeToken:i,onExchangeComplete:T,enableLogging:t,onExchangeError:_}))},G=()=>(0,c.useContext)(U);function K(e){let{enableLogging:t}=G();return e===void 0?t:e}function q(e){let t=K(e),{loggerRef:n}=G(),r=z(e=>{v.log(e,{enableLogging:t,logger:n.current??void 0})}),i=z(e=>{v.warn(e,{enableLogging:t,logger:n.current??void 0})}),a=z(e=>{v.error(e,{enableLogging:t,logger:n.current??void 0})});return(0,c.useMemo)(()=>({log:r,warn:i,error:a}),[r,i,a])}function J(e){let{token:t,className:n,enableLogging:r,onError:i,loadingComponent:a,renderingContext:o,methods:s,theme:l,sizeWidth:u}=e,d=K(r),{log:f}=q(r),{isLoaded:p,url:m,tokenData:h,iframeRef:g}=M({oneTimeToken:t,enableLogging:d,onError:i,renderingContext:o,theme:l,methods:s});if(!h||!m)return c.default.createElement(c.default.Fragment,null,a||null);let _=o.entryPoint!==`insightsWidget`;return c.default.createElement(c.default.Fragment,null,!p&&a,c.default.createElement(P,{src:m,allow:`clipboard-write`,checkOrigin:!1,style:{width:`1px`,height:`0px`,minWidth:`100%`},className:n,log:d,ref:g,hidden:!p,onLoad:()=>{f(`Main iframe HTML loaded successfully for entry point: ${o.entryPoint}`)},onError:e=>{f(`Main iframe failed to load: ${e}. This may indicate network issues, firewall blocking, or CSP violations.`)},onResized:e=>{if(!_)return;let t=`${parseInt(e.height)+12}px`;e.iframe.style.height=t},sizeWidth:u}))}const Y={bugButton:{position:`fixed`,left:`12px`,bottom:`12px`,margin:`12px`,padding:`4px`,display:`inline-flex`,alignItems:`center`,borderRadius:`9999px`,border:`1px solid transparent`,backgroundColor:`#2563eb`,color:`white`,opacity:.4,boxShadow:`0 1px 3px 0 rgb(0 0 0 / 0.1)`,cursor:`pointer`,zIndex:50,transition:`opacity 0.3s ease-in-out`},bugButtonHover:{backgroundColor:`#1d4ed8`,opacity:1},bugButtonFocus:{outline:`none`,boxShadow:`0 0 0 2px white, 0 0 0 4px #3b82f6`},bugIcon:{width:`20px`,height:`20px`},loadingButton:{cursor:`default`,opacity:1,animation:`pulse 1s cubic-bezier(0.4, 0, 0.6, 1) infinite`}},X=()=>c.default.createElement(`svg`,{style:Y.bugIcon,xmlns:`http://www.w3.org/2000/svg`,fill:`none`,viewBox:`0 0 24 24`,strokeWidth:`1.5`,stroke:`currentColor`},c.default.createElement(`path`,{strokeLinecap:`round`,strokeLinejoin:`round`,d:`M12 12.75c1.148 0 2.278.08 3.383.237 1.037.146 1.866.966 1.866 2.013 0 3.728-2.35 6.75-5.25 6.75S6.75 18.728 6.75 15c0-1.046.83-1.867 1.866-2.013A24.204 24.204 0 0 1 12 12.75Zm0 0c2.883 0 5.647.508 8.207 1.44a23.91 23.91 0 0 1-1.152 6.06M12 12.75c-2.883 0-5.647.508-8.208 1.44.125 2.104.52 4.136 1.153 6.06M12 12.75a2.25 2.25 0 0 0 2.248-2.354M12 12.75a2.25 2.25 0 0 1-2.248-2.354M12 8.25c.995 0 1.971-.08 2.922-.236.403-.066.74-.358.795-.762a3.778 3.778 0 0 0-.399-2.25M12 8.25c-.995 0-1.97-.08-2.922-.236-.402-.066-.74-.358-.795-.762a3.734 3.734 0 0 1 .4-2.253M12 8.25a2.25 2.25 0 0 0-2.248 2.146M12 8.25a2.25 2.25 0 0 1 2.248 2.146M8.683 5a6.032 6.032 0 0 1-1.155-1.002c.07-.63.27-1.222.574-1.747m.581 2.749A3.75 3.75 0 0 1 15.318 5m0 0c.427-.283.815-.62 1.155-.999a4.471 4.471 0 0 0-.575-1.752M4.921 6a24.048 24.048 0 0 0-.392 3.314c1.668.546 3.416.914 5.223 1.082M19.08 6c.205 1.08.337 2.187.392 3.314a23.882 23.882 0 0 1-5.223 1.082`}));function Z({onClick:e,isLoading:t=!1}){let[n,r]=(0,c.useState)(!1),[i,a]=(0,c.useState)(!1),o={...Y.bugButton,...t&&Y.loadingButton,...!t&&n&&Y.bugButtonHover,...!t&&i&&Y.bugButtonFocus};return t?c.default.createElement(`div`,{style:o},c.default.createElement(`style`,null,`
|
|
2
2
|
@keyframes pulse {
|
|
3
3
|
0%, 100% {
|
|
4
4
|
opacity: 1;
|
|
@@ -7,5 +7,5 @@
|
|
|
7
7
|
opacity: 0.4;
|
|
8
8
|
}
|
|
9
9
|
}
|
|
10
|
-
`),
|
|
10
|
+
`),c.default.createElement(X,null)):c.default.createElement(`button`,{id:`dev-tools-button`,onClick:e,type:`button`,style:o,onMouseEnter:()=>r(!0),onMouseLeave:()=>r(!1),onFocus:()=>a(!0),onBlur:()=>a(!1)},c.default.createElement(X,null))}const ae={panel:{position:`fixed`,bottom:`20px`,left:`20px`,zIndex:50}};function oe(e){let t=`devTools`,n=(0,c.useMemo)(()=>({entryPoint:t}),[t]),[r,i]=(0,c.useState)(!1);return c.default.createElement(`aside`,{"aria-label":`CapitalOS dev tools`},!r&&c.default.createElement(Z,{onClick:()=>i(!r)}),r&&c.default.createElement(`div`,{style:ae.panel},c.default.createElement(J,{...e,renderingContext:n,methods:{devTools:{onClose:()=>i(!1)}},enableLogging:!0,sizeWidth:!0,loadingComponent:c.default.createElement(Z,{isLoading:!0})})))}function Q(e){let t=`cardsApp`,n=(0,c.useMemo)(()=>({entryPoint:t}),[t]);return c.default.createElement(J,{...e,renderingContext:n})}const se=Q;function ce({cardholder:e,onCreate:t,onDone:n,onCancel:r,...i}){let a=`createCard`,o=(0,c.useMemo)(()=>({entryPoint:a,cardholder:e}),[e]);return c.default.createElement(J,{...i,renderingContext:o,methods:{createCard:{...t?{onCreate:t}:{},onDone:n,onCancel:r}}})}function le({transactionId:e,onDone:t,onCancel:n,...r}){let i=`createDispute`,a=(0,c.useMemo)(()=>({entryPoint:i,transactionId:e}),[e]);return c.default.createElement(J,{...r,renderingContext:a,methods:{createDispute:{onDone:t,onCancel:n}}})}function ue(e){let t=`billPayApp`,n=(0,c.useMemo)(()=>({entryPoint:t}),[t]);return c.default.createElement(J,{...e,renderingContext:n})}function de(e){let{onCardCanceled:t,onHideSensitiveDetails:n,...r}=e,i=`cardDetails`,a=(0,c.useMemo)(()=>({entryPoint:i,cardId:e.cardId,cardOnly:e.cardOnly,backOnly:e.backOnly,hideAddress:e.hideAddress}),[i,e.cardId,e.cardOnly,e.backOnly,e.hideAddress]);return c.default.createElement(J,{...r,renderingContext:a,methods:{cardDetails:{onCardCanceled:t??(()=>{}),onHideSensitiveDetails:n??(()=>{})}}})}function fe(e){let t=`accountDetails`,n=(0,c.useMemo)(()=>({entryPoint:t}),[t]);return c.default.createElement(J,{...e,renderingContext:n})}function pe(e){let t=`accountActions`,n=(0,c.useMemo)(()=>({entryPoint:t}),[t]);return c.default.createElement(J,{...e,renderingContext:n})}function me({onClose:e,onChange:t,hideTopLevelBackButton:n,hideTopLevelHeader:r,...i}){let a=`manageBankConnections`,o=(0,c.useMemo)(()=>({entryPoint:a,hideTopLevelBackButton:n,hideTopLevelHeader:r}),[a,n,r]);return c.default.createElement(J,{...i,renderingContext:o,methods:{manageBankConnections:{onClose:e,...t&&{onChange:t}}}})}function he({onClose:e,...t}){let n=`configureAutoPay`,r=(0,c.useMemo)(()=>({entryPoint:n}),[n]);return c.default.createElement(J,{...t,renderingContext:r,methods:{configureAutoPay:{onClose:e}}})}function ge({onClose:e,...t}){let n=`policySettings`,r=(0,c.useMemo)(()=>({entryPoint:n}),[n]);return c.default.createElement(J,{...t,renderingContext:r,methods:{policySettings:{onClose:e}}})}function _e({cardId:e,onClose:t,inlineCardOnFile:n,...r}){let i=`connectToVendors`,a=(0,c.useMemo)(()=>({entryPoint:i,cardId:e,inlineCardOnFile:n}),[i,e,n]);return c.default.createElement(J,{...r,renderingContext:a,methods:{connectToVendors:{onClose:t}}})}function ve({onClose:e,onDone:t,...n}){let r=`connectBankAccounts`,i=(0,c.useMemo)(()=>({entryPoint:r}),[r]);return c.default.createElement(J,{...n,renderingContext:i,methods:{connectBankAccounts:{onClose:e,onDone:t}}})}function ye(e){let t=`insightsDashboard`,n=(0,c.useMemo)(()=>({entryPoint:t}),[t]);return c.default.createElement(J,{...e,renderingContext:n})}function be(e){let t=`insightsWidget`,{widget:n,hideTitle:r,height:i,width:a}=e,o=(0,c.useMemo)(()=>({entryPoint:t,widget:n,hideTitle:r,height:i,width:a}),[t,n,r,i,a]);return c.default.createElement(J,{...e,renderingContext:o})}function $({onDone:e,entryPoint:t,exitPoint:n,allowExitOnNonApproved:r,doneButtonText:i,product:a,...o}){let s=`onboarding`,l=(0,c.useMemo)(()=>i?{"onboarding.doneButton":i,"onboarding.continueButton":i,"activation.successButton":i}:void 0,[i]),u=(0,c.useMemo)(()=>({entryPoint:s,onboardingEntryPoint:t,onboardingExitPoint:n,allowExitOnNonApproved:r,product:a,copy:l}),[s,t,n,r,a,l]);return c.default.createElement(J,{...o,renderingContext:u,methods:{onboarding:{onDone:e}}})}function xe({onDone:e,...t}){let n=`makePayment`,r=(0,c.useMemo)(()=>({entryPoint:n}),[n]);return c.default.createElement(J,{...t,renderingContext:r,methods:{makePayment:{onDone:e}}})}function Se({onDone:e,onCancel:t,...n}){let r=`contactSupport`,i=(0,c.useMemo)(()=>({entryPoint:r}),[r]);return c.default.createElement(J,{...n,renderingContext:i,methods:{contactSupport:{onDone:e,onCancel:t}}})}function Ce({onDone:e,...t}){let n=`statements`,r=(0,c.useMemo)(()=>({entryPoint:n}),[n]);return c.default.createElement(J,{...t,renderingContext:r,methods:{statements:{onDone:e}}})}function we({onDone:e,...t}){let n=`legalDocuments`,r=(0,c.useMemo)(()=>({entryPoint:n}),[n]);return c.default.createElement(J,{...t,renderingContext:r,methods:{legalDocuments:{onDone:e}}})}function Te({cardId:e,onDone:t,onClose:n,...r}){let i=`replaceCard`,a=(0,c.useMemo)(()=>({entryPoint:i,cardId:e}),[e]);return c.default.createElement(J,{...r,renderingContext:a,methods:{replaceCard:{onDone:t,onClose:n}}})}function Ee({cardId:e,onDone:t,onClose:n,...r}){let i=`terminateCard`,a=(0,c.useMemo)(()=>({entryPoint:i,cardId:e}),[e]);return c.default.createElement(J,{...r,renderingContext:a,methods:{terminateCard:{onDone:t,onClose:n}}})}function De(e){let t=`transactions`,n=(0,c.useMemo)(()=>({entryPoint:t}),[t]);return c.default.createElement(J,{...e,renderingContext:n})}function Oe(){let e=(0,c.useContext)(V);if(!e)throw new d({message:`useActions must be used within a CapitalOsAuthenticationProvider`,code:f.internal_error});let{childFunctions:t,isLoading:n}=e;return{actions:t,isLoading:n}}exports.AccountActions=pe,exports.AccountDetails=fe,exports.App=se,exports.BillPayApp=ue,exports.CapitalOsAuthenticationProvider=W,exports.CardDetails=de,exports.CardsApp=Q,exports.ConfigureAutoPay=he,exports.ConnectBankAccounts=ve,exports.ConnectToVendors=_e,exports.ContactSupport=Se,exports.DevTools=oe,exports.DisputeTransaction=le,exports.InsightsDashboard=ye,exports.InsightsWidget=be,exports.IssueCard=ce,exports.LegalDocuments=we,exports.MakePayment=xe,exports.ManageBankConnections=me,exports.Onboarding=$,exports.PolicySettings=ge,exports.ReplaceCard=Te,exports.Statements=Ce,exports.TerminateCard=Ee,exports.Transactions=De,exports.useActions=Oe;
|
|
11
11
|
//# sourceMappingURL=index.js.map
|