@zeniai/web-app-ui 5.1.54-qa → 5.1.55-dev

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 (121) hide show
  1. package/dist/assets/AddressRoutes-DvgS57PS.js +1 -0
  2. package/dist/assets/AddressScreen-kHZ3pkiE.js +9 -0
  3. package/dist/assets/{AiCfoScreen-CuCVJ-9z.js → AiCfoScreen-CnZOpF7D.js} +1 -1
  4. package/dist/assets/BillPayApprovalRoutes-CIS2PKjh.js +1 -0
  5. package/dist/assets/{BillPayRoutes-C-57jjzC.js → BillPayRoutes-Cp4tN_kn.js} +1 -1
  6. package/dist/assets/{BusinessVerificationPageScreen-CoxJBcce.js → BusinessVerificationPageScreen-Ds_dEqcf.js} +1 -1
  7. package/dist/assets/{CardsAiCfoScreen-BXut6M7h.js → CardsAiCfoScreen-DkmqTSNf.js} +1 -1
  8. package/dist/assets/{ChargeCardRoutes-DAakvdza.js → ChargeCardRoutes-CqBU7ZCW.js} +1 -1
  9. package/dist/assets/CompanyPassportScreen-DBSTWMtn.js +1 -0
  10. package/dist/assets/{ConnectionAuthScreen-BOHdbzkN.js → ConnectionAuthScreen-DzKO3rid.js} +1 -1
  11. package/dist/assets/CustomerOnboardingAuthScreen-ucKYqEJq.js +1 -0
  12. package/dist/assets/{CustomerOnboardingRoutes-Dh6ZowLh.js → CustomerOnboardingRoutes-CBqysmDl.js} +3 -3
  13. package/dist/assets/{DashboardRoutes-Cox4nEtE.js → DashboardRoutes-C0rT4cbB.js} +1 -1
  14. package/dist/assets/{DefaultTenantHome-DsGlDo8q.js → DefaultTenantHome-BPqd9f9F.js} +1 -1
  15. package/dist/assets/{DomesticWireDetailScreen-Dwlu904z.js → DomesticWireDetailScreen-BqVZ4JA4.js} +1 -1
  16. package/dist/assets/DrawerScreen-CuqanTdv.js +1 -0
  17. package/dist/assets/EntityDetailRoutes-BCC1kZvg.js +1 -0
  18. package/dist/assets/{ExpenseAutomationRoutes-CKsYpo_A.js → ExpenseAutomationRoutes-BvUJJ11E.js} +1 -1
  19. package/dist/assets/FeaturePreviewScreen-DruJFyVL.js +1 -0
  20. package/dist/assets/{HubSpotOAuthCallbackScreen-074s_I3B.js → HubSpotOAuthCallbackScreen-JY_hR32w.js} +1 -1
  21. package/dist/assets/{MagicLinkRoutes-Cu1l5Hae.js → MagicLinkRoutes-C4tggAcT.js} +6 -6
  22. package/dist/assets/MagicLinkSignInScreen-DSCcYkfy.js +12 -0
  23. package/dist/assets/{MobileAppDrawer-BPYh3fz7.js → MobileAppDrawer-DSwbMXYq.js} +1 -1
  24. package/dist/assets/NotFoundScreen-DaDxz3Zq.js +1 -0
  25. package/dist/assets/{NotificationRoutes-CM26Uc2-.js → NotificationRoutes-DlUwzF5Z.js} +1 -1
  26. package/dist/assets/{OAuthConsentScreen-OutOQhzE.js → OAuthConsentScreen-BQwxsDot.js} +1 -1
  27. package/dist/assets/{PandLWithForecastRoutes-B0qogd0A.js → PandLWithForecastRoutes-D3okgigP.js} +1 -1
  28. package/dist/assets/{PeopleRoutes-CUTyVwx1.js → PeopleRoutes-De0hcTG9.js} +2 -2
  29. package/dist/assets/{PerformanceRoutes-12eFPdp_.js → PerformanceRoutes-C_ycbWFc.js} +1 -1
  30. package/dist/assets/{Preview-DIHwHgF2.js → Preview-JiizEL_C.js} +1 -1
  31. package/dist/assets/{QBOConnectionScreen-D87ZntTL.js → QBOConnectionScreen-BOOiYmna.js} +1 -1
  32. package/dist/assets/ReferralListScreen-Cv0fhFUv.js +5 -0
  33. package/dist/assets/ReimbursementApprovalRoutes-hf0qddAB.js +1 -0
  34. package/dist/assets/ReimbursementApprovalRuleDetailScreen-BTAascVp.js +1 -0
  35. package/dist/assets/{ReimbursementRoutes-DSyBtaLh.js → ReimbursementRoutes-7HSI61Wk.js} +5 -5
  36. package/dist/assets/{ReportsRoutes-CrvdJeby.js → ReportsRoutes-BB28RWU5.js} +1 -1
  37. package/dist/assets/{RewardsRoutes-DYWFgTvw.js → RewardsRoutes-DVcld8aj.js} +1 -1
  38. package/dist/assets/ScreenRoutes-CFaDbJ8O.js +2 -0
  39. package/dist/assets/{SettingsRoutes-D-CGv9n3.js → SettingsRoutes-D4--hBRA.js} +1 -1
  40. package/dist/assets/{SetupPagesScreen-Bfb-yG5Q.js → SetupPagesScreen-Cl6654uo.js} +1 -1
  41. package/dist/assets/SignInScreen-DovpkvtQ.js +1 -0
  42. package/dist/assets/SignOutScreen-BwLbw69y.js +9 -0
  43. package/dist/assets/{TaskListScreen-SFzbbBq2.js → TaskListScreen-Cc1704_o.js} +2 -2
  44. package/dist/assets/{TaskRoutes-CgfIdOfE.js → TaskRoutes-COfhZO9a.js} +1 -1
  45. package/dist/assets/{TransactionDetailRoutes-BX1iNIyW.js → TransactionDetailRoutes-BLjycMRi.js} +1 -1
  46. package/dist/assets/{TransactionDetailScreen-bJ4okRq5.js → TransactionDetailScreen-DuwJpwyK.js} +1 -1
  47. package/dist/assets/{TransactionListRoutes-C7_m6Yqx.js → TransactionListRoutes-B6GnstS7.js} +1 -1
  48. package/dist/assets/{TreasuryRoutes-CueVe1jr.js → TreasuryRoutes-CHZyInsw.js} +6 -6
  49. package/dist/assets/{VendorsRoutes-DrErfdsR.js → VendorsRoutes-DlVyqp0b.js} +1 -1
  50. package/dist/assets/WiseConfirmationScreen-CeC5ER-6.js +12 -0
  51. package/dist/assets/{ZeniAccountRoutes-_K25ghKx.js → ZeniAccountRoutes-DggTbH7A.js} +9 -9
  52. package/dist/assets/ZeniAccountStatementScreen-CU1luGN8.js +9 -0
  53. package/dist/assets/{accountMappingHelper-BSLlTYQH.js → accountMappingHelper-BfrLGhoG.js} +1 -1
  54. package/dist/assets/{analytics-BHHyMpuV.js → analytics-CQmVOD4d.js} +1 -1
  55. package/dist/assets/{analyticsHelper-BsjRdUZX.js → analyticsHelper-BcD2hj7Q.js} +1 -1
  56. package/dist/assets/{core-CLKYLs-8.js → core-CbpoBsNm.js} +1 -1
  57. package/dist/assets/{decodeURIComponentSafe-Bm32N7cj.js → decodeURIComponentSafe-9Mzf3G8U.js} +1 -1
  58. package/dist/assets/{dnd-BgEYAbRi.js → dnd-CX5suNP6.js} +1 -1
  59. package/dist/assets/{empty-CwSgGrxu.js → empty-BijKctOw.js} +1 -1
  60. package/dist/assets/{empty-DdtYEopm.js → empty-DhAifQ6-.js} +1 -1
  61. package/dist/assets/{emptyVideoElement-D6kbFw8A.js → emptyVideoElement-D-mIIbkx.js} +1 -1
  62. package/dist/assets/epic-D_RLnD_Y.js +2 -0
  63. package/dist/assets/{getLocaleForTenant-C_VQis3o.js → getLocaleForTenant-DvFF548D.js} +1 -1
  64. package/dist/assets/{index-DR5HeC7u.js → index-B781xFYL.js} +2 -2
  65. package/dist/assets/{index-UrW8im9e.js → index-Bg6fgf4p.js} +1 -1
  66. package/dist/assets/{index-Dr5dodMd.js → index-CR_Xz42r.js} +1 -1
  67. package/dist/assets/{index-CTH1zZXf.js → index-CTRa-Eva.js} +1 -1
  68. package/dist/assets/{index-D_hiFYsE.js → index-CoMuhThK.js} +11456 -11456
  69. package/dist/assets/{index-CtRgwYlG.js → index-D-GsKzyX.js} +1 -1
  70. package/dist/assets/{index-DxSdRLh_.js → index-Mdt1gUpR.js} +1 -1
  71. package/dist/assets/{index-BzKXgra3.js → index-cXBO33fb.js} +1 -1
  72. package/dist/assets/{lexical-DN4b_Twn.js → lexical-BS7d_1CV.js} +1 -1
  73. package/dist/assets/{liveblocks-B6jAIe9x.js → liveblocks-BLlSTcoD.js} +1 -1
  74. package/dist/assets/{lottie-C38Bn-X6.js → lottie-BY8e0Ufw.js} +1 -1
  75. package/dist/assets/{mui-AZmtqUsi.js → mui-DcNGd9L2.js} +1 -1
  76. package/dist/assets/{pathToGoBack-ogdURlZM.js → pathToGoBack-C2QnAeVh.js} +1 -1
  77. package/dist/assets/{pdf-BzNDzZ8_.js → pdf-BslZhgI8.js} +4 -4
  78. package/dist/assets/{pdf-lib-0dW_LSbG.js → pdf-lib-BxiXr152.js} +1 -1
  79. package/dist/assets/{plaid-2Q72y6JT.js → plaid-B62punae.js} +1 -1
  80. package/dist/assets/{pusher-DsUo-9K1.js → pusher-yI34WBaU.js} +1 -1
  81. package/dist/assets/{react-DsxTC2P5.js → react-BhNVTcBK.js} +1 -1
  82. package/dist/assets/{react-C_zFJEm7.js → react-Bxt57-xI.js} +1 -1
  83. package/dist/assets/{react-DoYlyteP.js → react-CcJOgdcP.js} +1 -1
  84. package/dist/assets/{react-Ckos0IeG.js → react-D4d29E8H.js} +1 -1
  85. package/dist/assets/{react-BvYGWaT4.js → react-DP_wuGKo.js} +1 -1
  86. package/dist/assets/{react-BpYPYN78.js → react-bALoVfnT.js} +1 -1
  87. package/dist/assets/{recharts-CyaYjFwn.js → recharts-C0aThBg3.js} +1 -1
  88. package/dist/assets/{routePaths-XSngD1ow.js → routePaths-BqMV9loV.js} +1 -1
  89. package/dist/assets/{sentry-95bdnR3R.js → sentry-D_xp3E3Q.js} +1 -1
  90. package/dist/assets/{url-Br2V-Pa5.js → url-Cn_1-HsX.js} +1 -1
  91. package/dist/assets/{url-C5803Pxi.js → url-DZdoYQOC.js} +1 -1
  92. package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-CmgL0oiB.js → useAiCfoDashboardSuggestedQuestionsChips-Bw1l6HHU.js} +1 -1
  93. package/dist/assets/useAskAiCfoHostNavButtonProps-Dkub9Q1g.js +1 -0
  94. package/dist/assets/{useCashManagementBanner-Dy5XCSd3.js → useCashManagementBanner-zmolS1ux.js} +1 -1
  95. package/dist/assets/{useDeviceId-B5LKCqFY.js → useDeviceId-BX67JldO.js} +1 -1
  96. package/dist/assets/{useInitialThreadRequest-D1F5GLCG.js → useInitialThreadRequest-DKCJ4fRp.js} +1 -1
  97. package/dist/assets/{utils-CDpOkGne.js → utils-BQO84dIV.js} +1 -1
  98. package/dist/assets/{withTransactionSidePanel-kr0tYyxP.js → withTransactionSidePanel-DzEVaF52.js} +1 -1
  99. package/dist/assets/{zeni-epic-state-CjQblqOQ.js → zeni-epic-state-CkeDRiud.js} +3 -3
  100. package/dist/index.html +1 -1
  101. package/package.json +3 -3
  102. package/dist/assets/AddressRoutes-B9BoI8Fv.js +0 -1
  103. package/dist/assets/AddressScreen-BRdhnUB3.js +0 -9
  104. package/dist/assets/BillPayApprovalRoutes-BrRYqqLJ.js +0 -1
  105. package/dist/assets/CompanyPassportScreen-DUlm9sdh.js +0 -1
  106. package/dist/assets/CustomerOnboardingAuthScreen-BQyQByde.js +0 -1
  107. package/dist/assets/DrawerScreen-KqrF4Sq7.js +0 -1
  108. package/dist/assets/EntityDetailRoutes-COXR1SAJ.js +0 -1
  109. package/dist/assets/FeaturePreviewScreen-CNGfajWs.js +0 -1
  110. package/dist/assets/MagicLinkSignInScreen-iqOI3pqv.js +0 -12
  111. package/dist/assets/NotFoundScreen-ChEBjJeL.js +0 -1
  112. package/dist/assets/ReferralListScreen-BsBo666O.js +0 -5
  113. package/dist/assets/ReimbursementApprovalRoutes-ClbZ-O2b.js +0 -1
  114. package/dist/assets/ReimbursementApprovalRuleDetailScreen-D_Tk1V_u.js +0 -1
  115. package/dist/assets/ScreenRoutes-BE5zmBx7.js +0 -2
  116. package/dist/assets/SignInScreen-DKI-p16g.js +0 -1
  117. package/dist/assets/SignOutScreen-C2_s3moc.js +0 -9
  118. package/dist/assets/WiseConfirmationScreen-DrQXGVBy.js +0 -12
  119. package/dist/assets/ZeniAccountStatementScreen-Be29Xc0Q.js +0 -9
  120. package/dist/assets/epic-DZb8kqBH.js +0 -2
  121. package/dist/assets/useAskAiCfoHostNavButtonProps-FETbJUjN.js +0 -1
@@ -0,0 +1 @@
1
+ import{j as e}from"./liveblocks-BLlSTcoD.js";import{A as d}from"./AddressScreen-kHZ3pkiE.js";import i from"./NotFoundScreen-DaDxz3Zq.js";import"./sentry-D_xp3E3Q.js";import{o as s,p as r}from"./core-CbpoBsNm.js";import"./zeni-epic-state-CkeDRiud.js";import"./recharts-C0aThBg3.js";import"./index-CoMuhThK.js";import"./mui-DcNGd9L2.js";import"./analytics-CQmVOD4d.js";import"./plaid-B62punae.js";import"./dnd-CX5suNP6.js";import"./stripe-DMRn4zHo.js";import"./lottie-BY8e0Ufw.js";import"./lexical-BS7d_1CV.js";import"./pdf-BslZhgI8.js";import"./utils-BQO84dIV.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]="cd0ff2b4-1e27-4329-addf-f475e5a9db34",t._sentryDebugIdIdentifier="sentry-dbid-cd0ff2b4-1e27-4329-addf-f475e5a9db34")}catch{}})();function _(){return e.jsxs(s,{children:[e.jsx(r,{path:"/edit/:addressType/:addressId",element:e.jsx(d,{})}),e.jsx(r,{path:"/new/:addressType",element:e.jsx(d,{})}),e.jsx(r,{path:"*",element:e.jsx(i,{})})]})}export{_ as default};
@@ -0,0 +1,9 @@
1
+ import{j as r}from"./liveblocks-BLlSTcoD.js";import{a as h}from"./sentry-D_xp3E3Q.js";import{h as T,u as _,g as j,i as M,j as E,n as B}from"./core-CbpoBsNm.js";import{K as $,m as D,z as K,j as L,B as O,A as z,d as C,f as S,n as F,h as b,p as N}from"./index-CoMuhThK.js";import{Ml as w,hO as R,eW as U,Mm as G,c7 as V,Mn as q,l7 as H}from"./zeni-epic-state-CkeDRiud.js";import{n as W}from"./mui-DcNGd9L2.js";import J from"./NotFoundScreen-DaDxz3Zq.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="b8c762e4-0ab2-4314-8e02-9cd5dbf13d64",e._sentryDebugIdIdentifier="sentry-dbid-b8c762e4-0ab2-4314-8e02-9cd5dbf13d64")}catch{}})();const Q=W.div`
2
+ display: flex;
3
+ height: 100vh;
4
+ width: 100%;
5
+ flex: 1 1 auto;
6
+ flex-direction: column;
7
+ align-items: center;
8
+ background-color: ${e=>e.theme.colors.grey4};
9
+ `,X=B(function(e,t){const{addressId:o,isSubPage:i,addressType:c}=t,l=U(e),a=t.roleMap!=null&&G(t.roleMap),d=i||c==="user_address"||V(l?.userRole??[])||a?void 0:"readonly";if(o==null){const s=q(c,e);return{addressToEdit:s?.addressToCreate,loadingState:s?.status?.fetchState,googleAPIKey:b.googleMapsAPIKey,isDisabled:d,isSubPage:i,dontShowSaveConfirmationPopup:t.dontShowSaveConfirmation}}const n=w(e,o);return{addressToEdit:n.address,loadingState:n.fetchState,googleAPIKey:b.googleMapsAPIKey,isDisabled:d}},function(e,t){const{navigate:o,location:i,addressType:c}=t,l=a=>{if(a==="express-pay")o("../express-pay/add-wire");else{const d=i.state,n=N(d?.pathnameStackToGoBack);let s=n.poppedPathname??A();const u=d?.queryParams;if(u){const g=new URLSearchParams(u).toString();g&&(s=`${s}?${g}`)}o(s,{state:{pathnameStackToGoBack:n.newStack}})}};return{onSubmitHandler:a=>{const d=Y(a);e(H({addressType:c,addressToCreate:d})),C?.trackSaveAddressClicked(S.Event.saveAddressClicked,{street:a.street.addressString,city:a.city,state:a.state,country:a.country.selectedOption??"",postalCode:a.postalCode,suite:a.suite,secondaryInfo:a.secondaryInfo}),l(t.bankAccountContext)},onCancel:()=>{l(t.bankAccountContext)}}})(F);function re({isSubPage:e,hideAddressSubTitle:t=!1,hideAddressBackButton:o=!1,dontShowSaveConfirmation:i,accountContext:c,addressTypeParam:l}){const a=T(),d=_(),n=j(),{addressId:s,addressType:u}=M(),g=$(),I=D(),k=K.getSignedInUser(),[f,v]=h.useState(s==null),p=E(m=>s!=null?w(m,s).fetchState:"Not-Started"),x=L();if(k==null)throw Error("Can't access address page without signing in...");const P=m=>m.trackPageLoaded(s!=null?S.Event.editAddress:S.Event.addAddress),y=l??u;return h.useEffect(()=>{f||s==null||(v(!0),d(R(s,!1)))},[f,s,d]),y==null||y.match(/(user_address|company_address|company_registered_address|vendor_address|officer_([1-9]|10)_address)$/g)?!f&&p==="Not-Started"||f&&p==="In-Progress"?r.jsx(O,{fetchState:p,style:{backgroundColor:I.colors.grey5}}):s!=null&&p==="Error"?(a(`${A(1)}/new`,{replace:!0}),r.jsx(r.Fragment,{})):r.jsxs(r.Fragment,{children:[r.jsx(z,{analytics:C,onLoad:P}),r.jsx(Q,{windowSize:g,children:r.jsx(X,{location:n,navigate:a,isSubPage:e===!0,hideAddressBackButton:o,hideAddressSubTitle:t,addressId:s,addressType:y,dontShowSaveConfirmation:i,bankAccountContext:c,roleMap:x?.loggedInUserRoleMap})})]}):r.jsx(J,{})}const A=(e=2)=>{let t="../";for(let o=0;o<e;o++)t=`${t}../`;return t},Y=e=>({street:[e.street.addressString,e.suite,e.secondaryInfo],city:e.city,state:e.state,country:e.country.selectedOption??"",countryCode:e.countryCode,postalCode:e.postalCode,latitude:e.street.addressValue?.locationLat,longitude:e.street.addressValue?.locationLng});export{re as A,Y as t};
@@ -1,4 +1,4 @@
1
- import{j as c}from"./liveblocks-B6jAIe9x.js";import{a as r}from"./sentry-95bdnR3R.js";import{u as xe,h as Pe,g as we,j as Z,i as ye,n as Ee}from"./core-CLKYLs-8.js";import{W as Te,d9 as ve,z as Ae,K as Qe,da as _e,db as Oe,b6 as J,dc as ae,dd as Ue,b5 as se,n as M,A as B,c as I,de as R,df as je,dg as Le,a1 as Fe,e as De,a7 as Be,dh as Re,di as Ve,a2 as Me,dj as $e,dk as Ge,dl as Ne,r as qe,b1 as We,dm as ze}from"./index-D_hiFYsE.js";import{gj as He,eV as oe,eW as Ke,iu as Xe,Ts as Ye,fn as Ze,iE as Je,iA as et,eX as V,fu as tt,g4 as at,fZ as st,g1 as ee,g5 as ot,g6 as nt,g7 as it,g8 as rt,g9 as lt}from"./zeni-epic-state-CjQblqOQ.js";import{D as dt,n as k,S as ct,P as ut}from"./mui-AZmtqUsi.js";import{u as mt}from"./useAiCfoDashboardSuggestedQuestionsChips-CmgL0oiB.js";import{p as pt}from"./pathToGoBack-ogdURlZM.js";import"./recharts-CyaYjFwn.js";import"./analytics-BHHyMpuV.js";import"./plaid-2Q72y6JT.js";import"./dnd-BgEYAbRi.js";import"./stripe-DMRn4zHo.js";import"./lottie-C38Bn-X6.js";import"./lexical-DN4b_Twn.js";import"./pdf-BzNDzZ8_.js";import"./utils-CDpOkGne.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new e.Error().stack;o&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[o]="bd5602a6-0c70-44ea-a3c6-709b9b1feb14",e._sentryDebugIdIdentifier="sentry-dbid-bd5602a6-0c70-44ea-a3c6-709b9b1feb14")}catch{}})();const ne="chat-response-generated",ht=Ee(function(e,o){const t=oe(e),u=o.isSubmitting,a=t.uiState?.currentChatSessionId,h=a!=null?tt(e.aiCfoState,a):[],S=Ve(e,{allUsers:o.allUsers,onCardPolicyVendorSearchTextChange:o.onCardPolicyVendorSearchTextChange});return{showSampleQuestions:o.sessionFromUrl==="explore"&&t.uiState.currentChatSessionId==null,aiCfoView:t,isSubmitting:u,isNewChatSession:o.sessionFromUrl==="new_chat"||o.sessionFromUrl==="explore",isFullView:!0,tableDownloadEndPoint:`${Me}/tableDownload`,emailLinkQuestion:o.emailLinkQuestion,autoSubmitEmailLinkQuestion:o.autoSubmitEmailLinkQuestion,onEmailLinkQuestionProcessed:o.onEmailLinkQuestionProcessed,routedInitialQuestionSource:o.routedInitialQuestionSource,routedInitialQuestionSuggestionIndex:o.routedInitialQuestionSuggestionIndex,exploreSuggestedPromptQuestions:o.exploreSuggestedPromptQuestions,exploreSuggestedPromptQuestionsLoading:o.exploreSuggestedPromptQuestionsLoading,isFileUploadEnabled:o.isFileUploadEnabled,isUploadPromoVisible:o.isUploadPromoVisible,onUploadPromoClose:o.onUploadPromoClose,syntheticAnswers:h,resolveSyntheticAnswerCardTile:Ge(e),resolveSyntheticAnswerPolicyTile:$e(e),...S}},function(e,o){const{location:t,currentTenant:u,userId:a,navigate:h,currentChatSessionId:S,allSessionsWithOrderedQuestionAnswers:x,isAiCardCreationEnabled:T,isCardPolicyEnabled:v,setIsAiCfoOpen:b}=o,m=u.tenantEmailDomain;return{onEventReceived:(s,l)=>{if(s===ne&&typeof l.text=="string"&&typeof l.metadata=="object"){const d=l,g=nt(d.type),p=d.metadata.chat_session_id??null,{currentChatSession:n,currentQuestionAnswer:P,currentQuestionAnswerSummary:A}=se(x,p);g!=="answer"?I.trackAICFOChatResponseGenerated(g,P?.question.questionText??"",d.text,p,ze(A,n),d.metadata.message_id??null):I.trackAICFOChatAnswerGenerated(d.text,P?.question.questionText??"",(d.follow_up_questions?.length??0)>0,!!d.assumptions,!!d.insights,d.visualization!=null,it(d.visualization?.type??"")??null,p,d.summarized_title,d.metadata.message_id??null),e(rt({chatSessionId:d.metadata.chat_session_id,responseType:g,fetchState:{fetchState:"Completed",error:void 0}})),e(lt({chatSessionId:d.metadata.chat_session_id,answerPayload:d,userId:a}))}},onSubmit:(s,l,d,g)=>{s&&We(e,s,l,S,x,a,g,d)},updateCurrentInput:s=>{e(ee(s))},onStopSubmit:()=>{},onUpdateScrollYOffset:s=>{e(ot(s))},onSelectSampleQuestion:()=>{},onBackClick:()=>{h(-1)},onCloseClick:()=>{const s=M(t.state?.pathnameStackToGoBack),l=s.poppedPathname??pt(1);h(l,{state:{...t.state,pathnameStackToGoBack:s.newStack}}),e(ee(""))},togglePageView:()=>{const s=M(t.state?.pathnameStackToGoBack),l=s.poppedPathname??`/${u.tenantEmailDomain}/dashboard`;h(l,{state:{...ae(t.state),pathnameStackToGoBack:s.newStack,message:"open_ai_cfo_drawer"}}),b(!0)},onCopy:()=>{},onThumbsUp:()=>{},onThumbsDown:()=>{},onTogglePageView:()=>{h(-1)},onNewChatClick:()=>{S!=null&&e(st());const s=qe(t.state?.pathnameStackToGoBack,t.pathname);h(`/${u.tenantEmailDomain}/ai-cfo/new_chat`,{state:{pathnameStackToGoBack:s.slice(0,-1),referrer:"Sidebar"}})},onToggleCotCollapsed:(s,l)=>{e(at({questionAnswerId:s,isCollapsed:l}))},onMenuClick:o.onMenuClick,...Ne(e,{isAiCardCreationEnabled:T,isCardPolicyEnabled:v,currentChatSessionId:S,onAfterCardsCreationSubmit:()=>{b(!0),h(`/${m}/cards`,{state:{...t.state}})},onAfterCardPolicySubmit:()=>{b(!0),h(`/${m}/cards/policy`,{state:{...t.state}})}})}})(Be(Re)),Ft=({isFileUploadEnabled:e})=>{const{setIsAiCfoOpen:o}=Te(),t=xe(),u=Pe(),a=we(),[h,S]=r.useState(!1),{allUsers:x,isAiCardCreationEnabled:T,isCardPolicyEnabled:v,onCardPolicyVendorSearchTextChange:b}=ve();r.useEffect(()=>{t(He())},[t]);const m=Z(i=>oe(i)),s=Ae.getSignedInUser(),{session_id:l}=ye(),d=Qe(),g=Fe(d),p=Z(i=>Ke(i)),n=m.uiState.currentChatSessionId,P=p.tenantEmailDomain,{handleUploadPromoClose:A,isUploadPromoVisible:ie}=_e({isFileUploadEnabled:e,tenantEmailDomain:P}),Q=Oe({currentTenant:p,currentChatSessionId:n,aiCfoView:m}),{isSuggestedQuestionsLoading:re,suggestedPromptQuestions:le}=mt(),w=a.state,y=w?.aiCfoInitialQuestion,$=!!w?.aiCfoShouldSubmit;r.useEffect(()=>{const i=a.state;if(i?.[J]!==!0)return;S(!0);const f={...i};delete f[J],u(a,{replace:!0,state:f})},[a.pathname,a.search,a.state,u]);const[de,_]=r.useState(null),[ce,O]=r.useState(!1),[ue,U]=r.useState(void 0),[me,j]=r.useState(void 0),G=r.useRef(!1);r.useEffect(()=>{if(!G.current&&y!=null&&y!==""){const i=a.state;_(y),O($),U(i?.aiCfoInitialSubmissionSource!=null?i.aiCfoInitialSubmissionSource:void 0);const f=i?.aiCfoSuggestionIndex;j(typeof f=="number"?f:void 0),G.current=!0}},[y,$,a.state]);const pe=r.useCallback(()=>{_(null),O(!1),U(void 0),j(void 0),u(a.pathname,{replace:!0,state:ae(a.state)})},[a.pathname,a.state,u]),N=r.useMemo(()=>new URLSearchParams(a.search),[a.search]),q=N.get("ref")??w?.aiCfoRef,L=N.get("emailRefId")??w?.aiCfoEmailRefId,W=r.useRef(!1);r.useEffect(()=>{W.current||q!=="month-end-email"||L==null||n!=null||s==null||(t(Xe("controller",s.userId,L,"MONTH_END_EMAIL")),W.current=!0)},[q,L,n,t,s]);const E=m.uiState.lastContextMessage;r.useEffect(()=>{E!=null&&E!==""&&n!=null&&(_(E),O(!0),U(void 0),j(void 0),t(Ye()))},[E,n,t]);const he=p.masterTOSInfo,C=he?.isMasterTOSAccepted??!1,{visitedSessions:z}=Ue(n),F=m.fetchState,D=m.uiState.chatSessionsNextPageToken.hasMore||!m.uiState.chatSessionsFirstPageFetched,H=n!=null?m.fetchChatSessionHistoryByChatSessionId?.[n]?.fetchState??"Not-Started":"Not-Started",K=n==null||(m.uiState.chatHistoryNextPageToken[n]?.hasMore??!0),X=m.allSessionsWithOrderedQuestionAnswers,{currentSessionQuestionAnswers:Se}=se(X,n),ge=Se.length===0;r.useEffect(()=>{C||g||u("../dashboard",{state:{...a.state,message:"open_ai_cfo_drawer"}})},[C,g,u,a.state]);const fe=r.useCallback(()=>{const i=M(a.state?.pathnameStackToGoBack),f=p.tenantEmailDomain;u(i.poppedPathname??(f!=null?`/${f}/dashboard`:".."),{state:{...a.state,pathnameStackToGoBack:i.newStack}})},[p.tenantEmailDomain,a.state,u]);r.useEffect(()=>{n!=null&&l!==n&&u(`../ai-cfo/${n}`,{state:{...a.state}})},[n,l]),r.useEffect(()=>{l!=null&&n==null&&l!=="new_chat"&&l!=="explore"&&t(Ze({sessionId:l,agentId:"controller"}))},[]);const Ce=r.useMemo(()=>({events:z.map(i=>`private-encrypted-chat-${i}.${ne}`),eventCallback:(i,f,ke)=>ke.onEventReceived(i,f)}),[z]);r.useEffect(()=>{F!=="In-Progress"&&D&&t(Je())},[F,D,t]),r.useEffect(()=>{n!=null&&H!=="In-Progress"&&K&&s!=null&&F==="Completed"&&!D&&t(et(n,s.userId))},[H,K,n,s,t]);const Y=i=>i.trackAICFOOnboardingScreenStateChanged("open","first_visit");if(s==null||l==null)throw Error("Can't access AI Controller page without signing in...");const be=n!=null&&m.responseStateByChatSessionId?.[n]?.answer?.fetchState==="In-Progress";if(!C&&g)return c.jsxs(gt,{children:[c.jsx(B,{analytics:I,onLoad:Y}),Q.drawerElement,c.jsx(ft,{children:c.jsx(te,{children:c.jsx(R,{isTOSAccepted:!1,acceptMasterTOSState:m.masterTOSAcceptanceState,onCloseClick:fe,onCompleteClick:()=>{p.userRoleId!=null&&t(V(p.userRoleId))}})})})]});const Ie=c.jsxs(c.Fragment,{children:[h&&!C?c.jsx(B,{analytics:I,onLoad:Y}):null,c.jsx(R,{isTOSAccepted:C,acceptMasterTOSState:m.masterTOSAcceptanceState,showHeader:!1,togglePageView:C?()=>S(!1):void 0,onCloseClick:()=>S(!1),onCompleteClick:()=>{C||p.userRoleId==null||t(V(p.userRoleId)),S(!1)}})]});return c.jsxs(c.Fragment,{children:[c.jsxs(St,{children:[c.jsx(B,{analytics:I,onLoad:i=>i.trackPageLoaded(De.Event.aiCFOPage)}),g&&Q.drawerElement,c.jsx(ht,{...Ce,currentChatSessionId:n,allSessionsWithOrderedQuestionAnswers:X,allUsers:x,isAiCardCreationEnabled:T,isCardPolicyEnabled:v,openOnboardingPage:()=>S(!0),userId:s.userId,setIsAiCfoOpen:o,navigate:u,sessionFromUrl:l,location:a,isSubmitting:be,isEmptyChatWithSession:ge,currentTenant:p,emailLinkQuestion:de??void 0,autoSubmitEmailLinkQuestion:ce,onEmailLinkQuestionProcessed:pe,routedInitialQuestionSource:ue,routedInitialQuestionSuggestionIndex:me,onCardPolicyVendorSearchTextChange:b,onMenuClick:g?Q.open:void 0,isFileUploadEnabled:e,isUploadPromoVisible:ie,onUploadPromoClose:A,exploreSuggestedPromptQuestions:le,exploreSuggestedPromptQuestionsLoading:re}),h&&g?c.jsx(dt,{anchor:"right",open:h,transitionDuration:250,PaperProps:{component:Ct,style:{width:"100%"}},slotProps:{backdrop:{style:{backgroundColor:"transparent",cursor:"pointer"}}},onClose:()=>S(!1),children:c.jsx(te,{onClick:i=>i.stopPropagation(),children:c.jsx(R,{isTOSAccepted:C,acceptMasterTOSState:m.masterTOSAcceptanceState,onCloseClick:()=>S(!1),onCompleteClick:()=>{C||p.userRoleId==null||t(V(p.userRoleId)),S(!1)}})})}):null]}),h&&!g?c.jsx(je,{open:h,onClose:()=>S(!1),children:c.jsx(Le,{children:Ie})}):null]})},te=k(ct)`
1
+ import{j as c}from"./liveblocks-BLlSTcoD.js";import{a as r}from"./sentry-D_xp3E3Q.js";import{u as xe,h as Pe,g as we,j as Z,i as ye,n as Ee}from"./core-CbpoBsNm.js";import{W as Te,d9 as ve,z as Ae,K as Qe,da as _e,db as Oe,b6 as J,dc as ae,dd as Ue,b5 as se,p as M,A as B,d as I,de as R,df as je,dg as Le,a1 as Fe,f as De,a7 as Be,dh as Re,di as Ve,a2 as Me,dj as $e,dk as Ge,dl as Ne,s as qe,b1 as We,dm as ze}from"./index-CoMuhThK.js";import{gj as He,eV as oe,eW as Ke,iu as Xe,Ts as Ye,fn as Ze,iE as Je,iA as et,eX as V,fu as tt,g4 as at,fZ as st,g1 as ee,g5 as ot,g6 as nt,g7 as it,g8 as rt,g9 as lt}from"./zeni-epic-state-CkeDRiud.js";import{D as dt,n as k,S as ct,P as ut}from"./mui-DcNGd9L2.js";import{u as mt}from"./useAiCfoDashboardSuggestedQuestionsChips-Bw1l6HHU.js";import{p as pt}from"./pathToGoBack-C2QnAeVh.js";import"./recharts-C0aThBg3.js";import"./analytics-CQmVOD4d.js";import"./plaid-B62punae.js";import"./dnd-CX5suNP6.js";import"./stripe-DMRn4zHo.js";import"./lottie-BY8e0Ufw.js";import"./lexical-BS7d_1CV.js";import"./pdf-BslZhgI8.js";import"./utils-BQO84dIV.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new e.Error().stack;o&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[o]="c1e0b77b-bf06-487d-aea0-21f3e2873e6a",e._sentryDebugIdIdentifier="sentry-dbid-c1e0b77b-bf06-487d-aea0-21f3e2873e6a")}catch{}})();const ne="chat-response-generated",ht=Ee(function(e,o){const t=oe(e),u=o.isSubmitting,a=t.uiState?.currentChatSessionId,h=a!=null?tt(e.aiCfoState,a):[],S=Ve(e,{allUsers:o.allUsers,onCardPolicyVendorSearchTextChange:o.onCardPolicyVendorSearchTextChange});return{showSampleQuestions:o.sessionFromUrl==="explore"&&t.uiState.currentChatSessionId==null,aiCfoView:t,isSubmitting:u,isNewChatSession:o.sessionFromUrl==="new_chat"||o.sessionFromUrl==="explore",isFullView:!0,tableDownloadEndPoint:`${Me}/tableDownload`,emailLinkQuestion:o.emailLinkQuestion,autoSubmitEmailLinkQuestion:o.autoSubmitEmailLinkQuestion,onEmailLinkQuestionProcessed:o.onEmailLinkQuestionProcessed,routedInitialQuestionSource:o.routedInitialQuestionSource,routedInitialQuestionSuggestionIndex:o.routedInitialQuestionSuggestionIndex,exploreSuggestedPromptQuestions:o.exploreSuggestedPromptQuestions,exploreSuggestedPromptQuestionsLoading:o.exploreSuggestedPromptQuestionsLoading,isFileUploadEnabled:o.isFileUploadEnabled,isUploadPromoVisible:o.isUploadPromoVisible,onUploadPromoClose:o.onUploadPromoClose,syntheticAnswers:h,resolveSyntheticAnswerCardTile:Ge(e),resolveSyntheticAnswerPolicyTile:$e(e),...S}},function(e,o){const{location:t,currentTenant:u,userId:a,navigate:h,currentChatSessionId:S,allSessionsWithOrderedQuestionAnswers:x,isAiCardCreationEnabled:T,isCardPolicyEnabled:v,setIsAiCfoOpen:b}=o,m=u.tenantEmailDomain;return{onEventReceived:(s,l)=>{if(s===ne&&typeof l.text=="string"&&typeof l.metadata=="object"){const d=l,g=nt(d.type),p=d.metadata.chat_session_id??null,{currentChatSession:n,currentQuestionAnswer:P,currentQuestionAnswerSummary:A}=se(x,p);g!=="answer"?I.trackAICFOChatResponseGenerated(g,P?.question.questionText??"",d.text,p,ze(A,n),d.metadata.message_id??null):I.trackAICFOChatAnswerGenerated(d.text,P?.question.questionText??"",(d.follow_up_questions?.length??0)>0,!!d.assumptions,!!d.insights,d.visualization!=null,it(d.visualization?.type??"")??null,p,d.summarized_title,d.metadata.message_id??null),e(rt({chatSessionId:d.metadata.chat_session_id,responseType:g,fetchState:{fetchState:"Completed",error:void 0}})),e(lt({chatSessionId:d.metadata.chat_session_id,answerPayload:d,userId:a}))}},onSubmit:(s,l,d,g)=>{s&&We(e,s,l,S,x,a,g,d)},updateCurrentInput:s=>{e(ee(s))},onStopSubmit:()=>{},onUpdateScrollYOffset:s=>{e(ot(s))},onSelectSampleQuestion:()=>{},onBackClick:()=>{h(-1)},onCloseClick:()=>{const s=M(t.state?.pathnameStackToGoBack),l=s.poppedPathname??pt(1);h(l,{state:{...t.state,pathnameStackToGoBack:s.newStack}}),e(ee(""))},togglePageView:()=>{const s=M(t.state?.pathnameStackToGoBack),l=s.poppedPathname??`/${u.tenantEmailDomain}/dashboard`;h(l,{state:{...ae(t.state),pathnameStackToGoBack:s.newStack,message:"open_ai_cfo_drawer"}}),b(!0)},onCopy:()=>{},onThumbsUp:()=>{},onThumbsDown:()=>{},onTogglePageView:()=>{h(-1)},onNewChatClick:()=>{S!=null&&e(st());const s=qe(t.state?.pathnameStackToGoBack,t.pathname);h(`/${u.tenantEmailDomain}/ai-cfo/new_chat`,{state:{pathnameStackToGoBack:s.slice(0,-1),referrer:"Sidebar"}})},onToggleCotCollapsed:(s,l)=>{e(at({questionAnswerId:s,isCollapsed:l}))},onMenuClick:o.onMenuClick,...Ne(e,{isAiCardCreationEnabled:T,isCardPolicyEnabled:v,currentChatSessionId:S,onAfterCardsCreationSubmit:()=>{b(!0),h(`/${m}/cards`,{state:{...t.state}})},onAfterCardPolicySubmit:()=>{b(!0),h(`/${m}/cards/policy`,{state:{...t.state}})}})}})(Be(Re)),Ft=({isFileUploadEnabled:e})=>{const{setIsAiCfoOpen:o}=Te(),t=xe(),u=Pe(),a=we(),[h,S]=r.useState(!1),{allUsers:x,isAiCardCreationEnabled:T,isCardPolicyEnabled:v,onCardPolicyVendorSearchTextChange:b}=ve();r.useEffect(()=>{t(He())},[t]);const m=Z(i=>oe(i)),s=Ae.getSignedInUser(),{session_id:l}=ye(),d=Qe(),g=Fe(d),p=Z(i=>Ke(i)),n=m.uiState.currentChatSessionId,P=p.tenantEmailDomain,{handleUploadPromoClose:A,isUploadPromoVisible:ie}=_e({isFileUploadEnabled:e,tenantEmailDomain:P}),Q=Oe({currentTenant:p,currentChatSessionId:n,aiCfoView:m}),{isSuggestedQuestionsLoading:re,suggestedPromptQuestions:le}=mt(),w=a.state,y=w?.aiCfoInitialQuestion,$=!!w?.aiCfoShouldSubmit;r.useEffect(()=>{const i=a.state;if(i?.[J]!==!0)return;S(!0);const f={...i};delete f[J],u(a,{replace:!0,state:f})},[a.pathname,a.search,a.state,u]);const[de,_]=r.useState(null),[ce,O]=r.useState(!1),[ue,U]=r.useState(void 0),[me,j]=r.useState(void 0),G=r.useRef(!1);r.useEffect(()=>{if(!G.current&&y!=null&&y!==""){const i=a.state;_(y),O($),U(i?.aiCfoInitialSubmissionSource!=null?i.aiCfoInitialSubmissionSource:void 0);const f=i?.aiCfoSuggestionIndex;j(typeof f=="number"?f:void 0),G.current=!0}},[y,$,a.state]);const pe=r.useCallback(()=>{_(null),O(!1),U(void 0),j(void 0),u(a.pathname,{replace:!0,state:ae(a.state)})},[a.pathname,a.state,u]),N=r.useMemo(()=>new URLSearchParams(a.search),[a.search]),q=N.get("ref")??w?.aiCfoRef,L=N.get("emailRefId")??w?.aiCfoEmailRefId,W=r.useRef(!1);r.useEffect(()=>{W.current||q!=="month-end-email"||L==null||n!=null||s==null||(t(Xe("controller",s.userId,L,"MONTH_END_EMAIL")),W.current=!0)},[q,L,n,t,s]);const E=m.uiState.lastContextMessage;r.useEffect(()=>{E!=null&&E!==""&&n!=null&&(_(E),O(!0),U(void 0),j(void 0),t(Ye()))},[E,n,t]);const he=p.masterTOSInfo,C=he?.isMasterTOSAccepted??!1,{visitedSessions:z}=Ue(n),F=m.fetchState,D=m.uiState.chatSessionsNextPageToken.hasMore||!m.uiState.chatSessionsFirstPageFetched,H=n!=null?m.fetchChatSessionHistoryByChatSessionId?.[n]?.fetchState??"Not-Started":"Not-Started",K=n==null||(m.uiState.chatHistoryNextPageToken[n]?.hasMore??!0),X=m.allSessionsWithOrderedQuestionAnswers,{currentSessionQuestionAnswers:Se}=se(X,n),ge=Se.length===0;r.useEffect(()=>{C||g||u("../dashboard",{state:{...a.state,message:"open_ai_cfo_drawer"}})},[C,g,u,a.state]);const fe=r.useCallback(()=>{const i=M(a.state?.pathnameStackToGoBack),f=p.tenantEmailDomain;u(i.poppedPathname??(f!=null?`/${f}/dashboard`:".."),{state:{...a.state,pathnameStackToGoBack:i.newStack}})},[p.tenantEmailDomain,a.state,u]);r.useEffect(()=>{n!=null&&l!==n&&u(`../ai-cfo/${n}`,{state:{...a.state}})},[n,l]),r.useEffect(()=>{l!=null&&n==null&&l!=="new_chat"&&l!=="explore"&&t(Ze({sessionId:l,agentId:"controller"}))},[]);const Ce=r.useMemo(()=>({events:z.map(i=>`private-encrypted-chat-${i}.${ne}`),eventCallback:(i,f,ke)=>ke.onEventReceived(i,f)}),[z]);r.useEffect(()=>{F!=="In-Progress"&&D&&t(Je())},[F,D,t]),r.useEffect(()=>{n!=null&&H!=="In-Progress"&&K&&s!=null&&F==="Completed"&&!D&&t(et(n,s.userId))},[H,K,n,s,t]);const Y=i=>i.trackAICFOOnboardingScreenStateChanged("open","first_visit");if(s==null||l==null)throw Error("Can't access AI Controller page without signing in...");const be=n!=null&&m.responseStateByChatSessionId?.[n]?.answer?.fetchState==="In-Progress";if(!C&&g)return c.jsxs(gt,{children:[c.jsx(B,{analytics:I,onLoad:Y}),Q.drawerElement,c.jsx(ft,{children:c.jsx(te,{children:c.jsx(R,{isTOSAccepted:!1,acceptMasterTOSState:m.masterTOSAcceptanceState,onCloseClick:fe,onCompleteClick:()=>{p.userRoleId!=null&&t(V(p.userRoleId))}})})})]});const Ie=c.jsxs(c.Fragment,{children:[h&&!C?c.jsx(B,{analytics:I,onLoad:Y}):null,c.jsx(R,{isTOSAccepted:C,acceptMasterTOSState:m.masterTOSAcceptanceState,showHeader:!1,togglePageView:C?()=>S(!1):void 0,onCloseClick:()=>S(!1),onCompleteClick:()=>{C||p.userRoleId==null||t(V(p.userRoleId)),S(!1)}})]});return c.jsxs(c.Fragment,{children:[c.jsxs(St,{children:[c.jsx(B,{analytics:I,onLoad:i=>i.trackPageLoaded(De.Event.aiCFOPage)}),g&&Q.drawerElement,c.jsx(ht,{...Ce,currentChatSessionId:n,allSessionsWithOrderedQuestionAnswers:X,allUsers:x,isAiCardCreationEnabled:T,isCardPolicyEnabled:v,openOnboardingPage:()=>S(!0),userId:s.userId,setIsAiCfoOpen:o,navigate:u,sessionFromUrl:l,location:a,isSubmitting:be,isEmptyChatWithSession:ge,currentTenant:p,emailLinkQuestion:de??void 0,autoSubmitEmailLinkQuestion:ce,onEmailLinkQuestionProcessed:pe,routedInitialQuestionSource:ue,routedInitialQuestionSuggestionIndex:me,onCardPolicyVendorSearchTextChange:b,onMenuClick:g?Q.open:void 0,isFileUploadEnabled:e,isUploadPromoVisible:ie,onUploadPromoClose:A,exploreSuggestedPromptQuestions:le,exploreSuggestedPromptQuestionsLoading:re}),h&&g?c.jsx(dt,{anchor:"right",open:h,transitionDuration:250,PaperProps:{component:Ct,style:{width:"100%"}},slotProps:{backdrop:{style:{backgroundColor:"transparent",cursor:"pointer"}}},onClose:()=>S(!1),children:c.jsx(te,{onClick:i=>i.stopPropagation(),children:c.jsx(R,{isTOSAccepted:C,acceptMasterTOSState:m.masterTOSAcceptanceState,onCloseClick:()=>S(!1),onCompleteClick:()=>{C||p.userRoleId==null||t(V(p.userRoleId)),S(!1)}})})}):null]}),h&&!g?c.jsx(je,{open:h,onClose:()=>S(!1),children:c.jsx(Le,{children:Ie})}):null]})},te=k(ct)`
2
2
  display: flex;
