@capitalos/react 1.4.5-rc.1 → 1.4.5-rc.2

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.
@@ -4,6 +4,7 @@ import { IFrameMessageData } from 'iframe-resizer';
4
4
  import { IFrameOptions } from 'iframe-resizer';
5
5
  import { IFrameResizedData } from 'iframe-resizer';
6
6
  import { IFrameScrollData } from 'iframe-resizer';
7
+ import { MutableRefObject } from 'react';
7
8
  import { default as React_2 } from 'react';
8
9
  import { ReactNode } from 'react';
9
10
  import { RefObject } from 'react';
@@ -107,8 +108,9 @@ declare type CapitalOsAuthenticationContextType = {
107
108
  enableLogging: boolean;
108
109
  /**
109
110
  * Optional logger for capturing all SDK logs including Penpal.
111
+ * Stored in a ref to avoid unnecessary re-renders when logger changes.
110
112
  */
111
- logger?: Logger | undefined;
113
+ loggerRef: React_2.RefObject<Logger | undefined>;
112
114
  };
113
115
 
114
116
  declare const CapitalOsAuthenticationProvider: React_2.FC<ProviderProps>;
@@ -1081,10 +1083,16 @@ export declare type RawErrorDetails = {
1081
1083
  };
1082
1084
 
1083
1085
  /**
1084
- * Redacts token values from a string, keeping first 4 and last 4 characters for debugging
1086
+ * Redacts a string value, keeping first 4 and last 4 characters for debugging
1087
+ * Safe to use - handles undefined/null and short strings gracefully
1088
+ */
1089
+ export declare function redactString(value: string | undefined | null): string;
1090
+
1091
+ /**
1092
+ * Redacts token values from a url string, keeping first 4 and last 4 characters for debugging
1085
1093
  * Safe to use - will not throw even with malformed input
1086
1094
  */
1087
- export declare function redactToken(str: string): string;
1095
+ export declare function redactTokenFromUrl(str: string): string;
1088
1096
 
1089
1097
  declare type RenderingContext_2 = z.infer<typeof renderingContextSchema>;
1090
1098
 
@@ -1459,6 +1467,18 @@ export declare const useCapitalOsAuthContext: () => CapitalOsAuthenticationConte
1459
1467
  */
1460
1468
  export declare function useEnableLogging(enableLoggingProp?: boolean): boolean;
1461
1469
 
1470
+ /**
1471
+ * Creates a stable callback that always calls the latest version of the provided function.
1472
+ * This is useful for event handlers and callbacks that need to be in dependency arrays
1473
+ * but shouldn't trigger effect re-fires when they change.
1474
+ *
1475
+ * Based on the useEvent RFC (that made it into React 19.2): https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md
1476
+ *
1477
+ * @param fn The function to wrap
1478
+ * @returns A stable callback that always calls the latest version of fn
1479
+ */
1480
+ export declare function useEvent<T extends (...args: any[]) => any>(fn: T): T;
1481
+
1462
1482
  /**
1463
1483
  * A React hook that manages the iframe connection lifecycle, including:
1464
1484
  * - Establishing and maintaining the iframe connection
@@ -1504,8 +1524,18 @@ export declare function useIframeUrl({ tokenData, renderingContext, theme, onErr
1504
1524
  onError?: ((error: Error) => void) | undefined;
1505
1525
  }): string | undefined;
1506
1526
 
1527
+ /**
1528
+ * Returns a ref that always contains the latest value.
1529
+ * Useful for accessing the current value of props/state in callbacks without causing re-renders.
1530
+ *
1531
+ * @param value The value to track
1532
+ * @returns A ref containing the latest value
1533
+ */
1534
+ export declare function useLatest<T>(value: T): MutableRefObject<T>;
1535
+
1507
1536
  /**
1508
1537
  * Hook that provides stable logging functions (log, warn, error), scoped to the resolved enableLogging flag.
1538
+ * Uses useEvent to ensure the returned functions have stable identities while always using the latest values.
1509
1539
  * @param enableLoggingProp Optional direct prop to override logging.
1510
1540
  */
