@capitalos/react 1.2.1 → 1.3.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/README.md +4 -0
- package/dist/_tsup-dts-rollup.d.mts +104 -2
- package/dist/_tsup-dts-rollup.d.ts +104 -2
- package/dist/esm/index.js +2 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/src/index.d.mts +8 -0
- package/dist/src/index.d.ts +8 -0
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -54,3 +54,7 @@ TypeScript definitions for `@capitalos/react` are built into the npm package and
|
|
|
54
54
|
## Error Handling
|
|
55
55
|
|
|
56
56
|
For details on how errors are managed within the SDK and how to handle them as a consumer or a maintainer, please see our [Error Handling Guidelines](./ERROR_HANDLING.md).
|
|
57
|
+
|
|
58
|
+
## Navigation Patterns
|
|
59
|
+
|
|
60
|
+
For guidance on modal dismissal, back button behavior, and callback semantics when integrating SDK components into your application, please see our [Navigation and Closing Patterns](./NAVIGATION_PATTERNS.md).
|
|
@@ -549,6 +549,34 @@ export declare type CommonProps = {
|
|
|
549
549
|
theme?: ThemeColorScheme;
|
|
550
550
|
};
|
|
551
551
|
|
|
552
|
+
/**
|
|
553
|
+
* Renders the CapitalOS Configure Autopay experience.
|
|
554
|
+
*/
|
|
555
|
+
export declare function ConfigureAutoPay({ onClose, ...restOfProps }: ConfigureAutoPayProps): JSX.Element;
|
|
556
|
+
|
|
557
|
+
export declare type ConfigureAutoPayProps = CommonProps & {
|
|
558
|
+
/**
|
|
559
|
+
* Callback to invoke when the user closes the autopay configuration screen.
|
|
560
|
+
*/
|
|
561
|
+
onClose: () => void;
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Renders the CapitalOS Connect To Vendors experience.
|
|
566
|
+
*/
|
|
567
|
+
export declare function ConnectToVendors({ cardId, onClose, ...restOfProps }: ConnectToVendorsProps): JSX.Element;
|
|
568
|
+
|
|
569
|
+
export declare type ConnectToVendorsProps = CommonProps & {
|
|
570
|
+
/**
|
|
571
|
+
* The ID of the card to connect to vendor services. If not provided, uses the default card.
|
|
572
|
+
*/
|
|
573
|
+
cardId?: string;
|
|
574
|
+
/**
|
|
575
|
+
* Callback to invoke when the user closes the connect to vendors screen.
|
|
576
|
+
*/
|
|
577
|
+
onClose: () => void;
|
|
578
|
+
};
|
|
579
|
+
|
|
552
580
|
export declare function ContactSupport({ onDone, onCancel, ...restOfProps }: ContactSupportProps): JSX.Element;
|
|
553
581
|
|
|
554
582
|
export declare type ContactSupportProps = CommonProps & {
|
|
@@ -736,6 +764,22 @@ export declare type MakePaymentProps = CommonProps & {
|
|
|
736
764
|
onDone: () => void;
|
|
737
765
|
};
|
|
738
766
|
|
|
767
|
+
/**
|
|
768
|
+
* Renders the CapitalOS Manage Bank Connections experience.
|
|
769
|
+
*/
|
|
770
|
+
export declare function ManageBankConnections({ onDone, onCancel, ...restOfProps }: ManageBankConnectionsProps): JSX.Element;
|
|
771
|
+
|
|
772
|
+
export declare type ManageBankConnectionsProps = CommonProps & {
|
|
773
|
+
/**
|
|
774
|
+
* Callback to invoke when the user has completed managing bank connections.
|
|
775
|
+
*/
|
|
776
|
+
onDone: () => void;
|
|
777
|
+
/**
|
|
778
|
+
* Callback to invoke when the user has cancelled managing bank connections.
|
|
779
|
+
*/
|
|
780
|
+
onCancel: () => void;
|
|
781
|
+
};
|
|
782
|
+
|
|
739
783
|
export declare function Mfa({ onDone, onCancel, mfaId, destination, codeLength, canResendAfter, operationName, ...restOfProps }: MfaProps): JSX.Element;
|
|
740
784
|
|
|
741
785
|
export declare type MfaActionResult = ActionResult<void>;
|
|
@@ -855,6 +899,19 @@ export declare type ParentFunctions = {
|
|
|
855
899
|
makePayment?: {
|
|
856
900
|
onDone?: () => void;
|
|
857
901
|
};
|
|
902
|
+
manageBankConnections?: {
|
|
903
|
+
onDone?: () => void;
|
|
904
|
+
onCancel?: () => void;
|
|
905
|
+
};
|
|
906
|
+
configureAutoPay?: {
|
|
907
|
+
onClose?: () => void;
|
|
908
|
+
};
|
|
909
|
+
policySettings?: {
|
|
910
|
+
onClose?: () => void;
|
|
911
|
+
};
|
|
912
|
+
connectToVendors?: {
|
|
913
|
+
onClose?: () => void;
|
|
914
|
+
};
|
|
858
915
|
mfa?: {
|
|
859
916
|
onDone?: () => void;
|
|
860
917
|
onCancel?: () => void;
|
|
@@ -863,7 +920,10 @@ export declare type ParentFunctions = {
|
|
|
863
920
|
onDone?: (account: Account) => void;
|
|
864
921
|
};
|
|
865
922
|
replaceCard?: {
|
|
866
|
-
onDone?: (
|
|
923
|
+
onDone?: (result: {
|
|
924
|
+
oldCardId: string;
|
|
925
|
+
newCardId: string;
|
|
926
|
+
}) => void;
|
|
867
927
|
onClose?: () => void;
|
|
868
928
|
};
|
|
869
929
|
'system-messages'?: {
|
|
@@ -881,6 +941,18 @@ export declare type ParentFunctions = {
|
|
|
881
941
|
};
|
|
882
942
|
};
|
|
883
943
|
|
|
944
|
+
/**
|
|
945
|
+
* Renders the CapitalOS Policy Settings experience.
|
|
946
|
+
*/
|
|
947
|
+
export declare function PolicySettings({ onClose, ...restOfProps }: PolicySettingsProps): JSX.Element;
|
|
948
|
+
|
|
949
|
+
export declare type PolicySettingsProps = CommonProps & {
|
|
950
|
+
/**
|
|
951
|
+
* Callback to invoke when the user closes the policy settings screen.
|
|
952
|
+
*/
|
|
953
|
+
onClose: () => void;
|
|
954
|
+
};
|
|
955
|
+
|
|
884
956
|
declare type ProviderProps = {
|
|
885
957
|
getToken: () => Promise<string>;
|
|
886
958
|
enableLogging?: boolean | undefined;
|
|
@@ -982,6 +1054,33 @@ declare const renderingContextSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<
|
|
|
982
1054
|
entryPoint: "accountActions";
|
|
983
1055
|
}, {
|
|
984
1056
|
entryPoint: "accountActions";
|
|
1057
|
+
}>, z.ZodObject<{
|
|
1058
|
+
entryPoint: z.ZodLiteral<"manageBankConnections">;
|
|
1059
|
+
}, "strip", z.ZodTypeAny, {
|
|
1060
|
+
entryPoint: "manageBankConnections";
|
|
1061
|
+
}, {
|
|
1062
|
+
entryPoint: "manageBankConnections";
|
|
1063
|
+
}>, z.ZodObject<{
|
|
1064
|
+
entryPoint: z.ZodLiteral<"configureAutoPay">;
|
|
1065
|
+
}, "strip", z.ZodTypeAny, {
|
|
1066
|
+
entryPoint: "configureAutoPay";
|
|
1067
|
+
}, {
|
|
1068
|
+
entryPoint: "configureAutoPay";
|
|
1069
|
+
}>, z.ZodObject<{
|
|
1070
|
+
entryPoint: z.ZodLiteral<"policySettings">;
|
|
1071
|
+
}, "strip", z.ZodTypeAny, {
|
|
1072
|
+
entryPoint: "policySettings";
|
|
1073
|
+
}, {
|
|
1074
|
+
entryPoint: "policySettings";
|
|
1075
|
+
}>, z.ZodObject<{
|
|
1076
|
+
entryPoint: z.ZodLiteral<"connectToVendors">;
|
|
1077
|
+
cardId: z.ZodOptional<z.ZodString>;
|
|
1078
|
+
}, "strip", z.ZodTypeAny, {
|
|
1079
|
+
entryPoint: "connectToVendors";
|
|
1080
|
+
cardId?: string | undefined;
|
|
1081
|
+
}, {
|
|
1082
|
+
entryPoint: "connectToVendors";
|
|
1083
|
+
cardId?: string | undefined;
|
|
985
1084
|
}>, z.ZodObject<{
|
|
986
1085
|
entryPoint: z.ZodLiteral<"insightsDashboard">;
|
|
987
1086
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -1123,7 +1222,10 @@ export declare function ReplaceCard({ cardId, onDone, onClose, ...restOfProps }:
|
|
|
1123
1222
|
|
|
1124
1223
|
export declare type ReplaceCardProps = CommonProps & {
|
|
1125
1224
|
cardId: string;
|
|
1126
|
-
onDone: (
|
|
1225
|
+
onDone: (result: {
|
|
1226
|
+
oldCardId: string;
|
|
1227
|
+
newCardId: string;
|
|
1228
|
+
}) => void;
|
|
1127
1229
|
onClose: () => void;
|
|
1128
1230
|
};
|
|
1129
1231
|
|
|
@@ -549,6 +549,34 @@ export declare type CommonProps = {
|
|
|
549
549
|
theme?: ThemeColorScheme;
|
|
550
550
|
};
|
|
551
551
|
|
|
552
|
+
/**
|
|
553
|
+
* Renders the CapitalOS Configure Autopay experience.
|
|
554
|
+
*/
|
|
555
|
+
export declare function ConfigureAutoPay({ onClose, ...restOfProps }: ConfigureAutoPayProps): JSX.Element;
|
|
556
|
+
|
|
557
|
+
export declare type ConfigureAutoPayProps = CommonProps & {
|
|
558
|
+
/**
|
|
559
|
+
* Callback to invoke when the user closes the autopay configuration screen.
|
|
560
|
+
*/
|
|
561
|
+
onClose: () => void;
|
|
562
|
+
};
|
|
563
|
+
|
|
564
|
+
/**
|
|
565
|
+
* Renders the CapitalOS Connect To Vendors experience.
|
|
566
|
+
*/
|
|
567
|
+
export declare function ConnectToVendors({ cardId, onClose, ...restOfProps }: ConnectToVendorsProps): JSX.Element;
|
|
568
|
+
|
|
569
|
+
export declare type ConnectToVendorsProps = CommonProps & {
|
|
570
|
+
/**
|
|
571
|
+
* The ID of the card to connect to vendor services. If not provided, uses the default card.
|
|
572
|
+
*/
|
|
573
|
+
cardId?: string;
|
|
574
|
+
/**
|
|
575
|
+
* Callback to invoke when the user closes the connect to vendors screen.
|
|
576
|
+
*/
|
|
577
|
+
onClose: () => void;
|
|
578
|
+
};
|
|
579
|
+
|
|
552
580
|
export declare function ContactSupport({ onDone, onCancel, ...restOfProps }: ContactSupportProps): JSX.Element;
|
|
553
581
|
|
|
554
582
|
export declare type ContactSupportProps = CommonProps & {
|
|
@@ -736,6 +764,22 @@ export declare type MakePaymentProps = CommonProps & {
|
|
|
736
764
|
onDone: () => void;
|
|
737
765
|
};
|
|
738
766
|
|
|
767
|
+
/**
|
|
768
|
+
* Renders the CapitalOS Manage Bank Connections experience.
|
|
769
|
+
*/
|
|
770
|
+
export declare function ManageBankConnections({ onDone, onCancel, ...restOfProps }: ManageBankConnectionsProps): JSX.Element;
|
|
771
|
+
|
|
772
|
+
export declare type ManageBankConnectionsProps = CommonProps & {
|
|
773
|
+
/**
|
|
774
|
+
* Callback to invoke when the user has completed managing bank connections.
|
|
775
|
+
*/
|
|
776
|
+
onDone: () => void;
|
|
777
|
+
/**
|
|
778
|
+
* Callback to invoke when the user has cancelled managing bank connections.
|
|
779
|
+
*/
|
|
780
|
+
onCancel: () => void;
|
|
781
|
+
};
|
|
782
|
+
|
|
739
783
|
export declare function Mfa({ onDone, onCancel, mfaId, destination, codeLength, canResendAfter, operationName, ...restOfProps }: MfaProps): JSX.Element;
|
|
740
784
|
|
|
741
785
|
export declare type MfaActionResult = ActionResult<void>;
|
|
@@ -855,6 +899,19 @@ export declare type ParentFunctions = {
|
|
|
855
899
|
makePayment?: {
|
|
856
900
|
onDone?: () => void;
|
|
857
901
|
};
|
|
902
|
+
manageBankConnections?: {
|
|
903
|
+
onDone?: () => void;
|
|
904
|
+
onCancel?: () => void;
|
|
905
|
+
};
|
|
906
|
+
configureAutoPay?: {
|
|
907
|
+
onClose?: () => void;
|
|
908
|
+
};
|
|
909
|
+
policySettings?: {
|
|
910
|
+
onClose?: () => void;
|
|
911
|
+
};
|
|
912
|
+
connectToVendors?: {
|
|
913
|
+
onClose?: () => void;
|
|
914
|
+
};
|
|
858
915
|
mfa?: {
|
|
859
916
|
onDone?: () => void;
|
|
860
917
|
onCancel?: () => void;
|
|
@@ -863,7 +920,10 @@ export declare type ParentFunctions = {
|
|
|
863
920
|
onDone?: (account: Account) => void;
|
|
864
921
|
};
|
|
865
922
|
replaceCard?: {
|
|
866
|
-
onDone?: (
|
|
923
|
+
onDone?: (result: {
|
|
924
|
+
oldCardId: string;
|
|
925
|
+
newCardId: string;
|
|
926
|
+
}) => void;
|
|
867
927
|
onClose?: () => void;
|
|
868
928
|
};
|
|
869
929
|
'system-messages'?: {
|
|
@@ -881,6 +941,18 @@ export declare type ParentFunctions = {
|
|
|
881
941
|
};
|
|
882
942
|
};
|
|
883
943
|
|
|
944
|
+
/**
|
|
945
|
+
* Renders the CapitalOS Policy Settings experience.
|
|
946
|
+
*/
|
|
947
|
+
export declare function PolicySettings({ onClose, ...restOfProps }: PolicySettingsProps): JSX.Element;
|
|
948
|
+
|
|
949
|
+
export declare type PolicySettingsProps = CommonProps & {
|
|
950
|
+
/**
|
|
951
|
+
* Callback to invoke when the user closes the policy settings screen.
|
|
952
|
+
*/
|
|
953
|
+
onClose: () => void;
|
|
954
|
+
};
|
|
955
|
+
|
|
884
956
|
declare type ProviderProps = {
|
|
885
957
|
getToken: () => Promise<string>;
|
|
886
958
|
enableLogging?: boolean | undefined;
|
|
@@ -982,6 +1054,33 @@ declare const renderingContextSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<
|
|
|
982
1054
|
entryPoint: "accountActions";
|
|
983
1055
|
}, {
|
|
984
1056
|
entryPoint: "accountActions";
|
|
1057
|
+
}>, z.ZodObject<{
|
|
1058
|
+
entryPoint: z.ZodLiteral<"manageBankConnections">;
|
|
1059
|
+
}, "strip", z.ZodTypeAny, {
|
|
1060
|
+
entryPoint: "manageBankConnections";
|
|
1061
|
+
}, {
|
|
1062
|
+
entryPoint: "manageBankConnections";
|
|
1063
|
+
}>, z.ZodObject<{
|
|
1064
|
+
entryPoint: z.ZodLiteral<"configureAutoPay">;
|
|
1065
|
+
}, "strip", z.ZodTypeAny, {
|
|
1066
|
+
entryPoint: "configureAutoPay";
|
|
1067
|
+
}, {
|
|
1068
|
+
entryPoint: "configureAutoPay";
|
|
1069
|
+
}>, z.ZodObject<{
|
|
1070
|
+
entryPoint: z.ZodLiteral<"policySettings">;
|
|
1071
|
+
}, "strip", z.ZodTypeAny, {
|
|
1072
|
+
entryPoint: "policySettings";
|
|
1073
|
+
}, {
|
|
1074
|
+
entryPoint: "policySettings";
|
|
1075
|
+
}>, z.ZodObject<{
|
|
1076
|
+
entryPoint: z.ZodLiteral<"connectToVendors">;
|
|
1077
|
+
cardId: z.ZodOptional<z.ZodString>;
|
|
1078
|
+
}, "strip", z.ZodTypeAny, {
|
|
1079
|
+
entryPoint: "connectToVendors";
|
|
1080
|
+
cardId?: string | undefined;
|
|
1081
|
+
}, {
|
|
1082
|
+
entryPoint: "connectToVendors";
|
|
1083
|
+
cardId?: string | undefined;
|
|
985
1084
|
}>, z.ZodObject<{
|
|
986
1085
|
entryPoint: z.ZodLiteral<"insightsDashboard">;
|
|
987
1086
|
}, "strip", z.ZodTypeAny, {
|
|
@@ -1123,7 +1222,10 @@ export declare function ReplaceCard({ cardId, onDone, onClose, ...restOfProps }:
|
|
|
1123
1222
|
|
|
1124
1223
|
export declare type ReplaceCardProps = CommonProps & {
|
|
1125
1224
|
cardId: string;
|
|
1126
|
-
onDone: (
|
|
1225
|
+
onDone: (result: {
|
|
1226
|
+
oldCardId: string;
|
|
1227
|
+
newCardId: string;
|
|
1228
|
+
}) => void;
|
|
1127
1229
|
onClose: () => void;
|
|
1128
1230
|
};
|
|
1129
1231
|
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"use client";var be=Object.defineProperty,ke=Object.defineProperties;var Te=Object.getOwnPropertyDescriptors;var U=Object.getOwnPropertySymbols;var oe=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var ne=(e,t,n)=>t in e?be(e,t,{enumerable:!0,configurable:!0,writable:!0,value:n}):e[t]=n,c=(e,t)=>{for(var n in t||(t={}))oe.call(t,n)&&ne(e,n,t[n]);if(U)for(var n of U(t))re.call(t,n)&&ne(e,n,t[n]);return e},d=(e,t)=>ke(e,Te(t));var v=(e,t)=>{var n={};for(var o in e)oe.call(e,o)&&t.indexOf(o)<0&&(n[o]=e[o]);if(e!=null&&U)for(var o of U(e))t.indexOf(o)<0&&re.call(e,o)&&(n[o]=e[o]);return n};var D=(e,t,n)=>new Promise((o,i)=>{var r=l=>{try{a(n.next(l))}catch(u){i(u)}},s=l=>{try{a(n.throw(l))}catch(u){i(u)}},a=l=>l.done?o(l.value):Promise.resolve(l.value).then(r,s);a((n=n.apply(e,t)).next())});import x,{useMemo as h,useContext as ct}from"react";import B from"react";import z,{createContext as et,useContext as tt,useState as H,useMemo as xe,useCallback as S,useEffect as nt}from"react";import je,{useMemo as $e,useRef as Ke}from"react";var C=class extends Error{constructor({message:t,code:n}){super(t),this.name="CapitalOSError",this.code=n}},b={unauthorized:"unauthorized",invalid_account_status:"invalid_account_status",unsupported_entry_point:"unsupported_entry_point",internal_error:"internal_error"},A=class extends C{constructor(t){super({message:`Invalid token ${t!=null?t:""}`,code:b.unauthorized}),this.name="CapitalOSInvalidTokenError"}};import{connectToChild as Ae}from"penpal";import{useCallback as we,useEffect as J,useMemo as ae,useRef as W,useState as ce}from"react";var ie="1.2.1";function Le(e){let t=JSON.stringify(e),n=btoa(t);return encodeURIComponent(n)}function V(e){try{let t=decodeURIComponent(e),n=atob(t);return JSON.parse(n)}catch(t){throw new A}}function De(e){try{return decodeURIComponent(e)}catch(t){return e}}function se({tokenData:e,renderingContext:t,theme:n,onError:o}){try{let i=t?d(c({},t),{referer:window.location.href}):null,r=i?Le(i):null,s=new URL(e.baseUrl),a=De(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",ie),r&&s.searchParams.set("renderingContext",r),n&&s.searchParams.set("theme",n),s.toString()}catch(i){o==null||o(new A);return}}function q(e){let n=V(e).path;if(!n||typeof n!="string")throw new A;return{token:e,tokenType:"oneTime",baseUrl:n,paramKey:"token",paramLocation:"search"}}var Se=1e4;function X({iframeRef:e,token:t,onError:n,methods:o}){let[i,r]=ce(null);return J(()=>{if(!e.current)return;let s=Ae({iframe:e.current,childOrigin:"*",debug:!0,timeout:Se,methods:o});return s.promise.then(()=>{r(s)}).catch(a=>{n==null||n(a),r(null)}),()=>{s.destroy(),r(null)}},[t,e]),i}function Z({tokenData:e,renderingContext:t,theme:n,onError:o}){let i=W(o),r=W(t);return ae(()=>{if(e)return se({tokenData:e,renderingContext:r.current,theme:n,onError:i.current})},[e,n,i,r])}function j(e){let{oneTimeToken:t,enableLogging:n,onError:o,renderingContext:i,theme:r,methods:s}=e,{tokenData:a,error:l,invalidateToken:u}=G(),{log:f,warn:y}=w(n),[P,k]=ce(!1),T=W(null);Re(l,o);let E=ae(()=>t?q(t):a,[t,a]),I=we(()=>{if(f("Token expired, invalidating..."),t){o==null||o(new C({message:"Token expired. Cannot automatically refresh when using token prop.",code:b.unauthorized}));return}u(),k(!1)},[t,u,f,o]);J(()=>{t&&a&&y("token was provided both from provider and from the token prop. the prop will take precedence")},[t,a,y]);let g=Z({tokenData:E,renderingContext:i,theme:r,onError:o}),p=X({iframeRef:T,token:E==null?void 0:E.token,onError:L=>{o==null||o(L),k(!0)},methods:c({onLoad:()=>{k(!0)},onError:L=>{let ve=new C(L);o==null||o(ve)},onTokenExpired:I},s)});return{isLoaded:P,url:g,tokenData:E,iframeRef:T,connection:p}}function Re(e,t){let n=W(!1);J(()=>{e&&!n.current&&(t==null||t(e),n.current=!0)},[e,t])}import{iframeResizer as Fe}from"iframe-resizer";import ze,{forwardRef as He,useEffect as Be,useImperativeHandle as Ne,useRef as _e}from"react";var M=He((e,t)=>{let n=e.title||"iframe",{iframeHTMLAttributes:o,resizerOptions:i}=We(e),r=_e(null);return Be(()=>{let s=r.current;return Fe(c({},i),s),()=>s.iFrameResizer&&s.iFrameResizer.removeListeners()}),Ne(t,()=>r.current),ze.createElement("iframe",d(c({},o),{title:n,ref:r}))});M.displayName="IframeResizer";var Ue=["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(Ue);function We(e){return Object.keys(e).reduce((n,o)=>{let i=e[o];return qe.has(o)?i!==void 0&&(n.resizerOptions[o]=e[o]):n.iframeHTMLAttributes[o]=e[o],n},{resizerOptions:{},iframeHTMLAttributes:{}})}function de(e){let{oneTimeToken:t,enableLogging:n,onExchangeComplete:o,onExchangeError:i}=e,r=R(n),s=Ke(null),a=$e(()=>q(t),[t]),u=Z({tokenData:a,onError:i,renderingContext:{entryPoint:"tokenExchange"}});return X({iframeRef:s,token:t,onError:i,methods:{onLoad:()=>{},onError:f=>{i==null||i(new C(f))},tokenExchange:{onLongLivedToken:o}}}),je.createElement(M,{src:u,checkOrigin:!1,style:{display:"none"},log:r,ref:s})}var Q={enableLogging:!1},Y="[CapitalOS] ",$={log:(e,t=Q)=>{t.enableLogging&&console.log(`${Y}${e}`)},warn:(e,t=Q)=>{t.enableLogging&&console.warn(`${Y}${e}`)},error:(e,t=Q)=>{t.enableLogging&&console.error(`${Y}${e}`)}};import F,{createContext as Ge,useState as Qe,useMemo as ge,useCallback as Ye}from"react";import Ve from"react";import{useMemo as Je}from"react";function le(l){var u=l,{onDone:e,onCancel:t,mfaId:n,destination:o,codeLength:i,canResendAfter:r,operationName:s}=u,a=v(u,["onDone","onCancel","mfaId","destination","codeLength","canResendAfter","operationName"]);let f="mfa",y=Je(()=>({entryPoint:f,mfaId:n,destination:o,codeLength:i,canResendAfter:r,operationName:s}),[f,n,o,i,r,s]);return Ve.createElement(m,d(c({},a),{renderingContext:y,methods:{mfa:{onDone:e,onCancel:t}}}))}import pe,{useEffect as Xe}from"react";var ue={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 me({onClose:e,children:t,ariaLabel:n="Modal dialog"}){Xe(()=>{let i=r=>{r.key==="Escape"&&e()};return document.addEventListener("keydown",i),()=>{document.removeEventListener("keydown",i)}},[e]);let o=i=>{i.target===i.currentTarget&&e()};return pe.createElement("div",{style:ue.backdrop,onClick:o,role:"dialog","aria-modal":"true","aria-label":n},pe.createElement("div",{style:ue.container},t))}import{useState as Ze,useCallback as K}from"react";function fe(){var u;let[e,t]=Ze(null),{log:n}=w(),o=K(f=>(n("MFA requested"),new Promise((y,P)=>{t({context:f,resolve:y,reject:P})})),[n]),i=K(()=>{e&&(n("MFA completed successfully"),e.resolve({success:!0,canceled:!1,data:void 0}),t(null))},[e,n]),r=K(()=>{e&&(n("MFA canceled"),e.resolve({success:!1,canceled:!0}),t(null))},[e,n]),s=K(f=>{e&&(n("MFA error: "+f.message),e.resolve({success:!1,canceled:!1,error:f}),t(null))},[e,n]),a=!!e,l=(u=e==null?void 0:e.context)!=null?u:null;return{activeMfaRequest:e,isMfaActive:a,mfaContext:l,requestMfa:o,handleMfaDone:i,handleMfaCancel:r,handleMfaError:s}}var ee=Ge(null);function Ce({children:e}){let[t,n]=Qe(null),{log:o}=w(),{requestMfa:i,handleMfaDone:r,handleMfaCancel:s,isMfaActive:a,mfaContext:l}=fe(),u=Ye(g=>D(this,null,function*(){let p=yield i(g);return p.success?{success:!0}:p.canceled?{success:!1,canceled:!0}:{success:!1,error:p.error.message}}),[i]),f=ge(()=>t?{freezeCard:g=>D(this,null,function*(){try{let p=yield t.freezeCard(g);return p.success?{success:!0,canceled:!1,data:p.data}:p.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new C({code:b.internal_error,message:p.error})}}catch(p){return{success:!1,canceled:!1,error:new C({code:b.internal_error,message:p instanceof Error?p.message:"Communication error with iframe"})}}}),unfreezeCard:g=>D(this,null,function*(){try{let p=yield t.unfreezeCard(g);return p.success?{success:!0,canceled:!1,data:p.data}:p.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new C({code:b.internal_error,message:p.error})}}catch(p){return{success:!1,canceled:!1,error:new C({code:b.internal_error,message:p instanceof Error?p.message:"Communication error with iframe"})}}})}:null,[t]),y=ge(()=>({"system-messages":{requestMfa:u},mfa:{onDone:r,onCancel:s}}),[u,r,s]),{isLoaded:P,url:k,connection:T,iframeRef:E}=j({renderingContext:{entryPoint:"actions"},methods:y});F.useEffect(()=>{let g=!0;return T&&T.promise.then(p=>{g&&(n(p),o("Actions iframe child functions loaded"))}),()=>{g=!1}},[T,o]);let I=!P||!t;return F.createElement(ee.Provider,{value:{childFunctions:t,actions:f,isLoading:I}},e,k&&F.createElement(M,{src:k,style:{display:"none"},checkOrigin:!1,ref:E}),a&&l&&F.createElement(me,{onClose:s,ariaLabel:"Multi-factor authentication"},F.createElement(le,d(c({mfaId:l.mfaId,destination:l.destination,codeLength:l.codeLength,canResendAfter:l.canResendAfter},l.operationName&&{operationName:l.operationName}),{onDone:r,onCancel:s}))))}var he=et({isLoading:!1,invalidateToken:()=>{},enableLogging:!1}),ot=({getToken:e,enableLogging:t,children:n})=>{let[o,i]=H(void 0),[r,s]=H(void 0),[a,l]=H(void 0),[u,f]=H(!1),[y,P]=H(void 0),k=S(()=>D(void 0,null,function*(){f(!0);try{let g=yield e();i(g),P(void 0);let p=V(g),L=new URL(p.path);L.pathname="",s(L.toString())}catch(g){P(g)}finally{f(!1)}}),[e]),T=S(()=>{l(void 0)},[]);nt(()=>{a||k()},[a,k]);let E=S(g=>{l(g),i(void 0),P(void 0)},[]),I=xe(()=>{if(a&&!r)throw new C({message:"baseUrl is required for long lived tokens",code:b.unauthorized});return{tokenData:a?{token:a,tokenType:"longLived",baseUrl:r,paramKey:"access_token",paramLocation:"hash"}:void 0,isLoading:u,error:y,invalidateToken:T,enableLogging:t!=null?t:!1}},[a,u,y,T,r,t]);return z.createElement(z.Fragment,null,z.createElement(he.Provider,{value:I},z.createElement(Ce,null,n)),o&&!a&&z.createElement(de,{oneTimeToken:o,onExchangeComplete:E,enableLogging:t,onExchangeError:P}))},G=()=>tt(he);function R(e){let{enableLogging:t}=G();return e!==void 0?e:t}function w(e){let t=R(e),n=S(r=>{$.log(r,{enableLogging:t})},[t]),o=S(r=>{$.warn(r,{enableLogging:t})},[t]),i=S(r=>{$.error(r,{enableLogging:t})},[t]);return xe(()=>({log:n,warn:o,error:i}),[n,o,i])}function m(e){let{token:t,className:n,enableLogging:o,onError:i,loadingComponent:r,renderingContext:s,methods:a,theme:l,sizeWidth:u}=e,f=R(o),{isLoaded:y,url:P,tokenData:k,iframeRef:T}=j({oneTimeToken:t,enableLogging:f,onError:i,renderingContext:s,theme:l,methods:a});if(!k||!P)return B.createElement(B.Fragment,null,r||null);let E=s.entryPoint!=="insightsWidget";return B.createElement(B.Fragment,null,!y&&r,B.createElement(M,{src:P,allow:"clipboard-write",checkOrigin:!1,style:{width:"1px",height:"0px",minWidth:"100%"},className:n,log:f,ref:T,hidden:!y,onResized:I=>{if(!E)return;let g=`${parseInt(I.height)+12}px`;I.iframe.style.height=g},sizeWidth:u}))}import _,{useMemo as rt}from"react";import{useState as it}from"react";import O,{useState as ye}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"}},Pe=()=>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:t=!1}){let[n,o]=ye(!1),[i,r]=ye(!1),s=c(c(c(c({},N.bugButton),t&&N.loadingButton),!t&&n&&N.bugButtonHover),!t&&i&&N.bugButtonFocus);return t?O.createElement("div",{style:s},O.createElement("style",null,`
|
|
1
|
+
"use client";var be=Object.defineProperty,ke=Object.defineProperties;var Te=Object.getOwnPropertyDescriptors;var U=Object.getOwnPropertySymbols;var te=Object.prototype.hasOwnProperty,re=Object.prototype.propertyIsEnumerable;var oe=(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={}))te.call(n,o)&&oe(e,o,n[o]);if(U)for(var o of U(n))re.call(n,o)&&oe(e,o,n[o]);return e},d=(e,n)=>ke(e,Te(n));var h=(e,n)=>{var o={};for(var t in e)te.call(e,t)&&n.indexOf(t)<0&&(o[t]=e[t]);if(e!=null&&U)for(var t of U(e))n.indexOf(t)<0&&re.call(e,t)&&(o[t]=e[t]);return o};var L=(e,n,o)=>new Promise((t,r)=>{var i=l=>{try{a(o.next(l))}catch(m){r(m)}},s=l=>{try{a(o.throw(l))}catch(m){r(m)}},a=l=>l.done?t(l.value):Promise.resolve(l.value).then(i,s);a((o=o.apply(e,n)).next())});import f,{useMemo as g,useContext as dn}from"react";import B from"react";import z,{createContext as en,useContext as nn,useState as H,useMemo as xe,useCallback as S,useEffect as on}from"react";import je,{useMemo as Ve,useRef as $e}from"react";var y=class extends Error{constructor({message:n,code:o}){super(n),this.name="CapitalOSError",this.code=o}},b={unauthorized:"unauthorized",invalid_account_status:"invalid_account_status",unsupported_entry_point:"unsupported_entry_point",internal_error:"internal_error"},D=class extends y{constructor(n){super({message:`Invalid token ${n!=null?n:""}`,code:b.unauthorized}),this.name="CapitalOSInvalidTokenError"}};import{connectToChild as De}from"penpal";import{useCallback as we,useEffect as J,useMemo as ae,useRef as W,useState as ce}from"react";var ie="1.3.0";function Ae(e){let n=JSON.stringify(e),o=btoa(n);return encodeURIComponent(o)}function K(e){try{let n=decodeURIComponent(e),o=atob(n);return JSON.parse(o)}catch(n){throw new D}}function Le(e){try{return decodeURIComponent(e)}catch(n){return e}}function se({tokenData:e,renderingContext:n,theme:o,onError:t}){try{let r=n?d(c({},n),{referer:window.location.href}):null,i=r?Ae(r):null,s=new URL(e.baseUrl),a=Le(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",ie),i&&s.searchParams.set("renderingContext",i),o&&s.searchParams.set("theme",o),s.toString()}catch(r){t==null||t(new D);return}}function q(e){let o=K(e).path;if(!o||typeof o!="string")throw new D;return{token:e,tokenType:"oneTime",baseUrl:o,paramKey:"token",paramLocation:"search"}}var Se=1e4;function X({iframeRef:e,token:n,onError:o,methods:t}){let[r,i]=ce(null);return J(()=>{if(!e.current)return;let s=De({iframe:e.current,childOrigin:"*",debug:!0,timeout:Se,methods:t});return s.promise.then(()=>{i(s)}).catch(a=>{o==null||o(a),i(null)}),()=>{s.destroy(),i(null)}},[n,e]),r}function Z({tokenData:e,renderingContext:n,theme:o,onError:t}){let r=W(t),i=W(n);return ae(()=>{if(e)return se({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:l,invalidateToken:m}=G(),{log:C,warn:P}=w(o),[v,k]=ce(!1),T=W(null);Re(l,t);let E=ae(()=>n?q(n):a,[n,a]),I=we(()=>{if(C("Token expired, invalidating..."),n){t==null||t(new y({message:"Token expired. Cannot automatically refresh when using token prop.",code:b.unauthorized}));return}m(),k(!1)},[n,m,C,t]);J(()=>{n&&a&&P("token was provided both from provider and from the token prop. the prop will take precedence")},[n,a,P]);let x=Z({tokenData:E,renderingContext:r,theme:i,onError:t}),u=X({iframeRef:T,token:E==null?void 0:E.token,onError:A=>{t==null||t(A),k(!0)},methods:c({onLoad:()=>{k(!0)},onError:A=>{let ve=new y(A);t==null||t(ve)},onTokenExpired:I},s)});return{isLoaded:v,url:x,tokenData:E,iframeRef:T,connection:u}}function Re(e,n){let o=W(!1);J(()=>{e&&!o.current&&(n==null||n(e),o.current=!0)},[e,n])}import{iframeResizer as Fe}from"iframe-resizer";import ze,{forwardRef as He,useEffect as Be,useImperativeHandle as Ne,useRef as _e}from"react";var M=He((e,n)=>{let o=e.title||"iframe",{iframeHTMLAttributes:t,resizerOptions:r}=We(e),i=_e(null);return Be(()=>{let s=i.current;return Fe(c({},r),s),()=>s.iFrameResizer&&s.iFrameResizer.removeListeners()}),Ne(n,()=>i.current),ze.createElement("iframe",d(c({},t),{title:o,ref:i}))});M.displayName="IframeResizer";var Ue=["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(Ue);function We(e){return Object.keys(e).reduce((o,t)=>{let r=e[t];return qe.has(t)?r!==void 0&&(o.resizerOptions[t]=e[t]):o.iframeHTMLAttributes[t]=e[t],o},{resizerOptions:{},iframeHTMLAttributes:{}})}function de(e){let{oneTimeToken:n,enableLogging:o,onExchangeComplete:t,onExchangeError:r}=e,i=R(o),s=$e(null),a=Ve(()=>q(n),[n]),m=Z({tokenData:a,onError:r,renderingContext:{entryPoint:"tokenExchange"}});return X({iframeRef:s,token:n,onError:r,methods:{onLoad:()=>{},onError:C=>{r==null||r(new y(C))},tokenExchange:{onLongLivedToken:t}}}),je.createElement(M,{src:m,checkOrigin:!1,style:{display:"none"},log:i,ref:s})}var Q={enableLogging:!1},Y="[CapitalOS] ",V={log:(e,n=Q)=>{n.enableLogging&&console.log(`${Y}${e}`)},warn:(e,n=Q)=>{n.enableLogging&&console.warn(`${Y}${e}`)},error:(e,n=Q)=>{n.enableLogging&&console.error(`${Y}${e}`)}};import F,{createContext as Ge,useState as Qe,useMemo as ge,useCallback as Ye}from"react";import Ke from"react";import{useMemo as Je}from"react";function le(l){var m=l,{onDone:e,onCancel:n,mfaId:o,destination:t,codeLength:r,canResendAfter:i,operationName:s}=m,a=h(m,["onDone","onCancel","mfaId","destination","codeLength","canResendAfter","operationName"]);let C="mfa",P=Je(()=>({entryPoint:C,mfaId:o,destination:t,codeLength:r,canResendAfter:i,operationName:s}),[C,o,t,r,i,s]);return Ke.createElement(p,d(c({},a),{renderingContext:P,methods:{mfa:{onDone:e,onCancel:n}}}))}import pe,{useEffect as Xe}from"react";var ue={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 me({onClose:e,children:n,ariaLabel:o="Modal dialog"}){Xe(()=>{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 pe.createElement("div",{style:ue.backdrop,onClick:t,role:"dialog","aria-modal":"true","aria-label":o},pe.createElement("div",{style:ue.container},n))}import{useState as Ze,useCallback as $}from"react";function fe(){var m;let[e,n]=Ze(null),{log:o}=w(),t=$(C=>(o("MFA requested"),new Promise((P,v)=>{n({context:C,resolve:P,reject:v})})),[o]),r=$(()=>{e&&(o("MFA completed successfully"),e.resolve({success:!0,canceled:!1,data:void 0}),n(null))},[e,o]),i=$(()=>{e&&(o("MFA canceled"),e.resolve({success:!1,canceled:!0}),n(null))},[e,o]),s=$(C=>{e&&(o("MFA error: "+C.message),e.resolve({success:!1,canceled:!1,error:C}),n(null))},[e,o]),a=!!e,l=(m=e==null?void 0:e.context)!=null?m:null;return{activeMfaRequest:e,isMfaActive:a,mfaContext:l,requestMfa:t,handleMfaDone:r,handleMfaCancel:i,handleMfaError:s}}var ee=Ge(null);function Ce({children:e}){let[n,o]=Qe(null),{log:t}=w(),{requestMfa:r,handleMfaDone:i,handleMfaCancel:s,isMfaActive:a,mfaContext:l}=fe(),m=Ye(x=>L(this,null,function*(){let u=yield r(x);return u.success?{success:!0}:u.canceled?{success:!1,canceled:!0}:{success:!1,error:u.error.message}}),[r]),C=ge(()=>n?{freezeCard:x=>L(this,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 y({code:b.internal_error,message:u.error})}}catch(u){return{success:!1,canceled:!1,error:new y({code:b.internal_error,message:u instanceof Error?u.message:"Communication error with iframe"})}}}),unfreezeCard:x=>L(this,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 y({code:b.internal_error,message:u.error})}}catch(u){return{success:!1,canceled:!1,error:new y({code:b.internal_error,message:u instanceof Error?u.message:"Communication error with iframe"})}}})}:null,[n]),P=ge(()=>({"system-messages":{requestMfa:m},mfa:{onDone:i,onCancel:s}}),[m,i,s]),{isLoaded:v,url:k,connection:T,iframeRef:E}=j({renderingContext:{entryPoint:"actions"},methods:P});F.useEffect(()=>{let x=!0;return T&&T.promise.then(u=>{x&&(o(u),t("Actions iframe child functions loaded"))}),()=>{x=!1}},[T,t]);let I=!v||!n;return F.createElement(ee.Provider,{value:{childFunctions:n,actions:C,isLoading:I}},e,k&&F.createElement(M,{src:k,style:{display:"none"},checkOrigin:!1,ref:E}),a&&l&&F.createElement(me,{onClose:s,ariaLabel:"Multi-factor authentication"},F.createElement(le,d(c({mfaId:l.mfaId,destination:l.destination,codeLength:l.codeLength,canResendAfter:l.canResendAfter},l.operationName&&{operationName:l.operationName}),{onDone:i,onCancel:s}))))}var he=en({isLoading:!1,invalidateToken:()=>{},enableLogging:!1}),tn=({getToken:e,enableLogging:n,children:o})=>{let[t,r]=H(void 0),[i,s]=H(void 0),[a,l]=H(void 0),[m,C]=H(!1),[P,v]=H(void 0),k=S(()=>L(void 0,null,function*(){C(!0);try{let x=yield e();r(x),v(void 0);let u=K(x),A=new URL(u.path);A.pathname="",s(A.toString())}catch(x){v(x)}finally{C(!1)}}),[e]),T=S(()=>{l(void 0)},[]);on(()=>{a||k()},[a,k]);let E=S(x=>{l(x),r(void 0),v(void 0)},[]),I=xe(()=>{if(a&&!i)throw new y({message:"baseUrl is required for long lived tokens",code:b.unauthorized});return{tokenData:a?{token:a,tokenType:"longLived",baseUrl:i,paramKey:"access_token",paramLocation:"hash"}:void 0,isLoading:m,error:P,invalidateToken:T,enableLogging:n!=null?n:!1}},[a,m,P,T,i,n]);return z.createElement(z.Fragment,null,z.createElement(he.Provider,{value:I},z.createElement(Ce,null,o)),t&&!a&&z.createElement(de,{oneTimeToken:t,onExchangeComplete:E,enableLogging:n,onExchangeError:v}))},G=()=>nn(he);function R(e){let{enableLogging:n}=G();return e!==void 0?e:n}function w(e){let n=R(e),o=S(i=>{V.log(i,{enableLogging:n})},[n]),t=S(i=>{V.warn(i,{enableLogging:n})},[n]),r=S(i=>{V.error(i,{enableLogging:n})},[n]);return xe(()=>({log:o,warn:t,error:r}),[o,t,r])}function p(e){let{token:n,className:o,enableLogging:t,onError:r,loadingComponent:i,renderingContext:s,methods:a,theme:l,sizeWidth:m}=e,C=R(t),{isLoaded:P,url:v,tokenData:k,iframeRef:T}=j({oneTimeToken:n,enableLogging:C,onError:r,renderingContext:s,theme:l,methods:a});if(!k||!v)return B.createElement(B.Fragment,null,i||null);let E=s.entryPoint!=="insightsWidget";return B.createElement(B.Fragment,null,!P&&i,B.createElement(M,{src:v,allow:"clipboard-write",checkOrigin:!1,style:{width:"1px",height:"0px",minWidth:"100%"},className:o,log:C,ref:T,hidden:!P,onResized:I=>{if(!E)return;let x=`${parseInt(I.height)+12}px`;I.iframe.style.height=x},sizeWidth:m}))}import _,{useMemo as rn}from"react";import{useState as sn}from"react";import O,{useState as ye}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"}},Pe=()=>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 ne({onClick:e,isLoading:n=!1}){let[o,t]=ye(!1),[r,i]=ye(!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,`
|
|
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
|
-
`),O.createElement(Pe,null)):O.createElement("button",{id:"dev-tools-button",onClick:e,type:"button",style:s,onMouseEnter:()=>
|
|
10
|
+
`),O.createElement(Pe,null)):O.createElement("button",{id:"dev-tools-button",onClick:e,type:"button",style:s,onMouseEnter:()=>t(!0),onMouseLeave:()=>t(!1),onFocus:()=>i(!0),onBlur:()=>i(!1)},O.createElement(Pe,null))}var an={panel:{position:"fixed",bottom:"20px",left:"20px",zIndex:50}};function cn(e){let n="devTools",o=rn(()=>({entryPoint:n}),[n]),[t,r]=sn(!1);return _.createElement("aside",{"aria-label":"CapitalOS dev tools"},!t&&_.createElement(ne,{onClick:()=>r(!t)}),t&&_.createElement("div",{style:an.panel},_.createElement(p,d(c({},e),{renderingContext:o,methods:{devTools:{onClose:()=>r(!1)}},enableLogging:!0,sizeWidth:!0,loadingComponent:_.createElement(ne,{isLoading:!0})}))))}function ln(e){let n="cardsApp",o=g(()=>({entryPoint:n}),[n]);return f.createElement(p,d(c({},e),{renderingContext:o}))}var Zo=ln;function Go(r){var i=r,{cardholder:e,onDone:n,onCancel:o}=i,t=h(i,["cardholder","onDone","onCancel"]);let s="createCard",a=g(()=>({entryPoint:s,cardholder:e}),[e]);return f.createElement(p,d(c({},t),{renderingContext:a,methods:{createCard:{onDone:n,onCancel:o}}}))}function Qo(r){var i=r,{transactionId:e,onDone:n,onCancel:o}=i,t=h(i,["transactionId","onDone","onCancel"]);let s="createDispute",a=g(()=>({entryPoint:s,transactionId:e}),[e]);return f.createElement(p,d(c({},t),{renderingContext:a,methods:{createDispute:{onDone:n,onCancel:o}}}))}function Yo(e){let n="billPayApp",o=g(()=>({entryPoint:n}),[n]);return f.createElement(p,d(c({},e),{renderingContext:o}))}function et(e){let s=e,{onCardCanceled:n,onHideSensitiveDetails:o}=s,t=h(s,["onCardCanceled","onHideSensitiveDetails"]),r="cardDetails",i=g(()=>({entryPoint:r,cardId:e.cardId,cardOnly:e.cardOnly,backOnly:e.backOnly,hideAddress:e.hideAddress}),[r,e.cardId,e.cardOnly,e.backOnly,e.hideAddress]);return f.createElement(p,d(c({},t),{renderingContext:i,methods:{cardDetails:{onCardCanceled:n!=null?n:()=>{},onHideSensitiveDetails:o!=null?o:()=>{}}}}))}function nt(e){let n="accountDetails",o=g(()=>({entryPoint:n}),[n]);return f.createElement(p,d(c({},e),{renderingContext:o}))}function ot(e){let n="accountActions",o=g(()=>({entryPoint:n}),[n]);return f.createElement(p,d(c({},e),{renderingContext:o}))}function tt(t){var r=t,{onDone:e,onCancel:n}=r,o=h(r,["onDone","onCancel"]);let i="manageBankConnections",s=g(()=>({entryPoint:i}),[i]);return f.createElement(p,d(c({},o),{renderingContext:s,methods:{manageBankConnections:{onDone:e,onCancel:n}}}))}function rt(o){var t=o,{onClose:e}=t,n=h(t,["onClose"]);let r="configureAutoPay",i=g(()=>({entryPoint:r}),[r]);return f.createElement(p,d(c({},n),{renderingContext:i,methods:{configureAutoPay:{onClose:e}}}))}function it(o){var t=o,{onClose:e}=t,n=h(t,["onClose"]);let r="policySettings",i=g(()=>({entryPoint:r}),[r]);return f.createElement(p,d(c({},n),{renderingContext:i,methods:{policySettings:{onClose:e}}}))}function st(t){var r=t,{cardId:e,onClose:n}=r,o=h(r,["cardId","onClose"]);let i="connectToVendors",s=g(()=>({entryPoint:i,cardId:e}),[i,e]);return f.createElement(p,d(c({},o),{renderingContext:s,methods:{connectToVendors:{onClose:n}}}))}function at(e){let n="insightsDashboard",o=g(()=>({entryPoint:n}),[n]);return f.createElement(p,d(c({},e),{renderingContext:o}))}function ct(e){let n="insightsWidget",{widget:o,hideTitle:t,height:r,width:i}=e,s=g(()=>({entryPoint:n,widget:o,hideTitle:t,height:r,width:i}),[n,o,t,r,i]);return f.createElement(p,d(c({},e),{renderingContext:s}))}function dt(r){var i=r,{onDone:e,entryPoint:n,exitPoint:o}=i,t=h(i,["onDone","entryPoint","exitPoint"]);let s="onboarding",a=g(()=>({entryPoint:s,onboardingEntryPoint:n,onboardingExitPoint:o}),[s,n,o]);return f.createElement(p,d(c({},t),{renderingContext:a,methods:{onboarding:{onDone:e}}}))}function lt(o){var t=o,{onDone:e}=t,n=h(t,["onDone"]);let r="makePayment",i=g(()=>({entryPoint:r}),[r]);return f.createElement(p,d(c({},n),{renderingContext:i,methods:{makePayment:{onDone:e}}}))}function pt(t){var r=t,{onDone:e,onCancel:n}=r,o=h(r,["onDone","onCancel"]);let i="contactSupport",s=g(()=>({entryPoint:i}),[i]);return f.createElement(p,d(c({},o),{renderingContext:s,methods:{contactSupport:{onDone:e,onCancel:n}}}))}function ut(o){var t=o,{onDone:e}=t,n=h(t,["onDone"]);let r="statements",i=g(()=>({entryPoint:r}),[r]);return f.createElement(p,d(c({},n),{renderingContext:i,methods:{statements:{onDone:e}}}))}function mt(o){var t=o,{onDone:e}=t,n=h(t,["onDone"]);let r="legalDocuments",i=g(()=>({entryPoint:r}),[r]);return f.createElement(p,d(c({},n),{renderingContext:i,methods:{legalDocuments:{onDone:e}}}))}function ft(r){var i=r,{cardId:e,onDone:n,onClose:o}=i,t=h(i,["cardId","onDone","onClose"]);let s="replaceCard",a=g(()=>({entryPoint:s,cardId:e}),[e]);return f.createElement(p,d(c({},t),{renderingContext:a,methods:{replaceCard:{onDone:n,onClose:o}}}))}function gt(r){var i=r,{cardId:e,onDone:n,onClose:o}=i,t=h(i,["cardId","onDone","onClose"]);let s="terminateCard",a=g(()=>({entryPoint:s,cardId:e}),[e]);return f.createElement(p,d(c({},t),{renderingContext:a,methods:{terminateCard:{onDone:n,onClose:o}}}))}function Ct(e){let n="transactions",o=g(()=>({entryPoint:n}),[n]);return f.createElement(p,d(c({},e),{renderingContext:o}))}function xt(){let e=dn(ee);if(!e)throw new y({message:"useActions must be used within a CapitalOsAuthenticationProvider",code:b.internal_error});let{childFunctions:n,isLoading:o}=e;return{actions:n,isLoading:o}}export{ot as AccountActions,nt as AccountDetails,Zo as App,Yo as BillPayApp,tn as CapitalOsAuthenticationProvider,et as CardDetails,ln as CardsApp,rt as ConfigureAutoPay,st as ConnectToVendors,pt as ContactSupport,cn as DevTools,Qo as DisputeTransaction,at as InsightsDashboard,ct as InsightsWidget,Go as IssueCard,mt as LegalDocuments,lt as MakePayment,tt as ManageBankConnections,dt as Onboarding,it as PolicySettings,ft as ReplaceCard,ut as Statements,gt as TerminateCard,Ct as Transactions,xt as useActions};
|
|
11
11
|
//# sourceMappingURL=index.js.map
|