3
3
  min-height: 100%;
4
4
  flex-direction: column;
@@ -0,0 +1 @@
1
+ import{j as c}from"./liveblocks-BLlSTcoD.js";import{a as v}from"./sentry-D_xp3E3Q.js";import{h as U,g as B,u as j,j as y,N as z,n as k,i as W,o as te,p as x}from"./core-CbpoBsNm.js";import{eW as P,PD as A,Pj as h,zb as E,z3 as q,z7 as R,yY as K,Pl as J,zd as ae,y$ as Y,zg as G,zc as C}from"./zeni-epic-state-CkeDRiud.js";import{z as V,a7 as H,bI as oe,af as O,bz as M,bJ as le,m as Q,B as X,bK as pe,bL as se}from"./index-CoMuhThK.js";import"./mui-DcNGd9L2.js";import{u as Z,i as ne}from"./ReimbursementApprovalRuleDetailScreen-BTAascVp.js";import re from"./NotFoundScreen-DaDxz3Zq.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},p=new e.Error().stack;p&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[p]="0599711c-cc2d-4b5c-b8bd-9c7978a6044e",e._sentryDebugIdIdentifier="sentry-dbid-0599711c-cc2d-4b5c-b8bd-9c7978a6044e")}catch{}})();const T="bill-approval-rule-update",ie=k(function(e){return{approvalView:A(e),billPaySetupApproverViewUpdateData:h(e).billPaySetupApproverViewUpdateData}},function(e,p){const{navigate:t,location:o}=p;return{onApprovalRulesEventReceived:a=>{a.endsWith(T)&&e(J(!1))},onBackClick:()=>{O(o)?t("../../"):t("../../../bills/setup")},onDeleteRuleClick:a=>{e(K(a,!1))},onEditRuleClick:a=>{a!=null?(e(R(a)),t(`./${a}/edit`)):(e(R()),t("./new"))}}})(H(oe)),ce=({isLoading:e})=>{const p=U(),t=B(),o=j(),[a,r]=v.useState(!1),[n,d]=v.useState(!1),l=y(s=>s.billPaySetupApproverViewState.fetchState),u=y(s=>P(s)),i=y(s=>A(s)),f=y(s=>h(s).billPaySetupApproverViewUpdateData);if(v.useEffect(()=>{f?.updateStatus.fetchState==="Completed"&&o(E())},[f]),v.useEffect(()=>{a||l!=="Not-Started"||e||(r(!0),o(q(!0,!0,!1)))},[a,l,e,o]),V.getSignedInUser()==null)throw Error("Can't access billpay approval without signing in...");v.useEffect(()=>{i.allApprovalRules.length===0&&i.fetchState==="Completed"&&(n||(d(!0),o(R())),p("./new"))},[n,i,o]);const m={events:u.companyId!=null?[`private-encrypted-${u.companyId}.${T}`]:[],eventCallback:(s,w,S)=>{s.endsWith(T)&&S.onApprovalRulesEventReceived(s)}};return u?.companyBillPayInfo?.info?.isBillPayTOSAccepted===!1?c.jsx(z,{to:"../../promo"}):c.jsx(ie,{currentTenant:u,location:t,navigate:p,...m})},_="bill-approval-rule-update",ue=k(function(e){const p=A(e),t=h(e).billPaySetupApproverViewUpdateData,o={};for(const r of Object.values(e.vendorState.vendorByID))r?.id!=null&&(o[r.id]=r.name);const a={};for(const r of Object.values(e.classState.classesByKey))r?.classId!=null&&(a[r.classId]=r.className);return{approvalView:p,billPaySetupApproverViewUpdateData:t,vendorNamesById:o,departmentNamesById:a}},function(e,p){const{navigate:t,location:o}=p;return{onApprovalRulesEventReceived:a=>{a.endsWith(_)&&e(J(!1))},onBackClick:()=>{O(o)?t("../../"):t("../../../bills/setup")},onDeleteRuleClick:a=>{e(K(a,!0))},onEditRuleClick:a=>{a!=null?(e(R(a)),t(`./${a}/edit`)):(e(R()),t("./new"))},onReorderRules:a=>{e(ae(a,!0))}}})(H(le)),de=()=>{const e=y(o=>P(o)),{isApprovalRulesV3Enabled:p,isLoading:t}=M(e?.tenantId);return p?c.jsx(ve,{isLoading:t}):c.jsx(ce,{isLoading:t})},ve=({isLoading:e})=>{const p=U(),t=B(),o=j(),[a,r]=v.useState(!1),[n,d]=v.useState(!1),l=y(s=>s.billPaySetupApproverViewState.fetchState),u=y(s=>P(s));Z();const i=y(s=>A(s)),f=y(s=>h(s).billPaySetupApproverViewUpdateData);if(v.useEffect(()=>{f?.updateStatus.fetchState==="Completed"&&o(E())},[f]),v.useEffect(()=>{a||l!=="Not-Started"||e||(r(!0),o(q(!0,!0,!0)))},[a,l,e,o]),V.getSignedInUser()==null)throw Error("Can't access billpay approval without signing in...");v.useEffect(()=>{i.allApprovalRules.length===0&&i.fetchState==="Completed"&&(n||(d(!0),o(R())),p("./new"))},[n,i,o]);const m={events:u.companyId!=null?[`private-encrypted-${u.companyId}.${_}`]:[],eventCallback:(s,w,S)=>{s.endsWith(_)&&S.onApprovalRulesEventReceived(s)}};return u?.companyBillPayInfo?.info?.isBillPayTOSAccepted===!1?c.jsx(z,{to:"../../promo"}):c.jsx(ue,{currentTenant:u,location:t,navigate:p,isLoading:e,...m})},fe=k(function(e,p){const t=h(e),o=t.billPaySetupApproverViewUpdateData?.type??"approval_create",a=o==="approval_create"&&t.allApprovalRules.length!==0;let r=t.allApprovalRules.length===0;return p.approvalRuleId&&(r=t.allApprovalRules.findIndex(n=>n.approvalRuleId===p.approvalRuleId)===0),{localData:t,hideUpperBoundField:a,isLowerBoundDisabled:r,approvalUpdateActionType:o}},function(e,p){const{navigate:t,approvalUpdateDataView:o,approverViewData:a,approvalRuleId:r}=p,n=o.billPaySetupApproverViewUpdateData?.type,d=O(p.location);return{onApprovalRuleDataUpdated:l=>{const u=f=>{const m=[];return f.forEach(s=>{const w=s.actors.selectedUsers.map(b=>({type:"user",userId:b.userId,isImplicitActor:!1})),S=s.actors.selectedNonUsers.map(b=>{const I=!!ne(b.value);return{type:I?"attribute":"role",subType:b.value,userId:void 0,idType:void 0,isImplicitActor:!I}}),g=w.concat(S);m.push({action:s.stepType.selectedOption,actors:g,operator:g.length>1?s.stepType.selectedOption==="require_approval"?"or":"and":"is"})}),m},i={amount:{type:"amount",comparator:"range",min:{amount:l.lowerBound,currencyCode:"USD",currencySymbol:"$"},max:{amount:l.upperBound,currencyCode:"USD",currencySymbol:"$"}}};if(n==="approval_create"){const f={criteria:i,steps:u(l.steps),isApplicableOnPendingApprovalEntity:l.applyToExistingBills.includes("applyToExistingBills")};e(C(f))}else{const f={approvalRuleId:r,criteria:i,steps:u(l.steps),isApplicableOnPendingApprovalEntity:l.applyToExistingBills.includes("applyToExistingBills")};e(C(f))}},onResetClick:()=>{e(E()),n==="approval_update"||d?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onBackClick:()=>{e(E()),n==="approval_update"||d?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onSaveRuleClick:()=>{e(G(!1))},onSaveRuleSuccess:()=>{t("../")}}})(pe);function ye(){const e=U(),p=j(),t=B(),{approvalRuleId:o}=W(),a=V.getSignedInUser(),r=Q(),n=y(i=>h(i)),d=y(i=>A(i)),[l,u]=v.useState(!1);if(v.useEffect(()=>{l||(u(!0),p(Y(!0)))}),v.useEffect(()=>{d.fetchState==="Not-Started"&&e(o!=null?"../../":"../")},[d,o]),a==null)throw Error("Can't access address page without signing in...");return n.approverListFetchStatus.fetchState=="Not-Started"||n.approverListFetchStatus.fetchState==="In-Progress"?c.jsx(X,{fetchState:n.approverListFetchStatus.fetchState,style:{backgroundColor:r.colors.grey5}}):c.jsx(fe,{navigate:e,approvalUpdateDataView:n,approvalRuleId:o,approverViewData:d,location:t})}const ge=k(function(e,p){const t=h(e),o=t.billPaySetupApproverViewUpdateData?.type??"approval_create",a=[],r={};for(const n of Object.values(e.vendorState.vendorByID))n?.id!=null&&(a.push(n.id),r[n.id]=n.name);return{localData:t,approvalUpdateActionType:o,allVendorIds:a,vendorNamesById:r,editingRuleId:o==="approval_update"?p.approvalRuleId:void 0,allApprovalRulesWithUser:A(e).allApprovalRules}},function(e,p){const{navigate:t,approvalUpdateDataView:o,approverViewData:a,approvalRuleId:r}=p,n=o.billPaySetupApproverViewUpdateData?.type,d=O(p.location);return{onApprovalRuleDataUpdated:l=>{const u=g=>{const b=[];return g.forEach(I=>{const L=I.actorKind?.selectedOption,N=I.selectedRole?.selectedOption;let D=[];L==="role"&&N!=null?D=[{type:"attribute",subType:N,userId:void 0,idType:void 0,isImplicitActor:!1}]:L==="specific_person"&&(D=(I.persons?.selectedUsers??[]).map(ee=>({type:"user",userId:ee.userId,isImplicitActor:!1})));const F=I.action??"require_approval";b.push({action:F,actors:D,operator:D.length>1?F==="require_approval"?"or":"and":"is"})}),b},i=l.amountCriteria,f=l.vendorCriteria,m=l.departmentCriteria,s={};if(i!=null&&i.comparator.selectedOption!=null){const g=i.comparator.selectedOption;s.amount={type:"amount",comparator:g,min:g==="less_than"?void 0:i.min,max:g==="greater_than"?void 0:i.max}}const w=f?.selection.selectedOptions??[];w.length>0&&(s.vendor={type:"vendor",operator:f?.operator.selectedOption??"is",vendorIds:w});const S=m?.selection.selectedOptions??[];if(S.length>0&&(s.department={type:"department",operator:m?.operator.selectedOption??"is",departmentIds:S}),n==="approval_create"){const g={name:l.name,description:l.description,separationOfDuties:l.separationOfDuties,isFallback:l.isFallback,criteria:s,steps:u(l.steps),isApplicableOnPendingApprovalEntity:l.applyToExistingBills.includes("applyToExistingBills")};e(C(g))}else{const g={approvalRuleId:r,name:l.name,description:l.description,separationOfDuties:l.separationOfDuties,isFallback:l.isFallback,criteria:s,steps:u(l.steps),isApplicableOnPendingApprovalEntity:l.applyToExistingBills.includes("applyToExistingBills")};e(C(g))}},onResetClick:()=>{e(E()),n==="approval_update"||d?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onBackClick:()=>{e(E()),n==="approval_update"||d?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onSaveRuleClick:()=>{e(G(!0))},onSaveRuleSuccess:()=>{t("../")},onEditExistingRule:l=>{e(R(l)),t(n==="approval_update"?`../../${l}/edit`:`../${l}/edit`)}}})(se);function $(){const e=y(t=>P(t)),{isApprovalRulesV3Enabled:p}=M(e?.tenantId);return p?c.jsx(me,{}):c.jsx(ye,{})}function me(){const e=U(),p=j(),t=B(),{approvalRuleId:o}=W(),a=V.getSignedInUser(),r=Q(),n=y(i=>h(i)),d=y(i=>A(i)),[l,u]=v.useState(!1);if(Z(),v.useEffect(()=>{l||(u(!0),p(Y(!0)))}),v.useEffect(()=>{d.fetchState==="Not-Started"&&e(o!=null?"../../":"../")},[d,o]),a==null)throw Error("Can't access address page without signing in...");return n.approverListFetchStatus.fetchState=="Not-Started"||n.approverListFetchStatus.fetchState==="In-Progress"?c.jsx(X,{fetchState:n.approverListFetchStatus.fetchState,style:{backgroundColor:r.colors.grey5}}):c.jsx(ge,{navigate:e,approvalUpdateDataView:n,approvalRuleId:o,approverViewData:d,location:t},o??"new")}function De(){return c.jsxs(te,{children:[c.jsx(x,{path:"/",element:c.jsx(de,{})}),c.jsx(x,{path:"/new",element:c.jsx($,{})}),c.jsx(x,{path:"/:approvalRuleId/edit",element:c.jsx($,{})}),c.jsx(x,{path:"*",element:c.jsx(re,{})})]})}export{De as B};
@@ -1,4 +1,4 @@
1
- import{j as a}from"./liveblocks-B6jAIe9x.js";import{h as K,u as se,g as X,i as ae,j as v,N as te,n as Q,l as na,o as ia,p as y}from"./core-CLKYLs-8.js";import{eW as Z,OV as _e,bt as It,JS as oa,bo as wt,bJ as pe,OW as At,yt as Bt,zI as $e,z0 as la,bn as De,OX as sa,OY as ra,c7 as ca,OZ as da,kr as Ct,O_ as xt,O$ as Et,Ah as Ge,yI as Ce,P0 as ua,yh as tt,P1 as pa,Ee as ma,yl as ba,yr as Dt,P2 as ke,P3 as Me,zJ as Oe,P4 as ha,P5 as ga,zM as Ne,P6 as Sa,zZ as ya,P7 as Pt,zt as at,zy as fa,P8 as ka,P9 as ue,Pa as jt,Pb as Tt,Pc as Ft,gn as va,yN as Le,cB as Rt,Pd as Ia,fw as wa,Pe as Aa,Pf as Ba,fB as Vt,fz as $t,Pg as ze,Ph as Ca,Pi as xa,ME as Ze,Pj as Ea,MF as oe,MG as He,Pk as Da,Pl as Pa,Pm as ja,zA as nt,zx as Ta,Pn as Fa,Po as Ra,Pp as Va,zj as $a,Pq as La,Pr as Ua,Ps as _a,cp as Lt,cR as Ut,kC as Ga,bP as Ma,bq as _t,bQ as Gt,xz as Oa,Pt as Na,E1 as za,E7 as Za,tZ as Ha,zK as Wa,Ao as qa,kP as fe,Pu as Ja,Pv as Mt,lh as Ka,kJ as Ot,l2 as Nt,l1 as it,bE as be,bO as Xa,Pw as Qa,Px as ve,jm as Ya,Py as ot,Pz as en,jq as tn,jL as an,AC as nn,PA as on,la as ln,As as sn,PB as lt,Aw as rn,AB as cn,Ay as dn,Aq as un,PC as zt,yC as pn,PD as mn,PE as bn,gf as hn,ge as gn,gd as Sn,kS as yn,l8 as st,lj as fn,rx as kn,k$ as vn,Au as In,jw as wn,lo as An,PF as Bn,jo as Cn,ro as xn,PG as En,zp as Dn,bK as Pn,bs as jn,LA as Tn,cT as Fn,cS as Rn,cA as Vn,cH as $n}from"./zeni-epic-state-CjQblqOQ.js";import{m as me,z as V,j as Ie,_ as We,F as le,x as S,aN as xe,B as re,o as x,A as Pe,c as D,be as Ln,n as z,a2 as qe,r as E,K as we,bf as rt,bg as ct,bh as Un,ak as _n,I as Gn,aH as Mn,E as Zt,D as Je,N as Ke,bi as On,at as Ht,bj as Nn,X as zn,e as Wt,a7 as Zn,bk as Hn,bl as Wn,bm as qn,bn as Jn,bo as Kn,bp as Xn,bq as Qn,br as Yn,bs as ei,w as ti,bt as ai,b9 as ni,bu as ii,bv as oi,a9 as li}from"./index-D_hiFYsE.js";import{n as U,S as si}from"./mui-AZmtqUsi.js";import{A as dt}from"./AddressScreen-BRdhnUB3.js";import{g as ie,a as je,i as qt,V as Xe,b as Qe,c as ri,v as ci,d as di,A as he,D as ge}from"./DomesticWireDetailScreen-Dwlu904z.js";import{a as f}from"./sentry-95bdnR3R.js";import{u as Ye}from"./useAskAiCfoHostNavButtonProps-FETbJUjN.js";import{u as Jt}from"./useInitialThreadRequest-D1F5GLCG.js";import Ee from"./NotFoundScreen-ChEBjJeL.js";import{D as ui}from"./DrawerScreen-KqrF4Sq7.js";import{M as Kt}from"./MobileAppDrawer-BPYh3fz7.js";import{F as Xt}from"./FeaturePreviewScreen-CNGfajWs.js";import{S as Te}from"./SetupPagesScreen-Bfb-yG5Q.js";import{B as pi}from"./BillPayApprovalRoutes-BrRYqqLJ.js";import{FallBackRoute as mi}from"./ScreenRoutes-BE5zmBx7.js";import"./recharts-CyaYjFwn.js";import"./analytics-BHHyMpuV.js";import"./plaid-2Q72y6JT.js";import"./dnd-BgEYAbRi.js";import"./stripe-DMRn4zHo.js";import"./lottie-C38Bn-X6.js";import"./lexical-DN4b_Twn.js";import"./pdf-BzNDzZ8_.js";import"./utils-CDpOkGne.js";import"./analyticsHelper-BsjRdUZX.js";import"./routePaths-XSngD1ow.js";import"./BusinessVerificationPageScreen-CoxJBcce.js";import"./ReimbursementApprovalRuleDetailScreen-D_Tk1V_u.js";import"./getLocaleForTenant-C_VQis3o.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="43b28e90-f4ec-4e73-85a2-a1dde5a5416e",e._sentryDebugIdIdentifier="sentry-dbid-43b28e90-f4ec-4e73-85a2-a1dde5a5416e")}catch{}})();const bi=Q(function(e,t){const l=_e(e,t.billId),n=V.getSignedInUser(),c=e.tenantState.currentTenantId,r={userId:n?.userId??"",sessionId:n?.zeniSessionId??"",tenantId:c??""},u=z(t.location.state?.pathnameStackToGoBack);let o=!0;u.poppedPathname?.includes("bills")===!0&&(o=!1);let s=`${l.createdBy?.firstName??"Zeni"} ${l.createdBy?.lastName??""}`;const i=De(n);i||!l.createdBy?.email?.includes("zeni.ai")||(s="Zeni");let d=!1,p=!1;if(l?.billActivities.length>0){const{isApprovalorRejectBtnVisible:g,isMarkAsPaidBtnVisible:b}=sa(l.billActivities,ra(t.currentTenant),n);d=g,p=b}const m=ca(t.currentTenant?.userRole??[]),h=l.transactionDetails!=null&&da(l.transactionDetails,m,n);return{billDetails:l,isAccountingClassesEnabled:Ct(e),createdBy:s,authParams:r,transactionAttachmentEndpoint:`${qe}/transaction_attachment`,signedInUser:n,showBackButton:o,isAdmin:m,isRealTimeApprovalEnabled:t.isRealTimeApprovalEnabled,showApproveRejectBtns:d,showMarkAsPaidButtonToApprover:p,hasZeniAssistAccess:t.hasZeniAssistAccess,analytics:D,showMarkAsPaidButtonToCreator:h,isZeniUser:i}},function(e,t){const{billId:l,currentTenant:n,location:c,navigate:r}=t,{tenantEmailDomain:u}=n;return{redirectToBillsScreen:()=>{const o=ie(u),s=E(c.state?.pathnameStackToGoBack,c.pathname);r(o,{state:{pathnameStackToGoBack:s}})},redirectToEditableBillScreen:()=>{const o=E(c.state?.pathnameStackToGoBack,c.pathname);r("./edit",{state:{pathnameStackToGoBack:o}})},discardBillDetailsFromLocalStore:()=>{e(ke({}))},deleteBill:o=>{D.trackBillPayDeleteBill(l,o),e(Dt(l))},cancelAndDeleteBill:(o,s)=>{s===!0?D.trackBillPayCancelAndDeleteBill(l,o):D.trackBillPayCancelBill(l),e(ba(l,s))},onSaveRealTimeApprovals:o=>{e(ma(l,"bill_pay",o))},updateEditRealTimeApproverClicked:o=>{e(pa({isEdit:o,entityId:l,entityType:"bill_pay"}))},approveOrRejectBill:o=>{o.type==="approved"?e(tt(l,o.type,"")):e(tt(l,o.type,o.description??""))},retryOrRefundBill:o=>{o.type==="retry"?e(Ce(l,"retry")):e(Ce(l,"refund"))},onAddNewRule:()=>{r("../../bills/approval-rules")},onAttachmentClick:(o,s)=>{const i=je(u,o,s),d=E(c.state?.pathnameStackToGoBack,c.pathname);r(i,{state:{pathnameStackToGoBack:d}})},onBackClick:()=>{const o=z(t.location.state?.pathnameStackToGoBack),s=o.poppedPathname??ie(u);r(s,{state:{pathnameStackToGoBack:o.newStack}})},onRetryPaymentClick:()=>{const o=E(c.state?.pathnameStackToGoBack,c.pathname);r("./edit",{state:{pathnameStackToGoBack:o}}),e(ua({billId:t.billId}))},onRefundPaymentClick:()=>{e(Ce(t.billId,"refund"))},saveBillDetails:(o,s,i)=>{o&&e(Et({data:i,billId:l})),e(Ge(o?"paid":"pending_approval",o,s,l))},discardOutsideZeniPaymentData:()=>{e(xt({billId:l}))}}})(Ln);function hi(){const e=K(),t=se(),l=X(),{billId:n}=ae(),c=me(),r=V.getSignedInUser(),u=Ie(),o=v(O=>Z(O)),s=v(O=>_e(O,n??"")),i=s.transactionDetails?.billPayInfo.stage.code==="draft"&&s.transactionDetails.isDeleted===!1,d=Jt(o?.companyId,{clearParams:s.fetchState==="Completed"&&!i}),{isAiCfoAccessEnabled:p,onAskAiCfoClick:m}=Ye({mobileExploreReferrer:"Bill Details"});We({isDataReady:s.fetchState==="Completed"});const h=o?.userRole!=null&&It(o?.userRole),g=o?.company==null||o.company.featuresActivationInfo?.isBillPayFeatureEnabled&&!h,[b,k]=f.useState(!1),[P,A]=f.useState(!1),[B,G]=f.useState(!1),{useFeatureGate:j,useDynamicConfig:_}=le(),{isFeatureEnabled:$}=j(S.isShowDeletedBillsFeatureEnabled),{isFeatureEnabled:I}=j(S.isBillPayCommentingEnabled),{isFeatureEnabled:H}=j(S.isBillPayDetectInsufficientFundsEnabled),{configValue:M}=_(xe.zeniAssistConfig),C=oa(o),q=wt(o.userRole),W=g&&pe(u?.loggedInUserRoleMap),L=M.user_ids!=null&&r?.userId!=null&&M.user_ids.includes(r?.userId),{isFeatureEnabled:J}=j(S.isInternationalPaymentShaVsOurFeatureEnabled),{isFeatureEnabled:Y}=j(S.billPaySetupShowInternationalPaymentByWise);if(f.useEffect(()=>{$&&s.transactionDetails?.isDeleted===!0||o.isZeni===!0&&r?.userEmailDomain==="zeni.ai"&&C===!1?G(!1):G(s.billActivities[0]?.isRealTimeApprovalEnabled&&(q||W||s.allApprovers.find(O=>O.user.userId===r?.userId)!=null||s.transactionDetails?.lastUpdatedByUserId===r?.userId))},[s.billActivities[0]?.isRealTimeApprovalEnabled,s.allApprovers,s.transactionDetails?.lastUpdatedByUserId,q,W,o.isZeni,C,r]),f.useEffect(()=>{n!=null&&t(At(n))},[n]),f.useEffect(()=>{b||s.fetchState=="Completed"||s.fetchState=="In-Progress"||(k(!0),t(Bt(n??"",$,L,!1)))},[b,s,n,t]),f.useEffect(()=>{P||s.fetchState!="Completed"||s.transactionDetails?.billPayInfo.stage.code=="paid"||(A(!0),t($e(!1,$,L,Y,n)),s.billActivities[0]?.isRealTimeApprovalEnabled===!0&&t(la()))},[P,s,n,t]),r==null)throw Error("Can't access address page without signing in...");return s.transactionDetails?.billPayInfo.stage.code==="draft"&&s.transactionDetails.isDeleted===!1?a.jsx(te,{to:`./edit${l.search}`}):s.deleteStatus.fetchState==="In-Progress"||s.cancelAndDeleteStatus.fetchState==="In-Progress"||s.cancelStatus.fetchState==="In-Progress"?a.jsx(re,{fetchState:s.deleteStatus.fetchState,style:{boxShadow:`0px 2px ${x.sp1} ${c.colors.dropShadowNormal}`}}):a.jsxs(a.Fragment,{children:[a.jsx(Pe,{analytics:D,onLoad:O=>(ee=>{n!=null&&ee.trackBillPayBillDetails(n,s.isRecurring)})(O)}),a.jsx(bi,{initialOpenThreadRequest:d??void 0,isShowDeletedBillsEnabled:$,location:l,navigate:e,isBillPayCommentingEnabled:I,isRealTimeApprovalEnabled:B,currentTenant:o,billId:n??"",isInternationalPaymentShaVsOurEnabled:J,hasZeniAssistAccess:L,isDetectInsufficientFundsEnabled:H,isAiCfoAccessEnabled:p,onAskAiCfoClick:m})]})}const Se=Je.getLocalizedStrings().spendManagement.billPay.billDetails,gi={containerWidth:new Zt(100,58)},ut=Q(function(e,t){const l=V.getSignedInUser(),n=e.tenantState.currentTenantId,c={userId:l?.userId??"",sessionId:l?.zeniSessionId??"",tenantId:n??""},r=t.showActionButtons,u=r&&t.file==null;return{uploadInvoiceEndPoint:`${Ht.communicationAgentMicroServiceBaseUrl}`,authParams:c,billId:t.billId,file:t.file,showAutofill:t.showAutofill,analytics:D,entityId:t.billId,showTitlebarIcon:r,showTitlebar:r&&t?.file!=null,uploadStatus:t.uploadStatus,shouldNotShowAttachment:u,style:{paddingTop:x.sp10,paddingRight:x.sp3,paddingBottom:"15px",paddingLeft:x.sp5,...t.showAutofill?{}:{backgroundColor:t.backgroundColor,paddingBottom:"128px"}}}},function(e,t){const l=V.getSignedInUser();return{onInvoiceUpload:n=>{n!=null&&(t.file!=null||t.billId!=null||t.isInitialEdit?(t.setPayload(n),t.setShowConfirmationPopup(!0)):e(Ne(n,t.isVendorRecommendationEnabled,t.billId)))},updateInvoiceUploadFetchState:n=>{e(ya({fetchState:{fetchState:n,error:void 0},billId:t.billId}))},onSkipAutofill:n=>{D?.trackBillPaySkipAutofill(),e(Oe(n))},onDeleteClick:()=>{e(Sa({billId:t.billId})),D?.trackInvoiceActionClick(t.billStage??"","delete",l?.userEmail??"",null)}}})(Mn);function w({appContent:e}){const t=se(),l=K(),{billId:n}=ae(),c=X(),r=c.pathname,u=r.includes("bill/new")||r.includes("/edit"),o=we(),s=me(),i=V.getSignedInUser(),{useFeatureGate:d,useDynamicConfig:p}=le(),{isFeatureEnabled:m}=d(S.isVendorRecommendationFeatureEnabled),{isFeatureEnabled:h}=d(S.isShowDeletedBillsFeatureEnabled),{isFeatureEnabled:g}=d(S.isDepositAccountsFeatureEnabled),{isFeatureEnabled:b}=d(S.billPaySetupShowInternationalPaymentByWise),{configValue:k}=p(xe.zeniAssistConfig),P=k.user_ids!=null&&i?.userId!=null&&k.user_ids.includes(i?.userId),A=v(F=>Z(F)),[B,G]=f.useState(!1),[j,_]=f.useState(!1),[$,I]=f.useState(!1),[H,M]=f.useState(),C=v(F=>Me(F,m,g,n));let q=C.fetchState,W=C.file,L=C.showAutofill;const J=v(F=>_e(F,n??""));u===!1&&(q=J.fetchState,W=J.transactionDetails?.attachments?.[0],L=!1);const Y=C.billPayInfo!=null&&C.billPayInfo.stage.code==="pending_approval"?C.billPayInfo.billStatus.code:C.billStage;f.useEffect(()=>{n==null&&t(Oe(!0))},[n,t]),f.useEffect(()=>{q==="Not-Started"&&(u&&j?_(!1):!u&&B&&G(!1))},[n]),f.useEffect(()=>{B||n==null||u||(G(!0),t(Bt(n,h,P,!1)),j||(_(!0),t($e(!1,h,P,b,n)))),u&&!j&&(_(!0),t($e(!1,h,P,b,n)))},[B,j,u,n,t]);const O={onOkClick:()=>{if(I(!1),!H)return;const F=W!=null?"replace":"upload";D?.trackInvoiceActionClick(Y??"",F,i?.userEmail??"","yes"),t(ga({replaceBillData:!0,billId:n})),t(Ne(H,m,n))},onCancelClick:()=>{if(I(!1),!H)return;const F=W!=null?"replace":"upload";D?.trackInvoiceActionClick(Y??"",F,i?.userEmail??"","no"),t(ha({file:H,billId:n}))}},ee=f.useCallback(()=>{const F=z(c.state?.pathnameStackToGoBack),ce=F.poppedPathname??ie(A.tenantEmailDomain);t(ke({billId:n})),l(ce,{state:{pathnameStackToGoBack:F.newStack}})},[c.state,A.tenantEmailDomain,n,t,l]);if(i==null)throw Error("Can't access address page without signing in...");if(q==="Error"||J.fetchState==="Error")return a.jsx(Ee,{});if(q!="Completed")return n==null&&o!=="small"?a.jsx(rt,{fallback:ee,children:a.jsxs(Fe,{windowSize:o,children:[a.jsx(mt,{}),a.jsx(Re,{}),a.jsx(ut,{backgroundColor:s.colors.grey4,billId:n,file:W,showAutofill:!0,uploadStatus:C.uploadStatus,isVendorRecommendationEnabled:m,attachmentTitle:void 0,setShowConfirmationPopup:I,setPayload:M,showActionButtons:!1,isInitialEdit:!!C.isInitialEdit,billStage:Y}),a.jsx(Ve,{windowSize:o,children:a.jsx(ct,{isNewBill:!0})})]})}):a.jsxs(Fe,{windowSize:o,children:[o==="small"||L?null:a.jsx(pt,{children:a.jsx(Qt,{onClick:ee,"data-testid":"nav-bar-back-click"})}),o!=="small"?a.jsx(Re,{}):null,a.jsx(Un,{}),a.jsx(Ve,{windowSize:o,children:a.jsx(ct,{isNewBill:n==null})})]});{const F=C.billPayInfo!=null&&C.billPayInfo.stage.code==="pending_approval"?C.billPayInfo.billStatus.code:C.billStage;return a.jsx(rt,{fallback:ee,children:a.jsxs(Fe,{windowSize:o,children:[L&&o!=="small"?a.jsx(mt,{}):null,$?a.jsx(_n,{titleComponent:a.jsx(wi,{children:Se.overwriteTitle}),descriptionComponent:a.jsx(Ai,{children:Se.overwriteDescription}),primaryButtonText:Se.buttons.yes,secondaryButtonText:Se.buttons.no,action:O,isEditPopup:!0}):null,o==="small"||L?null:a.jsx(pt,{children:a.jsx(Si,{})}),o!=="small"?a.jsx(Re,{}):null,a.jsx(ut,{backgroundColor:s.colors.grey4,billId:n,file:W,showAutofill:L,uploadStatus:C.uploadStatus,isVendorRecommendationEnabled:m,attachmentTitle:yi(u,J,C),setShowConfirmationPopup:I,setPayload:M,showActionButtons:fi(u,C),isInitialEdit:!!C.isInitialEdit,billStage:F}),a.jsx(Ve,{windowSize:o,children:e})]})})}}function Si(){const{triggerBack:e}=On();return a.jsx(Qt,{onClick:e,"data-testid":"nav-bar-back-click"})}function yi(e,t,l){let n,c;return e?(n=l.recurringConfig?.currentInstance,c=l.recurringConfig?.totalPaymentCycles):(n=t.transactionDetails?.recurringBillInstance,c=t.recurringBillConfigDetail?.totalPaymentCycles),t?.isRecurring===!0?a.jsxs(ki,{children:[a.jsx(vi,{children:`${Se.recurringBill.recurringCycle}
1
+ import{j as a}from"./liveblocks-BLlSTcoD.js";import{h as K,u as se,g as X,i as ae,j as v,N as te,n as Q,l as na,o as ia,p as y}from"./core-CbpoBsNm.js";import{eW as Z,OV as _e,bt as It,JS as oa,bo as wt,bJ as pe,OW as At,yt as Bt,zI as $e,z0 as la,bn as De,OX as sa,OY as ra,c7 as ca,OZ as da,kr as Ct,O_ as xt,O$ as Et,Ah as Ge,yI as Ce,P0 as ua,yh as tt,P1 as pa,Ee as ma,yl as ba,yr as Dt,P2 as ke,P3 as Me,zJ as Oe,P4 as ha,P5 as ga,zM as Ne,P6 as Sa,zZ as ya,P7 as Pt,zt as at,zy as fa,P8 as ka,P9 as ue,Pa as jt,Pb as Tt,Pc as Ft,gn as va,yN as Le,cB as Rt,Pd as Ia,fw as wa,Pe as Aa,Pf as Ba,fB as Vt,fz as $t,Pg as ze,Ph as Ca,Pi as xa,ME as Ze,Pj as Ea,MF as oe,MG as He,Pk as Da,Pl as Pa,Pm as ja,zA as nt,zx as Ta,Pn as Fa,Po as Ra,Pp as Va,zj as $a,Pq as La,Pr as Ua,Ps as _a,cp as Lt,cR as Ut,kC as Ga,bP as Ma,bq as _t,bQ as Gt,xz as Oa,Pt as Na,E1 as za,E7 as Za,tZ as Ha,zK as Wa,Ao as qa,kP as fe,Pu as Ja,Pv as Mt,lh as Ka,kJ as Ot,l2 as Nt,l1 as it,bE as be,bO as Xa,Pw as Qa,Px as ve,jm as Ya,Py as ot,Pz as en,jq as tn,jL as an,AC as nn,PA as on,la as ln,As as sn,PB as lt,Aw as rn,AB as cn,Ay as dn,Aq as un,PC as zt,yC as pn,PD as mn,PE as bn,gf as hn,ge as gn,gd as Sn,kS as yn,l8 as st,lj as fn,rx as kn,k$ as vn,Au as In,jw as wn,lo as An,PF as Bn,jo as Cn,ro as xn,PG as En,zp as Dn,bK as Pn,bs as jn,LA as Tn,cT as Fn,cS as Rn,cA as Vn,cH as $n}from"./zeni-epic-state-CkeDRiud.js";import{m as me,z as V,j as Ie,_ as We,F as le,x as S,aN as xe,B as re,o as x,A as Pe,d as D,be as Ln,p as z,a2 as qe,s as E,K as we,bf as rt,bg as ct,bh as Un,ak as _n,I as Gn,aH as Mn,G as Zt,D as Je,J as Ke,bi as On,at as Ht,bj as Nn,X as zn,f as Wt,a7 as Zn,bk as Hn,bl as Wn,bm as qn,bn as Jn,bo as Kn,bp as Xn,bq as Qn,br as Yn,bs as ei,w as ti,bt as ai,b9 as ni,bu as ii,bv as oi,a9 as li}from"./index-CoMuhThK.js";import{n as U,S as si}from"./mui-DcNGd9L2.js";import{A as dt}from"./AddressScreen-kHZ3pkiE.js";import{g as ie,a as je,i as qt,V as Xe,b as Qe,c as ri,v as ci,d as di,A as he,D as ge}from"./DomesticWireDetailScreen-BqVZ4JA4.js";import{a as f}from"./sentry-D_xp3E3Q.js";import{u as Ye}from"./useAskAiCfoHostNavButtonProps-Dkub9Q1g.js";import{u as Jt}from"./useInitialThreadRequest-DKCJ4fRp.js";import Ee from"./NotFoundScreen-DaDxz3Zq.js";import{D as ui}from"./DrawerScreen-CuqanTdv.js";import{M as Kt}from"./MobileAppDrawer-DSwbMXYq.js";import{F as Xt}from"./FeaturePreviewScreen-DruJFyVL.js";import{S as Te}from"./SetupPagesScreen-Cl6654uo.js";import{B as pi}from"./BillPayApprovalRoutes-CIS2PKjh.js";import{FallBackRoute as mi}from"./ScreenRoutes-CFaDbJ8O.js";import"./recharts-C0aThBg3.js";import"./analytics-CQmVOD4d.js";import"./plaid-B62punae.js";import"./dnd-CX5suNP6.js";import"./stripe-DMRn4zHo.js";import"./lottie-BY8e0Ufw.js";import"./lexical-BS7d_1CV.js";import"./pdf-BslZhgI8.js";import"./utils-BQO84dIV.js";import"./analyticsHelper-BcD2hj7Q.js";import"./routePaths-BqMV9loV.js";import"./BusinessVerificationPageScreen-Ds_dEqcf.js";import"./ReimbursementApprovalRuleDetailScreen-BTAascVp.js";import"./getLocaleForTenant-DvFF548D.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="96187d5a-f7dd-481a-a1bc-69b9b8e863e4",e._sentryDebugIdIdentifier="sentry-dbid-96187d5a-f7dd-481a-a1bc-69b9b8e863e4")}catch{}})();const bi=Q(function(e,t){const l=_e(e,t.billId),n=V.getSignedInUser(),c=e.tenantState.currentTenantId,r={userId:n?.userId??"",sessionId:n?.zeniSessionId??"",tenantId:c??""},u=z(t.location.state?.pathnameStackToGoBack);let o=!0;u.poppedPathname?.includes("bills")===!0&&(o=!1);let s=`${l.createdBy?.firstName??"Zeni"} ${l.createdBy?.lastName??""}`;const i=De(n);i||!l.createdBy?.email?.includes("zeni.ai")||(s="Zeni");let d=!1,p=!1;if(l?.billActivities.length>0){const{isApprovalorRejectBtnVisible:g,isMarkAsPaidBtnVisible:b}=sa(l.billActivities,ra(t.currentTenant),n);d=g,p=b}const m=ca(t.currentTenant?.userRole??[]),h=l.transactionDetails!=null&&da(l.transactionDetails,m,n);return{billDetails:l,isAccountingClassesEnabled:Ct(e),createdBy:s,authParams:r,transactionAttachmentEndpoint:`${qe}/transaction_attachment`,signedInUser:n,showBackButton:o,isAdmin:m,isRealTimeApprovalEnabled:t.isRealTimeApprovalEnabled,showApproveRejectBtns:d,showMarkAsPaidButtonToApprover:p,hasZeniAssistAccess:t.hasZeniAssistAccess,analytics:D,showMarkAsPaidButtonToCreator:h,isZeniUser:i}},function(e,t){const{billId:l,currentTenant:n,location:c,navigate:r}=t,{tenantEmailDomain:u}=n;return{redirectToBillsScreen:()=>{const o=ie(u),s=E(c.state?.pathnameStackToGoBack,c.pathname);r(o,{state:{pathnameStackToGoBack:s}})},redirectToEditableBillScreen:()=>{const o=E(c.state?.pathnameStackToGoBack,c.pathname);r("./edit",{state:{pathnameStackToGoBack:o}})},discardBillDetailsFromLocalStore:()=>{e(ke({}))},deleteBill:o=>{D.trackBillPayDeleteBill(l,o),e(Dt(l))},cancelAndDeleteBill:(o,s)=>{s===!0?D.trackBillPayCancelAndDeleteBill(l,o):D.trackBillPayCancelBill(l),e(ba(l,s))},onSaveRealTimeApprovals:o=>{e(ma(l,"bill_pay",o))},updateEditRealTimeApproverClicked:o=>{e(pa({isEdit:o,entityId:l,entityType:"bill_pay"}))},approveOrRejectBill:o=>{o.type==="approved"?e(tt(l,o.type,"")):e(tt(l,o.type,o.description??""))},retryOrRefundBill:o=>{o.type==="retry"?e(Ce(l,"retry")):e(Ce(l,"refund"))},onAddNewRule:()=>{r("../../bills/approval-rules")},onAttachmentClick:(o,s)=>{const i=je(u,o,s),d=E(c.state?.pathnameStackToGoBack,c.pathname);r(i,{state:{pathnameStackToGoBack:d}})},onBackClick:()=>{const o=z(t.location.state?.pathnameStackToGoBack),s=o.poppedPathname??ie(u);r(s,{state:{pathnameStackToGoBack:o.newStack}})},onRetryPaymentClick:()=>{const o=E(c.state?.pathnameStackToGoBack,c.pathname);r("./edit",{state:{pathnameStackToGoBack:o}}),e(ua({billId:t.billId}))},onRefundPaymentClick:()=>{e(Ce(t.billId,"refund"))},saveBillDetails:(o,s,i)=>{o&&e(Et({data:i,billId:l})),e(Ge(o?"paid":"pending_approval",o,s,l))},discardOutsideZeniPaymentData:()=>{e(xt({billId:l}))}}})(Ln);function hi(){const e=K(),t=se(),l=X(),{billId:n}=ae(),c=me(),r=V.getSignedInUser(),u=Ie(),o=v(O=>Z(O)),s=v(O=>_e(O,n??"")),i=s.transactionDetails?.billPayInfo.stage.code==="draft"&&s.transactionDetails.isDeleted===!1,d=Jt(o?.companyId,{clearParams:s.fetchState==="Completed"&&!i}),{isAiCfoAccessEnabled:p,onAskAiCfoClick:m}=Ye({mobileExploreReferrer:"Bill Details"});We({isDataReady:s.fetchState==="Completed"});const h=o?.userRole!=null&&It(o?.userRole),g=o?.company==null||o.company.featuresActivationInfo?.isBillPayFeatureEnabled&&!h,[b,k]=f.useState(!1),[P,A]=f.useState(!1),[B,G]=f.useState(!1),{useFeatureGate:j,useDynamicConfig:_}=le(),{isFeatureEnabled:$}=j(S.isShowDeletedBillsFeatureEnabled),{isFeatureEnabled:I}=j(S.isBillPayCommentingEnabled),{isFeatureEnabled:H}=j(S.isBillPayDetectInsufficientFundsEnabled),{configValue:M}=_(xe.zeniAssistConfig),C=oa(o),q=wt(o.userRole),W=g&&pe(u?.loggedInUserRoleMap),L=M.user_ids!=null&&r?.userId!=null&&M.user_ids.includes(r?.userId),{isFeatureEnabled:J}=j(S.isInternationalPaymentShaVsOurFeatureEnabled),{isFeatureEnabled:Y}=j(S.billPaySetupShowInternationalPaymentByWise);if(f.useEffect(()=>{$&&s.transactionDetails?.isDeleted===!0||o.isZeni===!0&&r?.userEmailDomain==="zeni.ai"&&C===!1?G(!1):G(s.billActivities[0]?.isRealTimeApprovalEnabled&&(q||W||s.allApprovers.find(O=>O.user.userId===r?.userId)!=null||s.transactionDetails?.lastUpdatedByUserId===r?.userId))},[s.billActivities[0]?.isRealTimeApprovalEnabled,s.allApprovers,s.transactionDetails?.lastUpdatedByUserId,q,W,o.isZeni,C,r]),f.useEffect(()=>{n!=null&&t(At(n))},[n]),f.useEffect(()=>{b||s.fetchState=="Completed"||s.fetchState=="In-Progress"||(k(!0),t(Bt(n??"",$,L,!1)))},[b,s,n,t]),f.useEffect(()=>{P||s.fetchState!="Completed"||s.transactionDetails?.billPayInfo.stage.code=="paid"||(A(!0),t($e(!1,$,L,Y,n)),s.billActivities[0]?.isRealTimeApprovalEnabled===!0&&t(la()))},[P,s,n,t]),r==null)throw Error("Can't access address page without signing in...");return s.transactionDetails?.billPayInfo.stage.code==="draft"&&s.transactionDetails.isDeleted===!1?a.jsx(te,{to:`./edit${l.search}`}):s.deleteStatus.fetchState==="In-Progress"||s.cancelAndDeleteStatus.fetchState==="In-Progress"||s.cancelStatus.fetchState==="In-Progress"?a.jsx(re,{fetchState:s.deleteStatus.fetchState,style:{boxShadow:`0px 2px ${x.sp1} ${c.colors.dropShadowNormal}`}}):a.jsxs(a.Fragment,{children:[a.jsx(Pe,{analytics:D,onLoad:O=>(ee=>{n!=null&&ee.trackBillPayBillDetails(n,s.isRecurring)})(O)}),a.jsx(bi,{initialOpenThreadRequest:d??void 0,isShowDeletedBillsEnabled:$,location:l,navigate:e,isBillPayCommentingEnabled:I,isRealTimeApprovalEnabled:B,currentTenant:o,billId:n??"",isInternationalPaymentShaVsOurEnabled:J,hasZeniAssistAccess:L,isDetectInsufficientFundsEnabled:H,isAiCfoAccessEnabled:p,onAskAiCfoClick:m})]})}const Se=Je.getLocalizedStrings().spendManagement.billPay.billDetails,gi={containerWidth:new Zt(100,58)},ut=Q(function(e,t){const l=V.getSignedInUser(),n=e.tenantState.currentTenantId,c={userId:l?.userId??"",sessionId:l?.zeniSessionId??"",tenantId:n??""},r=t.showActionButtons,u=r&&t.file==null;return{uploadInvoiceEndPoint:`${Ht.communicationAgentMicroServiceBaseUrl}`,authParams:c,billId:t.billId,file:t.file,showAutofill:t.showAutofill,analytics:D,entityId:t.billId,showTitlebarIcon:r,showTitlebar:r&&t?.file!=null,uploadStatus:t.uploadStatus,shouldNotShowAttachment:u,style:{paddingTop:x.sp10,paddingRight:x.sp3,paddingBottom:"15px",paddingLeft:x.sp5,...t.showAutofill?{}:{backgroundColor:t.backgroundColor,paddingBottom:"128px"}}}},function(e,t){const l=V.getSignedInUser();return{onInvoiceUpload:n=>{n!=null&&(t.file!=null||t.billId!=null||t.isInitialEdit?(t.setPayload(n),t.setShowConfirmationPopup(!0)):e(Ne(n,t.isVendorRecommendationEnabled,t.billId)))},updateInvoiceUploadFetchState:n=>{e(ya({fetchState:{fetchState:n,error:void 0},billId:t.billId}))},onSkipAutofill:n=>{D?.trackBillPaySkipAutofill(),e(Oe(n))},onDeleteClick:()=>{e(Sa({billId:t.billId})),D?.trackInvoiceActionClick(t.billStage??"","delete",l?.userEmail??"",null)}}})(Mn);function w({appContent:e}){const t=se(),l=K(),{billId:n}=ae(),c=X(),r=c.pathname,u=r.includes("bill/new")||r.includes("/edit"),o=we(),s=me(),i=V.getSignedInUser(),{useFeatureGate:d,useDynamicConfig:p}=le(),{isFeatureEnabled:m}=d(S.isVendorRecommendationFeatureEnabled),{isFeatureEnabled:h}=d(S.isShowDeletedBillsFeatureEnabled),{isFeatureEnabled:g}=d(S.isDepositAccountsFeatureEnabled),{isFeatureEnabled:b}=d(S.billPaySetupShowInternationalPaymentByWise),{configValue:k}=p(xe.zeniAssistConfig),P=k.user_ids!=null&&i?.userId!=null&&k.user_ids.includes(i?.userId),A=v(F=>Z(F)),[B,G]=f.useState(!1),[j,_]=f.useState(!1),[$,I]=f.useState(!1),[H,M]=f.useState(),C=v(F=>Me(F,m,g,n));let q=C.fetchState,W=C.file,L=C.showAutofill;const J=v(F=>_e(F,n??""));u===!1&&(q=J.fetchState,W=J.transactionDetails?.attachments?.[0],L=!1);const Y=C.billPayInfo!=null&&C.billPayInfo.stage.code==="pending_approval"?C.billPayInfo.billStatus.code:C.billStage;f.useEffect(()=>{n==null&&t(Oe(!0))},[n,t]),f.useEffect(()=>{q==="Not-Started"&&(u&&j?_(!1):!u&&B&&G(!1))},[n]),f.useEffect(()=>{B||n==null||u||(G(!0),t(Bt(n,h,P,!1)),j||(_(!0),t($e(!1,h,P,b,n)))),u&&!j&&(_(!0),t($e(!1,h,P,b,n)))},[B,j,u,n,t]);const O={onOkClick:()=>{if(I(!1),!H)return;const F=W!=null?"replace":"upload";D?.trackInvoiceActionClick(Y??"",F,i?.userEmail??"","yes"),t(ga({replaceBillData:!0,billId:n})),t(Ne(H,m,n))},onCancelClick:()=>{if(I(!1),!H)return;const F=W!=null?"replace":"upload";D?.trackInvoiceActionClick(Y??"",F,i?.userEmail??"","no"),t(ha({file:H,billId:n}))}},ee=f.useCallback(()=>{const F=z(c.state?.pathnameStackToGoBack),ce=F.poppedPathname??ie(A.tenantEmailDomain);t(ke({billId:n})),l(ce,{state:{pathnameStackToGoBack:F.newStack}})},[c.state,A.tenantEmailDomain,n,t,l]);if(i==null)throw Error("Can't access address page without signing in...");if(q==="Error"||J.fetchState==="Error")return a.jsx(Ee,{});if(q!="Completed")return n==null&&o!=="small"?a.jsx(rt,{fallback:ee,children:a.jsxs(Fe,{windowSize:o,children:[a.jsx(mt,{}),a.jsx(Re,{}),a.jsx(ut,{backgroundColor:s.colors.grey4,billId:n,file:W,showAutofill:!0,uploadStatus:C.uploadStatus,isVendorRecommendationEnabled:m,attachmentTitle:void 0,setShowConfirmationPopup:I,setPayload:M,showActionButtons:!1,isInitialEdit:!!C.isInitialEdit,billStage:Y}),a.jsx(Ve,{windowSize:o,children:a.jsx(ct,{isNewBill:!0})})]})}):a.jsxs(Fe,{windowSize:o,children:[o==="small"||L?null:a.jsx(pt,{children:a.jsx(Qt,{onClick:ee,"data-testid":"nav-bar-back-click"})}),o!=="small"?a.jsx(Re,{}):null,a.jsx(Un,{}),a.jsx(Ve,{windowSize:o,children:a.jsx(ct,{isNewBill:n==null})})]});{const F=C.billPayInfo!=null&&C.billPayInfo.stage.code==="pending_approval"?C.billPayInfo.billStatus.code:C.billStage;return a.jsx(rt,{fallback:ee,children:a.jsxs(Fe,{windowSize:o,children:[L&&o!=="small"?a.jsx(mt,{}):null,$?a.jsx(_n,{titleComponent:a.jsx(wi,{children:Se.overwriteTitle}),descriptionComponent:a.jsx(Ai,{children:Se.overwriteDescription}),primaryButtonText:Se.buttons.yes,secondaryButtonText:Se.buttons.no,action:O,isEditPopup:!0}):null,o==="small"||L?null:a.jsx(pt,{children:a.jsx(Si,{})}),o!=="small"?a.jsx(Re,{}):null,a.jsx(ut,{backgroundColor:s.colors.grey4,billId:n,file:W,showAutofill:L,uploadStatus:C.uploadStatus,isVendorRecommendationEnabled:m,attachmentTitle:yi(u,J,C),setShowConfirmationPopup:I,setPayload:M,showActionButtons:fi(u,C),isInitialEdit:!!C.isInitialEdit,billStage:F}),a.jsx(Ve,{windowSize:o,children:e})]})})}}function Si(){const{triggerBack:e}=On();return a.jsx(Qt,{onClick:e,"data-testid":"nav-bar-back-click"})}function yi(e,t,l){let n,c;return e?(n=l.recurringConfig?.currentInstance,c=l.recurringConfig?.totalPaymentCycles):(n=t.transactionDetails?.recurringBillInstance,c=t.recurringBillConfigDetail?.totalPaymentCycles),t?.isRecurring===!0?a.jsxs(ki,{children:[a.jsx(vi,{children:`${Se.recurringBill.recurringCycle}
2
2
  ${n}/${c}`}),a.jsx(Ii,{})]}):void 0}function fi(e,t){const l=t.billActivities?.[0],n=t.billStage==="pending_approval"&&l?.areApprovalsSerialized===!0&&l?.currentPendingStepIndex===0;return e&&(t.billStage==="draft"||n)}const pt=U.div`
