@capitalos/react 1.4.5-rc.1 → 1.4.5-rc.3
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/_tsup-dts-rollup.d.mts +91 -12
- package/dist/_tsup-dts-rollup.d.ts +91 -12
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/index.d.mts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ import { IFrameMessageData } from 'iframe-resizer';
|
|
|
4
4
|
import { IFrameOptions } from 'iframe-resizer';
|
|
5
5
|
import { IFrameResizedData } from 'iframe-resizer';
|
|
6
6
|
import { IFrameScrollData } from 'iframe-resizer';
|
|
7
|
+
import { MutableRefObject } from 'react';
|
|
7
8
|
import { default as React_2 } from 'react';
|
|
8
9
|
import { ReactNode } from 'react';
|
|
9
10
|
import { RefObject } from 'react';
|
|
@@ -107,8 +108,9 @@ declare type CapitalOsAuthenticationContextType = {
|
|
|
107
108
|
enableLogging: boolean;
|
|
108
109
|
/**
|
|
109
110
|
* Optional logger for capturing all SDK logs including Penpal.
|
|
111
|
+
* Stored in a ref to avoid unnecessary re-renders when logger changes.
|
|
110
112
|
*/
|
|
111
|
-
|
|
113
|
+
loggerRef: React_2.RefObject<Logger | undefined>;
|
|
112
114
|
};
|
|
113
115
|
|
|
114
116
|
declare const CapitalOsAuthenticationProvider: React_2.FC<ProviderProps>;
|
|
@@ -670,6 +672,13 @@ export declare type ContactSupportProps = CommonProps & {
|
|
|
670
672
|
|
|
671
673
|
export declare function decodeOneTimeToken(token: string): any;
|
|
672
674
|
|
|
675
|
+
/**
|
|
676
|
+
* Renders the CapitalOS Demo Bill Payment Dashboard experience.
|
|
677
|
+
*/
|
|
678
|
+
export declare function DemoBillPayApp(props: DemoBillPayAppProps): JSX.Element;
|
|
679
|
+
|
|
680
|
+
export declare type DemoBillPayAppProps = CommonProps;
|
|
681
|
+
|
|
673
682
|
/**
|
|
674
683
|
* Renders the CapitalOS Dev Tools experience.
|
|
675
684
|
* Allows for simulating transactions, etc.
|
|
@@ -785,7 +794,7 @@ export declare class InvalidTokenError extends CapitalOSError {
|
|
|
785
794
|
/**
|
|
786
795
|
* Renders the CapitalOS Issue Card experience.
|
|
787
796
|
*/
|
|
788
|
-
export declare function IssueCard({ cardholder, onDone, onCancel, ...restOfProps }: IssueCardProps): JSX.Element;
|
|
797
|
+
export declare function IssueCard({ cardholder, onCreate, onDone, onCancel, ...restOfProps }: IssueCardProps): JSX.Element;
|
|
789
798
|
|
|
790
799
|
export declare type IssueCardDefaultValues = z.infer<typeof issueCardDefaultValuesSchema>;
|
|
791
800
|
|
|
@@ -817,20 +826,57 @@ export declare type IssueCardProps = CommonProps & {
|
|
|
817
826
|
*/
|
|
818
827
|
cardholder?: IssueCardDefaultValues;
|
|
819
828
|
/**
|
|
820
|
-
* Callback
|
|
829
|
+
* Callback invoked immediately when the card is successfully created on the server,
|
|
830
|
+
* before the success screen is displayed to the user.
|
|
831
|
+
*
|
|
832
|
+
* Use this callback when you need to know as soon as the card exists (e.g., to update
|
|
833
|
+
* your own records, trigger workflows, or log the creation event).
|
|
834
|
+
*
|
|
835
|
+
* This differs from `onDone`, which fires later when the user clicks the "Done" button
|
|
836
|
+
* after viewing the success screen. This is particularly useful when users might exit
|
|
837
|
+
* the modal without clicking "Done" (e.g., by clicking outside the modal or refreshing
|
|
838
|
+
* the page), ensuring you don't lose track of the created card.
|
|
821
839
|
*
|
|
822
840
|
* @param result - Object containing the created card's ID
|
|
823
|
-
* @param result.cardId - The ID of the newly created card
|
|
824
841
|
*/
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
842
|
+
onCreate?: (result: IssueCardResult) => void;
|
|
843
|
+
/**
|
|
844
|
+
* Callback invoked when the user clicks the "Done" button after viewing the success screen.
|
|
845
|
+
*
|
|
846
|
+
* This fires after the card has been created and the user has completed the entire workflow
|
|
847
|
+
* by clicking the "Done" button. If you need to know immediately when the card is created
|
|
848
|
+
* (before the user sees the success screen), use `onCreate` instead.
|
|
849
|
+
*
|
|
850
|
+
* @param result - Object containing the created card's ID
|
|
851
|
+
* @see onCreate - For immediate notification when the card is created
|
|
852
|
+
*/
|
|
853
|
+
onDone: (result: IssueCardResult) => void;
|
|
828
854
|
/**
|
|
829
855
|
* Callback to invoke when the card creation was cancelled by the user.
|
|
830
856
|
*/
|
|
831
857
|
onCancel: () => void;
|
|
832
858
|
};
|
|
833
859
|
|
|
860
|
+
/**
|
|
861
|
+
* Result object returned when a card is successfully created.
|
|
862
|
+
*/
|
|
863
|
+
export declare type IssueCardResult = {
|
|
864
|
+
/**
|
|
865
|
+
* The ID of the newly created card
|
|
866
|
+
*/
|
|
867
|
+
cardId: string;
|
|
868
|
+
};
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* Result object returned when a card is successfully created.
|
|
872
|
+
*/
|
|
873
|
+
export declare type IssueCardResult_alias_1 = {
|
|
874
|
+
/**
|
|
875
|
+
* The ID of the newly created card
|
|
876
|
+
*/
|
|
877
|
+
cardId: string;
|
|
878
|
+
};
|
|
879
|
+
|
|
834
880
|
export declare function LegalDocuments({ onDone, ...restOfProps }: LegalDocumentsProps): JSX.Element;
|
|
835
881
|
|
|
836
882
|
export declare type LegalDocumentsProps = CommonProps & {
|
|
@@ -993,9 +1039,8 @@ export declare type ParentFunctions = {
|
|
|
993
1039
|
onCancel?: () => void;
|
|
994
1040
|
};
|
|
995
1041
|
createCard?: {
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
}) => void;
|
|
1042
|
+
onCreate?: (result: IssueCardResult_alias_1) => void;
|
|
1043
|
+
onDone?: (result: IssueCardResult_alias_1) => void;
|
|
999
1044
|
onCancel?: () => void;
|
|
1000
1045
|
};
|
|
1001
1046
|
createDispute?: {
|
|
@@ -1081,10 +1126,16 @@ export declare type RawErrorDetails = {
|
|
|
1081
1126
|
};
|
|
1082
1127
|
|
|
1083
1128
|
/**
|
|
1084
|
-
* Redacts
|
|
1129
|
+
* Redacts a string value, keeping first 4 and last 4 characters for debugging
|
|
1130
|
+
* Safe to use - handles undefined/null and short strings gracefully
|
|
1131
|
+
*/
|
|
1132
|
+
export declare function redactString(value: string | undefined | null): string;
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* Redacts token values from a url string, keeping first 4 and last 4 characters for debugging
|
|
1085
1136
|
* Safe to use - will not throw even with malformed input
|
|
1086
1137
|
*/
|
|
1087
|
-
export declare function
|
|
1138
|
+
export declare function redactTokenFromUrl(str: string): string;
|
|
1088
1139
|
|
|
1089
1140
|
declare type RenderingContext_2 = z.infer<typeof renderingContextSchema>;
|
|
1090
1141
|
|
|
@@ -1142,6 +1193,12 @@ declare const renderingContextSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<
|
|
|
1142
1193
|
entryPoint: "billPayApp";
|
|
1143
1194
|
}, {
|
|
1144
1195
|
entryPoint: "billPayApp";
|
|
1196
|
+
}>, z.ZodObject<{
|
|
1197
|
+
entryPoint: z.ZodLiteral<"demoBillPayApp">;
|
|
1198
|
+
}, "strip", z.ZodTypeAny, {
|
|
1199
|
+
entryPoint: "demoBillPayApp";
|
|
1200
|
+
}, {
|
|
1201
|
+
entryPoint: "demoBillPayApp";
|
|
1145
1202
|
}>, z.ZodObject<{
|
|
1146
1203
|
entryPoint: z.ZodLiteral<"cardDetails">;
|
|
1147
1204
|
cardId: z.ZodString;
|
|
@@ -1459,6 +1516,18 @@ export declare const useCapitalOsAuthContext: () => CapitalOsAuthenticationConte
|
|
|
1459
1516
|
*/
|
|
1460
1517
|
export declare function useEnableLogging(enableLoggingProp?: boolean): boolean;
|
|
1461
1518
|
|
|
1519
|
+
/**
|
|
1520
|
+
* Creates a stable callback that always calls the latest version of the provided function.
|
|
1521
|
+
* This is useful for event handlers and callbacks that need to be in dependency arrays
|
|
1522
|
+
* but shouldn't trigger effect re-fires when they change.
|
|
1523
|
+
*
|
|
1524
|
+
* Based on the useEvent RFC (that made it into React 19.2): https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md
|
|
1525
|
+
*
|
|
1526
|
+
* @param fn The function to wrap
|
|
1527
|
+
* @returns A stable callback that always calls the latest version of fn
|
|
1528
|
+
*/
|
|
1529
|
+
export declare function useEvent<T extends (...args: any[]) => any>(fn: T): T;
|
|
1530
|
+
|
|
1462
1531
|
/**
|
|
1463
1532
|
* A React hook that manages the iframe connection lifecycle, including:
|
|
1464
1533
|
* - Establishing and maintaining the iframe connection
|
|
@@ -1504,8 +1573,18 @@ export declare function useIframeUrl({ tokenData, renderingContext, theme, onErr
|
|
|
1504
1573
|
onError?: ((error: Error) => void) | undefined;
|
|
1505
1574
|
}): string | undefined;
|
|
1506
1575
|
|
|
1576
|
+
/**
|
|
1577
|
+
* Returns a ref that always contains the latest value.
|
|
1578
|
+
* Useful for accessing the current value of props/state in callbacks without causing re-renders.
|
|
1579
|
+
*
|
|
1580
|
+
* @param value The value to track
|
|
1581
|
+
* @returns A ref containing the latest value
|
|
1582
|
+
*/
|
|
1583
|
+
export declare function useLatest<T>(value: T): MutableRefObject<T>;
|
|
1584
|
+
|
|
1507
1585
|
/**
|
|
1508
1586
|
* Hook that provides stable logging functions (log, warn, error), scoped to the resolved enableLogging flag.
|
|
1587
|
+
* Uses useEvent to ensure the returned functions have stable identities while always using the latest values.
|
|
1509
1588
|
* @param enableLoggingProp Optional direct prop to override logging.
|
|
1510
1589
|
*/
|
|
1511
1590
|
export declare function useLogger(enableLoggingProp?: boolean): {
|
|
@@ -4,6 +4,7 @@ import { IFrameMessageData } from 'iframe-resizer';
|
|
|
4
4
|
import { IFrameOptions } from 'iframe-resizer';
|
|
5
5
|
import { IFrameResizedData } from 'iframe-resizer';
|
|
6
6
|
import { IFrameScrollData } from 'iframe-resizer';
|
|
7
|
+
import { MutableRefObject } from 'react';
|
|
7
8
|
import { default as React_2 } from 'react';
|
|
8
9
|
import { ReactNode } from 'react';
|
|
9
10
|
import { RefObject } from 'react';
|
|
@@ -107,8 +108,9 @@ declare type CapitalOsAuthenticationContextType = {
|
|
|
107
108
|
enableLogging: boolean;
|
|
108
109
|
/**
|
|
109
110
|
* Optional logger for capturing all SDK logs including Penpal.
|
|
111
|
+
* Stored in a ref to avoid unnecessary re-renders when logger changes.
|
|
110
112
|
*/
|
|
111
|
-
|
|
113
|
+
loggerRef: React_2.RefObject<Logger | undefined>;
|
|
112
114
|
};
|
|
113
115
|
|
|
114
116
|
declare const CapitalOsAuthenticationProvider: React_2.FC<ProviderProps>;
|
|
@@ -670,6 +672,13 @@ export declare type ContactSupportProps = CommonProps & {
|
|
|
670
672
|
|
|
671
673
|
export declare function decodeOneTimeToken(token: string): any;
|
|
672
674
|
|
|
675
|
+
/**
|
|
676
|
+
* Renders the CapitalOS Demo Bill Payment Dashboard experience.
|
|
677
|
+
*/
|
|
678
|
+
export declare function DemoBillPayApp(props: DemoBillPayAppProps): JSX.Element;
|
|
679
|
+
|
|
680
|
+
export declare type DemoBillPayAppProps = CommonProps;
|
|
681
|
+
|
|
673
682
|
/**
|
|
674
683
|
* Renders the CapitalOS Dev Tools experience.
|
|
675
684
|
* Allows for simulating transactions, etc.
|
|
@@ -785,7 +794,7 @@ export declare class InvalidTokenError extends CapitalOSError {
|
|
|
785
794
|
/**
|
|
786
795
|
* Renders the CapitalOS Issue Card experience.
|
|
787
796
|
*/
|
|
788
|
-
export declare function IssueCard({ cardholder, onDone, onCancel, ...restOfProps }: IssueCardProps): JSX.Element;
|
|
797
|
+
export declare function IssueCard({ cardholder, onCreate, onDone, onCancel, ...restOfProps }: IssueCardProps): JSX.Element;
|
|
789
798
|
|
|
790
799
|
export declare type IssueCardDefaultValues = z.infer<typeof issueCardDefaultValuesSchema>;
|
|
791
800
|
|
|
@@ -817,20 +826,57 @@ export declare type IssueCardProps = CommonProps & {
|
|
|
817
826
|
*/
|
|
818
827
|
cardholder?: IssueCardDefaultValues;
|
|
819
828
|
/**
|
|
820
|
-
* Callback
|
|
829
|
+
* Callback invoked immediately when the card is successfully created on the server,
|
|
830
|
+
* before the success screen is displayed to the user.
|
|
831
|
+
*
|
|
832
|
+
* Use this callback when you need to know as soon as the card exists (e.g., to update
|
|
833
|
+
* your own records, trigger workflows, or log the creation event).
|
|
834
|
+
*
|
|
835
|
+
* This differs from `onDone`, which fires later when the user clicks the "Done" button
|
|
836
|
+
* after viewing the success screen. This is particularly useful when users might exit
|
|
837
|
+
* the modal without clicking "Done" (e.g., by clicking outside the modal or refreshing
|
|
838
|
+
* the page), ensuring you don't lose track of the created card.
|
|
821
839
|
*
|
|
822
840
|
* @param result - Object containing the created card's ID
|
|
823
|
-
* @param result.cardId - The ID of the newly created card
|
|
824
841
|
*/
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
842
|
+
onCreate?: (result: IssueCardResult) => void;
|
|
843
|
+
/**
|
|
844
|
+
* Callback invoked when the user clicks the "Done" button after viewing the success screen.
|
|
845
|
+
*
|
|
846
|
+
* This fires after the card has been created and the user has completed the entire workflow
|
|
847
|
+
* by clicking the "Done" button. If you need to know immediately when the card is created
|
|
848
|
+
* (before the user sees the success screen), use `onCreate` instead.
|
|
849
|
+
*
|
|
850
|
+
* @param result - Object containing the created card's ID
|
|
851
|
+
* @see onCreate - For immediate notification when the card is created
|
|
852
|
+
*/
|
|
853
|
+
onDone: (result: IssueCardResult) => void;
|
|
828
854
|
/**
|
|
829
855
|
* Callback to invoke when the card creation was cancelled by the user.
|
|
830
856
|
*/
|
|
831
857
|
onCancel: () => void;
|
|
832
858
|
};
|
|
833
859
|
|
|
860
|
+
/**
|
|
861
|
+
* Result object returned when a card is successfully created.
|
|
862
|
+
*/
|
|
863
|
+
export declare type IssueCardResult = {
|
|
864
|
+
/**
|
|
865
|
+
* The ID of the newly created card
|
|
866
|
+
*/
|
|
867
|
+
cardId: string;
|
|
868
|
+
};
|
|
869
|
+
|
|
870
|
+
/**
|
|
871
|
+
* Result object returned when a card is successfully created.
|
|
872
|
+
*/
|
|
873
|
+
export declare type IssueCardResult_alias_1 = {
|
|
874
|
+
/**
|
|
875
|
+
* The ID of the newly created card
|
|
876
|
+
*/
|
|
877
|
+
cardId: string;
|
|
878
|
+
};
|
|
879
|
+
|
|
834
880
|
export declare function LegalDocuments({ onDone, ...restOfProps }: LegalDocumentsProps): JSX.Element;
|
|
835
881
|
|
|
836
882
|
export declare type LegalDocumentsProps = CommonProps & {
|
|
@@ -993,9 +1039,8 @@ export declare type ParentFunctions = {
|
|
|
993
1039
|
onCancel?: () => void;
|
|
994
1040
|
};
|
|
995
1041
|
createCard?: {
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
}) => void;
|
|
1042
|
+
onCreate?: (result: IssueCardResult_alias_1) => void;
|
|
1043
|
+
onDone?: (result: IssueCardResult_alias_1) => void;
|
|
999
1044
|
onCancel?: () => void;
|
|
1000
1045
|
};
|
|
1001
1046
|
createDispute?: {
|
|
@@ -1081,10 +1126,16 @@ export declare type RawErrorDetails = {
|
|
|
1081
1126
|
};
|
|
1082
1127
|
|
|
1083
1128
|
/**
|
|
1084
|
-
* Redacts
|
|
1129
|
+
* Redacts a string value, keeping first 4 and last 4 characters for debugging
|
|
1130
|
+
* Safe to use - handles undefined/null and short strings gracefully
|
|
1131
|
+
*/
|
|
1132
|
+
export declare function redactString(value: string | undefined | null): string;
|
|
1133
|
+
|
|
1134
|
+
/**
|
|
1135
|
+
* Redacts token values from a url string, keeping first 4 and last 4 characters for debugging
|
|
1085
1136
|
* Safe to use - will not throw even with malformed input
|
|
1086
1137
|
*/
|
|
1087
|
-
export declare function
|
|
1138
|
+
export declare function redactTokenFromUrl(str: string): string;
|
|
1088
1139
|
|
|
1089
1140
|
declare type RenderingContext_2 = z.infer<typeof renderingContextSchema>;
|
|
1090
1141
|
|
|
@@ -1142,6 +1193,12 @@ declare const renderingContextSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<
|
|
|
1142
1193
|
entryPoint: "billPayApp";
|
|
1143
1194
|
}, {
|
|
1144
1195
|
entryPoint: "billPayApp";
|
|
1196
|
+
}>, z.ZodObject<{
|
|
1197
|
+
entryPoint: z.ZodLiteral<"demoBillPayApp">;
|
|
1198
|
+
}, "strip", z.ZodTypeAny, {
|
|
1199
|
+
entryPoint: "demoBillPayApp";
|
|
1200
|
+
}, {
|
|
1201
|
+
entryPoint: "demoBillPayApp";
|
|
1145
1202
|
}>, z.ZodObject<{
|
|
1146
1203
|
entryPoint: z.ZodLiteral<"cardDetails">;
|
|
1147
1204
|
cardId: z.ZodString;
|
|
@@ -1459,6 +1516,18 @@ export declare const useCapitalOsAuthContext: () => CapitalOsAuthenticationConte
|
|
|
1459
1516
|
*/
|
|
1460
1517
|
export declare function useEnableLogging(enableLoggingProp?: boolean): boolean;
|
|
1461
1518
|
|
|
1519
|
+
/**
|
|
1520
|
+
* Creates a stable callback that always calls the latest version of the provided function.
|
|
1521
|
+
* This is useful for event handlers and callbacks that need to be in dependency arrays
|
|
1522
|
+
* but shouldn't trigger effect re-fires when they change.
|
|
1523
|
+
*
|
|
1524
|
+
* Based on the useEvent RFC (that made it into React 19.2): https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md
|
|
1525
|
+
*
|
|
1526
|
+
* @param fn The function to wrap
|
|
1527
|
+
* @returns A stable callback that always calls the latest version of fn
|
|
1528
|
+
*/
|
|
1529
|
+
export declare function useEvent<T extends (...args: any[]) => any>(fn: T): T;
|
|
1530
|
+
|
|
1462
1531
|
/**
|
|
1463
1532
|
* A React hook that manages the iframe connection lifecycle, including:
|
|
1464
1533
|
* - Establishing and maintaining the iframe connection
|
|
@@ -1504,8 +1573,18 @@ export declare function useIframeUrl({ tokenData, renderingContext, theme, onErr
|
|
|
1504
1573
|
onError?: ((error: Error) => void) | undefined;
|
|
1505
1574
|
}): string | undefined;
|
|
1506
1575
|
|
|
1576
|
+
/**
|
|
1577
|
+
* Returns a ref that always contains the latest value.
|
|
1578
|
+
* Useful for accessing the current value of props/state in callbacks without causing re-renders.
|
|
1579
|
+
*
|
|
1580
|
+
* @param value The value to track
|
|
1581
|
+
* @returns A ref containing the latest value
|
|
1582
|
+
*/
|
|
1583
|
+
export declare function useLatest<T>(value: T): MutableRefObject<T>;
|
|
1584
|
+
|
|
1507
1585
|
/**
|
|
1508
1586
|
* Hook that provides stable logging functions (log, warn, error), scoped to the resolved enableLogging flag.
|
|
1587
|
+
* Uses useEvent to ensure the returned functions have stable identities while always using the latest values.
|
|
1509
1588
|
* @param enableLoggingProp Optional direct prop to override logging.
|
|
1510
1589
|
*/
|
|
1511
1590
|
export declare function useLogger(enableLoggingProp?: boolean): {
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";var be=Object.defineProperty,Te=Object.defineProperties;var Le=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var ie=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var re=(e,n,o)=>n in e?be(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o,c=(e,n)=>{for(var o in n||(n={}))ie.call(n,o)&&re(e,o,n[o]);if(W)for(var o of W(n))se.call(n,o)&&re(e,o,n[o]);return e},p=(e,n)=>Te(e,Le(n));var P=(e,n)=>{var o={};for(var t in e)ie.call(e,t)&&n.indexOf(t)<0&&(o[t]=e[t]);if(e!=null&&W)for(var t of W(e))n.indexOf(t)<0&&se.call(e,t)&&(o[t]=e[t]);return o};var D=(e,n,o)=>new Promise((t,r)=>{var i=m=>{try{a(o.next(m))}catch(d){r(d)}},s=m=>{try{a(o.throw(m))}catch(d){r(d)}},a=m=>m.done?t(m.value):Promise.resolve(m.value).then(i,s);a((o=o.apply(e,n)).next())});import h,{useMemo as y,useContext as fn}from"react";import U from"react";import H,{createContext as sn,useContext as an,useState as B,useMemo as ye,useCallback as R,useEffect as cn}from"react";import Je,{useMemo as Xe,useRef as Ze,useEffect as Ge}from"react";var v=class extends Error{constructor({message:n,code:o}){super(n),this.name="CapitalOSError",this.code=o}},L={unauthorized:"unauthorized",invalid_account_status:"invalid_account_status",unsupported_entry_point:"unsupported_entry_point",internal_error:"internal_error"},S=class extends v{constructor(n){super({message:`Invalid token ${n!=null?n:""}`,code:L.unauthorized}),this.name="CapitalOSInvalidTokenError"}};import{connect as Re,WindowMessenger as Fe}from"penpal";import{useCallback as ze,useEffect as z,useMemo as Y,useRef as V,useState as le}from"react";var ae="1.4.5-rc.1";function Ae(e){let n=JSON.stringify(e),o=btoa(n);return encodeURIComponent(o)}function G(e){try{let n=decodeURIComponent(e),o=atob(n);return JSON.parse(o)}catch(n){throw new S}}function Oe(e){try{return decodeURIComponent(e)}catch(n){return e}}function ce({tokenData:e,renderingContext:n,theme:o,onError:t}){try{let r=n?p(c({},n),{referer:window.location.href}):null,i=r?Ae(r):null,s=new URL(e.baseUrl),a=Oe(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",ae),i&&s.searchParams.set("renderingContext",i),o&&s.searchParams.set("theme",o),s.toString()}catch(r){t==null||t(new S);return}}function j(e){let o=G(e).path;if(!o||typeof o!="string")throw new S;return{token:e,tokenType:"oneTime",baseUrl:o,paramKey:"token",paramLocation:"search"}}var De={enableLogging:!1},Se="[CapitalOS] ";function Q(e){return(n,o=De)=>{try{let t=`${Se}${n}`;o.logger?o.logger[e](t):o.enableLogging&&console[e](t)}catch(t){}}}var q={log:Q("log"),warn:Q("warn"),error:Q("error")};function K(e){try{return e.replace(/([?&#])(token|access_token)=([^&\s#]+)/gi,(n,o,t,r)=>{if(!r||r.length<=12)return`${o}${t}=***`;let i=r.substring(0,4),s=r.substring(r.length-4);return`${o}${t}=${i}...${s}`})}catch(n){return"[URL redacted due to processing error]"}}var de=1e4;function $e(e){return(...n)=>{try{let o=n.map(t=>{if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch(r){return String(t)}}).join(" ");e(o)}catch(o){}}}function ee({iframeRef:e,token:n,onError:o,methods:t,iframeLabel:r}){let[i,s]=le(null),{log:a}=I(),m=Y(()=>$e(a),[a]);return z(()=>{let d=r?`[${r}] `:"";if(!e.current){a(`${d}Iframe ref not available - iframe element may not be mounted`);return}if(!e.current.contentWindow){a(`${d}Iframe contentWindow not accessible - may be blocked by browser security policy or CSP`);return}a(`${d}Establishing Penpal connection to iframe`);let l=!0,f=new Fe({remoteWindow:e.current.contentWindow,allowedOrigins:["*"]}),b=Re({messenger:f,methods:t,timeout:de,log:m});return b.promise.then(()=>{l&&(a(`${d}Penpal connection established successfully`),s(b))}).catch(k=>{l&&(a(`${d}Penpal connection failed: ${k.message}. Timeout: ${de}ms`),o==null||o(k),s(null))}),()=>{l=!1,a(`${d}Destroying Penpal connection (cleanup triggered - likely due to token or iframeRef change, or component unmount)`),b.destroy(),s(null)}},[n,e]),i}function ne({tokenData:e,renderingContext:n,theme:o,onError:t}){let r=V(t),i=V(n);return Y(()=>{if(e)return ce({tokenData:e,renderingContext:i.current,theme:o,onError:r.current})},[e,o,r,i])}function J(e){let{oneTimeToken:n,enableLogging:o,onError:t,renderingContext:r,theme:i,methods:s}=e,{tokenData:a,error:m,invalidateToken:d}=X(),{log:l,warn:f}=I(o),[b,k]=le(!1),E=V(null);He(m,t);let g=Y(()=>n?j(n):a,[n,a]);z(()=>{if(g){let u=g.token?`${g.token.substring(0,4)}...${g.token.substring(g.token.length-4)}`:"undefined";l(`[${r.entryPoint}] Token data available, type: ${g.tokenType}, token: ${u}, location: ${g.paramLocation}, key: ${g.paramKey}, baseUrl: ${g.baseUrl}`)}},[g]);let M=ze(()=>{if(l("Token expired, invalidating..."),n){t==null||t(new v({message:"Token expired. Cannot automatically refresh when using token prop.",code:L.unauthorized}));return}d(),k(!1)},[n,d,t]);z(()=>{n&&a&&f("token was provided both from provider and from the token prop. the prop will take precedence")},[n,a]);let T=ne({tokenData:g,renderingContext:r,theme:i,onError:t});z(()=>{T?l(`Iframe URL generated: ${K(T).substring(0,1024)}...`):g&&f("Failed to generate iframe URL despite having token data")},[T,g]);let x=ee({iframeRef:E,token:g==null?void 0:g.token,iframeLabel:r.entryPoint,onError:u=>{l(`Connection error: ${u.message}`),t==null||t(u),k(!0)},methods:c({onLoad:()=>{l("Iframe called onLoad()"),k(!0)},onError:u=>{let F=new v(u);l(`Iframe error: ${F.message}`),t==null||t(F)},onTokenExpired:M},s)});return{isLoaded:b,url:T,tokenData:g,iframeRef:E,connection:x}}function He(e,n){let o=V(!1);z(()=>{e&&!o.current&&(n==null||n(e),o.current=!0)},[e,n])}import{iframeResizer as Be}from"iframe-resizer";import Ue,{forwardRef as Ne,useEffect as _e,useImperativeHandle as We,useRef as je}from"react";var w=Ne((e,n)=>{let o=e.title||"iframe",{iframeHTMLAttributes:t,resizerOptions:r}=Ve(e),i=je(null);return _e(()=>{let s=i.current;return Be(c({},r),s),()=>s.iFrameResizer&&s.iFrameResizer.removeListeners()}),We(n,()=>i.current),Ue.createElement("iframe",p(c({},t),{title:o,ref:i}))});w.displayName="IframeResizer";var qe=["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"],Ke=new Set(qe);function Ve(e){return Object.keys(e).reduce((o,t)=>{let r=e[t];return Ke.has(t)?r!==void 0&&(o.resizerOptions[t]=e[t]):o.iframeHTMLAttributes[t]=e[t],o},{resizerOptions:{},iframeHTMLAttributes:{}})}function pe(e){let{oneTimeToken:n,enableLogging:o,onExchangeComplete:t,onExchangeError:r}=e,i=A(o),{log:s}=I(o),a=Ze(null),m=Xe(()=>j(n),[n]),l=ne({tokenData:m,onError:r,renderingContext:{entryPoint:"tokenExchange"}});return Ge(()=>{l&&s(`Token exchange iframe URL: ${K(l).substring(0,1024)}...`)},[l]),ee({iframeRef:a,token:n,iframeLabel:"token-exchange",onError:f=>{s(`Token exchange connection error: ${f.message}`),r==null||r(f)},methods:{onLoad:()=>{s("Token exchange iframe loaded")},onError:f=>{s(`Token exchange iframe error: ${f.message}`),r==null||r(new v(f))},tokenExchange:{onLongLivedToken:f=>{s("Token exchange complete: received long-lived token"),t(f)}}}}),Je.createElement(w,{src:l,checkOrigin:!1,style:{display:"none"},log:i,ref:a,onLoad:()=>{s("Token exchange iframe HTML loaded successfully")},onError:f=>{s(`Token exchange iframe failed to load: ${f}`)}})}import $,{createContext as on,useState as tn,useMemo as xe,useCallback as rn}from"react";import Qe from"react";import{useMemo as Ye}from"react";function ue(m){var d=m,{onDone:e,onCancel:n,mfaId:o,destination:t,codeLength:r,canResendAfter:i,operationName:s}=d,a=P(d,["onDone","onCancel","mfaId","destination","codeLength","canResendAfter","operationName"]);let l="mfa",f=Ye(()=>({entryPoint:l,mfaId:o,destination:t,codeLength:r,canResendAfter:i,operationName:s}),[l,o,t,r,i,s]);return Qe.createElement(C,p(c({},a),{renderingContext:f,methods:{mfa:{onDone:e,onCancel:n}}}))}import me,{useEffect as en}from"react";var fe={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 ge({onClose:e,children:n,ariaLabel:o="Modal dialog"}){en(()=>{let r=i=>{i.key==="Escape"&&e()};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[e]);let t=r=>{r.target===r.currentTarget&&e()};return me.createElement("div",{style:fe.backdrop,onClick:t,role:"dialog","aria-modal":"true","aria-label":o},me.createElement("div",{style:fe.container},n))}import{useState as nn,useCallback as Z}from"react";function Ce(){var d;let[e,n]=nn(null),{log:o}=I(),t=Z(l=>(o("MFA requested"),new Promise((f,b)=>{n({context:l,resolve:f,reject:b})})),[o]),r=Z(()=>{e&&(o("MFA completed successfully"),e.resolve({success:!0,canceled:!1,data:void 0}),n(null))},[e,o]),i=Z(()=>{e&&(o("MFA canceled"),e.resolve({success:!1,canceled:!0}),n(null))},[e,o]),s=Z(l=>{e&&(o("MFA error: "+l.message),e.resolve({success:!1,canceled:!1,error:l}),n(null))},[e,o]),a=!!e,m=(d=e==null?void 0:e.context)!=null?d:null;return{activeMfaRequest:e,isMfaActive:a,mfaContext:m,requestMfa:t,handleMfaDone:r,handleMfaCancel:i,handleMfaError:s}}var oe=on(null);function he({children:e}){let[n,o]=tn(null),t=A(),{log:r}=I(),{requestMfa:i,handleMfaDone:s,handleMfaCancel:a,isMfaActive:m,mfaContext:d}=Ce(),l=rn(x=>D(null,null,function*(){let u=yield i(x);return u.success?{success:!0}:u.canceled?{success:!1,canceled:!0}:{success:!1,error:u.error.message}}),[i]),f=xe(()=>n?{freezeCard:x=>D(null,null,function*(){try{let u=yield n.freezeCard(x);return u.success?{success:!0,canceled:!1,data:u.data}:u.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new v({code:L.internal_error,message:u.error})}}catch(u){return{success:!1,canceled:!1,error:new v({code:L.internal_error,message:u instanceof Error?u.message:"Communication error with iframe"})}}}),unfreezeCard:x=>D(null,null,function*(){try{let u=yield n.unfreezeCard(x);return u.success?{success:!0,canceled:!1,data:u.data}:u.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new v({code:L.internal_error,message:u.error})}}catch(u){return{success:!1,canceled:!1,error:new v({code:L.internal_error,message:u instanceof Error?u.message:"Communication error with iframe"})}}})}:null,[n]),b=xe(()=>({"system-messages":{requestMfa:l},mfa:{onDone:s,onCancel:a}}),[l,s,a]),{isLoaded:k,url:E,connection:g,iframeRef:M}=J({renderingContext:{entryPoint:"actions"},methods:b});$.useEffect(()=>{let x=!0;return g&&g.promise.then(u=>{x&&(o(u),r("Actions iframe child functions loaded"))}),()=>{x=!1}},[g]);let T=!k||!n;return $.createElement(oe.Provider,{value:{childFunctions:n,actions:f,isLoading:T}},e,E&&$.createElement(w,{src:E,style:{display:"none"},checkOrigin:!1,log:t,ref:M,onLoad:()=>{r("Actions iframe HTML loaded successfully")},onError:x=>{r(`Actions iframe failed to load: ${x}. This may indicate network issues or security policy blocking.`)}}),m&&d&&$.createElement(ge,{onClose:a,ariaLabel:"Multi-factor authentication"},$.createElement(ue,p(c({mfaId:d.mfaId,destination:d.destination,codeLength:d.codeLength,canResendAfter:d.canResendAfter},d.operationName&&{operationName:d.operationName}),{onDone:s,onCancel:a}))))}var Pe=sn({isLoading:!1,invalidateToken:()=>{},enableLogging:!1}),dn=({getToken:e,enableLogging:n,logger:o,children:t})=>{let[r,i]=B(void 0),[s,a]=B(void 0),[m,d]=B(void 0),[l,f]=B(!1),[b,k]=B(void 0),E=R(()=>D(null,null,function*(){f(!0);try{let x=yield e();i(x),k(void 0);let u=G(x),F=new URL(u.path);F.pathname="",a(F.toString())}catch(x){k(x)}finally{f(!1)}}),[e]),g=R(()=>{d(void 0)},[]);cn(()=>{m||E()},[m,E]);let M=R(x=>{d(x),i(void 0),k(void 0)},[]),T=ye(()=>{if(m&&!s)throw new v({message:"baseUrl is required for long lived tokens",code:L.unauthorized});return{tokenData:m?{token:m,tokenType:"longLived",baseUrl:s,paramKey:"access_token",paramLocation:"hash"}:void 0,isLoading:l,error:b,invalidateToken:g,enableLogging:n!=null?n:!1,logger:o}},[m,l,b,g,s,n]);return H.createElement(H.Fragment,null,H.createElement(Pe.Provider,{value:T},H.createElement(he,null,t)),r&&!m&&H.createElement(pe,{oneTimeToken:r,onExchangeComplete:M,enableLogging:n,onExchangeError:k}))},X=()=>an(Pe);function A(e){let{enableLogging:n}=X();return e!==void 0?e:n}function I(e){let n=A(e),{logger:o}=X(),t=R(s=>{q.log(s,{enableLogging:n,logger:o})},[n]),r=R(s=>{q.warn(s,{enableLogging:n,logger:o})},[n]),i=R(s=>{q.error(s,{enableLogging:n,logger:o})},[n]);return ye(()=>({log:t,warn:r,error:i}),[t,r,i])}function C(e){let{token:n,className:o,enableLogging:t,onError:r,loadingComponent:i,renderingContext:s,methods:a,theme:m,sizeWidth:d}=e,l=A(t),{log:f}=I(t),{isLoaded:b,url:k,tokenData:E,iframeRef:g}=J({oneTimeToken:n,enableLogging:l,onError:r,renderingContext:s,theme:m,methods:a});if(!E||!k)return U.createElement(U.Fragment,null,i||null);let M=s.entryPoint!=="insightsWidget";return U.createElement(U.Fragment,null,!b&&i,U.createElement(w,{src:k,allow:"clipboard-write",checkOrigin:!1,style:{width:"1px",height:"0px",minWidth:"100%"},className:o,log:l,ref:g,hidden:!b,onLoad:()=>{f(`Main iframe HTML loaded successfully for entry point: ${s.entryPoint}`)},onError:T=>{f(`Main iframe failed to load: ${T}. This may indicate network issues, firewall blocking, or CSP violations.`)},onResized:T=>{if(!M)return;let x=`${parseInt(T.height)+12}px`;T.iframe.style.height=x},sizeWidth:d}))}import _,{useMemo as ln}from"react";import{useState as pn}from"react";import O,{useState as ve}from"react";var N={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"}},ke=()=>O.createElement("svg",{style:N.bugIcon,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor"},O.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 te({onClick:e,isLoading:n=!1}){let[o,t]=ve(!1),[r,i]=ve(!1),s=c(c(c(c({},N.bugButton),n&&N.loadingButton),!n&&o&&N.bugButtonHover),!n&&r&&N.bugButtonFocus);return n?O.createElement("div",{style:s},O.createElement("style",null,`
|
|
1
|
+
"use client";var Ie=Object.defineProperty,Me=Object.defineProperties;var Oe=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var de=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var ce=(e,n,t)=>n in e?Ie(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,c=(e,n)=>{for(var t in n||(n={}))de.call(n,t)&&ce(e,t,n[t]);if(W)for(var t of W(n))le.call(n,t)&&ce(e,t,n[t]);return e},p=(e,n)=>Me(e,Oe(n));var k=(e,n)=>{var t={};for(var o in e)de.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(e!=null&&W)for(var o of W(e))n.indexOf(o)<0&&le.call(e,o)&&(t[o]=e[o]);return t};var D=(e,n,t)=>new Promise((o,r)=>{var i=m=>{try{a(t.next(m))}catch(f){r(f)}},s=m=>{try{a(t.throw(m))}catch(f){r(f)}},a=m=>m.done?o(m.value):Promise.resolve(m.value).then(i,s);a((t=t.apply(e,n)).next())});import x,{useMemo as h,useContext as kn}from"react";import B from"react";import $,{createContext as mn,useContext as fn,useState as H,useMemo as Te,useCallback as ie,useEffect as gn}from"react";import Ye,{useMemo as en,useRef as nn,useEffect as tn}from"react";var b=class extends Error{constructor({message:n,code:t}){super(n),this.name="CapitalOSError",this.code=t}},L={unauthorized:"unauthorized",invalid_account_status:"invalid_account_status",unsupported_entry_point:"unsupported_entry_point",internal_error:"internal_error"},O=class extends b{constructor(n){super({message:`Invalid token ${n!=null?n:""}`,code:L.unauthorized}),this.name="CapitalOSInvalidTokenError"}};import{connect as Be,WindowMessenger as Ue}from"penpal";import{useCallback as Ne,useEffect as F,useMemo as ne,useRef as K,useState as fe}from"react";import{useRef as Ae}from"react";function R(e){let n=Ae(e);return n.current=e,n}var we={enableLogging:!1},Se="[CapitalOS] ";function Q(e){return(n,t=we)=>{try{let o=`${Se}${n}`;t.logger?t.logger[e](o):t.enableLogging&&console[e](o)}catch(o){}}}var j={log:Q("log"),warn:Q("warn"),error:Q("error")};function Y(e){return e?e.length<=12?"***":`${e.substring(0,4)}...${e.substring(e.length-4)}`:"undefined"}function q(e){try{return e.replace(/([?&#])(token|access_token)=([^&\s#]+)/gi,(n,t,o,r)=>!r||r.length<=12?`${t}${o}=***`:`${t}${o}=${Y(r)}`)}catch(n){return"[URL redacted due to processing error]"}}function ee(e){try{let n=decodeURIComponent(e),t=atob(n);return JSON.parse(t)}catch(n){throw new O}}function V(e){let t=ee(e).path;if(!t||typeof t!="string")throw new O;return{token:e,tokenType:"oneTime",baseUrl:t,paramKey:"token",paramLocation:"search"}}var pe="1.4.5-rc.3";function $e(e){let n=JSON.stringify(e),t=btoa(n);return encodeURIComponent(t)}function He(e){try{return decodeURIComponent(e)}catch(n){return e}}function ue({tokenData:e,renderingContext:n,theme:t,onError:o}){try{let r=n?p(c({},n),{referer:window.location.href}):null,i=r?$e(r):null,s=new URL(e.baseUrl),a=He(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",pe),i&&s.searchParams.set("renderingContext",i),t&&s.searchParams.set("theme",t),s.toString()}catch(r){o==null||o(new O);return}}var me=1e4;function _e(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 te({iframeRef:e,token:n,onError:t,methods:o,iframeLabel:r}){let[i,s]=fe(null),{log:a}=M(),m=R(o),f=R(t),d=R(r),u=ne(()=>_e(a),[a]);return F(()=>{let y=d.current?`[${d.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 P=!0,E=new Ue({remoteWindow:e.current.contentWindow,allowedOrigins:["*"]}),g=Be({messenger:E,methods:m.current,timeout:me,log:u});return g.promise.then(()=>{P&&(a(`${y}Penpal connection established successfully`),s(g))}).catch(I=>{var T;P&&(a(`${y}Penpal connection failed: ${I.message}. Timeout: ${me}ms`),(T=f.current)==null||T.call(f,I),s(null))}),()=>{P=!1,a(`${y}Destroying Penpal connection (cleanup triggered - likely due to token or iframeRef change, or component unmount)`),g.destroy(),s(null)}},[n,a,u]),i}function oe({tokenData:e,renderingContext:n,theme:t,onError:o}){let r=K(o),i=K(n);return ne(()=>{if(e)return ue({tokenData:e,renderingContext:i.current,theme:t,onError:r.current})},[e,t,r,i])}function J(e){let{oneTimeToken:n,enableLogging:t,onError:o,renderingContext:r,theme:i,methods:s}=e,{tokenData:a,error:m,invalidateToken:f}=X(),{log:d,warn:u}=M(t),[y,P]=fe(!1),E=K(null);We(m,o);let g=ne(()=>n?V(n):a,[n,a]);F(()=>{g&&d(`[${r.entryPoint}] Token data available, type: ${g.tokenType}, token: ${Y(g.token)}, location: ${g.paramLocation}, key: ${g.paramKey}, baseUrl: ${g.baseUrl}`)},[g,d,r.entryPoint]);let I=Ne(()=>{if(d("Token expired, invalidating..."),n){o==null||o(new b({message:"Token expired. Cannot automatically refresh when using token prop.",code:L.unauthorized}));return}f(),P(!1)},[d,n,f,o]);F(()=>{n&&a&&u("token was provided both from provider and from the token prop. the prop will take precedence")},[n,a,u]);let T=oe({tokenData:g,renderingContext:r,theme:i,onError:o});F(()=>{T?d(`Iframe URL generated: ${q(T).substring(0,1024)}...`):g&&u("Failed to generate iframe URL despite having token data")},[T,g,d,u]);let v=te({iframeRef:E,token:g==null?void 0:g.token,iframeLabel:r.entryPoint,onError:l=>{d(`Connection error: ${l.message}`),o==null||o(l),P(!0)},methods:c({onLoad:()=>{d("Iframe called onLoad()"),P(!0)},onError:l=>{let _=new b(l);d(`Iframe error: ${_.message}`),o==null||o(_)},onTokenExpired:I},s)});return{isLoaded:y,url:T,tokenData:g,iframeRef:E,connection:v}}function We(e,n){let t=K(!1);F(()=>{e&&!t.current&&(n==null||n(e),t.current=!0)},[e,n])}import{iframeResizer as je}from"iframe-resizer";import qe,{forwardRef as Ve,useEffect as Ke,useImperativeHandle as Je,useRef as Xe}from"react";var A=Ve((e,n)=>{let t=e.title||"iframe",{iframeHTMLAttributes:o,resizerOptions:r}=Qe(e),i=Xe(null);return Ke(()=>{let s=i.current;return je(c({},r),s),()=>s.iFrameResizer&&s.iFrameResizer.removeListeners()}),Je(n,()=>i.current),qe.createElement("iframe",p(c({},o),{title:t,ref:i}))});A.displayName="IframeResizer";var Ze=["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"],Ge=new Set(Ze);function Qe(e){return Object.keys(e).reduce((t,o)=>{let r=e[o];return Ge.has(o)?r!==void 0&&(t.resizerOptions[o]=e[o]):t.iframeHTMLAttributes[o]=e[o],t},{resizerOptions:{},iframeHTMLAttributes:{}})}function ge(e){let{oneTimeToken:n,enableLogging:t,onExchangeComplete:o,onExchangeError:r}=e,i=w(t),{log:s}=M(t),a=nn(null),m=en(()=>V(n),[n]),d=oe({tokenData:m,onError:r,renderingContext:{entryPoint:"tokenExchange"}});return tn(()=>{if(d){let u=q(d),y=u.substring(0,1024),P=u.length>1024;s(`Token exchange iframe URL: ${y}${P?"...":""}`)}},[d,s]),te({iframeRef:a,token:n,iframeLabel:"token-exchange",onError:u=>{s(`Token exchange connection error: ${u.message}`),r==null||r(u)},methods:{onLoad:()=>{s("Token exchange iframe loaded")},onError:u=>{s(`Token exchange iframe error: ${u.message}`),r==null||r(new b(u))},tokenExchange:{onLongLivedToken:u=>{s("Token exchange complete: received long-lived token"),o(u)}}}}),Ye.createElement(A,{src:d,checkOrigin:!1,style:{display:"none"},log:i,ref:a,onLoad:()=>{s("Token exchange iframe HTML loaded successfully")},onError:u=>{s(`Token exchange iframe failed to load: ${u}`)}})}import{useCallback as on,useRef as rn}from"react";function Z(e){let n=rn(e);return n.current=e,on((...t)=>n.current(...t),[])}import z,{createContext as ln,useState as pn,useMemo as ke,useCallback as un}from"react";import sn from"react";import{useMemo as an}from"react";function Ce(m){var f=m,{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 d="mfa",u=an(()=>({entryPoint:d,mfaId:t,destination:o,codeLength:r,canResendAfter:i,operationName:s}),[d,t,o,r,i,s]);return sn.createElement(C,p(c({},a),{renderingContext:u,methods:{mfa:{onDone:e,onCancel:n}}}))}import xe,{useEffect as cn}from"react";var he={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 ye({onClose:e,children:n,ariaLabel:t="Modal dialog"}){cn(()=>{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 xe.createElement("div",{style:he.backdrop,onClick:o,role:"dialog","aria-modal":"true","aria-label":t},xe.createElement("div",{style:he.container},n))}import{useState as dn,useCallback as G}from"react";function Pe(){var f;let[e,n]=dn(null),{log:t}=M(),o=G(d=>(t("MFA requested"),new Promise((u,y)=>{n({context:d,resolve:u,reject:y})})),[t]),r=G(()=>{e&&(t("MFA completed successfully"),e.resolve({success:!0,canceled:!1,data:void 0}),n(null))},[e,t]),i=G(()=>{e&&(t("MFA canceled"),e.resolve({success:!1,canceled:!0}),n(null))},[e,t]),s=G(d=>{e&&(t("MFA error: "+d.message),e.resolve({success:!1,canceled:!1,error:d}),n(null))},[e,t]),a=!!e,m=(f=e==null?void 0:e.context)!=null?f:null;return{activeMfaRequest:e,isMfaActive:a,mfaContext:m,requestMfa:o,handleMfaDone:r,handleMfaCancel:i,handleMfaError:s}}var re=ln(null);function be({children:e}){let[n,t]=pn(null),o=w(),{log:r}=M(),{requestMfa:i,handleMfaDone:s,handleMfaCancel:a,isMfaActive:m,mfaContext:f}=Pe(),d=un(v=>D(null,null,function*(){let l=yield i(v);return l.success?{success:!0}:l.canceled?{success:!1,canceled:!0}:{success:!1,error:l.error.message}}),[i]),u=ke(()=>n?{freezeCard:v=>D(null,null,function*(){try{let l=yield n.freezeCard(v);return l.success?{success:!0,canceled:!1,data:l.data}:l.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new b({code:L.internal_error,message:l.error})}}catch(l){return{success:!1,canceled:!1,error:new b({code:L.internal_error,message:l instanceof Error?l.message:"Communication error with iframe"})}}}),unfreezeCard:v=>D(null,null,function*(){try{let l=yield n.unfreezeCard(v);return l.success?{success:!0,canceled:!1,data:l.data}:l.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new b({code:L.internal_error,message:l.error})}}catch(l){return{success:!1,canceled:!1,error:new b({code:L.internal_error,message:l instanceof Error?l.message:"Communication error with iframe"})}}})}:null,[n]),y=ke(()=>({"system-messages":{requestMfa:d},mfa:{onDone:s,onCancel:a}}),[d,s,a]),{isLoaded:P,url:E,connection:g,iframeRef:I}=J({renderingContext:{entryPoint:"actions"},methods:y});z.useEffect(()=>{let v=!0;return g&&g.promise.then(l=>{v&&(t(l),r("Actions iframe child functions loaded"))}),()=>{v=!1}},[g,r]);let T=!P||!n;return z.createElement(re.Provider,{value:{childFunctions:n,actions:u,isLoading:T}},e,E&&z.createElement(A,{src:E,style:{display:"none"},checkOrigin:!1,log:o,ref:I,onLoad:()=>{r("Actions iframe HTML loaded successfully")},onError:v=>{r(`Actions iframe failed to load: ${v}. This may indicate network issues or security policy blocking.`)}}),m&&f&&z.createElement(ye,{onClose:a,ariaLabel:"Multi-factor authentication"},z.createElement(Ce,p(c({mfaId:f.mfaId,destination:f.destination,codeLength:f.codeLength,canResendAfter:f.canResendAfter},f.operationName&&{operationName:f.operationName}),{onDone:s,onCancel:a}))))}var ve=mn({isLoading:!1,invalidateToken:()=>{},enableLogging:!1,loggerRef:{current:void 0}}),Cn=({getToken:e,enableLogging:n,logger:t,children:o})=>{let[r,i]=H(void 0),[s,a]=H(void 0),[m,f]=H(void 0),[d,u]=H(!1),[y,P]=H(void 0),E=R(t),g=ie(()=>D(null,null,function*(){u(!0);try{let l=yield e();i(l),P(void 0);let _=ee(l),ae=new URL(_.path);ae.pathname="",a(ae.toString())}catch(l){P(l)}finally{u(!1)}}),[e]),I=ie(()=>{f(void 0)},[]);gn(()=>{m||g()},[m,g]);let T=ie(l=>{f(l),i(void 0),P(void 0)},[]),v=Te(()=>{if(m&&!s)throw new b({message:"baseUrl is required for long lived tokens",code:L.unauthorized});return{tokenData:m?{token:m,tokenType:"longLived",baseUrl:s,paramKey:"access_token",paramLocation:"hash"}:void 0,isLoading:d,error:y,invalidateToken:I,enableLogging:n!=null?n:!1,loggerRef:E}},[m,d,y,I,s,n]);return $.createElement($.Fragment,null,$.createElement(ve.Provider,{value:v},$.createElement(be,null,o)),r&&!m&&$.createElement(ge,{oneTimeToken:r,onExchangeComplete:T,enableLogging:n,onExchangeError:P}))},X=()=>fn(ve);function w(e){let{enableLogging:n}=X();return e!==void 0?e:n}function M(e){let n=w(e),{loggerRef:t}=X(),o=Z(s=>{var a;j.log(s,{enableLogging:n,logger:(a=t.current)!=null?a:void 0})}),r=Z(s=>{var a;j.warn(s,{enableLogging:n,logger:(a=t.current)!=null?a:void 0})}),i=Z(s=>{var a;j.error(s,{enableLogging:n,logger:(a=t.current)!=null?a:void 0})});return Te(()=>({log:o,warn:r,error:i}),[o,r,i])}function C(e){let{token:n,className:t,enableLogging:o,onError:r,loadingComponent:i,renderingContext:s,methods:a,theme:m,sizeWidth:f}=e,d=w(o),{log:u}=M(o),{isLoaded:y,url:P,tokenData:E,iframeRef:g}=J({oneTimeToken:n,enableLogging:d,onError:r,renderingContext:s,theme:m,methods:a});if(!E||!P)return B.createElement(B.Fragment,null,i||null);let I=s.entryPoint!=="insightsWidget";return B.createElement(B.Fragment,null,!y&&i,B.createElement(A,{src:P,allow:"clipboard-write",checkOrigin:!1,style:{width:"1px",height:"0px",minWidth:"100%"},className:t,log:d,ref:g,hidden:!y,onLoad:()=>{u(`Main iframe HTML loaded successfully for entry point: ${s.entryPoint}`)},onError:T=>{u(`Main iframe failed to load: ${T}. This may indicate network issues, firewall blocking, or CSP violations.`)},onResized:T=>{if(!I)return;let v=`${parseInt(T.height)+12}px`;T.iframe.style.height=v},sizeWidth:f}))}import N,{useMemo as xn}from"react";import{useState as hn}from"react";import S,{useState as Le}from"react";var U={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"}},Ee=()=>S.createElement("svg",{style:U.bugIcon,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor"},S.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 se({onClick:e,isLoading:n=!1}){let[t,o]=Le(!1),[r,i]=Le(!1),s=c(c(c(c({},U.bugButton),n&&U.loadingButton),!n&&t&&U.bugButtonHover),!n&&r&&U.bugButtonFocus);return n?S.createElement("div",{style:s},S.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
|
+
`),S.createElement(Ee,null)):S.createElement("button",{id:"dev-tools-button",onClick:e,type:"button",style:s,onMouseEnter:()=>o(!0),onMouseLeave:()=>o(!1),onFocus:()=>i(!0),onBlur:()=>i(!1)},S.createElement(Ee,null))}var yn={panel:{position:"fixed",bottom:"20px",left:"20px",zIndex:50}};function Pn(e){let n="devTools",t=xn(()=>({entryPoint:n}),[n]),[o,r]=hn(!1);return N.createElement("aside",{"aria-label":"CapitalOS dev tools"},!o&&N.createElement(se,{onClick:()=>r(!o)}),o&&N.createElement("div",{style:yn.panel},N.createElement(C,p(c({},e),{renderingContext:t,methods:{devTools:{onClose:()=>r(!1)}},enableLogging:!0,sizeWidth:!0,loadingComponent:N.createElement(se,{isLoading:!0})}))))}function bn(e){let n="cardsApp",t=h(()=>({entryPoint:n}),[n]);return x.createElement(C,p(c({},e),{renderingContext:t}))}var xo=bn;function ho(i){var s=i,{cardholder:e,onCreate:n,onDone:t,onCancel:o}=s,r=k(s,["cardholder","onCreate","onDone","onCancel"]);let a="createCard",m=h(()=>({entryPoint:a,cardholder:e}),[e]);return x.createElement(C,p(c({},r),{renderingContext:m,methods:{createCard:p(c({},n?{onCreate:n}:{}),{onDone:t,onCancel:o})}}))}function yo(r){var i=r,{transactionId:e,onDone:n,onCancel:t}=i,o=k(i,["transactionId","onDone","onCancel"]);let s="createDispute",a=h(()=>({entryPoint:s,transactionId:e}),[e]);return x.createElement(C,p(c({},o),{renderingContext:a,methods:{createDispute:{onDone:n,onCancel:t}}}))}function Po(e){let n="billPayApp",t=h(()=>({entryPoint:n}),[n]);return x.createElement(C,p(c({},e),{renderingContext:t}))}function ko(e){let n="demoBillPayApp",t=h(()=>({entryPoint:n}),[n]);return x.createElement(C,p(c({},e),{renderingContext:t}))}function bo(e){let s=e,{onCardCanceled:n,onHideSensitiveDetails:t}=s,o=k(s,["onCardCanceled","onHideSensitiveDetails"]),r="cardDetails",i=h(()=>({entryPoint:r,cardId:e.cardId,cardOnly:e.cardOnly,backOnly:e.backOnly,hideAddress:e.hideAddress}),[r,e.cardId,e.cardOnly,e.backOnly,e.hideAddress]);return x.createElement(C,p(c({},o),{renderingContext:i,methods:{cardDetails:{onCardCanceled:n!=null?n:()=>{},onHideSensitiveDetails:t!=null?t:()=>{}}}}))}function To(e){let n="accountDetails",t=h(()=>({entryPoint:n}),[n]);return x.createElement(C,p(c({},e),{renderingContext:t}))}function vo(e){let n="accountActions",t=h(()=>({entryPoint:n}),[n]);return x.createElement(C,p(c({},e),{renderingContext:t}))}function Lo(t){var o=t,{onClose:e}=o,n=k(o,["onClose"]);let r="manageBankConnections",i=h(()=>({entryPoint:r}),[r]);return x.createElement(C,p(c({},n),{renderingContext:i,methods:{manageBankConnections:{onClose:e}}}))}function Eo(t){var o=t,{onClose:e}=o,n=k(o,["onClose"]);let r="configureAutoPay",i=h(()=>({entryPoint:r}),[r]);return x.createElement(C,p(c({},n),{renderingContext:i,methods:{configureAutoPay:{onClose:e}}}))}function Io(t){var o=t,{onClose:e}=o,n=k(o,["onClose"]);let r="policySettings",i=h(()=>({entryPoint:r}),[r]);return x.createElement(C,p(c({},n),{renderingContext:i,methods:{policySettings:{onClose:e}}}))}function Mo(r){var i=r,{cardId:e,onClose:n,inlineCardOnFile:t}=i,o=k(i,["cardId","onClose","inlineCardOnFile"]);let s="connectToVendors",a=h(()=>({entryPoint:s,cardId:e,inlineCardOnFile:t}),[s,e,t]);return x.createElement(C,p(c({},o),{renderingContext:a,methods:{connectToVendors:{onClose:n}}}))}function Oo(e){let n="insightsDashboard",t=h(()=>({entryPoint:n}),[n]);return x.createElement(C,p(c({},e),{renderingContext:t}))}function Ao(e){let n="insightsWidget",{widget:t,hideTitle:o,height:r,width:i}=e,s=h(()=>({entryPoint:n,widget:t,hideTitle:o,height:r,width:i}),[n,t,o,r,i]);return x.createElement(C,p(c({},e),{renderingContext:s}))}function wo(r){var i=r,{onDone:e,entryPoint:n,exitPoint:t}=i,o=k(i,["onDone","entryPoint","exitPoint"]);let s="onboarding",a=h(()=>({entryPoint:s,onboardingEntryPoint:n,onboardingExitPoint:t}),[s,n,t]);return x.createElement(C,p(c({},o),{renderingContext:a,methods:{onboarding:{onDone:e}}}))}function So(t){var o=t,{onDone:e}=o,n=k(o,["onDone"]);let r="makePayment",i=h(()=>({entryPoint:r}),[r]);return x.createElement(C,p(c({},n),{renderingContext:i,methods:{makePayment:{onDone:e}}}))}function Do(o){var r=o,{onDone:e,onCancel:n}=r,t=k(r,["onDone","onCancel"]);let i="contactSupport",s=h(()=>({entryPoint:i}),[i]);return x.createElement(C,p(c({},t),{renderingContext:s,methods:{contactSupport:{onDone:e,onCancel:n}}}))}function Ro(t){var o=t,{onDone:e}=o,n=k(o,["onDone"]);let r="statements",i=h(()=>({entryPoint:r}),[r]);return x.createElement(C,p(c({},n),{renderingContext:i,methods:{statements:{onDone:e}}}))}function Fo(t){var o=t,{onDone:e}=o,n=k(o,["onDone"]);let r="legalDocuments",i=h(()=>({entryPoint:r}),[r]);return x.createElement(C,p(c({},n),{renderingContext:i,methods:{legalDocuments:{onDone:e}}}))}function zo(r){var i=r,{cardId:e,onDone:n,onClose:t}=i,o=k(i,["cardId","onDone","onClose"]);let s="replaceCard",a=h(()=>({entryPoint:s,cardId:e}),[e]);return x.createElement(C,p(c({},o),{renderingContext:a,methods:{replaceCard:{onDone:n,onClose:t}}}))}function $o(r){var i=r,{cardId:e,onDone:n,onClose:t}=i,o=k(i,["cardId","onDone","onClose"]);let s="terminateCard",a=h(()=>({entryPoint:s,cardId:e}),[e]);return x.createElement(C,p(c({},o),{renderingContext:a,methods:{terminateCard:{onDone:n,onClose:t}}}))}function Ho(e){let n="transactions",t=h(()=>({entryPoint:n}),[n]);return x.createElement(C,p(c({},e),{renderingContext:t}))}function Bo(){let e=kn(re);if(!e)throw new b({message:"useActions must be used within a CapitalOsAuthenticationProvider",code:L.internal_error});let{childFunctions:n,isLoading:t}=e;return{actions:n,isLoading:t}}export{vo as AccountActions,To as AccountDetails,xo as App,Po as BillPayApp,Cn as CapitalOsAuthenticationProvider,bo as CardDetails,bn as CardsApp,Eo as ConfigureAutoPay,Mo as ConnectToVendors,Do as ContactSupport,ko as DemoBillPayApp,Pn as DevTools,yo as DisputeTransaction,Oo as InsightsDashboard,Ao as InsightsWidget,ho as IssueCard,Fo as LegalDocuments,So as MakePayment,Lo as ManageBankConnections,wo as Onboarding,Io as PolicySettings,zo as ReplaceCard,Ro as Statements,$o as TerminateCard,Ho as Transactions,Bo as useActions};
|
|
11
11
|
//# sourceMappingURL=index.js.map
|