@zeniai/web-app-ui 5.1.97-qa → 5.1.98-next

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.
Files changed (122) hide show
  1. package/dist/assets/AddressRoutes-HPXqpC_C.js +1 -0
  2. package/dist/assets/{AddressScreen-4qRIlnK-.js → AddressScreen-DloTYXZl.js} +2 -2
  3. package/dist/assets/{AiCfoScreen-C0xnk5cF.js → AiCfoScreen-D-ZVynRZ.js} +2 -2
  4. package/dist/assets/{BillPayApprovalRoutes-oopRYco4.js → BillPayApprovalRoutes-D1zNaUM2.js} +1 -1
  5. package/dist/assets/{BillPayRoutes-B0ySvfjH.js → BillPayRoutes-gVxhlaE4.js} +10 -10
  6. package/dist/assets/{BusinessVerificationPageScreen-BfTuFBnf.js → BusinessVerificationPageScreen-Iipb6Y1I.js} +2 -2
  7. package/dist/assets/{CardsAiCfoScreen-B68NhQxR.js → CardsAiCfoScreen-Dj12EtyG.js} +1 -1
  8. package/dist/assets/{ChargeCardRoutes-BBe1i5WM.js → ChargeCardRoutes-CHS_6dMy.js} +6 -6
  9. package/dist/assets/CompanyPassportScreen-Dgua-KO9.js +1 -0
  10. package/dist/assets/{ConnectionAuthScreen-hJWTTt8K.js → ConnectionAuthScreen-VeQpitaK.js} +1 -1
  11. package/dist/assets/CustomerOnboardingAuthScreen-DXGT5xNB.js +1 -0
  12. package/dist/assets/{CustomerOnboardingRoutes-CMiSGPxL.js → CustomerOnboardingRoutes-BrvfjKKy.js} +4 -4
  13. package/dist/assets/{DashboardRoutes-C-AFXkgO.js → DashboardRoutes-DpeDBXm-.js} +4 -4
  14. package/dist/assets/{DefaultTenantHome-S2gSmw3u.js → DefaultTenantHome-CcTsNwzo.js} +1 -1
  15. package/dist/assets/DomesticWireDetailScreen-BPDIrSr9.js +18 -0
  16. package/dist/assets/DrawerScreen-Dr1DrcKY.js +1 -0
  17. package/dist/assets/{EntityDetailRoutes-CoUef8K_.js → EntityDetailRoutes-DX9TMSpr.js} +1 -1
  18. package/dist/assets/{ExpenseAutomationRoutes-DvnfBRy6.js → ExpenseAutomationRoutes-BEGLd_e-.js} +1 -1
  19. package/dist/assets/FeaturePreviewScreen-CHiZhZE1.js +1 -0
  20. package/dist/assets/{HubSpotOAuthCallbackScreen-H96Zh7Xb.js → HubSpotOAuthCallbackScreen-Ck2NuyXz.js} +1 -1
  21. package/dist/assets/{MagicLinkRoutes-BxVpzgVN.js → MagicLinkRoutes-BTEAEbck.js} +9 -9
  22. package/dist/assets/MagicLinkSignInScreen-CPhJfs4Y.js +12 -0
  23. package/dist/assets/{MobileAppDrawer-BLdyZXBV.js → MobileAppDrawer-CcJQi30K.js} +1 -1
  24. package/dist/assets/NotFoundScreen-4X9999wY.js +1 -0
  25. package/dist/assets/{NotificationRoutes-CMje6h_r.js → NotificationRoutes-DeCx-UmY.js} +1 -1
  26. package/dist/assets/OAuthConsentScreen-D1hEnYWc.js +1 -0
  27. package/dist/assets/{PandLWithForecastRoutes-MVL6Lv1L.js → PandLWithForecastRoutes-DF1Zv6bh.js} +1 -1
  28. package/dist/assets/PeopleRoutes-C1_fRSyv.js +22 -0
  29. package/dist/assets/PerformanceRoutes-CSbbLZO-.js +1 -0
  30. package/dist/assets/{Preview-Da-KYkaZ.js → Preview-DLrFVP8X.js} +1 -1
  31. package/dist/assets/{QBOConnectionScreen-D2pSbt3W.js → QBOConnectionScreen-gf22CW_5.js} +1 -1
  32. package/dist/assets/ReferralListScreen-DWLkocDn.js +5 -0
  33. package/dist/assets/{ReimbursementApprovalRoutes-D_uAmibG.js → ReimbursementApprovalRoutes-Dx2rNAnC.js} +1 -1
  34. package/dist/assets/{ReimbursementApprovalRuleDetailScreen-oQrkg1Y7.js → ReimbursementApprovalRuleDetailScreen-CcoCZBQV.js} +1 -1
  35. package/dist/assets/{ReimbursementRoutes-BN-W5Zqw.js → ReimbursementRoutes-BU0IpsWm.js} +4 -4
  36. package/dist/assets/{ReportsRoutes-BDn-mdcO.js → ReportsRoutes-jIAZFXh3.js} +1 -1
  37. package/dist/assets/RewardsRoutes-CYbe7-MS.js +1 -0
  38. package/dist/assets/{ScreenRoutes-DgLWjLgf.js → ScreenRoutes-RhjybI7n.js} +2 -2
  39. package/dist/assets/{SettingsRoutes-B0KcbWsV.js → SettingsRoutes-mRLjZGK5.js} +7 -7
  40. package/dist/assets/{SetupPagesScreen-Dux5L0dD.js → SetupPagesScreen-D-4Tus-H.js} +5 -5
  41. package/dist/assets/SignInScreen-BfvUtvXy.js +1 -0
  42. package/dist/assets/SignOutScreen-BEIii5sa.js +9 -0
  43. package/dist/assets/{TaskListScreen-CLmDQlr2.js → TaskListScreen-BsaXzI2d.js} +2 -2
  44. package/dist/assets/{TaskRoutes-Bvfb_uGY.js → TaskRoutes-Dnk6hYwx.js} +2 -2
  45. package/dist/assets/{TransactionDetailRoutes-CueWZ-Ua.js → TransactionDetailRoutes-DkQMKNY8.js} +1 -1
  46. package/dist/assets/{TransactionDetailScreen-Ch1gEoDW.js → TransactionDetailScreen-DZiA10YJ.js} +2 -2
  47. package/dist/assets/{TransactionListRoutes-BtnPGpxm.js → TransactionListRoutes-BRd9qonY.js} +1 -1
  48. package/dist/assets/{TreasuryRoutes-hhTgxfCu.js → TreasuryRoutes-CcN0NXYD.js} +5 -5
  49. package/dist/assets/{VendorsRoutes-mwFtgJTR.js → VendorsRoutes-DJdXu8T5.js} +12 -12
  50. package/dist/assets/WiseConfirmationScreen-C9XPLPod.js +12 -0
  51. package/dist/assets/{ZeniAccountRoutes-DCD0MdZe.js → ZeniAccountRoutes-WmtdWVZV.js} +8 -8
  52. package/dist/assets/{ZeniAccountStatementScreen-DbDEELdQ.js → ZeniAccountStatementScreen-_lbEGquv.js} +2 -2
  53. package/dist/assets/{accountMappingHelper-rs0CYQJW.js → accountMappingHelper-BsxVhfWS.js} +1 -1
  54. package/dist/assets/{analytics-DL3j77s3.js → analytics-FZZqBV_U.js} +1 -1
  55. package/dist/assets/{analyticsHelper-BLQhTmmj.js → analyticsHelper-_dJZMDy8.js} +1 -1
  56. package/dist/assets/{core-BUDfBDzW.js → core-PLgxH77Q.js} +1 -1
  57. package/dist/assets/{decodeURIComponentSafe-CAV5JFIH.js → decodeURIComponentSafe-CQ4ERcUl.js} +1 -1
  58. package/dist/assets/{dnd-C2uuKLS_.js → dnd-BR185E7x.js} +1 -1
  59. package/dist/assets/{empty-gH7VKio2.js → empty-CNe_ouDG.js} +1 -1
  60. package/dist/assets/{empty-BZfUgT7s.js → empty-Dq4IMmn9.js} +1 -1
  61. package/dist/assets/{emptyVideoElement-DgEZFuvR.js → emptyVideoElement-5wfbFCSF.js} +1 -1
  62. package/dist/assets/epic-Bhd945RG.js +2 -0
  63. package/dist/assets/getLocaleForTenant-BGLRsxve.js +1 -0
  64. package/dist/assets/{index-JzqLJcCq.js → index-BEfSXxAQ.js} +1 -1
  65. package/dist/assets/{index-Pwg8iACI.js → index-B_XHaSw_.js} +2 -2
  66. package/dist/assets/{index-YvePaYki.js → index-CpBcW5M7.js} +1 -1
  67. package/dist/assets/{index-CwfGUvf7.js → index-D0Jc1k7S.js} +1 -1
  68. package/dist/assets/{index-B1-02ULB.js → index-DOjycsll.js} +1 -1
  69. package/dist/assets/{index-DN3QU4tq.js → index-DgiZLwkG.js} +1 -1
  70. package/dist/assets/{index-9PmElJom.js → index-DplenJAr.js} +13722 -13708
  71. package/dist/assets/{index-DoyRxeZ8.js → index-X_Qmk7RA.js} +1 -1
  72. package/dist/assets/{lexical-BJhq3Vel.js → lexical-lY8wPGQT.js} +1 -1
  73. package/dist/assets/{liveblocks-DvqoH3dJ.js → liveblocks-D0coviDj.js} +1 -1
  74. package/dist/assets/{lottie-DU31Qsck.js → lottie-Cr90j9wu.js} +1 -1
  75. package/dist/assets/{mui-BX-eccqP.js → mui-C0RqdtC7.js} +1 -1
  76. package/dist/assets/{pathToGoBack-CwLFXs-c.js → pathToGoBack-By1Lhc_q.js} +1 -1
  77. package/dist/assets/{pdf-SnLRVeGX.js → pdf-Aivmor3r.js} +3 -3
  78. package/dist/assets/{pdf-lib-C5S3Bgj_.js → pdf-lib-B-stT0RK.js} +1 -1
  79. package/dist/assets/{plaid-C1X6Gp1j.js → plaid-COO6326w.js} +1 -1
  80. package/dist/assets/{pusher-BeI8juZo.js → pusher-DtHY8rHB.js} +1 -1
  81. package/dist/assets/{react-BLUmJ7p4.js → react-B8cJYYnx.js} +1 -1
  82. package/dist/assets/{react-qzNQ2jmd.js → react-BX6js7T1.js} +1 -1
  83. package/dist/assets/{react-CajOW-KO.js → react-Bf74XzK0.js} +1 -1
  84. package/dist/assets/{react-4K1mijgw.js → react-C1pEib8q.js} +1 -1
  85. package/dist/assets/{react-C0kyiULF.js → react-DHlQnEph.js} +1 -1
  86. package/dist/assets/{react-gWLA1NwC.js → react-yWD_ydgs.js} +1 -1
  87. package/dist/assets/{recharts-C3oDuogX.js → recharts-IQlfHMoz.js} +1 -1
  88. package/dist/assets/{routePaths-BPZ60_ul.js → routePaths-DqswWqzZ.js} +1 -1
  89. package/dist/assets/{sentry-oCFmppdA.js → sentry-BX7AV8EY.js} +1 -1
  90. package/dist/assets/{url-BJ6QhvOT.js → url-BLVAmInC.js} +1 -1
  91. package/dist/assets/{url-MZGYWUXg.js → url-Dv9uN6IP.js} +1 -1
  92. package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-CbeWjSYp.js → useAiCfoDashboardSuggestedQuestionsChips-wozPJqFG.js} +1 -1
  93. package/dist/assets/useAskAiCfoHostNavButtonProps-C6zAZIxS.js +1 -0
  94. package/dist/assets/{useCashManagementBanner-DGFvypM8.js → useCashManagementBanner-CjJ4k3Dw.js} +1 -1
  95. package/dist/assets/{useChargeCardPusherEvents-Cb-4seWD.js → useChargeCardPusherEvents-O8t8uEp0.js} +1 -1
  96. package/dist/assets/{useDeviceId-B2fVfrfI.js → useDeviceId-BI_R4rAw.js} +1 -1
  97. package/dist/assets/{useEmailConnectResultRefresh-CrM96Zb1.js → useEmailConnectResultRefresh-Bzw9dqwD.js} +1 -1
  98. package/dist/assets/{useInitialThreadRequest-DfW2emMG.js → useInitialThreadRequest-D54lz34v.js} +1 -1
  99. package/dist/assets/{utils-BdmIffFy.js → utils-CBwnO3Ef.js} +1 -1
  100. package/dist/assets/{withTransactionSidePanel-CYfRQO6D.js → withTransactionSidePanel-BDwqseEK.js} +1 -1
  101. package/dist/assets/{zeni-epic-state-BRNxIopP.js → zeni-epic-state-CvlYbP8V.js} +4 -4
  102. package/dist/index.html +1 -1
  103. package/package.json +3 -3
  104. package/dist/assets/AddressRoutes-CkFcdLcd.js +0 -1
  105. package/dist/assets/CompanyPassportScreen-tdQzIeXB.js +0 -1
  106. package/dist/assets/CustomerOnboardingAuthScreen-BR_iC0Wz.js +0 -1
  107. package/dist/assets/DomesticWireDetailScreen-Bf63TFDj.js +0 -18
  108. package/dist/assets/DrawerScreen-CNxma0Qg.js +0 -1
  109. package/dist/assets/FeaturePreviewScreen-BvY_XvYQ.js +0 -1
  110. package/dist/assets/MagicLinkSignInScreen-DU96qNSs.js +0 -12
  111. package/dist/assets/NotFoundScreen-Bjeg8OER.js +0 -1
  112. package/dist/assets/OAuthConsentScreen-jazB5K-T.js +0 -1
  113. package/dist/assets/PeopleRoutes-DSMPSkgq.js +0 -22
  114. package/dist/assets/PerformanceRoutes-C40c0t7S.js +0 -1
  115. package/dist/assets/ReferralListScreen-BRzq9B_u.js +0 -5
  116. package/dist/assets/RewardsRoutes-DFbFMPqn.js +0 -1
  117. package/dist/assets/SignInScreen-CPVG_KJo.js +0 -1
  118. package/dist/assets/SignOutScreen-DVvG8cxR.js +0 -9
  119. package/dist/assets/WiseConfirmationScreen-D9d_nucN.js +0 -12
  120. package/dist/assets/epic-Bh9aJ89a.js +0 -2
  121. package/dist/assets/getLocaleForTenant-D9pSDinJ.js +0 -1
  122. package/dist/assets/useAskAiCfoHostNavButtonProps-I9ttKeZb.js +0 -1
@@ -1,4 +1,4 @@
1
- import{j as g}from"./liveblocks-DvqoH3dJ.js";import{a as l}from"./sentry-oCFmppdA.js";import{u as pe,h as he,g as Ce,j as M,i as fe,n as Se}from"./core-BUDfBDzW.js";import{Y as ge,dd as be,z as ye,de as Pe,dg as z,dh as Ie,ba as W,v as we,e as $,di as H,ds as Ee,a as ke,g as Ae,a9 as Te,dl as xe,dm as Ue,a4 as _e,dq as Oe,b6 as ve,dr as Qe}from"./index-9PmElJom.js";import{gl as Fe,eW as G,eX as $e,fq as De,iK as Le,iG as Ve,eY as B,g6 as je,f$ as qe,g3 as N,g7 as Re,g8 as Me,g9 as He,ga as Be,gb as Ne}from"./zeni-epic-state-BRNxIopP.js";import{D as ze,n as L,P as We,S as Ge}from"./mui-BX-eccqP.js";import"./recharts-C3oDuogX.js";import"./analytics-DL3j77s3.js";import"./plaid-C1X6Gp1j.js";import"./dnd-C2uuKLS_.js";import"./stripe-DMRn4zHo.js";import"./lottie-DU31Qsck.js";import"./lexical-BJhq3Vel.js";import"./pdf-SnLRVeGX.js";import"./utils-BdmIffFy.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new e.Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="44ef794f-788a-417a-ad92-59bbb3dd50fb",e._sentryDebugIdIdentifier="sentry-dbid-44ef794f-788a-417a-ad92-59bbb3dd50fb")}catch{}})();const Y="chat-response-generated",K="cards/ask",X="card_policy_hero";function D(e){return`/${e}/cards`}function Z(e){return`/${e}/cards/policy`}const Ye=Se(function(e,a){const o=G(e),c=a.isSubmitting,d=Ue(e,{allUsers:a.allUsers,onCardPolicyVendorSearchTextChange:a.onCardPolicyVendorSearchTextChange});return{showSampleQuestions:a.sessionFromUrl==="new_chat"&&o.uiState.currentChatSessionId==null,aiCfoView:o,isSubmitting:c,isNewChatSession:a.sessionFromUrl==="new_chat",isFullView:!0,tableDownloadEndPoint:`${_e}/tableDownload`,emailLinkQuestion:a.emailLinkQuestion,autoSubmitEmailLinkQuestion:a.autoSubmitEmailLinkQuestion,onEmailLinkQuestionProcessed:a.onEmailLinkQuestionProcessed,isFileUploadEnabled:a.isFileUploadEnabled,isUploadPromoVisible:a.isUploadPromoVisible,onUploadPromoClose:a.onUploadPromoClose,...d}},function(e,a){const{location:o,currentTenant:c,userId:d,navigate:m,currentChatSessionId:h,allSessionsWithOrderedQuestionAnswers:E,isAiCardCreationEnabled:T,isCardPolicyEnabled:x,cardPolicyPageContext:U}=a,i=c.tenantEmailDomain,C=o.state?.referrer,p=C===X?Z(i):D(i);return{onEventReceived:(n,t)=>{if(n===Y&&typeof t.text=="string"&&typeof t.metadata=="object"){const s=t,f=Me(s.type),b=s.metadata.chat_session_id??null,{currentChatSession:y,currentQuestionAnswer:u,currentQuestionAnswerSummary:P}=W(E,b);f!=="answer"?$.trackAICFOChatResponseGenerated(f,u?.question.questionText??"",s.text,b,Qe(P,y),s.metadata.message_id??null):$.trackAICFOChatAnswerGenerated(s.text,u?.question.questionText??"",(s.follow_up_questions?.length??0)>0,!!s.assumptions,!!s.insights,s.visualization!=null,He(s.visualization?.type??"")??null,b,s.summarized_title,s.metadata.message_id??null),e(Be({chatSessionId:s.metadata.chat_session_id,responseType:f,fetchState:{fetchState:"Completed",error:void 0}})),e(Ne({chatSessionId:s.metadata.chat_session_id,answerPayload:s,userId:d}))}},onSubmit:(n,t,s,f)=>{n&&ve(e,n,t,h,E,d,f,s,U)},updateCurrentInput:n=>{e(N(n))},onStopSubmit:()=>{},onUpdateScrollYOffset:n=>{e(Re(n))},onSelectSampleQuestion:()=>{},onBackClick:()=>{m(-1)},onCloseClick:()=>{m(p,{state:{...o.state}}),e(N(""))},togglePageView:()=>{m(p,{state:z(o.state)}),a.setIsAiCfoOpen(!0)},onCopy:()=>{},onThumbsUp:()=>{},onThumbsDown:()=>{},onTogglePageView:()=>{m(-1)},onNewChatClick:()=>{h!=null&&e(qe()),m(function(n){return`/${n}/${K}`}(i),{state:{...o.state}})},onToggleCotCollapsed:(n,t)=>{e(je({questionAnswerId:n,isCollapsed:t}))},...Oe(e,{isAiCardCreationEnabled:T,isCardPolicyEnabled:x,currentChatSessionId:h,onAfterCardsCreationSubmit:()=>{a.setIsAiCfoOpen(!0),m(D(i),{state:{...o.state}})},onAfterCardPolicySubmit:()=>{a.setIsAiCfoOpen(!0),m(`/${i}/cards/policy`,{state:{...o.state}})}})}})(Te(xe)),{spendManagement:{chargeCard:{cardsAiCfoHero:J,cardPolicyAiCfoHero:ee}}}=ke.getLocalizedStrings(),A=J.pageTitle,Ke=ee.pageTitle,Xe=J.chatHeaderSubtitle,Ze=ee.chatHeaderSubtitle,St=({isFileUploadEnabled:e})=>{const{setIsAiCfoOpen:a}=ge(),o=pe(),c=he(),d=Ce(),[m,h]=l.useState(!1),{allUsers:E,isAiCardCreationEnabled:T,isCardPolicyEnabled:x,onCardPolicyVendorSearchTextChange:U}=be();l.useEffect(()=>{o(Fe())},[o]);const i=M(r=>G(r)),C=ye.getSignedInUser(),{session_id:p}=fe(),n=M(r=>$e(r)),t=i.uiState.currentChatSessionId,s=n.tenantEmailDomain,{handleUploadPromoClose:f,isUploadPromoVisible:b}=Pe({isFileUploadEnabled:e,tenantEmailDomain:s}),y=d.state,u=y?.aiCfoInitialQuestion??null,P=!!y?.aiCfoShouldSubmit,I=y?.referrer===X,te=I?"card_policy":void 0,se=l.useMemo(()=>({title:I?Ke:A,subtitle:I?Ze:Xe}),[I]),[ae,_]=l.useState(null),[oe,O]=l.useState(!1),v=l.useRef(!1);l.useEffect(()=>{v.current||u==null||u===""||(_(u),O(P),v.current=!0)},[u,P]);const ne=l.useCallback(()=>{_(null),O(!1),c(d.pathname,{replace:!0,state:z(d.state)})},[d.pathname,d.state,c]),ie=n.masterTOSInfo,S=ie?.isMasterTOSAccepted??!1,k=l.useRef(null);l.useEffect(()=>{if(S&&k.current!=null){const{question:r,shouldSubmit:w}=k.current;k.current=null,_(r),O(w),v.current=!1}},[S]);const{visitedSessions:V}=Ie(t),Q=i.fetchState,F=i.uiState.chatSessionsNextPageToken.hasMore||!i.uiState.chatSessionsFirstPageFetched,j=t!=null?i.fetchChatSessionHistoryByChatSessionId?.[t]?.fetchState??"Not-Started":"Not-Started",q=t==null||(i.uiState.chatHistoryNextPageToken[t]?.hasMore??!0),R=i.allSessionsWithOrderedQuestionAnswers,{currentSessionQuestionAnswers:re}=W(R,t),le=re.length===0;l.useEffect(()=>{t!=null&&p!==t&&c(function(r,w){return`/${r}/${K}/${w}`}(s,t),{state:{...d.state},replace:!0})},[t,p,s,c,d.state]),l.useEffect(()=>{p!=null&&t==null&&p!=="new_chat"&&o(De({sessionId:p,agentId:"controller"}))},[]);const de=l.useMemo(()=>({events:V.map(r=>`private-encrypted-chat-${r}.${Y}`),eventCallback:(r,w,me)=>me.onEventReceived(r,w)}),[V]);if(l.useEffect(()=>{Q!=="In-Progress"&&F&&o(Le())},[Q,F,o]),l.useEffect(()=>{t!=null&&j!=="In-Progress"&&q&&C!=null&&Q==="Completed"&&!F&&o(Ve(t,C.userId))},[j,q,t,C,o]),C==null)throw Error("Can't access Cards AI CFO page without signing in...");const ce=p??"new_chat",ue=t!=null&&i.responseStateByChatSessionId?.[t]?.answer?.fetchState==="In-Progress";return g.jsxs(et,{children:[g.jsx(we,{analytics:$,onLoad:r=>r.trackPageLoaded(Ae.Event.aiCFOPage)}),S?g.jsx(Ye,{...de,currentChatSessionId:t,allSessionsWithOrderedQuestionAnswers:R,allUsers:E,isAiCardCreationEnabled:T,isCardPolicyEnabled:x,openOnboardingPage:()=>h(!0),userId:C.userId,setIsAiCfoOpen:a,navigate:c,sessionFromUrl:ce,location:d,isSubmitting:ue,isEmptyChatWithSession:le,customPageTitle:A,chatHeader:se,currentTenant:n,emailLinkQuestion:ae??void 0,autoSubmitEmailLinkQuestion:oe,onEmailLinkQuestionProcessed:ne,isFileUploadEnabled:e,isUploadPromoVisible:b,onUploadPromoClose:f,onCardPolicyVendorSearchTextChange:U,cardPolicyPageContext:te}):g.jsx(H,{isTOSAccepted:S,acceptMasterTOSState:i.masterTOSAcceptanceState,customPageTitle:A,onCloseClick:()=>{c(I?Z(s):D(s),{state:{...d.state}})},onCompleteClick:()=>{S||n.userRoleId==null||(u!=null&&u!==""&&(k.current={question:u,shouldSubmit:P}),o(B(n.userRoleId)))}}),g.jsx(ze,{anchor:"right",open:m,transitionDuration:250,PaperProps:{component:tt,style:{width:`${Ee}vw`}},slotProps:{backdrop:{style:{backgroundColor:"transparent",cursor:"pointer"}}},onClose:()=>h(!1),children:g.jsx(Je,{onClick:r=>r.stopPropagation(),children:g.jsx(H,{isTOSAccepted:S,acceptMasterTOSState:i.masterTOSAcceptanceState,customPageTitle:A,onCloseClick:()=>h(!1),onCompleteClick:()=>{S||n.userRoleId==null||o(B(n.userRoleId)),h(!1)}})})})]})},Je=L(Ge)`
1
+ import{j as g}from"./liveblocks-D0coviDj.js";import{a as l}from"./sentry-BX7AV8EY.js";import{u as pe,h as he,g as Ce,j as M,i as fe,n as Se}from"./core-PLgxH77Q.js";import{Z as ge,dd as be,z as ye,de as Pe,dg as z,dh as Ie,ba as W,D as we,d as $,di as H,ds as Ee,a as ke,f as Ae,a9 as Te,dl as xe,dm as Ue,a4 as _e,dq as Oe,b6 as ve,dr as Qe}from"./index-DplenJAr.js";import{gl as Fe,eW as G,eX as $e,fq as De,iK as Le,iG as Ve,eY as B,g6 as je,f$ as qe,g3 as N,g7 as Re,g8 as Me,g9 as He,ga as Be,gb as Ne}from"./zeni-epic-state-CvlYbP8V.js";import{D as ze,n as L,P as We,S as Ge}from"./mui-C0RqdtC7.js";import"./recharts-IQlfHMoz.js";import"./analytics-FZZqBV_U.js";import"./plaid-COO6326w.js";import"./dnd-BR185E7x.js";import"./stripe-DMRn4zHo.js";import"./lottie-Cr90j9wu.js";import"./lexical-lY8wPGQT.js";import"./pdf-Aivmor3r.js";import"./utils-CBwnO3Ef.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new e.Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="e38d6b44-5385-41d8-9404-16903ce287a7",e._sentryDebugIdIdentifier="sentry-dbid-e38d6b44-5385-41d8-9404-16903ce287a7")}catch{}})();const Y="chat-response-generated",J="cards/ask",K="card_policy_hero";function D(e){return`/${e}/cards`}function X(e){return`/${e}/cards/policy`}const Ye=Se(function(e,a){const o=G(e),c=a.isSubmitting,d=Ue(e,{allUsers:a.allUsers,onCardPolicyVendorSearchTextChange:a.onCardPolicyVendorSearchTextChange});return{showSampleQuestions:a.sessionFromUrl==="new_chat"&&o.uiState.currentChatSessionId==null,aiCfoView:o,isSubmitting:c,isNewChatSession:a.sessionFromUrl==="new_chat",isFullView:!0,tableDownloadEndPoint:`${_e}/tableDownload`,emailLinkQuestion:a.emailLinkQuestion,autoSubmitEmailLinkQuestion:a.autoSubmitEmailLinkQuestion,onEmailLinkQuestionProcessed:a.onEmailLinkQuestionProcessed,isFileUploadEnabled:a.isFileUploadEnabled,isUploadPromoVisible:a.isUploadPromoVisible,onUploadPromoClose:a.onUploadPromoClose,...d}},function(e,a){const{location:o,currentTenant:c,userId:d,navigate:m,currentChatSessionId:h,allSessionsWithOrderedQuestionAnswers:E,isAiCardCreationEnabled:T,isCardPolicyEnabled:x,cardPolicyPageContext:U}=a,i=c.tenantEmailDomain,C=o.state?.referrer,p=C===K?X(i):D(i);return{onEventReceived:(n,t)=>{if(n===Y&&typeof t.text=="string"&&typeof t.metadata=="object"){const s=t,f=Me(s.type),b=s.metadata.chat_session_id??null,{currentChatSession:y,currentQuestionAnswer:u,currentQuestionAnswerSummary:P}=W(E,b);f!=="answer"?$.trackAICFOChatResponseGenerated(f,u?.question.questionText??"",s.text,b,Qe(P,y),s.metadata.message_id??null):$.trackAICFOChatAnswerGenerated(s.text,u?.question.questionText??"",(s.follow_up_questions?.length??0)>0,!!s.assumptions,!!s.insights,s.visualization!=null,He(s.visualization?.type??"")??null,b,s.summarized_title,s.metadata.message_id??null),e(Be({chatSessionId:s.metadata.chat_session_id,responseType:f,fetchState:{fetchState:"Completed",error:void 0}})),e(Ne({chatSessionId:s.metadata.chat_session_id,answerPayload:s,userId:d}))}},onSubmit:(n,t,s,f)=>{n&&ve(e,n,t,h,E,d,f,s,U)},updateCurrentInput:n=>{e(N(n))},onStopSubmit:()=>{},onUpdateScrollYOffset:n=>{e(Re(n))},onSelectSampleQuestion:()=>{},onBackClick:()=>{m(-1)},onCloseClick:()=>{m(p,{state:{...o.state}}),e(N(""))},togglePageView:()=>{m(p,{state:z(o.state)}),a.setIsAiCfoOpen(!0)},onCopy:()=>{},onThumbsUp:()=>{},onThumbsDown:()=>{},onTogglePageView:()=>{m(-1)},onNewChatClick:()=>{h!=null&&e(qe()),m(function(n){return`/${n}/${J}`}(i),{state:{...o.state}})},onToggleCotCollapsed:(n,t)=>{e(je({questionAnswerId:n,isCollapsed:t}))},...Oe(e,{isAiCardCreationEnabled:T,isCardPolicyEnabled:x,currentChatSessionId:h,onAfterCardsCreationSubmit:()=>{a.setIsAiCfoOpen(!0),m(D(i),{state:{...o.state}})},onAfterCardPolicySubmit:()=>{a.setIsAiCfoOpen(!0),m(`/${i}/cards/policy`,{state:{...o.state}})}})}})(Te(xe)),{spendManagement:{chargeCard:{cardsAiCfoHero:Z,cardPolicyAiCfoHero:ee}}}=ke.getLocalizedStrings(),A=Z.pageTitle,Je=ee.pageTitle,Ke=Z.chatHeaderSubtitle,Xe=ee.chatHeaderSubtitle,St=({isFileUploadEnabled:e})=>{const{setIsAiCfoOpen:a}=ge(),o=pe(),c=he(),d=Ce(),[m,h]=l.useState(!1),{allUsers:E,isAiCardCreationEnabled:T,isCardPolicyEnabled:x,onCardPolicyVendorSearchTextChange:U}=be();l.useEffect(()=>{o(Fe())},[o]);const i=M(r=>G(r)),C=ye.getSignedInUser(),{session_id:p}=fe(),n=M(r=>$e(r)),t=i.uiState.currentChatSessionId,s=n.tenantEmailDomain,{handleUploadPromoClose:f,isUploadPromoVisible:b}=Pe({isFileUploadEnabled:e,tenantEmailDomain:s}),y=d.state,u=y?.aiCfoInitialQuestion??null,P=!!y?.aiCfoShouldSubmit,I=y?.referrer===K,te=I?"card_policy":void 0,se=l.useMemo(()=>({title:I?Je:A,subtitle:I?Xe:Ke}),[I]),[ae,_]=l.useState(null),[oe,O]=l.useState(!1),v=l.useRef(!1);l.useEffect(()=>{v.current||u==null||u===""||(_(u),O(P),v.current=!0)},[u,P]);const ne=l.useCallback(()=>{_(null),O(!1),c(d.pathname,{replace:!0,state:z(d.state)})},[d.pathname,d.state,c]),ie=n.masterTOSInfo,S=ie?.isMasterTOSAccepted??!1,k=l.useRef(null);l.useEffect(()=>{if(S&&k.current!=null){const{question:r,shouldSubmit:w}=k.current;k.current=null,_(r),O(w),v.current=!1}},[S]);const{visitedSessions:V}=Ie(t),Q=i.fetchState,F=i.uiState.chatSessionsNextPageToken.hasMore||!i.uiState.chatSessionsFirstPageFetched,j=t!=null?i.fetchChatSessionHistoryByChatSessionId?.[t]?.fetchState??"Not-Started":"Not-Started",q=t==null||(i.uiState.chatHistoryNextPageToken[t]?.hasMore??!0),R=i.allSessionsWithOrderedQuestionAnswers,{currentSessionQuestionAnswers:re}=W(R,t),le=re.length===0;l.useEffect(()=>{t!=null&&p!==t&&c(function(r,w){return`/${r}/${J}/${w}`}(s,t),{state:{...d.state},replace:!0})},[t,p,s,c,d.state]),l.useEffect(()=>{p!=null&&t==null&&p!=="new_chat"&&o(De({sessionId:p,agentId:"controller"}))},[]);const de=l.useMemo(()=>({events:V.map(r=>`private-encrypted-chat-${r}.${Y}`),eventCallback:(r,w,me)=>me.onEventReceived(r,w)}),[V]);if(l.useEffect(()=>{Q!=="In-Progress"&&F&&o(Le())},[Q,F,o]),l.useEffect(()=>{t!=null&&j!=="In-Progress"&&q&&C!=null&&Q==="Completed"&&!F&&o(Ve(t,C.userId))},[j,q,t,C,o]),C==null)throw Error("Can't access Cards AI CFO page without signing in...");const ce=p??"new_chat",ue=t!=null&&i.responseStateByChatSessionId?.[t]?.answer?.fetchState==="In-Progress";return g.jsxs(et,{children:[g.jsx(we,{analytics:$,onLoad:r=>r.trackPageLoaded(Ae.Event.aiCFOPage)}),S?g.jsx(Ye,{...de,currentChatSessionId:t,allSessionsWithOrderedQuestionAnswers:R,allUsers:E,isAiCardCreationEnabled:T,isCardPolicyEnabled:x,openOnboardingPage:()=>h(!0),userId:C.userId,setIsAiCfoOpen:a,navigate:c,sessionFromUrl:ce,location:d,isSubmitting:ue,isEmptyChatWithSession:le,customPageTitle:A,chatHeader:se,currentTenant:n,emailLinkQuestion:ae??void 0,autoSubmitEmailLinkQuestion:oe,onEmailLinkQuestionProcessed:ne,isFileUploadEnabled:e,isUploadPromoVisible:b,onUploadPromoClose:f,onCardPolicyVendorSearchTextChange:U,cardPolicyPageContext:te}):g.jsx(H,{isTOSAccepted:S,acceptMasterTOSState:i.masterTOSAcceptanceState,customPageTitle:A,onCloseClick:()=>{c(I?X(s):D(s),{state:{...d.state}})},onCompleteClick:()=>{S||n.userRoleId==null||(u!=null&&u!==""&&(k.current={question:u,shouldSubmit:P}),o(B(n.userRoleId)))}}),g.jsx(ze,{anchor:"right",open:m,transitionDuration:250,PaperProps:{component:tt,style:{width:`${Ee}vw`}},slotProps:{backdrop:{style:{backgroundColor:"transparent",cursor:"pointer"}}},onClose:()=>h(!1),children:g.jsx(Ze,{onClick:r=>r.stopPropagation(),children:g.jsx(H,{isTOSAccepted:S,acceptMasterTOSState:i.masterTOSAcceptanceState,customPageTitle:A,onCloseClick:()=>h(!1),onCompleteClick:()=>{S||n.userRoleId==null||o(B(n.userRoleId)),h(!1)}})})})]})},Ze=L(Ge)`
2
2
  display: flex;
3
3
  min-height: 100%;
4
4
  flex-direction: column;