3
3
  margin-bottom: 20px;
4
4
  margin-top: 20px;
@@ -1,4 +1,4 @@
1
- import{j as k}from"./liveblocks-B6jAIe9x.js";import{a as V}from"./sentry-95bdnR3R.js";import{h as ae,g as ne,u as se,i as ie,j as C,N as oe,n as re}from"./core-CLKYLs-8.js";import{j as ce,F as ue,aN as de,z,A as pe,c as E,af as x,e as P,bE as le,at as me,r as B,au as R}from"./index-D_hiFYsE.js";import{Pr as fe,eW as G,to as ye,JV as Se,zj as ge,CL as Ie,Fn as be,G0 as he,H0 as Oe,PO as Te,PP as De,PQ as ke,PR as Ce,PS as Ve,Mm as we,OQ as Ae,Mx as Ne,l7 as _e,gf as Fe,ge as ve,gd as xe,rx as Pe,ro as ze,rl as Ee,k$ as Be,tx as Re,tv as M,bE as L,tJ as j,cz as Me}from"./zeni-epic-state-CjQblqOQ.js";import{n as Le}from"./mui-AZmtqUsi.js";import{d as U}from"./routePaths-XSngD1ow.js";import{M as je}from"./MobileAppDrawer-BPYh3fz7.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},d=new e.Error().stack;d&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[d]="a57a3244-0f09-4b2d-b851-c96edb8e5dbf",e._sentryDebugIdIdentifier="sentry-dbid-a57a3244-0f09-4b2d-b851-c96edb8e5dbf")}catch{}})();const Ue=Le.div`
1
+ import{j as k}from"./liveblocks-BLlSTcoD.js";import{a as V}from"./sentry-D_xp3E3Q.js";import{h as ae,g as ne,u as se,i as ie,j as C,N as oe,n as re}from"./core-CbpoBsNm.js";import{j as ce,F as ue,aN as de,z,A as pe,d as E,af as x,f as P,bE as le,at as me,s as B,au as R}from"./index-CoMuhThK.js";import{Pr as fe,eW as G,to as ye,JV as Se,zj as ge,CL as Ie,Fn as be,G0 as he,H0 as Oe,PO as Te,PP as De,PQ as ke,PR as Ce,PS as Ve,Mm as we,OQ as Ae,Mx as Ne,l7 as _e,gf as Fe,ge as ve,gd as xe,rx as Pe,ro as ze,rl as Ee,k$ as Be,tx as Re,tv as M,bE as L,tJ as j,cz as Me}from"./zeni-epic-state-CkeDRiud.js";import{n as Le}from"./mui-DcNGd9L2.js";import{d as U}from"./routePaths-BqMV9loV.js";import{M as je}from"./MobileAppDrawer-DSwbMXYq.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},d=new e.Error().stack;d&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[d]="fb1d9dcd-e06f-44da-ab05-402bea6efe3a",e._sentryDebugIdIdentifier="sentry-dbid-fb1d9dcd-e06f-44da-ab05-402bea6efe3a")}catch{}})();const Ue=Le.div`
2
2
  display: flex;
