@capitalos/react 1.4.5-rc.2 → 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 +58 -9
- package/dist/_tsup-dts-rollup.d.ts +58 -9
- 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
|
@@ -672,6 +672,13 @@ export declare type ContactSupportProps = CommonProps & {
|
|
|
672
672
|
|
|
673
673
|
export declare function decodeOneTimeToken(token: string): any;
|
|
674
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
|
+
|
|
675
682
|
/**
|
|
676
683
|
* Renders the CapitalOS Dev Tools experience.
|
|
677
684
|
* Allows for simulating transactions, etc.
|
|
@@ -787,7 +794,7 @@ export declare class InvalidTokenError extends CapitalOSError {
|
|
|
787
794
|
/**
|
|
788
795
|
* Renders the CapitalOS Issue Card experience.
|
|
789
796
|
*/
|
|
790
|
-
export declare function IssueCard({ cardholder, onDone, onCancel, ...restOfProps }: IssueCardProps): JSX.Element;
|
|
797
|
+
export declare function IssueCard({ cardholder, onCreate, onDone, onCancel, ...restOfProps }: IssueCardProps): JSX.Element;
|
|
791
798
|
|
|
792
799
|
export declare type IssueCardDefaultValues = z.infer<typeof issueCardDefaultValuesSchema>;
|
|
793
800
|
|
|
@@ -819,20 +826,57 @@ export declare type IssueCardProps = CommonProps & {
|
|
|
819
826
|
*/
|
|
820
827
|
cardholder?: IssueCardDefaultValues;
|
|
821
828
|
/**
|
|
822
|
-
* 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.
|
|
823
839
|
*
|
|
824
840
|
* @param result - Object containing the created card's ID
|
|
825
|
-
* @param result.cardId - The ID of the newly created card
|
|
826
841
|
*/
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
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;
|
|
830
854
|
/**
|
|
831
855
|
* Callback to invoke when the card creation was cancelled by the user.
|
|
832
856
|
*/
|
|
833
857
|
onCancel: () => void;
|
|
834
858
|
};
|
|
835
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
|
+
|
|
836
880
|
export declare function LegalDocuments({ onDone, ...restOfProps }: LegalDocumentsProps): JSX.Element;
|
|
837
881
|
|
|
838
882
|
export declare type LegalDocumentsProps = CommonProps & {
|
|
@@ -995,9 +1039,8 @@ export declare type ParentFunctions = {
|
|
|
995
1039
|
onCancel?: () => void;
|
|
996
1040
|
};
|
|
997
1041
|
createCard?: {
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
}) => void;
|
|
1042
|
+
onCreate?: (result: IssueCardResult_alias_1) => void;
|
|
1043
|
+
onDone?: (result: IssueCardResult_alias_1) => void;
|
|
1001
1044
|
onCancel?: () => void;
|
|
1002
1045
|
};
|
|
1003
1046
|
createDispute?: {
|
|
@@ -1150,6 +1193,12 @@ declare const renderingContextSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<
|
|
|
1150
1193
|
entryPoint: "billPayApp";
|
|
1151
1194
|
}, {
|
|
1152
1195
|
entryPoint: "billPayApp";
|
|
1196
|
+
}>, z.ZodObject<{
|
|
1197
|
+
entryPoint: z.ZodLiteral<"demoBillPayApp">;
|
|
1198
|
+
}, "strip", z.ZodTypeAny, {
|
|
1199
|
+
entryPoint: "demoBillPayApp";
|
|
1200
|
+
}, {
|
|
1201
|
+
entryPoint: "demoBillPayApp";
|
|
1153
1202
|
}>, z.ZodObject<{
|
|
1154
1203
|
entryPoint: z.ZodLiteral<"cardDetails">;
|
|
1155
1204
|
cardId: z.ZodString;
|
|
@@ -672,6 +672,13 @@ export declare type ContactSupportProps = CommonProps & {
|
|
|
672
672
|
|
|
673
673
|
export declare function decodeOneTimeToken(token: string): any;
|
|
674
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
|
+
|
|
675
682
|
/**
|
|
676
683
|
* Renders the CapitalOS Dev Tools experience.
|
|
677
684
|
* Allows for simulating transactions, etc.
|
|
@@ -787,7 +794,7 @@ export declare class InvalidTokenError extends CapitalOSError {
|
|
|
787
794
|
/**
|
|
788
795
|
* Renders the CapitalOS Issue Card experience.
|
|
789
796
|
*/
|
|
790
|
-
export declare function IssueCard({ cardholder, onDone, onCancel, ...restOfProps }: IssueCardProps): JSX.Element;
|
|
797
|
+
export declare function IssueCard({ cardholder, onCreate, onDone, onCancel, ...restOfProps }: IssueCardProps): JSX.Element;
|
|
791
798
|
|
|
792
799
|
export declare type IssueCardDefaultValues = z.infer<typeof issueCardDefaultValuesSchema>;
|
|
793
800
|
|
|
@@ -819,20 +826,57 @@ export declare type IssueCardProps = CommonProps & {
|
|
|
819
826
|
*/
|
|
820
827
|
cardholder?: IssueCardDefaultValues;
|
|
821
828
|
/**
|
|
822
|
-
* 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.
|
|
823
839
|
*
|
|
824
840
|
* @param result - Object containing the created card's ID
|
|
825
|
-
* @param result.cardId - The ID of the newly created card
|
|
826
841
|
*/
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
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;
|
|
830
854
|
/**
|
|
831
855
|
* Callback to invoke when the card creation was cancelled by the user.
|
|
832
856
|
*/
|
|
833
857
|
onCancel: () => void;
|
|
834
858
|
};
|
|
835
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
|
+
|
|
836
880
|
export declare function LegalDocuments({ onDone, ...restOfProps }: LegalDocumentsProps): JSX.Element;
|
|
837
881
|
|
|
838
882
|
export declare type LegalDocumentsProps = CommonProps & {
|
|
@@ -995,9 +1039,8 @@ export declare type ParentFunctions = {
|
|
|
995
1039
|
onCancel?: () => void;
|
|
996
1040
|
};
|
|
997
1041
|
createCard?: {
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
}) => void;
|
|
1042
|
+
onCreate?: (result: IssueCardResult_alias_1) => void;
|
|
1043
|
+
onDone?: (result: IssueCardResult_alias_1) => void;
|
|
1001
1044
|
onCancel?: () => void;
|
|
1002
1045
|
};
|
|
1003
1046
|
createDispute?: {
|
|
@@ -1150,6 +1193,12 @@ declare const renderingContextSchema: z.ZodIntersection<z.ZodDiscriminatedUnion<
|
|
|
1150
1193
|
entryPoint: "billPayApp";
|
|
1151
1194
|
}, {
|
|
1152
1195
|
entryPoint: "billPayApp";
|
|
1196
|
+
}>, z.ZodObject<{
|
|
1197
|
+
entryPoint: z.ZodLiteral<"demoBillPayApp">;
|
|
1198
|
+
}, "strip", z.ZodTypeAny, {
|
|
1199
|
+
entryPoint: "demoBillPayApp";
|
|
1200
|
+
}, {
|
|
1201
|
+
entryPoint: "demoBillPayApp";
|
|
1153
1202
|
}>, z.ZodObject<{
|
|
1154
1203
|
entryPoint: z.ZodLiteral<"cardDetails">;
|
|
1155
1204
|
cardId: z.ZodString;
|
package/dist/esm/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
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=f=>{try{a(t.next(f))}catch(m){r(m)}},s=f=>{try{a(t.throw(f))}catch(m){r(m)}},a=f=>f.done?o(f.value):Promise.resolve(f.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 we}from"react";function R(e){let n=we(e);return n.current=e,n}var Ae={enableLogging:!1},Se="[CapitalOS] ";function Q(e){return(n,t=Ae)=>{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 ue="1.4.5-rc.2";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 pe({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",ue),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(),f=R(o),m=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:f.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=m.current)==null||T.call(m,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 pe({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:f,invalidateToken:m}=X(),{log:d,warn:u}=M(t),[y,P]=fe(!1),E=K(null);We(f,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}m(),P(!1)},[d,n,m,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 w=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}))});w.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=A(t),{log:s}=M(t),a=nn(null),f=en(()=>V(n),[n]),d=oe({tokenData:f,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(w,{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 un,useMemo as ke,useCallback as pn}from"react";import sn from"react";import{useMemo as an}from"react";function Ce(f){var m=f,{onDone:e,onCancel:n,mfaId:t,destination:o,codeLength:r,canResendAfter:i,operationName:s}=m,a=k(m,["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 m;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,f=(m=e==null?void 0:e.context)!=null?m:null;return{activeMfaRequest:e,isMfaActive:a,mfaContext:f,requestMfa:o,handleMfaDone:r,handleMfaCancel:i,handleMfaError:s}}var re=ln(null);function be({children:e}){let[n,t]=un(null),o=A(),{log:r}=M(),{requestMfa:i,handleMfaDone:s,handleMfaCancel:a,isMfaActive:f,mfaContext:m}=Pe(),d=pn(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(w,{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.`)}}),f&&m&&z.createElement(ye,{onClose:a,ariaLabel:"Multi-factor authentication"},z.createElement(Ce,p(c({mfaId:m.mfaId,destination:m.destination,codeLength:m.codeLength,canResendAfter:m.canResendAfter},m.operationName&&{operationName:m.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),[f,m]=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(()=>{m(void 0)},[]);gn(()=>{f||g()},[f,g]);let T=ie(l=>{m(l),i(void 0),P(void 0)},[]),v=Te(()=>{if(f&&!s)throw new b({message:"baseUrl is required for long lived tokens",code:L.unauthorized});return{tokenData:f?{token:f,tokenType:"longLived",baseUrl:s,paramKey:"access_token",paramLocation:"hash"}:void 0,isLoading:d,error:y,invalidateToken:I,enableLogging:n!=null?n:!1,loggerRef:E}},[f,d,y,I,s,n]);return $.createElement($.Fragment,null,$.createElement(ve.Provider,{value:v},$.createElement(be,null,o)),r&&!f&&$.createElement(ge,{oneTimeToken:r,onExchangeComplete:T,enableLogging:n,onExchangeError:P}))},X=()=>fn(ve);function A(e){let{enableLogging:n}=X();return e!==void 0?e:n}function M(e){let n=A(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:f,sizeWidth:m}=e,d=A(o),{log:u}=M(o),{isLoaded:y,url:P,tokenData:E,iframeRef:g}=J({oneTimeToken:n,enableLogging:d,onError:r,renderingContext:s,theme:f,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(w,{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:m}))}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,`
|
|
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
|
-
`),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(
|
|
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
|