@@ -1,4 +1,4 @@
1
- import{j as c}from"./liveblocks-DvqoH3dJ.js";import{u as me,j as i,h as le,g as he,i as Ve,N as Xe,s as _t,n as Pe,t as _n,o as cs,p as ce}from"./core-BUDfBDzW.js";import{f8 as Pt,RW as os,fk as wt,bt as Fe,RX as is,RY as ds,eZ as fn,RZ as Pn,f6 as wn,R_ as vn,R$ as Tn,S0 as Fn,S1 as xn,f7 as Bn,fj as Ln,S2 as Rn,S3 as ls,fd as us,fc as ms,S4 as Cs,C5 as On,fm as ia,S5 as ps,S6 as hs,e$ as fs,e_ as gs,fz as Ye,ff as Un,fe as jn,S7 as Ss,fg as bs,BC as ys,BB as Is,BF as ks,BH as Es,fs as As,eW as Mn,S8 as Ds,S9 as _s,fx as Nn,Sa as Ps,fy as yt,BN as ws,BK as vs,eX as ge,Sb as qa,fC as xe,fD as Be,fE as Le,gw as da,cv as la,Sc as ua,Sd as vt,uT as $a,kF as za,Se as Ya,Cl as ka,fn as Qe,Cn as Tt,kv as Vn,Sf as ma,C9 as _a,Sg as Ts,Sh as Fs,Cc as Qa,Si as xs,Qi as Xa,fi as Hn,Ci as Sa,hV as Bs,Sj as Gn,f9 as Ca,bo as Ls,Sk as Rs,gh as Ja,gg as et,CR as Os,gf as at,P_ as Us,Sl as $n,co as zn,cQ as js,Qh as wa,Dq as Yn,Sm as gn,D0 as Pa,Sn as Wn,Dr as Ms,QG as Ns,Ds as Vs,Ex as Hs,ub as Gs,Er as $s,So as zs,Cm as ca,Sp as Ys,Sq as Ws,Sr as Zs,Ss as Ks,St as qs,Su as Ft,Sv as Qs,CC as Zn,Cv as Xs,Sw as Js,gy as ec,CL as Kn,CP as qn,gx as ac,Sx as tc,Dc as Qn,Sy as nc,Sz as rc,SA as sc,CN as Xn,Cy as Jn,Cf as er,CH as ar,CF as tr,CJ as cc,SB as nr,SC as oc,fu as ic,fv as dc,fw as lc,SD as tt,fo as rr,cS as xt,SE as uc,SF as mc,SG as Cc,SH as pc,CX as It,Dj as hc,Df as fc,CT as gc,Dh as Sc,D7 as bc,D9 as yc,SI as sr,Dp as Ga,Kg as Ic,SJ as kc,SK as Ec,SL as Ac,SM as cr,SN as Dc,DM as _c,C$ as or,CW as Ne,C_ as Pc,SO as wc,SP as vc,C6 as Tc,SQ as ir,fh as dr,SR as Fc,C8 as xc,C7 as Sn,SS as Bc,ST as Lc,SU as Rc,MN as Oc,SV as Bt,SW as Uc,xU as lr,ld as jc,hL as Mc,DR as Nc,SX as ur,f3 as Vc,f4 as Hc,SY as Gc,dj as $c,fl as zc,DH as Yc,DB as qe,bs as Wc,bJ as Zc,cA as Kc,bK as qc,L_ as Qc}from"./zeni-epic-state-BRNxIopP.js";import{I as Re,cr as mr,q as we,cs as Cr,ct as pr,cu as Xc,a as ea,a0 as Lt,cv as Jc,cw as eo,Y as hr,c as fr,$ as gr,r as ye,C as ue,G as W,ar as ya,cx as Sr,cy as ao,cz as to,z as te,B as va,cg as nt,cA as no,cB as ro,cC as so,K as Ta,aS as We,bt as Rt,cD as co,D as Fa,k as rt,y as Ot,e as J,a9 as st,cE as oo,bG as ba,cF as kt,cG as io,v as Ut,cH as lo,au as br,a4 as Et,cI as uo,Z as yr,F as Ir,g as kr,cJ as mo,cK as Co,cL as po,cM as ho,cN as fo,cO as go,cP as So,o as Wa,cQ as bo,cR as yo,cS as ht,H as Io,cT as ko,cU as Eo,cV as Ao,cW as Do,cX as _o,i as Po}from"./index-9PmElJom.js";import{n as He,D as Er,S as wo}from"./mui-BX-eccqP.js";import{a as r}from"./sentry-oCFmppdA.js";import{u as xa}from"./useAskAiCfoHostNavButtonProps-I9ttKeZb.js";import{M as Ie}from"./MobileAppDrawer-BLdyZXBV.js";import{d as jt}from"./recharts-C3oDuogX.js";import{g as _e,a as Ba,b as Ar,c as Oe,d as Ue,e as Je,f as aa,h as ta,A as vo,i as Mt,P as To,j as Nt,s as Ia,k as Dr,l as oa,m as _r,n as Fo,o as Pr,p as xo,S as bn}from"./SetupPagesScreen-Dux5L0dD.js";import{u as wr}from"./useInitialThreadRequest-DfW2emMG.js";import ct from"./NotFoundScreen-Bjeg8OER.js";import{u as Vt}from"./useChargeCardPusherEvents-Cb-4seWD.js";import{n as yn}from"./utils-BdmIffFy.js";import{t as Bo}from"./AddressScreen-4qRIlnK-.js";import"./analytics-DL3j77s3.js";import"./plaid-C1X6Gp1j.js";import"./dnd-C2uuKLS_.js";import"./stripe-DMRn4zHo.js";import"./lottie-DU31Qsck.js";import"./lexical-BJhq3Vel.js";import"./pdf-SnLRVeGX.js";import"./analyticsHelper-BLQhTmmj.js";import"./routePaths-BPZ60_ul.js";import"./BusinessVerificationPageScreen-BfTuFBnf.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="4eced434-10dc-446e-855e-26d5028ca7d3",e._sentryDebugIdIdentifier="sentry-dbid-4eced434-10dc-446e-855e-26d5028ca7d3")}catch{}})();const Lo=e=>{const n=e.cardHolderUser,t=`${n.firstName??""} ${n.lastName??""}`.trim()||n.email||n.userId;return{userId:n.userId,displayName:t,roleLabel:e.cardHolderRoles?.titleAtCompany}},vr=e=>({id:e.id,isChecked:!1,cardName:e.cardName,last4:e.accountLast4,limitAmount:e.limit?.amount??0,limitCadence:e.creditLimitFrequency?.code,owner:Lo(e),utilizationAmount:(e.limit?.amount??0)-(e.available?.amount??0)});function Tr(){const e=me(),n=i(a=>Pt(a.cardPolicyState)),t=i(a=>os(a.cardPolicyState));r.useEffect(()=>{t!==""||n==="Completed"&&t===""||n==="In-Progress"||e(wt())},[e,n,t])}const{spendManagement:{chargeCard:{cardPolicyPage:In}}}=ea.getLocalizedStrings(),Ro=e=>Un(e,!1),Oo=e=>jn(e.name,!1);function Uo(){const e=le(),n=he(),{tenantEmailDomain:t}=Ve(),a=me(),s=Re(),y=Fe(s?.loggedInUserRoleMap),[g,S]=r.useState(!1),P=r.useCallback(E=>{S(E)},[]),m=r.useCallback(()=>{P(!0)},[P]),{isAiCfoAccessEnabled:C,onAskAiCfoClick:F}=xa({mobileExploreReferrer:"Card Policy"});r.useEffect(()=>()=>{a(is()),a(ds()),a(fn())},[a]);const w=i(E=>Pn(E.cardPolicyState)),l=i(E=>wn(E.cardPolicyState)),j=i(E=>vn(E.cardPolicyState)),B=i(E=>Tn(E.cardPolicyState)),L=i(E=>Fn(E.cardPolicyState)),p=i(E=>xn(E.cardPolicyState)),h=i(E=>Bn(E.cardPolicyState)),T=i(E=>Pt(E.cardPolicyState)),u=i(E=>E.chargeCardConfigState.receiptRequiredAboveAmount.amount),v=i(E=>E.chargeCardConfigState.fetchState);r.useEffect(()=>{w!=="Completed"&&w!=="In-Progress"&&a(Ln())},[a,w]),Tr();const k=i(E=>Rn(E.createCardPolicyState)),U=i(E=>ls(E.createCardPolicyState)),A=i(E=>us(E.cardPolicyState)),b=i(E=>ms(E.cardPolicyState)),x=i(E=>Cs(E.createCardPolicyState)),d=i(E=>On(E));r.useEffect(()=>{d.fetchState==="Not-Started"&&a(ia(!1,!1,!1))},[d.fetchState,a]);const f=r.useMemo(()=>l.map(Ro),[l]),M=r.useMemo(()=>h.map(Oo),[h]),V=r.useMemo(()=>d.cards.filter(E=>!mr(E.status.code)).map(vr),[d.cards]),O=w==="Completed"&&d.fetchState==="Completed"&&v==="Completed";r.useEffect(()=>{O&&x==null&&a(ps({cardsMasterList:V,defaultRequireReceiptAmount:u,suggestedAllowMerchants:j,suggestedBlockMerchants:B,suggestedAllowCategories:L,suggestedBlockCategories:p}))},[v,a,O,x,V,u,j,B,L,p]);const R=r.useMemo(()=>jt(E=>{a(wt(E))},250),[a]);r.useEffect(()=>()=>{R.cancel()},[R]);const z=r.useCallback(E=>{R(E)},[R]),$=k.fetchState,_=t!=null?`/${t}/cards/policy`:"..",D=r.useCallback(()=>{const E=we(n.state?.pathnameStackToGoBack),K=E.poppedPathname??_;e(K,{state:{pathnameStackToGoBack:E.newStack}})},[n.state,e,_]),G=r.useCallback(()=>{e(_)},[e,_]),Q=r.useCallback(E=>{a(hs(E))},[a]),I=r.useCallback(E=>{const K=Cr(E);a(fs({templates:[K]}))},[a]),N=r.useCallback(E=>{E.length!==0&&a(gs(E))},[a]),Z=r.useCallback(()=>{a(fn())},[a]),X=r.useRef($);r.useEffect(()=>{const E=X.current;X.current=$,$==="Completed"&&E!=="Completed"&&U!=null&&(a(Ye({messageSection:"card_policy_created",messageText:"success",type:"success"})),e(_))},[a,$,U,e,_]);const o=$==="Error"?k.error?.message??In.createPolicyGenericErrorMessage:void 0;return y&&t!=null?x==null?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:P}),c.jsx(pr,{showUploadDocumentSection:!0,navBarTitle:In.createPageTitle,onBackClick:D,onClickMenuIcon:m,isAiCfoAccessEnabled:C,onAskAiCfoClick:F})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:P}),c.jsx(Xc,{formDraft:x,vendorSearchOptions:M,categorySearchOptions:f,isVendorSearchLoading:T==="In-Progress",onVendorSearchTextChange:z,submitState:$,submitErrorMessage:o,documentUploadState:A,uploadedFileName:b,isAiCfoAccessEnabled:C,onAskAiCfoClick:F,onBackClick:D,onCancelClick:G,onClickMenuIcon:m,onFormChange:Q,onSubmit:I,onUploadDocument:N,onRemoveDocument:Z})]}):c.jsx(Xe,{to:"..",replace:!0})}const{spendManagement:{chargeCard:{cardPolicyPage:jo}}}=ea.getLocalizedStrings(),Mo=e=>Un(e,!1),No=e=>jn(e.name,!1);function Vo(){const e=le(),n=he(),{tenantEmailDomain:t,templateId:a}=Ve(),s=me(),y=Re(),g=Fe(y?.loggedInUserRoleMap),[S,P]=r.useState(!1),m=r.useCallback(o=>{P(o)},[]),C=r.useCallback(()=>{m(!0)},[m]),{isAiCfoAccessEnabled:F,onAskAiCfoClick:w}=xa({mobileExploreReferrer:"Card Policy"}),l=i(o=>Ss(o)),j=i(o=>Pn(o.cardPolicyState)),B=i(o=>wn(o.cardPolicyState)),L=i(o=>vn(o.cardPolicyState)),p=i(o=>Tn(o.cardPolicyState)),h=i(o=>Fn(o.cardPolicyState)),T=i(o=>xn(o.cardPolicyState)),u=i(o=>Bn(o.cardPolicyState)),v=i(o=>Pt(o.cardPolicyState)),k=i(o=>On(o)),U=i(o=>a!=null?bs(o.cardPolicyState,a):void 0),A=r.useMemo(()=>l.templateId===a&&l.formDraft!=null?l.formDraft:U!=null?ys(U):void 0,[l.templateId,l.formDraft,U,a]);r.useEffect(()=>{if(a==null)return;const o=l.detailFetchState.fetchState;l.templateId===a&&(o==="Completed"||o==="In-Progress")||U!=null||s(Is(a))},[s,a,l.templateId,l.detailFetchState.fetchState,U]),r.useEffect(()=>{j!=="Completed"&&j!=="In-Progress"&&s(Ln())},[s,j]),Tr();const b=i(o=>o.chargeCardConfigState.receiptRequiredAboveAmount.amount);r.useEffect(()=>{k.fetchState==="Not-Started"&&s(ia(!1,!1,!1))},[k.fetchState,s]);const x=r.useMemo(()=>B.map(Mo),[B]),d=r.useMemo(()=>u.map(No),[u]),f=r.useMemo(()=>k.cards.filter(o=>!mr(o.status.code)).map(vr),[k.cards]);Lt({isDataReady:A!=null});const M=r.useMemo(()=>{if(A!=null)return Jc({draft:A,cardRows:f,categorySearchOptions:x,vendorSearchOptions:d,defaultRequireReceiptAmount:b,suggestedAllowMerchants:L,suggestedBlockMerchants:p,suggestedAllowCategories:h,suggestedBlockCategories:T})},[A,f,x,d,b,L,p,h,T]),[V,O]=r.useState(void 0),R=r.useRef(!1);r.useEffect(()=>{R.current||V!=null||M==null||(R.current=!0,O(M))},[V,M]);const z=r.useCallback(o=>{O(o)},[]),$=r.useMemo(()=>jt(o=>{s(wt(o))},250),[s]);r.useEffect(()=>()=>{$.cancel()},[$]);const _=r.useCallback(o=>{$(o)},[$]),D=l.updateFetchState.fetchState,G=t!=null?`/${t}/cards/policy`:"..",Q=r.useCallback(()=>{const o=we(n.state?.pathnameStackToGoBack),E=o.poppedPathname??G;e(E,{state:{pathnameStackToGoBack:o.newStack}})},[n.state,e,G]),I=r.useCallback(()=>{e(G)},[e,G]),N=r.useCallback(o=>{if(a==null)return;const E=Cr(o);s(ks(E)),s(Es(a))},[s,a]),Z=r.useRef(D);r.useEffect(()=>{const o=Z.current;Z.current=D,D==="Completed"&&o!=="Completed"&&(s(Ye({messageSection:"card_policy_updated",messageText:"success",type:"success"})),e(G))},[s,D,e,G]);const X=D==="Error"?l.updateFetchState.error?.message??jo.updatePolicyGenericErrorMessage:void 0;return!g||t==null||a==null?c.jsx(Xe,{to:"..",replace:!0}):V!=null&&j==="Completed"&&k.fetchState==="Completed"?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:m}),c.jsx(eo,{templateName:l.template?.name??"",formDraft:V,vendorSearchOptions:d,categorySearchOptions:x,isVendorSearchLoading:v==="In-Progress",onVendorSearchTextChange:_,submitState:D,submitErrorMessage:X,isAiCfoAccessEnabled:F,onAskAiCfoClick:w,onBackClick:Q,onCancelClick:I,onClickMenuIcon:C,onFormChange:z,onSubmit:N})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:m}),c.jsx(pr,{showUploadDocumentSection:!1,navBarTitle:l.template?.name,onBackClick:Q,onClickMenuIcon:C,isAiCfoAccessEnabled:F,onAskAiCfoClick:w})]})}function Fr(e,n,t){return n?e.filter(a=>a!=null&&a.trim().length>0).slice(0,t):[]}function xr(e){return i(n=>e==null||e===""?{chips:ft,isResolved:!1}:function(t){const a=t?.fetchState,s=a==="Completed"||a==="Error";return{chips:a==="Completed"?t?.suggestedQuestions??ft:ft,isResolved:s}}(As(n,e)),_t)}const ft=[],{spendManagement:{chargeCard:{cardPolicyAiCfoHero:{headline:Ho,subheadline:Go,pageTitle:$o}}}}=ea.getLocalizedStrings(),zo=e=>{const n=e.cardsCount>0?e.cardsCount:e.appliedCards.length,t=e.allowedEntity.merchantNames.length+e.blockedEntity.merchantNames.length,a=e.allowedEntity.categoryCodes.length+e.blockedEntity.categoryCodes.length;return{templateId:e.templateId,name:e.name,description:e.description,mode:e.mode==="flexible"?"flexible":"strict",createdAtFormatted:e.createdAt.format("ll"),cardsCount:n,vendorRestrictionsCount:t,categoryRestrictionsCount:a}};function Yo(){const e=le(),n=he(),{tenantEmailDomain:t}=Ve(),a=me(),s=Re(),y=Fe(s?.loggedInUserRoleMap),[g,S]=r.useState(!1),P=r.useCallback(_=>{S(_)},[]),m=r.useCallback(()=>{P(!0)},[P]),{useFeatureGate:C}=ue(),{isFeatureEnabled:F}=C(W.isAiCfoFileUploadEnabled),{isFeatureEnabled:w}=C(W.isCardPolicyEnabled),{isAiCfoAccessEnabled:l,onAskAiCfoClick:j}=xa({mobileExploreReferrer:"Card Policy"}),B=i(_=>Ds(_)),L=i(_=>Rn(_.createCardPolicyState)),p=i(_=>_s(_.createCardPolicyState)),h=i(_=>p==null?[]:Nn(_.aiCfoState,p).filter(D=>D.kind==="creating_policy"),_t),T=L.fetchState==="In-Progress"?Math.max(h.length,1):0,u=i(_=>Ps(_.createCardPolicyState)),v=ya(L.fetchState);r.useEffect(()=>{if(v==="In-Progress"&&L.fetchState==="Completed"&&p!=null)h.forEach(_=>{a(yt({chatSessionId:p,id:_.id,entityIds:u,kind:"created_policy"}))});else if(v==="In-Progress"&&L.fetchState==="Error"&&p!=null){h.forEach(D=>{a(yt({chatSessionId:p,id:D.id,kind:"errored_policy"}))});const _=L.error?.message!=null&&L.error.message.length>0?L.error.message:ea.getLocalizedStrings().common.errorMessage.somethingWentWrongPleaseTryAgain;a(Ye({messageSection:"card_policy_created",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:_}]}))}},[L.error?.message,L.fetchState,a,p,u,h,v]);const k=B.fetchState.fetchState;r.useEffect(()=>{k!=="Not-Started"&&k!=="Error"||a(ws())},[a,k]);const U=B.archiveFetchState.fetchState,A=ya(U);r.useEffect(()=>{A==="In-Progress"&&U==="Completed"&&a(Ye({messageSection:"card_policy_deleted",messageText:"success",type:"success"}))},[U,a,A]);const b=r.useMemo(()=>B.templates.map(zo),[B.templates]);Lt({isDataReady:B.fetchState.fetchState==="Completed"});const x=b.length>0||T>0,d=function(_){const{hasAnyPolicies:D,isChargeCardAdmin:G,isFileUploadEnabled:Q}=_,I=le(),N=he(),{tenantEmailDomain:Z}=Ve(),{isAiCfoOpen:X,setIsAiCfoOpen:o}=hr(),E=fr(),K=gr(),ne=i(oe=>Mn(oe)).createSessionAndSubmitState.fetchState==="In-Progress",{chips:q,isResolved:ke}=xr("card_policy"),ve=r.useMemo(()=>Fr(q,ke,3),[q,ke]),[fe,se]=r.useState(""),Ee=K&&E&&Z!=null&&!X,re=r.useCallback(oe=>{if(Z==null)return;const fa=ye(N.state?.pathnameStackToGoBack,N.pathname);I(`/${Z}/cards/ask`,{state:{message:"",origin:"",pathnameStackToGoBack:fa,referrer:"card_policy_hero",aiCfoInitialQuestion:oe,aiCfoShouldSubmit:oe!=null&&oe.trim().length>0}})},[N.pathname,N.state,I,Z]),Ce=r.useCallback(oe=>{oe.trim().length!==0&&(se(""),re(oe))},[re]),Ae=r.useCallback(()=>{const oe=fe.trim();oe.length!==0&&(se(""),re(oe))},[fe,re]),ee=r.useCallback(()=>{},[]),Te=r.useCallback(oe=>{se(oe)},[]),De=r.useCallback(()=>{o(!0)},[o]),ae=r.useCallback(()=>{re(void 0)},[re]);return r.useMemo(()=>{if(Ee&&!D&&G)return{aiAgentName:$o,headline:Ho,subheadline:Go,promptChips:ve,composer:{currentInput:fe,isSubmitting:ne,isFileUploadEnabled:Q,onInputChange:Te,onSubmit:Ae,onStopSubmit:ee},onPromptClick:Ce,onOpenSidePanel:De,onOpenFullView:ae,dataTestIdPrefix:"card-policy-ai-cfo-hero"}},[fe,D,Ee,G,Q,ne,Te,ae,De,Ce,ee,Ae,ve])}({hasAnyPolicies:x,isChargeCardAdmin:y,isFileUploadEnabled:F}),f=w&&d!=null?c.jsx(Sr,{...d}):null,M=l&&f==null,V=r.useCallback(()=>{const _=we(n.state?.pathnameStackToGoBack),D=_.poppedPathname??"..";e(D,{state:{pathnameStackToGoBack:_.newStack}})},[n.state,e]),O=r.useCallback(()=>{t!=null&&e(`/${t}/cards/policy/new`)},[e,t]),R=r.useCallback(_=>{t!=null&&e(`/${t}/cards/policy/${_}/edit`)},[e,t]),z=r.useCallback(_=>{a(vs(_))},[a]),$=B.fetchState.fetchState;return!x&&$!=="Completed"&&$!=="Error"?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:P}),c.jsx(ao,{onBackClick:V,onNewPolicyClick:O,onClickMenuIcon:m,isAiCfoAccessEnabled:l,onAskAiCfoClick:j})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:P}),c.jsx(to,{policies:b,archivingTemplateId:B.archiveTargetTemplateId,pendingCreationCount:T,onBackClick:V,onNewPolicyClick:O,onEditPolicyClick:R,onArchivePolicyClick:z,onClickMenuIcon:m,policyAiCfoHero:f,isAiCfoAccessEnabled:M,onAskAiCfoClick:j})]})}function Wo(){const e=le(),{cardId:n}=Ve(),t=me(),a=te.getSignedInUser(),s=i(q=>ge(q)),y=Re(),g=Fe(y?.loggedInUserRoleMap),{useFeatureGate:S}=ue();if(a==null)throw Error("Can't access Add To Wallet Page without signing in...");const[P,m]=r.useState(!1),C=i(q=>qa(q).firstViewAfterActivation);if(n==null)throw Error("Empty card id is not valid...");const F=s.userRole.includes("charge_card_user"),{isFeatureEnabled:w}=S(W.isChargeCardFeatureEnabled),l=!!s.companyChargeCardInfo?.info?.isChargeCardEnabled,{isFeatureEnabled:j}=S(W.isDebitCardFeatureEnabled),B=xe(s),L=Be(s),p=Le(j,s),h=s.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,T=Oe({isDebitCardFeatureEnabled:j,isBankingOnlyTenant:p}),u=Ue({isCardsOnlyTenant:B,isChargeCardFeatureEnabled:w,isBookKeepingTenant:L,isDebitCardProductVisible:T,chargeCardsCreditAccountLimit:h}),v=!!s.companyDebitCardInfo?.info?.isDebitCardEnabled,k=i(q=>da(q,s.companyId)),U=la(k.controllers),{creditAccount:A,creditAccountRepayment:b}=i(q=>ua(q)),x=i(q=>q.classListState.fetchState),d=!F&&u&&l,f=i(q=>vt(q,n,d,u)),[M,V]=r.useState(!1),O=f.chargeCard,R=O?.cardCreatedByUser?.userId,z=i(q=>R!=null?$a(q.userRoleState,R):void 0),$=z?.accountingClassIDs[0],_=i(q=>$!=null?za(q.classState,{classId:$,reportId:"class_list"}):void 0),D=O?.cardHolderUser?.userId,G=i(q=>D!=null?$a(q.userRoleState,D):void 0),Q=G?.accountingClassIDs[0],I=i(q=>Q!=null?za(q.classState,{classId:Q,reportId:"class_list"}):void 0),N=O?.type.code==="business_physical_credit_card"||O?.type.code==="business_physical_debit_card",Z=O?.type.code==="business_physical_debit_card";r.useEffect(()=>{C&&P===!1&&N&&(m(!0),setTimeout(()=>{t(Ya()),Z&&t(Ye({messageSection:"set_debit_card_pin",messageText:"success",type:"success",showStatusIcon:!0}))},5e3))},[C,P,N,Z]),r.useEffect(()=>{M||f.fetchState==="Completed"||f.fetchState==="In-Progress"||n==null||(V(!0),t(ka(n,d,!1)))},[M,f,n,t]),r.useEffect(()=>{if(f.fetchState==="Completed"&&(N===!1||N&&O?.status?.code!=="active"||O?.cardHolderUserId!==a.userId||C===!1&&P===!1||O?.type.code==="business_physical_debit_card"||O?.type.code==="business_virtual_debit_card")){const q=_e(s.tenantEmailDomain,n,a,O,C);e(q)}},[f.fetchState,C,N]),r.useEffect(()=>{A.fetchState!=="Completed"&&A.fetchState!=="In-Progress"&&u&&l&&g&&t(Qe()),b.fetchState!=="Completed"&&b.fetchState!=="In-Progress"&&u&&l&&g&&t(Tt()),x!=="Completed"&&x!=="In-Progress"&&t(Vn())},[A.fetchState,b.fetchState,t,u,l,g,x]);const X=()=>{if(a!=null&&n!=null){t(Ya());const q=_e(s.tenantEmailDomain,n,a);e(q)}},o=O?.type.code==="business_physical_debit_card"||O?.type.code==="business_virtual_debit_card",E=Je(u,T,v,l),K=Ba(u,l,g,A,b),ne=Ar(o,f);return f.fetchState!=="Completed"?c.jsx(va,{fetchState:"In-Progress"}):c.jsxs(c.Fragment,{children:[c.jsx(nt,{showConfetti:C}),c.jsx(no,{onGotItClick:X,isDebitCard:O?.type.code==="business_physical_debit_card",controllerEmails:U,isChargeCardFeatureEnabled:u,isDebitCardFeatureEnabled:T,isDebitCardSetupEnabled:v,isChargeCardSetupEnabled:l,productInformation:E,creditAccountInformation:K,debitAccountInformation:ne,chargeCardDetailView:f,creditAccount:A,classListFetchState:x,creditAccountRepayment:b,cardIssuedByRoles:z?.userRoles,cardIssuedByDepartmentName:_?.className,cardHolderRoles:G?.userRoles,cardHolderDepartmentName:I?.className})]})}const Br="charge-card-transaction-update",Lr="charge-card-transaction-created",Rr="charge-card-transaction-declined",Or="charge-card-transaction-updated",Ur="charge-card-transaction-receipt-uploaded",pa="charge-card-status-update",Ht="charge-card-spending-updated",ot="credit-account-balance-updated",it="charge-card-created",Gt="charge-card-limit-updated",$t="charge-card-limit-reset",zt="charge-card-renamed",Zo="charge-card-department-updated",jr="charge-card-repayment-completed",Mr="charge-card-payment-date-updated",La="charge-card-cashback-redeemed",Ra="charge-card-cashback-earned",ha=(e,n)=>e==null||e===""?[]:n.map(t=>`private-encrypted-${e}.${t}`),Ko=[Ra,La],qo=Pe(function(e){const n=ma(e);return{insightsData:n.insight,cashbackByPeriod:n.cashbackByPeriod,uiState:n.uiState,cashbackSummary:n.cashbackSummary}},function(e){return{onColumnSortConfigChanged:(n,t)=>{e(Ts({uiState:{sortKey:n,sortOrder:t}}))}}})(so);function Qo(){const e=le(),n=me(),t=he(),a=te.getSignedInUser(),s=i(j=>ge(j)),{useFeatureGate:y}=ue(),{isFeatureEnabled:g}=y(W.isCardsCommentingEnabled),[S,P]=r.useState(!1),m=i(j=>ma(j)),C=wr(s.companyId,{clearParams:m.fetchState==="Completed"}),F=r.useCallback(()=>{const j=we(t.state?.pathnameStackToGoBack),B=j.poppedPathname??Xo(s.tenantEmailDomain);e(B,{state:{pathnameStackToGoBack:j.newStack}})},[e,t,s.tenantEmailDomain]),w=aa(s);if(Vt({events:ha(w,Ko),onEvent:j=>{switch(j){case Ra:case La:return void n(_a(!0))}},onSubscribed:()=>{n(_a(!0))}}),r.useEffect(()=>{S||m.fetchState==="Completed"||m.fetchState==="In-Progress"||(P(!0),n(_a()))},[S,m,n]),a==null)throw Error("Can't access cashback detail page without signing in...");const l=m.cashbackSummary?.cashbackEarned?.amount!=null&&m.fetchState!=="Not-Started";return m.fetchState!=="In-Progress"||l?(m.cashbackSummary?.cashbackEarned?.amount??0)===0&&m.fetchState==="Completed"?c.jsx(ct,{}):c.jsx(qo,{onBackClick:F,isCardsCommentingEnabled:g,initialOpenThreadRequest:C}):c.jsx(ro,{onBackClick:F})}const Xo=e=>`/${e}/cards`,Jo={containerWidth:new Fa(100,58)},ei=({appContent:e})=>{const n=Ta(),t=me(),a=le(),{cardId:s}=Ve(),y=he(),{useDynamicConfig:g}=ue(),[S,P]=r.useState(!1),[m,C]=r.useState(!1),[F,w]=r.useState(!1),[l,j]=r.useState(!1),B=te.getSignedInUser();if(B==null)throw Error("Can't access onboarding card page without signing in...");const L=i(I=>ge(I));if(s==null)throw Error("Empty card id is not valid...");const{configValue:p}=g(We.zeniCardsConfig),h=p.max_charge_card_activation_attempts_by_card_id,T=i(I=>Fs(I,s)),u=T.chargeCard,v=i(I=>I.chargeCardConfigState.fetchState),{useFeatureGate:k}=ue(),{isFeatureEnabled:U}=k(W.isChargeCardFeatureEnabled),{isFeatureEnabled:A}=k(W.isDebitCardFeatureEnabled),b=Le(A,L),x=Oe({isDebitCardFeatureEnabled:A,isBankingOnlyTenant:b}),d=!!L.companyChargeCardInfo?.info?.isChargeCardEnabled,f=L.userRole.includes("charge_card_user"),M=xe(L),V=Be(L),O=L.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,R=Ue({isCardsOnlyTenant:M,isChargeCardFeatureEnabled:U,isBookKeepingTenant:V,isDebitCardProductVisible:x,chargeCardsCreditAccountLimit:O}),z=!f&&R&&d;r.useEffect(()=>{S===!1&&v!=="In-Progress"&&v!=="Completed"&&(t(Qa()),P(!0)),m===!1&&T.fetchState==="Not-Started"&&(C(!0),t(ka(s,z,R)))},[m,T.fetchState,S,v]);const $=u?.type.code==="business_physical_credit_card"||u?.type.code==="business_physical_debit_card";r.useEffect(()=>{if(T.fetchState==="Completed"){if(F===!1&&($===!1||$&&u?.status?.code!=="inactive"||u?.cardHolderUserId!==B.userId)){const I=_e(L.tenantEmailDomain,s,B,u,!0),N=ye(y.state?.pathnameStackToGoBack,y.pathname);a(I,{state:{pathnameStackToGoBack:N}})}else if(F&&T.isRefreshingViewInBackground===!1&&u?.status?.code==="active"){t(xs({chargeCardId:s}));const I=_e(L.tenantEmailDomain,s,B,u,!0),N=ye(y.state?.pathnameStackToGoBack,y.pathname);t(Xa()),a(I,{state:{pathnameStackToGoBack:N}})}}},[T.fetchState,u?.type.code,F,T.isRefreshingViewInBackground]);const _=te.getZeniOtpTokenForCardHolder(s),D=i(I=>Hn(I.userState,B.userId)),G=()=>{u?.status?.code!=="active"&&t(Sa(s,!0))};r.useEffect(()=>{T.updatePhysicalChargeCardAttemptFetchState.fetchState==="Completed"&&u?.cardActivationAttemptHistory.some(I=>I.statusCode==="success")===!0&&F===!1&&(setTimeout(G,3e3),w(!0))},[T.updatePhysicalChargeCardAttemptFetchState.fetchState,u?.cardActivationAttemptHistory]);const Q=I=>{j(I)};if(v!=="Completed"||u==null)return c.jsx(va,{fetchState:"In-Progress"});if(u.shippingAddressId==null)throw Error("Can't access shippingAddressId.");if(D?.phone==null)throw Error("Can't access user phone number.");return c.jsxs(ni,{children:[c.jsx(Ie,{isAppContentDrawerOpen:l,handleDrawerToggle:Q}),c.jsx(ai,{cardId:s,card:u,shippingAddressId:u.shippingAddressId,phone:D.phone,signedInUser:B,isSandboxEnv:Rt(),chargeCardDetailState:T,signedInUserToken:_,navigate:a,currentTenant:L,location:y,maxChargeCardActivationAttempts:h[s]!=null?h[s]:p.default_max_charge_card_activation_attempts!=null?p.default_max_charge_card_activation_attempts:3,chargeCardCashbackRatePerTransaction:p.charge_card_cashback_rate_per_transaction!=null?p.charge_card_cashback_rate_per_transaction:.0175,onClickMenuIcon:()=>{Q(!0)}}),e!=null?c.jsx(ti,{windowSize:n,children:e}):null]})},ai=Pe(function(e,{chargeCardDetailState:n,shippingAddressId:t,location:a,cardId:s}){const y=Bs(e.addressState,t);if(y==null)throw Error("Can't access shippingAddress.");const g=Gn(e,s),S=n.updateStatus,P=Ca(e,!1,!1,!1);let m=!1;P.fetchState==="Completed"&&P.cards.length<=1&&(m=!0);const C=a.state?.message==="comingFromV2UrlPath";return{showActivatePage:n.chargeCard?.providerCardCreateTime!=null&&n.chargeCard.providerCardCreateTime.add(24,"h").isBefore(Ls())||C,showMenuIcon:m,shippingAddress:y,vgsVaultId:rt.cardVaultId,twoFAView:g,activationWaitStatus:S,isRefreshingViewInBackground:n.isRefreshingViewInBackground}},function(e,n){const{navigate:t,cardId:a,location:s,currentTenant:y,chargeCardDetailState:g}=n,S=g.chargeCard?.cardProviderID,{tenantEmailDomain:P}=y;return{onGetOtp:m=>{S!=null&&e(at(m,"ChargeCardHolder",a))},onUpdatePhysicalChargeCardAttempt:m=>{e(Os(a,m))},onResendOtp:m=>{S!=null&&e(et(m,"ChargeCardHolder",a))},onVerifyOtp:(m,C)=>{S!=null&&e(Ja(m,C,"ChargeCardHolder",a))},onVerifyOtpSuccess:m=>{m!=null&&te.saveZeniOtpTokenForCardHolder(m,a)},onCVVActivateSuccess:()=>{e(Rs({chargeCardId:a}))},onBackClick:()=>{const m=we(s.state?.pathnameStackToGoBack),C=m.poppedPathname==null||m.poppedPathname.includes("onboard")===!0?ta(P):m.poppedPathname;t(C,{state:{pathnameStackToGoBack:m.newStack}})}}})(co),ti=He.div`
1
+ import{j as c}from"./liveblocks-D0coviDj.js";import{u as me,j as i,h as le,g as he,i as Ve,N as Xe,s as _t,n as Pe,t as _n,o as cs,p as ce}from"./core-PLgxH77Q.js";import{f8 as Pt,RW as os,fk as wt,bt as Fe,RX as is,RY as ds,eZ as fn,RZ as Pn,f6 as wn,R_ as vn,R$ as Tn,S0 as Fn,S1 as xn,f7 as Bn,fj as Ln,S2 as Rn,S3 as ls,fd as us,fc as ms,S4 as Cs,C5 as On,fm as ia,S5 as ps,S6 as hs,e$ as fs,e_ as gs,fz as Ze,ff as Un,fe as jn,S7 as Ss,fg as bs,BC as ys,BB as Is,BF as ks,BH as Es,fs as As,eW as Mn,S8 as Ds,S9 as _s,fx as Nn,Sa as Ps,fy as yt,BN as ws,BK as vs,eX as ge,Sb as qa,fC as xe,fD as Be,fE as Le,gw as da,cw as la,Sc as ua,Sd as vt,uT as $a,kF as za,Se as Za,Cl as ka,fn as Qe,Cn as Tt,kv as Vn,Sf as ma,C9 as _a,Sg as Ts,Sh as Fs,Cc as Qa,Si as xs,Qi as Xa,fi as Hn,Ci as Sa,hV as Bs,Sj as Gn,f9 as Ca,bo as Ls,Sk as Rs,gh as Ja,gg as et,CR as Os,gf as at,P_ as Us,Sl as $n,cp as zn,cR as js,Qh as wa,Dq as Zn,Sm as gn,D0 as Pa,Sn as Wn,Dr as Ms,QG as Ns,Ds as Vs,Ex as Hs,ub as Gs,Er as $s,So as zs,Cm as ca,Sp as Zs,Sq as Ws,Sr as Ks,Ss as Ys,St as qs,Su as Ft,Sv as Qs,CC as Kn,Cv as Xs,Sw as Js,gy as ec,CL as Yn,CP as qn,gx as ac,Sx as tc,Dc as Qn,Sy as nc,Sz as rc,SA as sc,CN as Xn,Cy as Jn,Cf as er,CH as ar,CF as tr,CJ as cc,SB as nr,SC as oc,fu as ic,fv as dc,fw as lc,SD as tt,fo as rr,cT as xt,SE as uc,SF as mc,SG as Cc,SH as pc,CX as It,Dj as hc,Df as fc,CT as gc,Dh as Sc,D7 as bc,D9 as yc,SI as sr,Dp as Ga,Kg as Ic,SJ as kc,SK as Ec,SL as Ac,SM as cr,SN as Dc,DM as _c,C$ as or,CW as Ne,C_ as Pc,SO as wc,SP as vc,C6 as Tc,SQ as ir,fh as dr,SR as Fc,C8 as xc,C7 as Sn,SS as Bc,ST as Lc,SU as Rc,MN as Oc,SV as Bt,SW as Uc,xU as lr,ld as jc,hL as Mc,DR as Nc,SX as ur,f3 as Vc,f4 as Hc,SY as Gc,dj as $c,fl as zc,DH as Zc,DB as qe,bs as Wc,bJ as Kc,cB as Yc,bK as qc,L_ as Qc}from"./zeni-epic-state-CvlYbP8V.js";import{I as Re,cr as mr,p as we,cs as Cr,ct as pr,cu as Xc,a as ea,a0 as Lt,cv as Jc,cw as eo,Z as hr,c as fr,$ as gr,v as ye,C as ue,G as W,ar as ya,cx as Sr,cy as ao,cz as to,z as te,B as va,cg as nt,cA as no,cB as ro,cC as so,K as Ta,aS as We,bt as Rt,cD as co,F as Fa,j as rt,y as Ot,d as J,a9 as st,cE as oo,bG as ba,cF as kt,cG as io,D as Ut,cH as lo,au as br,a4 as Et,cI as uo,_ as yr,H as Ir,f as kr,cJ as mo,cK as Co,cL as po,cM as ho,cN as fo,cO as go,cP as So,o as Wa,cQ as bo,cR as yo,cS as ht,x as Io,cT as ko,cU as Eo,cV as Ao,cW as Do,cX as _o,i as Po}from"./index-DplenJAr.js";import{n as He,D as Er,S as wo}from"./mui-C0RqdtC7.js";import{a as r}from"./sentry-BX7AV8EY.js";import{u as xa}from"./useAskAiCfoHostNavButtonProps-C6zAZIxS.js";import{M as Ie}from"./MobileAppDrawer-CcJQi30K.js";import{d as jt}from"./recharts-IQlfHMoz.js";import{g as _e,a as Ba,b as Ar,c as Oe,d as Ue,e as Je,f as aa,h as ta,A as vo,i as Mt,P as To,j as Nt,s as Ia,k as Dr,l as oa,m as _r,n as Fo,o as Pr,p as xo,S as bn}from"./SetupPagesScreen-D-4Tus-H.js";import{u as wr}from"./useInitialThreadRequest-D54lz34v.js";import ct from"./NotFoundScreen-4X9999wY.js";import{u as Vt}from"./useChargeCardPusherEvents-O8t8uEp0.js";import{n as yn}from"./utils-CBwnO3Ef.js";import{t as Bo}from"./AddressScreen-DloTYXZl.js";import"./analytics-FZZqBV_U.js";import"./plaid-COO6326w.js";import"./dnd-BR185E7x.js";import"./stripe-DMRn4zHo.js";import"./lottie-Cr90j9wu.js";import"./lexical-lY8wPGQT.js";import"./pdf-Aivmor3r.js";import"./analyticsHelper-_dJZMDy8.js";import"./routePaths-DqswWqzZ.js";import"./BusinessVerificationPageScreen-Iipb6Y1I.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="db48dc71-1b27-48cc-9b4a-54b85edcca52",e._sentryDebugIdIdentifier="sentry-dbid-db48dc71-1b27-48cc-9b4a-54b85edcca52")}catch{}})();const Lo=e=>{const n=e.cardHolderUser,t=`${n.firstName??""} ${n.lastName??""}`.trim()||n.email||n.userId;return{userId:n.userId,displayName:t,roleLabel:e.cardHolderRoles?.titleAtCompany}},vr=e=>({id:e.id,isChecked:!1,cardName:e.cardName,last4:e.accountLast4,limitAmount:e.limit?.amount??0,limitCadence:e.creditLimitFrequency?.code,owner:Lo(e),utilizationAmount:(e.limit?.amount??0)-(e.available?.amount??0)});function Tr(){const e=me(),n=i(a=>Pt(a.cardPolicyState)),t=i(a=>os(a.cardPolicyState));r.useEffect(()=>{t!==""||n==="Completed"&&t===""||n==="In-Progress"||e(wt())},[e,n,t])}const{spendManagement:{chargeCard:{cardPolicyPage:In}}}=ea.getLocalizedStrings(),Ro=e=>Un(e,!1),Oo=e=>jn(e.name,!1);function Uo(){const e=le(),n=he(),{tenantEmailDomain:t}=Ve(),a=me(),s=Re(),y=Fe(s?.loggedInUserRoleMap),[g,S]=r.useState(!1),P=r.useCallback(E=>{S(E)},[]),m=r.useCallback(()=>{P(!0)},[P]),{isAiCfoAccessEnabled:C,onAskAiCfoClick:F}=xa({mobileExploreReferrer:"Card Policy"});r.useEffect(()=>()=>{a(is()),a(ds()),a(fn())},[a]);const w=i(E=>Pn(E.cardPolicyState)),l=i(E=>wn(E.cardPolicyState)),j=i(E=>vn(E.cardPolicyState)),B=i(E=>Tn(E.cardPolicyState)),L=i(E=>Fn(E.cardPolicyState)),p=i(E=>xn(E.cardPolicyState)),h=i(E=>Bn(E.cardPolicyState)),T=i(E=>Pt(E.cardPolicyState)),u=i(E=>E.chargeCardConfigState.receiptRequiredAboveAmount.amount),v=i(E=>E.chargeCardConfigState.fetchState);r.useEffect(()=>{w!=="Completed"&&w!=="In-Progress"&&a(Ln())},[a,w]),Tr();const k=i(E=>Rn(E.createCardPolicyState)),U=i(E=>ls(E.createCardPolicyState)),A=i(E=>us(E.cardPolicyState)),b=i(E=>ms(E.cardPolicyState)),x=i(E=>Cs(E.createCardPolicyState)),d=i(E=>On(E));r.useEffect(()=>{d.fetchState==="Not-Started"&&a(ia(!1,!1,!1))},[d.fetchState,a]);const f=r.useMemo(()=>l.map(Ro),[l]),M=r.useMemo(()=>h.map(Oo),[h]),V=r.useMemo(()=>d.cards.filter(E=>!mr(E.status.code)).map(vr),[d.cards]),O=w==="Completed"&&d.fetchState==="Completed"&&v==="Completed";r.useEffect(()=>{O&&x==null&&a(ps({cardsMasterList:V,defaultRequireReceiptAmount:u,suggestedAllowMerchants:j,suggestedBlockMerchants:B,suggestedAllowCategories:L,suggestedBlockCategories:p}))},[v,a,O,x,V,u,j,B,L,p]);const R=r.useMemo(()=>jt(E=>{a(wt(E))},250),[a]);r.useEffect(()=>()=>{R.cancel()},[R]);const z=r.useCallback(E=>{R(E)},[R]),$=k.fetchState,_=t!=null?`/${t}/cards/policy`:"..",D=r.useCallback(()=>{const E=we(n.state?.pathnameStackToGoBack),Y=E.poppedPathname??_;e(Y,{state:{pathnameStackToGoBack:E.newStack}})},[n.state,e,_]),G=r.useCallback(()=>{e(_)},[e,_]),Q=r.useCallback(E=>{a(hs(E))},[a]),I=r.useCallback(E=>{const Y=Cr(E);a(fs({templates:[Y]}))},[a]),N=r.useCallback(E=>{E.length!==0&&a(gs(E))},[a]),K=r.useCallback(()=>{a(fn())},[a]),X=r.useRef($);r.useEffect(()=>{const E=X.current;X.current=$,$==="Completed"&&E!=="Completed"&&U!=null&&(a(Ze({messageSection:"card_policy_created",messageText:"success",type:"success"})),e(_))},[a,$,U,e,_]);const o=$==="Error"?k.error?.message??In.createPolicyGenericErrorMessage:void 0;return y&&t!=null?x==null?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:P}),c.jsx(pr,{showUploadDocumentSection:!0,navBarTitle:In.createPageTitle,onBackClick:D,onClickMenuIcon:m,isAiCfoAccessEnabled:C,onAskAiCfoClick:F})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:P}),c.jsx(Xc,{formDraft:x,vendorSearchOptions:M,categorySearchOptions:f,isVendorSearchLoading:T==="In-Progress",onVendorSearchTextChange:z,submitState:$,submitErrorMessage:o,documentUploadState:A,uploadedFileName:b,isAiCfoAccessEnabled:C,onAskAiCfoClick:F,onBackClick:D,onCancelClick:G,onClickMenuIcon:m,onFormChange:Q,onSubmit:I,onUploadDocument:N,onRemoveDocument:K})]}):c.jsx(Xe,{to:"..",replace:!0})}const{spendManagement:{chargeCard:{cardPolicyPage:jo}}}=ea.getLocalizedStrings(),Mo=e=>Un(e,!1),No=e=>jn(e.name,!1);function Vo(){const e=le(),n=he(),{tenantEmailDomain:t,templateId:a}=Ve(),s=me(),y=Re(),g=Fe(y?.loggedInUserRoleMap),[S,P]=r.useState(!1),m=r.useCallback(o=>{P(o)},[]),C=r.useCallback(()=>{m(!0)},[m]),{isAiCfoAccessEnabled:F,onAskAiCfoClick:w}=xa({mobileExploreReferrer:"Card Policy"}),l=i(o=>Ss(o)),j=i(o=>Pn(o.cardPolicyState)),B=i(o=>wn(o.cardPolicyState)),L=i(o=>vn(o.cardPolicyState)),p=i(o=>Tn(o.cardPolicyState)),h=i(o=>Fn(o.cardPolicyState)),T=i(o=>xn(o.cardPolicyState)),u=i(o=>Bn(o.cardPolicyState)),v=i(o=>Pt(o.cardPolicyState)),k=i(o=>On(o)),U=i(o=>a!=null?bs(o.cardPolicyState,a):void 0),A=r.useMemo(()=>l.templateId===a&&l.formDraft!=null?l.formDraft:U!=null?ys(U):void 0,[l.templateId,l.formDraft,U,a]);r.useEffect(()=>{if(a==null)return;const o=l.detailFetchState.fetchState;l.templateId===a&&(o==="Completed"||o==="In-Progress")||U!=null||s(Is(a))},[s,a,l.templateId,l.detailFetchState.fetchState,U]),r.useEffect(()=>{j!=="Completed"&&j!=="In-Progress"&&s(Ln())},[s,j]),Tr();const b=i(o=>o.chargeCardConfigState.receiptRequiredAboveAmount.amount);r.useEffect(()=>{k.fetchState==="Not-Started"&&s(ia(!1,!1,!1))},[k.fetchState,s]);const x=r.useMemo(()=>B.map(Mo),[B]),d=r.useMemo(()=>u.map(No),[u]),f=r.useMemo(()=>k.cards.filter(o=>!mr(o.status.code)).map(vr),[k.cards]);Lt({isDataReady:A!=null});const M=r.useMemo(()=>{if(A!=null)return Jc({draft:A,cardRows:f,categorySearchOptions:x,vendorSearchOptions:d,defaultRequireReceiptAmount:b,suggestedAllowMerchants:L,suggestedBlockMerchants:p,suggestedAllowCategories:h,suggestedBlockCategories:T})},[A,f,x,d,b,L,p,h,T]),[V,O]=r.useState(void 0),R=r.useRef(!1);r.useEffect(()=>{R.current||V!=null||M==null||(R.current=!0,O(M))},[V,M]);const z=r.useCallback(o=>{O(o)},[]),$=r.useMemo(()=>jt(o=>{s(wt(o))},250),[s]);r.useEffect(()=>()=>{$.cancel()},[$]);const _=r.useCallback(o=>{$(o)},[$]),D=l.updateFetchState.fetchState,G=t!=null?`/${t}/cards/policy`:"..",Q=r.useCallback(()=>{const o=we(n.state?.pathnameStackToGoBack),E=o.poppedPathname??G;e(E,{state:{pathnameStackToGoBack:o.newStack}})},[n.state,e,G]),I=r.useCallback(()=>{e(G)},[e,G]),N=r.useCallback(o=>{if(a==null)return;const E=Cr(o);s(ks(E)),s(Es(a))},[s,a]),K=r.useRef(D);r.useEffect(()=>{const o=K.current;K.current=D,D==="Completed"&&o!=="Completed"&&(s(Ze({messageSection:"card_policy_updated",messageText:"success",type:"success"})),e(G))},[s,D,e,G]);const X=D==="Error"?l.updateFetchState.error?.message??jo.updatePolicyGenericErrorMessage:void 0;return!g||t==null||a==null?c.jsx(Xe,{to:"..",replace:!0}):V!=null&&j==="Completed"&&k.fetchState==="Completed"?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:m}),c.jsx(eo,{templateName:l.template?.name??"",formDraft:V,vendorSearchOptions:d,categorySearchOptions:x,isVendorSearchLoading:v==="In-Progress",onVendorSearchTextChange:_,submitState:D,submitErrorMessage:X,isAiCfoAccessEnabled:F,onAskAiCfoClick:w,onBackClick:Q,onCancelClick:I,onClickMenuIcon:C,onFormChange:z,onSubmit:N})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:m}),c.jsx(pr,{showUploadDocumentSection:!1,navBarTitle:l.template?.name,onBackClick:Q,onClickMenuIcon:C,isAiCfoAccessEnabled:F,onAskAiCfoClick:w})]})}function Fr(e,n,t){return n?e.filter(a=>a!=null&&a.trim().length>0).slice(0,t):[]}function xr(e){return i(n=>e==null||e===""?{chips:ft,isResolved:!1}:function(t){const a=t?.fetchState,s=a==="Completed"||a==="Error";return{chips:a==="Completed"?t?.suggestedQuestions??ft:ft,isResolved:s}}(As(n,e)),_t)}const ft=[],{spendManagement:{chargeCard:{cardPolicyAiCfoHero:{headline:Ho,subheadline:Go,pageTitle:$o}}}}=ea.getLocalizedStrings(),zo=e=>{const n=e.cardsCount>0?e.cardsCount:e.appliedCards.length,t=e.allowedEntity.merchantNames.length+e.blockedEntity.merchantNames.length,a=e.allowedEntity.categoryCodes.length+e.blockedEntity.categoryCodes.length;return{templateId:e.templateId,name:e.name,description:e.description,mode:e.mode==="flexible"?"flexible":"strict",createdAtFormatted:e.createdAt.format("ll"),cardsCount:n,vendorRestrictionsCount:t,categoryRestrictionsCount:a}};function Zo(){const e=le(),n=he(),{tenantEmailDomain:t}=Ve(),a=me(),s=Re(),y=Fe(s?.loggedInUserRoleMap),[g,S]=r.useState(!1),P=r.useCallback(_=>{S(_)},[]),m=r.useCallback(()=>{P(!0)},[P]),{useFeatureGate:C}=ue(),{isFeatureEnabled:F}=C(W.isAiCfoFileUploadEnabled),{isFeatureEnabled:w}=C(W.isCardPolicyEnabled),{isAiCfoAccessEnabled:l,onAskAiCfoClick:j}=xa({mobileExploreReferrer:"Card Policy"}),B=i(_=>Ds(_)),L=i(_=>Rn(_.createCardPolicyState)),p=i(_=>_s(_.createCardPolicyState)),h=i(_=>p==null?[]:Nn(_.aiCfoState,p).filter(D=>D.kind==="creating_policy"),_t),T=L.fetchState==="In-Progress"?Math.max(h.length,1):0,u=i(_=>Ps(_.createCardPolicyState)),v=ya(L.fetchState);r.useEffect(()=>{if(v==="In-Progress"&&L.fetchState==="Completed"&&p!=null)h.forEach(_=>{a(yt({chatSessionId:p,id:_.id,entityIds:u,kind:"created_policy"}))});else if(v==="In-Progress"&&L.fetchState==="Error"&&p!=null){h.forEach(D=>{a(yt({chatSessionId:p,id:D.id,kind:"errored_policy"}))});const _=L.error?.message!=null&&L.error.message.length>0?L.error.message:ea.getLocalizedStrings().common.errorMessage.somethingWentWrongPleaseTryAgain;a(Ze({messageSection:"card_policy_created",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:_}]}))}},[L.error?.message,L.fetchState,a,p,u,h,v]);const k=B.fetchState.fetchState;r.useEffect(()=>{k!=="Not-Started"&&k!=="Error"||a(ws())},[a,k]);const U=B.archiveFetchState.fetchState,A=ya(U);r.useEffect(()=>{A==="In-Progress"&&U==="Completed"&&a(Ze({messageSection:"card_policy_deleted",messageText:"success",type:"success"}))},[U,a,A]);const b=r.useMemo(()=>B.templates.map(zo),[B.templates]);Lt({isDataReady:B.fetchState.fetchState==="Completed"});const x=b.length>0||T>0,d=function(_){const{hasAnyPolicies:D,isChargeCardAdmin:G,isFileUploadEnabled:Q}=_,I=le(),N=he(),{tenantEmailDomain:K}=Ve(),{isAiCfoOpen:X,setIsAiCfoOpen:o}=hr(),E=fr(),Y=gr(),ne=i(oe=>Mn(oe)).createSessionAndSubmitState.fetchState==="In-Progress",{chips:q,isResolved:ke}=xr("card_policy"),ve=r.useMemo(()=>Fr(q,ke,3),[q,ke]),[fe,se]=r.useState(""),Ee=Y&&E&&K!=null&&!X,re=r.useCallback(oe=>{if(K==null)return;const fa=ye(N.state?.pathnameStackToGoBack,N.pathname);I(`/${K}/cards/ask`,{state:{message:"",origin:"",pathnameStackToGoBack:fa,referrer:"card_policy_hero",aiCfoInitialQuestion:oe,aiCfoShouldSubmit:oe!=null&&oe.trim().length>0}})},[N.pathname,N.state,I,K]),Ce=r.useCallback(oe=>{oe.trim().length!==0&&(se(""),re(oe))},[re]),Ae=r.useCallback(()=>{const oe=fe.trim();oe.length!==0&&(se(""),re(oe))},[fe,re]),ee=r.useCallback(()=>{},[]),Te=r.useCallback(oe=>{se(oe)},[]),De=r.useCallback(()=>{o(!0)},[o]),ae=r.useCallback(()=>{re(void 0)},[re]);return r.useMemo(()=>{if(Ee&&!D&&G)return{aiAgentName:$o,headline:Ho,subheadline:Go,promptChips:ve,composer:{currentInput:fe,isSubmitting:ne,isFileUploadEnabled:Q,onInputChange:Te,onSubmit:Ae,onStopSubmit:ee},onPromptClick:Ce,onOpenSidePanel:De,onOpenFullView:ae,dataTestIdPrefix:"card-policy-ai-cfo-hero"}},[fe,D,Ee,G,Q,ne,Te,ae,De,Ce,ee,Ae,ve])}({hasAnyPolicies:x,isChargeCardAdmin:y,isFileUploadEnabled:F}),f=w&&d!=null?c.jsx(Sr,{...d}):null,M=l&&f==null,V=r.useCallback(()=>{const _=we(n.state?.pathnameStackToGoBack),D=_.poppedPathname??"..";e(D,{state:{pathnameStackToGoBack:_.newStack}})},[n.state,e]),O=r.useCallback(()=>{t!=null&&e(`/${t}/cards/policy/new`)},[e,t]),R=r.useCallback(_=>{t!=null&&e(`/${t}/cards/policy/${_}/edit`)},[e,t]),z=r.useCallback(_=>{a(vs(_))},[a]),$=B.fetchState.fetchState;return!x&&$!=="Completed"&&$!=="Error"?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:P}),c.jsx(ao,{onBackClick:V,onNewPolicyClick:O,onClickMenuIcon:m,isAiCfoAccessEnabled:l,onAskAiCfoClick:j})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:P}),c.jsx(to,{policies:b,archivingTemplateId:B.archiveTargetTemplateId,pendingCreationCount:T,onBackClick:V,onNewPolicyClick:O,onEditPolicyClick:R,onArchivePolicyClick:z,onClickMenuIcon:m,policyAiCfoHero:f,isAiCfoAccessEnabled:M,onAskAiCfoClick:j})]})}function Wo(){const e=le(),{cardId:n}=Ve(),t=me(),a=te.getSignedInUser(),s=i(q=>ge(q)),y=Re(),g=Fe(y?.loggedInUserRoleMap),{useFeatureGate:S}=ue();if(a==null)throw Error("Can't access Add To Wallet Page without signing in...");const[P,m]=r.useState(!1),C=i(q=>qa(q).firstViewAfterActivation);if(n==null)throw Error("Empty card id is not valid...");const F=s.userRole.includes("charge_card_user"),{isFeatureEnabled:w}=S(W.isChargeCardFeatureEnabled),l=!!s.companyChargeCardInfo?.info?.isChargeCardEnabled,{isFeatureEnabled:j}=S(W.isDebitCardFeatureEnabled),B=xe(s),L=Be(s),p=Le(j,s),h=s.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,T=Oe({isDebitCardFeatureEnabled:j,isBankingOnlyTenant:p}),u=Ue({isCardsOnlyTenant:B,isChargeCardFeatureEnabled:w,isBookKeepingTenant:L,isDebitCardProductVisible:T,chargeCardsCreditAccountLimit:h}),v=!!s.companyDebitCardInfo?.info?.isDebitCardEnabled,k=i(q=>da(q,s.companyId)),U=la(k.controllers),{creditAccount:A,creditAccountRepayment:b}=i(q=>ua(q)),x=i(q=>q.classListState.fetchState),d=!F&&u&&l,f=i(q=>vt(q,n,d,u)),[M,V]=r.useState(!1),O=f.chargeCard,R=O?.cardCreatedByUser?.userId,z=i(q=>R!=null?$a(q.userRoleState,R):void 0),$=z?.accountingClassIDs[0],_=i(q=>$!=null?za(q.classState,{classId:$,reportId:"class_list"}):void 0),D=O?.cardHolderUser?.userId,G=i(q=>D!=null?$a(q.userRoleState,D):void 0),Q=G?.accountingClassIDs[0],I=i(q=>Q!=null?za(q.classState,{classId:Q,reportId:"class_list"}):void 0),N=O?.type.code==="business_physical_credit_card"||O?.type.code==="business_physical_debit_card",K=O?.type.code==="business_physical_debit_card";r.useEffect(()=>{C&&P===!1&&N&&(m(!0),setTimeout(()=>{t(Za()),K&&t(Ze({messageSection:"set_debit_card_pin",messageText:"success",type:"success",showStatusIcon:!0}))},5e3))},[C,P,N,K]),r.useEffect(()=>{M||f.fetchState==="Completed"||f.fetchState==="In-Progress"||n==null||(V(!0),t(ka(n,d,!1)))},[M,f,n,t]),r.useEffect(()=>{if(f.fetchState==="Completed"&&(N===!1||N&&O?.status?.code!=="active"||O?.cardHolderUserId!==a.userId||C===!1&&P===!1||O?.type.code==="business_physical_debit_card"||O?.type.code==="business_virtual_debit_card")){const q=_e(s.tenantEmailDomain,n,a,O,C);e(q)}},[f.fetchState,C,N]),r.useEffect(()=>{A.fetchState!=="Completed"&&A.fetchState!=="In-Progress"&&u&&l&&g&&t(Qe()),b.fetchState!=="Completed"&&b.fetchState!=="In-Progress"&&u&&l&&g&&t(Tt()),x!=="Completed"&&x!=="In-Progress"&&t(Vn())},[A.fetchState,b.fetchState,t,u,l,g,x]);const X=()=>{if(a!=null&&n!=null){t(Za());const q=_e(s.tenantEmailDomain,n,a);e(q)}},o=O?.type.code==="business_physical_debit_card"||O?.type.code==="business_virtual_debit_card",E=Je(u,T,v,l),Y=Ba(u,l,g,A,b),ne=Ar(o,f);return f.fetchState!=="Completed"?c.jsx(va,{fetchState:"In-Progress"}):c.jsxs(c.Fragment,{children:[c.jsx(nt,{showConfetti:C}),c.jsx(no,{onGotItClick:X,isDebitCard:O?.type.code==="business_physical_debit_card",controllerEmails:U,isChargeCardFeatureEnabled:u,isDebitCardFeatureEnabled:T,isDebitCardSetupEnabled:v,isChargeCardSetupEnabled:l,productInformation:E,creditAccountInformation:Y,debitAccountInformation:ne,chargeCardDetailView:f,creditAccount:A,classListFetchState:x,creditAccountRepayment:b,cardIssuedByRoles:z?.userRoles,cardIssuedByDepartmentName:_?.className,cardHolderRoles:G?.userRoles,cardHolderDepartmentName:I?.className})]})}const Br="charge-card-transaction-update",Lr="charge-card-transaction-created",Rr="charge-card-transaction-declined",Or="charge-card-transaction-updated",Ur="charge-card-transaction-receipt-uploaded",pa="charge-card-status-update",Ht="charge-card-spending-updated",ot="credit-account-balance-updated",it="charge-card-created",Gt="charge-card-limit-updated",$t="charge-card-limit-reset",zt="charge-card-renamed",Ko="charge-card-department-updated",jr="charge-card-repayment-completed",Mr="charge-card-payment-date-updated",La="charge-card-cashback-redeemed",Ra="charge-card-cashback-earned",ha=(e,n)=>e==null||e===""?[]:n.map(t=>`private-encrypted-${e}.${t}`),Yo=[Ra,La],qo=Pe(function(e){const n=ma(e);return{insightsData:n.insight,cashbackByPeriod:n.cashbackByPeriod,uiState:n.uiState,cashbackSummary:n.cashbackSummary}},function(e){return{onColumnSortConfigChanged:(n,t)=>{e(Ts({uiState:{sortKey:n,sortOrder:t}}))}}})(so);function Qo(){const e=le(),n=me(),t=he(),a=te.getSignedInUser(),s=i(j=>ge(j)),{useFeatureGate:y}=ue(),{isFeatureEnabled:g}=y(W.isCardsCommentingEnabled),[S,P]=r.useState(!1),m=i(j=>ma(j)),C=wr(s.companyId,{clearParams:m.fetchState==="Completed"}),F=r.useCallback(()=>{const j=we(t.state?.pathnameStackToGoBack),B=j.poppedPathname??Xo(s.tenantEmailDomain);e(B,{state:{pathnameStackToGoBack:j.newStack}})},[e,t,s.tenantEmailDomain]),w=aa(s);if(Vt({events:ha(w,Yo),onEvent:j=>{switch(j){case Ra:case La:return void n(_a(!0))}},onSubscribed:()=>{n(_a(!0))}}),r.useEffect(()=>{S||m.fetchState==="Completed"||m.fetchState==="In-Progress"||(P(!0),n(_a()))},[S,m,n]),a==null)throw Error("Can't access cashback detail page without signing in...");const l=m.cashbackSummary?.cashbackEarned?.amount!=null&&m.fetchState!=="Not-Started";return m.fetchState!=="In-Progress"||l?(m.cashbackSummary?.cashbackEarned?.amount??0)===0&&m.fetchState==="Completed"?c.jsx(ct,{}):c.jsx(qo,{onBackClick:F,isCardsCommentingEnabled:g,initialOpenThreadRequest:C}):c.jsx(ro,{onBackClick:F})}const Xo=e=>`/${e}/cards`,Jo={containerWidth:new Fa(100,58)},ei=({appContent:e})=>{const n=Ta(),t=me(),a=le(),{cardId:s}=Ve(),y=he(),{useDynamicConfig:g}=ue(),[S,P]=r.useState(!1),[m,C]=r.useState(!1),[F,w]=r.useState(!1),[l,j]=r.useState(!1),B=te.getSignedInUser();if(B==null)throw Error("Can't access onboarding card page without signing in...");const L=i(I=>ge(I));if(s==null)throw Error("Empty card id is not valid...");const{configValue:p}=g(We.zeniCardsConfig),h=p.max_charge_card_activation_attempts_by_card_id,T=i(I=>Fs(I,s)),u=T.chargeCard,v=i(I=>I.chargeCardConfigState.fetchState),{useFeatureGate:k}=ue(),{isFeatureEnabled:U}=k(W.isChargeCardFeatureEnabled),{isFeatureEnabled:A}=k(W.isDebitCardFeatureEnabled),b=Le(A,L),x=Oe({isDebitCardFeatureEnabled:A,isBankingOnlyTenant:b}),d=!!L.companyChargeCardInfo?.info?.isChargeCardEnabled,f=L.userRole.includes("charge_card_user"),M=xe(L),V=Be(L),O=L.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,R=Ue({isCardsOnlyTenant:M,isChargeCardFeatureEnabled:U,isBookKeepingTenant:V,isDebitCardProductVisible:x,chargeCardsCreditAccountLimit:O}),z=!f&&R&&d;r.useEffect(()=>{S===!1&&v!=="In-Progress"&&v!=="Completed"&&(t(Qa()),P(!0)),m===!1&&T.fetchState==="Not-Started"&&(C(!0),t(ka(s,z,R)))},[m,T.fetchState,S,v]);const $=u?.type.code==="business_physical_credit_card"||u?.type.code==="business_physical_debit_card";r.useEffect(()=>{if(T.fetchState==="Completed"){if(F===!1&&($===!1||$&&u?.status?.code!=="inactive"||u?.cardHolderUserId!==B.userId)){const I=_e(L.tenantEmailDomain,s,B,u,!0),N=ye(y.state?.pathnameStackToGoBack,y.pathname);a(I,{state:{pathnameStackToGoBack:N}})}else if(F&&T.isRefreshingViewInBackground===!1&&u?.status?.code==="active"){t(xs({chargeCardId:s}));const I=_e(L.tenantEmailDomain,s,B,u,!0),N=ye(y.state?.pathnameStackToGoBack,y.pathname);t(Xa()),a(I,{state:{pathnameStackToGoBack:N}})}}},[T.fetchState,u?.type.code,F,T.isRefreshingViewInBackground]);const _=te.getZeniOtpTokenForCardHolder(s),D=i(I=>Hn(I.userState,B.userId)),G=()=>{u?.status?.code!=="active"&&t(Sa(s,!0))};r.useEffect(()=>{T.updatePhysicalChargeCardAttemptFetchState.fetchState==="Completed"&&u?.cardActivationAttemptHistory.some(I=>I.statusCode==="success")===!0&&F===!1&&(setTimeout(G,3e3),w(!0))},[T.updatePhysicalChargeCardAttemptFetchState.fetchState,u?.cardActivationAttemptHistory]);const Q=I=>{j(I)};if(v!=="Completed"||u==null)return c.jsx(va,{fetchState:"In-Progress"});if(u.shippingAddressId==null)throw Error("Can't access shippingAddressId.");if(D?.phone==null)throw Error("Can't access user phone number.");return c.jsxs(ni,{children:[c.jsx(Ie,{isAppContentDrawerOpen:l,handleDrawerToggle:Q}),c.jsx(ai,{cardId:s,card:u,shippingAddressId:u.shippingAddressId,phone:D.phone,signedInUser:B,isSandboxEnv:Rt(),chargeCardDetailState:T,signedInUserToken:_,navigate:a,currentTenant:L,location:y,maxChargeCardActivationAttempts:h[s]!=null?h[s]:p.default_max_charge_card_activation_attempts!=null?p.default_max_charge_card_activation_attempts:3,chargeCardCashbackRatePerTransaction:p.charge_card_cashback_rate_per_transaction!=null?p.charge_card_cashback_rate_per_transaction:.0175,onClickMenuIcon:()=>{Q(!0)}}),e!=null?c.jsx(ti,{windowSize:n,children:e}):null]})},ai=Pe(function(e,{chargeCardDetailState:n,shippingAddressId:t,location:a,cardId:s}){const y=Bs(e.addressState,t);if(y==null)throw Error("Can't access shippingAddress.");const g=Gn(e,s),S=n.updateStatus,P=Ca(e,!1,!1,!1);let m=!1;P.fetchState==="Completed"&&P.cards.length<=1&&(m=!0);const C=a.state?.message==="comingFromV2UrlPath";return{showActivatePage:n.chargeCard?.providerCardCreateTime!=null&&n.chargeCard.providerCardCreateTime.add(24,"h").isBefore(Ls())||C,showMenuIcon:m,shippingAddress:y,vgsVaultId:rt.cardVaultId,twoFAView:g,activationWaitStatus:S,isRefreshingViewInBackground:n.isRefreshingViewInBackground}},function(e,n){const{navigate:t,cardId:a,location:s,currentTenant:y,chargeCardDetailState:g}=n,S=g.chargeCard?.cardProviderID,{tenantEmailDomain:P}=y;return{onGetOtp:m=>{S!=null&&e(at(m,"ChargeCardHolder",a))},onUpdatePhysicalChargeCardAttempt:m=>{e(Os(a,m))},onResendOtp:m=>{S!=null&&e(et(m,"ChargeCardHolder",a))},onVerifyOtp:(m,C)=>{S!=null&&e(Ja(m,C,"ChargeCardHolder",a))},onVerifyOtpSuccess:m=>{m!=null&&te.saveZeniOtpTokenForCardHolder(m,a)},onCVVActivateSuccess:()=>{e(Rs({chargeCardId:a}))},onBackClick:()=>{const m=we(s.state?.pathnameStackToGoBack),C=m.poppedPathname==null||m.poppedPathname.includes("onboard")===!0?ta(P):m.poppedPathname;t(C,{state:{pathnameStackToGoBack:m.newStack}})}}})(co),ti=He.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  width: ${e=>`${Jo.containerWidth.value(e.windowSize)}%`};
@@ -11,18 +11,18 @@ import{j as c}from"./liveblocks-DvqoH3dJ.js";import{u as me,j as i,h as le,g as
11
11
  flex-direction: column;
12
12
  align-items: center;
13
13
  background-color: ${e=>e.theme.colors.grey4};
14
- `,Za=ea.getLocalizedStrings().dateFormat,ri={overlayWidth:new Fa(100,100,58)},Nr=[jr,ot],si=new Set(Nr),ci=Pe(function(e,n){const t=n.currentTenant?.companyId;return{plaidConnectionDetails:Ns(e,t,"zeni_accounts","external_account").plaidConnectionDetails,depositAccountListView:Vs(e.depositAccountState,e.depositAccountListState)}},function(e,n){const{navigate:t,currentTenant:a,hasZeniAccountsAdminAccess:s,isZeniAccountsUser:y,isCashbackInfoFetchStateCompleted:g,isCreditCardInfoFetchStateCompleted:S,isDebitCardInfoFetchStateCompleted:P,controllerEmails:m,paymentDetails:C,productInformation:F,cashbackInformation:w,paymentSourceInformation:l,creditAccountInformation:j,debitAccountInformation:B,paymentInitiatedDate:L,sourcePage:p}=n,{tenantEmailDomain:h}=a,T=()=>{e(Yn(!0));const u=aa(a);u!=null&&u!==""&&e(Pa(u,!0,!0)),e(Qe(!0))};return{onBackNavigation:()=>{if(g&&S&&P&&w!=null&&J.trackCardsPayEarlyFormClick(m,F,w,"Back",C.chargeCardRepaymentDetailLocalData.isAutoRepayment,{paymentAmount:C.chargeCardRepaymentDetailLocalData.amount.amount,paymentAccountName:C.chargeCardRepaymentDetailLocalData.transferFrom?.label,paymentAccountType:C.chargeCardRepaymentDetailLocalData.transferFrom?.accType,paymentAccountLastFourDigits:C.chargeCardRepaymentDetailLocalData.transferFrom?.accountLast4,paymentCompleteEta:L?.add(3,"day").format(Za.visual.MMMDCommaYYYYformat),paymentInitiatedDate:L?.format(Za.visual.MMMDCommaYYYYformat)},l,j,B),p==="cardPaymentHistory")n.closeDrawerHandler(!0),e(Wn());else{const u=ta(h);t(u)}},onUpdatePaymentAccountStatus:(u,v,k)=>{e($s(u,v,"bill_pay","bill_pay_detail",k))},onEstablishConnectionSuccess:()=>{e(Pa(a.companyId,!0))},onFetchLinkTokenClick:u=>{e(Gs("external_account",u))},onEstablishConnectionClick:u=>{e(Hs(u,a.companyId,"charge_card_payment","charge_cards"))},onSignUpAccountClick:()=>{s?window.open(`/${h}/checking/promo`,"_blank"):window.open("https://www.zeni.ai/product/business-checking-accounts","_blank")},onMoveMoneyClick:()=>{y?window.open(`/${h}/checking/transfer`):window.open("https://www.zeni.ai/product/business-checking-accounts","_blank")},onEventReceived:u=>{si.has(u)&&T()},onPusherSubscribed:T}})(st(oo)),Yt=({isPaymentDrawerOpen:e,closeDrawerHandler:n,pageName:t,creditAccountSpentAmount:a,productInformation:s,sourcePage:y,creditAccountInformation:g,debitAccountInformation:S,cashbackInformation:P,isDebitCardInfoFetchStateCompleted:m,isCreditCardInfoFetchStateCompleted:C,isCashbackInfoFetchStateCompleted:F,paymentInitiatedDate:w,retryRepayment:l})=>{const j=le(),{useDynamicConfig:B}=ue(),{configValue:L}=B(We.zeniAccountsConfig),p=Us(L),h=i(E=>$n(E)),{creditAccount:T}=i(E=>ua(E)),u=i(E=>ge(E)),v=Ot(),k=Ta(),U=me(),A=te.getSignedInUser(),b=Re(),[x,d]=r.useState(!1),[f,M]=r.useState(!1),{configValue:V}=B(We.zeniCardsConfig),O=V.credit_card_auto_pay_threshold_by_company_id?.[u.companyId]??V.default_credit_card_auto_pay_threshold??vo,R=zn(b?.loggedInUserRoleMap),z=js(b?.loggedInUserRoleMap),$=!!u.companyZeniAccountInfo?.info?.isZeniAccountEnabled,_=i(E=>wa(E,u.companyId)),D=_.companyChargeCardInfo?.primaryFundingAccount,G=_.allFundingAccounts.find(E=>E.id===D?.accountId),Q=i(E=>da(E,u.companyId)),I=la(Q.controllers);r.useEffect(()=>{if(h.fetchState!=="Completed"&&h.fetchState!=="In-Progress"&&U(Yn()),h.fetchState==="Completed"&&!f){const E=u.companyChargeCardInfo?.info?.primaryFundingAccount?.accountId,K=h.transferFromAccounts.find(q=>q.id===E);let ne;if(y==="cardPaymentHistory"&&l){const q=l.paymentAccountId!=null?h.transferFromAccounts.find(ke=>ke.id===l.paymentAccountId):void 0;ne={amount:l.amount,isAutoRepayment:u.companyChargeCardInfo?.info?.isAutoPayEnabled??!1,idempotencyKey:yn(),transferFrom:q??K}}else ne={amount:{amount:T.balance.amount+T.hold.amount,currencyCode:T.balance.currencyCode,currencySymbol:T.balance.currencySymbol},isAutoRepayment:u.companyChargeCardInfo?.info?.isAutoPayEnabled??!1,idempotencyKey:yn(),transferFrom:K};U(gn(ne)),M(!0)}},[h.fetchState,f,y,l,h.transferFromAccounts,u.companyChargeCardInfo?.info?.primaryFundingAccount?.accountId,u.companyChargeCardInfo?.info?.isAutoPayEnabled,T.balance.amount,T.balance.currencyCode,T.balance.currencySymbol,T.hold.amount,U]);const N={isZeniCheckingEnabled:u.companyZeniAccountInfo?.info?.isZeniAccountEnabled??!1,isZeniCheckingPaymentSource:G?.accType==="depositAccount",creditCardPaymentSourceAccountName:G?.label,creditCardPaymentSourceAccountType:G?.accType,creditCardPaymentSourceLastFourDigits:G?.accountLast4,creditCardPaymentSourceBalance:G?.accountBalance?.available?.amount??0};if(r.useEffect(()=>{_.fetchState!=="Completed"&&_.fetchState!=="In-Progress"&&U(Pa(u.companyId,!0))},[_.fetchState]),r.useEffect(()=>{h.updateStatus==="Completed"&&P!=null&&F&&C&&m&&J.trackCardsPayEarlyPayNowClick(I,s,P,h.chargeCardRepaymentDetailLocalData.isAutoRepayment,{paymentAmount:h.chargeCardRepaymentDetailLocalData.amount.amount,paymentAccountName:h.chargeCardRepaymentDetailLocalData.transferFrom?.label,paymentAccountType:h.chargeCardRepaymentDetailLocalData.transferFrom?.accType,paymentAccountLastFourDigits:h.chargeCardRepaymentDetailLocalData.transferFrom?.accountLast4,paymentCompleteEta:w?.add(3,"day").format(Za.visual.MMMDCommaYYYYformat),paymentInitiatedDate:w?.format(Za.visual.MMMDCommaYYYYformat)},N,g,S)},[h.updateStatus,P,F,C,m,w]),r.useEffect(()=>{h.fetchState==="Completed"&&P!=null&&F&&C&&m&&!x&&e&&f&&P!=null&&(J.trackCardsPayEarlyFormView(I,s,P,t,u.companyChargeCardInfo?.info?.isAutoPayEnabled??!1,T.balance.amount,N,g,S),d(!0))},[h,F,C,m,x,e,f]),A==null)throw Error("Can't access invite people page without signing in...");const Z=()=>{n(!0),U(Wn())},X=aa(u),o={events:e?ha(X,Nr):[],eventCallback:(E,K,ne)=>{ne.onEventReceived(E)},onSubscribed:E=>{E.onPusherSubscribed()}};return c.jsx(c.Fragment,{children:c.jsx(Er,{onClose:()=>{Z()},anchor:"right",transitionDuration:250,open:e,PaperProps:{style:{width:ri.overlayWidth.valuePercentage(k),boxShadow:"none"}},slotProps:{backdrop:{style:{backgroundColor:v.colors.black,opacity:.75,cursor:"pointer"}}},children:c.jsx(oi,{onClick:E=>E.stopPropagation(),children:c.jsx(ci,{...o,closeDrawerHandler:n,navigate:j,paymentDetails:h,creditAccountSpentAmount:a,onTransferClick:()=>{F&&C&&m&&P!=null&&J.trackCardsPayEarlyFormClick(I,s,P,"Pay Now",h.chargeCardRepaymentDetailLocalData.isAutoRepayment,{paymentAmount:h.chargeCardRepaymentDetailLocalData.amount.amount,paymentAccountName:h.chargeCardRepaymentDetailLocalData.transferFrom?.label,paymentAccountType:h.chargeCardRepaymentDetailLocalData.transferFrom?.accType,paymentAccountLastFourDigits:h.chargeCardRepaymentDetailLocalData.transferFrom?.accountLast4,paymentCompleteEta:void 0,paymentInitiatedDate:void 0},N,g,S),U(Ms({companyId:u.companyId}))},onDismissClick:Z,onSaveChangesToLocalStore:E=>{U(gn(E))},currentTenant:u,hasZeniAccountsAdminAccess:R,isZeniAccountsUser:z,isZeniAccountSetupEnabled:$,productInformation:s,sourcePage:y,controllerEmails:I,autoPayThreshold:O,paymentSourceInformation:N,creditAccountInformation:g,debitAccountInformation:S,cashbackInformation:P,isCashbackInfoFetchStateCompleted:F,isCreditCardInfoFetchStateCompleted:C,isDebitCardInfoFetchStateCompleted:m,paymentInitiatedDate:w,maxInsuredAmount:p.maxInsuredAmount})})})})},oi=He(wo)`
14
+ `,Ka=ea.getLocalizedStrings().dateFormat,ri={overlayWidth:new Fa(100,100,58)},Nr=[jr,ot],si=new Set(Nr),ci=Pe(function(e,n){const t=n.currentTenant?.companyId;return{plaidConnectionDetails:Ns(e,t,"zeni_accounts","external_account").plaidConnectionDetails,depositAccountListView:Vs(e.depositAccountState,e.depositAccountListState)}},function(e,n){const{navigate:t,currentTenant:a,hasZeniAccountsAdminAccess:s,isZeniAccountsUser:y,isCashbackInfoFetchStateCompleted:g,isCreditCardInfoFetchStateCompleted:S,isDebitCardInfoFetchStateCompleted:P,controllerEmails:m,paymentDetails:C,productInformation:F,cashbackInformation:w,paymentSourceInformation:l,creditAccountInformation:j,debitAccountInformation:B,paymentInitiatedDate:L,sourcePage:p}=n,{tenantEmailDomain:h}=a,T=()=>{e(Zn(!0));const u=aa(a);u!=null&&u!==""&&e(Pa(u,!0,!0)),e(Qe(!0))};return{onBackNavigation:()=>{if(g&&S&&P&&w!=null&&J.trackCardsPayEarlyFormClick(m,F,w,"Back",C.chargeCardRepaymentDetailLocalData.isAutoRepayment,{paymentAmount:C.chargeCardRepaymentDetailLocalData.amount.amount,paymentAccountName:C.chargeCardRepaymentDetailLocalData.transferFrom?.label,paymentAccountType:C.chargeCardRepaymentDetailLocalData.transferFrom?.accType,paymentAccountLastFourDigits:C.chargeCardRepaymentDetailLocalData.transferFrom?.accountLast4,paymentCompleteEta:L?.add(3,"day").format(Ka.visual.MMMDCommaYYYYformat),paymentInitiatedDate:L?.format(Ka.visual.MMMDCommaYYYYformat)},l,j,B),p==="cardPaymentHistory")n.closeDrawerHandler(!0),e(Wn());else{const u=ta(h);t(u)}},onUpdatePaymentAccountStatus:(u,v,k)=>{e($s(u,v,"bill_pay","bill_pay_detail",k))},onEstablishConnectionSuccess:()=>{e(Pa(a.companyId,!0))},onFetchLinkTokenClick:u=>{e(Gs("external_account",u))},onEstablishConnectionClick:u=>{e(Hs(u,a.companyId,"charge_card_payment","charge_cards"))},onSignUpAccountClick:()=>{s?window.open(`/${h}/checking/promo`,"_blank"):window.open("https://www.zeni.ai/product/business-checking-accounts","_blank")},onMoveMoneyClick:()=>{y?window.open(`/${h}/checking/transfer`):window.open("https://www.zeni.ai/product/business-checking-accounts","_blank")},onEventReceived:u=>{si.has(u)&&T()},onPusherSubscribed:T}})(st(oo)),Zt=({isPaymentDrawerOpen:e,closeDrawerHandler:n,pageName:t,creditAccountSpentAmount:a,productInformation:s,sourcePage:y,creditAccountInformation:g,debitAccountInformation:S,cashbackInformation:P,isDebitCardInfoFetchStateCompleted:m,isCreditCardInfoFetchStateCompleted:C,isCashbackInfoFetchStateCompleted:F,paymentInitiatedDate:w,retryRepayment:l})=>{const j=le(),{useDynamicConfig:B}=ue(),{configValue:L}=B(We.zeniAccountsConfig),p=Us(L),h=i(E=>$n(E)),{creditAccount:T}=i(E=>ua(E)),u=i(E=>ge(E)),v=Ot(),k=Ta(),U=me(),A=te.getSignedInUser(),b=Re(),[x,d]=r.useState(!1),[f,M]=r.useState(!1),{configValue:V}=B(We.zeniCardsConfig),O=V.credit_card_auto_pay_threshold_by_company_id?.[u.companyId]??V.default_credit_card_auto_pay_threshold??vo,R=zn(b?.loggedInUserRoleMap),z=js(b?.loggedInUserRoleMap),$=!!u.companyZeniAccountInfo?.info?.isZeniAccountEnabled,_=i(E=>wa(E,u.companyId)),D=_.companyChargeCardInfo?.primaryFundingAccount,G=_.allFundingAccounts.find(E=>E.id===D?.accountId),Q=i(E=>da(E,u.companyId)),I=la(Q.controllers);r.useEffect(()=>{if(h.fetchState!=="Completed"&&h.fetchState!=="In-Progress"&&U(Zn()),h.fetchState==="Completed"&&!f){const E=u.companyChargeCardInfo?.info?.primaryFundingAccount?.accountId,Y=h.transferFromAccounts.find(q=>q.id===E);let ne;if(y==="cardPaymentHistory"&&l){const q=l.paymentAccountId!=null?h.transferFromAccounts.find(ke=>ke.id===l.paymentAccountId):void 0;ne={amount:l.amount,isAutoRepayment:u.companyChargeCardInfo?.info?.isAutoPayEnabled??!1,idempotencyKey:yn(),transferFrom:q??Y}}else ne={amount:{amount:T.balance.amount+T.hold.amount,currencyCode:T.balance.currencyCode,currencySymbol:T.balance.currencySymbol},isAutoRepayment:u.companyChargeCardInfo?.info?.isAutoPayEnabled??!1,idempotencyKey:yn(),transferFrom:Y};U(gn(ne)),M(!0)}},[h.fetchState,f,y,l,h.transferFromAccounts,u.companyChargeCardInfo?.info?.primaryFundingAccount?.accountId,u.companyChargeCardInfo?.info?.isAutoPayEnabled,T.balance.amount,T.balance.currencyCode,T.balance.currencySymbol,T.hold.amount,U]);const N={isZeniCheckingEnabled:u.companyZeniAccountInfo?.info?.isZeniAccountEnabled??!1,isZeniCheckingPaymentSource:G?.accType==="depositAccount",creditCardPaymentSourceAccountName:G?.label,creditCardPaymentSourceAccountType:G?.accType,creditCardPaymentSourceLastFourDigits:G?.accountLast4,creditCardPaymentSourceBalance:G?.accountBalance?.available?.amount??0};if(r.useEffect(()=>{_.fetchState!=="Completed"&&_.fetchState!=="In-Progress"&&U(Pa(u.companyId,!0))},[_.fetchState]),r.useEffect(()=>{h.updateStatus==="Completed"&&P!=null&&F&&C&&m&&J.trackCardsPayEarlyPayNowClick(I,s,P,h.chargeCardRepaymentDetailLocalData.isAutoRepayment,{paymentAmount:h.chargeCardRepaymentDetailLocalData.amount.amount,paymentAccountName:h.chargeCardRepaymentDetailLocalData.transferFrom?.label,paymentAccountType:h.chargeCardRepaymentDetailLocalData.transferFrom?.accType,paymentAccountLastFourDigits:h.chargeCardRepaymentDetailLocalData.transferFrom?.accountLast4,paymentCompleteEta:w?.add(3,"day").format(Ka.visual.MMMDCommaYYYYformat),paymentInitiatedDate:w?.format(Ka.visual.MMMDCommaYYYYformat)},N,g,S)},[h.updateStatus,P,F,C,m,w]),r.useEffect(()=>{h.fetchState==="Completed"&&P!=null&&F&&C&&m&&!x&&e&&f&&P!=null&&(J.trackCardsPayEarlyFormView(I,s,P,t,u.companyChargeCardInfo?.info?.isAutoPayEnabled??!1,T.balance.amount,N,g,S),d(!0))},[h,F,C,m,x,e,f]),A==null)throw Error("Can't access invite people page without signing in...");const K=()=>{n(!0),U(Wn())},X=aa(u),o={events:e?ha(X,Nr):[],eventCallback:(E,Y,ne)=>{ne.onEventReceived(E)},onSubscribed:E=>{E.onPusherSubscribed()}};return c.jsx(c.Fragment,{children:c.jsx(Er,{onClose:()=>{K()},anchor:"right",transitionDuration:250,open:e,PaperProps:{style:{width:ri.overlayWidth.valuePercentage(k),boxShadow:"none"}},slotProps:{backdrop:{style:{backgroundColor:v.colors.black,opacity:.75,cursor:"pointer"}}},children:c.jsx(oi,{onClick:E=>E.stopPropagation(),children:c.jsx(ci,{...o,closeDrawerHandler:n,navigate:j,paymentDetails:h,creditAccountSpentAmount:a,onTransferClick:()=>{F&&C&&m&&P!=null&&J.trackCardsPayEarlyFormClick(I,s,P,"Pay Now",h.chargeCardRepaymentDetailLocalData.isAutoRepayment,{paymentAmount:h.chargeCardRepaymentDetailLocalData.amount.amount,paymentAccountName:h.chargeCardRepaymentDetailLocalData.transferFrom?.label,paymentAccountType:h.chargeCardRepaymentDetailLocalData.transferFrom?.accType,paymentAccountLastFourDigits:h.chargeCardRepaymentDetailLocalData.transferFrom?.accountLast4,paymentCompleteEta:void 0,paymentInitiatedDate:void 0},N,g,S),U(Ms({companyId:u.companyId}))},onDismissClick:K,onSaveChangesToLocalStore:E=>{U(gn(E))},currentTenant:u,hasZeniAccountsAdminAccess:R,isZeniAccountsUser:z,isZeniAccountSetupEnabled:$,productInformation:s,sourcePage:y,controllerEmails:I,autoPayThreshold:O,paymentSourceInformation:N,creditAccountInformation:g,debitAccountInformation:S,cashbackInformation:P,isCashbackInfoFetchStateCompleted:F,isCreditCardInfoFetchStateCompleted:C,isDebitCardInfoFetchStateCompleted:m,paymentInitiatedDate:w,maxInsuredAmount:p.maxInsuredAmount})})})})},oi=He(wo)`
15
15
  display: flex;
16
16
  min-height: 100%;
17
17
  flex-direction: column;
18
- `,Wt=e=>e!=null&&typeof e=="object"?e:null,de=e=>typeof e=="string"?e:void 0,Me=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,Ka=e=>e!=null&&typeof e=="object"&&typeof e.code=="string"&&typeof e.name=="string",gt=e=>{if(e==null||typeof e!="object")return!1;const n=e;return typeof n.transaction_id=="string"&&typeof n.amount=="number"&&typeof n.currency_code=="string"&&typeof n.currency_symbol=="string"&&typeof n.direction=="string"&&!!Ka(n.transaction_status)&&!!Ka(n.transaction_type)},Zt=(e,n)=>{const t=e?.card_status;if(!Ka(t))return null;const a=e?.is_locked_by_admin;return{cardId:n,cardStatus:t,isLockedByAdmin:typeof a=="boolean"?a:void 0}},At=[Br,Lr,Rr,Or,Ur,pa,Ht,ot,Gt,$t,zt],Vr=[Ra,La],ii=new Set([...At,...Vr]),St=ea.getLocalizedStrings().dateFormat,di=Pe(function(e,n){const{includeCreditAccountInfo:t,cardId:a,signedInUserToken:s,isChargeCardFeatureEnabled:y}=n,g=te.getSignedInUser(),S=e.tenantState.currentTenantId,P={userId:g?.userId??"",sessionId:g?.zeniSessionId??"",tenantId:S??""},m=vt(e,a,t,y),C=Js(e,a),F=ec(e);return{chargeCardDetailView:m,chargeCardsRecurringExpensesState:C,vgsVaultId:rt.cardVaultId,transactionAttachmentsEndpointToFetch:`${Et}/card_transaction_attachments`,transactionAttachmentEndpointToDownload:`${Et}/card_transaction_attachment`,authParams:P,isSnackbarOpen:F.isSnackbarOpen,cardsEndPoint:`${br.cardMicroServiceBaseUrl}`,signedInUserToken:m.twoFAView.token??s}},function(e,n){const{cardId:t,currentTenant:a,navigate:s,location:y,cardProviderId:g,includeCreditAccountInfo:S,setIsPaymentOpen:P,controllerEmails:m,productInformation:C,cashbackInformation:F,primaryFundingAccountDetails:w,creditAccountInformation:l,debitAccountInformation:j,isChargeCardFeatureEnabled:B}=n,{tenantEmailDomain:L}=a;return{onEventReceived:(p,h)=>{(({event:T,data:u,cardId:v,dispatch:k,subscribedEvents:U})=>{const A=Wt(u);switch(T){case Ra:case La:return void k(_a(!0));case Br:{const b=de(A?.card_id);if(b==null||b!==v)return;const x=de(A?.transaction_id),d=A?.transaction_status;return x!=null&&Ka(d)?void k(Qs({transactionId:x,transactionStatus:d})):void k(ca(v,null,null,!0))}case pa:{const b=de(A?.card_id)??v;if(b!==v)return;const x=Zt(A,b);return x!=null?void k(Ft(x)):void k(Sa(v,!0))}case Ht:{const b=de(A?.card_id)??v;if(b!==v)return;const x=de(A?.currency_code),d=de(A?.currency_symbol),f=Me(A?.balance);return x!=null&&d!=null&&f!=null?(k(qs({cardId:b,currencyCode:x,currencySymbol:d,balance:f,hold:Me(A?.hold),dailyPurchaseSpends:Me(A?.daily_purchase_spends),monthlyPurchaseSpends:Me(A?.monthly_purchase_spends),dailyWithdrawals:Me(A?.daily_withdrawals),monthlyWithdrawals:Me(A?.monthly_withdrawals)})),void k(Qe(!0))):(k(Sa(v,!0)),void k(Qe(!0)))}case ot:{const b=de(A?.currency_code),x=de(A?.currency_symbol),d=Me(A?.available_amount),f=Me(A?.balance_amount);return b!=null&&x!=null&&d!=null&&f!=null?void k(Ks({currencyCode:b,currencySymbol:x,available:d,balance:f,hold:Me(A?.hold_amount),cashback:Me(A?.cashback_amount)})):void k(Qe(!0))}case Lr:{const b=de(A?.card_id)??v;if(b!==v)return;const x=A?.transaction;return gt(x)?void k(Zs({cardId:b,transaction:x})):void k(ca(v,null,null,!0))}case Rr:{const b=de(A?.card_id)??v;if(b!==v)return;const x=A?.transaction;return gt(x)?void k(Ws({cardId:b,declineReason:de(A?.decline_reason),transaction:x})):void k(ca(v,null,null,!0))}case Or:{const b=de(A?.card_id)??v;if(b!==v)return;const x=A?.transaction;return gt(x)?void k(Ys({cardId:b,transaction:x})):void k(ca(v,null,null,!0))}case Ur:{const b=de(A?.card_id)??v;if(b!==v)return;const x=de(A?.transaction_id),d=A?.attachment_file_paths;return x!=null&&Array.isArray(d)&&d.every(f=>typeof f=="string")?void k(zs({cardId:b,transactionId:x,attachmentFilePaths:d})):void k(ca(v,null,null,!0))}case Gt:case $t:case zt:{const b=de(A?.card_id);if(b==null||b!==v)return;k(Sa(v,!0))}}})({event:p,data:h,cardId:t,dispatch:e,subscribedEvents:ii})},onPusherSubscribed:()=>{e(Sa(t,!0)),e(ca(t,null,null,!0)),e(Qe(!0))},onReloadTransactions:()=>{e(ka(t,S,B))},onFetchChargeCardTransactionList:(p,h)=>{e(ca(t,p,h))},onUpdateScrollYOffset:p=>{},onGetOtp:p=>{g!=null&&e(at(p,"ChargeCardHolder",t))},onResendOtp:p=>{g!=null&&e(et(p,"ChargeCardHolder",t))},onVerifyOtp:(p,h)=>{g!=null&&e(Ja(p,h,"ChargeCardHolder",t))},onVerifyOtpSuccess:p=>{p!=null&&te.saveZeniOtpTokenForCardHolder(p,t)},onColorCodeChange:p=>{e(cc(t,p))},onLockChargeCard:(p,h)=>{e(tr(p,t,h))},onUnlockChargeCard:p=>{e(ar(p,t))},onCloseChargeCard:p=>{e(er(t,p))},onFetchChargeCardsRecurringExpenses:()=>{e(Jn([t]))},updateChargeCardName:(p,h)=>{e(Xn(p,t,h))},updateChargeCardTransactionAttachments:(p,h)=>{h!=null&&e(sc({transactionId:p,data:h}))},updateChargeCardTransactionUploadReceiptsFetchStatus:(p,h,T,u)=>{e(rc({chargeCardId:h,transactionId:p,fetchState:T,error:u}))},updateChargeCardTransactionReceiptsShowTick:(p,h,T)=>{e(nc({chargeCardId:h,transactionId:p,shouldShowTick:T}))},onChargeCardRevokeInviteClick:()=>{e(Qn(t))},updateChargeCardTransactionIsViewReceiptClicked:(p,h,T)=>{e(tc({chargeCardId:h,transactionId:p,isViewReceiptClicked:T}))},onChargeCardTransactionRowClick:(p,h)=>{const T=ye(y.state?.pathnameStackToGoBack,y.pathname);s(`../../transaction/${p}/${h}`,{state:{pathnameStackToGoBack:T}})},onBackClick:()=>{const p=we(y.state?.pathnameStackToGoBack),h=ta(L);s(h,{state:{pathnameStackToGoBack:p.newStack,message:"comingFromCardDetail"}})},removeSnackbar:()=>{e(ac())},onUpdateDebitCardPinAttempt:p=>{e(qn(t,p)),p==="success"&&e(Ye({messageSection:"update_debit_card_pin_attempt",messageText:"success",type:"success",showStatusIcon:!0}))},onUploadReceiptComplete:(p,h)=>{p?e(Ye({messageSection:"charge_card_receipt_upload",messageText:"success",type:"success",showStatusIcon:!0})):h!=null&&e(Ye({messageSection:"charge_card_receipt_upload",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:h.message}]}))},updateSpendLimit(p,h,T,u){e(Kn(p,h,T.code,u))},shouldOpenCreditCardPaymentDrawer(p){p&&F!=null&&J.trackCardsPayEarlyClick(m,C,F,"Card Detail","Text Button","Pay Now",{isZeniCheckingEnabled:a.company?.companyZeniAccountInfo.isZeniAccountEnabled??!1,isZeniCheckingPaymentSource:w?.accType==="depositAccount",creditCardPaymentSourceAccountName:w?.label,creditCardPaymentSourceAccountType:w?.accType,creditCardPaymentSourceLastFourDigits:w?.accountLast4,creditCardPaymentSourceBalance:w?.accountBalance?.available?.amount??0},l,j),P(p)}}})(st(lo));function li(){const e=le(),n=me(),t=he(),{cardId:a}=Ve(),[s,y]=r.useState(!1),[g,S]=r.useState(!1),{useDynamicConfig:P}=ue(),m=te.getSignedInUser(),C=i(Y=>ge(Y)),F=i(Y=>qa(Y).firstViewAfterActivation),w=i(Y=>Y.classListState.fetchState),{configValue:l}=P(We.documentAiReceiptMaxSizeLimitBytesConfig),{configValue:j}=P(We.zeniCardsConfig),B=j.enable_card_controls_for_company_ids,L=j.is_card_controls_enabled_for_all_tenants===!0||Array.isArray(B)&&B.includes(C.companyId),[p,h]=r.useState(!1),[T,u]=r.useState(!1),{useFeatureGate:v}=ue(),{isFeatureEnabled:k}=v(W.isChargeCardFeatureEnabled),{isFeatureEnabled:U}=v(W.isDebitCardFeatureEnabled),A=Le(U,C),b=Oe({isDebitCardFeatureEnabled:U,isBankingOnlyTenant:A}),{isFeatureEnabled:x}=v(W.isEarlyPayFeatureEnabled),{isFeatureEnabled:d}=v(W.isCardsCommentingEnabled),f=Be(C),M=xe(C),V=C.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,O=Ue({isCardsOnlyTenant:M,isChargeCardFeatureEnabled:k,isBookKeepingTenant:f,isDebitCardProductVisible:b,chargeCardsCreditAccountLimit:V}),R=!!C.companyDebitCardInfo?.info?.isDebitCardEnabled,z=!!C.companyChargeCardInfo?.info?.isChargeCardEnabled,$=!C.userRole.includes("charge_card_user")&&O&&z;if(a==null)throw Error("Empty card id is not valid...");const _=i(Y=>wa(Y,C.companyId)),{creditAccount:D,creditAccountRepayment:G}=i(Y=>ua(Y)),Q=te.getZeniOtpTokenForCardHolder(a),I=i(Y=>vt(Y,a,$,O)),{isAiCfoAccessEnabled:N,onAskAiCfoClick:Z}=xa({mobileExploreReferrer:"Card Detail"});Lt({isDataReady:I.fetchState==="Completed"});const X=i(Y=>ma(Y)),o=I.chargeCard,E=Re(),K=Fe(E?.loggedInUserRoleMap),ne=o?.type.code==="business_physical_debit_card"||o?.type.code==="business_virtual_debit_card",q=o?.type.code==="business_physical_debit_card"||o?.type.code==="business_physical_credit_card",ke=o?.type.code==="business_virtual_debit_card"||o?.type.code==="business_virtual_credit_card",ve=o?.type.code==="business_virtual_debit_card",fe=Ba(O,z,K,D,G),se=Ar(ne,I),Ee=Mt(K,X),re=Je(O,b,R,z),Ce=I.depositAccountLimitFetchState.fetchState!=="Completed"&&I.depositAccountLimitFetchState.fetchState!=="In-Progress",Ae=i(Y=>da(Y,C.companyId)),ee=la(Ae.controllers),Te=i(Y=>o?.cardCreatedByUser?.userId!=null?$a(Y.userRoleState,o?.cardCreatedByUser?.userId):void 0),De=i(Y=>Te?.accountingClassIDs[0]!=null?za(Y.classState,{classId:Te?.accountingClassIDs[0],reportId:"class_list"}):void 0),ae=i(Y=>o?.cardHolderUser?.userId!=null?$a(Y.userRoleState,o?.cardHolderUser?.userId):void 0),oe=i(Y=>ae?.accountingClassIDs[0]!=null?za(Y.classState,{classId:ae?.accountingClassIDs[0],reportId:"class_list"}):void 0),fa=C?.userRole,na=i(Y=>Ca(Y,!1,b,k).revokeCardInvite),Oa=ya(na.saveStatus.fetchState);if(r.useEffect(()=>{if(Oa==="In-Progress"&&na.saveStatus.fetchState==="Completed"){const Y=ta(C.tenantEmailDomain);e(Y)}},[Oa,na.saveStatus.fetchState,e,C.tenantEmailDomain]),r.useEffect(()=>{F&&s===!1&&ke&&(y(!0),setTimeout(()=>{n(Ya()),ve&&n(Ye({messageSection:"set_debit_card_pin",messageText:"success",type:"success",showStatusIcon:!0}))},5e3))},[F,s,ke,ve]),r.useEffect(()=>{p||I.fetchState==="Completed"||I.fetchState==="In-Progress"||a==null||(h(!0),n(ka(a,$,O,!1)))},[p,I,a,n]),r.useEffect(()=>{!T&&I.fetchState==="Completed"&&I.chargeCard?.connectedAccountId!=null&&ne&&Ce&&K&&(u(!0),n(Zn({depositAccountId:I.chargeCard?.connectedAccountId})))},[T,I,n,Ce,K]),r.useEffect(()=>{X.fetchState!=="Completed"&&X.fetchState!=="In-Progress"&&K&&n(_a()),w!=="Completed"&&w!=="In-Progress"&&n(Vn()),I.transactionStatistics.fetchState!=="Completed"&&I.transactionStatistics.fetchState!=="In-Progress"&&n(Xs({chargeCardId:a})),_.fetchState!=="Completed"&&_.fetchState!=="In-Progress"&&n(Pa(C.companyId,!0))},[X.fetchState,n,K,w,I.transactionStatistics.fetchState,_.fetchState]),r.useEffect(()=>{if(!(I.fetchState!=="Completed"||O&&D.fetchState!=="Completed"||o==null||I.transactionStatistics.fetchState!=="Completed"||ne&&K&&I.depositAccountLimitFetchState.fetchState!=="Completed")){const Y=o.type.code.includes("physical"),Se=Y?o.cardActivationAttemptHistory[0]?.timestamp:o.createTime;J.trackCardsCardDetailView(ee,re,{cardId:a,cardName:o.cardName,cardType:o.type.code.includes("credit")?"credit":"debit",cardCategory:Y?"physical":"virtual",cardLimit:ba(o.limit.amount),cardLastFourDigits:o.accountLast4,cardStatus:o.status.code,cardAssignedDate:o.createTime?.format(St.analytics.MMMDashDDDashYYYYFormat),cardIssuedDate:o.providerCardCreateTime?.format(St.analytics.MMMDashDDDashYYYYFormat),cardActivatedDate:Se?.format(St.analytics.MMMDashDDDashYYYYFormat),cardLimitFrequency:o.creditLimitFrequency.name,cardSpentAmount:ba(o.balance.amount),cardAvailableLimit:ba(o.available.amount),cardUtilizationPercent:o.limit.amount>0?Math.round((o.limit.amount-o.available.amount)/o.limit.amount*100):0,cardUtilizationAmount:ba(o.limit.amount-o.available.amount),totalNumberOfDeclinedTransactions:I.transactionStatistics.statistics.totalNumberOfDeclinedTransactions,numberOfDeclinedTransactionsCurrentMonth:I.transactionStatistics.statistics.numberOfDeclinedTransactionsCurrentMonth,totalNumberOfPaidTransactions:I.transactionStatistics.statistics.totalNumberOfPaidTransactions,numberOfPaidTransactionsCurrentMonth:I.transactionStatistics.statistics.numberOfPaidTransactionsCurrentMonth,totalNumberOfCanceledTransactions:I.transactionStatistics.statistics.totalNumberOfCanceledTransactions,numberOfCanceledTransactionsCurrentMonth:I.transactionStatistics.statistics.numberOfCanceledTransactionsCurrentMonth,totalNumberOfAuthorizedTransactions:I.transactionStatistics.statistics.totalNumberOfAuthorizedTransactions,numberOfAuthorizedTransactionsCurrentMonth:I.transactionStatistics.statistics.numberOfAuthorizedTransactionsCurrentMonth,totalNumberOfTransactionsWithReceipts:I.transactionStatistics.statistics.totalNumberOfTransactionsWithReceipts,numberOfTransactionsWithReceiptsCurrentMonth:I.transactionStatistics.statistics.numberOfTransactionsWithReceiptsCurrentMonth},{cardIssuedByName:kt(o.cardCreatedByUser,!1),cardIssuedByEmail:o.cardCreatedByUser?.email,cardIssuedByUserId:o.cardCreatedByUser?.userId,cardIssuedByRole:Te?.userRoles,cardIssuedByDepartment:De?.className},{cardholderName:kt(o.cardHolderUser,!1),cardholderEmail:o.cardHolderUser?.email,cardholderRole:ae?.userRoles,cardholderUserId:o.cardHolderUser?.userId,cardholderDepartment:oe?.className},fe,se)}},[I.fetchState,I.depositAccountLimitFetchState.fetchState,I.transactionStatistics.fetchState,D.fetchState,K]),m==null)throw Error("Can't access card detail page without signing in...");const dt=aa(C),Ea=K?[...At,...Vr]:At,ra={events:ha(dt,Ea),eventCallback:(Y,Se,ie)=>{ie.onEventReceived(Y,Se)},onSubscribed:Y=>{Y.onPusherSubscribed()}},Aa=()=>{if(a!=null&&o!=null){const{ownerName:Y,cardName:Se,utilisation:ie,limit:Ge,frequency:Ze,cardColor:$e}=bt(o),ze=o.cardHolderUserId===m.userId;J.trackCardsDetailPageViewed(a,Y,Se,ie,Ge,Ze,$e,ze)}};r.useEffect(()=>{if(I.fetchState==="Completed"){const Y=I.chargeCard;if(Y?.status.code==="inactive"||ne&&Y?.isPinSet===!1||q&&F){const Se=_e(C.tenantEmailDomain,a,m,o,F);e(Se)}}},[I.fetchState]);const lt=(Y,Se)=>{if(a!=null&&o!=null){const{ownerName:ie,cardName:Ge,utilisation:Ze,limit:$e,frequency:ze}=bt(o),sa=o.cardHolderUserId===m.userId;J.trackCardsDetailPageClicked(a,ie,Ge,Ze,$e,ze,Y,sa,Se)}},ut=(Y,Se)=>{if(a!=null&&o!=null){const{ownerName:ie,cardName:Ge,utilisation:Ze,limit:$e,frequency:ze}=bt(o),sa=o.cardHolderUserId===m.userId;J.trackCardsVerifyPopUpClick(a,ie,Ge,Ze,$e,ze,Y,sa,Se)}},pe=D.balance.amount+D.hold.amount,Ua=C.companyChargeCardInfo?.info?.primaryFundingAccount,Da=_.allFundingAccounts.find(Y=>Y.id===Ua?.accountId),ja=I.chargeCard!=null,Ma=I.depositAccountLimit!=null;return I.fetchState!=="Error"||ja?!ja&&(I.fetchState==="In-Progress"||I.fetchState==="Not-Started")||na.saveStatus.fetchState==="In-Progress"||!Ma&&ne&&K&&I.depositAccountLimitFetchState.fetchState!=="Completed"?c.jsx(io,{}):c.jsxs(c.Fragment,{children:[c.jsx(nt,{showConfetti:F}),I.fetchState==="Completed"?c.jsx(Ut,{analytics:J,onLoad:Aa}):null,g===!0?c.jsx(Yt,{closeDrawerHandler:()=>S(!1),isPaymentDrawerOpen:g,pageName:"Card Detail",sourcePage:"cardDetailPage",productInformation:re,creditAccountInformation:fe,debitAccountInformation:se,cashbackInformation:Ee,creditAccountSpentAmount:pe,isDebitCardInfoFetchStateCompleted:!ne||!K||I.depositAccountLimitFetchState.fetchState==="Completed",isCreditCardInfoFetchStateCompleted:!O||D.fetchState==="Completed",isCashbackInfoFetchStateCompleted:!K||X.fetchState==="Completed",paymentInitiatedDate:G.initiatedRepaymentDate}):null,c.jsx(di,{...ra,hideSorting:!0,onColumnSortConfigChanged:()=>{},onFireVerifyPopOnClickAnalytics:ut,onFireOnClickAnalytics:lt,isSandboxEnv:Rt(),signedInUser:m,location:t,navigate:e,setIsPaymentOpen:S,cardIssuedByRoles:Te?.userRoles,cardIssuedByDepartmentName:De?.className,cardHolderRoles:ae?.userRoles,cardHolderDepartmentName:oe?.className,loggedInUserRole:fa,isChargeCardFeatureEnabled:O,isDebitCardFeatureEnabled:b,isDebitCardSetupEnabled:R,isChargeCardSetupEnabled:z,isCardControlsEnabled:L,isEarlyPayEnabled:x,controllerEmails:ee,chargeCardCashbackDetailState:X,productInformation:re,creditAccountInformation:fe,debitAccountInformation:se,cashbackInformation:Ee,classListFetchState:w,primaryFundingAccountDetails:Da,currentTenant:C,cardProviderId:I.chargeCard?.cardProviderID,cardId:a,creditAccount:D,creditAccountRepayment:G,includeCreditAccountInfo:$,signedInUserToken:Q,appleWalletLink:"shoebox://",googleWalletLink:"https://www.android.com/payapp/",documentAiReceiptMaxSizeLimit:l.documentAiReceiptMaxSizeLimitBytes!=null?l.documentAiReceiptMaxSizeLimitBytes:9437184,isAiCfoAccessEnabled:N,onAskAiCfoClick:Z,isCardsCommentingEnabled:d})]}):c.jsx(ct,{})}const bt=e=>{const n=`${e.cardHolderUser?.firstName.toLowerCase()} ${e.cardHolderUser?.lastName.toLowerCase()}`,t=e.cardName,a=(e.limit.amount??0)-(e.available.amount??0),s=e.limit.amount,y=e.creditLimitFrequency.name;return{ownerName:n,cardName:t,utilisation:a,cardColor:e.cardColorCode??"",frequency:y,limit:s}},{spendManagement:{chargeCard:{cardsAiCfoHero:{headline:ui,subheadline:mi,pageTitle:Ci}}}}=ea.getLocalizedStrings(),Hr=[pa,ot,Mr,La,Ra,it,zt,Zo,Gt,$t,Ht],pi=new Set(Hr),Dt=jt((e,n,t,a)=>{e(ia(n,t,a,!0))},400),hi=He.div`
18
+ `,Wt=e=>e!=null&&typeof e=="object"?e:null,de=e=>typeof e=="string"?e:void 0,Me=e=>typeof e=="number"&&Number.isFinite(e)?e:void 0,Ya=e=>e!=null&&typeof e=="object"&&typeof e.code=="string"&&typeof e.name=="string",gt=e=>{if(e==null||typeof e!="object")return!1;const n=e;return typeof n.transaction_id=="string"&&typeof n.amount=="number"&&typeof n.currency_code=="string"&&typeof n.currency_symbol=="string"&&typeof n.direction=="string"&&!!Ya(n.transaction_status)&&!!Ya(n.transaction_type)},Kt=(e,n)=>{const t=e?.card_status;if(!Ya(t))return null;const a=e?.is_locked_by_admin;return{cardId:n,cardStatus:t,isLockedByAdmin:typeof a=="boolean"?a:void 0}},At=[Br,Lr,Rr,Or,Ur,pa,Ht,ot,Gt,$t,zt],Vr=[Ra,La],ii=new Set([...At,...Vr]),St=ea.getLocalizedStrings().dateFormat,di=Pe(function(e,n){const{includeCreditAccountInfo:t,cardId:a,signedInUserToken:s,isChargeCardFeatureEnabled:y}=n,g=te.getSignedInUser(),S=e.tenantState.currentTenantId,P={userId:g?.userId??"",sessionId:g?.zeniSessionId??"",tenantId:S??""},m=vt(e,a,t,y),C=Js(e,a),F=ec(e);return{chargeCardDetailView:m,chargeCardsRecurringExpensesState:C,vgsVaultId:rt.cardVaultId,transactionAttachmentsEndpointToFetch:`${Et}/card_transaction_attachments`,transactionAttachmentEndpointToDownload:`${Et}/card_transaction_attachment`,authParams:P,isSnackbarOpen:F.isSnackbarOpen,cardsEndPoint:`${br.cardMicroServiceBaseUrl}`,signedInUserToken:m.twoFAView.token??s}},function(e,n){const{cardId:t,currentTenant:a,navigate:s,location:y,cardProviderId:g,includeCreditAccountInfo:S,setIsPaymentOpen:P,controllerEmails:m,productInformation:C,cashbackInformation:F,primaryFundingAccountDetails:w,creditAccountInformation:l,debitAccountInformation:j,isChargeCardFeatureEnabled:B}=n,{tenantEmailDomain:L}=a;return{onEventReceived:(p,h)=>{(({event:T,data:u,cardId:v,dispatch:k,subscribedEvents:U})=>{const A=Wt(u);switch(T){case Ra:case La:return void k(_a(!0));case Br:{const b=de(A?.card_id);if(b==null||b!==v)return;const x=de(A?.transaction_id),d=A?.transaction_status;return x!=null&&Ya(d)?void k(Qs({transactionId:x,transactionStatus:d})):void k(ca(v,null,null,!0))}case pa:{const b=de(A?.card_id)??v;if(b!==v)return;const x=Kt(A,b);return x!=null?void k(Ft(x)):void k(Sa(v,!0))}case Ht:{const b=de(A?.card_id)??v;if(b!==v)return;const x=de(A?.currency_code),d=de(A?.currency_symbol),f=Me(A?.balance);return x!=null&&d!=null&&f!=null?(k(qs({cardId:b,currencyCode:x,currencySymbol:d,balance:f,hold:Me(A?.hold),dailyPurchaseSpends:Me(A?.daily_purchase_spends),monthlyPurchaseSpends:Me(A?.monthly_purchase_spends),dailyWithdrawals:Me(A?.daily_withdrawals),monthlyWithdrawals:Me(A?.monthly_withdrawals)})),void k(Qe(!0))):(k(Sa(v,!0)),void k(Qe(!0)))}case ot:{const b=de(A?.currency_code),x=de(A?.currency_symbol),d=Me(A?.available_amount),f=Me(A?.balance_amount);return b!=null&&x!=null&&d!=null&&f!=null?void k(Ys({currencyCode:b,currencySymbol:x,available:d,balance:f,hold:Me(A?.hold_amount),cashback:Me(A?.cashback_amount)})):void k(Qe(!0))}case Lr:{const b=de(A?.card_id)??v;if(b!==v)return;const x=A?.transaction;return gt(x)?void k(Ks({cardId:b,transaction:x})):void k(ca(v,null,null,!0))}case Rr:{const b=de(A?.card_id)??v;if(b!==v)return;const x=A?.transaction;return gt(x)?void k(Ws({cardId:b,declineReason:de(A?.decline_reason),transaction:x})):void k(ca(v,null,null,!0))}case Or:{const b=de(A?.card_id)??v;if(b!==v)return;const x=A?.transaction;return gt(x)?void k(Zs({cardId:b,transaction:x})):void k(ca(v,null,null,!0))}case Ur:{const b=de(A?.card_id)??v;if(b!==v)return;const x=de(A?.transaction_id),d=A?.attachment_file_paths;return x!=null&&Array.isArray(d)&&d.every(f=>typeof f=="string")?void k(zs({cardId:b,transactionId:x,attachmentFilePaths:d})):void k(ca(v,null,null,!0))}case Gt:case $t:case zt:{const b=de(A?.card_id);if(b==null||b!==v)return;k(Sa(v,!0))}}})({event:p,data:h,cardId:t,dispatch:e,subscribedEvents:ii})},onPusherSubscribed:()=>{e(Sa(t,!0)),e(ca(t,null,null,!0)),e(Qe(!0))},onReloadTransactions:()=>{e(ka(t,S,B))},onFetchChargeCardTransactionList:(p,h)=>{e(ca(t,p,h))},onUpdateScrollYOffset:p=>{},onGetOtp:p=>{g!=null&&e(at(p,"ChargeCardHolder",t))},onResendOtp:p=>{g!=null&&e(et(p,"ChargeCardHolder",t))},onVerifyOtp:(p,h)=>{g!=null&&e(Ja(p,h,"ChargeCardHolder",t))},onVerifyOtpSuccess:p=>{p!=null&&te.saveZeniOtpTokenForCardHolder(p,t)},onColorCodeChange:p=>{e(cc(t,p))},onLockChargeCard:(p,h)=>{e(tr(p,t,h))},onUnlockChargeCard:p=>{e(ar(p,t))},onCloseChargeCard:p=>{e(er(t,p))},onFetchChargeCardsRecurringExpenses:()=>{e(Jn([t]))},updateChargeCardName:(p,h)=>{e(Xn(p,t,h))},updateChargeCardTransactionAttachments:(p,h)=>{h!=null&&e(sc({transactionId:p,data:h}))},updateChargeCardTransactionUploadReceiptsFetchStatus:(p,h,T,u)=>{e(rc({chargeCardId:h,transactionId:p,fetchState:T,error:u}))},updateChargeCardTransactionReceiptsShowTick:(p,h,T)=>{e(nc({chargeCardId:h,transactionId:p,shouldShowTick:T}))},onChargeCardRevokeInviteClick:()=>{e(Qn(t))},updateChargeCardTransactionIsViewReceiptClicked:(p,h,T)=>{e(tc({chargeCardId:h,transactionId:p,isViewReceiptClicked:T}))},onChargeCardTransactionRowClick:(p,h)=>{const T=ye(y.state?.pathnameStackToGoBack,y.pathname);s(`../../transaction/${p}/${h}`,{state:{pathnameStackToGoBack:T}})},onBackClick:()=>{const p=we(y.state?.pathnameStackToGoBack),h=ta(L);s(h,{state:{pathnameStackToGoBack:p.newStack,message:"comingFromCardDetail"}})},removeSnackbar:()=>{e(ac())},onUpdateDebitCardPinAttempt:p=>{e(qn(t,p)),p==="success"&&e(Ze({messageSection:"update_debit_card_pin_attempt",messageText:"success",type:"success",showStatusIcon:!0}))},onUploadReceiptComplete:(p,h)=>{p?e(Ze({messageSection:"charge_card_receipt_upload",messageText:"success",type:"success",showStatusIcon:!0})):h!=null&&e(Ze({messageSection:"charge_card_receipt_upload",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:h.message}]}))},updateSpendLimit(p,h,T,u){e(Yn(p,h,T.code,u))},shouldOpenCreditCardPaymentDrawer(p){p&&F!=null&&J.trackCardsPayEarlyClick(m,C,F,"Card Detail","Text Button","Pay Now",{isZeniCheckingEnabled:a.company?.companyZeniAccountInfo.isZeniAccountEnabled??!1,isZeniCheckingPaymentSource:w?.accType==="depositAccount",creditCardPaymentSourceAccountName:w?.label,creditCardPaymentSourceAccountType:w?.accType,creditCardPaymentSourceLastFourDigits:w?.accountLast4,creditCardPaymentSourceBalance:w?.accountBalance?.available?.amount??0},l,j),P(p)}}})(st(lo));function li(){const e=le(),n=me(),t=he(),{cardId:a}=Ve(),[s,y]=r.useState(!1),[g,S]=r.useState(!1),{useDynamicConfig:P}=ue(),m=te.getSignedInUser(),C=i(Z=>ge(Z)),F=i(Z=>qa(Z).firstViewAfterActivation),w=i(Z=>Z.classListState.fetchState),{configValue:l}=P(We.documentAiReceiptMaxSizeLimitBytesConfig),{configValue:j}=P(We.zeniCardsConfig),B=j.enable_card_controls_for_company_ids,L=j.is_card_controls_enabled_for_all_tenants===!0||Array.isArray(B)&&B.includes(C.companyId),[p,h]=r.useState(!1),[T,u]=r.useState(!1),{useFeatureGate:v}=ue(),{isFeatureEnabled:k}=v(W.isChargeCardFeatureEnabled),{isFeatureEnabled:U}=v(W.isDebitCardFeatureEnabled),A=Le(U,C),b=Oe({isDebitCardFeatureEnabled:U,isBankingOnlyTenant:A}),{isFeatureEnabled:x}=v(W.isEarlyPayFeatureEnabled),{isFeatureEnabled:d}=v(W.isCardsCommentingEnabled),f=Be(C),M=xe(C),V=C.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,O=Ue({isCardsOnlyTenant:M,isChargeCardFeatureEnabled:k,isBookKeepingTenant:f,isDebitCardProductVisible:b,chargeCardsCreditAccountLimit:V}),R=!!C.companyDebitCardInfo?.info?.isDebitCardEnabled,z=!!C.companyChargeCardInfo?.info?.isChargeCardEnabled,$=!C.userRole.includes("charge_card_user")&&O&&z;if(a==null)throw Error("Empty card id is not valid...");const _=i(Z=>wa(Z,C.companyId)),{creditAccount:D,creditAccountRepayment:G}=i(Z=>ua(Z)),Q=te.getZeniOtpTokenForCardHolder(a),I=i(Z=>vt(Z,a,$,O)),{isAiCfoAccessEnabled:N,onAskAiCfoClick:K}=xa({mobileExploreReferrer:"Card Detail"});Lt({isDataReady:I.fetchState==="Completed"});const X=i(Z=>ma(Z)),o=I.chargeCard,E=Re(),Y=Fe(E?.loggedInUserRoleMap),ne=o?.type.code==="business_physical_debit_card"||o?.type.code==="business_virtual_debit_card",q=o?.type.code==="business_physical_debit_card"||o?.type.code==="business_physical_credit_card",ke=o?.type.code==="business_virtual_debit_card"||o?.type.code==="business_virtual_credit_card",ve=o?.type.code==="business_virtual_debit_card",fe=Ba(O,z,Y,D,G),se=Ar(ne,I),Ee=Mt(Y,X),re=Je(O,b,R,z),Ce=I.depositAccountLimitFetchState.fetchState!=="Completed"&&I.depositAccountLimitFetchState.fetchState!=="In-Progress",Ae=i(Z=>da(Z,C.companyId)),ee=la(Ae.controllers),Te=i(Z=>o?.cardCreatedByUser?.userId!=null?$a(Z.userRoleState,o?.cardCreatedByUser?.userId):void 0),De=i(Z=>Te?.accountingClassIDs[0]!=null?za(Z.classState,{classId:Te?.accountingClassIDs[0],reportId:"class_list"}):void 0),ae=i(Z=>o?.cardHolderUser?.userId!=null?$a(Z.userRoleState,o?.cardHolderUser?.userId):void 0),oe=i(Z=>ae?.accountingClassIDs[0]!=null?za(Z.classState,{classId:ae?.accountingClassIDs[0],reportId:"class_list"}):void 0),fa=C?.userRole,na=i(Z=>Ca(Z,!1,b,k).revokeCardInvite),Oa=ya(na.saveStatus.fetchState);if(r.useEffect(()=>{if(Oa==="In-Progress"&&na.saveStatus.fetchState==="Completed"){const Z=ta(C.tenantEmailDomain);e(Z)}},[Oa,na.saveStatus.fetchState,e,C.tenantEmailDomain]),r.useEffect(()=>{F&&s===!1&&ke&&(y(!0),setTimeout(()=>{n(Za()),ve&&n(Ze({messageSection:"set_debit_card_pin",messageText:"success",type:"success",showStatusIcon:!0}))},5e3))},[F,s,ke,ve]),r.useEffect(()=>{p||I.fetchState==="Completed"||I.fetchState==="In-Progress"||a==null||(h(!0),n(ka(a,$,O,!1)))},[p,I,a,n]),r.useEffect(()=>{!T&&I.fetchState==="Completed"&&I.chargeCard?.connectedAccountId!=null&&ne&&Ce&&Y&&(u(!0),n(Kn({depositAccountId:I.chargeCard?.connectedAccountId})))},[T,I,n,Ce,Y]),r.useEffect(()=>{X.fetchState!=="Completed"&&X.fetchState!=="In-Progress"&&Y&&n(_a()),w!=="Completed"&&w!=="In-Progress"&&n(Vn()),I.transactionStatistics.fetchState!=="Completed"&&I.transactionStatistics.fetchState!=="In-Progress"&&n(Xs({chargeCardId:a})),_.fetchState!=="Completed"&&_.fetchState!=="In-Progress"&&n(Pa(C.companyId,!0))},[X.fetchState,n,Y,w,I.transactionStatistics.fetchState,_.fetchState]),r.useEffect(()=>{if(!(I.fetchState!=="Completed"||O&&D.fetchState!=="Completed"||o==null||I.transactionStatistics.fetchState!=="Completed"||ne&&Y&&I.depositAccountLimitFetchState.fetchState!=="Completed")){const Z=o.type.code.includes("physical"),Se=Z?o.cardActivationAttemptHistory[0]?.timestamp:o.createTime;J.trackCardsCardDetailView(ee,re,{cardId:a,cardName:o.cardName,cardType:o.type.code.includes("credit")?"credit":"debit",cardCategory:Z?"physical":"virtual",cardLimit:ba(o.limit.amount),cardLastFourDigits:o.accountLast4,cardStatus:o.status.code,cardAssignedDate:o.createTime?.format(St.analytics.MMMDashDDDashYYYYFormat),cardIssuedDate:o.providerCardCreateTime?.format(St.analytics.MMMDashDDDashYYYYFormat),cardActivatedDate:Se?.format(St.analytics.MMMDashDDDashYYYYFormat),cardLimitFrequency:o.creditLimitFrequency.name,cardSpentAmount:ba(o.balance.amount),cardAvailableLimit:ba(o.available.amount),cardUtilizationPercent:o.limit.amount>0?Math.round((o.limit.amount-o.available.amount)/o.limit.amount*100):0,cardUtilizationAmount:ba(o.limit.amount-o.available.amount),totalNumberOfDeclinedTransactions:I.transactionStatistics.statistics.totalNumberOfDeclinedTransactions,numberOfDeclinedTransactionsCurrentMonth:I.transactionStatistics.statistics.numberOfDeclinedTransactionsCurrentMonth,totalNumberOfPaidTransactions:I.transactionStatistics.statistics.totalNumberOfPaidTransactions,numberOfPaidTransactionsCurrentMonth:I.transactionStatistics.statistics.numberOfPaidTransactionsCurrentMonth,totalNumberOfCanceledTransactions:I.transactionStatistics.statistics.totalNumberOfCanceledTransactions,numberOfCanceledTransactionsCurrentMonth:I.transactionStatistics.statistics.numberOfCanceledTransactionsCurrentMonth,totalNumberOfAuthorizedTransactions:I.transactionStatistics.statistics.totalNumberOfAuthorizedTransactions,numberOfAuthorizedTransactionsCurrentMonth:I.transactionStatistics.statistics.numberOfAuthorizedTransactionsCurrentMonth,totalNumberOfTransactionsWithReceipts:I.transactionStatistics.statistics.totalNumberOfTransactionsWithReceipts,numberOfTransactionsWithReceiptsCurrentMonth:I.transactionStatistics.statistics.numberOfTransactionsWithReceiptsCurrentMonth},{cardIssuedByName:kt(o.cardCreatedByUser,!1),cardIssuedByEmail:o.cardCreatedByUser?.email,cardIssuedByUserId:o.cardCreatedByUser?.userId,cardIssuedByRole:Te?.userRoles,cardIssuedByDepartment:De?.className},{cardholderName:kt(o.cardHolderUser,!1),cardholderEmail:o.cardHolderUser?.email,cardholderRole:ae?.userRoles,cardholderUserId:o.cardHolderUser?.userId,cardholderDepartment:oe?.className},fe,se)}},[I.fetchState,I.depositAccountLimitFetchState.fetchState,I.transactionStatistics.fetchState,D.fetchState,Y]),m==null)throw Error("Can't access card detail page without signing in...");const dt=aa(C),Ea=Y?[...At,...Vr]:At,ra={events:ha(dt,Ea),eventCallback:(Z,Se,ie)=>{ie.onEventReceived(Z,Se)},onSubscribed:Z=>{Z.onPusherSubscribed()}},Aa=()=>{if(a!=null&&o!=null){const{ownerName:Z,cardName:Se,utilisation:ie,limit:Ge,frequency:Ke,cardColor:$e}=bt(o),ze=o.cardHolderUserId===m.userId;J.trackCardsDetailPageViewed(a,Z,Se,ie,Ge,Ke,$e,ze)}};r.useEffect(()=>{if(I.fetchState==="Completed"){const Z=I.chargeCard;if(Z?.status.code==="inactive"||ne&&Z?.isPinSet===!1||q&&F){const Se=_e(C.tenantEmailDomain,a,m,o,F);e(Se)}}},[I.fetchState]);const lt=(Z,Se)=>{if(a!=null&&o!=null){const{ownerName:ie,cardName:Ge,utilisation:Ke,limit:$e,frequency:ze}=bt(o),sa=o.cardHolderUserId===m.userId;J.trackCardsDetailPageClicked(a,ie,Ge,Ke,$e,ze,Z,sa,Se)}},ut=(Z,Se)=>{if(a!=null&&o!=null){const{ownerName:ie,cardName:Ge,utilisation:Ke,limit:$e,frequency:ze}=bt(o),sa=o.cardHolderUserId===m.userId;J.trackCardsVerifyPopUpClick(a,ie,Ge,Ke,$e,ze,Z,sa,Se)}},pe=D.balance.amount+D.hold.amount,Ua=C.companyChargeCardInfo?.info?.primaryFundingAccount,Da=_.allFundingAccounts.find(Z=>Z.id===Ua?.accountId),ja=I.chargeCard!=null,Ma=I.depositAccountLimit!=null;return I.fetchState!=="Error"||ja?!ja&&(I.fetchState==="In-Progress"||I.fetchState==="Not-Started")||na.saveStatus.fetchState==="In-Progress"||!Ma&&ne&&Y&&I.depositAccountLimitFetchState.fetchState!=="Completed"?c.jsx(io,{}):c.jsxs(c.Fragment,{children:[c.jsx(nt,{showConfetti:F}),I.fetchState==="Completed"?c.jsx(Ut,{analytics:J,onLoad:Aa}):null,g===!0?c.jsx(Zt,{closeDrawerHandler:()=>S(!1),isPaymentDrawerOpen:g,pageName:"Card Detail",sourcePage:"cardDetailPage",productInformation:re,creditAccountInformation:fe,debitAccountInformation:se,cashbackInformation:Ee,creditAccountSpentAmount:pe,isDebitCardInfoFetchStateCompleted:!ne||!Y||I.depositAccountLimitFetchState.fetchState==="Completed",isCreditCardInfoFetchStateCompleted:!O||D.fetchState==="Completed",isCashbackInfoFetchStateCompleted:!Y||X.fetchState==="Completed",paymentInitiatedDate:G.initiatedRepaymentDate}):null,c.jsx(di,{...ra,hideSorting:!0,onColumnSortConfigChanged:()=>{},onFireVerifyPopOnClickAnalytics:ut,onFireOnClickAnalytics:lt,isSandboxEnv:Rt(),signedInUser:m,location:t,navigate:e,setIsPaymentOpen:S,cardIssuedByRoles:Te?.userRoles,cardIssuedByDepartmentName:De?.className,cardHolderRoles:ae?.userRoles,cardHolderDepartmentName:oe?.className,loggedInUserRole:fa,isChargeCardFeatureEnabled:O,isDebitCardFeatureEnabled:b,isDebitCardSetupEnabled:R,isChargeCardSetupEnabled:z,isCardControlsEnabled:L,isEarlyPayEnabled:x,controllerEmails:ee,chargeCardCashbackDetailState:X,productInformation:re,creditAccountInformation:fe,debitAccountInformation:se,cashbackInformation:Ee,classListFetchState:w,primaryFundingAccountDetails:Da,currentTenant:C,cardProviderId:I.chargeCard?.cardProviderID,cardId:a,creditAccount:D,creditAccountRepayment:G,includeCreditAccountInfo:$,signedInUserToken:Q,appleWalletLink:"shoebox://",googleWalletLink:"https://www.android.com/payapp/",documentAiReceiptMaxSizeLimit:l.documentAiReceiptMaxSizeLimitBytes!=null?l.documentAiReceiptMaxSizeLimitBytes:9437184,isAiCfoAccessEnabled:N,onAskAiCfoClick:K,isCardsCommentingEnabled:d})]}):c.jsx(ct,{})}const bt=e=>{const n=`${e.cardHolderUser?.firstName.toLowerCase()} ${e.cardHolderUser?.lastName.toLowerCase()}`,t=e.cardName,a=(e.limit.amount??0)-(e.available.amount??0),s=e.limit.amount,y=e.creditLimitFrequency.name;return{ownerName:n,cardName:t,utilisation:a,cardColor:e.cardColorCode??"",frequency:y,limit:s}},{spendManagement:{chargeCard:{cardsAiCfoHero:{headline:ui,subheadline:mi,pageTitle:Ci}}}}=ea.getLocalizedStrings(),Hr=[pa,ot,Mr,La,Ra,it,zt,Ko,Gt,$t,Ht],pi=new Set(Hr),Dt=jt((e,n,t,a)=>{e(ia(n,t,a,!0))},400),hi=He.div`
19
19
  display: flex;
20
20
  width: 100%;
21
21
  flex: 1 1 auto;
22
22
  flex-direction: column;
23
23
  align-items: center;
24
24
  background-color: ${e=>e.theme.colors.grey4};
25
- `,fi=Pe(function(e,n){const t=Ca(e,n.includeCreditAccountDebitSummaryAndCashbackInfo,n.isDebitCardFeatureEnabled&&n.isDebitCardSetupEnabled,n.isChargeCardFeatureEnabled&&n.isChargeCardSetupEnabled);return{chargeCardListView:t,rowActionView:uc(e),bulkActionView:mc(e),companyLegalName:n.currentTenant.companyName,admins:n.admins,searchText:t.searchText,uiState:t.uiState,signedInUser:n.signedInUser}},function(e,n){const{navigateAndClearBulkSelection:t,currentTenant:a,location:s,signedInUser:y,chargeCardListState:g,includeCreditAccountDebitSummaryAndCashbackInfo:S,isChargeCardFeatureEnabled:P,isCreditCardProductVisibleForExpressInterest:m,isChargeCardSetupEnabled:C,isDebitCardFeatureEnabled:F,isDebitCardSetupEnabled:w,isDebitCardTOSAccepted:l,isChargeCardTOSAccepted:j,controllerEmails:B,depositAccountListWithDebitCardIssued:L,primaryFundingAccountDetails:p,chargeCardSetUpViewFetchState:h,productInformation:T,cashbackInformation:u,creditAccountInformation:v,debitAccountInformation:k,updatePayNowInfoTooltip:U,isUserHasCardsAdminLevelAccess:A}=n,{tenantEmailDomain:b}=a,{cards:x}=g;return{onChargeCardRowClick:(d,f)=>{const M=_r(x,d);let V;M!=null&&((R=>{const z=R.limit.amount-R.available.amount,$=`${R.cardHolderUser?.firstName.toLowerCase()} ${R.cardHolderUser?.lastName.toLowerCase()}`,_=R.cardName,D=R.department?.className??"",G=R.limit.amount,Q=R.creditLimitFrequency.name;J.trackCardsListRowClicked($,_,D,z,G,Q,y.userId===R.cardHolderUserId)})(M),oa(F,w,L)&&J.trackCardsCardListRowClick(B,T,"Card Row Item","row_clicked",f+1,{cardOwner:kt(M.cardHolderUser,!1),cardName:M.cardName,cardType:M.type.code.includes("credit")?"credit":"debit",cardStatus:M.status.code,cardUtilizationAmount:ba(M.limit.amount-M.available.amount),cardUtilizationPercent:M.limit.amount>0?Math.round((M.limit.amount-M.available.amount)/M.limit.amount*100):0,cardLimit:ba(M.limit.amount)},u,v,k)),V=M?.status.code==="request_on_hold"&&y.userId===M.cardHolderUserId?Pr(b):_e(b,d,y,M);const O=ye(s.state?.pathnameStackToGoBack,s.pathname);t(V,{state:{pathnameStackToGoBack:O}})},onFetchChargeCardsRecurringExpenses:d=>{e(Jn(d))},onFetchDepositAccountLimit:d=>{e(Zn({depositAccountId:d}))},onChargeCardResendInviteClick:d=>{e(yc(d))},onChargeCardRevokeInviteClick:d=>{e(Qn(d))},onLockChargeCardList:(d,f)=>{e(bc(d,f))},onUnlockChargeCardList:d=>{e(Sc(d))},onCloseChargeCardList:(d,f)=>{e(gc(d,f))},onRevokeChargeCardList:d=>{e(fc(d))},updateChargeCardListSpendLimit(d,f,M){e(hc(d,f,M.code))},onLockChargeCard:(d,f)=>{e(tr(A,d,f))},onUnlockChargeCard:d=>{e(ar(A,d))},onCloseChargeCard:(d,f)=>{e(er(d,f))},onUpdateSpendLimit(d,f,M,V){e(Kn(d,f,M.code,V))},updateChargeCardName:(d,f)=>{e(Xn(A,d,f))},onClickSetupIcon:()=>{J.trackCardsListPageClicked("settings"),oa(F,w,L)&&u!=null&&J.trackCardsSettingsClick(B,T,u,v,k);const d=Fo(b),f=ye(s.state?.pathnameStackToGoBack,s.pathname);t(d,{state:{pathnameStackToGoBack:f}})},onIssueCardClick:()=>{J.trackCardsListPageClicked("new card"),oa(F,w,L)&&u!=null&&J.trackCardsNewCardClick(B,T,u,"New Button","card_creation_initiated","Card List",v,k);const d=gi(b),f=ye(s.state?.pathnameStackToGoBack,s.pathname);t(d,{state:{pathnameStackToGoBack:f}})},onColumnSortConfigChanged:(d,f)=>{oa(F,w,L)&&u!=null&&J.trackCardsCardListSortClick(B,T,u,"Sort Icon","sort",d,f==="ascending"?"ASC":"DESC","Cards List",v,k),e(It({uiState:{sortKey:d,sortOrder:f}}))},onSearchTextChanged:d=>{e(pc(d))},onReloadCards:()=>{e(ia(S,F&&w,P&&C,!0))},onLetsGoClick:()=>{t("./onboard")},onBackClick:()=>{t("../../")},onTotalCashbackClick:()=>{oa(F,w,L)&&u!=null&&J.trackCardsCashbackOverviewClick(B,T,u,"Cashback Overview","cashback_details_viewed",v,k),t("./cashback")},onClickStatementsIcon:()=>{oa(F,w,L)&&u!=null&&J.trackCardsStatementsClick(B,T,u,v,k),t("./statements")},onCreateNowClick:d=>{oa(F,w,L)&&u!=null&&J.trackCardsNewCardClick(B,T,u,"Promo Banner","card_creation_initiated","Card List",v,k),t(`./new?cardType=${d}`)},onPromoCardClick:d=>{t(d==="debit"&&F&&!l||d==="credit"&&m&&!j?`../promo?cardPromoType=${d}`:"./setup")},navigateToCreditCardPaymentPage:(d,f)=>{h==="Completed"&&a.company!=null&&u!=null&&J.trackCardsPayEarlyClick(B,T,u,"Card List",d,f,{isZeniCheckingEnabled:a.company.companyZeniAccountInfo.isZeniAccountEnabled,isZeniCheckingPaymentSource:p?.accType==="depositAccount",creditCardPaymentSourceAccountName:p?.label,creditCardPaymentSourceAccountType:p?.accType,creditCardPaymentSourceLastFourDigits:p?.accountLast4,creditCardPaymentSourceBalance:p?.accountBalance?.available?.amount??0},v,k);const M=Si(b);t(M)},navigateToCreditCardPaymentHistoryPage:()=>{const d=bi(b),f=ye(s.state?.pathnameStackToGoBack,s.pathname);t(d,{state:{pathnameStackToGoBack:f}})},shouldShowPayNowInfoTooltip:U,onSetRowActionCardId:d=>{e(Cc(d))},onSetBulkActionCardIds:d=>{e(nr(d))},onEventReceived:d=>{pi.has(d)&&Dt(e,S,F&&w,P&&C)},onPusherSubscribed:()=>{Dt(e,S,F&&w,P&&C)}}})(st(Co));function kn({isPaymentDrawerOpen:e}){const n=le(),t=me(),a=he(),s=r.useCallback((H,je)=>{t(nr([])),n(H,je)},[t,n]),[y,g]=r.useState(!1),[S,P]=r.useState(te.getPayNowInfoTooltip()??!1),m=H=>{te.savePayNowInfoTooltip(H),P(H)},[C,F]=r.useState(!1),w=te.getSignedInUser(),l=i(H=>ge(H)),[j,B]=r.useState(!1),[L,p]=r.useState(!1),{isAiCfoAccessEnabled:h,onAskAiCfoClick:T}=xa({mobileExploreReferrer:"Cards"}),u=l.userRole.includes("charge_card_user"),v=!u,k=!!l.companyDebitCardInfo?.info?.isDebitCardEnabled,{useFeatureGate:U,useDynamicConfig:A}=ue(),{isFeatureEnabled:b}=U(W.isCashbackFeatureEnabled),{isFeatureEnabled:x}=U(W.isChargeCardFeatureEnabled),{isFeatureEnabled:d}=U(W.isDebitCardFeatureEnabled),{isFeatureEnabled:f}=U(W.isEarlyPayFeatureEnabled),{isFeatureEnabled:M}=U(W.isChargeCardPaymentHistoryFeatureEnabled),{isFeatureEnabled:V}=U(W.isCardsCommentingEnabled),{isFeatureEnabled:O}=U(W.isAiCfoFileUploadEnabled),{isFeatureEnabled:R}=U(W.isCardPolicyEnabled),{isFeatureEnabled:z}=U(W.isAiCardCreationEnabled),$=Le(d,l),_=Oe({isDebitCardFeatureEnabled:d,isBankingOnlyTenant:$}),D=xe(l),G=Be(l),Q=l.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,I=Ue({isCardsOnlyTenant:D,isChargeCardFeatureEnabled:x,isBookKeepingTenant:G,isDebitCardProductVisible:_,chargeCardsCreditAccountLimit:Q}),N=Dr({isCardsOnlyTenant:D,isChargeCardFeatureEnabled:x,isBookKeepingTenant:G}),{configValue:Z}=A(We.zeniCardsConfig),X=Re(),o=Fe(X?.loggedInUserRoleMap),E=i(H=>da(H,l.companyId)),K=la(E.controllers),ne=Z.charge_card_cashback_rate_per_transaction!=null?Z.charge_card_cashback_rate_per_transaction:.0175,q=Z.credit_card_pay_now_threshold_by_company_id?.[l.companyId]??Z.default_credit_card_pay_now_threshold??To,ke=Z.is_card_controls_enabled_for_all_tenants===!0||Array.isArray(Z.enable_card_controls_for_company_ids)&&Z.enable_card_controls_for_company_ids.includes(l.companyId),ve=!!l.companyChargeCardInfo?.info?.isChargeCardTOSAccepted,fe=!!l.companyDebitCardInfo?.info?.isDebitCardTOSAccepted,se=!!l.companyChargeCardInfo?.info?.isChargeCardEnabled,Ee=!!l.company?.companyChargeCardInfo?.isChargeCardEnabled,re=!!l.company?.companyDebitCardInfo?.isDebitCardEnabled,Ce=i(H=>$n(H)),Ae=ya(Ce.updateStatus),ee=i(H=>Ca(H,v,_&&k,I&&se)),Te=i(H=>oc(H)),De=i(H=>ic(H)),ae=i(H=>dc(H)),oe=i(H=>lc(H)),fa=i(H=>ae==null?[]:Nn(H.aiCfoState,ae).filter(je=>je.kind==="creating_cards"),_t),na=ya(De.fetchState);r.useEffect(()=>{na==="In-Progress"&&De.fetchState==="Completed"&&ae!=null&&fa.forEach(H=>{t(yt({chatSessionId:ae,id:H.id,entityIds:oe,kind:"created_cards"}))})},[t,De.fetchState,ae,oe,fa,na]);const Oa=ee.cards.filter(H=>H.type.code.includes("debit")).map(H=>H.connectedAccountId),dt=[...new Set(Oa)],Ea=i(H=>ma(H)),ra=i(H=>tt(H,dt)),Aa=i(H=>wa(H,l.companyId)),lt=Aa.companyChargeCardInfo?.primaryFundingAccount,ut=Aa.allFundingAccounts.find(H=>H.id===lt?.accountId),pe=ee.fetchState,Ua=ee.creditAccount,Da=r.useCallback(()=>o===!0&&R===!0&&pe==="Completed"&&te.getCardPolicyPopupSeen(l.tenantEmailDomain??"")!==!0,[o,R,pe,l.tenantEmailDomain]),[ja,Ma]=r.useState(Da);r.useEffect(()=>{Ma(Da())},[Da]);const Y=()=>{te.saveCardPolicyPopupSeen(l.tenantEmailDomain??"",!0),Ma(!1)},Se=pe==="Completed"&&!ee.hasCreditCard&&!ee.hasDebitCard;uo({isDataReady:pe==="Completed",pageContext:Se?"cards_creation":"cards"});const{creditAccountRepayment:ie}=i(H=>ua(H)),Ge=i(H=>qa(H).firstViewAfterActivation),{areTenantIdsInSync:Ze}=yr(),$e=Mt(o,Ea),ze=Ba(I,se,o,Ua,ie),sa=Nt(_,k,o,ra,ee.debitCardSummary),mt=Je(I,_,k,se),Ct=ee.creditAccount.balance.amount+ee.creditAccount.hold.amount;if(r.useEffect(()=>{pe==="Completed"&&(te.getPayNowInfoTooltip()==null||Ct<q*ee.creditAccount.limit.amount/100)&&m(!0)},[pe,q,Ct,ee.creditAccount.limit.amount]),r.useEffect(()=>{if(e!=null&&e===!0&&ie.initiatedRepayments.amount===0&&ie.fetchState==="Completed"||Ae==="In-Progress"&&Ce.updateStatus==="Completed")m(!1),g(!0);else if(ie.initiatedRepayments.amount>0&&ie.fetchState==="Completed"){g(!1),document.body.style.overflow="auto";const H=ta(l.tenantEmailDomain);s(H)}},[e,ie.initiatedRepayments.amount,ie.fetchState,Ae,Ce.updateStatus,s,l.tenantEmailDomain]),r.useEffect(()=>{!j&&(se||k)&&(Ee||re)&&Ze&&(B(!0),t(ia(v,_&&k,I&&se,!1)))},[j,v,t,Ze,Ee,re]),r.useEffect(()=>{Ge&&C===!1&&(F(!0),setTimeout(()=>{t(Ya())},5e3))},[Ge,C]),r.useEffect(()=>()=>{Dt.flush()},[]),r.useEffect(()=>{pe==="Completed"&&u&&ee.cards.length===1&&(ee.cards[0].status.code==="inactive"&&ee.cards[0].type.code==="business_physical_credit_card"?s(`./${ee.cards[0].id}/activate`):ee.cards[0].status.code!=="request_on_hold"&&(a.state?.message==="comingFromCardDetail"?s("../../"):s(`./${ee.cards[0].id}`)))},[pe,u,a.state,s,ee.cards]),r.useEffect(()=>{if(pe==="Completed"&&u){const H=ee.cards.length,je=ee.cards.filter(Ke=>Ke.cardHolderUserId===w?.userId).filter(Ke=>Ke.status.code==="request_on_hold");je.length>0&&H===je.length&&s("./onboard")}},[pe,ee.cards,u,s,w?.userId]),r.useEffect(()=>{pe!=="Completed"||I&&ie.fetchState!=="Completed"||_&&k&&o&&ra.fetchState!=="Completed"||J.trackCardsCardListView(K,mt,$e,ze,sa)},[pe,Ua,ie.fetchState,ra.fetchState,o]),w==null)throw Error("Can't access charge card list page without signing in...");const Yr=i(H=>rr(H.userState,H.userRoleState,H.userListViewState,"cardAdmin")),Kt=xt(X?.loggedInUserRoleMap),qt=H=>{p(H)},Wr=ee.creditAccount.limit,Zr=()=>{g(!1),s("..")},Kr=l.companyChargeCardInfo?.info!=null&&Ia({cardInfo:l.companyChargeCardInfo.info,isProductVisible:I&&Ee,isTOSAccepted:ve,isSetupEnabled:se,isUserHasCardsAdminLevelAccess:o,isUserHasCardsAccess:Kt}),qr=l.companyDebitCardInfo?.info!=null&&Ia({cardInfo:l.companyDebitCardInfo.info,isProductVisible:_&&re,isTOSAccepted:fe,isSetupEnabled:k,isUserHasCardsAdminLevelAccess:o,isUserHasCardsAccess:Kt}),Qr=Kr||qr,Qt=function(H){const{isEmptyCardsState:je,isChargeCardAdmin:Ke,isFileUploadEnabled:an}=H,tn=le(),Na=he(),{tenantEmailDomain:Va}=Ve(),{isAiCfoOpen:ts,setIsAiCfoOpen:nn}=hr(),ns=fr(),rs=gr(),rn=i(be=>Mn(be)).createSessionAndSubmitState.fetchState==="In-Progress",{chips:sn,isResolved:cn}=xr("cards_creation"),on=r.useMemo(()=>Fr(sn,cn,3),[sn,cn]),[Ha,pt]=r.useState(""),dn=rs&&ns&&Va!=null&&!ts,ga=r.useCallback(be=>{if(Va==null)return;const ss=ye(Na.state?.pathnameStackToGoBack,Na.pathname);tn(`/${Va}/cards/ask`,{state:{message:"",origin:"",pathnameStackToGoBack:ss,referrer:"cards_hero",aiCfoInitialQuestion:be,aiCfoShouldSubmit:be!=null&&be.trim().length>0}})},[Na.pathname,Na.state,tn,Va]),ln=r.useCallback(be=>{be.trim().length!==0&&(pt(""),ga(be))},[ga]),un=r.useCallback(()=>{const be=Ha.trim();be.length!==0&&(pt(""),ga(be))},[Ha,ga]),mn=r.useCallback(()=>{},[]),Cn=r.useCallback(be=>{pt(be)},[]),pn=r.useCallback(()=>{nn(!0)},[nn]),hn=r.useCallback(()=>{ga(void 0)},[ga]);return r.useMemo(()=>{if(dn&&je&&Ke)return{aiAgentName:Ci,headline:ui,subheadline:mi,promptChips:on,composer:{currentInput:Ha,isSubmitting:rn,isFileUploadEnabled:an,onInputChange:Cn,onSubmit:un,onStopSubmit:mn},onPromptClick:ln,onOpenSidePanel:pn,onOpenFullView:hn,dataTestIdPrefix:"cards-ai-cfo-hero"}},[Ha,dn,Ke,je,an,rn,Cn,hn,pn,ln,mn,un,on])}({isEmptyCardsState:Se,isChargeCardAdmin:o,isFileUploadEnabled:O}),Xt=z&&Qt!=null?c.jsx(Sr,{...Qt}):null,{isCardsShuttingDown:Jt,shutdownContent:en}=Ir(l.tenantId,l.company?.managementInfo?.receiverEmails),Xr=Jt===!0&&en!=null?c.jsx(mo,{shutdownContent:en}):null,Jr=h&&Xt==null,es=aa(l),as={events:ha(es,Hr),eventCallback:(H,je,Ke)=>{Ke.onEventReceived(H)},onSubscribed:H=>{H.onPusherSubscribed()}};return se||k?c.jsxs(c.Fragment,{children:[pe==="Completed"?c.jsxs(c.Fragment,{children:[c.jsx(Ut,{analytics:J,onLoad:()=>{J.trackPageLoaded(kr.Event.cardsListPage),(I&&!se||_&&!k)&&J.trackCardsPromoView(K,{isCreditCardOffered:I,isDebitCardOffered:_,isDebitCardEnabled:k,isCreditCardEnabled:se},"Banner",_&&!k?"Debit Card":I&&!se?"Credit Card":"","Card List")}}),c.jsx(nt,{showConfetti:Ge})]}):null,y===!0?c.jsx(Yt,{closeDrawerHandler:Zr,isPaymentDrawerOpen:y,pageName:"Card List",sourcePage:"cardListPage",creditAccountSpentAmount:Ct,productInformation:mt,creditAccountInformation:ze,debitAccountInformation:sa,cashbackInformation:$e,isDebitCardInfoFetchStateCompleted:!(_&&k&&o)||ra.fetchState==="Completed",isCreditCardInfoFetchStateCompleted:!I||ie.fetchState==="Completed",isCashbackInfoFetchStateCompleted:!o||Ea.fetchState==="Completed",paymentInitiatedDate:ie.initiatedRepaymentDate}):null,c.jsxs(hi,{children:[c.jsx(Ie,{isAppContentDrawerOpen:L,handleDrawerToggle:qt}),c.jsx(fi,{...as,isCashbackFeatureEnabled:b,isChargeCardFeatureEnabled:I,isDebitCardFeatureEnabled:_,isCreditCardProductVisibleForExpressInterest:N,updatePayNowInfoTooltip:m,showPayNowInfoTooltip:S,creditCardPayNowThreshold:q,signedInUser:w,chargeCardListState:ee,location:a,admins:Yr.users,navigateAndClearBulkSelection:s,currentTenant:l,isCardControlsEnabled:ke,companyChargeCardInfoCreditAccountLimit:l.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,isCompanyInterestedInChargeCard:l.companyChargeCardInfo?.info?.isCompanyInterestedInChargeCard??!1,isUserHasCardsAdminLevelAccess:o,includeCreditAccountDebitSummaryAndCashbackInfo:v,onClickMenuIcon:()=>{qt(!0)},creditLimit:Wr,isChargeCardSetupEnabled:se,isChargeCardEnabledOnCompany:Ee,isDebitCardSetupEnabled:k,isDebitCardEnabledOnCompany:re,isEarlyPayEnabled:f,isChargeCardPaymentHistoryFeatureEnabled:M,cashbackRate:ne,controllerEmails:K,chargeCardCashbackDetailState:Ea,depositAccountListWithDebitCardIssued:ra,isChargeCardTOSAccepted:ve,isDebitCardTOSAccepted:fe,primaryFundingAccountDetails:ut,chargeCardSetUpViewFetchState:Aa.fetchState,productInformation:mt,creditAccountInformation:ze,debitAccountInformation:sa,cashbackInformation:$e,isAiCfoAccessEnabled:Jr,onAskAiCfoClick:T,isCardsCommentingEnabled:V,cardsAiCfoHero:Xt,cardsShutdownBanner:Xr,isCardsShuttingDown:Jt,onClickPolicyIcon:o&&R?()=>n(yi(l.tenantEmailDomain)):void 0,isPolicyIntroTooltipVisible:ja,onPolicyIntroTooltipClose:Y,pendingCreationCount:Te})]})]}):(ve||fe)&&o===!0?c.jsx(Xe,{to:"../setup"}):Qr?c.jsx(Xe,{to:"../promo"}):c.jsx(va,{fetchState:pe})}const gi=e=>`/${e}/cards/new`,Si=e=>`/${e}/cards/payment`,bi=e=>`/${e}/cards/payment-history`,yi=e=>`/${e}/cards/policy`,Gr=[jr,Mr],Ii=new Set(Gr),ki=Pe(function(e){const n=te.getSignedInUser(),t=ge(e),a=e.tenantState.currentTenantId,s=sr(e),y={userId:n?.userId??"",sessionId:n?.zeniSessionId??"",tenantId:a??""},g=t?.companyName??"",S=e.chargeCardPaymentHistoryState.downloadUIState.downloadState;return{fetchState:s.fetchState,filters:s.filters,isZeniTenant:Ic(t),repaymentList:s.repaymentHistory,searchText:s.searchText,repaymentHistoryUsers:s.repaymentHistoryUsers,sortConfig:{sortKey:s.uiState.sortKey,sortOrder:s.uiState.sortOrder},downloadParams:{authParams:y,companyName:g,spendManagementEndPoint:`${Et}/spendManagement`,isShowDeletedBillsEnabled:!1,isShowDeletedReimbursementEnabled:!1},downloadState:S}},function(e,n){const{location:t,navigate:a}=n;return{onBackClick:()=>{const s=we(t.state?.pathnameStackToGoBack),y=s.poppedPathname??"..";a(y,{state:{pathnameStackToGoBack:s.newStack}})},onColumnSortConfigChanged:(s,y)=>{e({type:"chargeCardPaymentHistory/updatePaymentHistoryUIState",payload:{uiState:{sortKey:s,sortOrder:y}}})},onFiltersChange:s=>{e(Ec({filters:s}))},onReloadPayments:()=>{e(Ga(!0))},onEventReceived:s=>{Ii.has(s)&&e(Ga(!0))},onPusherSubscribed:()=>{e(Ga(!0))},onSearchTextChanged:s=>{e({type:"chargeCardPaymentHistory/updatePaymentHistorySearchText",payload:s})},updateDownloadStateHandler:s=>{e(kc({uiState:{downloadState:s}}))}}})(st(po));function Ei(){const e=le(),n=he(),t=me(),{areTenantIdsInSync:a}=yr(),{useFeatureGate:s}=ue();if(te.getSignedInUser()==null)throw Error("Can't access payment history page without signing in...");const y=i(o=>ge(o)),g=i(o=>sr(o)),[S,P]=r.useState(!1),[m,C]=r.useState(!1),[F,w]=r.useState(!1),[l,j]=r.useState(null),B=!y.userRole.includes("charge_card_user"),L=!!y.companyDebitCardInfo?.info?.isDebitCardEnabled,{isFeatureEnabled:p}=s(W.isChargeCardFeatureEnabled),{isFeatureEnabled:h}=s(W.isDebitCardFeatureEnabled),T=Le(h,y),u=Oe({isDebitCardFeatureEnabled:h,isBankingOnlyTenant:T}),v=xe(y),k=Be(y),U=y.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,A=Ue({isCardsOnlyTenant:v,isChargeCardFeatureEnabled:p,isBookKeepingTenant:k,isDebitCardProductVisible:u,chargeCardsCreditAccountLimit:U}),b=!!y.companyChargeCardInfo?.info?.isChargeCardEnabled,x=Re(),d=Fe(x?.loggedInUserRoleMap),f=i(o=>Ca(o,B,u&&L,A&&b)),M=r.useMemo(()=>{const o=f.cards.filter(E=>E.type.code.includes("debit"));return[...new Set(o.map(E=>E.connectedAccountId))]},[f.cards]),V=i(o=>ma(o)),O=i(o=>tt(o,M)),{creditAccountRepayment:R}=i(o=>ua(o)),z=r.useMemo(()=>Mt(d,V),[d,V]),$=r.useMemo(()=>Ba(A,b,d,f.creditAccount,R),[A,b,d,f.creditAccount,R]),_=r.useMemo(()=>Nt(u,L,d,O,f.debitCardSummary),[u,L,d,O,f.debitCardSummary]),D=r.useMemo(()=>Je(A,u,L,b),[A,u,L,b]),G=f.creditAccount.balance.amount+f.creditAccount.hold.amount,Q=r.useMemo(()=>l!=null?g.repaymentHistory.find(o=>o.cardRepaymentId===l):void 0,[l,g.repaymentHistory]),I=r.useCallback(o=>{j(o),t(ia(B,u&&L,A&&b,!1)),w(!0)},[t,B,u,L,A,b]),N=r.useCallback(()=>{w(!1),j(null),document.body.style.overflow="auto"},[]);r.useEffect(()=>{S||g.fetchState==="Completed"||g.fetchState==="In-Progress"||(P(!0),t(Ga()))},[S,t,g.fetchState]),r.useEffect(()=>{!m&&(b||L)&&a&&(C(!0),t(ia(B,!1,A&&b,!1)))},[m,b,L,a,t,B,A]);const Z=aa(y),X={events:ha(Z,Gr),eventCallback:(o,E,K)=>{K.onEventReceived(o)},onSubscribed:o=>{o.onPusherSubscribed()}};return c.jsxs(c.Fragment,{children:[F?c.jsx(Yt,{closeDrawerHandler:N,isPaymentDrawerOpen:F,pageName:"Payment History",sourcePage:"cardPaymentHistory",creditAccountSpentAmount:G,productInformation:D,creditAccountInformation:$,debitAccountInformation:_,cashbackInformation:z,isDebitCardInfoFetchStateCompleted:!(u&&L&&d)||O.fetchState==="Completed",isCreditCardInfoFetchStateCompleted:!A||R.fetchState==="Completed",isCashbackInfoFetchStateCompleted:!d||V.fetchState==="Completed",paymentInitiatedDate:R.initiatedRepaymentDate,retryRepayment:Q}):null,c.jsx(ki,{...X,location:n,navigate:e,accountInfoByAccountId:g.accountInfoByAccountId,onRetryPaymentClick:I})]})}const En=He.div`
25
+ `,fi=Pe(function(e,n){const t=Ca(e,n.includeCreditAccountDebitSummaryAndCashbackInfo,n.isDebitCardFeatureEnabled&&n.isDebitCardSetupEnabled,n.isChargeCardFeatureEnabled&&n.isChargeCardSetupEnabled);return{chargeCardListView:t,rowActionView:uc(e),bulkActionView:mc(e),companyLegalName:n.currentTenant.companyName,admins:n.admins,searchText:t.searchText,uiState:t.uiState,signedInUser:n.signedInUser}},function(e,n){const{navigateAndClearBulkSelection:t,currentTenant:a,location:s,signedInUser:y,chargeCardListState:g,includeCreditAccountDebitSummaryAndCashbackInfo:S,isChargeCardFeatureEnabled:P,isCreditCardProductVisibleForExpressInterest:m,isChargeCardSetupEnabled:C,isDebitCardFeatureEnabled:F,isDebitCardSetupEnabled:w,isDebitCardTOSAccepted:l,isChargeCardTOSAccepted:j,controllerEmails:B,depositAccountListWithDebitCardIssued:L,primaryFundingAccountDetails:p,chargeCardSetUpViewFetchState:h,productInformation:T,cashbackInformation:u,creditAccountInformation:v,debitAccountInformation:k,updatePayNowInfoTooltip:U,isUserHasCardsAdminLevelAccess:A}=n,{tenantEmailDomain:b}=a,{cards:x}=g;return{onChargeCardRowClick:(d,f)=>{const M=_r(x,d);let V;M!=null&&((R=>{const z=R.limit.amount-R.available.amount,$=`${R.cardHolderUser?.firstName.toLowerCase()} ${R.cardHolderUser?.lastName.toLowerCase()}`,_=R.cardName,D=R.department?.className??"",G=R.limit.amount,Q=R.creditLimitFrequency.name;J.trackCardsListRowClicked($,_,D,z,G,Q,y.userId===R.cardHolderUserId)})(M),oa(F,w,L)&&J.trackCardsCardListRowClick(B,T,"Card Row Item","row_clicked",f+1,{cardOwner:kt(M.cardHolderUser,!1),cardName:M.cardName,cardType:M.type.code.includes("credit")?"credit":"debit",cardStatus:M.status.code,cardUtilizationAmount:ba(M.limit.amount-M.available.amount),cardUtilizationPercent:M.limit.amount>0?Math.round((M.limit.amount-M.available.amount)/M.limit.amount*100):0,cardLimit:ba(M.limit.amount)},u,v,k)),V=M?.status.code==="request_on_hold"&&y.userId===M.cardHolderUserId?Pr(b):_e(b,d,y,M);const O=ye(s.state?.pathnameStackToGoBack,s.pathname);t(V,{state:{pathnameStackToGoBack:O}})},onFetchChargeCardsRecurringExpenses:d=>{e(Jn(d))},onFetchDepositAccountLimit:d=>{e(Kn({depositAccountId:d}))},onChargeCardResendInviteClick:d=>{e(yc(d))},onChargeCardRevokeInviteClick:d=>{e(Qn(d))},onLockChargeCardList:(d,f)=>{e(bc(d,f))},onUnlockChargeCardList:d=>{e(Sc(d))},onCloseChargeCardList:(d,f)=>{e(gc(d,f))},onRevokeChargeCardList:d=>{e(fc(d))},updateChargeCardListSpendLimit(d,f,M){e(hc(d,f,M.code))},onLockChargeCard:(d,f)=>{e(tr(A,d,f))},onUnlockChargeCard:d=>{e(ar(A,d))},onCloseChargeCard:(d,f)=>{e(er(d,f))},onUpdateSpendLimit(d,f,M,V){e(Yn(d,f,M.code,V))},updateChargeCardName:(d,f)=>{e(Xn(A,d,f))},onClickSetupIcon:()=>{J.trackCardsListPageClicked("settings"),oa(F,w,L)&&u!=null&&J.trackCardsSettingsClick(B,T,u,v,k);const d=Fo(b),f=ye(s.state?.pathnameStackToGoBack,s.pathname);t(d,{state:{pathnameStackToGoBack:f}})},onIssueCardClick:()=>{J.trackCardsListPageClicked("new card"),oa(F,w,L)&&u!=null&&J.trackCardsNewCardClick(B,T,u,"New Button","card_creation_initiated","Card List",v,k);const d=gi(b),f=ye(s.state?.pathnameStackToGoBack,s.pathname);t(d,{state:{pathnameStackToGoBack:f}})},onColumnSortConfigChanged:(d,f)=>{oa(F,w,L)&&u!=null&&J.trackCardsCardListSortClick(B,T,u,"Sort Icon","sort",d,f==="ascending"?"ASC":"DESC","Cards List",v,k),e(It({uiState:{sortKey:d,sortOrder:f}}))},onSearchTextChanged:d=>{e(pc(d))},onReloadCards:()=>{e(ia(S,F&&w,P&&C,!0))},onLetsGoClick:()=>{t("./onboard")},onBackClick:()=>{t("../../")},onTotalCashbackClick:()=>{oa(F,w,L)&&u!=null&&J.trackCardsCashbackOverviewClick(B,T,u,"Cashback Overview","cashback_details_viewed",v,k),t("./cashback")},onClickStatementsIcon:()=>{oa(F,w,L)&&u!=null&&J.trackCardsStatementsClick(B,T,u,v,k),t("./statements")},onCreateNowClick:d=>{oa(F,w,L)&&u!=null&&J.trackCardsNewCardClick(B,T,u,"Promo Banner","card_creation_initiated","Card List",v,k),t(`./new?cardType=${d}`)},onPromoCardClick:d=>{t(d==="debit"&&F&&!l||d==="credit"&&m&&!j?`../promo?cardPromoType=${d}`:"./setup")},navigateToCreditCardPaymentPage:(d,f)=>{h==="Completed"&&a.company!=null&&u!=null&&J.trackCardsPayEarlyClick(B,T,u,"Card List",d,f,{isZeniCheckingEnabled:a.company.companyZeniAccountInfo.isZeniAccountEnabled,isZeniCheckingPaymentSource:p?.accType==="depositAccount",creditCardPaymentSourceAccountName:p?.label,creditCardPaymentSourceAccountType:p?.accType,creditCardPaymentSourceLastFourDigits:p?.accountLast4,creditCardPaymentSourceBalance:p?.accountBalance?.available?.amount??0},v,k);const M=Si(b);t(M)},navigateToCreditCardPaymentHistoryPage:()=>{const d=bi(b),f=ye(s.state?.pathnameStackToGoBack,s.pathname);t(d,{state:{pathnameStackToGoBack:f}})},shouldShowPayNowInfoTooltip:U,onSetRowActionCardId:d=>{e(Cc(d))},onSetBulkActionCardIds:d=>{e(nr(d))},onEventReceived:d=>{pi.has(d)&&Dt(e,S,F&&w,P&&C)},onPusherSubscribed:()=>{Dt(e,S,F&&w,P&&C)}}})(st(Co));function kn({isPaymentDrawerOpen:e}){const n=le(),t=me(),a=he(),s=r.useCallback((H,je)=>{t(nr([])),n(H,je)},[t,n]),[y,g]=r.useState(!1),[S,P]=r.useState(te.getPayNowInfoTooltip()??!1),m=H=>{te.savePayNowInfoTooltip(H),P(H)},[C,F]=r.useState(!1),w=te.getSignedInUser(),l=i(H=>ge(H)),[j,B]=r.useState(!1),[L,p]=r.useState(!1),{isAiCfoAccessEnabled:h,onAskAiCfoClick:T}=xa({mobileExploreReferrer:"Cards"}),u=l.userRole.includes("charge_card_user"),v=!u,k=!!l.companyDebitCardInfo?.info?.isDebitCardEnabled,{useFeatureGate:U,useDynamicConfig:A}=ue(),{isFeatureEnabled:b}=U(W.isCashbackFeatureEnabled),{isFeatureEnabled:x}=U(W.isChargeCardFeatureEnabled),{isFeatureEnabled:d}=U(W.isDebitCardFeatureEnabled),{isFeatureEnabled:f}=U(W.isEarlyPayFeatureEnabled),{isFeatureEnabled:M}=U(W.isChargeCardPaymentHistoryFeatureEnabled),{isFeatureEnabled:V}=U(W.isCardsCommentingEnabled),{isFeatureEnabled:O}=U(W.isAiCfoFileUploadEnabled),{isFeatureEnabled:R}=U(W.isCardPolicyEnabled),{isFeatureEnabled:z}=U(W.isAiCardCreationEnabled),$=Le(d,l),_=Oe({isDebitCardFeatureEnabled:d,isBankingOnlyTenant:$}),D=xe(l),G=Be(l),Q=l.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,I=Ue({isCardsOnlyTenant:D,isChargeCardFeatureEnabled:x,isBookKeepingTenant:G,isDebitCardProductVisible:_,chargeCardsCreditAccountLimit:Q}),N=Dr({isCardsOnlyTenant:D,isChargeCardFeatureEnabled:x,isBookKeepingTenant:G}),{configValue:K}=A(We.zeniCardsConfig),X=Re(),o=Fe(X?.loggedInUserRoleMap),E=i(H=>da(H,l.companyId)),Y=la(E.controllers),ne=K.charge_card_cashback_rate_per_transaction!=null?K.charge_card_cashback_rate_per_transaction:.0175,q=K.credit_card_pay_now_threshold_by_company_id?.[l.companyId]??K.default_credit_card_pay_now_threshold??To,ke=K.is_card_controls_enabled_for_all_tenants===!0||Array.isArray(K.enable_card_controls_for_company_ids)&&K.enable_card_controls_for_company_ids.includes(l.companyId),ve=!!l.companyChargeCardInfo?.info?.isChargeCardTOSAccepted,fe=!!l.companyDebitCardInfo?.info?.isDebitCardTOSAccepted,se=!!l.companyChargeCardInfo?.info?.isChargeCardEnabled,Ee=!!l.company?.companyChargeCardInfo?.isChargeCardEnabled,re=!!l.company?.companyDebitCardInfo?.isDebitCardEnabled,Ce=i(H=>$n(H)),Ae=ya(Ce.updateStatus),ee=i(H=>Ca(H,v,_&&k,I&&se)),Te=i(H=>oc(H)),De=i(H=>ic(H)),ae=i(H=>dc(H)),oe=i(H=>lc(H)),fa=i(H=>ae==null?[]:Nn(H.aiCfoState,ae).filter(je=>je.kind==="creating_cards"),_t),na=ya(De.fetchState);r.useEffect(()=>{na==="In-Progress"&&De.fetchState==="Completed"&&ae!=null&&fa.forEach(H=>{t(yt({chatSessionId:ae,id:H.id,entityIds:oe,kind:"created_cards"}))})},[t,De.fetchState,ae,oe,fa,na]);const Oa=ee.cards.filter(H=>H.type.code.includes("debit")).map(H=>H.connectedAccountId),dt=[...new Set(Oa)],Ea=i(H=>ma(H)),ra=i(H=>tt(H,dt)),Aa=i(H=>wa(H,l.companyId)),lt=Aa.companyChargeCardInfo?.primaryFundingAccount,ut=Aa.allFundingAccounts.find(H=>H.id===lt?.accountId),pe=ee.fetchState,Ua=ee.creditAccount,Da=r.useCallback(()=>o===!0&&R===!0&&pe==="Completed"&&te.getCardPolicyPopupSeen(l.tenantEmailDomain??"")!==!0,[o,R,pe,l.tenantEmailDomain]),[ja,Ma]=r.useState(Da);r.useEffect(()=>{Ma(Da())},[Da]);const Z=()=>{te.saveCardPolicyPopupSeen(l.tenantEmailDomain??"",!0),Ma(!1)},Se=pe==="Completed"&&!ee.hasCreditCard&&!ee.hasDebitCard;uo({isDataReady:pe==="Completed",pageContext:Se?"cards_creation":"cards"});const{creditAccountRepayment:ie}=i(H=>ua(H)),Ge=i(H=>qa(H).firstViewAfterActivation),{areTenantIdsInSync:Ke}=yr(),$e=Mt(o,Ea),ze=Ba(I,se,o,Ua,ie),sa=Nt(_,k,o,ra,ee.debitCardSummary),mt=Je(I,_,k,se),Ct=ee.creditAccount.balance.amount+ee.creditAccount.hold.amount;if(r.useEffect(()=>{pe==="Completed"&&(te.getPayNowInfoTooltip()==null||Ct<q*ee.creditAccount.limit.amount/100)&&m(!0)},[pe,q,Ct,ee.creditAccount.limit.amount]),r.useEffect(()=>{if(e!=null&&e===!0&&ie.initiatedRepayments.amount===0&&ie.fetchState==="Completed"||Ae==="In-Progress"&&Ce.updateStatus==="Completed")m(!1),g(!0);else if(ie.initiatedRepayments.amount>0&&ie.fetchState==="Completed"){g(!1),document.body.style.overflow="auto";const H=ta(l.tenantEmailDomain);s(H)}},[e,ie.initiatedRepayments.amount,ie.fetchState,Ae,Ce.updateStatus,s,l.tenantEmailDomain]),r.useEffect(()=>{!j&&(se||k)&&(Ee||re)&&Ke&&(B(!0),t(ia(v,_&&k,I&&se,!1)))},[j,v,t,Ke,Ee,re]),r.useEffect(()=>{Ge&&C===!1&&(F(!0),setTimeout(()=>{t(Za())},5e3))},[Ge,C]),r.useEffect(()=>()=>{Dt.flush()},[]),r.useEffect(()=>{pe==="Completed"&&u&&ee.cards.length===1&&(ee.cards[0].status.code==="inactive"&&ee.cards[0].type.code==="business_physical_credit_card"?s(`./${ee.cards[0].id}/activate`):ee.cards[0].status.code!=="request_on_hold"&&(a.state?.message==="comingFromCardDetail"?s("../../"):s(`./${ee.cards[0].id}`)))},[pe,u,a.state,s,ee.cards]),r.useEffect(()=>{if(pe==="Completed"&&u){const H=ee.cards.length,je=ee.cards.filter(Ye=>Ye.cardHolderUserId===w?.userId).filter(Ye=>Ye.status.code==="request_on_hold");je.length>0&&H===je.length&&s("./onboard")}},[pe,ee.cards,u,s,w?.userId]),r.useEffect(()=>{pe!=="Completed"||I&&ie.fetchState!=="Completed"||_&&k&&o&&ra.fetchState!=="Completed"||J.trackCardsCardListView(Y,mt,$e,ze,sa)},[pe,Ua,ie.fetchState,ra.fetchState,o]),w==null)throw Error("Can't access charge card list page without signing in...");const Zr=i(H=>rr(H.userState,H.userRoleState,H.userListViewState,"cardAdmin")),Yt=xt(X?.loggedInUserRoleMap),qt=H=>{p(H)},Wr=ee.creditAccount.limit,Kr=()=>{g(!1),s("..")},Yr=l.companyChargeCardInfo?.info!=null&&Ia({cardInfo:l.companyChargeCardInfo.info,isProductVisible:I&&Ee,isTOSAccepted:ve,isSetupEnabled:se,isUserHasCardsAdminLevelAccess:o,isUserHasCardsAccess:Yt}),qr=l.companyDebitCardInfo?.info!=null&&Ia({cardInfo:l.companyDebitCardInfo.info,isProductVisible:_&&re,isTOSAccepted:fe,isSetupEnabled:k,isUserHasCardsAdminLevelAccess:o,isUserHasCardsAccess:Yt}),Qr=Yr||qr,Qt=function(H){const{isEmptyCardsState:je,isChargeCardAdmin:Ye,isFileUploadEnabled:an}=H,tn=le(),Na=he(),{tenantEmailDomain:Va}=Ve(),{isAiCfoOpen:ts,setIsAiCfoOpen:nn}=hr(),ns=fr(),rs=gr(),rn=i(be=>Mn(be)).createSessionAndSubmitState.fetchState==="In-Progress",{chips:sn,isResolved:cn}=xr("cards_creation"),on=r.useMemo(()=>Fr(sn,cn,3),[sn,cn]),[Ha,pt]=r.useState(""),dn=rs&&ns&&Va!=null&&!ts,ga=r.useCallback(be=>{if(Va==null)return;const ss=ye(Na.state?.pathnameStackToGoBack,Na.pathname);tn(`/${Va}/cards/ask`,{state:{message:"",origin:"",pathnameStackToGoBack:ss,referrer:"cards_hero",aiCfoInitialQuestion:be,aiCfoShouldSubmit:be!=null&&be.trim().length>0}})},[Na.pathname,Na.state,tn,Va]),ln=r.useCallback(be=>{be.trim().length!==0&&(pt(""),ga(be))},[ga]),un=r.useCallback(()=>{const be=Ha.trim();be.length!==0&&(pt(""),ga(be))},[Ha,ga]),mn=r.useCallback(()=>{},[]),Cn=r.useCallback(be=>{pt(be)},[]),pn=r.useCallback(()=>{nn(!0)},[nn]),hn=r.useCallback(()=>{ga(void 0)},[ga]);return r.useMemo(()=>{if(dn&&je&&Ye)return{aiAgentName:Ci,headline:ui,subheadline:mi,promptChips:on,composer:{currentInput:Ha,isSubmitting:rn,isFileUploadEnabled:an,onInputChange:Cn,onSubmit:un,onStopSubmit:mn},onPromptClick:ln,onOpenSidePanel:pn,onOpenFullView:hn,dataTestIdPrefix:"cards-ai-cfo-hero"}},[Ha,dn,Ye,je,an,rn,Cn,hn,pn,ln,mn,un,on])}({isEmptyCardsState:Se,isChargeCardAdmin:o,isFileUploadEnabled:O}),Xt=z&&Qt!=null?c.jsx(Sr,{...Qt}):null,{isCardsShuttingDown:Jt,shutdownContent:en}=Ir(l.tenantId,l.company?.managementInfo?.receiverEmails),Xr=Jt===!0&&en!=null?c.jsx(mo,{shutdownContent:en}):null,Jr=h&&Xt==null,es=aa(l),as={events:ha(es,Hr),eventCallback:(H,je,Ye)=>{Ye.onEventReceived(H)},onSubscribed:H=>{H.onPusherSubscribed()}};return se||k?c.jsxs(c.Fragment,{children:[pe==="Completed"?c.jsxs(c.Fragment,{children:[c.jsx(Ut,{analytics:J,onLoad:()=>{J.trackPageLoaded(kr.Event.cardsListPage),(I&&!se||_&&!k)&&J.trackCardsPromoView(Y,{isCreditCardOffered:I,isDebitCardOffered:_,isDebitCardEnabled:k,isCreditCardEnabled:se},"Banner",_&&!k?"Debit Card":I&&!se?"Credit Card":"","Card List")}}),c.jsx(nt,{showConfetti:Ge})]}):null,y===!0?c.jsx(Zt,{closeDrawerHandler:Kr,isPaymentDrawerOpen:y,pageName:"Card List",sourcePage:"cardListPage",creditAccountSpentAmount:Ct,productInformation:mt,creditAccountInformation:ze,debitAccountInformation:sa,cashbackInformation:$e,isDebitCardInfoFetchStateCompleted:!(_&&k&&o)||ra.fetchState==="Completed",isCreditCardInfoFetchStateCompleted:!I||ie.fetchState==="Completed",isCashbackInfoFetchStateCompleted:!o||Ea.fetchState==="Completed",paymentInitiatedDate:ie.initiatedRepaymentDate}):null,c.jsxs(hi,{children:[c.jsx(Ie,{isAppContentDrawerOpen:L,handleDrawerToggle:qt}),c.jsx(fi,{...as,isCashbackFeatureEnabled:b,isChargeCardFeatureEnabled:I,isDebitCardFeatureEnabled:_,isCreditCardProductVisibleForExpressInterest:N,updatePayNowInfoTooltip:m,showPayNowInfoTooltip:S,creditCardPayNowThreshold:q,signedInUser:w,chargeCardListState:ee,location:a,admins:Zr.users,navigateAndClearBulkSelection:s,currentTenant:l,isCardControlsEnabled:ke,companyChargeCardInfoCreditAccountLimit:l.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,isCompanyInterestedInChargeCard:l.companyChargeCardInfo?.info?.isCompanyInterestedInChargeCard??!1,isUserHasCardsAdminLevelAccess:o,includeCreditAccountDebitSummaryAndCashbackInfo:v,onClickMenuIcon:()=>{qt(!0)},creditLimit:Wr,isChargeCardSetupEnabled:se,isChargeCardEnabledOnCompany:Ee,isDebitCardSetupEnabled:k,isDebitCardEnabledOnCompany:re,isEarlyPayEnabled:f,isChargeCardPaymentHistoryFeatureEnabled:M,cashbackRate:ne,controllerEmails:Y,chargeCardCashbackDetailState:Ea,depositAccountListWithDebitCardIssued:ra,isChargeCardTOSAccepted:ve,isDebitCardTOSAccepted:fe,primaryFundingAccountDetails:ut,chargeCardSetUpViewFetchState:Aa.fetchState,productInformation:mt,creditAccountInformation:ze,debitAccountInformation:sa,cashbackInformation:$e,isAiCfoAccessEnabled:Jr,onAskAiCfoClick:T,isCardsCommentingEnabled:V,cardsAiCfoHero:Xt,cardsShutdownBanner:Xr,isCardsShuttingDown:Jt,onClickPolicyIcon:o&&R?()=>n(yi(l.tenantEmailDomain)):void 0,isPolicyIntroTooltipVisible:ja,onPolicyIntroTooltipClose:Z,pendingCreationCount:Te})]})]}):(ve||fe)&&o===!0?c.jsx(Xe,{to:"../setup"}):Qr?c.jsx(Xe,{to:"../promo"}):c.jsx(va,{fetchState:pe})}const gi=e=>`/${e}/cards/new`,Si=e=>`/${e}/cards/payment`,bi=e=>`/${e}/cards/payment-history`,yi=e=>`/${e}/cards/policy`,Gr=[jr,Mr],Ii=new Set(Gr),ki=Pe(function(e){const n=te.getSignedInUser(),t=ge(e),a=e.tenantState.currentTenantId,s=sr(e),y={userId:n?.userId??"",sessionId:n?.zeniSessionId??"",tenantId:a??""},g=t?.companyName??"",S=e.chargeCardPaymentHistoryState.downloadUIState.downloadState;return{fetchState:s.fetchState,filters:s.filters,isZeniTenant:Ic(t),repaymentList:s.repaymentHistory,searchText:s.searchText,repaymentHistoryUsers:s.repaymentHistoryUsers,sortConfig:{sortKey:s.uiState.sortKey,sortOrder:s.uiState.sortOrder},downloadParams:{authParams:y,companyName:g,spendManagementEndPoint:`${Et}/spendManagement`,isShowDeletedBillsEnabled:!1,isShowDeletedReimbursementEnabled:!1},downloadState:S}},function(e,n){const{location:t,navigate:a}=n;return{onBackClick:()=>{const s=we(t.state?.pathnameStackToGoBack),y=s.poppedPathname??"..";a(y,{state:{pathnameStackToGoBack:s.newStack}})},onColumnSortConfigChanged:(s,y)=>{e({type:"chargeCardPaymentHistory/updatePaymentHistoryUIState",payload:{uiState:{sortKey:s,sortOrder:y}}})},onFiltersChange:s=>{e(Ec({filters:s}))},onReloadPayments:()=>{e(Ga(!0))},onEventReceived:s=>{Ii.has(s)&&e(Ga(!0))},onPusherSubscribed:()=>{e(Ga(!0))},onSearchTextChanged:s=>{e({type:"chargeCardPaymentHistory/updatePaymentHistorySearchText",payload:s})},updateDownloadStateHandler:s=>{e(kc({uiState:{downloadState:s}}))}}})(st(po));function Ei(){const e=le(),n=he(),t=me(),{areTenantIdsInSync:a}=yr(),{useFeatureGate:s}=ue();if(te.getSignedInUser()==null)throw Error("Can't access payment history page without signing in...");const y=i(o=>ge(o)),g=i(o=>sr(o)),[S,P]=r.useState(!1),[m,C]=r.useState(!1),[F,w]=r.useState(!1),[l,j]=r.useState(null),B=!y.userRole.includes("charge_card_user"),L=!!y.companyDebitCardInfo?.info?.isDebitCardEnabled,{isFeatureEnabled:p}=s(W.isChargeCardFeatureEnabled),{isFeatureEnabled:h}=s(W.isDebitCardFeatureEnabled),T=Le(h,y),u=Oe({isDebitCardFeatureEnabled:h,isBankingOnlyTenant:T}),v=xe(y),k=Be(y),U=y.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,A=Ue({isCardsOnlyTenant:v,isChargeCardFeatureEnabled:p,isBookKeepingTenant:k,isDebitCardProductVisible:u,chargeCardsCreditAccountLimit:U}),b=!!y.companyChargeCardInfo?.info?.isChargeCardEnabled,x=Re(),d=Fe(x?.loggedInUserRoleMap),f=i(o=>Ca(o,B,u&&L,A&&b)),M=r.useMemo(()=>{const o=f.cards.filter(E=>E.type.code.includes("debit"));return[...new Set(o.map(E=>E.connectedAccountId))]},[f.cards]),V=i(o=>ma(o)),O=i(o=>tt(o,M)),{creditAccountRepayment:R}=i(o=>ua(o)),z=r.useMemo(()=>Mt(d,V),[d,V]),$=r.useMemo(()=>Ba(A,b,d,f.creditAccount,R),[A,b,d,f.creditAccount,R]),_=r.useMemo(()=>Nt(u,L,d,O,f.debitCardSummary),[u,L,d,O,f.debitCardSummary]),D=r.useMemo(()=>Je(A,u,L,b),[A,u,L,b]),G=f.creditAccount.balance.amount+f.creditAccount.hold.amount,Q=r.useMemo(()=>l!=null?g.repaymentHistory.find(o=>o.cardRepaymentId===l):void 0,[l,g.repaymentHistory]),I=r.useCallback(o=>{j(o),t(ia(B,u&&L,A&&b,!1)),w(!0)},[t,B,u,L,A,b]),N=r.useCallback(()=>{w(!1),j(null),document.body.style.overflow="auto"},[]);r.useEffect(()=>{S||g.fetchState==="Completed"||g.fetchState==="In-Progress"||(P(!0),t(Ga()))},[S,t,g.fetchState]),r.useEffect(()=>{!m&&(b||L)&&a&&(C(!0),t(ia(B,!1,A&&b,!1)))},[m,b,L,a,t,B,A]);const K=aa(y),X={events:ha(K,Gr),eventCallback:(o,E,Y)=>{Y.onEventReceived(o)},onSubscribed:o=>{o.onPusherSubscribed()}};return c.jsxs(c.Fragment,{children:[F?c.jsx(Zt,{closeDrawerHandler:N,isPaymentDrawerOpen:F,pageName:"Payment History",sourcePage:"cardPaymentHistory",creditAccountSpentAmount:G,productInformation:D,creditAccountInformation:$,debitAccountInformation:_,cashbackInformation:z,isDebitCardInfoFetchStateCompleted:!(u&&L&&d)||O.fetchState==="Completed",isCreditCardInfoFetchStateCompleted:!A||R.fetchState==="Completed",isCashbackInfoFetchStateCompleted:!d||V.fetchState==="Completed",paymentInitiatedDate:R.initiatedRepaymentDate,retryRepayment:Q}):null,c.jsx(ki,{...X,location:n,navigate:e,accountInfoByAccountId:g.accountInfoByAccountId,onRetryPaymentClick:I})]})}const En=He.div`
26
26
  display: flex;
27
27
  height: 100vh;
28
28
  width: 100%;
@@ -31,7 +31,7 @@ import{j as c}from"./liveblocks-DvqoH3dJ.js";import{u as me,j as i,h as le,g as
31
31
  overflow: auto;
32
32
  align-items: center;
33
33
  background-color: ${e=>e.theme.colors.grey4};
34
- `,An=ea.getLocalizedStrings().months;function Ai(){const e=le(),n=me(),t=he(),{creditAccount:a,creditAccountRepayment:s}=i(D=>ua(D)),y=`${br.cardMicroServiceBaseUrl}/1.0/credit-accounts/${a.id}`,[g,S]=r.useState(!1),[P,m]=r.useState(!1),C=i(D=>Ac(D)),{useFeatureGate:F}=ue(),w=i(D=>ge(D)),{isFeatureEnabled:l}=F(W.isChargeCardFeatureEnabled),{isFeatureEnabled:j}=F(W.isDebitCardFeatureEnabled),{isFeatureEnabled:B}=F(W.isCardsCommentingEnabled),L=wr(B?w.companyId:void 0,{clearParams:B&&C.fetchState==="Completed"}),p=Le(j,w),h=Oe({isDebitCardFeatureEnabled:j,isBankingOnlyTenant:p}),T=xe(w),u=Be(w),v=w.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,k=Ue({isCardsOnlyTenant:T,isChargeCardFeatureEnabled:l,isBookKeepingTenant:u,isDebitCardProductVisible:h,chargeCardsCreditAccountLimit:v}),U=!!w.companyDebitCardInfo?.info?.isDebitCardEnabled,A=!!w.companyChargeCardInfo?.info?.isChargeCardEnabled,b=i(D=>da(D,w.companyId)),x=la(b.controllers),d=i(D=>cr(D)),f=d.cards.filter(D=>D.type.code.includes("debit")).map(D=>D.connectedAccountId),M=[...new Set(f)],V=i(D=>tt(D,M)),O=i(D=>Dc(D));r.useEffect(()=>{P||a.fetchState==="Completed"||a.fetchState==="In-Progress"||(S(!0),n(Qe()))},[g,n,a.fetchState]),r.useEffect(()=>{P||a.fetchState!=="Completed"||a.id==null||C.fetchState==="Completed"||C.fetchState==="In-Progress"||(m(!0),n(_c(a.id)))},[P,n,a.fetchState,a.id,C.fetchState]),r.useEffect(()=>{V.fetchState!=="Completed"&&V.fetchState!=="In-Progress"&&h&&U&&n(or()),d.fetchState!=="Completed"&&d.fetchState!=="In-Progress"&&n(Ne()),O.fetchState!=="Completed"&&O.fetchState!=="In-Progress"&&h&&U&&n(Pc()),s.fetchState!=="Completed"&&s.fetchState!=="In-Progress"&&k&&A&&n(Tt())},[V.fetchState,h,U,d.fetchState,O.fetchState,s.fetchState,k,A]),r.useEffect(()=>{if(C.fetchState==="Completed"&&a.fetchState==="Completed"&&s.fetchState==="Completed"&&d.fetchState==="Completed"&&(!h||!U||V.fetchState==="Completed"&&O.fetchState==="Completed")){let D="",G="";if(C.statements.length>0){const Z=C.statements[C.statements.length-1].period,[X,o]=Z.split("-"),E=C.statements[0].period,[K,ne]=E.split("-");D=`${An[parseInt(o)-1]} ${X}`,G=`${An[parseInt(ne)-1]} ${K}`}const Q=Je(k,h,U,A),I=Ba(k,A,!0,a,s),N=Nt(h,U,!0,V,O);J.trackCardsCreditCardStatementsView(x,Q,{numberOfStatements:C.statements.length,oldestStatementMonthYear:D,latestStatementMonthYear:G},I,N)}},[C.fetchState,a.fetchState,s.fetchState,V.fetchState,d.fetchState,O.fetchState]);const R=()=>{const D=we(t.state?.pathnameStackToGoBack),G=D.poppedPathname??"..";e(G,{state:{pathnameStackToGoBack:D.newStack}})},z=i(D=>ma(D)),$=te.getSignedInUser(),_={userId:$?.userId??"",sessionId:$?.zeniSessionId??"",tenantId:w.tenantId??""};if($==null)throw Error("Can't access address page without signing in...");if(C.fetchState!=="Completed")return c.jsx(En,{children:c.jsx(ho,{onBackClick:R})});{const D=Je(k,h,U,A);return c.jsx(En,{children:c.jsx(fo,{currentTenantCompanyName:w.companyName,statementListView:C,productInformation:D,onBackClick:R,authParams:_,controllerEmails:x,isChargeCardFeatureEnabled:k,isDebitCardFeatureEnabled:h,isDebitCardSetupEnabled:U,isChargeCardSetupEnabled:A,isCardsCommentingEnabled:B,initialOpenThreadRequest:L,chargeCardCashbackDetailState:z,creditAccount:a,creditAccountRepayment:s,depositAccountListWithDebitCardIssued:V,debitCardSummary:O,downloadEndPoint:y})})}}const $r=[pa,it],Di=new Set($r),_i={containerWidth:new Fa(100,58)},Pi=({appContent:e})=>{const n=Ta(),t=me(),a=le(),s=he(),{useDynamicConfig:y}=ue(),[g,S]=r.useState(!1),[P,m]=r.useState(!1),[C,F]=r.useState(!1),[w,l]=r.useState(!1),j=r.useRef(!1),B=r.useRef(null);r.useEffect(()=>()=>{B.current!=null&&(clearTimeout(B.current),B.current=null)},[]);const[L,p]=r.useState(!1),[h,T]=r.useState(!1),u=te.getSignedInUser();if(u==null)throw Error("Can't access onboarding card page without signing in...");const v=i(N=>ge(N)),{configValue:k}=y(We.zeniCardsConfig),U=i(N=>wc(N)),{tenantEmailDomain:A}=v,b=i(N=>N.settingsViewState.profile.fetchState),x=i(N=>N.chargeCardListState.fetchState),d=i(N=>N.settingsViewState.profile.userId),f=i(N=>N.chargeCardConfigState.fetchState);r.useEffect(()=>{g===!1&&b!=="In-Progress"&&b!=="Completed"&&(t(vc()),S(!0)),P===!1&&f!=="In-Progress"&&f!=="Completed"&&(t(Qa()),m(!0)),C===!1&&x==="Not-Started"&&(F(!0),t(Ne()))},[g,C,x,P,f]),r.useEffect(()=>{b==="Completed"&&L===!1&&d!=null&&x==="Completed"&&U.cards.length>0&&(t(Tc({userId:d})),t(ir({cardId:U.cards[U.cards.length-1].id})),p(!0))},[b,L,d,x]),r.useEffect(()=>{if(!w&&U.fetchState==="Completed"&&U.cards.length===0){const N=we(s.state?.pathnameStackToGoBack),Z=N.poppedPathname??ta(A);a(Z,{state:{pathnameStackToGoBack:N.newStack}})}},[U.fetchState,U.cards,w]);const M=i(N=>qa(N)),V=ya(M.updateStatus.fetchState),O=M.currentDisplayedCardId,{useFeatureGate:R}=ue(),{isFeatureEnabled:z}=R(W.isChargeCardFeatureEnabled),$=!!v.companyChargeCardInfo?.info?.isChargeCardEnabled,_=!v.userRole.includes("charge_card_user")&&z&&$,D=i(N=>O!=null?dr(N.chargeCardState,O):null),G=()=>{O!=null&&(j.current=!0,B.current!=null&&clearTimeout(B.current),B.current=setTimeout(()=>{j.current=!1,B.current=null},5e3),t(ka(O,_,!0)),t(Ne(!0)),l(!0))},Q=aa(v);Vt({events:ha(Q,$r),onSubscribed:()=>{t(Ne(!0))},onEvent:(N,Z)=>{if(!Di.has(N))return;const X=Wt(Z),o=j.current;if(N===pa){const K=de(X?.card_id)??O;if(K!=null){const ne=Zt(X,K);if(ne!=null)return t(Ft(ne)),void(K!==O||o||G())}}if(N===it)return void t(Ne(!0));const E=de(X?.card_id)??O;(O==null||E===O)&&O!=null?o||G():t(Ne(!0))}}),r.useEffect(()=>{if(w&&O!=null&&D!=null&&D.status.code!=="request_on_hold"){const N=_e(v.tenantEmailDomain,O,u,D),Z=ye(s.state?.pathnameStackToGoBack,s.pathname);t(Fc()),D?.type.code==="business_virtual_credit_card"&&t(Xa()),a(N,{state:{pathnameStackToGoBack:Z},replace:!0}),j.current=!1,B.current!=null&&(clearTimeout(B.current),B.current=null)}},[w,D?.status.code]),r.useEffect(()=>{V==="In-Progress"&&M.updateStatus.fetchState==="Completed"&&setTimeout(G,3e3)},[V,M.updateStatus.fetchState]);const I=N=>{T(N)};if(b!=="Completed"||U.cards.length===0)return c.jsxs(Dn,{children:[c.jsx(Ie,{isAppContentDrawerOpen:h,handleDrawerToggle:I}),c.jsx(go,{})]});if(d==null)throw Error("Can't access my userId.");return c.jsxs(Dn,{children:[c.jsx(Ie,{isAppContentDrawerOpen:h,handleDrawerToggle:I}),c.jsx(wi,{chargeCardListView:U,cardUserOnboardingView:M,navigate:a,currentTenant:v,myUserId:d,location:s,chargeCardCashbackRatePerTransaction:k.charge_card_cashback_rate_per_transaction!=null?k.charge_card_cashback_rate_per_transaction:.0175,onClickMenuIcon:()=>{I(!0)}}),e!=null?c.jsx(vi,{windowSize:n,children:e}):null]})},wi=Pe(function(e,{currentTenant:n,cardUserOnboardingView:t,chargeCardListView:a,myUserId:s}){const y=Ca(e,!1,!1,!1);let g=!1;return y.fetchState==="Completed"&&y.cards.length<=1&&(g=!0),{cards:a.cards,showMenuIcon:g,companyLegalName:n.companyName,twoFAView:t.twoFAView,cardUserOnboardingLocalData:t.cardUserOnboardingLocalData??{userId:s},isDOBDisabled:t.isDOBPresent,onboardingProgressStatus:t.onboardingProgressStatus}},function(e,n){const{navigate:t,cardUserOnboardingView:a,location:s,currentTenant:y}=n,{tenantEmailDomain:g}=y;return{updateCardUserOnboardingLocalData:S=>{e(Sn({localData:S}))},onGetOtp:S=>{if(a.cardUserOnboardingLocalData!=null){const P={...a.cardUserOnboardingLocalData,phone:S};e(Sn({localData:P}))}e(at(S,"CardUserOnboarding"))},onResendOtp:S=>{e(et(S,"CardUserOnboarding"))},onVerifyOtp:(S,P)=>{e(Ja(S,P,"CardUserOnboarding"))},onVerifyOtpSuccess:S=>{e(xc()),S!=null&&te.saveZeniOtpToken(S)},setCurrentDisplayedCardId:S=>{e(ir({cardId:S}))},onBackClick:()=>{const S=we(s.state?.pathnameStackToGoBack),P=S.poppedPathname??ta(g);t(P,{state:{pathnameStackToGoBack:S.newStack}})}}})(So),vi=He.div`
34
+ `,An=ea.getLocalizedStrings().months;function Ai(){const e=le(),n=me(),t=he(),{creditAccount:a,creditAccountRepayment:s}=i(D=>ua(D)),y=`${br.cardMicroServiceBaseUrl}/1.0/credit-accounts/${a.id}`,[g,S]=r.useState(!1),[P,m]=r.useState(!1),C=i(D=>Ac(D)),{useFeatureGate:F}=ue(),w=i(D=>ge(D)),{isFeatureEnabled:l}=F(W.isChargeCardFeatureEnabled),{isFeatureEnabled:j}=F(W.isDebitCardFeatureEnabled),{isFeatureEnabled:B}=F(W.isCardsCommentingEnabled),L=wr(B?w.companyId:void 0,{clearParams:B&&C.fetchState==="Completed"}),p=Le(j,w),h=Oe({isDebitCardFeatureEnabled:j,isBankingOnlyTenant:p}),T=xe(w),u=Be(w),v=w.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,k=Ue({isCardsOnlyTenant:T,isChargeCardFeatureEnabled:l,isBookKeepingTenant:u,isDebitCardProductVisible:h,chargeCardsCreditAccountLimit:v}),U=!!w.companyDebitCardInfo?.info?.isDebitCardEnabled,A=!!w.companyChargeCardInfo?.info?.isChargeCardEnabled,b=i(D=>da(D,w.companyId)),x=la(b.controllers),d=i(D=>cr(D)),f=d.cards.filter(D=>D.type.code.includes("debit")).map(D=>D.connectedAccountId),M=[...new Set(f)],V=i(D=>tt(D,M)),O=i(D=>Dc(D));r.useEffect(()=>{P||a.fetchState==="Completed"||a.fetchState==="In-Progress"||(S(!0),n(Qe()))},[g,n,a.fetchState]),r.useEffect(()=>{P||a.fetchState!=="Completed"||a.id==null||C.fetchState==="Completed"||C.fetchState==="In-Progress"||(m(!0),n(_c(a.id)))},[P,n,a.fetchState,a.id,C.fetchState]),r.useEffect(()=>{V.fetchState!=="Completed"&&V.fetchState!=="In-Progress"&&h&&U&&n(or()),d.fetchState!=="Completed"&&d.fetchState!=="In-Progress"&&n(Ne()),O.fetchState!=="Completed"&&O.fetchState!=="In-Progress"&&h&&U&&n(Pc()),s.fetchState!=="Completed"&&s.fetchState!=="In-Progress"&&k&&A&&n(Tt())},[V.fetchState,h,U,d.fetchState,O.fetchState,s.fetchState,k,A]),r.useEffect(()=>{if(C.fetchState==="Completed"&&a.fetchState==="Completed"&&s.fetchState==="Completed"&&d.fetchState==="Completed"&&(!h||!U||V.fetchState==="Completed"&&O.fetchState==="Completed")){let D="",G="";if(C.statements.length>0){const K=C.statements[C.statements.length-1].period,[X,o]=K.split("-"),E=C.statements[0].period,[Y,ne]=E.split("-");D=`${An[parseInt(o)-1]} ${X}`,G=`${An[parseInt(ne)-1]} ${Y}`}const Q=Je(k,h,U,A),I=Ba(k,A,!0,a,s),N=Nt(h,U,!0,V,O);J.trackCardsCreditCardStatementsView(x,Q,{numberOfStatements:C.statements.length,oldestStatementMonthYear:D,latestStatementMonthYear:G},I,N)}},[C.fetchState,a.fetchState,s.fetchState,V.fetchState,d.fetchState,O.fetchState]);const R=()=>{const D=we(t.state?.pathnameStackToGoBack),G=D.poppedPathname??"..";e(G,{state:{pathnameStackToGoBack:D.newStack}})},z=i(D=>ma(D)),$=te.getSignedInUser(),_={userId:$?.userId??"",sessionId:$?.zeniSessionId??"",tenantId:w.tenantId??""};if($==null)throw Error("Can't access address page without signing in...");if(C.fetchState!=="Completed")return c.jsx(En,{children:c.jsx(ho,{onBackClick:R})});{const D=Je(k,h,U,A);return c.jsx(En,{children:c.jsx(fo,{currentTenantCompanyName:w.companyName,statementListView:C,productInformation:D,onBackClick:R,authParams:_,controllerEmails:x,isChargeCardFeatureEnabled:k,isDebitCardFeatureEnabled:h,isDebitCardSetupEnabled:U,isChargeCardSetupEnabled:A,isCardsCommentingEnabled:B,initialOpenThreadRequest:L,chargeCardCashbackDetailState:z,creditAccount:a,creditAccountRepayment:s,depositAccountListWithDebitCardIssued:V,debitCardSummary:O,downloadEndPoint:y})})}}const $r=[pa,it],Di=new Set($r),_i={containerWidth:new Fa(100,58)},Pi=({appContent:e})=>{const n=Ta(),t=me(),a=le(),s=he(),{useDynamicConfig:y}=ue(),[g,S]=r.useState(!1),[P,m]=r.useState(!1),[C,F]=r.useState(!1),[w,l]=r.useState(!1),j=r.useRef(!1),B=r.useRef(null);r.useEffect(()=>()=>{B.current!=null&&(clearTimeout(B.current),B.current=null)},[]);const[L,p]=r.useState(!1),[h,T]=r.useState(!1),u=te.getSignedInUser();if(u==null)throw Error("Can't access onboarding card page without signing in...");const v=i(N=>ge(N)),{configValue:k}=y(We.zeniCardsConfig),U=i(N=>wc(N)),{tenantEmailDomain:A}=v,b=i(N=>N.settingsViewState.profile.fetchState),x=i(N=>N.chargeCardListState.fetchState),d=i(N=>N.settingsViewState.profile.userId),f=i(N=>N.chargeCardConfigState.fetchState);r.useEffect(()=>{g===!1&&b!=="In-Progress"&&b!=="Completed"&&(t(vc()),S(!0)),P===!1&&f!=="In-Progress"&&f!=="Completed"&&(t(Qa()),m(!0)),C===!1&&x==="Not-Started"&&(F(!0),t(Ne()))},[g,C,x,P,f]),r.useEffect(()=>{b==="Completed"&&L===!1&&d!=null&&x==="Completed"&&U.cards.length>0&&(t(Tc({userId:d})),t(ir({cardId:U.cards[U.cards.length-1].id})),p(!0))},[b,L,d,x]),r.useEffect(()=>{if(!w&&U.fetchState==="Completed"&&U.cards.length===0){const N=we(s.state?.pathnameStackToGoBack),K=N.poppedPathname??ta(A);a(K,{state:{pathnameStackToGoBack:N.newStack}})}},[U.fetchState,U.cards,w]);const M=i(N=>qa(N)),V=ya(M.updateStatus.fetchState),O=M.currentDisplayedCardId,{useFeatureGate:R}=ue(),{isFeatureEnabled:z}=R(W.isChargeCardFeatureEnabled),$=!!v.companyChargeCardInfo?.info?.isChargeCardEnabled,_=!v.userRole.includes("charge_card_user")&&z&&$,D=i(N=>O!=null?dr(N.chargeCardState,O):null),G=()=>{O!=null&&(j.current=!0,B.current!=null&&clearTimeout(B.current),B.current=setTimeout(()=>{j.current=!1,B.current=null},5e3),t(ka(O,_,!0)),t(Ne(!0)),l(!0))},Q=aa(v);Vt({events:ha(Q,$r),onSubscribed:()=>{t(Ne(!0))},onEvent:(N,K)=>{if(!Di.has(N))return;const X=Wt(K),o=j.current;if(N===pa){const Y=de(X?.card_id)??O;if(Y!=null){const ne=Kt(X,Y);if(ne!=null)return t(Ft(ne)),void(Y!==O||o||G())}}if(N===it)return void t(Ne(!0));const E=de(X?.card_id)??O;(O==null||E===O)&&O!=null?o||G():t(Ne(!0))}}),r.useEffect(()=>{if(w&&O!=null&&D!=null&&D.status.code!=="request_on_hold"){const N=_e(v.tenantEmailDomain,O,u,D),K=ye(s.state?.pathnameStackToGoBack,s.pathname);t(Fc()),D?.type.code==="business_virtual_credit_card"&&t(Xa()),a(N,{state:{pathnameStackToGoBack:K},replace:!0}),j.current=!1,B.current!=null&&(clearTimeout(B.current),B.current=null)}},[w,D?.status.code]),r.useEffect(()=>{V==="In-Progress"&&M.updateStatus.fetchState==="Completed"&&setTimeout(G,3e3)},[V,M.updateStatus.fetchState]);const I=N=>{T(N)};if(b!=="Completed"||U.cards.length===0)return c.jsxs(Dn,{children:[c.jsx(Ie,{isAppContentDrawerOpen:h,handleDrawerToggle:I}),c.jsx(go,{})]});if(d==null)throw Error("Can't access my userId.");return c.jsxs(Dn,{children:[c.jsx(Ie,{isAppContentDrawerOpen:h,handleDrawerToggle:I}),c.jsx(wi,{chargeCardListView:U,cardUserOnboardingView:M,navigate:a,currentTenant:v,myUserId:d,location:s,chargeCardCashbackRatePerTransaction:k.charge_card_cashback_rate_per_transaction!=null?k.charge_card_cashback_rate_per_transaction:.0175,onClickMenuIcon:()=>{I(!0)}}),e!=null?c.jsx(vi,{windowSize:n,children:e}):null]})},wi=Pe(function(e,{currentTenant:n,cardUserOnboardingView:t,chargeCardListView:a,myUserId:s}){const y=Ca(e,!1,!1,!1);let g=!1;return y.fetchState==="Completed"&&y.cards.length<=1&&(g=!0),{cards:a.cards,showMenuIcon:g,companyLegalName:n.companyName,twoFAView:t.twoFAView,cardUserOnboardingLocalData:t.cardUserOnboardingLocalData??{userId:s},isDOBDisabled:t.isDOBPresent,onboardingProgressStatus:t.onboardingProgressStatus}},function(e,n){const{navigate:t,cardUserOnboardingView:a,location:s,currentTenant:y}=n,{tenantEmailDomain:g}=y;return{updateCardUserOnboardingLocalData:S=>{e(Sn({localData:S}))},onGetOtp:S=>{if(a.cardUserOnboardingLocalData!=null){const P={...a.cardUserOnboardingLocalData,phone:S};e(Sn({localData:P}))}e(at(S,"CardUserOnboarding"))},onResendOtp:S=>{e(et(S,"CardUserOnboarding"))},onVerifyOtp:(S,P)=>{e(Ja(S,P,"CardUserOnboarding"))},onVerifyOtpSuccess:S=>{e(xc()),S!=null&&te.saveZeniOtpToken(S)},setCurrentDisplayedCardId:S=>{e(ir({cardId:S}))},onBackClick:()=>{const S=we(s.state?.pathnameStackToGoBack),P=S.poppedPathname??ta(g);t(P,{state:{pathnameStackToGoBack:S.newStack}})}}})(So),vi=He.div`
35
35
  display: flex;
36
36
  flex-direction: column;
37
37
  width: ${e=>`${_i.containerWidth.value(e.windowSize)}%`};
@@ -68,4 +68,4 @@ import{j as c}from"./liveblocks-DvqoH3dJ.js";import{u as me,j as i,h as le,g as
68
68
  overflow: auto;
69
69
  align-items: center;
70
70
  background-color: ${e=>e.theme.colors.grey4};
71
- `,Hi=Pe(function(e,n){const{myPendingActivationChargeCardListState:t}=n;return{myPendingActivationChargeCardListView:t,uiState:t.uiState,signedInUser:n.signedInUser}},function(e,n){const{navigate:t,currentTenant:a,location:s,signedInUser:y,myPendingActivationChargeCardListState:g}=n,{tenantEmailDomain:S}=a,{cards:P}=g;return{onChargeCardRowClick:m=>{const C=_r(P,m),F=_e(S,m,y,C),w=ye(s.state?.pathnameStackToGoBack,s.pathname);t(F,{state:{pathnameStackToGoBack:w}})},onColumnSortConfigChanged:(m,C)=>{e(It({uiState:{sortKey:m,sortOrder:C}}))},onReloadCards:()=>{e(Ne())},onBackClick:()=>{const m=a.userRole.includes("charge_card_user");e(It({uiState:{sortKey:m?"cardName":"owner",sortOrder:"ascending"}})),t("../")}}})(Ao);function Gi(){const e=le(),n=me(),t=he(),a=Ot(),[s,y]=r.useState(!1),g=i(R=>Gc(R)),S=i(R=>ge(R)),P=i(R=>da(R,S.companyId)),m=la(P.controllers),{useFeatureGate:C}=ue(),{isFeatureEnabled:F}=C(W.isChargeCardFeatureEnabled),{isFeatureEnabled:w}=C(W.isDebitCardFeatureEnabled),l=Le(w,S),j=Oe({isDebitCardFeatureEnabled:w,isBankingOnlyTenant:l}),B=!!S.companyDebitCardInfo?.info?.isDebitCardEnabled,L=!!S.companyChargeCardInfo?.info?.isChargeCardEnabled,p=Re(),h=xe(S),T=Be(S),u=S.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,v=Ue({isCardsOnlyTenant:h,isChargeCardFeatureEnabled:F,isBookKeepingTenant:T,isDebitCardProductVisible:j,chargeCardsCreditAccountLimit:u}),k=Fe(p?.loggedInUserRoleMap),U=i(R=>ma(R)),{creditAccount:A,creditAccountRepayment:b}=i(R=>ua(R)),x=i(R=>cr(R)).cards.filter(R=>R.type.code.includes("debit")).map(R=>R.connectedAccountId),d=[...new Set(x)],f=i(R=>tt(R,d));r.useEffect(()=>{s||g.fetchState==="Completed"||g.fetchState==="In-Progress"||(y(!0),n(Ne()),n(Qa()))},[s,n,g.fetchState]),r.useEffect(()=>{if(g.fetchState==="Completed"&&g.cards.length===1&&M!=null){const R=_e(S.tenantEmailDomain,g.cards[0].id,M,g.cards[0]);e(R,{state:{message:t.state?.message}})}},[g.fetchState,g.cards]);const M=te.getSignedInUser();r.useEffect(()=>{A.fetchState!=="Completed"&&A.fetchState!=="In-Progress"&&v&&L&&k&&n(Qe()),b.fetchState!=="Completed"&&b.fetchState!=="In-Progress"&&k&&n(Tt()),f.fetchState!=="Completed"&&f.fetchState!=="In-Progress"&&j&&B&&k&&n(or())},[A.fetchState,b.fetchState,n,f.fetchState,j,B,k,v,L]);const V=aa(S);if(Vt({events:ha(V,zr),onEvent:(R,z)=>{if(!Ni.has(R))return;const $=Wt(z);if(R===pa){const _=de($?.card_id);if(_!=null){const D=Zt($,_);if(D!=null)return void n(Ft(D))}}n(Ne(!0))},onSubscribed:()=>{n(Ne(!0))}}),M==null)throw Error("Can't access address page without signing in...");const O=g.cards!=null&&g.cards.length>0;if(g.fetchState==="Completed"||O){const R=Je(v,j,B,L);return c.jsx(Vi,{children:c.jsx(Hi,{navigate:e,currentTenant:S,signedInUser:M,productInformation:R,myPendingActivationChargeCardListState:g,isChargeCardFeatureEnabled:v,isDebitCardFeatureEnabled:j,isDebitCardSetupEnabled:B,isChargeCardSetupEnabled:L,chargeCardCashbackDetailState:U,creditAccount:A,creditAccountRepayment:b,depositAccountListWithDebitCardIssued:f,controllerEmails:m,location:t})})}return c.jsx(va,{fetchState:"In-Progress",style:{backgroundColor:a.colors.grey5}})}const $i=Pe(function(e,n){const{companyId:t,companyLegalName:a}=n;return{chargeCardSetupView:wa(e,t),admins:n.adminList,companyLegalName:a,meetingUrl:"https://meetings.hubspot.com/niharn/demo-zeni-charge-cards?embed=true"}},function(e,n){const{navigate:t,companyId:a,isCompanyBusinessVerificationAndPaymentSetUpDone:s,isDebitCardSetupEnabled:y,isChargeCardSetupEnabled:g,signedInUser:S,location:P,productInformation:m,isEarlyPayEnabled:C,controllerEmails:F,chargeCardsCreditAccountLimit:w}=n;return{onSetupButtonClick:l=>{if(S!=null&&J.trackCardsPromoPageClicked("enable cards"),s)switch(J.trackCardsEnableCardsClick(F,m,"Cards Promo"),l){case"credit":e(qe(a,!0,"charge_cards",C,!1));break;case"debit":e(qe(a,!0,"debit_cards",C,!1));break;case"debit_and_credit":e(w===0?qe(a,!0,"debit_cards",C,!0):qe(a,!0,"charge_cards__debit_cards",C,!1))}else switch(J.trackCardsSetupCardsClick(F,m,"Cards Promo"),l){case"credit":e(qe(a,!1,"charge_cards",C,!1));break;case"debit":e(qe(a,!1,"debit_cards",C,!1));break;case"debit_and_credit":e(w===0?qe(a,!1,"debit_cards",C,!0):qe(a,!1,"charge_cards__debit_cards",C,!1))}},onBackClick:()=>{const l=we(P.state?.pathnameStackToGoBack);let j=l.poppedPathname;j==null&&(j=y||g?"..":"../.."),t(j,{state:{pathnameStackToGoBack:l.newStack}})},onLetsGoClick:()=>{t("./onboard")},onSetupChargeCardSuccess:()=>{s?(e(Xa()),t("../",{relative:"path"})):t("../setup",{relative:"path"})},onExpressInterestClick:()=>{e(Yc(a))}}})(_o),zi=()=>{const e=le(),{tenantEmailDomain:n}=Ve(),[t]=_n(),a=t.get("cardPromoType"),s=me(),{useDynamicConfig:y,useFeatureGate:g}=ue(),[S,P]=r.useState(!1),{isFeatureEnabled:m}=g(W.isDebitCardFeatureEnabled),{isFeatureEnabled:C}=g(W.isEarlyPayFeatureEnabled),{isFeatureEnabled:F}=g(W.isChargeCardFeatureEnabled),{configValue:w}=y(We.zeniCardsConfig),l=i(ae=>ge(ae)),j=i(ae=>da(ae,l.companyId)),B=la(j.controllers),L=w.charge_card_cashback_rate_per_transaction!=null?w.charge_card_cashback_rate_per_transaction:.0175,p=he(),h=te.getSignedInUserTenant(n)?.companyId??l.companyId,T=i(ae=>wa(ae,h)),u=T.primaryFundingAccount,v=l.companyBillPayInfo?.info,k=xe(l),U=Be(l),A=Le(m,l),b=l.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,x=Oe({isDebitCardFeatureEnabled:m,isBankingOnlyTenant:A}),d=Ue({isCardsOnlyTenant:k,isChargeCardFeatureEnabled:F,isBookKeepingTenant:U,isDebitCardProductVisible:x,chargeCardsCreditAccountLimit:b}),f=Dr({isCardsOnlyTenant:k,isChargeCardFeatureEnabled:F,isBookKeepingTenant:U}),M=x&&d===!1,V=v?.businessVerificationStatus?.code==="verified"&&(M||u?.accType==="depositAccount"||$c(u?.providerVerificationStatus?.code??"")),O=te.getSignedInUser(),R=!!l.companyZeniAccountInfo?.info?.isZeniAccountEnabled,z=!!l.companyChargeCardInfo?.info?.isChargeCardTOSAccepted,$=!!l.company?.companyChargeCardInfo?.isChargeCardEnabled,_=!!l.company?.companyDebitCardInfo?.isDebitCardEnabled,D=!!l.companyChargeCardInfo?.info?.isChargeCardEnabled,G=!!l.companyDebitCardInfo?.info?.isDebitCardEnabled,Q=!!l.companyDebitCardInfo?.info?.isDebitCardTOSAccepted,I=ae=>{P(ae)},N=i(ae=>ae.chargeCardSetupViewState.fetchState);if(O==null)throw Error("Can't access Charge Card promo page without signing in...");const Z=Re(),X=Fe(Z?.loggedInUserRoleMap),o=xt(Z?.loggedInUserRoleMap),[E,K]=r.useState(!1),[ne,q]=r.useState(!1),[ke,ve]=r.useState(!1);r.useEffect(()=>{E===!1&&p.state?.message==="activation"&&K(!0)},[p.state]),r.useEffect(()=>{ne||N!=="Not-Started"||h==null||(q(!0),s(Pa(h,!0)))},[ne,N,h,s]);const fe=l.companyChargeCardInfo?.info!=null&&Ia({cardInfo:l.companyChargeCardInfo.info,isProductVisible:f&&$,isTOSAccepted:z,isSetupEnabled:D,isUserHasCardsAdminLevelAccess:X,isUserHasCardsAccess:o}),se=l.companyDebitCardInfo?.info!=null&&Ia({cardInfo:l.companyDebitCardInfo.info,isProductVisible:x&&_,isTOSAccepted:Q,isSetupEnabled:G,isUserHasCardsAdminLevelAccess:X,isUserHasCardsAccess:o}),Ee=x&&se&&f&&b>=0&&fe?"debit_and_credit":x&&se?"debit":"credit",re=xo(a,Ee),Ce=T?.chargeCardTermsDetails?.fetchStatus?.fetchState,Ae=r.useRef(null);r.useEffect(()=>{Ce==="In-Progress"?Ae.current=re:Ce!=="Error"&&Ce!=="Not-Started"||(Ae.current=null)},[Ce,re]);const ee=Ce!=="In-Progress"&&Ce!=="Completed"||Ae.current==null?re:Ae.current;r.useEffect(()=>{re==="credit"&&(D||f===!1&&G)||re==="debit"&&G||re==="debit_and_credit"&&G&&D?e("../"):(re==="debit_and_credit"&&z===!0&&Q===!0||re==="credit"&&(z===!0||f===!1&&Q===!0)||re==="debit"&&Q===!0)&&X===!0&&e("../setup")},[V,D,G,re,z,Q]),r.useEffect(()=>{ke||(s(zc("cardAdmin")),ve(!0))},[ke]);const Te=i(ae=>rr(ae.userState,ae.userRoleState,ae.userListViewState,"cardAdmin")),De=Je(f,x,G,D);return(ae=>{switch(ae){case"credit":return $;case"debit":return _;case"debit_and_credit":return $&&_;default:return!1}})(ee)?(fe||se)&&N==="Completed"?c.jsxs(c.Fragment,{children:[c.jsx(Ut,{analytics:J,onLoad:()=>{if(J.trackPageLoaded(kr.Event.cardsPromoPage),!!f&&!D||!!x&&!G||!!f&&!!x&&!G&&!D){const ae=Yi({isDebitCardSetupEnabled:G,isChargeCardSetupEnabled:D,isCreditCardProductVisibleForExpressInterest:f,isDebitCardProductVisible:x});J.trackCardsPromoView(B,De,"Page",ae,"Promo Page")}}}),c.jsx(nt,{showConfetti:E}),c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:I}),c.jsx($i,{signedInUser:O,location:p,showEnableCardButton:V,isCompanyBusinessVerificationAndPaymentSetUpDone:V,isChargeCardSetupEnabled:D,isDebitCardSetupEnabled:G,companyLegalName:l.companyName,adminList:Te.users,isCheckingEnabled:R,navigate:e,companyId:h,cardPromoType:ee,controllerEmails:B,productInformation:De,isCreditCardProductVisible:d,isDebitCardFeatureEnabled:m,isEarlyPayEnabled:C,cashbackRate:L,chargeCardsCreditAccountLimit:b,onClickMenuIcon:()=>{I(!0)}})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:I}),c.jsx(Do,{})]}):c.jsx(Xe,{to:"../",replace:!0})},Yi=({isDebitCardSetupEnabled:e,isChargeCardSetupEnabled:n,isCreditCardProductVisibleForExpressInterest:t,isDebitCardProductVisible:a})=>t&&a&&!e&&!n?"Credit & Debit Card":t&&!n?"Credit Card":a&&!e?"Debit Card":"";function Sd(){const e=he(),n=i(X=>ge(X)),{useFeatureGate:t}=ue(),{isFeatureEnabled:a}=t(W.isChargeCardFeatureEnabled),{isFeatureEnabled:s}=t(W.isDebitCardFeatureEnabled),{isFeatureEnabled:y}=t(W.isEarlyPayFeatureEnabled),{isFeatureEnabled:g}=t(W.isChargeCardPaymentHistoryFeatureEnabled),{isFeatureEnabled:S}=t(W.isCardPolicyEnabled),P=Le(s,n),m=Oe({isDebitCardFeatureEnabled:s,isBankingOnlyTenant:P}),C=Po(n,a,s),F=!!n.company?.companyChargeCardInfo.isChargeCardTOSAccepted,w=!!n.company?.companyDebitCardInfo.isDebitCardTOSAccepted,l=!!n.company?.companyChargeCardInfo?.isChargeCardEnabled,j=!!n.company?.companyDebitCardInfo?.isDebitCardEnabled,B=!!n.companyChargeCardInfo?.info?.isChargeCardEnabled,L=!!n.companyDebitCardInfo?.info?.isDebitCardEnabled,p=Re(),h=Fe(p?.loggedInUserRoleMap),{isCardsShuttingDown:T}=Ir(n.tenantId,n.company?.managementInfo?.receiverEmails),u=xt(p?.loggedInUserRoleMap),{isFeatureEnabled:v}=t(W.isCashbackFeatureEnabled),k=n.userRole.includes("charge_card_user"),U=!k,A=!k&&B,b=n?.userRole!=null&&Wc(n?.userRole),x=(n?.company==null||n.company.featuresActivationInfo?.isBillPayFeatureEnabled&&!b)&&Zc(p?.loggedInUserRoleMap),d=Kc(p?.loggedInUserRoleMap),f=(n?.company==null||n.company.featuresActivationInfo?.isReimbursementFeatureEnabled&&!b)&&qc(p?.loggedInUserRoleMap),{isFeatureEnabled:M}=t(W.isDepositAccountsFeatureEnabled),V=M&&!b&&zn(p?.loggedInUserRoleMap),O=B&&l&&!b,R=L&&j&&!b,z=C&&!b&&Fe(p?.loggedInUserRoleMap),$=Qc(p?.loggedInUserRoleMap),_=xe(n),D=Be(n),G=n.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,Q=Ue({isCardsOnlyTenant:_,isChargeCardFeatureEnabled:a,isBookKeepingTenant:D,isDebitCardProductVisible:m,chargeCardsCreditAccountLimit:G}),I=n.companyChargeCardInfo?.info!=null&&Ia({cardInfo:n.companyChargeCardInfo.info,isProductVisible:Q&&l,isTOSAccepted:F,isSetupEnabled:B,isUserHasCardsAdminLevelAccess:h,isUserHasCardsAccess:u}),N=n.companyDebitCardInfo?.info!=null&&Ia({cardInfo:n.companyDebitCardInfo.info,isProductVisible:m&&j,isTOSAccepted:w,isSetupEnabled:L,isUserHasCardsAdminLevelAccess:h,isUserHasCardsAccess:u}),Z=I||N;return c.jsxs(cs,{children:[h?c.jsx(ce,{path:"setup",element:c.jsx(bn,{isBillPayAdminLevelAccess:x,isReimbursementAdminLevelAccess:f,isZeniAccountAdminLevelAccess:V,isChargeCardAdminLevelAccess:z,isUserHasOnlyCardAccess:$,isUserHasOnlyBillPayAccess:d,productType:"charge_cards",type:"setup"})}):null,h?c.jsx(ce,{path:"verification",element:c.jsx(bn,{isBillPayAdminLevelAccess:x,isUserHasOnlyBillPayAccess:d,isReimbursementAdminLevelAccess:f,isZeniAccountAdminLevelAccess:V,isChargeCardAdminLevelAccess:z,isUserHasOnlyCardAccess:$,productType:"charge_cards",type:"verification"})}):null,h&&S?c.jsxs(c.Fragment,{children:[c.jsx(ce,{path:"policy",element:c.jsx(Yo,{})}),c.jsx(ce,{path:"policy/new",element:c.jsx(Uo,{})}),c.jsx(ce,{path:"policy/:templateId/edit",element:c.jsx(Vo,{})})]}):null,c.jsx(ce,{path:"promo",element:c.jsx(zi,{})}),O||R?c.jsxs(c.Fragment,{children:[c.jsx(ce,{path:"/",element:c.jsx(kn,{isPaymentDrawerOpen:!1})}),z&&y?c.jsx(ce,{path:"payment",element:c.jsx(kn,{isPaymentDrawerOpen:!0})}):null,c.jsx(ce,{path:"activate",element:c.jsx(Gi,{})}),c.jsx(ce,{path:"onboard",element:c.jsx(Pi,{})}),h&&T!==!0?c.jsx(ce,{path:"new",element:c.jsx(Mi,{})}):h?c.jsx(ce,{path:"new",element:c.jsx(Xe,{to:"..",replace:!0})}):null,v&&U?c.jsx(ce,{path:"cashback",element:c.jsx(Qo,{})}):null,A?c.jsx(ce,{path:"statements",element:c.jsx(Ai,{})}):null,z&&g&&B?c.jsx(ce,{path:"payment-history",element:c.jsx(Ei,{})}):null,c.jsx(ce,{path:":cardId/activate",element:c.jsx(ei,{})}),c.jsx(ce,{path:":cardId/setPin",element:c.jsx(Fi,{})}),c.jsx(ce,{path:":cardId/addToWallet",element:c.jsx(Wo,{})}),c.jsx(ce,{path:":cardId/*",element:c.jsx(li,{})}),c.jsx(ce,{path:"*",element:c.jsx(ct,{})})]}):(F||w)&&h?c.jsx(ce,{path:"*",element:c.jsx(Xe,{to:"../setup"})}):Z?c.jsx(ce,{path:"*",element:c.jsx(Xe,{to:"../promo",state:e.state})}):c.jsx(ce,{path:"*",element:null})]})}export{Sd as default};
71
+ `,Hi=Pe(function(e,n){const{myPendingActivationChargeCardListState:t}=n;return{myPendingActivationChargeCardListView:t,uiState:t.uiState,signedInUser:n.signedInUser}},function(e,n){const{navigate:t,currentTenant:a,location:s,signedInUser:y,myPendingActivationChargeCardListState:g}=n,{tenantEmailDomain:S}=a,{cards:P}=g;return{onChargeCardRowClick:m=>{const C=_r(P,m),F=_e(S,m,y,C),w=ye(s.state?.pathnameStackToGoBack,s.pathname);t(F,{state:{pathnameStackToGoBack:w}})},onColumnSortConfigChanged:(m,C)=>{e(It({uiState:{sortKey:m,sortOrder:C}}))},onReloadCards:()=>{e(Ne())},onBackClick:()=>{const m=a.userRole.includes("charge_card_user");e(It({uiState:{sortKey:m?"cardName":"owner",sortOrder:"ascending"}})),t("../")}}})(Ao);function Gi(){const e=le(),n=me(),t=he(),a=Ot(),[s,y]=r.useState(!1),g=i(R=>Gc(R)),S=i(R=>ge(R)),P=i(R=>da(R,S.companyId)),m=la(P.controllers),{useFeatureGate:C}=ue(),{isFeatureEnabled:F}=C(W.isChargeCardFeatureEnabled),{isFeatureEnabled:w}=C(W.isDebitCardFeatureEnabled),l=Le(w,S),j=Oe({isDebitCardFeatureEnabled:w,isBankingOnlyTenant:l}),B=!!S.companyDebitCardInfo?.info?.isDebitCardEnabled,L=!!S.companyChargeCardInfo?.info?.isChargeCardEnabled,p=Re(),h=xe(S),T=Be(S),u=S.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,v=Ue({isCardsOnlyTenant:h,isChargeCardFeatureEnabled:F,isBookKeepingTenant:T,isDebitCardProductVisible:j,chargeCardsCreditAccountLimit:u}),k=Fe(p?.loggedInUserRoleMap),U=i(R=>ma(R)),{creditAccount:A,creditAccountRepayment:b}=i(R=>ua(R)),x=i(R=>cr(R)).cards.filter(R=>R.type.code.includes("debit")).map(R=>R.connectedAccountId),d=[...new Set(x)],f=i(R=>tt(R,d));r.useEffect(()=>{s||g.fetchState==="Completed"||g.fetchState==="In-Progress"||(y(!0),n(Ne()),n(Qa()))},[s,n,g.fetchState]),r.useEffect(()=>{if(g.fetchState==="Completed"&&g.cards.length===1&&M!=null){const R=_e(S.tenantEmailDomain,g.cards[0].id,M,g.cards[0]);e(R,{state:{message:t.state?.message}})}},[g.fetchState,g.cards]);const M=te.getSignedInUser();r.useEffect(()=>{A.fetchState!=="Completed"&&A.fetchState!=="In-Progress"&&v&&L&&k&&n(Qe()),b.fetchState!=="Completed"&&b.fetchState!=="In-Progress"&&k&&n(Tt()),f.fetchState!=="Completed"&&f.fetchState!=="In-Progress"&&j&&B&&k&&n(or())},[A.fetchState,b.fetchState,n,f.fetchState,j,B,k,v,L]);const V=aa(S);if(Vt({events:ha(V,zr),onEvent:(R,z)=>{if(!Ni.has(R))return;const $=Wt(z);if(R===pa){const _=de($?.card_id);if(_!=null){const D=Kt($,_);if(D!=null)return void n(Ft(D))}}n(Ne(!0))},onSubscribed:()=>{n(Ne(!0))}}),M==null)throw Error("Can't access address page without signing in...");const O=g.cards!=null&&g.cards.length>0;if(g.fetchState==="Completed"||O){const R=Je(v,j,B,L);return c.jsx(Vi,{children:c.jsx(Hi,{navigate:e,currentTenant:S,signedInUser:M,productInformation:R,myPendingActivationChargeCardListState:g,isChargeCardFeatureEnabled:v,isDebitCardFeatureEnabled:j,isDebitCardSetupEnabled:B,isChargeCardSetupEnabled:L,chargeCardCashbackDetailState:U,creditAccount:A,creditAccountRepayment:b,depositAccountListWithDebitCardIssued:f,controllerEmails:m,location:t})})}return c.jsx(va,{fetchState:"In-Progress",style:{backgroundColor:a.colors.grey5}})}const $i=Pe(function(e,n){const{companyId:t,companyLegalName:a}=n;return{chargeCardSetupView:wa(e,t),admins:n.adminList,companyLegalName:a,meetingUrl:"https://meetings.hubspot.com/niharn/demo-zeni-charge-cards?embed=true"}},function(e,n){const{navigate:t,companyId:a,isCompanyBusinessVerificationAndPaymentSetUpDone:s,isDebitCardSetupEnabled:y,isChargeCardSetupEnabled:g,signedInUser:S,location:P,productInformation:m,isEarlyPayEnabled:C,controllerEmails:F,chargeCardsCreditAccountLimit:w}=n;return{onSetupButtonClick:l=>{if(S!=null&&J.trackCardsPromoPageClicked("enable cards"),s)switch(J.trackCardsEnableCardsClick(F,m,"Cards Promo"),l){case"credit":e(qe(a,!0,"charge_cards",C,!1));break;case"debit":e(qe(a,!0,"debit_cards",C,!1));break;case"debit_and_credit":e(w===0?qe(a,!0,"debit_cards",C,!0):qe(a,!0,"charge_cards__debit_cards",C,!1))}else switch(J.trackCardsSetupCardsClick(F,m,"Cards Promo"),l){case"credit":e(qe(a,!1,"charge_cards",C,!1));break;case"debit":e(qe(a,!1,"debit_cards",C,!1));break;case"debit_and_credit":e(w===0?qe(a,!1,"debit_cards",C,!0):qe(a,!1,"charge_cards__debit_cards",C,!1))}},onBackClick:()=>{const l=we(P.state?.pathnameStackToGoBack);let j=l.poppedPathname;j==null&&(j=y||g?"..":"../.."),t(j,{state:{pathnameStackToGoBack:l.newStack}})},onLetsGoClick:()=>{t("./onboard")},onSetupChargeCardSuccess:()=>{s?(e(Xa()),t("../",{relative:"path"})):t("../setup",{relative:"path"})},onExpressInterestClick:()=>{e(Zc(a))}}})(_o),zi=()=>{const e=le(),{tenantEmailDomain:n}=Ve(),[t]=_n(),a=t.get("cardPromoType"),s=me(),{useDynamicConfig:y,useFeatureGate:g}=ue(),[S,P]=r.useState(!1),{isFeatureEnabled:m}=g(W.isDebitCardFeatureEnabled),{isFeatureEnabled:C}=g(W.isEarlyPayFeatureEnabled),{isFeatureEnabled:F}=g(W.isChargeCardFeatureEnabled),{configValue:w}=y(We.zeniCardsConfig),l=i(ae=>ge(ae)),j=i(ae=>da(ae,l.companyId)),B=la(j.controllers),L=w.charge_card_cashback_rate_per_transaction!=null?w.charge_card_cashback_rate_per_transaction:.0175,p=he(),h=te.getSignedInUserTenant(n)?.companyId??l.companyId,T=i(ae=>wa(ae,h)),u=T.primaryFundingAccount,v=l.companyBillPayInfo?.info,k=xe(l),U=Be(l),A=Le(m,l),b=l.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,x=Oe({isDebitCardFeatureEnabled:m,isBankingOnlyTenant:A}),d=Ue({isCardsOnlyTenant:k,isChargeCardFeatureEnabled:F,isBookKeepingTenant:U,isDebitCardProductVisible:x,chargeCardsCreditAccountLimit:b}),f=Dr({isCardsOnlyTenant:k,isChargeCardFeatureEnabled:F,isBookKeepingTenant:U}),M=x&&d===!1,V=v?.businessVerificationStatus?.code==="verified"&&(M||u?.accType==="depositAccount"||$c(u?.providerVerificationStatus?.code??"")),O=te.getSignedInUser(),R=!!l.companyZeniAccountInfo?.info?.isZeniAccountEnabled,z=!!l.companyChargeCardInfo?.info?.isChargeCardTOSAccepted,$=!!l.company?.companyChargeCardInfo?.isChargeCardEnabled,_=!!l.company?.companyDebitCardInfo?.isDebitCardEnabled,D=!!l.companyChargeCardInfo?.info?.isChargeCardEnabled,G=!!l.companyDebitCardInfo?.info?.isDebitCardEnabled,Q=!!l.companyDebitCardInfo?.info?.isDebitCardTOSAccepted,I=ae=>{P(ae)},N=i(ae=>ae.chargeCardSetupViewState.fetchState);if(O==null)throw Error("Can't access Charge Card promo page without signing in...");const K=Re(),X=Fe(K?.loggedInUserRoleMap),o=xt(K?.loggedInUserRoleMap),[E,Y]=r.useState(!1),[ne,q]=r.useState(!1),[ke,ve]=r.useState(!1);r.useEffect(()=>{E===!1&&p.state?.message==="activation"&&Y(!0)},[p.state]),r.useEffect(()=>{ne||N!=="Not-Started"||h==null||(q(!0),s(Pa(h,!0)))},[ne,N,h,s]);const fe=l.companyChargeCardInfo?.info!=null&&Ia({cardInfo:l.companyChargeCardInfo.info,isProductVisible:f&&$,isTOSAccepted:z,isSetupEnabled:D,isUserHasCardsAdminLevelAccess:X,isUserHasCardsAccess:o}),se=l.companyDebitCardInfo?.info!=null&&Ia({cardInfo:l.companyDebitCardInfo.info,isProductVisible:x&&_,isTOSAccepted:Q,isSetupEnabled:G,isUserHasCardsAdminLevelAccess:X,isUserHasCardsAccess:o}),Ee=x&&se&&f&&b>=0&&fe?"debit_and_credit":x&&se?"debit":"credit",re=xo(a,Ee),Ce=T?.chargeCardTermsDetails?.fetchStatus?.fetchState,Ae=r.useRef(null);r.useEffect(()=>{Ce==="In-Progress"?Ae.current=re:Ce!=="Error"&&Ce!=="Not-Started"||(Ae.current=null)},[Ce,re]);const ee=Ce!=="In-Progress"&&Ce!=="Completed"||Ae.current==null?re:Ae.current;r.useEffect(()=>{re==="credit"&&(D||f===!1&&G)||re==="debit"&&G||re==="debit_and_credit"&&G&&D?e("../"):(re==="debit_and_credit"&&z===!0&&Q===!0||re==="credit"&&(z===!0||f===!1&&Q===!0)||re==="debit"&&Q===!0)&&X===!0&&e("../setup")},[V,D,G,re,z,Q]),r.useEffect(()=>{ke||(s(zc("cardAdmin")),ve(!0))},[ke]);const Te=i(ae=>rr(ae.userState,ae.userRoleState,ae.userListViewState,"cardAdmin")),De=Je(f,x,G,D);return(ae=>{switch(ae){case"credit":return $;case"debit":return _;case"debit_and_credit":return $&&_;default:return!1}})(ee)?(fe||se)&&N==="Completed"?c.jsxs(c.Fragment,{children:[c.jsx(Ut,{analytics:J,onLoad:()=>{if(J.trackPageLoaded(kr.Event.cardsPromoPage),!!f&&!D||!!x&&!G||!!f&&!!x&&!G&&!D){const ae=Zi({isDebitCardSetupEnabled:G,isChargeCardSetupEnabled:D,isCreditCardProductVisibleForExpressInterest:f,isDebitCardProductVisible:x});J.trackCardsPromoView(B,De,"Page",ae,"Promo Page")}}}),c.jsx(nt,{showConfetti:E}),c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:I}),c.jsx($i,{signedInUser:O,location:p,showEnableCardButton:V,isCompanyBusinessVerificationAndPaymentSetUpDone:V,isChargeCardSetupEnabled:D,isDebitCardSetupEnabled:G,companyLegalName:l.companyName,adminList:Te.users,isCheckingEnabled:R,navigate:e,companyId:h,cardPromoType:ee,controllerEmails:B,productInformation:De,isCreditCardProductVisible:d,isDebitCardFeatureEnabled:m,isEarlyPayEnabled:C,cashbackRate:L,chargeCardsCreditAccountLimit:b,onClickMenuIcon:()=>{I(!0)}})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:S,handleDrawerToggle:I}),c.jsx(Do,{})]}):c.jsx(Xe,{to:"../",replace:!0})},Zi=({isDebitCardSetupEnabled:e,isChargeCardSetupEnabled:n,isCreditCardProductVisibleForExpressInterest:t,isDebitCardProductVisible:a})=>t&&a&&!e&&!n?"Credit & Debit Card":t&&!n?"Credit Card":a&&!e?"Debit Card":"";function Sd(){const e=he(),n=i(X=>ge(X)),{useFeatureGate:t}=ue(),{isFeatureEnabled:a}=t(W.isChargeCardFeatureEnabled),{isFeatureEnabled:s}=t(W.isDebitCardFeatureEnabled),{isFeatureEnabled:y}=t(W.isEarlyPayFeatureEnabled),{isFeatureEnabled:g}=t(W.isChargeCardPaymentHistoryFeatureEnabled),{isFeatureEnabled:S}=t(W.isCardPolicyEnabled),P=Le(s,n),m=Oe({isDebitCardFeatureEnabled:s,isBankingOnlyTenant:P}),C=Po(n,a,s),F=!!n.company?.companyChargeCardInfo.isChargeCardTOSAccepted,w=!!n.company?.companyDebitCardInfo.isDebitCardTOSAccepted,l=!!n.company?.companyChargeCardInfo?.isChargeCardEnabled,j=!!n.company?.companyDebitCardInfo?.isDebitCardEnabled,B=!!n.companyChargeCardInfo?.info?.isChargeCardEnabled,L=!!n.companyDebitCardInfo?.info?.isDebitCardEnabled,p=Re(),h=Fe(p?.loggedInUserRoleMap),{isCardsShuttingDown:T}=Ir(n.tenantId,n.company?.managementInfo?.receiverEmails),u=xt(p?.loggedInUserRoleMap),{isFeatureEnabled:v}=t(W.isCashbackFeatureEnabled),k=n.userRole.includes("charge_card_user"),U=!k,A=!k&&B,b=n?.userRole!=null&&Wc(n?.userRole),x=(n?.company==null||n.company.featuresActivationInfo?.isBillPayFeatureEnabled&&!b)&&Kc(p?.loggedInUserRoleMap),d=Yc(p?.loggedInUserRoleMap),f=(n?.company==null||n.company.featuresActivationInfo?.isReimbursementFeatureEnabled&&!b)&&qc(p?.loggedInUserRoleMap),{isFeatureEnabled:M}=t(W.isDepositAccountsFeatureEnabled),V=M&&!b&&zn(p?.loggedInUserRoleMap),O=B&&l&&!b,R=L&&j&&!b,z=C&&!b&&Fe(p?.loggedInUserRoleMap),$=Qc(p?.loggedInUserRoleMap),_=xe(n),D=Be(n),G=n.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,Q=Ue({isCardsOnlyTenant:_,isChargeCardFeatureEnabled:a,isBookKeepingTenant:D,isDebitCardProductVisible:m,chargeCardsCreditAccountLimit:G}),I=n.companyChargeCardInfo?.info!=null&&Ia({cardInfo:n.companyChargeCardInfo.info,isProductVisible:Q&&l,isTOSAccepted:F,isSetupEnabled:B,isUserHasCardsAdminLevelAccess:h,isUserHasCardsAccess:u}),N=n.companyDebitCardInfo?.info!=null&&Ia({cardInfo:n.companyDebitCardInfo.info,isProductVisible:m&&j,isTOSAccepted:w,isSetupEnabled:L,isUserHasCardsAdminLevelAccess:h,isUserHasCardsAccess:u}),K=I||N;return c.jsxs(cs,{children:[h?c.jsx(ce,{path:"setup",element:c.jsx(bn,{isBillPayAdminLevelAccess:x,isReimbursementAdminLevelAccess:f,isZeniAccountAdminLevelAccess:V,isChargeCardAdminLevelAccess:z,isUserHasOnlyCardAccess:$,isUserHasOnlyBillPayAccess:d,productType:"charge_cards",type:"setup"})}):null,h?c.jsx(ce,{path:"verification",element:c.jsx(bn,{isBillPayAdminLevelAccess:x,isUserHasOnlyBillPayAccess:d,isReimbursementAdminLevelAccess:f,isZeniAccountAdminLevelAccess:V,isChargeCardAdminLevelAccess:z,isUserHasOnlyCardAccess:$,productType:"charge_cards",type:"verification"})}):null,h&&S?c.jsxs(c.Fragment,{children:[c.jsx(ce,{path:"policy",element:c.jsx(Zo,{})}),c.jsx(ce,{path:"policy/new",element:c.jsx(Uo,{})}),c.jsx(ce,{path:"policy/:templateId/edit",element:c.jsx(Vo,{})})]}):null,c.jsx(ce,{path:"promo",element:c.jsx(zi,{})}),O||R?c.jsxs(c.Fragment,{children:[c.jsx(ce,{path:"/",element:c.jsx(kn,{isPaymentDrawerOpen:!1})}),z&&y?c.jsx(ce,{path:"payment",element:c.jsx(kn,{isPaymentDrawerOpen:!0})}):null,c.jsx(ce,{path:"activate",element:c.jsx(Gi,{})}),c.jsx(ce,{path:"onboard",element:c.jsx(Pi,{})}),h&&T!==!0?c.jsx(ce,{path:"new",element:c.jsx(Mi,{})}):h?c.jsx(ce,{path:"new",element:c.jsx(Xe,{to:"..",replace:!0})}):null,v&&U?c.jsx(ce,{path:"cashback",element:c.jsx(Qo,{})}):null,A?c.jsx(ce,{path:"statements",element:c.jsx(Ai,{})}):null,z&&g&&B?c.jsx(ce,{path:"payment-history",element:c.jsx(Ei,{})}):null,c.jsx(ce,{path:":cardId/activate",element:c.jsx(ei,{})}),c.jsx(ce,{path:":cardId/setPin",element:c.jsx(Fi,{})}),c.jsx(ce,{path:":cardId/addToWallet",element:c.jsx(Wo,{})}),c.jsx(ce,{path:":cardId/*",element:c.jsx(li,{})}),c.jsx(ce,{path:"*",element:c.jsx(ct,{})})]}):(F||w)&&h?c.jsx(ce,{path:"*",element:c.jsx(Xe,{to:"../setup"})}):K?c.jsx(ce,{path:"*",element:c.jsx(Xe,{to:"../promo",state:e.state})}):c.jsx(ce,{path:"*",element:null})]})}export{Sd as default};
@@ -0,0 +1 @@
1
+ import{j as m}from"./liveblocks-D0coviDj.js";import{a as g}from"./sentry-BX7AV8EY.js";import{h as w,u as T,g as x,i as k,j as O,n as E}from"./core-PLgxH77Q.js";import{z as C,be as P,D as F,d as V,f as j,ag as b,bf as A,au as L,av as U,v as B}from"./index-DplenJAr.js";import{eX as D,gj as M,tC as _,ge as z,c6 as G,Pn as R,bn as Y,rC as q,rq as H,l5 as Q,mG as S,Po as X,bE as Z,cz as N,mQ as $,mT as J}from"./zeni-epic-state-CvlYbP8V.js";import"./mui-C0RqdtC7.js";import{d as K}from"./routePaths-DqswWqzZ.js";import{M as W}from"./MobileAppDrawer-CcJQi30K.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new a.Error().stack;t&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[t]="b2710fdd-1e62-4d0a-b4e7-4171e71eeaea",a._sentryDebugIdIdentifier="sentry-dbid-b2710fdd-1e62-4d0a-b4e7-4171e71eeaea")}catch{}})();const ee=E(function(a){const t=z(a),i=C.getSignedInUser(),l=D(a),c=l.tenantId,p={userId:i?.userId??"",sessionId:i?.zeniSessionId??"",tenantId:c??""},f=G(l?.userRole??[])&&t.localData.updateStatus.fetchState!=="In-Progress"?void 0:"readonly",e=R(a.companyConfigState),n=a.countryListState?.byCountryListCode?.nationalityCountryList?.countries??[];return{isCompanyVerified:t.companyView?.company?.company?.companyBillPayInfo?.companyVerificationStatus?.code==="verified",companyPassportView:t,allIndustries:e.companyIndustries??[],allNationalityCountries:n,isDisabled:f,authParams:p,filesEndPoint:`${L.fileMicroServiceBaseUrl}`,isZeniUser:Y(i)}},function(a,t){const{companyId:i,currentTenant:l,navigate:c,location:p}=t,{tenantEmailDomain:f}=l;return{onScheduleClick:e=>{let n=e.href;n.includes("http")||(n="https://".concat(n)),window.open(n,"_blank")},onSaveAll:()=>{a(J())},onAddressClick:e=>{const n=K(f,e),o=B(p.state?.pathnameStackToGoBack,p.pathname);c(n,{state:{pathnameStackToGoBack:o}})},onResetClick:()=>{a($({companyId:i}))},onBackClick:()=>{c("../")},onCompanyDetailsChanged:e=>{const{companyInfo:n,incInfo:o,taxDetails:r,zeniFinanceTeam:d}=e,{website:u}=n,{meetingLink:y}=d,{incDate:s}=o,{taxesFiledYears:h}=r,v={companyInfo:{...n,website:u!=""&&u!=null?N(u):void 0,meetingLink:y!=""&&y!=null?N(y):void 0,industry:n.industry.selectedOption,companyIndustryType:n.companyIndustryType?.selectedOption??void 0,companySubIndustry:n.companySubIndustry?.selectedOption??void 0,businessModel:n.businessModel.selectedOption??"",companySourceOfFunds:n.companySourceOfFunds?.selectedOption,companySourceOfFundsDescription:n.companySourceOfFundsDescription??void 0,countriesOfOperations:n.countriesOfOperations?.selectedOptions?.map(I=>I.length===2?I:U(I))??[],transactionVolume:n.transactionVolume?.selectedOption??void 0,transactionVolumeDescription:n.transactionVolumeDescription??void 0,regulatedStatus:n.regulatedStatus??void 0,regulatedStatusDescription:n.regulatedStatusDescription??void 0,usNexus:n.usNexus??void 0,usNexusTypes:n.usNexusTypes?.selectedOptions??[],purposeOfAccount:n.purposeOfAccount?.selectedOption??void 0,purposeOfAccountDescription:n.purposeOfAccountDescription??void 0},incInfo:{typeOfInc:o.typeOfInc.selectedOption??"",stateOfInc:o.stateOfInc.selectedOption??"",incDate:s!=null?Z(s?.toString()):s,fileId:o.fileIds[0]},taxDetails:{taxIdOrEIN:r.taxIdOrEIN,sicCode:r.sicCode,naicsCode:r.naicsCode,dunsNumber:r.dunsNumber,taxesFiledYears:h.selectedOptions.map(I=>parseInt(I)),fileId:r.fileIds[0]}};a(S({companyDetails:v}))},onPrimaryContactDetailsUpdated:e=>{a(S({primaryContact:{userId:e.userId,email:e.email.trim(),firstName:e.name.firstName,lastName:e.name.lastName}}))},onNewCompanyOfficerAdded:e=>{a(S({officers:[{officerType:e.officerType,email:e.email.trim(),phone:e.phone,firstName:e.name.firstName,lastName:e.name.lastName,userId:void 0}]}))},onNewCompanyOfficerRemoved:e=>{a(X(e))},onCompanyOfficerUpdated:e=>{a(S({officers:[{officerType:e.officerType,email:e.email.trim(),phone:e.phone,firstName:e.name.firstName,lastName:e.name.lastName,userId:e.userId}]}))},updateFilesEntity:e=>{a(Q({files:e}))},onDeleteFile:e=>{a(H(e))},onEditFileName:(e,n)=>{a(q(e,n.split(".")[0]))}}})(A);function de(){const a=w(),t=T(),i=x(),{tenantEmailDomain:l}=k(),[c,p]=g.useState(!1),[f,e]=g.useState(!1),n=O(s=>s.companyViewState.passportView.fetchState),o=O(s=>s.companyConfigState.fetchState),r=O(s=>D(s)),d=r.companyId??C.getSignedInUserTenant(l)?.companyId;if(C.getSignedInUser()==null)throw Error("Can't access company details page without signing in...");g.useEffect(()=>{c||n!=="Not-Started"||d==null||(p(!0),t(M(d)))},[c,n,d,t]),g.useEffect(()=>{o==="Not-Started"&&t(_())},[o,t]);const u=s=>{e(s)},y=n==="Not-Started"||n==="In-Progress"||o==="Not-Started"||o==="In-Progress";return d!=null&&n==="Error"?m.jsx(P,{onGoHome:()=>a("../",{replace:!0}),onReload:()=>window.location.reload()}):m.jsxs(m.Fragment,{children:[m.jsx(F,{analytics:V,onLoad:s=>s.trackPageLoaded(j.Event.companyPassport,b(i)?"Settings":"Company Passport")}),b(i)?m.jsx(W,{isAppContentDrawerOpen:f,handleDrawerToggle:u}):null,m.jsx(ee,{companyId:d,navigate:a,location:i,isLoading:y,currentTenant:r,isSettings:b(i),onClickMenuIcon:()=>{u(!0)}})]})}export{de as C};
@@ -1,4 +1,4 @@
1
- import{j as g}from"./liveblocks-DvqoH3dJ.js";import{a}from"./sentry-oCFmppdA.js";import{u as D,g as v,j as m,N as w}from"./core-BUDfBDzW.js";import{LW as A,eX as O,g1 as _,o9 as j,gs as h,g0 as L,fA as U,M1 as F}from"./zeni-epic-state-BRNxIopP.js";import{u as $,z as p,L as C,a as k,o as H}from"./index-9PmElJom.js";import{n as z}from"./mui-BX-eccqP.js";import{t as R}from"./getLocaleForTenant-D9pSDinJ.js";import{g as P,Q as G}from"./QBOConnectionScreen-D2pSbt3W.js";import"./recharts-C3oDuogX.js";import"./analytics-DL3j77s3.js";import"./plaid-C1X6Gp1j.js";import"./dnd-C2uuKLS_.js";import"./stripe-DMRn4zHo.js";import"./lottie-DU31Qsck.js";import"./lexical-BJhq3Vel.js";import"./pdf-SnLRVeGX.js";import"./utils-BdmIffFy.js";import"./empty-gH7VKio2.js";import"./pdf-lib-C5S3Bgj_.js";import"./index-CwfGUvf7.js";import"./url-MZGYWUXg.js";import"./index-YvePaYki.js";import"./decodeURIComponentSafe-CAV5JFIH.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},i=new t.Error().stack;i&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[i]="b4b78fa5-2985-4494-adcd-66b73055d705",t._sentryDebugIdIdentifier="sentry-dbid-b4b78fa5-2985-4494-adcd-66b73055d705")}catch{}})();const M=z.div`
1
+ import{j as g}from"./liveblocks-D0coviDj.js";import{a}from"./sentry-BX7AV8EY.js";import{u as D,g as v,j as m,N as w}from"./core-PLgxH77Q.js";import{LW as A,eX as O,g1 as _,o9 as j,gs as h,g0 as L,fA as U,M1 as F}from"./zeni-epic-state-CvlYbP8V.js";import{u as $,z as p,L as C,a as k,o as H}from"./index-DplenJAr.js";import{n as z}from"./mui-C0RqdtC7.js";import{t as R}from"./getLocaleForTenant-BGLRsxve.js";import{g as P,Q as G}from"./QBOConnectionScreen-gf22CW_5.js";import"./recharts-IQlfHMoz.js";import"./analytics-FZZqBV_U.js";import"./plaid-COO6326w.js";import"./dnd-BR185E7x.js";import"./stripe-DMRn4zHo.js";import"./lottie-Cr90j9wu.js";import"./lexical-lY8wPGQT.js";import"./pdf-Aivmor3r.js";import"./utils-CBwnO3Ef.js";import"./empty-CNe_ouDG.js";import"./pdf-lib-B-stT0RK.js";import"./index-D0Jc1k7S.js";import"./url-Dv9uN6IP.js";import"./index-CpBcW5M7.js";import"./decodeURIComponentSafe-CQ4ERcUl.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},i=new t.Error().stack;i&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[i]="b4b78fa5-2985-4494-adcd-66b73055d705",t._sentryDebugIdIdentifier="sentry-dbid-b4b78fa5-2985-4494-adcd-66b73055d705")}catch{}})();const M=z.div`
2
2
  display: flex;