3
3
  min-height: 100%;
4
4
  width: 100%;
@@ -1,4 +1,4 @@
1
- import{j as g}from"./liveblocks-B6jAIe9x.js";import{a as l}from"./sentry-95bdnR3R.js";import{u as pe,h as he,g as Ce,j as M,i as fe,n as Se}from"./core-CLKYLs-8.js";import{W as ge,d9 as be,z as ye,da as Pe,dc as z,dd as Ie,b5 as W,A as we,c as $,de as H,dn as Ee,D as Ae,e as ke,a7 as Te,dh as xe,di as Ue,a2 as _e,dl as Oe,b1 as ve,dm as Qe}from"./index-D_hiFYsE.js";import{gj as Fe,eV as G,eW as $e,fn as De,iE as Ve,iA as Le,eX as B,g4 as je,fZ as Re,g1 as N,g5 as qe,g6 as Me,g7 as He,g8 as Be,g9 as Ne}from"./zeni-epic-state-CjQblqOQ.js";import{D as ze,n as V,P as We,S as Ge}from"./mui-AZmtqUsi.js";import"./recharts-CyaYjFwn.js";import"./analytics-BHHyMpuV.js";import"./plaid-2Q72y6JT.js";import"./dnd-BgEYAbRi.js";import"./stripe-DMRn4zHo.js";import"./lottie-C38Bn-X6.js";import"./lexical-DN4b_Twn.js";import"./pdf-BzNDzZ8_.js";import"./utils-CDpOkGne.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]="72bf2741-487a-4f10-be39-a17351c79bc6",e._sentryDebugIdIdentifier="sentry-dbid-72bf2741-487a-4f10-be39-a17351c79bc6")}catch{}})();const K="chat-response-generated",X="cards/ask",Y="card_policy_hero";function D(e){return`/${e}/cards`}function Z(e){return`/${e}/cards/policy`}const Ke=Se(function(e,a){const n=G(e),c=a.isSubmitting,d=Ue(e,{allUsers:a.allUsers,onCardPolicyVendorSearchTextChange:a.onCardPolicyVendorSearchTextChange});return{showSampleQuestions:a.sessionFromUrl==="new_chat"&&n.uiState.currentChatSessionId==null,aiCfoView:n,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:n,currentTenant:c,userId:d,navigate:m,currentChatSessionId:h,allSessionsWithOrderedQuestionAnswers:E,isAiCardCreationEnabled:T,isCardPolicyEnabled:x,cardPolicyPageContext:U}=a,i=c.tenantEmailDomain,C=n.state?.referrer,p=C===Y?Z(i):D(i);return{onEventReceived:(o,t)=>{if(o===K&&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:(o,t,s,f)=>{o&&ve(e,o,t,h,E,d,f,s,U)},updateCurrentInput:o=>{e(N(o))},onStopSubmit:()=>{},onUpdateScrollYOffset:o=>{e(qe(o))},onSelectSampleQuestion:()=>{},onBackClick:()=>{m(-1)},onCloseClick:()=>{m(p,{state:{...n.state}}),e(N(""))},togglePageView:()=>{m(p,{state:z(n.state)}),a.setIsAiCfoOpen(!0)},onCopy:()=>{},onThumbsUp:()=>{},onThumbsDown:()=>{},onTogglePageView:()=>{m(-1)},onNewChatClick:()=>{h!=null&&e(Re()),m(function(o){return`/${o}/${X}`}(i),{state:{...n.state}})},onToggleCotCollapsed:(o,t)=>{e(je({questionAnswerId:o,isCollapsed:t}))},...Oe(e,{isAiCardCreationEnabled:T,isCardPolicyEnabled:x,currentChatSessionId:h,onAfterCardsCreationSubmit:()=>{a.setIsAiCfoOpen(!0),m(D(i),{state:{...n.state}})},onAfterCardPolicySubmit:()=>{a.setIsAiCfoOpen(!0),m(`/${i}/cards/policy`,{state:{...n.state}})}})}})(Te(xe)),{spendManagement:{chargeCard:{cardsAiCfoHero:J,cardPolicyAiCfoHero:ee}}}=Ae.getLocalizedStrings(),k=J.pageTitle,Xe=ee.pageTitle,Ye=J.chatHeaderSubtitle,Ze=ee.chatHeaderSubtitle,St=({isFileUploadEnabled:e})=>{const{setIsAiCfoOpen:a}=ge(),n=pe(),c=he(),d=Ce(),[m,h]=l.useState(!1),{allUsers:E,isAiCardCreationEnabled:T,isCardPolicyEnabled:x,onCardPolicyVendorSearchTextChange:U}=be();l.useEffect(()=>{n(Fe())},[n]);const i=M(r=>G(r)),C=ye.getSignedInUser(),{session_id:p}=fe(),o=M(r=>$e(r)),t=i.uiState.currentChatSessionId,s=o.tenantEmailDomain,{handleUploadPromoClose:f,isUploadPromoVisible:b}=Pe({isFileUploadEnabled:e,tenantEmailDomain:s}),y=d.state,u=y?.aiCfoInitialQuestion??null,P=!!y?.aiCfoShouldSubmit,I=y?.referrer===Y,te=I?"card_policy":void 0,se=l.useMemo(()=>({title:I?Xe:k,subtitle:I?Ze:Ye}),[I]),[ae,_]=l.useState(null),[ne,O]=l.useState(!1),v=l.useRef(!1);l.useEffect(()=>{v.current||u==null||u===""||(_(u),O(P),v.current=!0)},[u,P]);const oe=l.useCallback(()=>{_(null),O(!1),c(d.pathname,{replace:!0,state:z(d.state)})},[d.pathname,d.state,c]),ie=o.masterTOSInfo,S=ie?.isMasterTOSAccepted??!1,A=l.useRef(null);l.useEffect(()=>{if(S&&A.current!=null){const{question:r,shouldSubmit:w}=A.current;A.current=null,_(r),O(w),v.current=!1}},[S]);const{visitedSessions:L}=Ie(t),Q=i.fetchState,F=i.uiState.chatSessionsNextPageToken.hasMore||!i.uiState.chatSessionsFirstPageFetched,j=t!=null?i.fetchChatSessionHistoryByChatSessionId?.[t]?.fetchState??"Not-Started":"Not-Started",R=t==null||(i.uiState.chatHistoryNextPageToken[t]?.hasMore??!0),q=i.allSessionsWithOrderedQuestionAnswers,{currentSessionQuestionAnswers:re}=W(q,t),le=re.length===0;l.useEffect(()=>{t!=null&&p!==t&&c(function(r,w){return`/${r}/${X}/${w}`}(s,t),{state:{...d.state},replace:!0})},[t,p,s,c,d.state]),l.useEffect(()=>{p!=null&&t==null&&p!=="new_chat"&&n(De({sessionId:p,agentId:"controller"}))},[]);const de=l.useMemo(()=>({events:L.map(r=>`private-encrypted-chat-${r}.${K}`),eventCallback:(r,w,me)=>me.onEventReceived(r,w)}),[L]);if(l.useEffect(()=>{Q!=="In-Progress"&&F&&n(Ve())},[Q,F,n]),l.useEffect(()=>{t!=null&&j!=="In-Progress"&&R&&C!=null&&Q==="Completed"&&!F&&n(Le(t,C.userId))},[j,R,t,C,n]),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(ke.Event.aiCFOPage)}),S?g.jsx(Ke,{...de,currentChatSessionId:t,allSessionsWithOrderedQuestionAnswers:q,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:k,chatHeader:se,currentTenant:o,emailLinkQuestion:ae??void 0,autoSubmitEmailLinkQuestion:ne,onEmailLinkQuestionProcessed:oe,isFileUploadEnabled:e,isUploadPromoVisible:b,onUploadPromoClose:f,onCardPolicyVendorSearchTextChange:U,cardPolicyPageContext:te}):g.jsx(H,{isTOSAccepted:S,acceptMasterTOSState:i.masterTOSAcceptanceState,customPageTitle:k,onCloseClick:()=>{c(I?Z(s):D(s),{state:{...d.state}})},onCompleteClick:()=>{S||o.userRoleId==null||(u!=null&&u!==""&&(A.current={question:u,shouldSubmit:P}),n(B(o.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:k,onCloseClick:()=>h(!1),onCompleteClick:()=>{S||o.userRoleId==null||n(B(o.userRoleId)),h(!1)}})})})]})},Je=V(Ge)`
1
+ import{j as g}from"./liveblocks-BLlSTcoD.js";import{a as l}from"./sentry-D_xp3E3Q.js";import{u as pe,h as he,g as Ce,j as M,i as fe,n as Se}from"./core-CbpoBsNm.js";import{W as ge,d9 as be,z as ye,da as Pe,dc as z,dd as Ie,b5 as W,A as we,d as $,de as H,dn as Ee,D as Ae,f as ke,a7 as Te,dh as xe,di as Ue,a2 as _e,dl as Oe,b1 as ve,dm as Qe}from"./index-CoMuhThK.js";import{gj as Fe,eV as G,eW as $e,fn as De,iE as Ve,iA as Le,eX as B,g4 as je,fZ as Re,g1 as N,g5 as qe,g6 as Me,g7 as He,g8 as Be,g9 as Ne}from"./zeni-epic-state-CkeDRiud.js";import{D as ze,n as V,P as We,S as Ge}from"./mui-DcNGd9L2.js";import"./recharts-C0aThBg3.js";import"./analytics-CQmVOD4d.js";import"./plaid-B62punae.js";import"./dnd-CX5suNP6.js";import"./stripe-DMRn4zHo.js";import"./lottie-BY8e0Ufw.js";import"./lexical-BS7d_1CV.js";import"./pdf-BslZhgI8.js";import"./utils-BQO84dIV.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]="221ace5a-edd9-48ff-b14a-53077730b3c2",e._sentryDebugIdIdentifier="sentry-dbid-221ace5a-edd9-48ff-b14a-53077730b3c2")}catch{}})();const K="chat-response-generated",X="cards/ask",Y="card_policy_hero";function D(e){return`/${e}/cards`}function Z(e){return`/${e}/cards/policy`}const Ke=Se(function(e,a){const n=G(e),c=a.isSubmitting,d=Ue(e,{allUsers:a.allUsers,onCardPolicyVendorSearchTextChange:a.onCardPolicyVendorSearchTextChange});return{showSampleQuestions:a.sessionFromUrl==="new_chat"&&n.uiState.currentChatSessionId==null,aiCfoView:n,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:n,currentTenant:c,userId:d,navigate:m,currentChatSessionId:h,allSessionsWithOrderedQuestionAnswers:E,isAiCardCreationEnabled:T,isCardPolicyEnabled:x,cardPolicyPageContext:U}=a,i=c.tenantEmailDomain,C=n.state?.referrer,p=C===Y?Z(i):D(i);return{onEventReceived:(o,t)=>{if(o===K&&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:(o,t,s,f)=>{o&&ve(e,o,t,h,E,d,f,s,U)},updateCurrentInput:o=>{e(N(o))},onStopSubmit:()=>{},onUpdateScrollYOffset:o=>{e(qe(o))},onSelectSampleQuestion:()=>{},onBackClick:()=>{m(-1)},onCloseClick:()=>{m(p,{state:{...n.state}}),e(N(""))},togglePageView:()=>{m(p,{state:z(n.state)}),a.setIsAiCfoOpen(!0)},onCopy:()=>{},onThumbsUp:()=>{},onThumbsDown:()=>{},onTogglePageView:()=>{m(-1)},onNewChatClick:()=>{h!=null&&e(Re()),m(function(o){return`/${o}/${X}`}(i),{state:{...n.state}})},onToggleCotCollapsed:(o,t)=>{e(je({questionAnswerId:o,isCollapsed:t}))},...Oe(e,{isAiCardCreationEnabled:T,isCardPolicyEnabled:x,currentChatSessionId:h,onAfterCardsCreationSubmit:()=>{a.setIsAiCfoOpen(!0),m(D(i),{state:{...n.state}})},onAfterCardPolicySubmit:()=>{a.setIsAiCfoOpen(!0),m(`/${i}/cards/policy`,{state:{...n.state}})}})}})(Te(xe)),{spendManagement:{chargeCard:{cardsAiCfoHero:J,cardPolicyAiCfoHero:ee}}}=Ae.getLocalizedStrings(),k=J.pageTitle,Xe=ee.pageTitle,Ye=J.chatHeaderSubtitle,Ze=ee.chatHeaderSubtitle,St=({isFileUploadEnabled:e})=>{const{setIsAiCfoOpen:a}=ge(),n=pe(),c=he(),d=Ce(),[m,h]=l.useState(!1),{allUsers:E,isAiCardCreationEnabled:T,isCardPolicyEnabled:x,onCardPolicyVendorSearchTextChange:U}=be();l.useEffect(()=>{n(Fe())},[n]);const i=M(r=>G(r)),C=ye.getSignedInUser(),{session_id:p}=fe(),o=M(r=>$e(r)),t=i.uiState.currentChatSessionId,s=o.tenantEmailDomain,{handleUploadPromoClose:f,isUploadPromoVisible:b}=Pe({isFileUploadEnabled:e,tenantEmailDomain:s}),y=d.state,u=y?.aiCfoInitialQuestion??null,P=!!y?.aiCfoShouldSubmit,I=y?.referrer===Y,te=I?"card_policy":void 0,se=l.useMemo(()=>({title:I?Xe:k,subtitle:I?Ze:Ye}),[I]),[ae,_]=l.useState(null),[ne,O]=l.useState(!1),v=l.useRef(!1);l.useEffect(()=>{v.current||u==null||u===""||(_(u),O(P),v.current=!0)},[u,P]);const oe=l.useCallback(()=>{_(null),O(!1),c(d.pathname,{replace:!0,state:z(d.state)})},[d.pathname,d.state,c]),ie=o.masterTOSInfo,S=ie?.isMasterTOSAccepted??!1,A=l.useRef(null);l.useEffect(()=>{if(S&&A.current!=null){const{question:r,shouldSubmit:w}=A.current;A.current=null,_(r),O(w),v.current=!1}},[S]);const{visitedSessions:L}=Ie(t),Q=i.fetchState,F=i.uiState.chatSessionsNextPageToken.hasMore||!i.uiState.chatSessionsFirstPageFetched,j=t!=null?i.fetchChatSessionHistoryByChatSessionId?.[t]?.fetchState??"Not-Started":"Not-Started",R=t==null||(i.uiState.chatHistoryNextPageToken[t]?.hasMore??!0),q=i.allSessionsWithOrderedQuestionAnswers,{currentSessionQuestionAnswers:re}=W(q,t),le=re.length===0;l.useEffect(()=>{t!=null&&p!==t&&c(function(r,w){return`/${r}/${X}/${w}`}(s,t),{state:{...d.state},replace:!0})},[t,p,s,c,d.state]),l.useEffect(()=>{p!=null&&t==null&&p!=="new_chat"&&n(De({sessionId:p,agentId:"controller"}))},[]);const de=l.useMemo(()=>({events:L.map(r=>`private-encrypted-chat-${r}.${K}`),eventCallback:(r,w,me)=>me.onEventReceived(r,w)}),[L]);if(l.useEffect(()=>{Q!=="In-Progress"&&F&&n(Ve())},[Q,F,n]),l.useEffect(()=>{t!=null&&j!=="In-Progress"&&R&&C!=null&&Q==="Completed"&&!F&&n(Le(t,C.userId))},[j,R,t,C,n]),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(ke.Event.aiCFOPage)}),S?g.jsx(Ke,{...de,currentChatSessionId:t,allSessionsWithOrderedQuestionAnswers:q,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:k,chatHeader:se,currentTenant:o,emailLinkQuestion:ae??void 0,autoSubmitEmailLinkQuestion:ne,onEmailLinkQuestionProcessed:oe,isFileUploadEnabled:e,isUploadPromoVisible:b,onUploadPromoClose:f,onCardPolicyVendorSearchTextChange:U,cardPolicyPageContext:te}):g.jsx(H,{isTOSAccepted:S,acceptMasterTOSState:i.masterTOSAcceptanceState,customPageTitle:k,onCloseClick:()=>{c(I?Z(s):D(s),{state:{...d.state}})},onCompleteClick:()=>{S||o.userRoleId==null||(u!=null&&u!==""&&(A.current={question:u,shouldSubmit:P}),n(B(o.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:k,onCloseClick:()=>h(!1),onCompleteClick:()=>{S||o.userRoleId==null||n(B(o.userRoleId)),h(!1)}})})})]})},Je=V(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-B6jAIe9x.js";import{h as de,g as Ce,i as Me,u as pe,j as o,N as Sa,s as Dt,n as De,t as In,o as es,p as se}from"./core-CLKYLs-8.js";import{bs as Pe,Rq as as,Rr as ts,eY as un,Rs as kn,f5 as En,Rt as An,Ru as Dn,Rv as _n,Rw as Pn,f6 as wn,f7 as vn,Rx as Tn,fh as Fn,fi as $a,Ry as xn,Rz as ns,fb as rs,fa as ss,RA as cs,BP as Rn,fk as ca,RB as os,RC as is,e_ as ds,eZ as ls,fw as ze,fd as Bn,fc as Ln,RD as us,fe as ms,Bk as Cs,Bj as ps,Bn as hs,Bp as fs,fp as gs,eV as On,RE as bs,RF as Ss,fu as Un,RG as ys,fv as St,Bv as Is,Bs as ks,eW as fe,RH as Qa,fz as we,fA as ve,fB as Te,gu as oa,cw as ia,RI as da,RJ as _t,uC as za,kz as Za,RK as Wa,C3 as ka,C5 as Qe,C6 as Pt,kp as jn,RL as la,BT as _a,RM as Es,RN as As,BW as Ja,RO as Ds,PL as Xa,fg as Mn,C0 as ga,hP as _s,RP as Nn,RQ as ua,bq as Ps,RR as ws,gf as et,ge as at,CA as vs,gd as tt,Pr as Ts,RS as Vn,cp as Hn,cR as Fs,PK as wa,D9 as Gn,RT as mn,CL as Pa,RU as $n,Da as xs,Qa as Rs,Db as Bs,E7 as Ls,tZ as Os,E1 as Us,RV as js,C4 as ra,RW as Ms,RX as Ns,RY as Vs,RZ as Hs,R_ as Gs,R$ as wt,S0 as $s,Cl as zn,Ce as zs,S1 as Zs,gw as Ws,Cu as Zn,Cy as Wn,gv as Ks,S2 as Ys,CX as Kn,S3 as qs,S4 as Qs,S5 as Js,Cw as Yn,Ch as qn,BZ as Qn,Cq as Jn,Co as Xn,Cs as Xs,S6 as er,S7 as ec,fr as ac,fs as tc,ft as nc,S8 as nt,fl as ar,cS as vt,S9 as rc,Sa as sc,Sb as cc,Sc as oc,CG as yt,D2 as ic,C_ as dc,CC as lc,D0 as uc,CS as mc,CU as Cc,Sd as tr,D8 as Ga,JS as pc,Se as hc,Sf as fc,Sg as gc,Sh as nr,Si as bc,Dv as Sc,CK as rr,CF as je,CJ as yc,Sj as Ic,Sk as kc,BQ as Ec,Sl as sr,ff as cr,Sm as Ac,BS as Dc,BR as Cn,Sn as _c,So as Pc,Sp as wc,Mn as vc,Sq as Tt,Sr as Tc,xC as or,l7 as Fc,hF as xc,DA as Rc,Ss as ir,f2 as Bc,f3 as Lc,St as Oc,di as Uc,fj as jc,Dq as Mc,Dk as qe,bt as Nc,bJ as Vc,cB as Hc,bK as Gc,LA as $c}from"./zeni-epic-state-CjQblqOQ.js";import{j as Fe,cm as dr,n as _e,cn as lr,co as ur,cp as zc,D as Xe,_ as Ft,cq as Zc,cr as Wc,W as mr,a as Cr,Z as pr,r as ye,F as le,x as K,aq as ya,cs as hr,ct as Kc,cu as Yc,z as re,B as va,cb as rt,cv as qc,cw as Qc,cx as Jc,cy as Xc,cz as eo,K as Ta,aN as Ze,bo as xt,cA as ao,E as Fa,h as st,m as Rt,c as J,a7 as ct,cB as to,bB as ba,cC as It,cD as no,A as Bt,cE as ro,at as fr,a2 as kt,cF as so,X as gr,e as br,cG as co,cH as oo,cI as io,cJ as lo,cK as uo,cL as mo,o as Ka,cM as Co,cN as po,cO as pt,w as ho,cP as fo,cQ as go,cR as bo,cS as So,cT as yo,a9 as Io}from"./index-D_hiFYsE.js";import{n as Ne,D as Sr,S as ko}from"./mui-AZmtqUsi.js";import{a as r}from"./sentry-95bdnR3R.js";import{u as xa}from"./useAskAiCfoHostNavButtonProps-FETbJUjN.js";import{M as Ie}from"./MobileAppDrawer-BPYh3fz7.js";import{d as Lt}from"./recharts-CyaYjFwn.js";import{g as Ae,a as Ra,b as yr,c as xe,d as Re,e as Je,f as ea,h as aa,A as Eo,i as Ot,P as Ao,j as Ut,s as Ia,k as Ir,l as sa,m as kr,n as Do,o as Er,p as _o,S as pn}from"./SetupPagesScreen-Bfb-yG5Q.js";import{u as Ar}from"./useInitialThreadRequest-D1F5GLCG.js";import ot from"./NotFoundScreen-ChEBjJeL.js";import{n as hn}from"./utils-CDpOkGne.js";import{t as Po}from"./AddressScreen-BRdhnUB3.js";import"./analytics-BHHyMpuV.js";import"./plaid-2Q72y6JT.js";import"./dnd-BgEYAbRi.js";import"./stripe-DMRn4zHo.js";import"./lottie-C38Bn-X6.js";import"./lexical-DN4b_Twn.js";import"./pdf-BzNDzZ8_.js";import"./analyticsHelper-BsjRdUZX.js";import"./routePaths-XSngD1ow.js";import"./BusinessVerificationPageScreen-CoxJBcce.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]="786f2162-5803-49e9-b9a7-9a0f283f117b",e._sentryDebugIdIdentifier="sentry-dbid-786f2162-5803-49e9-b9a7-9a0f283f117b")}catch{}})();const wo=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}},Dr=e=>({id:e.id,isChecked:!1,cardName:e.cardName,last4:e.accountLast4,limitAmount:e.limit?.amount??0,limitCadence:e.creditLimitFrequency?.code,owner:wo(e),utilizationAmount:(e.limit?.amount??0)-(e.available?.amount??0)}),{spendManagement:{chargeCard:{cardPolicyPage:fn}}}=Xe.getLocalizedStrings(),vo=e=>Bn(e,!1),To=e=>Ln(e.name,!1);function Fo(){const e=de(),n=Ce(),{tenantEmailDomain:t}=Me(),a=pe(),s=Fe(),b=Pe(s?.loggedInUserRoleMap),[f,g]=r.useState(!1),_=r.useCallback(T=>{g(T)},[]),i=r.useCallback(()=>{_(!0)},[_]),{isAiCfoAccessEnabled:m,onAskAiCfoClick:B}=xa({mobileExploreReferrer:"Card Policy"});r.useEffect(()=>()=>{a(as()),a(ts()),a(un())},[a]);const D=o(T=>kn(T.cardPolicyState)),d=o(T=>En(T.cardPolicyState)),j=o(T=>An(T.cardPolicyState)),P=o(T=>Dn(T.cardPolicyState)),F=o(T=>_n(T.cardPolicyState)),C=o(T=>Pn(T.cardPolicyState)),h=o(T=>wn(T.cardPolicyState)),w=o(T=>vn(T.cardPolicyState)),u=o(T=>Tn(T.cardPolicyState)),v=o(T=>T.chargeCardConfigState.receiptRequiredAboveAmount.amount),k=o(T=>T.chargeCardConfigState.fetchState);r.useEffect(()=>{D!=="Completed"&&D!=="In-Progress"&&a(Fn())},[a,D]),r.useEffect(()=>{w==="Completed"&&u===""||w==="In-Progress"||a($a())},[a,w,u]);const M=o(T=>xn(T.createCardPolicyState)),A=o(T=>ns(T.createCardPolicyState)),I=o(T=>rs(T.cardPolicyState)),L=o(T=>ss(T.cardPolicyState)),l=o(T=>cs(T.createCardPolicyState)),p=o(T=>Rn(T));r.useEffect(()=>{p.fetchState==="Not-Started"&&a(ca(!1,!1,!1))},[p.fetchState,a]);const N=r.useMemo(()=>d.map(vo),[d]),G=r.useMemo(()=>h.map(To),[h]),O=r.useMemo(()=>p.cards.filter(T=>!dr(T.status.code)).map(Dr),[p.cards]),U=D==="Completed"&&p.fetchState==="Completed"&&k==="Completed";r.useEffect(()=>{U&&l==null&&a(os({cardsMasterList:O,defaultRequireReceiptAmount:v,suggestedAllowMerchants:j,suggestedBlockMerchants:P,suggestedAllowCategories:F,suggestedBlockCategories:C}))},[k,a,U,l,O,v,j,P,F,C]);const z=r.useMemo(()=>Lt(T=>{a($a(T))},250),[a]);r.useEffect(()=>()=>{z.cancel()},[z]);const Z=r.useCallback(T=>{z(T)},[z]),y=M.fetchState,x=t!=null?`/${t}/cards/policy`:"..",W=r.useCallback(()=>{const T=_e(n.state?.pathnameStackToGoBack),ee=T.poppedPathname??x;e(ee,{state:{pathnameStackToGoBack:T.newStack}})},[n.state,e,x]),q=r.useCallback(()=>{e(x)},[e,x]),E=r.useCallback(T=>{a(is(T))},[a]),V=r.useCallback(T=>{const ee=lr(T);a(ds({templates:[ee]}))},[a]),Q=r.useCallback(T=>{T.length!==0&&a(ls(T))},[a]),X=r.useCallback(()=>{a(un())},[a]),S=r.useRef(y);r.useEffect(()=>{const T=S.current;S.current=y,y==="Completed"&&T!=="Completed"&&A!=null&&(a(ze({messageSection:"card_policy_created",messageText:"success",type:"success"})),e(x))},[a,y,A,e,x]);const R=y==="Error"?M.error?.message??fn.createPolicyGenericErrorMessage:void 0;return b&&t!=null?l==null?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:f,handleDrawerToggle:_}),c.jsx(ur,{showUploadDocumentSection:!0,navBarTitle:fn.createPageTitle,onBackClick:W,onClickMenuIcon:i,isAiCfoAccessEnabled:m,onAskAiCfoClick:B})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:f,handleDrawerToggle:_}),c.jsx(zc,{formDraft:l,vendorSearchOptions:G,categorySearchOptions:N,isVendorSearchLoading:w==="In-Progress",onVendorSearchTextChange:Z,submitState:y,submitErrorMessage:R,documentUploadState:I,uploadedFileName:L,isAiCfoAccessEnabled:m,onAskAiCfoClick:B,onBackClick:W,onCancelClick:q,onClickMenuIcon:i,onFormChange:E,onSubmit:V,onUploadDocument:Q,onRemoveDocument:X})]}):c.jsx(Sa,{to:"..",replace:!0})}const{spendManagement:{chargeCard:{cardPolicyPage:xo}}}=Xe.getLocalizedStrings(),Ro=e=>Bn(e,!1),Bo=e=>Ln(e.name,!1);function Lo(){const e=de(),n=Ce(),{tenantEmailDomain:t,templateId:a}=Me(),s=pe(),b=Fe(),f=Pe(b?.loggedInUserRoleMap),[g,_]=r.useState(!1),i=r.useCallback(R=>{_(R)},[]),m=r.useCallback(()=>{i(!0)},[i]),{isAiCfoAccessEnabled:B,onAskAiCfoClick:D}=xa({mobileExploreReferrer:"Card Policy"}),d=o(R=>us(R)),j=o(R=>kn(R.cardPolicyState)),P=o(R=>En(R.cardPolicyState)),F=o(R=>An(R.cardPolicyState)),C=o(R=>Dn(R.cardPolicyState)),h=o(R=>_n(R.cardPolicyState)),w=o(R=>Pn(R.cardPolicyState)),u=o(R=>wn(R.cardPolicyState)),v=o(R=>vn(R.cardPolicyState)),k=o(R=>Tn(R.cardPolicyState)),M=o(R=>Rn(R)),A=o(R=>a!=null?ms(R.cardPolicyState,a):void 0),I=r.useMemo(()=>d.templateId===a&&d.formDraft!=null?d.formDraft:A!=null?Cs(A):void 0,[d.templateId,d.formDraft,A,a]);r.useEffect(()=>{if(a==null)return;const R=d.detailFetchState.fetchState;d.templateId===a&&(R==="Completed"||R==="In-Progress")||A!=null||s(ps(a))},[s,a,d.templateId,d.detailFetchState.fetchState,A]),r.useEffect(()=>{j!=="Completed"&&j!=="In-Progress"&&s(Fn())},[s,j]),r.useEffect(()=>{v==="Completed"&&k===""||v==="In-Progress"||s($a())},[s,v,k]);const L=o(R=>R.chargeCardConfigState.receiptRequiredAboveAmount.amount);r.useEffect(()=>{M.fetchState==="Not-Started"&&s(ca(!1,!1,!1))},[M.fetchState,s]);const l=r.useMemo(()=>P.map(Ro),[P]),p=r.useMemo(()=>u.map(Bo),[u]),N=r.useMemo(()=>M.cards.filter(R=>!dr(R.status.code)).map(Dr),[M.cards]);Ft({isDataReady:I!=null});const G=r.useMemo(()=>{if(I!=null)return Zc({draft:I,cardRows:N,categorySearchOptions:l,vendorSearchOptions:p,defaultRequireReceiptAmount:L,suggestedAllowMerchants:F,suggestedBlockMerchants:C,suggestedAllowCategories:h,suggestedBlockCategories:w})},[I,N,l,p,L,F,C,h,w]),[O,U]=r.useState(void 0),z=r.useRef(!1);r.useEffect(()=>{z.current||O!=null||G==null||(z.current=!0,U(G))},[O,G]);const Z=r.useCallback(R=>{U(R)},[]),y=r.useMemo(()=>Lt(R=>{s($a(R))},250),[s]);r.useEffect(()=>()=>{y.cancel()},[y]);const x=r.useCallback(R=>{y(R)},[y]),W=d.updateFetchState.fetchState,q=t!=null?`/${t}/cards/policy`:"..",E=r.useCallback(()=>{const R=_e(n.state?.pathnameStackToGoBack),T=R.poppedPathname??q;e(T,{state:{pathnameStackToGoBack:R.newStack}})},[n.state,e,q]),V=r.useCallback(()=>{e(q)},[e,q]),Q=r.useCallback(R=>{if(a==null)return;const T=lr(R);s(hs(T)),s(fs(a))},[s,a]),X=r.useRef(W);r.useEffect(()=>{const R=X.current;X.current=W,W==="Completed"&&R!=="Completed"&&(s(ze({messageSection:"card_policy_updated",messageText:"success",type:"success"})),e(q))},[s,W,e,q]);const S=W==="Error"?d.updateFetchState.error?.message??xo.updatePolicyGenericErrorMessage:void 0;return!f||t==null||a==null?c.jsx(Sa,{to:"..",replace:!0}):O!=null&&j==="Completed"&&M.fetchState==="Completed"?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:i}),c.jsx(Wc,{templateName:d.template?.name??"",formDraft:O,vendorSearchOptions:p,categorySearchOptions:l,isVendorSearchLoading:v==="In-Progress",onVendorSearchTextChange:x,submitState:W,submitErrorMessage:S,isAiCfoAccessEnabled:B,onAskAiCfoClick:D,onBackClick:E,onCancelClick:V,onClickMenuIcon:m,onFormChange:Z,onSubmit:Q})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:i}),c.jsx(ur,{showUploadDocumentSection:!1,navBarTitle:d.template?.name,onBackClick:E,onClickMenuIcon:m,isAiCfoAccessEnabled:B,onAskAiCfoClick:D})]})}function _r(e,n,t){return n?e.filter(a=>a!=null&&a.trim().length>0).slice(0,t):[]}function Pr(e){return o(n=>e==null||e===""?{chips:ht,isResolved:!1}:function(t){const a=t?.fetchState,s=a==="Completed"||a==="Error";return{chips:a==="Completed"?t?.suggestedQuestions??ht:ht,isResolved:s}}(gs(n,e)),Dt)}const ht=[],{spendManagement:{chargeCard:{cardPolicyAiCfoHero:{headline:Oo,subheadline:Uo,pageTitle:jo}}}}=Xe.getLocalizedStrings(),Mo=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 No(){const e=de(),n=Ce(),{tenantEmailDomain:t}=Me(),a=pe(),s=Fe(),b=Pe(s?.loggedInUserRoleMap),[f,g]=r.useState(!1),_=r.useCallback(y=>{g(y)},[]),i=r.useCallback(()=>{_(!0)},[_]),{useFeatureGate:m}=le(),{isFeatureEnabled:B}=m(K.isAiCfoFileUploadEnabled),{isFeatureEnabled:D}=m(K.isCardPolicyEnabled),{isAiCfoAccessEnabled:d,onAskAiCfoClick:j}=xa({mobileExploreReferrer:"Card Policy"}),P=o(y=>bs(y)),F=o(y=>xn(y.createCardPolicyState)),C=o(y=>Ss(y.createCardPolicyState)),h=o(y=>C==null?[]:Un(y.aiCfoState,C).filter(x=>x.kind==="creating_policy"),Dt),w=F.fetchState==="In-Progress"?Math.max(h.length,1):0,u=o(y=>ys(y.createCardPolicyState)),v=ya(F.fetchState);r.useEffect(()=>{if(v==="In-Progress"&&F.fetchState==="Completed"&&C!=null)h.forEach(y=>{a(St({chatSessionId:C,id:y.id,entityIds:u,kind:"created_policy"}))});else if(v==="In-Progress"&&F.fetchState==="Error"&&C!=null){h.forEach(x=>{a(St({chatSessionId:C,id:x.id,kind:"errored_policy"}))});const y=F.error?.message!=null&&F.error.message.length>0?F.error.message:Xe.getLocalizedStrings().common.errorMessage.somethingWentWrongPleaseTryAgain;a(ze({messageSection:"card_policy_created",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:y}]}))}},[F.error?.message,F.fetchState,a,C,u,h,v]);const k=P.fetchState.fetchState;r.useEffect(()=>{k!=="Not-Started"&&k!=="Error"||a(Is())},[a,k]);const M=P.archiveFetchState.fetchState,A=ya(M);r.useEffect(()=>{A==="In-Progress"&&M==="Completed"&&a(ze({messageSection:"card_policy_deleted",messageText:"success",type:"success"}))},[M,a,A]);const I=r.useMemo(()=>P.templates.map(Mo),[P.templates]);Ft({isDataReady:P.fetchState.fetchState==="Completed"});const L=I.length>0||w>0,l=function(y){const{hasAnyPolicies:x,isChargeCardAdmin:W,isFileUploadEnabled:q}=y,E=de(),V=Ce(),{tenantEmailDomain:Q}=Me(),{isAiCfoOpen:X,setIsAiCfoOpen:S}=mr(),R=Cr(),T=pr(),ee=o(ce=>On(ce)).createSessionAndSubmitState.fetchState==="In-Progress",{chips:Y,isResolved:ke}=Pr("card_policy"),be=r.useMemo(()=>_r(Y,ke,3),[Y,ke]),[ge,ae]=r.useState(""),ue=T&&R&&Q!=null&&!X,oe=r.useCallback(ce=>{if(Q==null)return;const Ea=ye(V.state?.pathnameStackToGoBack,V.pathname);E(`/${Q}/cards/ask`,{state:{message:"",origin:"",pathnameStackToGoBack:Ea,referrer:"card_policy_hero",aiCfoInitialQuestion:ce,aiCfoShouldSubmit:ce!=null&&ce.trim().length>0}})},[V.pathname,V.state,E,Q]),te=r.useCallback(ce=>{ce.trim().length!==0&&(ae(""),oe(ce))},[oe]),We=r.useCallback(()=>{const ce=ge.trim();ce.length!==0&&(ae(""),oe(ce))},[ge,oe]),Ee=r.useCallback(()=>{},[]),ne=r.useCallback(ce=>{ae(ce)},[]),Ke=r.useCallback(()=>{S(!0)},[S]),Be=r.useCallback(()=>{oe(void 0)},[oe]);return r.useMemo(()=>{if(ue&&!x&&W)return{aiAgentName:jo,headline:Oo,subheadline:Uo,promptChips:be,composer:{currentInput:ge,isSubmitting:ee,isFileUploadEnabled:q,onInputChange:ne,onSubmit:We,onStopSubmit:Ee},onPromptClick:te,onOpenSidePanel:Ke,onOpenFullView:Be,dataTestIdPrefix:"card-policy-ai-cfo-hero"}},[ge,x,ue,W,q,ee,ne,Be,Ke,te,Ee,We,be])}({hasAnyPolicies:L,isChargeCardAdmin:b,isFileUploadEnabled:B}),p=D&&l!=null?c.jsx(hr,{...l}):null,N=d&&p==null,G=r.useCallback(()=>{const y=_e(n.state?.pathnameStackToGoBack),x=y.poppedPathname??"..";e(x,{state:{pathnameStackToGoBack:y.newStack}})},[n.state,e]),O=r.useCallback(()=>{t!=null&&e(`/${t}/cards/policy/new`)},[e,t]),U=r.useCallback(y=>{t!=null&&e(`/${t}/cards/policy/${y}/edit`)},[e,t]),z=r.useCallback(y=>{a(ks(y))},[a]),Z=P.fetchState.fetchState;return!L&&Z!=="Completed"&&Z!=="Error"?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:f,handleDrawerToggle:_}),c.jsx(Kc,{onBackClick:G,onNewPolicyClick:O,onClickMenuIcon:i,isAiCfoAccessEnabled:d,onAskAiCfoClick:j})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:f,handleDrawerToggle:_}),c.jsx(Yc,{policies:I,archivingTemplateId:P.archiveTargetTemplateId,pendingCreationCount:w,onBackClick:G,onNewPolicyClick:O,onEditPolicyClick:U,onArchivePolicyClick:z,onClickMenuIcon:i,policyAiCfoHero:p,isAiCfoAccessEnabled:N,onAskAiCfoClick:j})]})}function Vo(){const e=de(),{cardId:n}=Me(),t=pe(),a=re.getSignedInUser(),s=o(Y=>fe(Y)),b=Fe(),f=Pe(b?.loggedInUserRoleMap),{useFeatureGate:g}=le();if(a==null)throw Error("Can't access Add To Wallet Page without signing in...");const[_,i]=r.useState(!1),m=o(Y=>Qa(Y).firstViewAfterActivation);if(n==null)throw Error("Empty card id is not valid...");const B=s.userRole.includes("charge_card_user"),{isFeatureEnabled:D}=g(K.isChargeCardFeatureEnabled),d=!!s.companyChargeCardInfo?.info?.isChargeCardEnabled,{isFeatureEnabled:j}=g(K.isDebitCardFeatureEnabled),P=we(s),F=ve(s),C=Te(j,s),h=s.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,w=xe({isDebitCardFeatureEnabled:j,isBankingOnlyTenant:C}),u=Re({isCardsOnlyTenant:P,isChargeCardFeatureEnabled:D,isBookKeepingTenant:F,isDebitCardProductVisible:w,chargeCardsCreditAccountLimit:h}),v=!!s.companyDebitCardInfo?.info?.isDebitCardEnabled,k=o(Y=>oa(Y,s.companyId)),M=ia(k.controllers),{creditAccount:A,creditAccountRepayment:I}=o(Y=>da(Y)),L=o(Y=>Y.classListState.fetchState),l=!B&&u&&d,p=o(Y=>_t(Y,n,l,u)),[N,G]=r.useState(!1),O=p.chargeCard,U=O?.cardCreatedByUser?.userId,z=o(Y=>U!=null?za(Y.userRoleState,U):void 0),Z=z?.accountingClassIDs[0],y=o(Y=>Z!=null?Za(Y.classState,{classId:Z,reportId:"class_list"}):void 0),x=O?.cardHolderUser?.userId,W=o(Y=>x!=null?za(Y.userRoleState,x):void 0),q=W?.accountingClassIDs[0],E=o(Y=>q!=null?Za(Y.classState,{classId:q,reportId:"class_list"}):void 0),V=O?.type.code==="business_physical_credit_card"||O?.type.code==="business_physical_debit_card",Q=O?.type.code==="business_physical_debit_card";r.useEffect(()=>{m&&_===!1&&V&&(i(!0),setTimeout(()=>{t(Wa()),Q&&t(ze({messageSection:"set_debit_card_pin",messageText:"success",type:"success",showStatusIcon:!0}))},5e3))},[m,_,V,Q]),r.useEffect(()=>{N||p.fetchState==="Completed"||p.fetchState==="In-Progress"||n==null||(G(!0),t(ka(n,l,!1)))},[N,p,n,t]),r.useEffect(()=>{if(p.fetchState==="Completed"&&(V===!1||V&&O?.status?.code!=="active"||O?.cardHolderUserId!==a.userId||m===!1&&_===!1||O?.type.code==="business_physical_debit_card"||O?.type.code==="business_virtual_debit_card")){const Y=Ae(s.tenantEmailDomain,n,a,O,m);e(Y)}},[p.fetchState,m,V]),r.useEffect(()=>{A.fetchState!=="Completed"&&A.fetchState!=="In-Progress"&&u&&d&&f&&t(Qe()),I.fetchState!=="Completed"&&I.fetchState!=="In-Progress"&&u&&d&&f&&t(Pt()),L!=="Completed"&&L!=="In-Progress"&&t(jn())},[A.fetchState,I.fetchState,t,u,d,f,L]);const X=()=>{if(a!=null&&n!=null){t(Wa());const Y=Ae(s.tenantEmailDomain,n,a);e(Y)}},S=O?.type.code==="business_physical_debit_card"||O?.type.code==="business_virtual_debit_card",R=Je(u,w,v,d),T=Ra(u,d,f,A,I),ee=yr(S,p);return p.fetchState!=="Completed"?c.jsx(va,{fetchState:"In-Progress"}):c.jsxs(c.Fragment,{children:[c.jsx(rt,{showConfetti:m}),c.jsx(qc,{onGotItClick:X,isDebitCard:O?.type.code==="business_physical_debit_card",controllerEmails:M,isChargeCardFeatureEnabled:u,isDebitCardFeatureEnabled:w,isDebitCardSetupEnabled:v,isChargeCardSetupEnabled:d,productInformation:R,creditAccountInformation:T,debitAccountInformation:ee,chargeCardDetailView:p,creditAccount:A,classListFetchState:L,creditAccountRepayment:I,cardIssuedByRoles:z?.userRoles,cardIssuedByDepartmentName:y?.className,cardHolderRoles:W?.userRoles,cardHolderDepartmentName:E?.className})]})}const jt=e=>{const{events:n,onEvent:t,onSubscribed:a}=e,s=Qc(),b=r.useRef(t),f=r.useRef(a),g=r.useRef(0);r.useEffect(()=>{b.current=t},[t]),r.useEffect(()=>{f.current=a},[a]);const _=r.useMemo(()=>[...n].sort().join("|"),[n]);r.useEffect(()=>{if(s==null||n.length===0)return;const i=[],m=new Set,B=()=>{if(f.current==null)return;const D=Date.now();D-g.current<5e3||(g.current=D,f.current())};return n.forEach(D=>{const[d,j]=Jc(D);if(j==="")return;const P=s.channel(d),F=h=>{b.current(j,h)};let C;if(P?.subscribed===!0)C=P,C.bind(j,F),m.has(d)||(m.add(d),B()),i.push(()=>{P.unbind(j,F)});else{if(C=P??s.subscribe(d),C.bind(j,F),!m.has(d)){m.add(d);const h=()=>{B()};C.bind("pusher:subscription_succeeded",h),i.push(()=>{C.unbind("pusher:subscription_succeeded",h)})}i.push(()=>{C.unbind(j,F)})}}),()=>{i.forEach(D=>D())}},[s,_])},wr="charge-card-transaction-update",vr="charge-card-transaction-created",Tr="charge-card-transaction-declined",Fr="charge-card-transaction-updated",xr="charge-card-transaction-receipt-uploaded",ma="charge-card-status-update",Mt="charge-card-spending-updated",it="credit-account-balance-updated",dt="charge-card-created",Nt="charge-card-limit-updated",Vt="charge-card-limit-reset",Ht="charge-card-renamed",Ho="charge-card-department-updated",Rr="charge-card-repayment-completed",Br="charge-card-payment-date-updated",Ba="charge-card-cashback-redeemed",La="charge-card-cashback-earned",Ca=(e,n)=>e==null||e===""?[]:n.map(t=>`private-encrypted-${e}.${t}`),Go=[La,Ba],$o=De(function(e){const n=la(e);return{insightsData:n.insight,cashbackByPeriod:n.cashbackByPeriod,uiState:n.uiState,cashbackSummary:n.cashbackSummary}},function(e){return{onColumnSortConfigChanged:(n,t)=>{e(Es({uiState:{sortKey:n,sortOrder:t}}))}}})(eo);function zo(){const e=de(),n=pe(),t=Ce(),a=re.getSignedInUser(),s=o(j=>fe(j)),{useFeatureGate:b}=le(),{isFeatureEnabled:f}=b(K.isCardsCommentingEnabled),[g,_]=r.useState(!1),i=o(j=>la(j)),m=Ar(s.companyId,{clearParams:i.fetchState==="Completed"}),B=r.useCallback(()=>{const j=_e(t.state?.pathnameStackToGoBack),P=j.poppedPathname??Zo(s.tenantEmailDomain);e(P,{state:{pathnameStackToGoBack:j.newStack}})},[e,t,s.tenantEmailDomain]),D=ea(s);if(jt({events:Ca(D,Go),onEvent:j=>{switch(j){case La:case Ba:return void n(_a(!0))}},onSubscribed:()=>{n(_a(!0))}}),r.useEffect(()=>{g||i.fetchState==="Completed"||i.fetchState==="In-Progress"||(_(!0),n(_a()))},[g,i,n]),a==null)throw Error("Can't access cashback detail page without signing in...");const d=i.cashbackSummary?.cashbackEarned?.amount!=null&&i.fetchState!=="Not-Started";return i.fetchState!=="In-Progress"||d?(i.cashbackSummary?.cashbackEarned?.amount??0)===0&&i.fetchState==="Completed"?c.jsx(ot,{}):c.jsx($o,{onBackClick:B,isCardsCommentingEnabled:f,initialOpenThreadRequest:m}):c.jsx(Xc,{onBackClick:B})}const Zo=e=>`/${e}/cards`,Wo={containerWidth:new Fa(100,58)},Ko=({appContent:e})=>{const n=Ta(),t=pe(),a=de(),{cardId:s}=Me(),b=Ce(),{useDynamicConfig:f}=le(),[g,_]=r.useState(!1),[i,m]=r.useState(!1),[B,D]=r.useState(!1),[d,j]=r.useState(!1),P=re.getSignedInUser();if(P==null)throw Error("Can't access onboarding card page without signing in...");const F=o(E=>fe(E));if(s==null)throw Error("Empty card id is not valid...");const{configValue:C}=f(Ze.zeniCardsConfig),h=C.max_charge_card_activation_attempts_by_card_id,w=o(E=>As(E,s)),u=w.chargeCard,v=o(E=>E.chargeCardConfigState.fetchState),{useFeatureGate:k}=le(),{isFeatureEnabled:M}=k(K.isChargeCardFeatureEnabled),{isFeatureEnabled:A}=k(K.isDebitCardFeatureEnabled),I=Te(A,F),L=xe({isDebitCardFeatureEnabled:A,isBankingOnlyTenant:I}),l=!!F.companyChargeCardInfo?.info?.isChargeCardEnabled,p=F.userRole.includes("charge_card_user"),N=we(F),G=ve(F),O=F.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,U=Re({isCardsOnlyTenant:N,isChargeCardFeatureEnabled:M,isBookKeepingTenant:G,isDebitCardProductVisible:L,chargeCardsCreditAccountLimit:O}),z=!p&&U&&l;r.useEffect(()=>{g===!1&&v!=="In-Progress"&&v!=="Completed"&&(t(Ja()),_(!0)),i===!1&&w.fetchState==="Not-Started"&&(m(!0),t(ka(s,z,U)))},[i,w.fetchState,g,v]);const Z=u?.type.code==="business_physical_credit_card"||u?.type.code==="business_physical_debit_card";r.useEffect(()=>{if(w.fetchState==="Completed"){if(B===!1&&(Z===!1||Z&&u?.status?.code!=="inactive"||u?.cardHolderUserId!==P.userId)){const E=Ae(F.tenantEmailDomain,s,P,u,!0),V=ye(b.state?.pathnameStackToGoBack,b.pathname);a(E,{state:{pathnameStackToGoBack:V}})}else if(B&&w.isRefreshingViewInBackground===!1&&u?.status?.code==="active"){t(Ds({chargeCardId:s}));const E=Ae(F.tenantEmailDomain,s,P,u,!0),V=ye(b.state?.pathnameStackToGoBack,b.pathname);t(Xa()),a(E,{state:{pathnameStackToGoBack:V}})}}},[w.fetchState,u?.type.code,B,w.isRefreshingViewInBackground]);const y=re.getZeniOtpTokenForCardHolder(s),x=o(E=>Mn(E.userState,P.userId)),W=()=>{u?.status?.code!=="active"&&t(ga(s,!0))};r.useEffect(()=>{w.updatePhysicalChargeCardAttemptFetchState.fetchState==="Completed"&&u?.cardActivationAttemptHistory.some(E=>E.statusCode==="success")===!0&&B===!1&&(setTimeout(W,3e3),D(!0))},[w.updatePhysicalChargeCardAttemptFetchState.fetchState,u?.cardActivationAttemptHistory]);const q=E=>{j(E)};if(v!=="Completed"||u==null)return c.jsx(va,{fetchState:"In-Progress"});if(u.shippingAddressId==null)throw Error("Can't access shippingAddressId.");if(x?.phone==null)throw Error("Can't access user phone number.");return c.jsxs(Qo,{children:[c.jsx(Ie,{isAppContentDrawerOpen:d,handleDrawerToggle:q}),c.jsx(Yo,{cardId:s,card:u,shippingAddressId:u.shippingAddressId,phone:x.phone,signedInUser:P,isSandboxEnv:xt(),chargeCardDetailState:w,signedInUserToken:y,navigate:a,currentTenant:F,location:b,maxChargeCardActivationAttempts:h[s]!=null?h[s]:C.default_max_charge_card_activation_attempts!=null?C.default_max_charge_card_activation_attempts:3,chargeCardCashbackRatePerTransaction:C.charge_card_cashback_rate_per_transaction!=null?C.charge_card_cashback_rate_per_transaction:.0175,onClickMenuIcon:()=>{q(!0)}}),e!=null?c.jsx(qo,{windowSize:n,children:e}):null]})},Yo=De(function(e,{chargeCardDetailState:n,shippingAddressId:t,location:a,cardId:s}){const b=_s(e.addressState,t);if(b==null)throw Error("Can't access shippingAddress.");const f=Nn(e,s),g=n.updateStatus,_=ua(e,!1,!1,!1);let i=!1;_.fetchState==="Completed"&&_.cards.length<=1&&(i=!0);const m=a.state?.message==="comingFromV2UrlPath";return{showActivatePage:n.chargeCard?.providerCardCreateTime!=null&&n.chargeCard.providerCardCreateTime.add(24,"h").isBefore(Ps())||m,showMenuIcon:i,shippingAddress:b,vgsVaultId:st.cardVaultId,twoFAView:f,activationWaitStatus:g,isRefreshingViewInBackground:n.isRefreshingViewInBackground}},function(e,n){const{navigate:t,cardId:a,location:s,currentTenant:b,chargeCardDetailState:f}=n,g=f.chargeCard?.cardProviderID,{tenantEmailDomain:_}=b;return{onGetOtp:i=>{g!=null&&e(tt(i,"ChargeCardHolder",a))},onUpdatePhysicalChargeCardAttempt:i=>{e(vs(a,i))},onResendOtp:i=>{g!=null&&e(at(i,"ChargeCardHolder",a))},onVerifyOtp:(i,m)=>{g!=null&&e(et(i,m,"ChargeCardHolder",a))},onVerifyOtpSuccess:i=>{i!=null&&re.saveZeniOtpTokenForCardHolder(i,a)},onCVVActivateSuccess:()=>{e(ws({chargeCardId:a}))},onBackClick:()=>{const i=_e(s.state?.pathnameStackToGoBack),m=i.poppedPathname==null||i.poppedPathname.includes("onboard")===!0?aa(_):i.poppedPathname;t(m,{state:{pathnameStackToGoBack:i.newStack}})}}})(ao),qo=Ne.div`
1
+ import{j as c}from"./liveblocks-BLlSTcoD.js";import{h as de,g as Ce,i as Me,u as pe,j as o,N as Sa,s as Dt,n as De,t as In,o as es,p as se}from"./core-CbpoBsNm.js";import{bs as Pe,Rq as as,Rr as ts,eY as un,Rs as kn,f5 as En,Rt as An,Ru as Dn,Rv as _n,Rw as Pn,f6 as wn,f7 as vn,Rx as Tn,fh as Fn,fi as $a,Ry as xn,Rz as ns,fb as rs,fa as ss,RA as cs,BP as Rn,fk as ca,RB as os,RC as is,e_ as ds,eZ as ls,fw as ze,fd as Bn,fc as Ln,RD as us,fe as ms,Bk as Cs,Bj as ps,Bn as hs,Bp as fs,fp as gs,eV as On,RE as bs,RF as Ss,fu as Un,RG as ys,fv as St,Bv as Is,Bs as ks,eW as fe,RH as Qa,fz as we,fA as ve,fB as Te,gu as oa,cw as ia,RI as da,RJ as _t,uC as za,kz as Za,RK as Wa,C3 as ka,C5 as Qe,C6 as Pt,kp as jn,RL as la,BT as _a,RM as Es,RN as As,BW as Ja,RO as Ds,PL as Xa,fg as Mn,C0 as ga,hP as _s,RP as Nn,RQ as ua,bq as Ps,RR as ws,gf as et,ge as at,CA as vs,gd as tt,Pr as Ts,RS as Vn,cp as Hn,cR as Fs,PK as wa,D9 as Gn,RT as mn,CL as Pa,RU as $n,Da as xs,Qa as Rs,Db as Bs,E7 as Ls,tZ as Os,E1 as Us,RV as js,C4 as ra,RW as Ms,RX as Ns,RY as Vs,RZ as Hs,R_ as Gs,R$ as wt,S0 as $s,Cl as zn,Ce as zs,S1 as Zs,gw as Ws,Cu as Zn,Cy as Wn,gv as Ks,S2 as Ys,CX as Kn,S3 as qs,S4 as Qs,S5 as Js,Cw as Yn,Ch as qn,BZ as Qn,Cq as Jn,Co as Xn,Cs as Xs,S6 as er,S7 as ec,fr as ac,fs as tc,ft as nc,S8 as nt,fl as ar,cS as vt,S9 as rc,Sa as sc,Sb as cc,Sc as oc,CG as yt,D2 as ic,C_ as dc,CC as lc,D0 as uc,CS as mc,CU as Cc,Sd as tr,D8 as Ga,JS as pc,Se as hc,Sf as fc,Sg as gc,Sh as nr,Si as bc,Dv as Sc,CK as rr,CF as je,CJ as yc,Sj as Ic,Sk as kc,BQ as Ec,Sl as sr,ff as cr,Sm as Ac,BS as Dc,BR as Cn,Sn as _c,So as Pc,Sp as wc,Mn as vc,Sq as Tt,Sr as Tc,xC as or,l7 as Fc,hF as xc,DA as Rc,Ss as ir,f2 as Bc,f3 as Lc,St as Oc,di as Uc,fj as jc,Dq as Mc,Dk as qe,bt as Nc,bJ as Vc,cB as Hc,bK as Gc,LA as $c}from"./zeni-epic-state-CkeDRiud.js";import{j as Fe,cm as dr,p as _e,cn as lr,co as ur,cp as zc,D as Xe,_ as Ft,cq as Zc,cr as Wc,W as mr,a as Cr,Z as pr,s as ye,F as le,x as K,aq as ya,cs as hr,ct as Kc,cu as Yc,z as re,B as va,cb as rt,cv as qc,cw as Qc,cx as Jc,cy as Xc,cz as eo,K as Ta,aN as Ze,bo as xt,cA as ao,G as Fa,h as st,m as Rt,d as J,a7 as ct,cB as to,bB as ba,cC as It,cD as no,A as Bt,cE as ro,at as fr,a2 as kt,cF as so,X as gr,f as br,cG as co,cH as oo,cI as io,cJ as lo,cK as uo,cL as mo,o as Ka,cM as Co,cN as po,cO as pt,w as ho,cP as fo,cQ as go,cR as bo,cS as So,cT as yo,a9 as Io}from"./index-CoMuhThK.js";import{n as Ne,D as Sr,S as ko}from"./mui-DcNGd9L2.js";import{a as r}from"./sentry-D_xp3E3Q.js";import{u as xa}from"./useAskAiCfoHostNavButtonProps-Dkub9Q1g.js";import{M as Ie}from"./MobileAppDrawer-DSwbMXYq.js";import{d as Lt}from"./recharts-C0aThBg3.js";import{g as Ae,a as Ra,b as yr,c as xe,d as Re,e as Je,f as ea,h as aa,A as Eo,i as Ot,P as Ao,j as Ut,s as Ia,k as Ir,l as sa,m as kr,n as Do,o as Er,p as _o,S as pn}from"./SetupPagesScreen-Cl6654uo.js";import{u as Ar}from"./useInitialThreadRequest-DKCJ4fRp.js";import ot from"./NotFoundScreen-DaDxz3Zq.js";import{n as hn}from"./utils-BQO84dIV.js";import{t as Po}from"./AddressScreen-kHZ3pkiE.js";import"./analytics-CQmVOD4d.js";import"./plaid-B62punae.js";import"./dnd-CX5suNP6.js";import"./stripe-DMRn4zHo.js";import"./lottie-BY8e0Ufw.js";import"./lexical-BS7d_1CV.js";import"./pdf-BslZhgI8.js";import"./analyticsHelper-BcD2hj7Q.js";import"./routePaths-BqMV9loV.js";import"./BusinessVerificationPageScreen-Ds_dEqcf.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]="be86d683-7e2e-4df6-98b9-db99bc3c52a5",e._sentryDebugIdIdentifier="sentry-dbid-be86d683-7e2e-4df6-98b9-db99bc3c52a5")}catch{}})();const wo=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}},Dr=e=>({id:e.id,isChecked:!1,cardName:e.cardName,last4:e.accountLast4,limitAmount:e.limit?.amount??0,limitCadence:e.creditLimitFrequency?.code,owner:wo(e),utilizationAmount:(e.limit?.amount??0)-(e.available?.amount??0)}),{spendManagement:{chargeCard:{cardPolicyPage:fn}}}=Xe.getLocalizedStrings(),vo=e=>Bn(e,!1),To=e=>Ln(e.name,!1);function Fo(){const e=de(),n=Ce(),{tenantEmailDomain:t}=Me(),a=pe(),s=Fe(),b=Pe(s?.loggedInUserRoleMap),[f,g]=r.useState(!1),_=r.useCallback(T=>{g(T)},[]),i=r.useCallback(()=>{_(!0)},[_]),{isAiCfoAccessEnabled:m,onAskAiCfoClick:B}=xa({mobileExploreReferrer:"Card Policy"});r.useEffect(()=>()=>{a(as()),a(ts()),a(un())},[a]);const D=o(T=>kn(T.cardPolicyState)),d=o(T=>En(T.cardPolicyState)),j=o(T=>An(T.cardPolicyState)),P=o(T=>Dn(T.cardPolicyState)),F=o(T=>_n(T.cardPolicyState)),C=o(T=>Pn(T.cardPolicyState)),h=o(T=>wn(T.cardPolicyState)),w=o(T=>vn(T.cardPolicyState)),u=o(T=>Tn(T.cardPolicyState)),v=o(T=>T.chargeCardConfigState.receiptRequiredAboveAmount.amount),k=o(T=>T.chargeCardConfigState.fetchState);r.useEffect(()=>{D!=="Completed"&&D!=="In-Progress"&&a(Fn())},[a,D]),r.useEffect(()=>{w==="Completed"&&u===""||w==="In-Progress"||a($a())},[a,w,u]);const M=o(T=>xn(T.createCardPolicyState)),A=o(T=>ns(T.createCardPolicyState)),I=o(T=>rs(T.cardPolicyState)),L=o(T=>ss(T.cardPolicyState)),l=o(T=>cs(T.createCardPolicyState)),p=o(T=>Rn(T));r.useEffect(()=>{p.fetchState==="Not-Started"&&a(ca(!1,!1,!1))},[p.fetchState,a]);const N=r.useMemo(()=>d.map(vo),[d]),G=r.useMemo(()=>h.map(To),[h]),O=r.useMemo(()=>p.cards.filter(T=>!dr(T.status.code)).map(Dr),[p.cards]),U=D==="Completed"&&p.fetchState==="Completed"&&k==="Completed";r.useEffect(()=>{U&&l==null&&a(os({cardsMasterList:O,defaultRequireReceiptAmount:v,suggestedAllowMerchants:j,suggestedBlockMerchants:P,suggestedAllowCategories:F,suggestedBlockCategories:C}))},[k,a,U,l,O,v,j,P,F,C]);const z=r.useMemo(()=>Lt(T=>{a($a(T))},250),[a]);r.useEffect(()=>()=>{z.cancel()},[z]);const Z=r.useCallback(T=>{z(T)},[z]),y=M.fetchState,x=t!=null?`/${t}/cards/policy`:"..",W=r.useCallback(()=>{const T=_e(n.state?.pathnameStackToGoBack),ee=T.poppedPathname??x;e(ee,{state:{pathnameStackToGoBack:T.newStack}})},[n.state,e,x]),q=r.useCallback(()=>{e(x)},[e,x]),E=r.useCallback(T=>{a(is(T))},[a]),V=r.useCallback(T=>{const ee=lr(T);a(ds({templates:[ee]}))},[a]),Q=r.useCallback(T=>{T.length!==0&&a(ls(T))},[a]),X=r.useCallback(()=>{a(un())},[a]),S=r.useRef(y);r.useEffect(()=>{const T=S.current;S.current=y,y==="Completed"&&T!=="Completed"&&A!=null&&(a(ze({messageSection:"card_policy_created",messageText:"success",type:"success"})),e(x))},[a,y,A,e,x]);const R=y==="Error"?M.error?.message??fn.createPolicyGenericErrorMessage:void 0;return b&&t!=null?l==null?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:f,handleDrawerToggle:_}),c.jsx(ur,{showUploadDocumentSection:!0,navBarTitle:fn.createPageTitle,onBackClick:W,onClickMenuIcon:i,isAiCfoAccessEnabled:m,onAskAiCfoClick:B})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:f,handleDrawerToggle:_}),c.jsx(zc,{formDraft:l,vendorSearchOptions:G,categorySearchOptions:N,isVendorSearchLoading:w==="In-Progress",onVendorSearchTextChange:Z,submitState:y,submitErrorMessage:R,documentUploadState:I,uploadedFileName:L,isAiCfoAccessEnabled:m,onAskAiCfoClick:B,onBackClick:W,onCancelClick:q,onClickMenuIcon:i,onFormChange:E,onSubmit:V,onUploadDocument:Q,onRemoveDocument:X})]}):c.jsx(Sa,{to:"..",replace:!0})}const{spendManagement:{chargeCard:{cardPolicyPage:xo}}}=Xe.getLocalizedStrings(),Ro=e=>Bn(e,!1),Bo=e=>Ln(e.name,!1);function Lo(){const e=de(),n=Ce(),{tenantEmailDomain:t,templateId:a}=Me(),s=pe(),b=Fe(),f=Pe(b?.loggedInUserRoleMap),[g,_]=r.useState(!1),i=r.useCallback(R=>{_(R)},[]),m=r.useCallback(()=>{i(!0)},[i]),{isAiCfoAccessEnabled:B,onAskAiCfoClick:D}=xa({mobileExploreReferrer:"Card Policy"}),d=o(R=>us(R)),j=o(R=>kn(R.cardPolicyState)),P=o(R=>En(R.cardPolicyState)),F=o(R=>An(R.cardPolicyState)),C=o(R=>Dn(R.cardPolicyState)),h=o(R=>_n(R.cardPolicyState)),w=o(R=>Pn(R.cardPolicyState)),u=o(R=>wn(R.cardPolicyState)),v=o(R=>vn(R.cardPolicyState)),k=o(R=>Tn(R.cardPolicyState)),M=o(R=>Rn(R)),A=o(R=>a!=null?ms(R.cardPolicyState,a):void 0),I=r.useMemo(()=>d.templateId===a&&d.formDraft!=null?d.formDraft:A!=null?Cs(A):void 0,[d.templateId,d.formDraft,A,a]);r.useEffect(()=>{if(a==null)return;const R=d.detailFetchState.fetchState;d.templateId===a&&(R==="Completed"||R==="In-Progress")||A!=null||s(ps(a))},[s,a,d.templateId,d.detailFetchState.fetchState,A]),r.useEffect(()=>{j!=="Completed"&&j!=="In-Progress"&&s(Fn())},[s,j]),r.useEffect(()=>{v==="Completed"&&k===""||v==="In-Progress"||s($a())},[s,v,k]);const L=o(R=>R.chargeCardConfigState.receiptRequiredAboveAmount.amount);r.useEffect(()=>{M.fetchState==="Not-Started"&&s(ca(!1,!1,!1))},[M.fetchState,s]);const l=r.useMemo(()=>P.map(Ro),[P]),p=r.useMemo(()=>u.map(Bo),[u]),N=r.useMemo(()=>M.cards.filter(R=>!dr(R.status.code)).map(Dr),[M.cards]);Ft({isDataReady:I!=null});const G=r.useMemo(()=>{if(I!=null)return Zc({draft:I,cardRows:N,categorySearchOptions:l,vendorSearchOptions:p,defaultRequireReceiptAmount:L,suggestedAllowMerchants:F,suggestedBlockMerchants:C,suggestedAllowCategories:h,suggestedBlockCategories:w})},[I,N,l,p,L,F,C,h,w]),[O,U]=r.useState(void 0),z=r.useRef(!1);r.useEffect(()=>{z.current||O!=null||G==null||(z.current=!0,U(G))},[O,G]);const Z=r.useCallback(R=>{U(R)},[]),y=r.useMemo(()=>Lt(R=>{s($a(R))},250),[s]);r.useEffect(()=>()=>{y.cancel()},[y]);const x=r.useCallback(R=>{y(R)},[y]),W=d.updateFetchState.fetchState,q=t!=null?`/${t}/cards/policy`:"..",E=r.useCallback(()=>{const R=_e(n.state?.pathnameStackToGoBack),T=R.poppedPathname??q;e(T,{state:{pathnameStackToGoBack:R.newStack}})},[n.state,e,q]),V=r.useCallback(()=>{e(q)},[e,q]),Q=r.useCallback(R=>{if(a==null)return;const T=lr(R);s(hs(T)),s(fs(a))},[s,a]),X=r.useRef(W);r.useEffect(()=>{const R=X.current;X.current=W,W==="Completed"&&R!=="Completed"&&(s(ze({messageSection:"card_policy_updated",messageText:"success",type:"success"})),e(q))},[s,W,e,q]);const S=W==="Error"?d.updateFetchState.error?.message??xo.updatePolicyGenericErrorMessage:void 0;return!f||t==null||a==null?c.jsx(Sa,{to:"..",replace:!0}):O!=null&&j==="Completed"&&M.fetchState==="Completed"?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:i}),c.jsx(Wc,{templateName:d.template?.name??"",formDraft:O,vendorSearchOptions:p,categorySearchOptions:l,isVendorSearchLoading:v==="In-Progress",onVendorSearchTextChange:x,submitState:W,submitErrorMessage:S,isAiCfoAccessEnabled:B,onAskAiCfoClick:D,onBackClick:E,onCancelClick:V,onClickMenuIcon:m,onFormChange:Z,onSubmit:Q})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:g,handleDrawerToggle:i}),c.jsx(ur,{showUploadDocumentSection:!1,navBarTitle:d.template?.name,onBackClick:E,onClickMenuIcon:m,isAiCfoAccessEnabled:B,onAskAiCfoClick:D})]})}function _r(e,n,t){return n?e.filter(a=>a!=null&&a.trim().length>0).slice(0,t):[]}function Pr(e){return o(n=>e==null||e===""?{chips:ht,isResolved:!1}:function(t){const a=t?.fetchState,s=a==="Completed"||a==="Error";return{chips:a==="Completed"?t?.suggestedQuestions??ht:ht,isResolved:s}}(gs(n,e)),Dt)}const ht=[],{spendManagement:{chargeCard:{cardPolicyAiCfoHero:{headline:Oo,subheadline:Uo,pageTitle:jo}}}}=Xe.getLocalizedStrings(),Mo=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 No(){const e=de(),n=Ce(),{tenantEmailDomain:t}=Me(),a=pe(),s=Fe(),b=Pe(s?.loggedInUserRoleMap),[f,g]=r.useState(!1),_=r.useCallback(y=>{g(y)},[]),i=r.useCallback(()=>{_(!0)},[_]),{useFeatureGate:m}=le(),{isFeatureEnabled:B}=m(K.isAiCfoFileUploadEnabled),{isFeatureEnabled:D}=m(K.isCardPolicyEnabled),{isAiCfoAccessEnabled:d,onAskAiCfoClick:j}=xa({mobileExploreReferrer:"Card Policy"}),P=o(y=>bs(y)),F=o(y=>xn(y.createCardPolicyState)),C=o(y=>Ss(y.createCardPolicyState)),h=o(y=>C==null?[]:Un(y.aiCfoState,C).filter(x=>x.kind==="creating_policy"),Dt),w=F.fetchState==="In-Progress"?Math.max(h.length,1):0,u=o(y=>ys(y.createCardPolicyState)),v=ya(F.fetchState);r.useEffect(()=>{if(v==="In-Progress"&&F.fetchState==="Completed"&&C!=null)h.forEach(y=>{a(St({chatSessionId:C,id:y.id,entityIds:u,kind:"created_policy"}))});else if(v==="In-Progress"&&F.fetchState==="Error"&&C!=null){h.forEach(x=>{a(St({chatSessionId:C,id:x.id,kind:"errored_policy"}))});const y=F.error?.message!=null&&F.error.message.length>0?F.error.message:Xe.getLocalizedStrings().common.errorMessage.somethingWentWrongPleaseTryAgain;a(ze({messageSection:"card_policy_created",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:y}]}))}},[F.error?.message,F.fetchState,a,C,u,h,v]);const k=P.fetchState.fetchState;r.useEffect(()=>{k!=="Not-Started"&&k!=="Error"||a(Is())},[a,k]);const M=P.archiveFetchState.fetchState,A=ya(M);r.useEffect(()=>{A==="In-Progress"&&M==="Completed"&&a(ze({messageSection:"card_policy_deleted",messageText:"success",type:"success"}))},[M,a,A]);const I=r.useMemo(()=>P.templates.map(Mo),[P.templates]);Ft({isDataReady:P.fetchState.fetchState==="Completed"});const L=I.length>0||w>0,l=function(y){const{hasAnyPolicies:x,isChargeCardAdmin:W,isFileUploadEnabled:q}=y,E=de(),V=Ce(),{tenantEmailDomain:Q}=Me(),{isAiCfoOpen:X,setIsAiCfoOpen:S}=mr(),R=Cr(),T=pr(),ee=o(ce=>On(ce)).createSessionAndSubmitState.fetchState==="In-Progress",{chips:Y,isResolved:ke}=Pr("card_policy"),be=r.useMemo(()=>_r(Y,ke,3),[Y,ke]),[ge,ae]=r.useState(""),ue=T&&R&&Q!=null&&!X,oe=r.useCallback(ce=>{if(Q==null)return;const Ea=ye(V.state?.pathnameStackToGoBack,V.pathname);E(`/${Q}/cards/ask`,{state:{message:"",origin:"",pathnameStackToGoBack:Ea,referrer:"card_policy_hero",aiCfoInitialQuestion:ce,aiCfoShouldSubmit:ce!=null&&ce.trim().length>0}})},[V.pathname,V.state,E,Q]),te=r.useCallback(ce=>{ce.trim().length!==0&&(ae(""),oe(ce))},[oe]),We=r.useCallback(()=>{const ce=ge.trim();ce.length!==0&&(ae(""),oe(ce))},[ge,oe]),Ee=r.useCallback(()=>{},[]),ne=r.useCallback(ce=>{ae(ce)},[]),Ke=r.useCallback(()=>{S(!0)},[S]),Be=r.useCallback(()=>{oe(void 0)},[oe]);return r.useMemo(()=>{if(ue&&!x&&W)return{aiAgentName:jo,headline:Oo,subheadline:Uo,promptChips:be,composer:{currentInput:ge,isSubmitting:ee,isFileUploadEnabled:q,onInputChange:ne,onSubmit:We,onStopSubmit:Ee},onPromptClick:te,onOpenSidePanel:Ke,onOpenFullView:Be,dataTestIdPrefix:"card-policy-ai-cfo-hero"}},[ge,x,ue,W,q,ee,ne,Be,Ke,te,Ee,We,be])}({hasAnyPolicies:L,isChargeCardAdmin:b,isFileUploadEnabled:B}),p=D&&l!=null?c.jsx(hr,{...l}):null,N=d&&p==null,G=r.useCallback(()=>{const y=_e(n.state?.pathnameStackToGoBack),x=y.poppedPathname??"..";e(x,{state:{pathnameStackToGoBack:y.newStack}})},[n.state,e]),O=r.useCallback(()=>{t!=null&&e(`/${t}/cards/policy/new`)},[e,t]),U=r.useCallback(y=>{t!=null&&e(`/${t}/cards/policy/${y}/edit`)},[e,t]),z=r.useCallback(y=>{a(ks(y))},[a]),Z=P.fetchState.fetchState;return!L&&Z!=="Completed"&&Z!=="Error"?c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:f,handleDrawerToggle:_}),c.jsx(Kc,{onBackClick:G,onNewPolicyClick:O,onClickMenuIcon:i,isAiCfoAccessEnabled:d,onAskAiCfoClick:j})]}):c.jsxs(c.Fragment,{children:[c.jsx(Ie,{isAppContentDrawerOpen:f,handleDrawerToggle:_}),c.jsx(Yc,{policies:I,archivingTemplateId:P.archiveTargetTemplateId,pendingCreationCount:w,onBackClick:G,onNewPolicyClick:O,onEditPolicyClick:U,onArchivePolicyClick:z,onClickMenuIcon:i,policyAiCfoHero:p,isAiCfoAccessEnabled:N,onAskAiCfoClick:j})]})}function Vo(){const e=de(),{cardId:n}=Me(),t=pe(),a=re.getSignedInUser(),s=o(Y=>fe(Y)),b=Fe(),f=Pe(b?.loggedInUserRoleMap),{useFeatureGate:g}=le();if(a==null)throw Error("Can't access Add To Wallet Page without signing in...");const[_,i]=r.useState(!1),m=o(Y=>Qa(Y).firstViewAfterActivation);if(n==null)throw Error("Empty card id is not valid...");const B=s.userRole.includes("charge_card_user"),{isFeatureEnabled:D}=g(K.isChargeCardFeatureEnabled),d=!!s.companyChargeCardInfo?.info?.isChargeCardEnabled,{isFeatureEnabled:j}=g(K.isDebitCardFeatureEnabled),P=we(s),F=ve(s),C=Te(j,s),h=s.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,w=xe({isDebitCardFeatureEnabled:j,isBankingOnlyTenant:C}),u=Re({isCardsOnlyTenant:P,isChargeCardFeatureEnabled:D,isBookKeepingTenant:F,isDebitCardProductVisible:w,chargeCardsCreditAccountLimit:h}),v=!!s.companyDebitCardInfo?.info?.isDebitCardEnabled,k=o(Y=>oa(Y,s.companyId)),M=ia(k.controllers),{creditAccount:A,creditAccountRepayment:I}=o(Y=>da(Y)),L=o(Y=>Y.classListState.fetchState),l=!B&&u&&d,p=o(Y=>_t(Y,n,l,u)),[N,G]=r.useState(!1),O=p.chargeCard,U=O?.cardCreatedByUser?.userId,z=o(Y=>U!=null?za(Y.userRoleState,U):void 0),Z=z?.accountingClassIDs[0],y=o(Y=>Z!=null?Za(Y.classState,{classId:Z,reportId:"class_list"}):void 0),x=O?.cardHolderUser?.userId,W=o(Y=>x!=null?za(Y.userRoleState,x):void 0),q=W?.accountingClassIDs[0],E=o(Y=>q!=null?Za(Y.classState,{classId:q,reportId:"class_list"}):void 0),V=O?.type.code==="business_physical_credit_card"||O?.type.code==="business_physical_debit_card",Q=O?.type.code==="business_physical_debit_card";r.useEffect(()=>{m&&_===!1&&V&&(i(!0),setTimeout(()=>{t(Wa()),Q&&t(ze({messageSection:"set_debit_card_pin",messageText:"success",type:"success",showStatusIcon:!0}))},5e3))},[m,_,V,Q]),r.useEffect(()=>{N||p.fetchState==="Completed"||p.fetchState==="In-Progress"||n==null||(G(!0),t(ka(n,l,!1)))},[N,p,n,t]),r.useEffect(()=>{if(p.fetchState==="Completed"&&(V===!1||V&&O?.status?.code!=="active"||O?.cardHolderUserId!==a.userId||m===!1&&_===!1||O?.type.code==="business_physical_debit_card"||O?.type.code==="business_virtual_debit_card")){const Y=Ae(s.tenantEmailDomain,n,a,O,m);e(Y)}},[p.fetchState,m,V]),r.useEffect(()=>{A.fetchState!=="Completed"&&A.fetchState!=="In-Progress"&&u&&d&&f&&t(Qe()),I.fetchState!=="Completed"&&I.fetchState!=="In-Progress"&&u&&d&&f&&t(Pt()),L!=="Completed"&&L!=="In-Progress"&&t(jn())},[A.fetchState,I.fetchState,t,u,d,f,L]);const X=()=>{if(a!=null&&n!=null){t(Wa());const Y=Ae(s.tenantEmailDomain,n,a);e(Y)}},S=O?.type.code==="business_physical_debit_card"||O?.type.code==="business_virtual_debit_card",R=Je(u,w,v,d),T=Ra(u,d,f,A,I),ee=yr(S,p);return p.fetchState!=="Completed"?c.jsx(va,{fetchState:"In-Progress"}):c.jsxs(c.Fragment,{children:[c.jsx(rt,{showConfetti:m}),c.jsx(qc,{onGotItClick:X,isDebitCard:O?.type.code==="business_physical_debit_card",controllerEmails:M,isChargeCardFeatureEnabled:u,isDebitCardFeatureEnabled:w,isDebitCardSetupEnabled:v,isChargeCardSetupEnabled:d,productInformation:R,creditAccountInformation:T,debitAccountInformation:ee,chargeCardDetailView:p,creditAccount:A,classListFetchState:L,creditAccountRepayment:I,cardIssuedByRoles:z?.userRoles,cardIssuedByDepartmentName:y?.className,cardHolderRoles:W?.userRoles,cardHolderDepartmentName:E?.className})]})}const jt=e=>{const{events:n,onEvent:t,onSubscribed:a}=e,s=Qc(),b=r.useRef(t),f=r.useRef(a),g=r.useRef(0);r.useEffect(()=>{b.current=t},[t]),r.useEffect(()=>{f.current=a},[a]);const _=r.useMemo(()=>[...n].sort().join("|"),[n]);r.useEffect(()=>{if(s==null||n.length===0)return;const i=[],m=new Set,B=()=>{if(f.current==null)return;const D=Date.now();D-g.current<5e3||(g.current=D,f.current())};return n.forEach(D=>{const[d,j]=Jc(D);if(j==="")return;const P=s.channel(d),F=h=>{b.current(j,h)};let C;if(P?.subscribed===!0)C=P,C.bind(j,F),m.has(d)||(m.add(d),B()),i.push(()=>{P.unbind(j,F)});else{if(C=P??s.subscribe(d),C.bind(j,F),!m.has(d)){m.add(d);const h=()=>{B()};C.bind("pusher:subscription_succeeded",h),i.push(()=>{C.unbind("pusher:subscription_succeeded",h)})}i.push(()=>{C.unbind(j,F)})}}),()=>{i.forEach(D=>D())}},[s,_])},wr="charge-card-transaction-update",vr="charge-card-transaction-created",Tr="charge-card-transaction-declined",Fr="charge-card-transaction-updated",xr="charge-card-transaction-receipt-uploaded",ma="charge-card-status-update",Mt="charge-card-spending-updated",it="credit-account-balance-updated",dt="charge-card-created",Nt="charge-card-limit-updated",Vt="charge-card-limit-reset",Ht="charge-card-renamed",Ho="charge-card-department-updated",Rr="charge-card-repayment-completed",Br="charge-card-payment-date-updated",Ba="charge-card-cashback-redeemed",La="charge-card-cashback-earned",Ca=(e,n)=>e==null||e===""?[]:n.map(t=>`private-encrypted-${e}.${t}`),Go=[La,Ba],$o=De(function(e){const n=la(e);return{insightsData:n.insight,cashbackByPeriod:n.cashbackByPeriod,uiState:n.uiState,cashbackSummary:n.cashbackSummary}},function(e){return{onColumnSortConfigChanged:(n,t)=>{e(Es({uiState:{sortKey:n,sortOrder:t}}))}}})(eo);function zo(){const e=de(),n=pe(),t=Ce(),a=re.getSignedInUser(),s=o(j=>fe(j)),{useFeatureGate:b}=le(),{isFeatureEnabled:f}=b(K.isCardsCommentingEnabled),[g,_]=r.useState(!1),i=o(j=>la(j)),m=Ar(s.companyId,{clearParams:i.fetchState==="Completed"}),B=r.useCallback(()=>{const j=_e(t.state?.pathnameStackToGoBack),P=j.poppedPathname??Zo(s.tenantEmailDomain);e(P,{state:{pathnameStackToGoBack:j.newStack}})},[e,t,s.tenantEmailDomain]),D=ea(s);if(jt({events:Ca(D,Go),onEvent:j=>{switch(j){case La:case Ba:return void n(_a(!0))}},onSubscribed:()=>{n(_a(!0))}}),r.useEffect(()=>{g||i.fetchState==="Completed"||i.fetchState==="In-Progress"||(_(!0),n(_a()))},[g,i,n]),a==null)throw Error("Can't access cashback detail page without signing in...");const d=i.cashbackSummary?.cashbackEarned?.amount!=null&&i.fetchState!=="Not-Started";return i.fetchState!=="In-Progress"||d?(i.cashbackSummary?.cashbackEarned?.amount??0)===0&&i.fetchState==="Completed"?c.jsx(ot,{}):c.jsx($o,{onBackClick:B,isCardsCommentingEnabled:f,initialOpenThreadRequest:m}):c.jsx(Xc,{onBackClick:B})}const Zo=e=>`/${e}/cards`,Wo={containerWidth:new Fa(100,58)},Ko=({appContent:e})=>{const n=Ta(),t=pe(),a=de(),{cardId:s}=Me(),b=Ce(),{useDynamicConfig:f}=le(),[g,_]=r.useState(!1),[i,m]=r.useState(!1),[B,D]=r.useState(!1),[d,j]=r.useState(!1),P=re.getSignedInUser();if(P==null)throw Error("Can't access onboarding card page without signing in...");const F=o(E=>fe(E));if(s==null)throw Error("Empty card id is not valid...");const{configValue:C}=f(Ze.zeniCardsConfig),h=C.max_charge_card_activation_attempts_by_card_id,w=o(E=>As(E,s)),u=w.chargeCard,v=o(E=>E.chargeCardConfigState.fetchState),{useFeatureGate:k}=le(),{isFeatureEnabled:M}=k(K.isChargeCardFeatureEnabled),{isFeatureEnabled:A}=k(K.isDebitCardFeatureEnabled),I=Te(A,F),L=xe({isDebitCardFeatureEnabled:A,isBankingOnlyTenant:I}),l=!!F.companyChargeCardInfo?.info?.isChargeCardEnabled,p=F.userRole.includes("charge_card_user"),N=we(F),G=ve(F),O=F.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,U=Re({isCardsOnlyTenant:N,isChargeCardFeatureEnabled:M,isBookKeepingTenant:G,isDebitCardProductVisible:L,chargeCardsCreditAccountLimit:O}),z=!p&&U&&l;r.useEffect(()=>{g===!1&&v!=="In-Progress"&&v!=="Completed"&&(t(Ja()),_(!0)),i===!1&&w.fetchState==="Not-Started"&&(m(!0),t(ka(s,z,U)))},[i,w.fetchState,g,v]);const Z=u?.type.code==="business_physical_credit_card"||u?.type.code==="business_physical_debit_card";r.useEffect(()=>{if(w.fetchState==="Completed"){if(B===!1&&(Z===!1||Z&&u?.status?.code!=="inactive"||u?.cardHolderUserId!==P.userId)){const E=Ae(F.tenantEmailDomain,s,P,u,!0),V=ye(b.state?.pathnameStackToGoBack,b.pathname);a(E,{state:{pathnameStackToGoBack:V}})}else if(B&&w.isRefreshingViewInBackground===!1&&u?.status?.code==="active"){t(Ds({chargeCardId:s}));const E=Ae(F.tenantEmailDomain,s,P,u,!0),V=ye(b.state?.pathnameStackToGoBack,b.pathname);t(Xa()),a(E,{state:{pathnameStackToGoBack:V}})}}},[w.fetchState,u?.type.code,B,w.isRefreshingViewInBackground]);const y=re.getZeniOtpTokenForCardHolder(s),x=o(E=>Mn(E.userState,P.userId)),W=()=>{u?.status?.code!=="active"&&t(ga(s,!0))};r.useEffect(()=>{w.updatePhysicalChargeCardAttemptFetchState.fetchState==="Completed"&&u?.cardActivationAttemptHistory.some(E=>E.statusCode==="success")===!0&&B===!1&&(setTimeout(W,3e3),D(!0))},[w.updatePhysicalChargeCardAttemptFetchState.fetchState,u?.cardActivationAttemptHistory]);const q=E=>{j(E)};if(v!=="Completed"||u==null)return c.jsx(va,{fetchState:"In-Progress"});if(u.shippingAddressId==null)throw Error("Can't access shippingAddressId.");if(x?.phone==null)throw Error("Can't access user phone number.");return c.jsxs(Qo,{children:[c.jsx(Ie,{isAppContentDrawerOpen:d,handleDrawerToggle:q}),c.jsx(Yo,{cardId:s,card:u,shippingAddressId:u.shippingAddressId,phone:x.phone,signedInUser:P,isSandboxEnv:xt(),chargeCardDetailState:w,signedInUserToken:y,navigate:a,currentTenant:F,location:b,maxChargeCardActivationAttempts:h[s]!=null?h[s]:C.default_max_charge_card_activation_attempts!=null?C.default_max_charge_card_activation_attempts:3,chargeCardCashbackRatePerTransaction:C.charge_card_cashback_rate_per_transaction!=null?C.charge_card_cashback_rate_per_transaction:.0175,onClickMenuIcon:()=>{q(!0)}}),e!=null?c.jsx(qo,{windowSize:n,children:e}):null]})},Yo=De(function(e,{chargeCardDetailState:n,shippingAddressId:t,location:a,cardId:s}){const b=_s(e.addressState,t);if(b==null)throw Error("Can't access shippingAddress.");const f=Nn(e,s),g=n.updateStatus,_=ua(e,!1,!1,!1);let i=!1;_.fetchState==="Completed"&&_.cards.length<=1&&(i=!0);const m=a.state?.message==="comingFromV2UrlPath";return{showActivatePage:n.chargeCard?.providerCardCreateTime!=null&&n.chargeCard.providerCardCreateTime.add(24,"h").isBefore(Ps())||m,showMenuIcon:i,shippingAddress:b,vgsVaultId:st.cardVaultId,twoFAView:f,activationWaitStatus:g,isRefreshingViewInBackground:n.isRefreshingViewInBackground}},function(e,n){const{navigate:t,cardId:a,location:s,currentTenant:b,chargeCardDetailState:f}=n,g=f.chargeCard?.cardProviderID,{tenantEmailDomain:_}=b;return{onGetOtp:i=>{g!=null&&e(tt(i,"ChargeCardHolder",a))},onUpdatePhysicalChargeCardAttempt:i=>{e(vs(a,i))},onResendOtp:i=>{g!=null&&e(at(i,"ChargeCardHolder",a))},onVerifyOtp:(i,m)=>{g!=null&&e(et(i,m,"ChargeCardHolder",a))},onVerifyOtpSuccess:i=>{i!=null&&re.saveZeniOtpTokenForCardHolder(i,a)},onCVVActivateSuccess:()=>{e(ws({chargeCardId:a}))},onBackClick:()=>{const i=_e(s.state?.pathnameStackToGoBack),m=i.poppedPathname==null||i.poppedPathname.includes("onboard")===!0?aa(_):i.poppedPathname;t(m,{state:{pathnameStackToGoBack:i.newStack}})}}})(ao),qo=Ne.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  width: ${e=>`${Wo.containerWidth.value(e.windowSize)}%`};
@@ -0,0 +1 @@
1
+ import{j as m}from"./liveblocks-BLlSTcoD.js";import{a as g}from"./sentry-D_xp3E3Q.js";import{h as w,u as x,g as k,i as T,j as O,n as E}from"./core-CbpoBsNm.js";import{z as C,b9 as F,A as P,d as A,f as V,af as N,ba as j,at as L,au as U,s as B}from"./index-CoMuhThK.js";import{eW as h,gh as M,to as R,gc as _,c7 as z,OQ as G,bn as Y,rx as $,rl as H,k$ as K,mA as S,OR as Q,bE as W,cz as b,mK as Z,mN as q}from"./zeni-epic-state-CkeDRiud.js";import"./mui-DcNGd9L2.js";import{d as J}from"./routePaths-BqMV9loV.js";import{M as X}from"./MobileAppDrawer-DSwbMXYq.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new t.Error().stack;a&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[a]="8e0d90a5-cb3c-4180-8634-cfdd7cd9260e",t._sentryDebugIdIdentifier="sentry-dbid-8e0d90a5-cb3c-4180-8634-cfdd7cd9260e")}catch{}})();const ee=E(function(t){const a=_(t),i=C.getSignedInUser(),l=h(t),c=l.tenantId,p={userId:i?.userId??"",sessionId:i?.zeniSessionId??"",tenantId:c??""},f=z(l?.userRole??[])&&a.localData.updateStatus.fetchState!=="In-Progress"?void 0:"readonly",e=G(t.companyConfigState),n=t.countryListState?.byCountryListCode?.nationalityCountryList?.countries??[];return{isCompanyVerified:a.companyView?.company?.company?.companyBillPayInfo?.companyVerificationStatus?.code==="verified",companyPassportView:a,allIndustries:e.companyIndustries??[],allNationalityCountries:n,isDisabled:f,authParams:p,filesEndPoint:`${L.fileMicroServiceBaseUrl}`,isZeniUser:Y(i)}},function(t,a){const{companyId:i,currentTenant:l,navigate:c,location:p}=a,{tenantEmailDomain:f}=l;return{onScheduleClick:e=>{let n=e.href;n.includes("http")||(n="https://".concat(n)),window.open(n,"_blank")},onSaveAll:()=>{t(q())},onAddressClick:e=>{const n=J(f,e),o=B(p.state?.pathnameStackToGoBack,p.pathname);c(n,{state:{pathnameStackToGoBack:o}})},onResetClick:()=>{t(Z({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:D}=r,v={companyInfo:{...n,website:u!=""&&u!=null?b(u):void 0,meetingLink:y!=""&&y!=null?b(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?W(s?.toString()):s,fileId:o.fileIds[0]},taxDetails:{taxIdOrEIN:r.taxIdOrEIN,sicCode:r.sicCode,naicsCode:r.naicsCode,dunsNumber:r.dunsNumber,taxesFiledYears:D.selectedOptions.map(I=>parseInt(I)),fileId:r.fileIds[0]}};t(S({companyDetails:v}))},onPrimaryContactDetailsUpdated:e=>{t(S({primaryContact:{userId:e.userId,email:e.email.trim(),firstName:e.name.firstName,lastName:e.name.lastName}}))},onNewCompanyOfficerAdded:e=>{t(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=>{t(Q(e))},onCompanyOfficerUpdated:e=>{t(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=>{t(K({files:e}))},onDeleteFile:e=>{t(H(e))},onEditFileName:(e,n)=>{t($(e,n.split(".")[0]))}}})(j);function de(){const t=w(),a=x(),i=k(),{tenantEmailDomain:l}=T(),[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=>h(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),a(M(d)))},[c,n,d,a]),g.useEffect(()=>{o==="Not-Started"&&a(R())},[o,a]);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(F,{onGoHome:()=>t("../",{replace:!0}),onReload:()=>window.location.reload()}):m.jsxs(m.Fragment,{children:[m.jsx(P,{analytics:A,onLoad:s=>s.trackPageLoaded(V.Event.companyPassport,N(i)?"Settings":"Company Passport")}),N(i)?m.jsx(X,{isAppContentDrawerOpen:f,handleDrawerToggle:u}):null,m.jsx(ee,{companyId:d,navigate:t,location:i,isLoading:y,currentTenant:r,isSettings:N(i),onClickMenuIcon:()=>{u(!0)}})]})}export{de as C};
@@ -1,4 +1,4 @@
1
- import{j as C}from"./liveblocks-B6jAIe9x.js";import{a}from"./sentry-95bdnR3R.js";import{u as D,g as w,j as m,N as v}from"./core-CLKYLs-8.js";import{Lw as _,eW as A,f$ as L,o4 as O,gq as E,f_ as j,fx as U,LD as $}from"./zeni-epic-state-CjQblqOQ.js";import{u as F,z as c,L as g,D as k,o as H}from"./index-D_hiFYsE.js";import{n as z}from"./mui-AZmtqUsi.js";import{t as R}from"./getLocaleForTenant-C_VQis3o.js";import{g as P,Q as q}from"./QBOConnectionScreen-D87ZntTL.js";import"./recharts-CyaYjFwn.js";import"./analytics-BHHyMpuV.js";import"./plaid-2Q72y6JT.js";import"./dnd-BgEYAbRi.js";import"./stripe-DMRn4zHo.js";import"./lottie-C38Bn-X6.js";import"./lexical-DN4b_Twn.js";import"./pdf-BzNDzZ8_.js";import"./utils-CDpOkGne.js";import"./empty-DdtYEopm.js";import"./pdf-lib-0dW_LSbG.js";import"./index-CtRgwYlG.js";import"./url-Br2V-Pa5.js";import"./index-UrW8im9e.js";import"./decodeURIComponentSafe-Bm32N7cj.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]="a98b9efb-d494-4ccb-8a90-62466d009eb4",t._sentryDebugIdIdentifier="sentry-dbid-a98b9efb-d494-4ccb-8a90-62466d009eb4")}catch{}})();const G=z.div`
1
+ import{j as C}from"./liveblocks-BLlSTcoD.js";import{a}from"./sentry-D_xp3E3Q.js";import{u as D,g as w,j as m,N as v}from"./core-CbpoBsNm.js";import{Lw as _,eW as A,f$ as L,o4 as O,gq as E,f_ as j,fx as U,LD as $}from"./zeni-epic-state-CkeDRiud.js";import{u as F,z as c,L as g,D as k,o as H}from"./index-CoMuhThK.js";import{n as z}from"./mui-DcNGd9L2.js";import{t as R}from"./getLocaleForTenant-DvFF548D.js";import{g as P,Q as q}from"./QBOConnectionScreen-BOOiYmna.js";import"./recharts-C0aThBg3.js";import"./analytics-CQmVOD4d.js";import"./plaid-B62punae.js";import"./dnd-CX5suNP6.js";import"./stripe-DMRn4zHo.js";import"./lottie-BY8e0Ufw.js";import"./lexical-BS7d_1CV.js";import"./pdf-BslZhgI8.js";import"./utils-BQO84dIV.js";import"./empty-DhAifQ6-.js";import"./pdf-lib-BxiXr152.js";import"./index-D-GsKzyX.js";import"./url-Cn_1-HsX.js";import"./index-Bg6fgf4p.js";import"./decodeURIComponentSafe-9Mzf3G8U.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]="a98b9efb-d494-4ccb-8a90-62466d009eb4",t._sentryDebugIdIdentifier="sentry-dbid-a98b9efb-d494-4ccb-8a90-62466d009eb4")}catch{}})();const G=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-BLlSTcoD.js";import{z as n}from"./index-CoMuhThK.js";import{g as d}from"./QBOConnectionScreen-BOOiYmna.js";import"./sentry-D_xp3E3Q.js";import{g as p,N as s}from"./core-CbpoBsNm.js";import"./zeni-epic-state-CkeDRiud.js";import"./recharts-C0aThBg3.js";import"./mui-DcNGd9L2.js";import"./analytics-CQmVOD4d.js";import"./plaid-B62punae.js";import"./dnd-CX5suNP6.js";import"./stripe-DMRn4zHo.js";import"./lottie-BY8e0Ufw.js";import"./lexical-BS7d_1CV.js";import"./pdf-BslZhgI8.js";import"./utils-BQO84dIV.js";import"./empty-DhAifQ6-.js";import"./pdf-lib-BxiXr152.js";import"./index-D-GsKzyX.js";import"./url-Cn_1-HsX.js";import"./index-Bg6fgf4p.js";import"./decodeURIComponentSafe-9Mzf3G8U.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};
@@ -1,4 +1,4 @@
1
- import{j as a}from"./liveblocks-B6jAIe9x.js";import{t as Me,A as Ce}from"./AddressScreen-BRdhnUB3.js";import $e from"./NotFoundScreen-ChEBjJeL.js";import{a as g}from"./sentry-95bdnR3R.js";import{h as oe,g as se,u as ie,i as re,j as D,N as x,n as ce,l as ze,o as Qe,p as z}from"./core-CLKYLs-8.js";import{w as de,j as le,z as B,F as ue,m as qe,x as _,r as V,A as Y,c as N,B as je,e as J,ap as Ke,K as Ze,aq as ke,h as te,ar as We,as as Ie,o as Ye,at as He,au as xe,av as Je}from"./index-D_hiFYsE.js";import{bn as Xe,eW as ee,fT as et,fB as pe,fz as me,bt as tt,o2 as at,fP as nt,bS as ot,k3 as ae,k6 as ve,M0 as st,bY as it,c7 as ge,tC as he,tn as rt,Mv as X,tD as _e,JV as ct,l7 as Ue,Mw as Ve,Mx as dt,My as lt,Mz as ut,k1 as pt,k4 as mt,tp as Be,tB as gt,bE as Ee,cz as ht,tP as Te,rx as ft,rl as yt,k$ as St,gf as bt,ge as Ct,gd as kt,MA as It,th as xt,tQ as Et,tT as Tt,tW as Ot,u0 as Pt,cY as At}from"./zeni-epic-state-CjQblqOQ.js";import{n as fe}from"./mui-AZmtqUsi.js";import{g as Dt,h as Ft,q as ne}from"./QBOConnectionScreen-D87ZntTL.js";import"./recharts-CyaYjFwn.js";import"./analytics-BHHyMpuV.js";import"./plaid-2Q72y6JT.js";import"./dnd-BgEYAbRi.js";import"./stripe-DMRn4zHo.js";import"./lottie-C38Bn-X6.js";import"./lexical-DN4b_Twn.js";import"./pdf-BzNDzZ8_.js";import"./utils-CDpOkGne.js";import"./empty-DdtYEopm.js";import"./pdf-lib-0dW_LSbG.js";import"./index-CtRgwYlG.js";import"./url-Br2V-Pa5.js";import"./index-UrW8im9e.js";import"./decodeURIComponentSafe-Bm32N7cj.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]="d1246502-dcdd-4cd0-809c-a5cf74f9ef24",t._sentryDebugIdIdentifier="sentry-dbid-d1246502-dcdd-4cd0-809c-a5cf74f9ef24")}catch{}})();const wt=ce(function(t,o){const s=[];o.isApAgingFeatureEnabled===!1&&s.push("accounts_payable_aging"),o.isArAgingFeatureEnabled===!1&&s.push("accounts_receivable_aging"),o.shouldFetchZeniAccountsPromoCard===!1&&s.push("zeni_accounts_promo_card"),o.shouldFetchRewardsPlanCard===!1&&s.push("rewards_card"),o.isExpenseAutomationEnabledForUser===!1&&s.push("expense_automation_card");const u=nt(t,s,o.signedInUser,o.isExpenseAutomationFeatureEnabledV2,o.isExpenseAutomationEnabledForUser,o.isTreasuryEnabled);return{dashboardFetchState:ot(u.reportsInOrder.map(d=>({fetchState:d.fetchState,error:d.error}))).fetchState}},function(t,o){const{themeState:s,navigate:u,location:d}=o;return{onZeniLogoClick:()=>{s.toggle()},onDashboardFetchDone:()=>{const r=V(d.state?.pathnameStackToGoBack,d.pathname);u("../../dashboard",{state:{pathnameStackToGoBack:r,message:"activation"}})}}})(Ke),jt=()=>{const t=oe(),o=se(),s=ie(),u=de(),[d,r]=g.useState(!1),[p,S]=g.useState(!1),{tenantEmailDomain:e}=re(),n=le(),i=B.getSignedInUser(),h=Xe(i),{useFeatureGate:m}=ue(),I=qe(),{isFeatureEnabled:E}=m(_.isApAgingFeatureEnabled),{isFeatureEnabled:T}=m(_.isArAgingFeatureEnabled),{isFeatureEnabled:k}=m(_.isDepositAccountsFeatureEnabled),{isFeatureEnabled:f}=m(_.isReferralFeatureEnabled),{isFeatureEnabled:U}=m(_.isExpenseAutomationEnabled),{isFeatureEnabled:C}=m(_.isExpenseAutomationEnabledV2),{isFeatureEnabled:F}=m(_.isDebitCardFeatureEnabled),M=C||U&&h,c=D(l=>ee(l)),{isFeatureEnabled:L}=m(_.isTreasuryEnabled),w=c.company!=null&&et(c.company),R=L&&w,O=D(l=>l.onboardingCustomerViewState.fetchState),b=c.excludedResources,G=c.companyId??B.getSignedInUserTenant(e)?.companyId;if(i==null)throw Error("Can't access onboarding flow without signing in...");const j=pe(F,c),P=me(c),A=[],K=b?.resources?.find(l=>l.resource==="/reports/top_expenses")==null,$=b?.resources?.find(l=>l.resource==="/reports/task_card")==null,Q=c?.userRole!=null&&tt(c?.userRole),v=b?.resources?.find(l=>l.resource==="/bills")==null&&!Q,q=b?.resources?.find(l=>l.resource==="/reimbursements")==null;if(K===!1&&A.push("top_expenses"),$===!1&&A.push("task_card"),v===!1&&A.push("bill_pay_card","bill_pay_promo_card"),q===!1&&A.push("reimbursement_card","reimbursement_promo_card"),k===!1&&A.push("zeni_accounts_promo_card"),f===!1&&A.push("rewards_card"),g.useEffect(()=>{O!=="Completed"||d||j||P||(r(!0),s(at(i.userId,G,c.tenantId,!0,!1,A)))},[d,O,j,P,i,c.tenantId,s]),g.useEffect(()=>{(j||P)&&setTimeout(()=>{S(!0)},5e3)},[j,P]),O!=="Completed")return a.jsx(x,{to:"../"});if(O==="Completed"&&p){const l=V(o.state?.pathnameStackToGoBack,o.pathname);if(j)return a.jsx(x,{to:"../../checking",state:{...o.state,pathnameStackToGoBack:l,message:"activation"}});if(P)return a.jsx(x,{to:"../../cards",state:{...o.state,pathnameStackToGoBack:l,message:"activation"}})}return n?.loggedInUserRoleMap!=null?a.jsxs(a.Fragment,{children:[a.jsx(Y,{analytics:N,onLoad:l=>(Z=>Z.trackPageLoaded(J.Event.onboardingDashboardActivation))(l)}),a.jsx(wt,{navigate:t,location:o,themeState:u,signedInUser:i,isApAgingFeatureEnabled:E,isArAgingFeatureEnabled:T,shouldFetchZeniAccountsPromoCard:k,shouldFetchRewardsPlanCard:f,isExpenseAutomationEnabledForUser:M,isExpenseAutomationFeatureEnabledV2:C,isTreasuryEnabled:R,loggedInUserRoleMap:n?.loggedInUserRoleMap})]}):a.jsx(je,{fetchState:"In-Progress",style:{backgroundColor:I.colors.grey5}})},Oe=fe.div`
1
+ import{j as a}from"./liveblocks-BLlSTcoD.js";import{t as Me,A as Ce}from"./AddressScreen-kHZ3pkiE.js";import $e from"./NotFoundScreen-DaDxz3Zq.js";import{a as g}from"./sentry-D_xp3E3Q.js";import{h as oe,g as se,u as ie,i as re,j as D,N as x,n as ce,l as ze,o as Qe,p as z}from"./core-CbpoBsNm.js";import{w as de,j as le,z as B,F as ue,m as qe,x as _,s as V,A as Y,d as N,B as je,f as J,ap as Ke,K as Ze,aq as ke,h as te,ar as We,as as Ie,o as Ye,at as He,au as xe,av as Je}from"./index-CoMuhThK.js";import{bn as Xe,eW as ee,fT as et,fB as pe,fz as me,bt as tt,o2 as at,fP as nt,bS as ot,k3 as ae,k6 as ve,M0 as st,bY as it,c7 as ge,tC as he,tn as rt,Mv as X,tD as _e,JV as ct,l7 as Ue,Mw as Ve,Mx as dt,My as lt,Mz as ut,k1 as pt,k4 as mt,tp as Be,tB as gt,bE as Ee,cz as ht,tP as Te,rx as ft,rl as yt,k$ as bt,gf as St,ge as Ct,gd as kt,MA as It,th as xt,tQ as Et,tT as Tt,tW as Ot,u0 as Pt,cY as At}from"./zeni-epic-state-CkeDRiud.js";import{n as fe}from"./mui-DcNGd9L2.js";import{g as Dt,h as Ft,q as ne}from"./QBOConnectionScreen-BOOiYmna.js";import"./recharts-C0aThBg3.js";import"./analytics-CQmVOD4d.js";import"./plaid-B62punae.js";import"./dnd-CX5suNP6.js";import"./stripe-DMRn4zHo.js";import"./lottie-BY8e0Ufw.js";import"./lexical-BS7d_1CV.js";import"./pdf-BslZhgI8.js";import"./utils-BQO84dIV.js";import"./empty-DhAifQ6-.js";import"./pdf-lib-BxiXr152.js";import"./index-D-GsKzyX.js";import"./url-Cn_1-HsX.js";import"./index-Bg6fgf4p.js";import"./decodeURIComponentSafe-9Mzf3G8U.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]="3b82e2b7-5c4e-4963-ba3e-df7c002263b1",t._sentryDebugIdIdentifier="sentry-dbid-3b82e2b7-5c4e-4963-ba3e-df7c002263b1")}catch{}})();const wt=ce(function(t,o){const s=[];o.isApAgingFeatureEnabled===!1&&s.push("accounts_payable_aging"),o.isArAgingFeatureEnabled===!1&&s.push("accounts_receivable_aging"),o.shouldFetchZeniAccountsPromoCard===!1&&s.push("zeni_accounts_promo_card"),o.shouldFetchRewardsPlanCard===!1&&s.push("rewards_card"),o.isExpenseAutomationEnabledForUser===!1&&s.push("expense_automation_card");const u=nt(t,s,o.signedInUser,o.isExpenseAutomationFeatureEnabledV2,o.isExpenseAutomationEnabledForUser,o.isTreasuryEnabled);return{dashboardFetchState:ot(u.reportsInOrder.map(d=>({fetchState:d.fetchState,error:d.error}))).fetchState}},function(t,o){const{themeState:s,navigate:u,location:d}=o;return{onZeniLogoClick:()=>{s.toggle()},onDashboardFetchDone:()=>{const r=V(d.state?.pathnameStackToGoBack,d.pathname);u("../../dashboard",{state:{pathnameStackToGoBack:r,message:"activation"}})}}})(Ke),jt=()=>{const t=oe(),o=se(),s=ie(),u=de(),[d,r]=g.useState(!1),[p,b]=g.useState(!1),{tenantEmailDomain:e}=re(),n=le(),i=B.getSignedInUser(),h=Xe(i),{useFeatureGate:m}=ue(),I=qe(),{isFeatureEnabled:E}=m(_.isApAgingFeatureEnabled),{isFeatureEnabled:T}=m(_.isArAgingFeatureEnabled),{isFeatureEnabled:k}=m(_.isDepositAccountsFeatureEnabled),{isFeatureEnabled:f}=m(_.isReferralFeatureEnabled),{isFeatureEnabled:U}=m(_.isExpenseAutomationEnabled),{isFeatureEnabled:C}=m(_.isExpenseAutomationEnabledV2),{isFeatureEnabled:F}=m(_.isDebitCardFeatureEnabled),M=C||U&&h,c=D(l=>ee(l)),{isFeatureEnabled:L}=m(_.isTreasuryEnabled),w=c.company!=null&&et(c.company),R=L&&w,O=D(l=>l.onboardingCustomerViewState.fetchState),S=c.excludedResources,G=c.companyId??B.getSignedInUserTenant(e)?.companyId;if(i==null)throw Error("Can't access onboarding flow without signing in...");const j=pe(F,c),P=me(c),A=[],K=S?.resources?.find(l=>l.resource==="/reports/top_expenses")==null,$=S?.resources?.find(l=>l.resource==="/reports/task_card")==null,Q=c?.userRole!=null&&tt(c?.userRole),v=S?.resources?.find(l=>l.resource==="/bills")==null&&!Q,q=S?.resources?.find(l=>l.resource==="/reimbursements")==null;if(K===!1&&A.push("top_expenses"),$===!1&&A.push("task_card"),v===!1&&A.push("bill_pay_card","bill_pay_promo_card"),q===!1&&A.push("reimbursement_card","reimbursement_promo_card"),k===!1&&A.push("zeni_accounts_promo_card"),f===!1&&A.push("rewards_card"),g.useEffect(()=>{O!=="Completed"||d||j||P||(r(!0),s(at(i.userId,G,c.tenantId,!0,!1,A)))},[d,O,j,P,i,c.tenantId,s]),g.useEffect(()=>{(j||P)&&setTimeout(()=>{b(!0)},5e3)},[j,P]),O!=="Completed")return a.jsx(x,{to:"../"});if(O==="Completed"&&p){const l=V(o.state?.pathnameStackToGoBack,o.pathname);if(j)return a.jsx(x,{to:"../../checking",state:{...o.state,pathnameStackToGoBack:l,message:"activation"}});if(P)return a.jsx(x,{to:"../../cards",state:{...o.state,pathnameStackToGoBack:l,message:"activation"}})}return n?.loggedInUserRoleMap!=null?a.jsxs(a.Fragment,{children:[a.jsx(Y,{analytics:N,onLoad:l=>(Z=>Z.trackPageLoaded(J.Event.onboardingDashboardActivation))(l)}),a.jsx(wt,{navigate:t,location:o,themeState:u,signedInUser:i,isApAgingFeatureEnabled:E,isArAgingFeatureEnabled:T,shouldFetchZeniAccountsPromoCard:k,shouldFetchRewardsPlanCard:f,isExpenseAutomationEnabledForUser:M,isExpenseAutomationFeatureEnabledV2:C,isTreasuryEnabled:R,loggedInUserRoleMap:n?.loggedInUserRoleMap})]}):a.jsx(je,{fetchState:"In-Progress",style:{backgroundColor:I.colors.grey5}})},Oe=fe.div`
2
2
  display: flex;