1511
1541
  export declare function useLogger(enableLoggingProp?: boolean): {
@@ -4,6 +4,7 @@ import { IFrameMessageData } from 'iframe-resizer';
4
4
  import { IFrameOptions } from 'iframe-resizer';
5
5
  import { IFrameResizedData } from 'iframe-resizer';
6
6
  import { IFrameScrollData } from 'iframe-resizer';
7
+ import { MutableRefObject } from 'react';
7
8
  import { default as React_2 } from 'react';
8
9
  import { ReactNode } from 'react';
9
10
  import { RefObject } from 'react';
@@ -107,8 +108,9 @@ declare type CapitalOsAuthenticationContextType = {
107
108
  enableLogging: boolean;
108
109
  /**
109
110
  * Optional logger for capturing all SDK logs including Penpal.
111
+ * Stored in a ref to avoid unnecessary re-renders when logger changes.
110
112
  */
111
- logger?: Logger | undefined;
113
+ loggerRef: React_2.RefObject<Logger | undefined>;
112
114
  };
113
115
 
114
116
  declare const CapitalOsAuthenticationProvider: React_2.FC<ProviderProps>;
@@ -1081,10 +1083,16 @@ export declare type RawErrorDetails = {
1081
1083
  };
1082
1084
 
1083
1085
  /**
1084
- * Redacts token values from a string, keeping first 4 and last 4 characters for debugging
1086
+ * Redacts a string value, keeping first 4 and last 4 characters for debugging
1087
+ * Safe to use - handles undefined/null and short strings gracefully
1088
+ */
1089
+ export declare function redactString(value: string | undefined | null): string;
1090
+
1091
+ /**
1092
+ * Redacts token values from a url string, keeping first 4 and last 4 characters for debugging
1085
1093
  * Safe to use - will not throw even with malformed input
1086
1094
  */
1087
- export declare function redactToken(str: string): string;
1095
+ export declare function redactTokenFromUrl(str: string): string;
1088
1096
 
1089
1097
  declare type RenderingContext_2 = z.infer<typeof renderingContextSchema>;
1090
1098
 
@@ -1459,6 +1467,18 @@ export declare const useCapitalOsAuthContext: () => CapitalOsAuthenticationConte
1459
1467
  */
1460
1468
  export declare function useEnableLogging(enableLoggingProp?: boolean): boolean;
1461
1469
 
1470
+ /**
1471
+ * Creates a stable callback that always calls the latest version of the provided function.
1472
+ * This is useful for event handlers and callbacks that need to be in dependency arrays
1473
+ * but shouldn't trigger effect re-fires when they change.
1474
+ *
1475
+ * Based on the useEvent RFC (that made it into React 19.2): https://github.com/reactjs/rfcs/blob/useevent/text/0000-useevent.md
1476
+ *
1477
+ * @param fn The function to wrap
1478
+ * @returns A stable callback that always calls the latest version of fn
1479
+ */
1480
+ export declare function useEvent<T extends (...args: any[]) => any>(fn: T): T;
1481
+
1462
1482
  /**
1463
1483
  * A React hook that manages the iframe connection lifecycle, including:
1464
1484
  * - Establishing and maintaining the iframe connection
@@ -1504,8 +1524,18 @@ export declare function useIframeUrl({ tokenData, renderingContext, theme, onErr
1504
1524
  onError?: ((error: Error) => void) | undefined;
1505
1525
  }): string | undefined;
1506
1526
 
1527
+ /**
1528
+ * Returns a ref that always contains the latest value.
1529
+ * Useful for accessing the current value of props/state in callbacks without causing re-renders.
1530
+ *
1531
+ * @param value The value to track
1532
+ * @returns A ref containing the latest value
1533
+ */
1534
+ export declare function useLatest<T>(value: T): MutableRefObject<T>;
1535
+
1507
1536
  /**
1508
1537
  * Hook that provides stable logging functions (log, warn, error), scoped to the resolved enableLogging flag.
1538
+ * Uses useEvent to ensure the returned functions have stable identities while always using the latest values.
1509
1539
  * @param enableLoggingProp Optional direct prop to override logging.
1510
1540
  */
1511
1541
  export declare function useLogger(enableLoggingProp?: boolean): {
package/dist/esm/index.js CHANGED
@@ -1,4 +1,4 @@
1
- "use client";var be=Object.defineProperty,Te=Object.defineProperties;var Le=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var ie=Object.prototype.hasOwnProperty,se=Object.prototype.propertyIsEnumerable;var re=(e,n,o)=>n in e?be(e,n,{enumerable:!0,configurable:!0,writable:!0,value:o}):e[n]=o,c=(e,n)=>{for(var o in n||(n={}))ie.call(n,o)&&re(e,o,n[o]);if(W)for(var o of W(n))se.call(n,o)&&re(e,o,n[o]);return e},p=(e,n)=>Te(e,Le(n));var P=(e,n)=>{var o={};for(var t in e)ie.call(e,t)&&n.indexOf(t)<0&&(o[t]=e[t]);if(e!=null&&W)for(var t of W(e))n.indexOf(t)<0&&se.call(e,t)&&(o[t]=e[t]);return o};var D=(e,n,o)=>new Promise((t,r)=>{var i=m=>{try{a(o.next(m))}catch(d){r(d)}},s=m=>{try{a(o.throw(m))}catch(d){r(d)}},a=m=>m.done?t(m.value):Promise.resolve(m.value).then(i,s);a((o=o.apply(e,n)).next())});import h,{useMemo as y,useContext as fn}from"react";import U from"react";import H,{createContext as sn,useContext as an,useState as B,useMemo as ye,useCallback as R,useEffect as cn}from"react";import Je,{useMemo as Xe,useRef as Ze,useEffect as Ge}from"react";var v=class extends Error{constructor({message:n,code:o}){super(n),this.name="CapitalOSError",this.code=o}},L={unauthorized:"unauthorized",invalid_account_status:"invalid_account_status",unsupported_entry_point:"unsupported_entry_point",internal_error:"internal_error"},S=class extends v{constructor(n){super({message:`Invalid token ${n!=null?n:""}`,code:L.unauthorized}),this.name="CapitalOSInvalidTokenError"}};import{connect as Re,WindowMessenger as Fe}from"penpal";import{useCallback as ze,useEffect as z,useMemo as Y,useRef as V,useState as le}from"react";var ae="1.4.5-rc.1";function Ae(e){let n=JSON.stringify(e),o=btoa(n);return encodeURIComponent(o)}function G(e){try{let n=decodeURIComponent(e),o=atob(n);return JSON.parse(o)}catch(n){throw new S}}function Oe(e){try{return decodeURIComponent(e)}catch(n){return e}}function ce({tokenData:e,renderingContext:n,theme:o,onError:t}){try{let r=n?p(c({},n),{referer:window.location.href}):null,i=r?Ae(r):null,s=new URL(e.baseUrl),a=Oe(e.token);return e.paramLocation==="search"?s.searchParams.set(e.paramKey,a):e.paramLocation==="hash"&&(s.hash=e.paramKey+"="+encodeURIComponent(a)),s.searchParams.set("sdkVersion",ae),i&&s.searchParams.set("renderingContext",i),o&&s.searchParams.set("theme",o),s.toString()}catch(r){t==null||t(new S);return}}function j(e){let o=G(e).path;if(!o||typeof o!="string")throw new S;return{token:e,tokenType:"oneTime",baseUrl:o,paramKey:"token",paramLocation:"search"}}var De={enableLogging:!1},Se="[CapitalOS] ";function Q(e){return(n,o=De)=>{try{let t=`${Se}${n}`;o.logger?o.logger[e](t):o.enableLogging&&console[e](t)}catch(t){}}}var q={log:Q("log"),warn:Q("warn"),error:Q("error")};function K(e){try{return e.replace(/([?&#])(token|access_token)=([^&\s#]+)/gi,(n,o,t,r)=>{if(!r||r.length<=12)return`${o}${t}=***`;let i=r.substring(0,4),s=r.substring(r.length-4);return`${o}${t}=${i}...${s}`})}catch(n){return"[URL redacted due to processing error]"}}var de=1e4;function $e(e){return(...n)=>{try{let o=n.map(t=>{if(typeof t=="string")return t;if(t instanceof Error)return t.message;try{return JSON.stringify(t)}catch(r){return String(t)}}).join(" ");e(o)}catch(o){}}}function ee({iframeRef:e,token:n,onError:o,methods:t,iframeLabel:r}){let[i,s]=le(null),{log:a}=I(),m=Y(()=>$e(a),[a]);return z(()=>{let d=r?`[${r}] `:"";if(!e.current){a(`${d}Iframe ref not available - iframe element may not be mounted`);return}if(!e.current.contentWindow){a(`${d}Iframe contentWindow not accessible - may be blocked by browser security policy or CSP`);return}a(`${d}Establishing Penpal connection to iframe`);let l=!0,f=new Fe({remoteWindow:e.current.contentWindow,allowedOrigins:["*"]}),b=Re({messenger:f,methods:t,timeout:de,log:m});return b.promise.then(()=>{l&&(a(`${d}Penpal connection established successfully`),s(b))}).catch(k=>{l&&(a(`${d}Penpal connection failed: ${k.message}. Timeout: ${de}ms`),o==null||o(k),s(null))}),()=>{l=!1,a(`${d}Destroying Penpal connection (cleanup triggered - likely due to token or iframeRef change, or component unmount)`),b.destroy(),s(null)}},[n,e]),i}function ne({tokenData:e,renderingContext:n,theme:o,onError:t}){let r=V(t),i=V(n);return Y(()=>{if(e)return ce({tokenData:e,renderingContext:i.current,theme:o,onError:r.current})},[e,o,r,i])}function J(e){let{oneTimeToken:n,enableLogging:o,onError:t,renderingContext:r,theme:i,methods:s}=e,{tokenData:a,error:m,invalidateToken:d}=X(),{log:l,warn:f}=I(o),[b,k]=le(!1),E=V(null);He(m,t);let g=Y(()=>n?j(n):a,[n,a]);z(()=>{if(g){let u=g.token?`${g.token.substring(0,4)}...${g.token.substring(g.token.length-4)}`:"undefined";l(`[${r.entryPoint}] Token data available, type: ${g.tokenType}, token: ${u}, location: ${g.paramLocation}, key: ${g.paramKey}, baseUrl: ${g.baseUrl}`)}},[g]);let M=ze(()=>{if(l("Token expired, invalidating..."),n){t==null||t(new v({message:"Token expired. Cannot automatically refresh when using token prop.",code:L.unauthorized}));return}d(),k(!1)},[n,d,t]);z(()=>{n&&a&&f("token was provided both from provider and from the token prop. the prop will take precedence")},[n,a]);let T=ne({tokenData:g,renderingContext:r,theme:i,onError:t});z(()=>{T?l(`Iframe URL generated: ${K(T).substring(0,1024)}...`):g&&f("Failed to generate iframe URL despite having token data")},[T,g]);let x=ee({iframeRef:E,token:g==null?void 0:g.token,iframeLabel:r.entryPoint,onError:u=>{l(`Connection error: ${u.message}`),t==null||t(u),k(!0)},methods:c({onLoad:()=>{l("Iframe called onLoad()"),k(!0)},onError:u=>{let F=new v(u);l(`Iframe error: ${F.message}`),t==null||t(F)},onTokenExpired:M},s)});return{isLoaded:b,url:T,tokenData:g,iframeRef:E,connection:x}}function He(e,n){let o=V(!1);z(()=>{e&&!o.current&&(n==null||n(e),o.current=!0)},[e,n])}import{iframeResizer as Be}from"iframe-resizer";import Ue,{forwardRef as Ne,useEffect as _e,useImperativeHandle as We,useRef as je}from"react";var w=Ne((e,n)=>{let o=e.title||"iframe",{iframeHTMLAttributes:t,resizerOptions:r}=Ve(e),i=je(null);return _e(()=>{let s=i.current;return Be(c({},r),s),()=>s.iFrameResizer&&s.iFrameResizer.removeListeners()}),We(n,()=>i.current),Ue.createElement("iframe",p(c({},t),{title:o,ref:i}))});w.displayName="IframeResizer";var qe=["autoResize","bodyBackground","bodyMargin","bodyPadding","checkOrigin","inPageLinks","heightCalculationMethod","interval","log","maxHeight","maxWidth","minHeight","minWidth","resizeFrom","scrolling","sizeHeight","sizeWidth","warningTimeout","tolerance","widthCalculationMethod","onClosed","onInit","onMessage","onResized","onScroll"],Ke=new Set(qe);function Ve(e){return Object.keys(e).reduce((o,t)=>{let r=e[t];return Ke.has(t)?r!==void 0&&(o.resizerOptions[t]=e[t]):o.iframeHTMLAttributes[t]=e[t],o},{resizerOptions:{},iframeHTMLAttributes:{}})}function pe(e){let{oneTimeToken:n,enableLogging:o,onExchangeComplete:t,onExchangeError:r}=e,i=A(o),{log:s}=I(o),a=Ze(null),m=Xe(()=>j(n),[n]),l=ne({tokenData:m,onError:r,renderingContext:{entryPoint:"tokenExchange"}});return Ge(()=>{l&&s(`Token exchange iframe URL: ${K(l).substring(0,1024)}...`)},[l]),ee({iframeRef:a,token:n,iframeLabel:"token-exchange",onError:f=>{s(`Token exchange connection error: ${f.message}`),r==null||r(f)},methods:{onLoad:()=>{s("Token exchange iframe loaded")},onError:f=>{s(`Token exchange iframe error: ${f.message}`),r==null||r(new v(f))},tokenExchange:{onLongLivedToken:f=>{s("Token exchange complete: received long-lived token"),t(f)}}}}),Je.createElement(w,{src:l,checkOrigin:!1,style:{display:"none"},log:i,ref:a,onLoad:()=>{s("Token exchange iframe HTML loaded successfully")},onError:f=>{s(`Token exchange iframe failed to load: ${f}`)}})}import $,{createContext as on,useState as tn,useMemo as xe,useCallback as rn}from"react";import Qe from"react";import{useMemo as Ye}from"react";function ue(m){var d=m,{onDone:e,onCancel:n,mfaId:o,destination:t,codeLength:r,canResendAfter:i,operationName:s}=d,a=P(d,["onDone","onCancel","mfaId","destination","codeLength","canResendAfter","operationName"]);let l="mfa",f=Ye(()=>({entryPoint:l,mfaId:o,destination:t,codeLength:r,canResendAfter:i,operationName:s}),[l,o,t,r,i,s]);return Qe.createElement(C,p(c({},a),{renderingContext:f,methods:{mfa:{onDone:e,onCancel:n}}}))}import me,{useEffect as en}from"react";var fe={backdrop:{position:"fixed",top:0,left:0,right:0,bottom:0,backgroundColor:"rgba(0, 0, 0, 0.4)",backdropFilter:"blur(2px)",zIndex:1e3,display:"flex",alignItems:"center",justifyContent:"center",padding:"20px"},container:{backgroundColor:"white",borderRadius:"8px",boxShadow:"0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -2px rgb(0 0 0 / 0.05)",maxWidth:"600px",width:"100%",maxHeight:"90vh",overflow:"hidden",position:"relative"}};function ge({onClose:e,children:n,ariaLabel:o="Modal dialog"}){en(()=>{let r=i=>{i.key==="Escape"&&e()};return document.addEventListener("keydown",r),()=>{document.removeEventListener("keydown",r)}},[e]);let t=r=>{r.target===r.currentTarget&&e()};return me.createElement("div",{style:fe.backdrop,onClick:t,role:"dialog","aria-modal":"true","aria-label":o},me.createElement("div",{style:fe.container},n))}import{useState as nn,useCallback as Z}from"react";function Ce(){var d;let[e,n]=nn(null),{log:o}=I(),t=Z(l=>(o("MFA requested"),new Promise((f,b)=>{n({context:l,resolve:f,reject:b})})),[o]),r=Z(()=>{e&&(o("MFA completed successfully"),e.resolve({success:!0,canceled:!1,data:void 0}),n(null))},[e,o]),i=Z(()=>{e&&(o("MFA canceled"),e.resolve({success:!1,canceled:!0}),n(null))},[e,o]),s=Z(l=>{e&&(o("MFA error: "+l.message),e.resolve({success:!1,canceled:!1,error:l}),n(null))},[e,o]),a=!!e,m=(d=e==null?void 0:e.context)!=null?d:null;return{activeMfaRequest:e,isMfaActive:a,mfaContext:m,requestMfa:t,handleMfaDone:r,handleMfaCancel:i,handleMfaError:s}}var oe=on(null);function he({children:e}){let[n,o]=tn(null),t=A(),{log:r}=I(),{requestMfa:i,handleMfaDone:s,handleMfaCancel:a,isMfaActive:m,mfaContext:d}=Ce(),l=rn(x=>D(null,null,function*(){let u=yield i(x);return u.success?{success:!0}:u.canceled?{success:!1,canceled:!0}:{success:!1,error:u.error.message}}),[i]),f=xe(()=>n?{freezeCard:x=>D(null,null,function*(){try{let u=yield n.freezeCard(x);return u.success?{success:!0,canceled:!1,data:u.data}:u.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new v({code:L.internal_error,message:u.error})}}catch(u){return{success:!1,canceled:!1,error:new v({code:L.internal_error,message:u instanceof Error?u.message:"Communication error with iframe"})}}}),unfreezeCard:x=>D(null,null,function*(){try{let u=yield n.unfreezeCard(x);return u.success?{success:!0,canceled:!1,data:u.data}:u.canceled?{success:!1,canceled:!0}:{success:!1,canceled:!1,error:new v({code:L.internal_error,message:u.error})}}catch(u){return{success:!1,canceled:!1,error:new v({code:L.internal_error,message:u instanceof Error?u.message:"Communication error with iframe"})}}})}:null,[n]),b=xe(()=>({"system-messages":{requestMfa:l},mfa:{onDone:s,onCancel:a}}),[l,s,a]),{isLoaded:k,url:E,connection:g,iframeRef:M}=J({renderingContext:{entryPoint:"actions"},methods:b});$.useEffect(()=>{let x=!0;return g&&g.promise.then(u=>{x&&(o(u),r("Actions iframe child functions loaded"))}),()=>{x=!1}},[g]);let T=!k||!n;return $.createElement(oe.Provider,{value:{childFunctions:n,actions:f,isLoading:T}},e,E&&$.createElement(w,{src:E,style:{display:"none"},checkOrigin:!1,log:t,ref:M,onLoad:()=>{r("Actions iframe HTML loaded successfully")},onError:x=>{r(`Actions iframe failed to load: ${x}. This may indicate network issues or security policy blocking.`)}}),m&&d&&$.createElement(ge,{onClose:a,ariaLabel:"Multi-factor authentication"},$.createElement(ue,p(c({mfaId:d.mfaId,destination:d.destination,codeLength:d.codeLength,canResendAfter:d.canResendAfter},d.operationName&&{operationName:d.operationName}),{onDone:s,onCancel:a}))))}var Pe=sn({isLoading:!1,invalidateToken:()=>{},enableLogging:!1}),dn=({getToken:e,enableLogging:n,logger:o,children:t})=>{let[r,i]=B(void 0),[s,a]=B(void 0),[m,d]=B(void 0),[l,f]=B(!1),[b,k]=B(void 0),E=R(()=>D(null,null,function*(){f(!0);try{let x=yield e();i(x),k(void 0);let u=G(x),F=new URL(u.path);F.pathname="",a(F.toString())}catch(x){k(x)}finally{f(!1)}}),[e]),g=R(()=>{d(void 0)},[]);cn(()=>{m||E()},[m,E]);let M=R(x=>{d(x),i(void 0),k(void 0)},[]),T=ye(()=>{if(m&&!s)throw new v({message:"baseUrl is required for long lived tokens",code:L.unauthorized});return{tokenData:m?{token:m,tokenType:"longLived",baseUrl:s,paramKey:"access_token",paramLocation:"hash"}:void 0,isLoading:l,error:b,invalidateToken:g,enableLogging:n!=null?n:!1,logger:o}},[m,l,b,g,s,n]);return H.createElement(H.Fragment,null,H.createElement(Pe.Provider,{value:T},H.createElement(he,null,t)),r&&!m&&H.createElement(pe,{oneTimeToken:r,onExchangeComplete:M,enableLogging:n,onExchangeError:k}))},X=()=>an(Pe);function A(e){let{enableLogging:n}=X();return e!==void 0?e:n}function I(e){let n=A(e),{logger:o}=X(),t=R(s=>{q.log(s,{enableLogging:n,logger:o})},[n]),r=R(s=>{q.warn(s,{enableLogging:n,logger:o})},[n]),i=R(s=>{q.error(s,{enableLogging:n,logger:o})},[n]);return ye(()=>({log:t,warn:r,error:i}),[t,r,i])}function C(e){let{token:n,className:o,enableLogging:t,onError:r,loadingComponent:i,renderingContext:s,methods:a,theme:m,sizeWidth:d}=e,l=A(t),{log:f}=I(t),{isLoaded:b,url:k,tokenData:E,iframeRef:g}=J({oneTimeToken:n,enableLogging:l,onError:r,renderingContext:s,theme:m,methods:a});if(!E||!k)return U.createElement(U.Fragment,null,i||null);let M=s.entryPoint!=="insightsWidget";return U.createElement(U.Fragment,null,!b&&i,U.createElement(w,{src:k,allow:"clipboard-write",checkOrigin:!1,style:{width:"1px",height:"0px",minWidth:"100%"},className:o,log:l,ref:g,hidden:!b,onLoad:()=>{f(`Main iframe HTML loaded successfully for entry point: ${s.entryPoint}`)},onError:T=>{f(`Main iframe failed to load: ${T}. This may indicate network issues, firewall blocking, or CSP violations.`)},onResized:T=>{if(!M)return;let x=`${parseInt(T.height)+12}px`;T.iframe.style.height=x},sizeWidth:d}))}import _,{useMemo as ln}from"react";import{useState as pn}from"react";import O,{useState as ve}from"react";var N={bugButton:{position:"fixed",left:"12px",bottom:"12px",margin:"12px",padding:"4px",display:"inline-flex",alignItems:"center",borderRadius:"9999px",border:"1px solid transparent",backgroundColor:"#2563eb",color:"white",opacity:.4,boxShadow:"0 1px 3px 0 rgb(0 0 0 / 0.1)",cursor:"pointer",zIndex:50,transition:"opacity 0.3s ease-in-out"},bugButtonHover:{backgroundColor:"#1d4ed8",opacity:1},bugButtonFocus:{outline:"none",boxShadow:"0 0 0 2px white, 0 0 0 4px #3b82f6"},bugIcon:{width:"20px",height:"20px"},loadingButton:{cursor:"default",opacity:1,animation:"pulse 1s cubic-bezier(0.4, 0, 0.6, 1) infinite"}},ke=()=>O.createElement("svg",{style:N.bugIcon,xmlns:"http://www.w3.org/2000/svg",fill:"none",viewBox:"0 0 24 24",strokeWidth:"1.5",stroke:"currentColor"},O.createElement("path",{strokeLinecap:"round",strokeLinejoin:"round",d:"M12 12.75c1.148 0 2.278.08 3.383.237 1.037.146 1.866.966 1.866 2.013 0 3.728-2.35 6.75-5.25 6.75S6.75 18.728 6.75 15c0-1.046.83-1.867 1.866-2.013A24.204 24.204 0 0 1 12 12.75Zm0 0c2.883 0 5.647.508 8.207 1.44a23.91 23.91 0 0 1-1.152 6.06M12 12.75c-2.883 0-5.647.508-8.208 1.44.125 2.104.52 4.136 1.153 6.06M12 12.75a2.25 2.25 0 0 0 2.248-2.354M12 12.75a2.25 2.25 0 0 1-2.248-2.354M12 8.25c.995 0 1.971-.08 2.922-.236.403-.066.74-.358.795-.762a3.778 3.778 0 0 0-.399-2.25M12 8.25c-.995 0-1.97-.08-2.922-.236-.402-.066-.74-.358-.795-.762a3.734 3.734 0 0 1 .4-2.253M12 8.25a2.25 2.25 0 0 0-2.248 2.146M12 8.25a2.25 2.25 0 0 1 2.248 2.146M8.683 5a6.032 6.032 0 0 1-1.155-1.002c.07-.63.27-1.222.574-1.747m.581 2.749A3.75 3.75 0 0 1 15.318 5m0 0c.427-.283.815-.62 1.155-.999a4.471 4.471 0 0 0-.575-1.752M4.921 6a24.048 24.048 0 0 0-.392 3.314c1.668.546 3.416.914 5.223 1.082M19.08 6c.205 1.08.337 2.187.392 3.314a23.882 23.882 0 0 1-5.223 1.082"}));function te({onClick:e,isLoading:n=!1}){let[o,t]=ve(!1),[r,i]=ve(!1),s=c(c(c(c({},N.bugButton),n&&N.loadingButton),!n&&o&&N.bugButtonHover),!n&&r&&N.bugButtonFocus);return n?O.createElement("div",{style:s},O.createElement("style",null,`
1
+ "use client";var Ie=Object.defineProperty,Me=Object.defineProperties;var Oe=Object.getOwnPropertyDescriptors;var W=Object.getOwnPropertySymbols;var de=Object.prototype.hasOwnProperty,le=Object.prototype.propertyIsEnumerable;var ce=(e,n,t)=>n in e?Ie(e,n,{enumerable:!0,configurable:!0,writable:!0,value:t}):e[n]=t,c=(e,n)=>{for(var t in n||(n={}))de.call(n,t)&&ce(e,t,n[t]);if(W)for(var t of W(n))le.call(n,t)&&ce(e,t,n[t]);return e},p=(e,n)=>Me(e,Oe(n));var k=(e,n)=>{var t={};for(var o in e)de.call(e,o)&&n.indexOf(o)<0&&(t[o]=e[o]);if(e!=null&&W)for(var o of W(e))n.indexOf(o)<0&&le.call(e,o)&&(t[o]=e[o]);return t};var D=(e,n,t)=>new Promise((o,r)=>{var i=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,`
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(ke,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(ke,null))}var un={panel:{position:"fixed",bottom:"20px",left:"20px",zIndex:50}};function mn(e){let n="devTools",o=ln(()=>({entryPoint:n}),[n]),[t,r]=pn(!1);return _.createElement("aside",{"aria-label":"CapitalOS dev tools"},!t&&_.createElement(te,{onClick:()=>r(!t)}),t&&_.createElement("div",{style:un.panel},_.createElement(C,p(c({},e),{renderingContext:o,methods:{devTools:{onClose:()=>r(!1)}},enableLogging:!0,sizeWidth:!0,loadingComponent:_.createElement(te,{isLoading:!0})}))))}function gn(e){let n="cardsApp",o=y(()=>({entryPoint:n}),[n]);return h.createElement(C,p(c({},e),{renderingContext:o}))}var it=gn;function st(r){var i=r,{cardholder:e,onDone:n,onCancel:o}=i,t=P(i,["cardholder","onDone","onCancel"]);let s="createCard",a=y(()=>({entryPoint:s,cardholder:e}),[e]);return h.createElement(C,p(c({},t),{renderingContext:a,methods:{createCard:{onDone:n,onCancel:o}}}))}function at(r){var i=r,{transactionId:e,onDone:n,onCancel:o}=i,t=P(i,["transactionId","onDone","onCancel"]);let s="createDispute",a=y(()=>({entryPoint:s,transactionId:e}),[e]);return h.createElement(C,p(c({},t),{renderingContext:a,methods:{createDispute:{onDone:n,onCancel:o}}}))}function ct(e){let n="billPayApp",o=y(()=>({entryPoint:n}),[n]);return h.createElement(C,p(c({},e),{renderingContext:o}))}function dt(e){let s=e,{onCardCanceled:n,onHideSensitiveDetails:o}=s,t=P(s,["onCardCanceled","onHideSensitiveDetails"]),r="cardDetails",i=y(()=>({entryPoint:r,cardId:e.cardId,cardOnly:e.cardOnly,backOnly:e.backOnly,hideAddress:e.hideAddress}),[r,e.cardId,e.cardOnly,e.backOnly,e.hideAddress]);return h.createElement(C,p(c({},t),{renderingContext:i,methods:{cardDetails:{onCardCanceled:n!=null?n:()=>{},onHideSensitiveDetails:o!=null?o:()=>{}}}}))}function lt(e){let n="accountDetails",o=y(()=>({entryPoint:n}),[n]);return h.createElement(C,p(c({},e),{renderingContext:o}))}function pt(e){let n="accountActions",o=y(()=>({entryPoint:n}),[n]);return h.createElement(C,p(c({},e),{renderingContext:o}))}function ut(o){var t=o,{onClose:e}=t,n=P(t,["onClose"]);let r="manageBankConnections",i=y(()=>({entryPoint:r}),[r]);return h.createElement(C,p(c({},n),{renderingContext:i,methods:{manageBankConnections:{onClose:e}}}))}function mt(o){var t=o,{onClose:e}=t,n=P(t,["onClose"]);let r="configureAutoPay",i=y(()=>({entryPoint:r}),[r]);return h.createElement(C,p(c({},n),{renderingContext:i,methods:{configureAutoPay:{onClose:e}}}))}function ft(o){var t=o,{onClose:e}=t,n=P(t,["onClose"]);let r="policySettings",i=y(()=>({entryPoint:r}),[r]);return h.createElement(C,p(c({},n),{renderingContext:i,methods:{policySettings:{onClose:e}}}))}function gt(r){var i=r,{cardId:e,onClose:n,inlineCardOnFile:o}=i,t=P(i,["cardId","onClose","inlineCardOnFile"]);let s="connectToVendors",a=y(()=>({entryPoint:s,cardId:e,inlineCardOnFile:o}),[s,e,o]);return h.createElement(C,p(c({},t),{renderingContext:a,methods:{connectToVendors:{onClose:n}}}))}function Ct(e){let n="insightsDashboard",o=y(()=>({entryPoint:n}),[n]);return h.createElement(C,p(c({},e),{renderingContext:o}))}function xt(e){let n="insightsWidget",{widget:o,hideTitle:t,height:r,width:i}=e,s=y(()=>({entryPoint:n,widget:o,hideTitle:t,height:r,width:i}),[n,o,t,r,i]);return h.createElement(C,p(c({},e),{renderingContext:s}))}function ht(r){var i=r,{onDone:e,entryPoint:n,exitPoint:o}=i,t=P(i,["onDone","entryPoint","exitPoint"]);let s="onboarding",a=y(()=>({entryPoint:s,onboardingEntryPoint:n,onboardingExitPoint:o}),[s,n,o]);return h.createElement(C,p(c({},t),{renderingContext:a,methods:{onboarding:{onDone:e}}}))}function yt(o){var t=o,{onDone:e}=t,n=P(t,["onDone"]);let r="makePayment",i=y(()=>({entryPoint:r}),[r]);return h.createElement(C,p(c({},n),{renderingContext:i,methods:{makePayment:{onDone:e}}}))}function Pt(t){var r=t,{onDone:e,onCancel:n}=r,o=P(r,["onDone","onCancel"]);let i="contactSupport",s=y(()=>({entryPoint:i}),[i]);return h.createElement(C,p(c({},o),{renderingContext:s,methods:{contactSupport:{onDone:e,onCancel:n}}}))}function vt(o){var t=o,{onDone:e}=t,n=P(t,["onDone"]);let r="statements",i=y(()=>({entryPoint:r}),[r]);return h.createElement(C,p(c({},n),{renderingContext:i,methods:{statements:{onDone:e}}}))}function kt(o){var t=o,{onDone:e}=t,n=P(t,["onDone"]);let r="legalDocuments",i=y(()=>({entryPoint:r}),[r]);return h.createElement(C,p(c({},n),{renderingContext:i,methods:{legalDocuments:{onDone:e}}}))}function bt(r){var i=r,{cardId:e,onDone:n,onClose:o}=i,t=P(i,["cardId","onDone","onClose"]);let s="replaceCard",a=y(()=>({entryPoint:s,cardId:e}),[e]);return h.createElement(C,p(c({},t),{renderingContext:a,methods:{replaceCard:{onDone:n,onClose:o}}}))}function Tt(r){var i=r,{cardId:e,onDone:n,onClose:o}=i,t=P(i,["cardId","onDone","onClose"]);let s="terminateCard",a=y(()=>({entryPoint:s,cardId:e}),[e]);return h.createElement(C,p(c({},t),{renderingContext:a,methods:{terminateCard:{onDone:n,onClose:o}}}))}function Lt(e){let n="transactions",o=y(()=>({entryPoint:n}),[n]);return h.createElement(C,p(c({},e),{renderingContext:o}))}function It(){let e=fn(oe);if(!e)throw new v({message:"useActions must be used within a CapitalOsAuthenticationProvider",code:L.internal_error});let{childFunctions:n,isLoading:o}=e;return{actions:n,isLoading:o}}export{pt as AccountActions,lt as AccountDetails,it as App,ct as BillPayApp,dn as CapitalOsAuthenticationProvider,dt as CardDetails,gn as CardsApp,mt as ConfigureAutoPay,gt as ConnectToVendors,Pt as ContactSupport,mn as DevTools,at as DisputeTransaction,Ct as InsightsDashboard,xt as InsightsWidget,st as IssueCard,kt as LegalDocuments,yt as MakePayment,ut as ManageBankConnections,ht as Onboarding,ft as PolicySettings,bt as ReplaceCard,vt as Statements,Tt as TerminateCard,Lt as Transactions,It as useActions};
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(r){var i=r,{cardholder:e,onDone:n,onCancel:t}=i,o=k(i,["cardholder","onDone","onCancel"]);let s="createCard",a=h(()=>({entryPoint:s,cardholder:e}),[e]);return x.createElement(C,p(c({},o),{renderingContext:a,methods:{createCard:{onDone:n,onCancel:t}}}))}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 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 bo(e){let n="accountDetails",t=h(()=>({entryPoint:n}),[n]);return x.createElement(C,p(c({},e),{renderingContext:t}))}function To(e){let n="accountActions",t=h(()=>({entryPoint:n}),[n]);return x.createElement(C,p(c({},e),{renderingContext:t}))}function vo(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 Lo(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 Eo(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 Io(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 Mo(e){let n="insightsDashboard",t=h(()=>({entryPoint:n}),[n]);return x.createElement(C,p(c({},e),{renderingContext:t}))}function Oo(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 Ao(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 So(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 Do(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 Ro(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 Fo(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 zo(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 $o(e){let n="transactions",t=h(()=>({entryPoint:n}),[n]);return x.createElement(C,p(c({},e),{renderingContext:t}))}function Ho(){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{To as AccountActions,bo as AccountDetails,xo as App,Po as BillPayApp,Cn as CapitalOsAuthenticationProvider,ko as CardDetails,bn as CardsApp,Lo as ConfigureAutoPay,Io as ConnectToVendors,So as ContactSupport,Pn as DevTools,yo as DisputeTransaction,Mo as InsightsDashboard,Oo as InsightsWidget,ho as IssueCard,Ro as LegalDocuments,Ao as MakePayment,vo as ManageBankConnections,wo as Onboarding,Eo as PolicySettings,Fo as ReplaceCard,Do as Statements,zo as TerminateCard,$o as Transactions,Ho as useActions};
11
11
  //# sourceMappingURL=index.js.map