3
3
  flex: 1 1 auto;
4
4
  flex-direction: row;
@@ -0,0 +1 @@
1
+ import{j as i}from"./liveblocks-D0coviDj.js";import{z as n}from"./index-DplenJAr.js";import{g as d}from"./QBOConnectionScreen-gf22CW_5.js";import"./sentry-BX7AV8EY.js";import{g as p,N as s}from"./core-PLgxH77Q.js";import"./zeni-epic-state-CvlYbP8V.js";import"./recharts-IQlfHMoz.js";import"./mui-C0RqdtC7.js";import"./analytics-FZZqBV_U.js";import"./plaid-COO6326w.js";import"./dnd-BR185E7x.js";import"./stripe-DMRn4zHo.js";import"./lottie-Cr90j9wu.js";import"./lexical-lY8wPGQT.js";import"./pdf-Aivmor3r.js";import"./utils-CBwnO3Ef.js";import"./empty-CNe_ouDG.js";import"./pdf-lib-B-stT0RK.js";import"./index-D0Jc1k7S.js";import"./url-Dv9uN6IP.js";import"./index-CpBcW5M7.js";import"./decodeURIComponentSafe-CQ4ERcUl.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new t.Error().stack;o&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[o]="817363c8-7f1d-4590-b58b-cef70b99ca15",t._sentryDebugIdIdentifier="sentry-dbid-817363c8-7f1d-4590-b58b-cef70b99ca15")}catch{}})();const U=()=>{const t=p(),{code:o,realmId:r,state:e}=d(t.search),m=n.getSignedInUser()?.userId??"";if(f(o,r,e,m)===!0){const a=`../../${e}/onboarding?code=${o}&realmId=${r}&state=auth_flow`;return i.jsx(s,{to:a})}return i.jsx(s,{to:"../../"})},f=(t,o,r,e)=>t!=""&&o!=""&&r!=""&&e!=null&&e!="";export{U as default,f as hasValidParams};