3
3
  height: 100vh;
4
4
  background-color: ${t=>t.theme.colors.grey4};
@@ -16,8 +16,8 @@ import{j as a}from"./liveblocks-B6jAIe9x.js";import{t as Me,A as Ce}from"./Addre
16
16
  }
17
17
 
18
18
  ${t=>t.windowSize!=="small"?"overflow: auto;":""}
19
- `,Ae=ce(function(t,o){const{companyId:s,isAdmin:u,currentTenant:d,isOnAddressPage:r}=o,p=B.getSignedInUser(),S=d.tenantId,e={userId:p?.userId??"",sessionId:p?.zeniSessionId??"",tenantId:S??""},n=ee(t),i=he(t,s),h=Ve(t),m=ge(d?.userRole??[])&&i.updateStatus.fetchState!=="In-Progress"?void 0:"readonly",I=dt(t.userRoleConfigState);return{onboardingCustomerView:i,analytics:N,isRefreshingViewInBackground:!1,isDisabled:m,companyTitles:I.companyTitles,connectedAccountProvider:n.company?.featuresActivationInfo.connectedAccountProvider??"",fileProps:{filesEndPoint:He.fileMicroServiceBaseUrl,authParams:e},signedInUser:B.getSignedInUser(),currentTenant:d,isAdmin:u,isOnAddressPage:r,meetingUrl:"https://meetings.hubspot.com/niharn/zeni-onboarding-overview?embed=true",cardPaymentView:h,isCardPaymentPopupOpen:!1,stripeKey:te.stripeKey}},function(t,o){const{companyId:s,currentTenant:u,themeState:d,navigate:r,location:p}=o,{tenantEmailDomain:S}=u;return{onFetchLinkTokenClick:(e,n)=>{t(Pt(e,n))},onEstablishConnectionClick:(e,n)=>{t(Ot(e,n))},onUpdatePaymentAccountStatus:(e,n,i)=>{t(Tt(e,n,i))},onUpdatePaymentAccountLoginStatus:(e,n)=>{t(Et(!1,e,n))},onEstablishConnectionSuccess:()=>{t(xt(s,!0,!1))},handleOnConnectClick:()=>{N.trackOnboardingConnectQBO(),ne.handleClick()},updateQBOPopupState:e=>{t(X({isQBOPopupOpen:e}))},onCompanyOfficerUpdated:e=>{const n=e.map(i=>{const{officerType:h,userId:m,name:I,email:E,ssn:T,nationalityCountryCode:k,dob:f,phone:U,syncToken:C,selectDocument:F,role:M,ownership:c,isSelectedForVerification:L,userVerificationStatus:w,fileIds:R,isPhoneVerified:O}=i;let b;return F.selectDocumentType==="driverLicense"?b="driving_license":F.selectDocumentType==="passport"?b="passport":F.selectDocumentType==="stateId"?b="id_document":F.selectDocumentType==="ssnCard"&&(b="social_security_card"),{officerType:h,userId:m,firstName:I.firstName,lastName:I.lastName,email:E,ssn:T,nationalityCountryCode:k?.selectedOption!=null?xe(k.selectedOption):void 0,phone:U,birthday:f!=null?Ee(f?.toString()):f,syncToken:C,titleAtCompany:M.selectedOption,ownershipInCompany:c,documentTypeSelectedForVerification:b,isSelectedForVerification:L,userVerificationStatus:w,fileIds:R,additionalDocumentTypesRequestedForVerification:[],additionalSubmittedDocumentsForVerificationFileIds:[],areAdditionalDocumentsRequestedForVerification:!1,areAdditionalDocumentsSubmittedForVerification:!1,isPhoneVerified:O}});t(Te({officers:n}))},onGetOtp:(e,n)=>{t(kt(e,"CustomerOnboarding")),n!=null&&t(It({officerType:n,phone:e}))},onResendOtp:e=>{t(Ct(e,"CustomerOnboarding"))},onVerifyOtp:(e,n)=>{t(bt(e,n,"CustomerOnboarding"))},updateFilesEntity:e=>{t(St({files:e}))},onDeleteFile:e=>{t(yt(e))},onEditFileName:(e,n)=>{t(ft(e,n.split(".")[0]))},onCompanyDetailsChanged:e=>{const{companyDescription:n,companyIndustry:i,companyIndustryType:h,companyLegalName:m,companyTaxId:I,companyWebsite:E,companyPhone:T,primaryContactEmail:k,primaryContactName:f,primaryContactUserId:U,primaryContactSyncToken:C,syncToken:F,fileIds:M,typeOfIncorporation:c,stateOfIncorporation:L,incDate:w,companySourceOfFunds:R,companySourceOfFundsDescription:O,companySubIndustry:b,countriesOfOperations:G,purposeOfAccount:j,purposeOfAccountDescription:P,regulatedStatus:A,regulatedStatusDescription:K,transactionVolume:$,transactionVolumeDescription:Q,usNexus:v,usNexusTypes:q}=e,l={companyId:s,companyDescription:n,companyIndustry:i.selectedOption,companyIndustryType:h?.selectedOption??"",companyLegalName:m,taxIdOrEIN:I,website:E!=""&&E!=null?ht(E):void 0,phone:T,syncToken:F,fileIds:M,incDate:w!=null?Ee(w?.toString()):w,typeOfIncorporation:c?.selectedOption??"",stateOfIncorporation:L?.selectedOption??"",companySourceOfFunds:R?.selectedOption??"",companySourceOfFundsDescription:O,companySubIndustry:b?.selectedOption??"",countriesOfOperations:G?.selectedOptions.map(W=>W.length===2?W:xe(W))??[],purposeOfAccount:j?.selectedOption??"",purposeOfAccountDescription:P,regulatedStatus:A??"",regulatedStatusDescription:K,transactionVolume:$?.selectedOption??"",transactionVolumeDescription:Q,usNexus:v,usNexusTypes:q?.selectedOptions??[]},Z={userId:U,firstName:f.firstName,lastName:f.lastName,email:k,syncToken:C};t(Te({companyDetails:l,primaryContactDetails:Z}))},onAddressClick:(e,n)=>{const i=De(S,e,n),h=V(p.state?.pathnameStackToGoBack,p.pathname);r(i,{state:{pathnameStackToGoBack:h}})},onRegisteredAddressClick:(e,n)=>{const i=De(S,e,n),h=V(p.state?.pathnameStackToGoBack,p.pathname);r(i,{state:{pathnameStackToGoBack:h}})},onUpdateCustomerView:(e,n,i)=>{t(gt(s,!1,n,i,e))},onAddressEditHandler:e=>{if(e!=null){const n=Me(e);t(Ue({addressType:"subscription_billing_address",addressToCreate:n}))}},onSkipSetupClick:()=>{const e=V(p.state?.pathnameStackToGoBack,p.pathname);t(Be(s,!1,!1)),r("./activation",{state:{pathnameStackToGoBack:e}})},onUpdateStep:e=>{t(_e({step:e}))},onZeniLogoClick:()=>{d.toggle()},handleLogOutClick:()=>{const e=V(p.state?.pathnameStackToGoBack,p.pathname);r("/signout",{replace:!0,state:{pathnameStackToGoBack:e,message:"logout"}})},handleCockpitClick:()=>{window.open("/cockpit")},handleCreateCardSetupIntent:e=>{t(ve(e))},handleConfirmCardSetupIntent:e=>{t(mt(e))},updateCardPaymentModalState:e=>{t(X({isCardPaymentPopupOpen:e}))},handleAddCardPaymentSource:(e,n,i)=>{t(pt(e,n,i))},handleFetchPaymentSources:()=>{t(ae())},resetCardPaymentViewState:()=>{t(ut())},handleResetCardPaymentErrorStatuses:()=>{t(lt())},redirectToProductSuitePage:()=>{const e=V(p.state?.pathnameStackToGoBack,p.pathname);r(`/${S}/onboarding/thankyou`,{state:{pathnameStackToGoBack:e,message:"OnboardingThankyou"},replace:!0})}}})(We),H=({taxCFOCustomer:t=!1,isOnAddressPage:o=!1,appContent:s})=>{const u=oe(),d=se(),r=ie(),p=Ze(),S=de(),[e,n]=g.useState(!1),[i,h]=g.useState(!1),[m,I]=g.useState(!1),{tenantEmailDomain:E}=re(),T=le(),{useFeatureGate:k}=ue(),{isFeatureEnabled:f}=k(_.isDebitCardFeatureEnabled),U=ze("/:tenantEmailDomain/onboarding")!==null&&d.search?.includes("code"),C=D(y=>y.onboardingCustomerViewState.fetchState),F=D(y=>y.onboardingCustomerViewState.currentStep),M=D(y=>y.onboardingCustomerViewState.uiState),c=D(y=>ee(y)),L=D(y=>y.userRoleConfigState.fetchState),w=D(y=>y.cardPaymentViewState),R=ke(w.addCardPaymentSourceStatus.fetchState),O=w.addCardPaymentSourceStatus.fetchState,{code:b,realmId:G,state:j}=Dt(d.search),P=c.externalConnections?.accounting[0],A=P?.connectionType,K=P?.connectionName,$=P?.connectionId??"",Q=B.getSignedInUser()?.userId??"";g.useEffect(()=>{i||(h(!0),r(ae()))},[i,r]),g.useEffect(()=>{m||(ve(["card"]),I(!0))},[m]),g.useEffect(()=>{R==="In-Progress"&&O==="Completed"&&r(ae())},[R,O]),g.useEffect(()=>{Ft(b,G,j,$,Q)===!0&&c.externalConnections?.saveConnectionState!=="In-Progress"&&C==="Completed"&&(r(st(c.tenantId,{connection_type:A??"accounting",connection_name:K??"quickbooks_online",authorization_code:b,realm_id:G,connection_id:$,user_id:Q},it(window.location.origin+"/onboarding/auth"))),N.trackOnboardingSaveQBOConnection(G,$),u(d.pathname))},[b,G,j,d.pathname,C]),g.useEffect(()=>{ne.isInitiated===!1&&C==="Completed"&&ne.init("/onboarding/auth",c.tenantEmailDomain)},[C]);const v=c.companyId??B.getSignedInUserTenant(E)?.companyId,q=ge(c?.userRole??[]),l=D(y=>he(y,v));g.useEffect(()=>{e||C!=="Not-Started"||v==null||(n(!0),r(rt(v,!0,!U)))},[e,C,v]),g.useEffect(()=>{c.externalConnections?.saveConnectionState!=="Completed"&&c.externalConnections?.saveConnectionState!=="Error"||!M.isQBOPopupOpen||F!=="qbo_connection"||r(X({isQBOPopupOpen:!1}))},[c.externalConnections?.saveConnectionState]),g.useEffect(()=>{C==="Completed"&&U&&(r(_e({step:"qbo_connection"})),r(X({isQBOPopupOpen:!0})))},[U,C]),g.useEffect(()=>{L==="Not-Started"&&r(ct(!0))},[L,r]);const Z=ke(l.companyDetailsLocalData?.addressStatus);g.useEffect(()=>{l.companyDetailsLocalData?.registeredAddressStatus?.addressToCreate==null&&l.companyDetailsLocalData?.addressStatus?.addressToCreate!=null&&Z==null&&r(Ue({addressType:"company_registered_address",addressToCreate:l.companyDetailsLocalData?.addressStatus?.addressToCreate}))},[l.companyDetailsLocalData?.addressStatus?.addressToCreate,l.companyDetailsLocalData?.registeredAddressStatus?.addressToCreate]);const W=l.isInterimEmailSent;if(B.getSignedInUser()==null)throw Error("Can't access onboarding flow without signing in...");const Le=pe(f,c),Re=me(c),ye=c.company?.companyOnboardingInfo.isOnboardingCompleted,Se=y=>y.trackPageLoaded(J.Event.onboardingPage),be=c.productSettings.isOtherProductsEnabled,Ge=c.productSettings.isTreasuryEnabled;if(ye===!0){if(!be)return Ge?a.jsx(x,{to:"../../treasury"}):Le?a.jsx(x,{to:"../../checking"}):Re?a.jsx(x,{to:"../../cards"}):a.jsx(x,{to:"../../dashboard"});const y=l.updateStatus.fetchState==="In-Progress";if(be&&!y)return t?a.jsxs(Oe,{children:[a.jsx(Y,{analytics:N,onLoad:Ne=>Se(Ne)}),a.jsx(Ae,{navigate:u,location:d,companyId:v,currentTenant:c,isAdmin:q,isOnAddressPage:o,themeState:S,googleAPIKey:te.googleMapsAPIKey}),s!=null?a.jsx(Pe,{windowSize:p,children:s}):null]}):a.jsx(x,{to:"../../onboarding/thankyou"})}else if(ye===!1&&T?.loggedInUserRoleMap!=null)return W===!0?a.jsx(x,{to:"../../onboarding/thankyou"}):a.jsxs(Oe,{children:[a.jsx(Y,{analytics:N,onLoad:y=>Se(y)}),a.jsx(Ae,{navigate:u,location:d,companyId:v,currentTenant:c,isAdmin:q,isOnAddressPage:o,themeState:S,googleAPIKey:te.googleMapsAPIKey}),s!=null?a.jsx(Pe,{windowSize:p,children:s}):null]});return null};function De(t,o,s){let u=`/${t}/onboarding/address`;return u=s!=null?u.concat(`/edit/${o}/${encodeURIComponent(s)}`):u.concat(`/new/${o}`),u}const Fe=fe.div`
19
+ `,Ae=ce(function(t,o){const{companyId:s,isAdmin:u,currentTenant:d,isOnAddressPage:r}=o,p=B.getSignedInUser(),b=d.tenantId,e={userId:p?.userId??"",sessionId:p?.zeniSessionId??"",tenantId:b??""},n=ee(t),i=he(t,s),h=Ve(t),m=ge(d?.userRole??[])&&i.updateStatus.fetchState!=="In-Progress"?void 0:"readonly",I=dt(t.userRoleConfigState);return{onboardingCustomerView:i,analytics:N,isRefreshingViewInBackground:!1,isDisabled:m,companyTitles:I.companyTitles,connectedAccountProvider:n.company?.featuresActivationInfo.connectedAccountProvider??"",fileProps:{filesEndPoint:He.fileMicroServiceBaseUrl,authParams:e},signedInUser:B.getSignedInUser(),currentTenant:d,isAdmin:u,isOnAddressPage:r,meetingUrl:"https://meetings.hubspot.com/niharn/zeni-onboarding-overview?embed=true",cardPaymentView:h,isCardPaymentPopupOpen:!1,stripeKey:te.stripeKey}},function(t,o){const{companyId:s,currentTenant:u,themeState:d,navigate:r,location:p}=o,{tenantEmailDomain:b}=u;return{onFetchLinkTokenClick:(e,n)=>{t(Pt(e,n))},onEstablishConnectionClick:(e,n)=>{t(Ot(e,n))},onUpdatePaymentAccountStatus:(e,n,i)=>{t(Tt(e,n,i))},onUpdatePaymentAccountLoginStatus:(e,n)=>{t(Et(!1,e,n))},onEstablishConnectionSuccess:()=>{t(xt(s,!0,!1))},handleOnConnectClick:()=>{N.trackOnboardingConnectQBO(),ne.handleClick()},updateQBOPopupState:e=>{t(X({isQBOPopupOpen:e}))},onCompanyOfficerUpdated:e=>{const n=e.map(i=>{const{officerType:h,userId:m,name:I,email:E,ssn:T,nationalityCountryCode:k,dob:f,phone:U,syncToken:C,selectDocument:F,role:M,ownership:c,isSelectedForVerification:L,userVerificationStatus:w,fileIds:R,isPhoneVerified:O}=i;let S;return F.selectDocumentType==="driverLicense"?S="driving_license":F.selectDocumentType==="passport"?S="passport":F.selectDocumentType==="stateId"?S="id_document":F.selectDocumentType==="ssnCard"&&(S="social_security_card"),{officerType:h,userId:m,firstName:I.firstName,lastName:I.lastName,email:E,ssn:T,nationalityCountryCode:k?.selectedOption!=null?xe(k.selectedOption):void 0,phone:U,birthday:f!=null?Ee(f?.toString()):f,syncToken:C,titleAtCompany:M.selectedOption,ownershipInCompany:c,documentTypeSelectedForVerification:S,isSelectedForVerification:L,userVerificationStatus:w,fileIds:R,additionalDocumentTypesRequestedForVerification:[],additionalSubmittedDocumentsForVerificationFileIds:[],areAdditionalDocumentsRequestedForVerification:!1,areAdditionalDocumentsSubmittedForVerification:!1,isPhoneVerified:O}});t(Te({officers:n}))},onGetOtp:(e,n)=>{t(kt(e,"CustomerOnboarding")),n!=null&&t(It({officerType:n,phone:e}))},onResendOtp:e=>{t(Ct(e,"CustomerOnboarding"))},onVerifyOtp:(e,n)=>{t(St(e,n,"CustomerOnboarding"))},updateFilesEntity:e=>{t(bt({files:e}))},onDeleteFile:e=>{t(yt(e))},onEditFileName:(e,n)=>{t(ft(e,n.split(".")[0]))},onCompanyDetailsChanged:e=>{const{companyDescription:n,companyIndustry:i,companyIndustryType:h,companyLegalName:m,companyTaxId:I,companyWebsite:E,companyPhone:T,primaryContactEmail:k,primaryContactName:f,primaryContactUserId:U,primaryContactSyncToken:C,syncToken:F,fileIds:M,typeOfIncorporation:c,stateOfIncorporation:L,incDate:w,companySourceOfFunds:R,companySourceOfFundsDescription:O,companySubIndustry:S,countriesOfOperations:G,purposeOfAccount:j,purposeOfAccountDescription:P,regulatedStatus:A,regulatedStatusDescription:K,transactionVolume:$,transactionVolumeDescription:Q,usNexus:v,usNexusTypes:q}=e,l={companyId:s,companyDescription:n,companyIndustry:i.selectedOption,companyIndustryType:h?.selectedOption??"",companyLegalName:m,taxIdOrEIN:I,website:E!=""&&E!=null?ht(E):void 0,phone:T,syncToken:F,fileIds:M,incDate:w!=null?Ee(w?.toString()):w,typeOfIncorporation:c?.selectedOption??"",stateOfIncorporation:L?.selectedOption??"",companySourceOfFunds:R?.selectedOption??"",companySourceOfFundsDescription:O,companySubIndustry:S?.selectedOption??"",countriesOfOperations:G?.selectedOptions.map(W=>W.length===2?W:xe(W))??[],purposeOfAccount:j?.selectedOption??"",purposeOfAccountDescription:P,regulatedStatus:A??"",regulatedStatusDescription:K,transactionVolume:$?.selectedOption??"",transactionVolumeDescription:Q,usNexus:v,usNexusTypes:q?.selectedOptions??[]},Z={userId:U,firstName:f.firstName,lastName:f.lastName,email:k,syncToken:C};t(Te({companyDetails:l,primaryContactDetails:Z}))},onAddressClick:(e,n)=>{const i=De(b,e,n),h=V(p.state?.pathnameStackToGoBack,p.pathname);r(i,{state:{pathnameStackToGoBack:h}})},onRegisteredAddressClick:(e,n)=>{const i=De(b,e,n),h=V(p.state?.pathnameStackToGoBack,p.pathname);r(i,{state:{pathnameStackToGoBack:h}})},onUpdateCustomerView:(e,n,i)=>{t(gt(s,!1,n,i,e))},onAddressEditHandler:e=>{if(e!=null){const n=Me(e);t(Ue({addressType:"subscription_billing_address",addressToCreate:n}))}},onSkipSetupClick:()=>{const e=V(p.state?.pathnameStackToGoBack,p.pathname);t(Be(s,!1,!1)),r("./activation",{state:{pathnameStackToGoBack:e}})},onUpdateStep:e=>{t(_e({step:e}))},onZeniLogoClick:()=>{d.toggle()},handleLogOutClick:()=>{const e=V(p.state?.pathnameStackToGoBack,p.pathname);r("/signout",{replace:!0,state:{pathnameStackToGoBack:e,message:"logout"}})},handleCockpitClick:()=>{window.open("/cockpit")},handleCreateCardSetupIntent:e=>{t(ve(e))},handleConfirmCardSetupIntent:e=>{t(mt(e))},updateCardPaymentModalState:e=>{t(X({isCardPaymentPopupOpen:e}))},handleAddCardPaymentSource:(e,n,i)=>{t(pt(e,n,i))},handleFetchPaymentSources:()=>{t(ae())},resetCardPaymentViewState:()=>{t(ut())},handleResetCardPaymentErrorStatuses:()=>{t(lt())},redirectToProductSuitePage:()=>{const e=V(p.state?.pathnameStackToGoBack,p.pathname);r(`/${b}/onboarding/thankyou`,{state:{pathnameStackToGoBack:e,message:"OnboardingThankyou"},replace:!0})}}})(We),H=({taxCFOCustomer:t=!1,isOnAddressPage:o=!1,appContent:s})=>{const u=oe(),d=se(),r=ie(),p=Ze(),b=de(),[e,n]=g.useState(!1),[i,h]=g.useState(!1),[m,I]=g.useState(!1),{tenantEmailDomain:E}=re(),T=le(),{useFeatureGate:k}=ue(),{isFeatureEnabled:f}=k(_.isDebitCardFeatureEnabled),U=ze("/:tenantEmailDomain/onboarding")!==null&&d.search?.includes("code"),C=D(y=>y.onboardingCustomerViewState.fetchState),F=D(y=>y.onboardingCustomerViewState.currentStep),M=D(y=>y.onboardingCustomerViewState.uiState),c=D(y=>ee(y)),L=D(y=>y.userRoleConfigState.fetchState),w=D(y=>y.cardPaymentViewState),R=ke(w.addCardPaymentSourceStatus.fetchState),O=w.addCardPaymentSourceStatus.fetchState,{code:S,realmId:G,state:j}=Dt(d.search),P=c.externalConnections?.accounting[0],A=P?.connectionType,K=P?.connectionName,$=P?.connectionId??"",Q=B.getSignedInUser()?.userId??"";g.useEffect(()=>{i||(h(!0),r(ae()))},[i,r]),g.useEffect(()=>{m||(ve(["card"]),I(!0))},[m]),g.useEffect(()=>{R==="In-Progress"&&O==="Completed"&&r(ae())},[R,O]),g.useEffect(()=>{Ft(S,G,j,$,Q)===!0&&c.externalConnections?.saveConnectionState!=="In-Progress"&&C==="Completed"&&(r(st(c.tenantId,{connection_type:A??"accounting",connection_name:K??"quickbooks_online",authorization_code:S,realm_id:G,connection_id:$,user_id:Q},it(window.location.origin+"/onboarding/auth"))),N.trackOnboardingSaveQBOConnection(G,$),u(d.pathname))},[S,G,j,d.pathname,C]),g.useEffect(()=>{ne.isInitiated===!1&&C==="Completed"&&ne.init("/onboarding/auth",c.tenantEmailDomain)},[C]);const v=c.companyId??B.getSignedInUserTenant(E)?.companyId,q=ge(c?.userRole??[]),l=D(y=>he(y,v));g.useEffect(()=>{e||C!=="Not-Started"||v==null||(n(!0),r(rt(v,!0,!U)))},[e,C,v]),g.useEffect(()=>{c.externalConnections?.saveConnectionState!=="Completed"&&c.externalConnections?.saveConnectionState!=="Error"||!M.isQBOPopupOpen||F!=="qbo_connection"||r(X({isQBOPopupOpen:!1}))},[c.externalConnections?.saveConnectionState]),g.useEffect(()=>{C==="Completed"&&U&&(r(_e({step:"qbo_connection"})),r(X({isQBOPopupOpen:!0})))},[U,C]),g.useEffect(()=>{L==="Not-Started"&&r(ct(!0))},[L,r]);const Z=ke(l.companyDetailsLocalData?.addressStatus);g.useEffect(()=>{l.companyDetailsLocalData?.registeredAddressStatus?.addressToCreate==null&&l.companyDetailsLocalData?.addressStatus?.addressToCreate!=null&&Z==null&&r(Ue({addressType:"company_registered_address",addressToCreate:l.companyDetailsLocalData?.addressStatus?.addressToCreate}))},[l.companyDetailsLocalData?.addressStatus?.addressToCreate,l.companyDetailsLocalData?.registeredAddressStatus?.addressToCreate]);const W=l.isInterimEmailSent;if(B.getSignedInUser()==null)throw Error("Can't access onboarding flow without signing in...");const Le=pe(f,c),Re=me(c),ye=c.company?.companyOnboardingInfo.isOnboardingCompleted,be=y=>y.trackPageLoaded(J.Event.onboardingPage),Se=c.productSettings.isOtherProductsEnabled,Ge=c.productSettings.isTreasuryEnabled;if(ye===!0){if(!Se)return Ge?a.jsx(x,{to:"../../treasury"}):Le?a.jsx(x,{to:"../../checking"}):Re?a.jsx(x,{to:"../../cards"}):a.jsx(x,{to:"../../dashboard"});const y=l.updateStatus.fetchState==="In-Progress";if(Se&&!y)return t?a.jsxs(Oe,{children:[a.jsx(Y,{analytics:N,onLoad:Ne=>be(Ne)}),a.jsx(Ae,{navigate:u,location:d,companyId:v,currentTenant:c,isAdmin:q,isOnAddressPage:o,themeState:b,googleAPIKey:te.googleMapsAPIKey}),s!=null?a.jsx(Pe,{windowSize:p,children:s}):null]}):a.jsx(x,{to:"../../onboarding/thankyou"})}else if(ye===!1&&T?.loggedInUserRoleMap!=null)return W===!0?a.jsx(x,{to:"../../onboarding/thankyou"}):a.jsxs(Oe,{children:[a.jsx(Y,{analytics:N,onLoad:y=>be(y)}),a.jsx(Ae,{navigate:u,location:d,companyId:v,currentTenant:c,isAdmin:q,isOnAddressPage:o,themeState:b,googleAPIKey:te.googleMapsAPIKey}),s!=null?a.jsx(Pe,{windowSize:p,children:s}):null]});return null};function De(t,o,s){let u=`/${t}/onboarding/address`;return u=s!=null?u.concat(`/edit/${o}/${encodeURIComponent(s)}`):u.concat(`/new/${o}`),u}const Fe=fe.div`
20
20
  display: flex;
21
21
  height: 100vh;
22
22
  background-color: ${t=>t.theme.colors.grey4};
23
- `,we=ce(function(t,o){const{companyId:s,currentTenant:u}=o,d=he(t,s),r=Ve(t);return{hasVerifiedBankAccount:(d.paymentAccount?.providerVerificationStatus?.code?.includes("verified")??!1)||(r.bankAccountsList[0]?.providerVerificationStatus?.code?.includes("verified")??!1),isDisabled:ge(u?.userRole??[])&&d.updateStatus.fetchState!=="In-Progress"?void 0:"readonly",signedInUser:B.getSignedInUser(),currentTenant:u,meetingUrl:"https://meetings.hubspot.com/niharn/zeni-onboarding-overview?embed=true"}},function(t,o){const{currentTenant:s,themeState:u,navigate:d,location:r}=o,{tenantEmailDomain:p}=s;return{onZeniLogoClick:()=>{u.toggle()},handleLogOutClick:()=>{const S=V(r.state?.pathnameStackToGoBack,r.pathname);d("/signout",{replace:!0,state:{pathnameStackToGoBack:S,message:"logout"}})},handleCockpitClick:()=>{window.open("/cockpit")},handleUpdatePaymentAddressDetailClick:()=>{const S=V(r.state?.pathnameStackToGoBack,r.pathname);d(`/${p}/onboarding/billing/edit`,{state:{pathnameStackToGoBack:S,message:"UpdatePaymentAddressDetail"}})}}})(Je),vt=()=>{const t=oe(),o=ie(),s=se(),u=de(),{useFeatureGate:d}=ue(),{isFeatureEnabled:r}=d(_.isDebitCardFeatureEnabled),{tenantEmailDomain:p}=re(),S=le(),[e,n]=g.useState(!1);g.useEffect(()=>{e===!1&&s.state?.message==="OnboardingThankyou"&&n(!0)},[s.state]);const i=D(f=>ee(f)),h=i.productSettings.isOtherProductsEnabled;g.useEffect(()=>{o(Be(m,!1,!h))},[]);const m=i.companyId??B.getSignedInUserTenant(p)?.companyId;if(S.loggedInUser==null)throw Error("Can't access onboarding flow without signing in...");const I=pe(r,i),E=me(i),T=D(f=>f.onboardingCustomerViewState.updateStatus.fetchState),k=i.company?.companyOnboardingInfo.isOnboardingCompleted;return k!==!0||h?T==="Completed"&&k===!0&&h&&S?.loggedInUserRoleMap!=null?a.jsxs(Fe,{children:[a.jsx(Y,{analytics:N,onLoad:f=>{f.trackPageLoaded(J.Event.onboardingLandingPage,"Onboarding",At(i.productSettings))}}),a.jsx(we,{navigate:t,showUpdatePaymentDetailButton:h,location:s,companyId:m,currentTenant:i,themeState:u,isVisitingFirstTime:e})]}):T==="Completed"&&k===!1&&S?.loggedInUserRoleMap!=null?a.jsxs(Fe,{children:[a.jsx(Y,{analytics:N,onLoad:f=>{f.trackPageLoaded(J.Event.onboardingInterimPage)}}),a.jsx(we,{navigate:t,showUpdatePaymentDetailButton:h,location:s,companyId:m,currentTenant:i,themeState:u,isVisitingFirstTime:e})]}):a.jsx(je,{fetchState:T}):I?a.jsx(x,{to:"../../checking"}):E?a.jsx(x,{to:"../../cards"}):a.jsx(x,{to:"../../dashboard"})};function oa(){return a.jsxs(Qe,{children:[a.jsx(z,{path:"/",element:a.jsx(H,{})}),a.jsx(z,{path:"/billing/edit",element:a.jsx(H,{taxCFOCustomer:!0})}),a.jsx(z,{path:"/thankyou",element:a.jsx(vt,{})}),a.jsx(z,{path:"/activation",element:a.jsx(jt,{})}),a.jsx(z,{path:"/address/edit/:addressType/:addressId",element:a.jsx(H,{isOnAddressPage:!0,appContent:a.jsx(Ce,{})})}),a.jsx(z,{path:"/address/new/:addressType",element:a.jsx(H,{isOnAddressPage:!0,appContent:a.jsx(Ce,{})})}),a.jsx(z,{path:"*",element:a.jsx($e,{})})]})}export{oa as default};
23
+ `,we=ce(function(t,o){const{companyId:s,currentTenant:u}=o,d=he(t,s),r=Ve(t);return{hasVerifiedBankAccount:(d.paymentAccount?.providerVerificationStatus?.code?.includes("verified")??!1)||(r.bankAccountsList[0]?.providerVerificationStatus?.code?.includes("verified")??!1),isDisabled:ge(u?.userRole??[])&&d.updateStatus.fetchState!=="In-Progress"?void 0:"readonly",signedInUser:B.getSignedInUser(),currentTenant:u,meetingUrl:"https://meetings.hubspot.com/niharn/zeni-onboarding-overview?embed=true"}},function(t,o){const{currentTenant:s,themeState:u,navigate:d,location:r}=o,{tenantEmailDomain:p}=s;return{onZeniLogoClick:()=>{u.toggle()},handleLogOutClick:()=>{const b=V(r.state?.pathnameStackToGoBack,r.pathname);d("/signout",{replace:!0,state:{pathnameStackToGoBack:b,message:"logout"}})},handleCockpitClick:()=>{window.open("/cockpit")},handleUpdatePaymentAddressDetailClick:()=>{const b=V(r.state?.pathnameStackToGoBack,r.pathname);d(`/${p}/onboarding/billing/edit`,{state:{pathnameStackToGoBack:b,message:"UpdatePaymentAddressDetail"}})}}})(Je),vt=()=>{const t=oe(),o=ie(),s=se(),u=de(),{useFeatureGate:d}=ue(),{isFeatureEnabled:r}=d(_.isDebitCardFeatureEnabled),{tenantEmailDomain:p}=re(),b=le(),[e,n]=g.useState(!1);g.useEffect(()=>{e===!1&&s.state?.message==="OnboardingThankyou"&&n(!0)},[s.state]);const i=D(f=>ee(f)),h=i.productSettings.isOtherProductsEnabled;g.useEffect(()=>{o(Be(m,!1,!h))},[]);const m=i.companyId??B.getSignedInUserTenant(p)?.companyId;if(b.loggedInUser==null)throw Error("Can't access onboarding flow without signing in...");const I=pe(r,i),E=me(i),T=D(f=>f.onboardingCustomerViewState.updateStatus.fetchState),k=i.company?.companyOnboardingInfo.isOnboardingCompleted;return k!==!0||h?T==="Completed"&&k===!0&&h&&b?.loggedInUserRoleMap!=null?a.jsxs(Fe,{children:[a.jsx(Y,{analytics:N,onLoad:f=>{f.trackPageLoaded(J.Event.onboardingLandingPage,"Onboarding",At(i.productSettings))}}),a.jsx(we,{navigate:t,showUpdatePaymentDetailButton:h,location:s,companyId:m,currentTenant:i,themeState:u,isVisitingFirstTime:e})]}):T==="Completed"&&k===!1&&b?.loggedInUserRoleMap!=null?a.jsxs(Fe,{children:[a.jsx(Y,{analytics:N,onLoad:f=>{f.trackPageLoaded(J.Event.onboardingInterimPage)}}),a.jsx(we,{navigate:t,showUpdatePaymentDetailButton:h,location:s,companyId:m,currentTenant:i,themeState:u,isVisitingFirstTime:e})]}):a.jsx(je,{fetchState:T}):I?a.jsx(x,{to:"../../checking"}):E?a.jsx(x,{to:"../../cards"}):a.jsx(x,{to:"../../dashboard"})};function oa(){return a.jsxs(Qe,{children:[a.jsx(z,{path:"/",element:a.jsx(H,{})}),a.jsx(z,{path:"/billing/edit",element:a.jsx(H,{taxCFOCustomer:!0})}),a.jsx(z,{path:"/thankyou",element:a.jsx(vt,{})}),a.jsx(z,{path:"/activation",element:a.jsx(jt,{})}),a.jsx(z,{path:"/address/edit/:addressType/:addressId",element:a.jsx(H,{isOnAddressPage:!0,appContent:a.jsx(Ce,{})})}),a.jsx(z,{path:"/address/new/:addressType",element:a.jsx(H,{isOnAddressPage:!0,appContent:a.jsx(Ce,{})})}),a.jsx(z,{path:"*",element:a.jsx($e,{})})]})}export{oa as default};