@zeniai/web-app-ui 5.3.52-dev → 5.3.52-qa

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 (70) hide show
  1. package/dist/assets/{AccountMappingScreen-CfjKXYvl.js → AccountMappingScreen-BFD6zGSo.js} +1 -1
  2. package/dist/assets/{ActualMatchingMatchDetailScreen-Ctlw5YXu.js → ActualMatchingMatchDetailScreen--CUkwe-7.js} +1 -1
  3. package/dist/assets/{AddressRoutes-DakZpUxU.js → AddressRoutes-IFU8jeyM.js} +1 -1
  4. package/dist/assets/{AddressScreen-dsCmoEfc.js → AddressScreen-C5gOC9K1.js} +1 -1
  5. package/dist/assets/{AiCfoScreen-1hhGcQPM.js → AiCfoScreen-Dk4NZsn4.js} +1 -1
  6. package/dist/assets/{AppDrawer-QudxLZqd.js → AppDrawer-BioYAA8q.js} +1 -1
  7. package/dist/assets/{BillPayApprovalRoutes--p2o0UTq.js → BillPayApprovalRoutes-CbgUcPPn.js} +1 -1
  8. package/dist/assets/{BillPayRoutes-BQ5naZy9.js → BillPayRoutes-BLaPoSH3.js} +1 -1
  9. package/dist/assets/{BusinessVerificationPageScreen-fABxFj6p.js → BusinessVerificationPageScreen-_lNpLbtb.js} +1 -1
  10. package/dist/assets/{CardsAiCfoScreen-D7lfbMvU.js → CardsAiCfoScreen-_v8KOvIs.js} +1 -1
  11. package/dist/assets/{ChargeCardRoutes-8okIr07w.js → ChargeCardRoutes-Cm8gRyWo.js} +1 -1
  12. package/dist/assets/{CompanyPassportScreen-DGlmYKZ8.js → CompanyPassportScreen-LNhKVlPD.js} +1 -1
  13. package/dist/assets/{ConnectionAuthScreen-BkpK3Q9m.js → ConnectionAuthScreen-CvbL5gXS.js} +1 -1
  14. package/dist/assets/{CustomerOnboardingAuthScreen-CUL244kC.js → CustomerOnboardingAuthScreen-1_BAWSpj.js} +1 -1
  15. package/dist/assets/{CustomerOnboardingRoutes-A9qZQBlL.js → CustomerOnboardingRoutes-CFt1axWu.js} +1 -1
  16. package/dist/assets/{DashboardRoutes-monhFGcO.js → DashboardRoutes-B_RKHDQw.js} +1 -1
  17. package/dist/assets/{DefaultTenantHome-B4aMzjG6.js → DefaultTenantHome-CzERteR_.js} +1 -1
  18. package/dist/assets/{DomesticWireDetailScreen-DSnjP_Z5.js → DomesticWireDetailScreen-DdGRU08t.js} +1 -1
  19. package/dist/assets/{DrawerScreen-C728nU-t.js → DrawerScreen-BkWdrsyD.js} +1 -1
  20. package/dist/assets/{EntityDetailRoutes-Bn5UTAGi.js → EntityDetailRoutes-BJQ1CgrE.js} +1 -1
  21. package/dist/assets/{ExpenseAutomationRoutes-lJCxAksc.js → ExpenseAutomationRoutes-90qVj0mK.js} +1 -1
  22. package/dist/assets/{FeaturePreviewScreen-BTcHNbYq.js → FeaturePreviewScreen-DmuM1Efe.js} +1 -1
  23. package/dist/assets/{HubSpotOAuthCallbackScreen-DeY4bk0n.js → HubSpotOAuthCallbackScreen-D5Csp1UO.js} +1 -1
  24. package/dist/assets/{InvoicingRoutes-BFDQ_AF7.js → InvoicingRoutes-CexYyC5q.js} +1 -1
  25. package/dist/assets/{MagicLinkRoutes-CDa3T_71.js → MagicLinkRoutes-JEaRIrxB.js} +1 -1
  26. package/dist/assets/{MagicLinkSignInScreen-DkY-AFQs.js → MagicLinkSignInScreen-DwZW3Erw.js} +1 -1
  27. package/dist/assets/{MobileAppDrawer-CZL1M8HC.js → MobileAppDrawer-C-ti4sM2.js} +1 -1
  28. package/dist/assets/{NotFoundScreen-rNwJ2-Qg.js → NotFoundScreen-3qucmnjW.js} +1 -1
  29. package/dist/assets/{NotificationRoutes-Dq1wMoB2.js → NotificationRoutes-bEJ4pL_q.js} +1 -1
  30. package/dist/assets/{OAuthConsentScreen-QrzCNvCR.js → OAuthConsentScreen-CH9GHZTu.js} +1 -1
  31. package/dist/assets/{PandLWithForecastRoutes-CGjGCsop.js → PandLWithForecastRoutes-BuxQksyO.js} +1 -1
  32. package/dist/assets/{PaymentLinkScreen-BYkX6g2m.js → PaymentLinkScreen-Dgt4_0Sf.js} +1 -1
  33. package/dist/assets/{PeopleRoutes-BSwZbUJ-.js → PeopleRoutes-B9g6bB_r.js} +1 -1
  34. package/dist/assets/{PerformanceRoutes-Cr1pAdV3.js → PerformanceRoutes-hC8UVG3D.js} +1 -1
  35. package/dist/assets/{QBOConnectionScreen-TrNoYiXG.js → QBOConnectionScreen-BT2gd9dq.js} +1 -1
  36. package/dist/assets/{ReimbursementApprovalRoutes-C2OtR60a.js → ReimbursementApprovalRoutes-CoFA16rX.js} +1 -1
  37. package/dist/assets/{ReimbursementApprovalRuleDetailScreen-BqumfK_F.js → ReimbursementApprovalRuleDetailScreen-uAvwHmVJ.js} +1 -1
  38. package/dist/assets/{ReimbursementRoutes-CPjQ0Aws.js → ReimbursementRoutes-BnvmE75X.js} +1 -1
  39. package/dist/assets/{ReportsRoutes-BbjIc2Jw.js → ReportsRoutes-ByrzWoSX.js} +1 -1
  40. package/dist/assets/{RewardsRoutes-Ca33Xd5P.js → RewardsRoutes-BrjKJijg.js} +1 -1
  41. package/dist/assets/{ScheduleDetailsPrepaidExpensesScreen-DETwY7pD.js → ScheduleDetailsPrepaidExpensesScreen-CcW917MW.js} +1 -1
  42. package/dist/assets/{ScreenRoutes-CiAckpHg.js → ScreenRoutes-BgjTH3MD.js} +2 -2
  43. package/dist/assets/{SettingsRoutes-DwAkdZyX.js → SettingsRoutes-DCgOWsFJ.js} +1 -1
  44. package/dist/assets/{SetupPagesScreen-Y9SYCogP.js → SetupPagesScreen-CgVfrQ5w.js} +1 -1
  45. package/dist/assets/{SignInScreen-McvwseEQ.js → SignInScreen-QbBLEpYE.js} +1 -1
  46. package/dist/assets/{SignOutScreen-lXmArlao.js → SignOutScreen-Cg98jLSX.js} +1 -1
  47. package/dist/assets/{TaskListScreen-CZxRWWOz.js → TaskListScreen-BKRaew41.js} +1 -1
  48. package/dist/assets/{TaskRoutes-q7JoPp0N.js → TaskRoutes-tj9-zwIR.js} +1 -1
  49. package/dist/assets/{TransactionDetailRoutes-ZlWD_PWX.js → TransactionDetailRoutes-BSNaBZbG.js} +1 -1
  50. package/dist/assets/{TransactionDetailScreen-0HhiaPRe.js → TransactionDetailScreen-DHysjIND.js} +1 -1
  51. package/dist/assets/{TransactionListRoutes-UQ_0OeeD.js → TransactionListRoutes-BcKO42ff.js} +1 -1
  52. package/dist/assets/{TreasuryRoutes-DKuwHbrg.js → TreasuryRoutes-0_eMw0Wx.js} +1 -1
  53. package/dist/assets/{VendorsRoutes-DXw2vvr4.js → VendorsRoutes-B3eT8rLn.js} +1 -1
  54. package/dist/assets/{WiseConfirmationScreen-XQZz5N0L.js → WiseConfirmationScreen-DJ2wN1Fx.js} +1 -1
  55. package/dist/assets/{ZeniAccountRoutes-BU1gb-LE.js → ZeniAccountRoutes-BNdYEOcI.js} +1 -1
  56. package/dist/assets/{ZeniAccountStatementScreen-CrkxN9K8.js → ZeniAccountStatementScreen-Cua_2c_y.js} +1 -1
  57. package/dist/assets/{analyticsHelper-B9ZU7ow3.js → analyticsHelper-DnGDW6mo.js} +1 -1
  58. package/dist/assets/{getLocaleForTenant-Dfv4vBw9.js → getLocaleForTenant-U4ff53sp.js} +1 -1
  59. package/dist/assets/{index-CXbL8CxL.js → index-D0or4oV9.js} +5 -5
  60. package/dist/assets/{routePaths-7schl7H2.js → routePaths-DTZH71MW.js} +1 -1
  61. package/dist/assets/{useActualMatchingMatchDetail-BFtfLe4Y.js → useActualMatchingMatchDetail-CtxH6NWw.js} +1 -1
  62. package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-BdSnJq4D.js → useAiCfoDashboardSuggestedQuestionsChips-BHQEdJfL.js} +1 -1
  63. package/dist/assets/{useAskAiCfoHostNavButtonProps-gnFsttzV.js → useAskAiCfoHostNavButtonProps-eAE85_k_.js} +1 -1
  64. package/dist/assets/{useChargeCardPusherEvents-BHookjIG.js → useChargeCardPusherEvents-CLlJNBdI.js} +1 -1
  65. package/dist/assets/{useEmailConnectResultRefresh-bvDRvnqZ.js → useEmailConnectResultRefresh-DfrDVqu0.js} +1 -1
  66. package/dist/assets/{useInitialThreadRequest-TFVuVZA_.js → useInitialThreadRequest-DYGeNL0J.js} +1 -1
  67. package/dist/assets/{useTaskManagerAccess-CiaMEBoG.js → useTaskManagerAccess-CxAfFVI5.js} +1 -1
  68. package/dist/assets/{withTransactionSidePanel-BR8uip_B.js → withTransactionSidePanel-CQ96RPah.js} +1 -1
  69. package/dist/index.html +1 -1
  70. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import{j as L}from"./liveblocks-BPL36a6x.js";import{a as o}from"./sentry-_x3Yh1Jc.js";import{h as K,g as W,u as X,j as m,s as q,l as Y}from"./core-DOBELRta.js";import{aj as Z,c as ee,A as $,z as te,o as G,ak as ne,k as ae,V as ce}from"./index-CXbL8CxL.js";import{bn as se,fF as oe,gV as ie,oB as Q,Uz as re,i8 as J,gh as le,os as ue,UA as de,UB as pe,u6 as ge,l$ as me,oq as Ae,om as be,ox as fe,ia as Ie,UC as ye,UD as Se}from"./zeni-epic-state-DXFYDM66.js";import{n as he}from"./mui-wO6EIETx.js";import{M as Ee}from"./MobileAppDrawer-CZL1M8HC.js";import{q as R}from"./QBOConnectionScreen-TrNoYiXG.js";import{g as h,a as E,m as ze}from"./accountMappingHelper-DQktkWkn.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new a.Error().stack;e&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[e]="8afc5f6d-8031-4487-ac2e-ca1d6ada7584",a._sentryDebugIdIdentifier="sentry-dbid-8afc5f6d-8031-4487-ac2e-ca1d6ada7584")}catch{}})();const l="zeni_pending_projects_enable",u={pending:"pending",ready:"ready"},ve=he.div`
1
+ import{j as L}from"./liveblocks-BPL36a6x.js";import{a as o}from"./sentry-_x3Yh1Jc.js";import{h as K,g as W,u as X,j as m,s as q,l as Y}from"./core-DOBELRta.js";import{aj as Z,c as ee,A as $,z as te,o as G,ak as ne,k as ae,V as ce}from"./index-D0or4oV9.js";import{bn as se,fF as oe,gV as ie,oB as Q,Uz as re,i8 as J,gh as le,os as ue,UA as de,UB as pe,u6 as ge,l$ as me,oq as Ae,om as be,ox as fe,ia as Ie,UC as ye,UD as Se}from"./zeni-epic-state-DXFYDM66.js";import{n as he}from"./mui-wO6EIETx.js";import{M as Ee}from"./MobileAppDrawer-C-ti4sM2.js";import{q as R}from"./QBOConnectionScreen-BT2gd9dq.js";import{g as h,a as E,m as ze}from"./accountMappingHelper-DQktkWkn.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new a.Error().stack;e&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[e]="8afc5f6d-8031-4487-ac2e-ca1d6ada7584",a._sentryDebugIdIdentifier="sentry-dbid-8afc5f6d-8031-4487-ac2e-ca1d6ada7584")}catch{}})();const l="zeni_pending_projects_enable",u={pending:"pending",ready:"ready"},ve=he.div`
2
2
  display: flex;
3
3
  height: 100%;
4
4
  width: 100%;
@@ -1 +1 @@
1
- import{j as s}from"./liveblocks-BPL36a6x.js";import{a as k}from"./sentry-_x3Yh1Jc.js";import{a5 as I,dQ as g}from"./index-CXbL8CxL.js";import"./mui-wO6EIETx.js";import{u as y}from"./useActualMatchingMatchDetail-BFtfLe4Y.js";import b from"./NotFoundScreen-rNwJ2-Qg.js";import{i as v,h as U,g as w}from"./core-DOBELRta.js";import"./zeni-epic-state-DXFYDM66.js";import"./recharts-Sp9X2zHo.js";import"./analytics-GZ8dIY_c.js";import"./plaid-C-eBmVPr.js";import"./dnd-0MaFz9wL.js";import"./stripe-cKAAJElX.js";import"./lottie-38LSfraF.js";import"./lexical-CAgOy6Q-.js";import"./pdf-B2N0erO1.js";import"./utils-BU0XThgM.js";import"./stripSplatSuffix-bz-VGo3l.js";import"./decodeURIComponentSafe-DjVlhgki.js";import"./routePaths-7schl7H2.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="0b9cbf63-f788-4a28-96e6-d5ee605ae585",t._sentryDebugIdIdentifier="sentry-dbid-0b9cbf63-f788-4a28-96e6-d5ee605ae585")}catch{}})();function J(){const{matchId:t,tenantEmailDomain:e}=v(),n=U(),r=w(),R=y(t??""),a=k.useCallback((()=>{const S=I(r.state?.pathnameStackToGoBack);n(S.poppedPathname??`/${e??""}/month_end_close_checks/review`,{state:{pathnameStackToGoBack:S.newStack}})}),[r.state,n,e]);if(t==null)return s.jsx(b,{});const{match:i,detailFetchState:o,handleOpenBill:l,handleRefresh:c,handleUndoReversal:d,handleContinueMatch:h,lastMatchResults:f,lastUndoResults:m,refreshStatus:p,undoReversalStatus:u}=R;return i==null?o.fetchState==="Not-Started"||o.fetchState==="In-Progress"?s.jsx(g,{detailFetchState:o.fetchState,isUndoInFlight:u.fetchState==="In-Progress",refreshStatus:p.fetchState,onNavigateBack:a,onOpenBill:l,onContinueMatch:()=>{h(),a()},onRefresh:c,onUndoReversal:d,lastMatchResults:f,lastUndoResults:m}):s.jsx(b,{}):s.jsx(g,{match:i,detailFetchState:o.fetchState,isUndoInFlight:u.fetchState==="In-Progress",refreshStatus:p.fetchState,onNavigateBack:a,onOpenBill:l,onContinueMatch:()=>{h(),a()},onRefresh:c,onUndoReversal:d,lastMatchResults:f,lastUndoResults:m})}export{J as default};
1
+ import{j as s}from"./liveblocks-BPL36a6x.js";import{a as k}from"./sentry-_x3Yh1Jc.js";import{a5 as I,dQ as g}from"./index-D0or4oV9.js";import"./mui-wO6EIETx.js";import{u as y}from"./useActualMatchingMatchDetail-CtxH6NWw.js";import b from"./NotFoundScreen-3qucmnjW.js";import{i as v,h as U,g as w}from"./core-DOBELRta.js";import"./zeni-epic-state-DXFYDM66.js";import"./recharts-Sp9X2zHo.js";import"./analytics-GZ8dIY_c.js";import"./plaid-C-eBmVPr.js";import"./dnd-0MaFz9wL.js";import"./stripe-cKAAJElX.js";import"./lottie-38LSfraF.js";import"./lexical-CAgOy6Q-.js";import"./pdf-B2N0erO1.js";import"./utils-BU0XThgM.js";import"./stripSplatSuffix-bz-VGo3l.js";import"./decodeURIComponentSafe-DjVlhgki.js";import"./routePaths-DTZH71MW.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="0b9cbf63-f788-4a28-96e6-d5ee605ae585",t._sentryDebugIdIdentifier="sentry-dbid-0b9cbf63-f788-4a28-96e6-d5ee605ae585")}catch{}})();function J(){const{matchId:t,tenantEmailDomain:e}=v(),n=U(),r=w(),R=y(t??""),a=k.useCallback((()=>{const S=I(r.state?.pathnameStackToGoBack);n(S.poppedPathname??`/${e??""}/month_end_close_checks/review`,{state:{pathnameStackToGoBack:S.newStack}})}),[r.state,n,e]);if(t==null)return s.jsx(b,{});const{match:i,detailFetchState:o,handleOpenBill:l,handleRefresh:c,handleUndoReversal:d,handleContinueMatch:h,lastMatchResults:f,lastUndoResults:m,refreshStatus:p,undoReversalStatus:u}=R;return i==null?o.fetchState==="Not-Started"||o.fetchState==="In-Progress"?s.jsx(g,{detailFetchState:o.fetchState,isUndoInFlight:u.fetchState==="In-Progress",refreshStatus:p.fetchState,onNavigateBack:a,onOpenBill:l,onContinueMatch:()=>{h(),a()},onRefresh:c,onUndoReversal:d,lastMatchResults:f,lastUndoResults:m}):s.jsx(b,{}):s.jsx(g,{match:i,detailFetchState:o.fetchState,isUndoInFlight:u.fetchState==="In-Progress",refreshStatus:p.fetchState,onNavigateBack:a,onOpenBill:l,onContinueMatch:()=>{h(),a()},onRefresh:c,onUndoReversal:d,lastMatchResults:f,lastUndoResults:m})}export{J as default};
@@ -1 +1 @@
1
- import{j as e}from"./liveblocks-BPL36a6x.js";import{A as i}from"./AddressScreen-dsCmoEfc.js";import s from"./NotFoundScreen-rNwJ2-Qg.js";import"./sentry-_x3Yh1Jc.js";import{n as d,o as r}from"./core-DOBELRta.js";import"./zeni-epic-state-DXFYDM66.js";import"./recharts-Sp9X2zHo.js";import"./index-CXbL8CxL.js";import"./mui-wO6EIETx.js";import"./analytics-GZ8dIY_c.js";import"./plaid-C-eBmVPr.js";import"./dnd-0MaFz9wL.js";import"./stripe-cKAAJElX.js";import"./lottie-38LSfraF.js";import"./lexical-CAgOy6Q-.js";import"./pdf-B2N0erO1.js";import"./utils-BU0XThgM.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]="81cbb5c1-1b56-4d87-a240-ae6c03b91825",t._sentryDebugIdIdentifier="sentry-dbid-81cbb5c1-1b56-4d87-a240-ae6c03b91825")}catch{}})();function _(){return e.jsxs(d,{children:[e.jsx(r,{path:"/edit/:addressType/:addressId",element:e.jsx(i,{})}),e.jsx(r,{path:"/new/:addressType",element:e.jsx(i,{})}),e.jsx(r,{path:"*",element:e.jsx(s,{})})]})}export{_ as default};
1
+ import{j as e}from"./liveblocks-BPL36a6x.js";import{A as i}from"./AddressScreen-C5gOC9K1.js";import s from"./NotFoundScreen-3qucmnjW.js";import"./sentry-_x3Yh1Jc.js";import{n as d,o as r}from"./core-DOBELRta.js";import"./zeni-epic-state-DXFYDM66.js";import"./recharts-Sp9X2zHo.js";import"./index-D0or4oV9.js";import"./mui-wO6EIETx.js";import"./analytics-GZ8dIY_c.js";import"./plaid-C-eBmVPr.js";import"./dnd-0MaFz9wL.js";import"./stripe-cKAAJElX.js";import"./lottie-38LSfraF.js";import"./lexical-CAgOy6Q-.js";import"./pdf-B2N0erO1.js";import"./utils-BU0XThgM.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]="81cbb5c1-1b56-4d87-a240-ae6c03b91825",t._sentryDebugIdIdentifier="sentry-dbid-81cbb5c1-1b56-4d87-a240-ae6c03b91825")}catch{}})();function _(){return e.jsxs(d,{children:[e.jsx(r,{path:"/edit/:addressType/:addressId",element:e.jsx(i,{})}),e.jsx(r,{path:"/new/:addressType",element:e.jsx(i,{})}),e.jsx(r,{path:"*",element:e.jsx(s,{})})]})}export{_ as default};
@@ -1,4 +1,4 @@
1
- import{j as r}from"./liveblocks-BPL36a6x.js";import{a as h}from"./sentry-_x3Yh1Jc.js";import{h as T,u as P,g as j,i as E,j as B,l as M}from"./core-DOBELRta.js";import{a2 as V,E as $,z as D,N as L,a8 as K,a9 as F,k as C,V as S,a4 as N,Z as b,a5 as z}from"./index-CXbL8CxL.js";import{Ve as _,ip as R,fF as U,Vf as G,c8 as H,Vg as O,mH as q}from"./zeni-epic-state-DXFYDM66.js";import{n as Z}from"./mui-wO6EIETx.js";import J from"./NotFoundScreen-rNwJ2-Qg.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new e.Error().stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="97402e44-e138-4347-8340-38ba83c2d604",e._sentryDebugIdIdentifier="sentry-dbid-97402e44-e138-4347-8340-38ba83c2d604")}catch{}})();const Q=Z.div`
1
+ import{j as r}from"./liveblocks-BPL36a6x.js";import{a as h}from"./sentry-_x3Yh1Jc.js";import{h as T,u as P,g as j,i as E,j as B,l as M}from"./core-DOBELRta.js";import{a2 as V,E as $,z as D,N as L,a8 as K,a9 as F,k as C,V as S,a4 as N,Z as b,a5 as z}from"./index-D0or4oV9.js";import{Ve as _,ip as R,fF as U,Vf as G,c8 as H,Vg as O,mH as q}from"./zeni-epic-state-DXFYDM66.js";import{n as Z}from"./mui-wO6EIETx.js";import J from"./NotFoundScreen-3qucmnjW.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new e.Error().stack;s&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[s]="97402e44-e138-4347-8340-38ba83c2d604",e._sentryDebugIdIdentifier="sentry-dbid-97402e44-e138-4347-8340-38ba83c2d604")}catch{}})();const Q=Z.div`
2
2
  display: flex;
3
3
  height: 100vh;
4
4
  width: 100%;
@@ -1,4 +1,4 @@
1
- import{j as S}from"./liveblocks-BPL36a6x.js";import{a}from"./sentry-_x3Yh1Jc.js";import{u as Rt,h as Tt,i as jt,g as Ot,j as b,l as At}from"./core-DOBELRta.js";import{a as Qt,H as Dt,e7 as Lt,z as Ut,a2 as _t,e8 as Bt,e9 as Ft,ea as Mt,bp as Ae,eb as Ne,ec as Vt,bo as Ge,a5 as me,a9 as re,k as B,ed as le,ee as $t,ef as Nt,av as Gt,V as Ht,w as qt,eg as zt,eh as Wt,aw as Yt,ei as Jt,ej as Kt,ek as Xt,el as Zt,p as es,bl as Qe,em as ts}from"./index-CXbL8CxL.js";import{fE as _,gt as y,TY as ss,a24 as as,a25 as ns,jM as os,a26 as is,jJ as rs,a27 as de,jD as ue,jT as z,jl as Se,jB as De,jz as ls,jQ as ds,ju as He,U5 as Le,gv as F,gK as us,U4 as cs,TR as Ue,fF as ms,j3 as Ss,a28 as hs,g8 as ps,jh as fs,jd as gs,fG as ce,gf as Cs,a29 as Is,a2a as ks,a2b as bs,gu as vs,go as _e,k4 as Be,gq as Fe,gw as Es,a2c as Me,jV as Ps,ja as ws,jo as ys,jR as Ve,jr as xs,gx as Rs,gy as Ts,gz as js,gA as Os}from"./zeni-epic-state-DXFYDM66.js";import{D as As,n as M,S as Qs,P as Ds}from"./mui-wO6EIETx.js";import{u as Ls}from"./useAiCfoDashboardSuggestedQuestionsChips-BdSnJq4D.js";import{p as Us}from"./pathToGoBack-BTiQNxwp.js";import{j as _s}from"./routePaths-7schl7H2.js";import"./recharts-Sp9X2zHo.js";import"./analytics-GZ8dIY_c.js";import"./plaid-C-eBmVPr.js";import"./dnd-0MaFz9wL.js";import"./stripe-cKAAJElX.js";import"./lottie-38LSfraF.js";import"./lexical-CAgOy6Q-.js";import"./pdf-B2N0erO1.js";import"./utils-BU0XThgM.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new s.Error().stack;r&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[r]="8e40b9a4-bc42-4493-9122-e742c44cedfc",s._sentryDebugIdIdentifier="sentry-dbid-8e40b9a4-bc42-4493-9122-e742c44cedfc")}catch{}})();const qe="chat-response-generated";function Bs(s,r){if(r.kind!=="save")return;if(r.fetchState==="In-Progress")return{status:"saving"};if(r.fetchState==="Error")return{status:"failed"};if(r.fetchState!=="Completed")return;const t=y(s).skills.find((l=>l.macroId===r.savedMacroId));return t==null?void 0:{status:"saved",command:t.name}}const Fs=At((function(s,r){const t=_(s),l=r.isSubmitting,u=t.uiState?.currentChatSessionId,i=u!=null?Cs(s.aiCfoState,u):[],f=Wt(s,{allUsers:r.allUsers,onCardPolicyVendorSearchTextChange:r.onCardPolicyVendorSearchTextChange}),p=Is(s),m=ks(s),T=bs(s);return{showSampleQuestions:r.sessionFromUrl==="explore"&&t.uiState.currentChatSessionId==null,aiCfoView:t,isSubmitting:l,isNewChatSession:r.sessionFromUrl==="new_chat"||r.sessionFromUrl==="explore",isFullView:!0,tableDownloadEndPoint:`${Yt}/tableDownload`,exportDownloadEndPoint:Xt(),emailLinkQuestion:r.emailLinkQuestion,autoSubmitEmailLinkQuestion:r.autoSubmitEmailLinkQuestion,onEmailLinkQuestionProcessed:r.onEmailLinkQuestionProcessed,routedInitialQuestionSource:r.routedInitialQuestionSource,routedInitialQuestionSuggestionIndex:r.routedInitialQuestionSuggestionIndex,exploreSuggestedPromptQuestions:r.exploreSuggestedPromptQuestions,exploreSuggestedPromptQuestionsLoading:r.exploreSuggestedPromptQuestionsLoading,isFileUploadEnabled:r.isFileUploadEnabled,isUploadPromoVisible:r.isUploadPromoVisible,onUploadPromoClose:r.onUploadPromoClose,skills:y(s).skills,skillSaveState:Bs(s,T),skillsEnabled:y(s).skillsEnabled,skillsList:y(s).skills,skillsListError:y(s).fetchState==="Error",skillsListLoading:y(s).fetchState==="In-Progress",skillsCanPublish:y(s).canPublish,skillSaving:T.fetchState==="In-Progress",skillSaveError:T.fetchState==="Error",skillVersionHistory:p.macroId!=null?{macroId:p.macroId,versions:p.versions,error:p.fetchState==="Error",loading:p.fetchState==="In-Progress"}:void 0,skillRestoreBody:m.macroId!=null&&m.version!=null?{macroId:m.macroId,version:m.version,instructions:m.instructions,error:m.fetchState==="Error",loading:m.fetchState==="In-Progress"}:void 0,skillDetail:z(s).detail,skillDetailError:z(s).fetchState==="Error",skillDetailLoading:z(s).fetchState==="In-Progress",syntheticAnswers:i,resolveSyntheticAnswerCardTile:Kt(s),resolveSyntheticAnswerPolicyTile:Jt(s),...f}}),(function(s,r){const{location:t,currentTenant:l,userId:u,navigate:i,currentChatSessionId:f,allSessionsWithOrderedQuestionAnswers:p,isAiCardCreationEnabled:m,isCardPolicyEnabled:T,setIsAiCfoOpen:A}=r,Q=l.tenantEmailDomain;return{onEventReceived:(n,o)=>{if(n===qe&&typeof o.text=="string"&&typeof o.metadata=="object"){const c=o,E=Rs(c.type),v=c.metadata.chat_session_id??null,{currentChatSession:W,currentQuestionAnswer:x,currentQuestionAnswerSummary:Y}=Ge(p,v);E!=="answer"?B.trackAICFOChatResponseGenerated(E,x?.question.questionText??"",c.text,v,ts(Y,W),c.metadata.message_id??null):B.trackAICFOChatAnswerGenerated(c.text,x?.question.questionText??"",(c.follow_up_questions?.length??0)>0,!!c.assumptions,!!c.insights,c.visualization!=null,Ts(c.visualization?.type??"")??null,v,c.summarized_title,c.metadata.message_id??null),s(js({chatSessionId:c.metadata.chat_session_id,responseType:E,fetchState:{fetchState:"Completed",error:void 0}})),s(Os({chatSessionId:c.metadata.chat_session_id,answerPayload:c,userId:u}))}},onSubmit:(n,o,c,E,v)=>{n&&Qe(s,n,o,f,p,u,E,c,void 0,v)},onFetchSkills:()=>{s(He())},onOpenSkill:n=>{s(Se({macroId:n})),s(xs({macroId:n}))},onSaveSkill:(n,o)=>{s(Ve({draft:n,macroId:o}))},onSaveSkillDraft:n=>{const o=n.displayName?.trim()??"",c=n.name?.trim()??"";s(Ve({draft:{name:o.length>0?o:c,description:n.description?.trim()??null,instructions:n.instructions,visibility:"private"}}))},onFetchSkillVersionBody:(n,o)=>{s(ys({macroId:n,version:o}))},onDeleteSkill:n=>{s(ws({macroId:n}))},onSetSkillVisibility:(n,o)=>{s(Ps({macroId:n,visibility:o}))},onCloseSkillDetail:()=>{s(Me())},onRunSkill:(n,o)=>{s(F()),s(_e()),Qe(s,o,"user_input",void 0,p,u,void 0,void 0,void 0,n),s(Me())},updateCurrentInput:n=>{s(Fe(n))},onStopSubmit:()=>{},onUpdateScrollYOffset:n=>{s(Es(n))},onSelectSampleQuestion:()=>{},onBackClick:()=>{i(-1)},onCloseClick:()=>{const n=me(t.state?.pathnameStackToGoBack),o=n.poppedPathname??Us(1);i(o,{state:{...t.state,pathnameStackToGoBack:n.newStack}}),s(Fe(""))},togglePageView:()=>{const n=me(t.state?.pathnameStackToGoBack),o=n.poppedPathname??`/${l.tenantEmailDomain}/dashboard`;i(o,{state:{...Ne(t.state),pathnameStackToGoBack:n.newStack,message:"open_ai_cfo_drawer"}}),A(!0)},onCopy:()=>{},onThumbsUp:(n,o)=>{f!=null&&o?.messageId!=null&&s(Be(f,o.messageId,"positive",o.questionText,o.answerText))},onThumbsDown:(n,o)=>{f!=null&&o?.messageId!=null&&s(Be(f,o.messageId,"negative",o.questionText,o.answerText))},onTogglePageView:()=>{i(-1)},onNewChatClick:()=>{s(F()),f!=null&&s(_e());const n=es(t.state?.pathnameStackToGoBack,t.pathname);i(`/${l.tenantEmailDomain}/ai-cfo/new_chat`,{state:{pathnameStackToGoBack:n.slice(0,-1),referrer:"Sidebar"}})},onToggleCotCollapsed:(n,o)=>{s(vs({questionAnswerId:n,isCollapsed:o}))},onMenuClick:r.onMenuClick,...Zt(s,{isAiCardCreationEnabled:m,isCardPolicyEnabled:T,currentChatSessionId:f,onAfterCardsCreationSubmit:()=>{A(!0),i(`/${Q}/cards`,{state:{...t.state}})},onAfterCardPolicySubmit:()=>{A(!0),i(`/${Q}/cards/policy`,{state:{...t.state}})}})}}))(qt(zt)),la=({isFileUploadEnabled:s})=>{const{setIsAiCfoOpen:r}=Qt(),t=Rt(),l=Tt(),{session_id:u}=jt(),i=Ot(),f=new URLSearchParams(i.search).get("routine")??void 0,[p,m]=a.useState(!1),T=b((e=>_(e).uiState.isSkillsBrowserOpen===!0)),A=b((e=>y(e).skillsEnabled)),Q=b((e=>_(e).uiState.isRoutinesBrowserOpen===!0)),n=b((e=>ss(e))),o=b((e=>as(e))),c=b((e=>ns(e))),[E,v]=a.useState(void 0),[W,x]=a.useState(!1),[Y,he]=a.useState(void 0),ze=a.useCallback((()=>{he(void 0),v(void 0),x(!0)}),[]),We=a.useCallback((e=>{v(e),x(!0)}),[]),Ye=a.useCallback((()=>{v(void 0),x(!1)}),[]),Je=a.useCallback((e=>{t(os({draft:e,...E!=null&&{scheduleId:E.scheduleId}})),v(void 0),x(!1)}),[t,E]),j=f,pe=n.routines.find((e=>e.scheduleId===j)),C=b((e=>is(e))),Ke=a.useCallback((e=>{t(rs({scheduleId:e.scheduleId}))}),[t]);a.useEffect((()=>{t(j!=null?ue({scheduleId:j}):de())}),[t,j]);const L=pe?.macroId,Xe=b((e=>z(e))),fe=L!=null&&L!==""&&Xe.fetchState==="Not-Started";a.useEffect((()=>{fe&&L!=null&&t(Se({macroId:L}))}),[t,fe,L]);const Ze=b((e=>_(e).uiState.currentChatSessionId))??u,I=n.routines.find((e=>e.scheduleId===f))??n.routines.find((e=>e.scheduleId===Dt(Ze))),U=I?.scheduleId??null,[ge,et]=a.useState(!0);a.useEffect((()=>{U!=null&&t(ue({scheduleId:U}))}),[t,U]);const Ce=C.runs.some((e=>e.status==="claimed"||e.status==="running"))===!0;a.useEffect((()=>{if(j==null||Ce!==!0)return;const e=window.setInterval((()=>{t(ue({scheduleId:j})),t(De())}),5e3);return()=>window.clearInterval(e)}),[t,Ce,j]);const tt=a.useCallback((e=>{he(e),v(void 0),x(!0)}),[]),st=a.useCallback((e=>{t(ls({scheduleId:e.scheduleId}))}),[t]),at=a.useCallback(((e,h)=>{t(ds({enabled:h,scheduleId:e.scheduleId}))}),[t]);a.useEffect((()=>{Q&&t(De())}),[t,Q]);const Ie=b((e=>y(e).skills)),J=a.useMemo((()=>Ie.map((e=>({macroId:e.macroId,name:e.displayName??e.name})))),[Ie]),nt=a.useCallback((e=>{t(Se({macroId:e}))}),[t]),K=a.useCallback((()=>{t(He()),t(Le())}),[t]),ot=a.useCallback((()=>{t(F())}),[t]),{allUsers:it,isAiCardCreationEnabled:rt,isCardPolicyEnabled:lt,onCardPolicyVendorSearchTextChange:dt}=Lt();a.useEffect((()=>{t(us())}),[t]);const g=b((e=>_(e))),R=Ut.getSignedInUser();a.useEffect((()=>u==="routines"?(t(F()),void t(cs())):u==="skills"?(t(de()),t(Ue()),void t(Le())):(U==null&&t(de()),t(Ue()),void t(F()))),[t,U,f,u]);const ut=_t(),O=Gt(ut),k=b((e=>ms(e))),d=g.uiState.currentChatSessionId,P=k.tenantEmailDomain,D=P!=null&&P!=="",X=a.useCallback((e=>{D&&l(`/${P}/ai-cfo/routines?routine=${encodeURIComponent(e.scheduleId)}`)}),[D,l,P]),Z=a.useCallback((()=>{D&&l(`/${P}/ai-cfo/routines`)}),[D,l,P]),ee=a.useCallback(((e,h)=>{const q=e.sessionId??C.sessionId;q!=null&&D&&l(`/${P}/ai-cfo/${q}?routine=${encodeURIComponent(h)}`)}),[D,l,C.sessionId,P]),ct=a.useMemo((()=>I==null?void 0:{error:C.fetchState==="Error",kind:"routineRuns",loading:C.fetchState==="In-Progress"||C.fetchState==="Not-Started",routineName:I.name,schedule:Bt(I),skillName:I.isAdHoc===!0?void 0:J.find((e=>e.macroId===I.macroId))?.name,onOpenSkill:I.isAdHoc===!0?void 0:K,runs:C.runs,tzName:I.tzName,unreadCount:I.unreadRuns,open:ge,onToggle:()=>et((e=>!e)),onOpenRun:e=>ee(e,I.scheduleId),onOpenRoutine:()=>X(I),onOpenRoutines:Z}),[K,Z,X,ee,ge,I,C.fetchState,C.runs,J]),{handleUploadPromoClose:mt,isUploadPromoVisible:St}=Ft({isFileUploadEnabled:s,tenantEmailDomain:P}),te=Mt({currentTenant:k,currentChatSessionId:d,aiCfoView:g,skillsEnabled:A,onCloseSkills:ot,onOpenSkills:K}),{isSuggestedQuestionsLoading:ht,suggestedPromptQuestions:pt}=Ls(),V=i.state,$=V?.aiCfoInitialQuestion,ke=!!V?.aiCfoShouldSubmit;a.useEffect((()=>{const e=i.state;if(e?.[Ae]!==!0)return;m(!0);const h={...e};delete h[Ae],l(i,{replace:!0,state:h})}),[i.pathname,i.search,i.state,l]);const[ft,se]=a.useState(null),[gt,ae]=a.useState(!1),[Ct,ne]=a.useState(void 0),[It,oe]=a.useState(void 0),be=a.useRef(!1);a.useEffect((()=>{if(!be.current&&$!=null&&$!==""){const e=i.state;se($),ae(ke),ne(e?.aiCfoInitialSubmissionSource!=null?e.aiCfoInitialSubmissionSource:void 0);const h=e?.aiCfoSuggestionIndex;oe(typeof h=="number"?h:void 0),be.current=!0}}),[$,ke,i.state]);const kt=a.useCallback((()=>{se(null),ae(!1),ne(void 0),oe(void 0),l(i.pathname,{replace:!0,state:Ne(i.state)})}),[i.pathname,i.state,l]),ve=a.useMemo((()=>new URLSearchParams(i.search)),[i.search]),Ee=ve.get("ref")??V?.aiCfoRef,ie=ve.get("emailRefId")??V?.aiCfoEmailRefId,Pe=a.useRef(!1);a.useEffect((()=>{Pe.current||Ee!=="month-end-email"||ie==null||d!=null||R==null||(t(Ss("controller",R.userId,ie,"MONTH_END_EMAIL")),Pe.current=!0)}),[Ee,ie,d,t,R]);const N=g.uiState.lastContextMessage;a.useEffect((()=>{N!=null&&N!==""&&d!=null&&(se(N),ae(!0),ne(void 0),oe(void 0),t(hs()))}),[N,d,t]);const bt=k.masterTOSInfo,w=bt?.isMasterTOSAccepted??!1,{visitedSessions:we}=Vt(d),G=g.fetchState,H=g.uiState.chatSessionsNextPageToken.hasMore||!g.uiState.chatSessionsFirstPageFetched,ye=d!=null?g.fetchChatSessionHistoryByChatSessionId?.[d]?.fetchState??"Not-Started":"Not-Started",xe=d==null||(g.uiState.chatHistoryNextPageToken[d]?.hasMore??!0),Re=g.allSessionsWithOrderedQuestionAnswers,{currentSessionQuestionAnswers:vt}=Ge(Re,d),Et=vt.length===0;a.useEffect((()=>{w||O||l("../dashboard",{state:{...i.state,message:"open_ai_cfo_drawer"}})}),[w,O,l,i.state]);const Pt=a.useCallback((()=>{const e=me(i.state?.pathnameStackToGoBack),h=k.tenantEmailDomain;l(e.poppedPathname??(h!=null?`/${h}/dashboard`:".."),{state:{...i.state,pathnameStackToGoBack:e.newStack}})}),[k.tenantEmailDomain,i.state,l]),Te=a.useRef(void 0),je=a.useRef(void 0);a.useEffect((()=>{const e=u!==Te.current,h=d!==je.current;Te.current=u,je.current=d,u!==d&&(!e||u==null||_s(u)?h&&d!=null&&l(`../ai-cfo/${d}`,{state:{...i.state}}):t(ps({sessionId:u,agentId:"controller"})))}),[d,u]);const wt=a.useMemo((()=>({events:we.map((e=>`private-encrypted-chat-${e}.${qe}`)),eventCallback:(e,h,q)=>q.onEventReceived(e,h)})),[we]);a.useEffect((()=>{G!=="In-Progress"&&H&&t(fs())}),[G,H,t]),a.useEffect((()=>{d!=null&&ye!=="In-Progress"&&xe&&R!=null&&(u===d||G==="Completed"&&!H)&&t(gs(d,R.userId))}),[ye,G,xe,H,d,R,u,t]);const Oe=e=>e.trackAICFOOnboardingScreenStateChanged("open","first_visit");if(R==null||u==null)throw Error("Can't access AI Controller page without signing in...");const yt=d!=null&&g.responseStateByChatSessionId?.[d]?.answer?.fetchState==="In-Progress";if(!w&&O)return S.jsxs(Vs,{children:[S.jsx(re,{analytics:B,onLoad:Oe}),te.drawerElement,S.jsx($s,{children:S.jsx($e,{children:S.jsx(le,{isTOSAccepted:!1,acceptMasterTOSState:g.masterTOSAcceptanceState,onCloseClick:Pt,onCompleteClick:()=>{k.userRoleId!=null&&t(ce(k.userRoleId))}})})})]});const xt=S.jsxs(S.Fragment,{children:[p&&!w?S.jsx(re,{analytics:B,onLoad:Oe}):null,S.jsx(le,{isTOSAccepted:w,acceptMasterTOSState:g.masterTOSAcceptanceState,showHeader:!1,togglePageView:w?()=>m(!1):void 0,onCloseClick:()=>m(!1),onCompleteClick:()=>{w||k.userRoleId==null||t(ce(k.userRoleId)),m(!1)}})]});return S.jsxs(S.Fragment,{children:[S.jsxs(Ms,{children:[S.jsx(re,{analytics:B,onLoad:e=>e.trackPageLoaded(Ht.Event.aiCFOPage)}),O&&te.drawerElement,S.jsx(Fs,{...wt,currentChatSessionId:d,allSessionsWithOrderedQuestionAnswers:Re,allUsers:it,isAiCardCreationEnabled:rt,isCardPolicyEnabled:lt,openOnboardingPage:()=>m(!0),userId:R.userId,setIsAiCfoOpen:r,navigate:l,sessionFromUrl:u,location:i,isSubmitting:yt,isEmptyChatWithSession:Et,currentTenant:k,emailLinkQuestion:ft??void 0,autoSubmitEmailLinkQuestion:gt,onEmailLinkQuestionProcessed:kt,routedInitialQuestionSource:Ct,routedInitialQuestionSuggestionIndex:It,onCardPolicyVendorSearchTextChange:dt,onMenuClick:O?te.open:void 0,isFileUploadEnabled:s,isUploadPromoVisible:St,onUploadPromoClose:mt,exploreSuggestedPromptQuestions:pt,exploreSuggestedPromptQuestionsLoading:ht,isSkillsOpen:T,isRoutinesOpen:Q,routineCanCreate:c,routineEditing:E,routineEditorOpen:W,routineListError:n.fetchState==="Error",routineListLoading:n.fetchState==="In-Progress",routineMaxRoutines:n.maxRoutines,routineSaveError:o.fetchState==="Error",routineSaving:o.fetchState==="In-Progress",routineSchedulableSkills:J,routines:n.routines,onRoutineCreate:ze,onRoutineDelete:st,routineHistoryError:C.fetchState==="Error",routineHistoryLoading:C.fetchState==="In-Progress",chatSidePanel:ct,routineDetail:pe,routineRunningScheduleId:o.runningScheduleId,routineRuns:C.runs,onRoutineEdit:We,onRoutineOpenRun:(e,h)=>ee(h,e.scheduleId),onRoutineRun:Ke,onRoutineCloseDetail:Z,onRoutineDraft:tt,routineDraftPrompt:Y,onRoutineOpenDetail:X,onRoutineEditorCancel:Ye,onRoutineLoadSkillInstructions:nt,onRoutineSave:Je,onRoutineSetEnabled:at,isCreateSkillEnabled:A,promoDismissalScope:P}),p&&O?S.jsx(As,{anchor:"right",open:p,transitionDuration:250,PaperProps:{component:Ns,style:{width:"100%"}},slotProps:{backdrop:{style:{backgroundColor:"transparent",cursor:"pointer"}}},onClose:()=>m(!1),children:S.jsx($e,{onClick:e=>e.stopPropagation(),children:S.jsx(le,{isTOSAccepted:w,acceptMasterTOSState:g.masterTOSAcceptanceState,onCloseClick:()=>m(!1),onCompleteClick:()=>{w||k.userRoleId==null||t(ce(k.userRoleId)),m(!1)}})})}):null]}),p&&!O?S.jsx($t,{open:p,onClose:()=>m(!1),children:S.jsx(Nt,{children:xt})}):null]})},$e=M(Qs)`
1
+ import{j as S}from"./liveblocks-BPL36a6x.js";import{a}from"./sentry-_x3Yh1Jc.js";import{u as Rt,h as Tt,i as jt,g as Ot,j as b,l as At}from"./core-DOBELRta.js";import{a as Qt,H as Dt,e7 as Lt,z as Ut,a2 as _t,e8 as Bt,e9 as Ft,ea as Mt,bp as Ae,eb as Ne,ec as Vt,bo as Ge,a5 as me,a9 as re,k as B,ed as le,ee as $t,ef as Nt,av as Gt,V as Ht,w as qt,eg as zt,eh as Wt,aw as Yt,ei as Jt,ej as Kt,ek as Xt,el as Zt,p as es,bl as Qe,em as ts}from"./index-D0or4oV9.js";import{fE as _,gt as y,TY as ss,a24 as as,a25 as ns,jM as os,a26 as is,jJ as rs,a27 as de,jD as ue,jT as z,jl as Se,jB as De,jz as ls,jQ as ds,ju as He,U5 as Le,gv as F,gK as us,U4 as cs,TR as Ue,fF as ms,j3 as Ss,a28 as hs,g8 as ps,jh as fs,jd as gs,fG as ce,gf as Cs,a29 as Is,a2a as ks,a2b as bs,gu as vs,go as _e,k4 as Be,gq as Fe,gw as Es,a2c as Me,jV as Ps,ja as ws,jo as ys,jR as Ve,jr as xs,gx as Rs,gy as Ts,gz as js,gA as Os}from"./zeni-epic-state-DXFYDM66.js";import{D as As,n as M,S as Qs,P as Ds}from"./mui-wO6EIETx.js";import{u as Ls}from"./useAiCfoDashboardSuggestedQuestionsChips-BHQEdJfL.js";import{p as Us}from"./pathToGoBack-BTiQNxwp.js";import{j as _s}from"./routePaths-DTZH71MW.js";import"./recharts-Sp9X2zHo.js";import"./analytics-GZ8dIY_c.js";import"./plaid-C-eBmVPr.js";import"./dnd-0MaFz9wL.js";import"./stripe-cKAAJElX.js";import"./lottie-38LSfraF.js";import"./lexical-CAgOy6Q-.js";import"./pdf-B2N0erO1.js";import"./utils-BU0XThgM.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new s.Error().stack;r&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[r]="8e40b9a4-bc42-4493-9122-e742c44cedfc",s._sentryDebugIdIdentifier="sentry-dbid-8e40b9a4-bc42-4493-9122-e742c44cedfc")}catch{}})();const qe="chat-response-generated";function Bs(s,r){if(r.kind!=="save")return;if(r.fetchState==="In-Progress")return{status:"saving"};if(r.fetchState==="Error")return{status:"failed"};if(r.fetchState!=="Completed")return;const t=y(s).skills.find((l=>l.macroId===r.savedMacroId));return t==null?void 0:{status:"saved",command:t.name}}const Fs=At((function(s,r){const t=_(s),l=r.isSubmitting,u=t.uiState?.currentChatSessionId,i=u!=null?Cs(s.aiCfoState,u):[],f=Wt(s,{allUsers:r.allUsers,onCardPolicyVendorSearchTextChange:r.onCardPolicyVendorSearchTextChange}),p=Is(s),m=ks(s),T=bs(s);return{showSampleQuestions:r.sessionFromUrl==="explore"&&t.uiState.currentChatSessionId==null,aiCfoView:t,isSubmitting:l,isNewChatSession:r.sessionFromUrl==="new_chat"||r.sessionFromUrl==="explore",isFullView:!0,tableDownloadEndPoint:`${Yt}/tableDownload`,exportDownloadEndPoint:Xt(),emailLinkQuestion:r.emailLinkQuestion,autoSubmitEmailLinkQuestion:r.autoSubmitEmailLinkQuestion,onEmailLinkQuestionProcessed:r.onEmailLinkQuestionProcessed,routedInitialQuestionSource:r.routedInitialQuestionSource,routedInitialQuestionSuggestionIndex:r.routedInitialQuestionSuggestionIndex,exploreSuggestedPromptQuestions:r.exploreSuggestedPromptQuestions,exploreSuggestedPromptQuestionsLoading:r.exploreSuggestedPromptQuestionsLoading,isFileUploadEnabled:r.isFileUploadEnabled,isUploadPromoVisible:r.isUploadPromoVisible,onUploadPromoClose:r.onUploadPromoClose,skills:y(s).skills,skillSaveState:Bs(s,T),skillsEnabled:y(s).skillsEnabled,skillsList:y(s).skills,skillsListError:y(s).fetchState==="Error",skillsListLoading:y(s).fetchState==="In-Progress",skillsCanPublish:y(s).canPublish,skillSaving:T.fetchState==="In-Progress",skillSaveError:T.fetchState==="Error",skillVersionHistory:p.macroId!=null?{macroId:p.macroId,versions:p.versions,error:p.fetchState==="Error",loading:p.fetchState==="In-Progress"}:void 0,skillRestoreBody:m.macroId!=null&&m.version!=null?{macroId:m.macroId,version:m.version,instructions:m.instructions,error:m.fetchState==="Error",loading:m.fetchState==="In-Progress"}:void 0,skillDetail:z(s).detail,skillDetailError:z(s).fetchState==="Error",skillDetailLoading:z(s).fetchState==="In-Progress",syntheticAnswers:i,resolveSyntheticAnswerCardTile:Kt(s),resolveSyntheticAnswerPolicyTile:Jt(s),...f}}),(function(s,r){const{location:t,currentTenant:l,userId:u,navigate:i,currentChatSessionId:f,allSessionsWithOrderedQuestionAnswers:p,isAiCardCreationEnabled:m,isCardPolicyEnabled:T,setIsAiCfoOpen:A}=r,Q=l.tenantEmailDomain;return{onEventReceived:(n,o)=>{if(n===qe&&typeof o.text=="string"&&typeof o.metadata=="object"){const c=o,E=Rs(c.type),v=c.metadata.chat_session_id??null,{currentChatSession:W,currentQuestionAnswer:x,currentQuestionAnswerSummary:Y}=Ge(p,v);E!=="answer"?B.trackAICFOChatResponseGenerated(E,x?.question.questionText??"",c.text,v,ts(Y,W),c.metadata.message_id??null):B.trackAICFOChatAnswerGenerated(c.text,x?.question.questionText??"",(c.follow_up_questions?.length??0)>0,!!c.assumptions,!!c.insights,c.visualization!=null,Ts(c.visualization?.type??"")??null,v,c.summarized_title,c.metadata.message_id??null),s(js({chatSessionId:c.metadata.chat_session_id,responseType:E,fetchState:{fetchState:"Completed",error:void 0}})),s(Os({chatSessionId:c.metadata.chat_session_id,answerPayload:c,userId:u}))}},onSubmit:(n,o,c,E,v)=>{n&&Qe(s,n,o,f,p,u,E,c,void 0,v)},onFetchSkills:()=>{s(He())},onOpenSkill:n=>{s(Se({macroId:n})),s(xs({macroId:n}))},onSaveSkill:(n,o)=>{s(Ve({draft:n,macroId:o}))},onSaveSkillDraft:n=>{const o=n.displayName?.trim()??"",c=n.name?.trim()??"";s(Ve({draft:{name:o.length>0?o:c,description:n.description?.trim()??null,instructions:n.instructions,visibility:"private"}}))},onFetchSkillVersionBody:(n,o)=>{s(ys({macroId:n,version:o}))},onDeleteSkill:n=>{s(ws({macroId:n}))},onSetSkillVisibility:(n,o)=>{s(Ps({macroId:n,visibility:o}))},onCloseSkillDetail:()=>{s(Me())},onRunSkill:(n,o)=>{s(F()),s(_e()),Qe(s,o,"user_input",void 0,p,u,void 0,void 0,void 0,n),s(Me())},updateCurrentInput:n=>{s(Fe(n))},onStopSubmit:()=>{},onUpdateScrollYOffset:n=>{s(Es(n))},onSelectSampleQuestion:()=>{},onBackClick:()=>{i(-1)},onCloseClick:()=>{const n=me(t.state?.pathnameStackToGoBack),o=n.poppedPathname??Us(1);i(o,{state:{...t.state,pathnameStackToGoBack:n.newStack}}),s(Fe(""))},togglePageView:()=>{const n=me(t.state?.pathnameStackToGoBack),o=n.poppedPathname??`/${l.tenantEmailDomain}/dashboard`;i(o,{state:{...Ne(t.state),pathnameStackToGoBack:n.newStack,message:"open_ai_cfo_drawer"}}),A(!0)},onCopy:()=>{},onThumbsUp:(n,o)=>{f!=null&&o?.messageId!=null&&s(Be(f,o.messageId,"positive",o.questionText,o.answerText))},onThumbsDown:(n,o)=>{f!=null&&o?.messageId!=null&&s(Be(f,o.messageId,"negative",o.questionText,o.answerText))},onTogglePageView:()=>{i(-1)},onNewChatClick:()=>{s(F()),f!=null&&s(_e());const n=es(t.state?.pathnameStackToGoBack,t.pathname);i(`/${l.tenantEmailDomain}/ai-cfo/new_chat`,{state:{pathnameStackToGoBack:n.slice(0,-1),referrer:"Sidebar"}})},onToggleCotCollapsed:(n,o)=>{s(vs({questionAnswerId:n,isCollapsed:o}))},onMenuClick:r.onMenuClick,...Zt(s,{isAiCardCreationEnabled:m,isCardPolicyEnabled:T,currentChatSessionId:f,onAfterCardsCreationSubmit:()=>{A(!0),i(`/${Q}/cards`,{state:{...t.state}})},onAfterCardPolicySubmit:()=>{A(!0),i(`/${Q}/cards/policy`,{state:{...t.state}})}})}}))(qt(zt)),la=({isFileUploadEnabled:s})=>{const{setIsAiCfoOpen:r}=Qt(),t=Rt(),l=Tt(),{session_id:u}=jt(),i=Ot(),f=new URLSearchParams(i.search).get("routine")??void 0,[p,m]=a.useState(!1),T=b((e=>_(e).uiState.isSkillsBrowserOpen===!0)),A=b((e=>y(e).skillsEnabled)),Q=b((e=>_(e).uiState.isRoutinesBrowserOpen===!0)),n=b((e=>ss(e))),o=b((e=>as(e))),c=b((e=>ns(e))),[E,v]=a.useState(void 0),[W,x]=a.useState(!1),[Y,he]=a.useState(void 0),ze=a.useCallback((()=>{he(void 0),v(void 0),x(!0)}),[]),We=a.useCallback((e=>{v(e),x(!0)}),[]),Ye=a.useCallback((()=>{v(void 0),x(!1)}),[]),Je=a.useCallback((e=>{t(os({draft:e,...E!=null&&{scheduleId:E.scheduleId}})),v(void 0),x(!1)}),[t,E]),j=f,pe=n.routines.find((e=>e.scheduleId===j)),C=b((e=>is(e))),Ke=a.useCallback((e=>{t(rs({scheduleId:e.scheduleId}))}),[t]);a.useEffect((()=>{t(j!=null?ue({scheduleId:j}):de())}),[t,j]);const L=pe?.macroId,Xe=b((e=>z(e))),fe=L!=null&&L!==""&&Xe.fetchState==="Not-Started";a.useEffect((()=>{fe&&L!=null&&t(Se({macroId:L}))}),[t,fe,L]);const Ze=b((e=>_(e).uiState.currentChatSessionId))??u,I=n.routines.find((e=>e.scheduleId===f))??n.routines.find((e=>e.scheduleId===Dt(Ze))),U=I?.scheduleId??null,[ge,et]=a.useState(!0);a.useEffect((()=>{U!=null&&t(ue({scheduleId:U}))}),[t,U]);const Ce=C.runs.some((e=>e.status==="claimed"||e.status==="running"))===!0;a.useEffect((()=>{if(j==null||Ce!==!0)return;const e=window.setInterval((()=>{t(ue({scheduleId:j})),t(De())}),5e3);return()=>window.clearInterval(e)}),[t,Ce,j]);const tt=a.useCallback((e=>{he(e),v(void 0),x(!0)}),[]),st=a.useCallback((e=>{t(ls({scheduleId:e.scheduleId}))}),[t]),at=a.useCallback(((e,h)=>{t(ds({enabled:h,scheduleId:e.scheduleId}))}),[t]);a.useEffect((()=>{Q&&t(De())}),[t,Q]);const Ie=b((e=>y(e).skills)),J=a.useMemo((()=>Ie.map((e=>({macroId:e.macroId,name:e.displayName??e.name})))),[Ie]),nt=a.useCallback((e=>{t(Se({macroId:e}))}),[t]),K=a.useCallback((()=>{t(He()),t(Le())}),[t]),ot=a.useCallback((()=>{t(F())}),[t]),{allUsers:it,isAiCardCreationEnabled:rt,isCardPolicyEnabled:lt,onCardPolicyVendorSearchTextChange:dt}=Lt();a.useEffect((()=>{t(us())}),[t]);const g=b((e=>_(e))),R=Ut.getSignedInUser();a.useEffect((()=>u==="routines"?(t(F()),void t(cs())):u==="skills"?(t(de()),t(Ue()),void t(Le())):(U==null&&t(de()),t(Ue()),void t(F()))),[t,U,f,u]);const ut=_t(),O=Gt(ut),k=b((e=>ms(e))),d=g.uiState.currentChatSessionId,P=k.tenantEmailDomain,D=P!=null&&P!=="",X=a.useCallback((e=>{D&&l(`/${P}/ai-cfo/routines?routine=${encodeURIComponent(e.scheduleId)}`)}),[D,l,P]),Z=a.useCallback((()=>{D&&l(`/${P}/ai-cfo/routines`)}),[D,l,P]),ee=a.useCallback(((e,h)=>{const q=e.sessionId??C.sessionId;q!=null&&D&&l(`/${P}/ai-cfo/${q}?routine=${encodeURIComponent(h)}`)}),[D,l,C.sessionId,P]),ct=a.useMemo((()=>I==null?void 0:{error:C.fetchState==="Error",kind:"routineRuns",loading:C.fetchState==="In-Progress"||C.fetchState==="Not-Started",routineName:I.name,schedule:Bt(I),skillName:I.isAdHoc===!0?void 0:J.find((e=>e.macroId===I.macroId))?.name,onOpenSkill:I.isAdHoc===!0?void 0:K,runs:C.runs,tzName:I.tzName,unreadCount:I.unreadRuns,open:ge,onToggle:()=>et((e=>!e)),onOpenRun:e=>ee(e,I.scheduleId),onOpenRoutine:()=>X(I),onOpenRoutines:Z}),[K,Z,X,ee,ge,I,C.fetchState,C.runs,J]),{handleUploadPromoClose:mt,isUploadPromoVisible:St}=Ft({isFileUploadEnabled:s,tenantEmailDomain:P}),te=Mt({currentTenant:k,currentChatSessionId:d,aiCfoView:g,skillsEnabled:A,onCloseSkills:ot,onOpenSkills:K}),{isSuggestedQuestionsLoading:ht,suggestedPromptQuestions:pt}=Ls(),V=i.state,$=V?.aiCfoInitialQuestion,ke=!!V?.aiCfoShouldSubmit;a.useEffect((()=>{const e=i.state;if(e?.[Ae]!==!0)return;m(!0);const h={...e};delete h[Ae],l(i,{replace:!0,state:h})}),[i.pathname,i.search,i.state,l]);const[ft,se]=a.useState(null),[gt,ae]=a.useState(!1),[Ct,ne]=a.useState(void 0),[It,oe]=a.useState(void 0),be=a.useRef(!1);a.useEffect((()=>{if(!be.current&&$!=null&&$!==""){const e=i.state;se($),ae(ke),ne(e?.aiCfoInitialSubmissionSource!=null?e.aiCfoInitialSubmissionSource:void 0);const h=e?.aiCfoSuggestionIndex;oe(typeof h=="number"?h:void 0),be.current=!0}}),[$,ke,i.state]);const kt=a.useCallback((()=>{se(null),ae(!1),ne(void 0),oe(void 0),l(i.pathname,{replace:!0,state:Ne(i.state)})}),[i.pathname,i.state,l]),ve=a.useMemo((()=>new URLSearchParams(i.search)),[i.search]),Ee=ve.get("ref")??V?.aiCfoRef,ie=ve.get("emailRefId")??V?.aiCfoEmailRefId,Pe=a.useRef(!1);a.useEffect((()=>{Pe.current||Ee!=="month-end-email"||ie==null||d!=null||R==null||(t(Ss("controller",R.userId,ie,"MONTH_END_EMAIL")),Pe.current=!0)}),[Ee,ie,d,t,R]);const N=g.uiState.lastContextMessage;a.useEffect((()=>{N!=null&&N!==""&&d!=null&&(se(N),ae(!0),ne(void 0),oe(void 0),t(hs()))}),[N,d,t]);const bt=k.masterTOSInfo,w=bt?.isMasterTOSAccepted??!1,{visitedSessions:we}=Vt(d),G=g.fetchState,H=g.uiState.chatSessionsNextPageToken.hasMore||!g.uiState.chatSessionsFirstPageFetched,ye=d!=null?g.fetchChatSessionHistoryByChatSessionId?.[d]?.fetchState??"Not-Started":"Not-Started",xe=d==null||(g.uiState.chatHistoryNextPageToken[d]?.hasMore??!0),Re=g.allSessionsWithOrderedQuestionAnswers,{currentSessionQuestionAnswers:vt}=Ge(Re,d),Et=vt.length===0;a.useEffect((()=>{w||O||l("../dashboard",{state:{...i.state,message:"open_ai_cfo_drawer"}})}),[w,O,l,i.state]);const Pt=a.useCallback((()=>{const e=me(i.state?.pathnameStackToGoBack),h=k.tenantEmailDomain;l(e.poppedPathname??(h!=null?`/${h}/dashboard`:".."),{state:{...i.state,pathnameStackToGoBack:e.newStack}})}),[k.tenantEmailDomain,i.state,l]),Te=a.useRef(void 0),je=a.useRef(void 0);a.useEffect((()=>{const e=u!==Te.current,h=d!==je.current;Te.current=u,je.current=d,u!==d&&(!e||u==null||_s(u)?h&&d!=null&&l(`../ai-cfo/${d}`,{state:{...i.state}}):t(ps({sessionId:u,agentId:"controller"})))}),[d,u]);const wt=a.useMemo((()=>({events:we.map((e=>`private-encrypted-chat-${e}.${qe}`)),eventCallback:(e,h,q)=>q.onEventReceived(e,h)})),[we]);a.useEffect((()=>{G!=="In-Progress"&&H&&t(fs())}),[G,H,t]),a.useEffect((()=>{d!=null&&ye!=="In-Progress"&&xe&&R!=null&&(u===d||G==="Completed"&&!H)&&t(gs(d,R.userId))}),[ye,G,xe,H,d,R,u,t]);const Oe=e=>e.trackAICFOOnboardingScreenStateChanged("open","first_visit");if(R==null||u==null)throw Error("Can't access AI Controller page without signing in...");const yt=d!=null&&g.responseStateByChatSessionId?.[d]?.answer?.fetchState==="In-Progress";if(!w&&O)return S.jsxs(Vs,{children:[S.jsx(re,{analytics:B,onLoad:Oe}),te.drawerElement,S.jsx($s,{children:S.jsx($e,{children:S.jsx(le,{isTOSAccepted:!1,acceptMasterTOSState:g.masterTOSAcceptanceState,onCloseClick:Pt,onCompleteClick:()=>{k.userRoleId!=null&&t(ce(k.userRoleId))}})})})]});const xt=S.jsxs(S.Fragment,{children:[p&&!w?S.jsx(re,{analytics:B,onLoad:Oe}):null,S.jsx(le,{isTOSAccepted:w,acceptMasterTOSState:g.masterTOSAcceptanceState,showHeader:!1,togglePageView:w?()=>m(!1):void 0,onCloseClick:()=>m(!1),onCompleteClick:()=>{w||k.userRoleId==null||t(ce(k.userRoleId)),m(!1)}})]});return S.jsxs(S.Fragment,{children:[S.jsxs(Ms,{children:[S.jsx(re,{analytics:B,onLoad:e=>e.trackPageLoaded(Ht.Event.aiCFOPage)}),O&&te.drawerElement,S.jsx(Fs,{...wt,currentChatSessionId:d,allSessionsWithOrderedQuestionAnswers:Re,allUsers:it,isAiCardCreationEnabled:rt,isCardPolicyEnabled:lt,openOnboardingPage:()=>m(!0),userId:R.userId,setIsAiCfoOpen:r,navigate:l,sessionFromUrl:u,location:i,isSubmitting:yt,isEmptyChatWithSession:Et,currentTenant:k,emailLinkQuestion:ft??void 0,autoSubmitEmailLinkQuestion:gt,onEmailLinkQuestionProcessed:kt,routedInitialQuestionSource:Ct,routedInitialQuestionSuggestionIndex:It,onCardPolicyVendorSearchTextChange:dt,onMenuClick:O?te.open:void 0,isFileUploadEnabled:s,isUploadPromoVisible:St,onUploadPromoClose:mt,exploreSuggestedPromptQuestions:pt,exploreSuggestedPromptQuestionsLoading:ht,isSkillsOpen:T,isRoutinesOpen:Q,routineCanCreate:c,routineEditing:E,routineEditorOpen:W,routineListError:n.fetchState==="Error",routineListLoading:n.fetchState==="In-Progress",routineMaxRoutines:n.maxRoutines,routineSaveError:o.fetchState==="Error",routineSaving:o.fetchState==="In-Progress",routineSchedulableSkills:J,routines:n.routines,onRoutineCreate:ze,onRoutineDelete:st,routineHistoryError:C.fetchState==="Error",routineHistoryLoading:C.fetchState==="In-Progress",chatSidePanel:ct,routineDetail:pe,routineRunningScheduleId:o.runningScheduleId,routineRuns:C.runs,onRoutineEdit:We,onRoutineOpenRun:(e,h)=>ee(h,e.scheduleId),onRoutineRun:Ke,onRoutineCloseDetail:Z,onRoutineDraft:tt,routineDraftPrompt:Y,onRoutineOpenDetail:X,onRoutineEditorCancel:Ye,onRoutineLoadSkillInstructions:nt,onRoutineSave:Je,onRoutineSetEnabled:at,isCreateSkillEnabled:A,promoDismissalScope:P}),p&&O?S.jsx(As,{anchor:"right",open:p,transitionDuration:250,PaperProps:{component:Ns,style:{width:"100%"}},slotProps:{backdrop:{style:{backgroundColor:"transparent",cursor:"pointer"}}},onClose:()=>m(!1),children:S.jsx($e,{onClick:e=>e.stopPropagation(),children:S.jsx(le,{isTOSAccepted:w,acceptMasterTOSState:g.masterTOSAcceptanceState,onCloseClick:()=>m(!1),onCompleteClick:()=>{w||k.userRoleId==null||t(ce(k.userRoleId)),m(!1)}})})}):null]}),p&&!O?S.jsx($t,{open:p,onClose:()=>m(!1),children:S.jsx(Nt,{children:xt})}):null]})},$e=M(Qs)`
2
2
  display: flex;
3
3
  min-height: 100%;
4
4
  flex-direction: column;
@@ -1,4 +1,4 @@
1
- import{j as d}from"./liveblocks-BPL36a6x.js";import{a as o,R as va}from"./sentry-_x3Yh1Jc.js";import{u as Me,j as r,g as ya,h as $a,q as G}from"./core-DOBELRta.js";import{fF as Fe,TP as Ba,TQ as Re,g9 as xa,gv as W,TR as J,ju as Ie,jB as Te,TS as Aa,TT as _a,gO as Da,p$ as Ma,TU as Fa,TV as ve,gm as Ra,TW as $,fE as Za,gt as Ga,TX as Pa,TY as Va,TZ as ja,T_ as ye,T$ as Ha,U0 as $e,U1 as La,E5 as Na,gn as Ua,h1 as Oa,cV as za,U2 as qa,U3 as Ya,qC as Qa,g8 as Wa,j6 as Ja,U4 as Xa,U5 as Ka,wq as et,go as at}from"./zeni-epic-state-DXFYDM66.js";import{w as tt,i as nt,a as ot,R as st,E as rt,c as it,A as m,d as lt,u as dt,e as ct,f as ut,g as mt,h as Ct,_ as pt,H as ht,j as ft,z as gt,k as P,p,m as Be,l as bt,q as St,n as xe,o as kt,Q as Ae,r as Et,O as wt,s as K,v as X,x as It,y as Tt,B as vt,L as yt,C as $t,D as Bt,F as ee,I as xt,J as At}from"./index-CXbL8CxL.js";import{A as _t,b as Dt,I as Mt,a as _e,d as Ft,D as De}from"./mui-wO6EIETx.js";import{u as Rt}from"./InboxNotificationsProvider-Bd8tLMl8.js";import{u as Zt}from"./useTaskManagerAccess-CiaMEBoG.js";import{u as Gt}from"./expenseAutomationHelper-CRKfrxDD.js";import"./recharts-Sp9X2zHo.js";import"./analytics-GZ8dIY_c.js";import"./plaid-C-eBmVPr.js";import"./dnd-0MaFz9wL.js";import"./stripe-cKAAJElX.js";import"./lottie-38LSfraF.js";import"./lexical-CAgOy6Q-.js";import"./pdf-B2N0erO1.js";import"./utils-BU0XThgM.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},C=new a.Error().stack;C&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[C]="d90e326b-bdc2-4a55-8a25-f3f86e7dc5ba",a._sentryDebugIdIdentifier="sentry-dbid-d90e326b-bdc2-4a55-8a25-f3f86e7dc5ba")}catch{}})();const B="AppDrawer",c={root:`${B}-root`,drawer:`${B}-drawer`,appBar:`${B}-appBar`,menuButton:`${B}-menuButton`,appBarZenilogo:`${B}-appBarZenilogo`,drawerZenilogo:`${B}-drawerZenilogo`},Pt=ee("div",{slot:"Root"})((({theme:a})=>({[`&.${c.root}`]:{display:"flex"},[`& .${c.drawer}`]:{[a.breakpoints.up("md")]:{width:K,flexShrink:0,backgroundColor:a.colors.background}},[`& .${c.appBar}`]:{color:a.colors.primary,backgroundColor:a.colors.background,boxShadow:"none"},"& .MuiToolbar-root":{backgroundColor:a.colors.background},[`& .${c.menuButton}`]:{marginRight:a.spacing(2),[a.breakpoints.up("md")]:{display:"none"}},[`& .${c.appBarZenilogo}`]:{fill:a.colors.primary,cursor:"pointer",width:"100%",marginLeft:a.spacing(-6)},[`& .${c.drawerZenilogo}`]:{margin:`${a.spacing(3)} ${a.spacing(3)} ${a.spacing(0)}`,fill:a.colors.primary,cursor:"pointer"}}))),Vt=tt((function({tenantEmailDomain:a}){const{isAiCfoOpen:C,setIsAiCfoOpen:b}=ot(),[V,A]=va.useState(!1),[S,Ze]=o.useState(!1),t=ya(),s=$a(),ae=xa(),te=st(),n=Me(),[Ge,Pe]=o.useState(!1),j=rt(),ne=t.pathname.includes("/ai-cfo/");o.useEffect((()=>{ne||(n(W()),n(J()))}),[n,ne]),o.useEffect((()=>{n(W()),n(J())}),[n,a]);const{useFeatureGate:u}=it(),{isFeatureEnabled:oe}=u(m.isDebitCardFeatureEnabled),k=lt(),i=r((e=>Fe(e))),H=i.masterTOSInfo?.isMasterTOSAccepted??!1,{setLoading:Ve}=dt(),E=ct(),{isTaskManagerAccessEnabled:_,isZeniUser:je}=Zt(k),se=ut(),w=mt();o.useEffect((()=>{w&&E&&(n(Ie()),n(Te()))}),[n,w,i.tenantId,E]);const[L,He]=o.useState(void 0),Le=!!i.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:Ne}=u(m.isChargeCardFeatureEnabled),Ue=Ct(i,Ne,oe),{isFeatureEnabled:Oe}=u(m.isSettingsFeatureEnabled),{isFeatureEnabled:D}=u(m.isReferralFeatureEnabled),ze=i.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",re=r((e=>Aa(e)));o.useEffect((()=>{const e=()=>{Pe(window.scrollY>10)};return window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}}),[]);const N=r((e=>_a(e))),h=r((e=>e.expenseAutomationViewState.selectedPeriodByTenantId)),f=r((e=>Da(e))),{monthEndCloseChecksView:I}=f,qe=G("/signout")!==null,M=G("/:tenantEmailDomain/dashboard")!==null,ie=G("/:tenantEmailDomain/reports")!==null,g=G("/:tenantEmailDomain/onboarding/*")!==null,le=Gt();o.useEffect((()=>{w&&D&&!g&&N.fetchState==="Not-Started"&&n(Ma(!0))}),[w,D,N.fetchState,g]),o.useEffect((()=>{if(le){const e=t.state?.origin;if(e!=null){const l=Fa(e);l!=null&&n(ve(l))}}}),[le,t.state]);const Ye=qe||g,U=r((e=>e.tenantState)),Qe=r((e=>U.fetchState==="Completed"?Ra(e):[])),{isFeatureEnabled:We}=u(m.isApAgingFeatureEnabled),{isFeatureEnabled:Je}=u(m.isArAgingFeatureEnabled),{isFeatureEnabled:Xe}=u(m.isDashboardSidebarHalloweenAnimationEnabled),{isFeatureEnabled:Ke}=u(m.isDashboardSidebarThanksGivingAnimationEnabled),{isFeatureEnabled:ea}=u(m.isDashboardSidebarChristmasAnimationEnabled),{isFeatureEnabled:aa}=u(m.isDashboardSidebarNewYearAnimationEnabled),ta=r((e=>$(e).totalUnreadCount)),na=r((e=>$(e).notificationDetailsByTab.tasks.uiState.unreadCount)),oa=r((e=>$(e).notificationDetailsByTab.comments.uiState.unreadCount)),sa=r((e=>$(e).reducedFetchCountState)),de=r((e=>$(e).notificationDetailsByTab.tasks.fetchCountState)),O=r((e=>Za(e))),ra=r((e=>Ga(e).skillsEnabled)),ia=r((e=>Pa(e))),ce=r((e=>Va(e).routines)),la=o.useMemo((()=>ce.filter((e=>e.sessionId!=null)).map((e=>({cadence:pt(e),name:e.name,scheduleId:e.scheduleId,sessionId:e.sessionId,unreadRuns:e.unreadRuns})))),[ce]),da=new URLSearchParams(t.search).get("routine")??ht(t.pathname.split("/ai-cfo/")[1])??void 0,ca=o.useCallback(((e,l)=>{s(l!=null&&l!==""?`/${a}/ai-cfo/${encodeURIComponent(l)}`:`/${a}/ai-cfo/routines?routine=${encodeURIComponent(e)}`)}),[s,a]),{status:ue}=r(ja),[T,z]=o.useState(void 0),q=O.uiState.currentChatSessionId,F=T!=null?O.deleteChatSessionStateByChatSessionId[T]?.fetchState:void 0,me=ft(F),{inboxNotifications:Y,isLoading:Ce,isFetchingMore:pe,hasFetchedAll:he,fetchMore:ua}=Rt(),R=r((e=>$(e).notificationDetailsByTab.comments.fetchCountState));o.useEffect((()=>{const e=setTimeout((()=>ua?.()),0);return()=>clearTimeout(e)})),o.useEffect((()=>{if(T!=null)return me==="In-Progress"&&F==="Completed"?(n(ye({chatSessionId:T})),z(void 0),void s(`/${a}/ai-cfo/explore`,{state:{...t.state,referrer:"Sidebar"}})):void(F==="Error"&&(n(ye({chatSessionId:T})),z(void 0)))}),[n,t.state,s,F,T,me,a]),o.useEffect((()=>{if(Ce===!1&&pe===!1&&he===!0&&i?.companyId!=null&&Y!=null){const e=`dashboard_${i.companyId}`;He(Y.filter((l=>l.roomId===e&&l.readAt==null)).length)}}),[Ce,pe,he,i?.companyId,Y]),o.useEffect((()=>{w&&_&&!g&&de.fetchState==="Not-Started"&&ae.tenantId!=null&&n(Ha("task_manager","dashboard"))}),[w,_,g,de.fetchState,ae.tenantId,n]),o.useEffect((()=>{g||R.fetchState!=="Not-Started"||n($e({fetchCountState:{fetchState:"In-Progress",error:void 0}},"comments"))}),[g,R.fetchState,n]),o.useEffect((()=>{if(L!=null){const{fetchState:e}=R;e!=="In-Progress"&&e!=="Completed"||(e==="In-Progress"&&n($e({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),n(Re({unreadCount:L},"comments")))}}),[L,R.fetchState]);const ma={fetchStatus:sa,count:ta},v=[];We===!1&&v.push("accounts_payable_aging"),Je===!1&&v.push("accounts_receivable_aging"),v.push("zeni_accounts_promo_card","treasury_promo_card"),D===!1&&v.push("rewards_card"),se===!1&&v.push("expense_automation_card");const fe=r((e=>La(e,v).fetchState)),ge=r((e=>Na(e).fetchState)),be=a!=null?gt.getSignedInUserTenant(a):null,Se=r((e=>be?.tenantId!=null?Ua(e,be.tenantId):void 0)),Ca=M&&(fe==="Completed"||fe==="Error")||ie&&(ge==="Completed"||ge==="Error")||!M&&!ie?void 0:"disabled",pa=o.useMemo((()=>Oa(i.userRole)),[i.userRole]),ha=za(pa),y=e=>{A(e)},fa=ze,ga=i?.rewardsLastViewedTime==null,ba=k?.userEmail!=null&&re.fetchState==="Completed"&&qa(re.notificationSettings,k.userEmail,oe,i,_),Sa=o.useCallback((e=>{const l=t.state?.referrer;if(I.monthEndCloseChecks?.auditSummary!=null&&P.trackMonthCloseAuditPage(e.month,e.year,I.monthEndCloseChecks.reportEmailSentDate!=null?"closed":"in-review",I.monthEndCloseChecks.auditSummary.auditScorePercentage,!1,l??null),n(Ya(i.tenantId,e)),h[i.tenantId]!=null){const x=p(t.state?.pathnameStackToGoBack,t.pathname);s(`/${a}/month_end_close_checks/review/${f.currentSelectedView}/${e.month}-${e.year}`,{state:{pathnameStackToGoBack:x,referrer:f.currentSelectedView}})}n(ve(f.currentSelectedView)),f.reconciliation.selectedAccountId!=null&&n(Qa({selectedAccountId:void 0}))}),[f.reconciliation.selectedAccountId,f.currentSelectedView,i.tenantId,I.monthEndCloseChecks?.auditSummary,I.monthEndCloseChecks?.reportEmailSentDate,h,a,t.state,t.pathname]),ka=o.useMemo((()=>({zIndex:S?12:Be[2]})),[S]),Ea=E&&bt(t),ke=d.jsx(St,{signedInUser:k,currentTenantId:U.currentTenantId??"",tenants:U.fetchState==="Completed"?Qe:Se!=null?[Se]:[],rewardsConfiguration:{isRewardsTabVisible:D,isRewardsAnimated:ga,rewardsPlan:N.rewardsPlan},selectedMenu:C===!0?Ae("ai_cfo"):xe(t)&&ue!=="completed"?Ae("invoicing"):Et(t),isTenantDropdownDisabled:Ca,isSettings:kt(t),isInvoicing:xe(t)&&ue==="completed",isSettingsFeatureEnabled:Oe,currentTenant:i,isVendorsTabVisible:ha,isZeniAccountEnabled:Le,isChargeCardEnabled:Ue,isTreasuryEnabled:fa,isNotificationsTabVisible:ba,notificationCountDetails:ma,isExpenseAutomationEnabledForUser:se,isAiCfoAccessEnabled:E,skillsEnabled:ra&&E,routinesEnabled:ia===!0&&E,routines:la,selectedRoutineId:da,onRoutineSelect:ca,onNotificationIconClick:()=>{y(!1);const e=je?na===0&&oa>0?"notifications/comments":"notifications/tasks":"notifications/comments",l=p(t.state?.pathnameStackToGoBack,t.pathname);s(`${a}/${e}`,{state:{pathnameStackToGoBack:l}})},onZeniLogoClick:()=>{te.toggle()},handleTenantSelect:e=>{Ve(yt.TENANT_SWITCHING),y(!1),$t({dispatch:n,navigate:s,pathToNavigate:Bt(e.tenantEmailDomain,t),selectedTenant:e,signedInUser:k})},handleMenuChange:(e,l)=>{if(k!=null&&P.trackSidePanelClicked(e.type,e.group),y(!1),a==null)return;if(e.type==="routines")return H?(n(Te()),n(Xa()),void s(`/${a}/ai-cfo/routines`,{state:{pathnameStackToGoBack:p(t.state?.pathnameStackToGoBack,t.pathname),referrer:"Sidebar"}})):void X({location:t,navigate:s,mergeState:{referrer:"Sidebar"}});if(e.type==="skills")return H?(n(Ie()),n(Ka()),void s(`/${a}/ai-cfo/skills`,{state:{pathnameStackToGoBack:p(t.state?.pathnameStackToGoBack,t.pathname),referrer:"Sidebar"}})):void X({location:t,navigate:s,mergeState:{referrer:"Sidebar"}});if(n(W()),n(J()),e.type==="invoicing")return C&&b(!1),n(et({cacheOverride:!1})),void s(`../${a}/invoicing/overview`,{state:{pathnameStackToGoBack:p(t.state?.pathnameStackToGoBack,t.pathname),referrer:"Sidebar"}});if(C&&It(e.type)&&b(!1),e.type==="ai_cfo"){if(P.trackAICFOChatScreenStateChanged("viewed","left_menu",q??null,null),!H)return void X({location:t,navigate:s,mergeState:{referrer:"Sidebar"}});const Z=p(t.state?.pathnameStackToGoBack,t.pathname);return void s(`/${a}/ai-cfo/explore`,{state:{pathnameStackToGoBack:Z,referrer:"Sidebar"}})}const x=p(t.state?.pathnameStackToGoBack,t.pathname),Q=e.type,we=At(Q)&&Q!=="command_center";if(Q!=="command_center"&&!we||h[i.tenantId]==null||P.trackMonthEndCloseClicked(h[i.tenantId].month,h[i.tenantId].year,"Sidebar"),we&&h[i.tenantId]!=null){const Z=h[i.tenantId];return void s(`/${a}/month_end_close_checks/review/${e.type}/${Z.month}-${Z.year}`,{state:{pathnameStackToGoBack:x,message:l,referrer:"Sidebar"}})}const Ta=Tt(e.type);vt(e.type)?(q!=null&&n(at()),s(`/${a}/ai-cfo/${e.type}`,{state:{pathnameStackToGoBack:x.slice(0,-1),message:l,referrer:"Sidebar"}})):s(`../${a}/${Ta}`,{state:{pathnameStackToGoBack:x,message:l,referrer:"Sidebar"}})},onDeleteChatSession:e=>{n(Ja(e)),q===e&&z(e)},handleLogOutClick:()=>{y(!1);const e=p(t.state?.pathnameStackToGoBack,t.pathname);s("/signout",{replace:!0,state:{pathnameStackToGoBack:e,message:"logout"}})},handleMyProfileClick:()=>{s(`${a}/settings/my_profile`)},handleReferralsClick:()=>{s(`${a}/rewards/refer`)},handleBackClick:()=>{s(`${a}/dashboard`)},handleCockpitClick:()=>{window.open("/cockpit")},monthEndCloseChecksView:I,onPeriodChange:Sa,onCalendarOpen:Ze,aiCfoView:O,isAiCfo:Ea,isOnDashboard:M,isTaskManagerAccessEnabled:_,updateCurrentChatSessionId:e=>{n(Wa({sessionId:e,agentId:"controller"})),s(`../${a}/ai-cfo/${e}`,{state:{...t.state}})},halloweenAnimationEnabled:Xe,thanksGivingAnimationEnabled:Ke,christmasAnimationEnabled:ea,newYearAnimationEnabled:aa}),wa=d.jsx(_t,{position:"fixed",className:c.appBar,style:{borderBottom:Ge?`1px solid ${j.colors.grey2}`:""},children:d.jsxs(Dt,{style:{minHeight:wt},children:[d.jsx(Mt,{color:"inherit","aria-label":"open drawer",edge:"start",onClick:()=>y(!0),className:c.menuButton,size:"large",children:d.jsx(jt,{})}),d.jsx(Ht,{className:c.appBarZenilogo,onClick:()=>{te.toggle()}})]})}),Ee=_e((e=>e.breakpoints.up("md"))),Ia=_e((e=>e.breakpoints.down("md")));return a==null?null:d.jsxs(Pt,{className:c.root,children:[d.jsx(Ft,{}),Ye===!1?d.jsxs(d.Fragment,{children:[Ee||!M?null:wa,d.jsxs("nav",{className:c.drawer,children:[Ee?null:d.jsx(De,{container:window.document.body,variant:"temporary",open:V,onClose:()=>y(!1),PaperProps:{sx:{width:K,zIndex:Be[2],borderRight:"none",backgroundImage:"none",backgroundColor:j.colors.background}},ModalProps:{keepMounted:!0},children:ke}),Ia?null:d.jsx(De,{PaperProps:{sx:{width:K,borderRight:"none",backgroundImage:"none",backgroundColor:j.colors.background,...ka}},variant:"permanent",open:!0,children:ke})]})]}):null]})})),r1=({tenantEmailDomain:a})=>{const C=Me(),b=r((A=>Fe(A))),V={events:b.userRoleId!=null?[`private-encrypted-${b.userRoleId}.dashboard-user-notification`]:[],eventCallback:(A,S)=>{nt(S)&&Ba(S.mode)==="dashboard"&&C(Re({unreadCount:S.data.unread},"tasks"))}};return d.jsx(Vt,{tenantEmailDomain:a,...V})},jt=ee((a=>o.createElement("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",...a},o.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.604839 4.51889C0.333157 4.57797 0.0879194 4.8318 0.0182541 5.12602C-0.00534674 5.22569 -0.00534674 5.4412 0.0182541 5.54086C0.0523791 5.685 0.117181 5.80198 0.22956 5.92229C0.346814 6.04782 0.459133 6.11627 0.600351 6.14826C0.726193 6.17676 23.2738 6.17676 23.3997 6.14826C23.5409 6.11627 23.6532 6.04782 23.7704 5.92229C23.9348 5.74632 24 5.57908 24 5.33344C24 5.1793 23.9797 5.08352 23.9199 4.95575C23.8455 4.79698 23.6879 4.63709 23.5343 4.56468C23.3857 4.49468 24.2116 4.49926 11.9899 4.50058C2.66632 4.50157 0.669677 4.50479 0.604839 4.51889ZM0.669895 11.1732C0.365117 11.2113 0.0889356 11.4752 0.0182179 11.7958C-0.00468131 11.8996 -0.00469357 12.0996 0.0181935 12.2034C0.0806855 12.4867 0.305734 12.7294 0.581516 12.8108C0.65573 12.8327 1.1761 12.8337 12 12.8337C22.8591 12.8337 23.3441 12.8327 23.4192 12.8106C23.6933 12.7297 23.9196 12.4855 23.9818 12.2034C24.0047 12.0996 24.0047 11.8997 23.9818 11.7959C23.9201 11.516 23.7014 11.2776 23.425 11.1888C23.3558 11.1665 22.8817 11.1655 12.0544 11.164C5.84032 11.1631 0.717278 11.1672 0.669895 11.1732ZM0.594774 17.8516C0.458952 17.8831 0.344939 17.9535 0.22956 18.077C0.0652015 18.253 0 18.4202 0 18.6659C0 18.82 0.0203225 18.9158 0.0801289 19.0435C0.154452 19.2023 0.312097 19.3622 0.465726 19.4346C0.614214 19.5046 -0.209758 19.4999 12 19.4999C21.8294 19.4999 23.3082 19.4975 23.3881 19.4811C23.6596 19.4256 23.9122 19.1669 23.9817 18.8733C24.0053 18.7736 24.0053 18.5581 23.9817 18.4584C23.9476 18.3143 23.8828 18.1973 23.7704 18.077C23.6532 17.9515 23.5409 17.883 23.3997 17.851C23.2779 17.8235 0.713601 17.824 0.594774 17.8516Z",fill:"currentColor"}))))`
1
+ import{j as d}from"./liveblocks-BPL36a6x.js";import{a as o,R as va}from"./sentry-_x3Yh1Jc.js";import{u as Me,j as r,g as ya,h as $a,q as G}from"./core-DOBELRta.js";import{fF as Fe,TP as Ba,TQ as Re,g9 as xa,gv as W,TR as J,ju as Ie,jB as Te,TS as Aa,TT as _a,gO as Da,p$ as Ma,TU as Fa,TV as ve,gm as Ra,TW as $,fE as Za,gt as Ga,TX as Pa,TY as Va,TZ as ja,T_ as ye,T$ as Ha,U0 as $e,U1 as La,E5 as Na,gn as Ua,h1 as Oa,cV as za,U2 as qa,U3 as Ya,qC as Qa,g8 as Wa,j6 as Ja,U4 as Xa,U5 as Ka,wq as et,go as at}from"./zeni-epic-state-DXFYDM66.js";import{w as tt,i as nt,a as ot,R as st,E as rt,c as it,A as m,d as lt,u as dt,e as ct,f as ut,g as mt,h as Ct,_ as pt,H as ht,j as ft,z as gt,k as P,p,m as Be,l as bt,q as St,n as xe,o as kt,Q as Ae,r as Et,O as wt,s as K,v as X,x as It,y as Tt,B as vt,L as yt,C as $t,D as Bt,F as ee,I as xt,J as At}from"./index-D0or4oV9.js";import{A as _t,b as Dt,I as Mt,a as _e,d as Ft,D as De}from"./mui-wO6EIETx.js";import{u as Rt}from"./InboxNotificationsProvider-Bd8tLMl8.js";import{u as Zt}from"./useTaskManagerAccess-CxAfFVI5.js";import{u as Gt}from"./expenseAutomationHelper-CRKfrxDD.js";import"./recharts-Sp9X2zHo.js";import"./analytics-GZ8dIY_c.js";import"./plaid-C-eBmVPr.js";import"./dnd-0MaFz9wL.js";import"./stripe-cKAAJElX.js";import"./lottie-38LSfraF.js";import"./lexical-CAgOy6Q-.js";import"./pdf-B2N0erO1.js";import"./utils-BU0XThgM.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},C=new a.Error().stack;C&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[C]="d90e326b-bdc2-4a55-8a25-f3f86e7dc5ba",a._sentryDebugIdIdentifier="sentry-dbid-d90e326b-bdc2-4a55-8a25-f3f86e7dc5ba")}catch{}})();const B="AppDrawer",c={root:`${B}-root`,drawer:`${B}-drawer`,appBar:`${B}-appBar`,menuButton:`${B}-menuButton`,appBarZenilogo:`${B}-appBarZenilogo`,drawerZenilogo:`${B}-drawerZenilogo`},Pt=ee("div",{slot:"Root"})((({theme:a})=>({[`&.${c.root}`]:{display:"flex"},[`& .${c.drawer}`]:{[a.breakpoints.up("md")]:{width:K,flexShrink:0,backgroundColor:a.colors.background}},[`& .${c.appBar}`]:{color:a.colors.primary,backgroundColor:a.colors.background,boxShadow:"none"},"& .MuiToolbar-root":{backgroundColor:a.colors.background},[`& .${c.menuButton}`]:{marginRight:a.spacing(2),[a.breakpoints.up("md")]:{display:"none"}},[`& .${c.appBarZenilogo}`]:{fill:a.colors.primary,cursor:"pointer",width:"100%",marginLeft:a.spacing(-6)},[`& .${c.drawerZenilogo}`]:{margin:`${a.spacing(3)} ${a.spacing(3)} ${a.spacing(0)}`,fill:a.colors.primary,cursor:"pointer"}}))),Vt=tt((function({tenantEmailDomain:a}){const{isAiCfoOpen:C,setIsAiCfoOpen:b}=ot(),[V,A]=va.useState(!1),[S,Ze]=o.useState(!1),t=ya(),s=$a(),ae=xa(),te=st(),n=Me(),[Ge,Pe]=o.useState(!1),j=rt(),ne=t.pathname.includes("/ai-cfo/");o.useEffect((()=>{ne||(n(W()),n(J()))}),[n,ne]),o.useEffect((()=>{n(W()),n(J())}),[n,a]);const{useFeatureGate:u}=it(),{isFeatureEnabled:oe}=u(m.isDebitCardFeatureEnabled),k=lt(),i=r((e=>Fe(e))),H=i.masterTOSInfo?.isMasterTOSAccepted??!1,{setLoading:Ve}=dt(),E=ct(),{isTaskManagerAccessEnabled:_,isZeniUser:je}=Zt(k),se=ut(),w=mt();o.useEffect((()=>{w&&E&&(n(Ie()),n(Te()))}),[n,w,i.tenantId,E]);const[L,He]=o.useState(void 0),Le=!!i.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:Ne}=u(m.isChargeCardFeatureEnabled),Ue=Ct(i,Ne,oe),{isFeatureEnabled:Oe}=u(m.isSettingsFeatureEnabled),{isFeatureEnabled:D}=u(m.isReferralFeatureEnabled),ze=i.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",re=r((e=>Aa(e)));o.useEffect((()=>{const e=()=>{Pe(window.scrollY>10)};return window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}}),[]);const N=r((e=>_a(e))),h=r((e=>e.expenseAutomationViewState.selectedPeriodByTenantId)),f=r((e=>Da(e))),{monthEndCloseChecksView:I}=f,qe=G("/signout")!==null,M=G("/:tenantEmailDomain/dashboard")!==null,ie=G("/:tenantEmailDomain/reports")!==null,g=G("/:tenantEmailDomain/onboarding/*")!==null,le=Gt();o.useEffect((()=>{w&&D&&!g&&N.fetchState==="Not-Started"&&n(Ma(!0))}),[w,D,N.fetchState,g]),o.useEffect((()=>{if(le){const e=t.state?.origin;if(e!=null){const l=Fa(e);l!=null&&n(ve(l))}}}),[le,t.state]);const Ye=qe||g,U=r((e=>e.tenantState)),Qe=r((e=>U.fetchState==="Completed"?Ra(e):[])),{isFeatureEnabled:We}=u(m.isApAgingFeatureEnabled),{isFeatureEnabled:Je}=u(m.isArAgingFeatureEnabled),{isFeatureEnabled:Xe}=u(m.isDashboardSidebarHalloweenAnimationEnabled),{isFeatureEnabled:Ke}=u(m.isDashboardSidebarThanksGivingAnimationEnabled),{isFeatureEnabled:ea}=u(m.isDashboardSidebarChristmasAnimationEnabled),{isFeatureEnabled:aa}=u(m.isDashboardSidebarNewYearAnimationEnabled),ta=r((e=>$(e).totalUnreadCount)),na=r((e=>$(e).notificationDetailsByTab.tasks.uiState.unreadCount)),oa=r((e=>$(e).notificationDetailsByTab.comments.uiState.unreadCount)),sa=r((e=>$(e).reducedFetchCountState)),de=r((e=>$(e).notificationDetailsByTab.tasks.fetchCountState)),O=r((e=>Za(e))),ra=r((e=>Ga(e).skillsEnabled)),ia=r((e=>Pa(e))),ce=r((e=>Va(e).routines)),la=o.useMemo((()=>ce.filter((e=>e.sessionId!=null)).map((e=>({cadence:pt(e),name:e.name,scheduleId:e.scheduleId,sessionId:e.sessionId,unreadRuns:e.unreadRuns})))),[ce]),da=new URLSearchParams(t.search).get("routine")??ht(t.pathname.split("/ai-cfo/")[1])??void 0,ca=o.useCallback(((e,l)=>{s(l!=null&&l!==""?`/${a}/ai-cfo/${encodeURIComponent(l)}`:`/${a}/ai-cfo/routines?routine=${encodeURIComponent(e)}`)}),[s,a]),{status:ue}=r(ja),[T,z]=o.useState(void 0),q=O.uiState.currentChatSessionId,F=T!=null?O.deleteChatSessionStateByChatSessionId[T]?.fetchState:void 0,me=ft(F),{inboxNotifications:Y,isLoading:Ce,isFetchingMore:pe,hasFetchedAll:he,fetchMore:ua}=Rt(),R=r((e=>$(e).notificationDetailsByTab.comments.fetchCountState));o.useEffect((()=>{const e=setTimeout((()=>ua?.()),0);return()=>clearTimeout(e)})),o.useEffect((()=>{if(T!=null)return me==="In-Progress"&&F==="Completed"?(n(ye({chatSessionId:T})),z(void 0),void s(`/${a}/ai-cfo/explore`,{state:{...t.state,referrer:"Sidebar"}})):void(F==="Error"&&(n(ye({chatSessionId:T})),z(void 0)))}),[n,t.state,s,F,T,me,a]),o.useEffect((()=>{if(Ce===!1&&pe===!1&&he===!0&&i?.companyId!=null&&Y!=null){const e=`dashboard_${i.companyId}`;He(Y.filter((l=>l.roomId===e&&l.readAt==null)).length)}}),[Ce,pe,he,i?.companyId,Y]),o.useEffect((()=>{w&&_&&!g&&de.fetchState==="Not-Started"&&ae.tenantId!=null&&n(Ha("task_manager","dashboard"))}),[w,_,g,de.fetchState,ae.tenantId,n]),o.useEffect((()=>{g||R.fetchState!=="Not-Started"||n($e({fetchCountState:{fetchState:"In-Progress",error:void 0}},"comments"))}),[g,R.fetchState,n]),o.useEffect((()=>{if(L!=null){const{fetchState:e}=R;e!=="In-Progress"&&e!=="Completed"||(e==="In-Progress"&&n($e({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),n(Re({unreadCount:L},"comments")))}}),[L,R.fetchState]);const ma={fetchStatus:sa,count:ta},v=[];We===!1&&v.push("accounts_payable_aging"),Je===!1&&v.push("accounts_receivable_aging"),v.push("zeni_accounts_promo_card","treasury_promo_card"),D===!1&&v.push("rewards_card"),se===!1&&v.push("expense_automation_card");const fe=r((e=>La(e,v).fetchState)),ge=r((e=>Na(e).fetchState)),be=a!=null?gt.getSignedInUserTenant(a):null,Se=r((e=>be?.tenantId!=null?Ua(e,be.tenantId):void 0)),Ca=M&&(fe==="Completed"||fe==="Error")||ie&&(ge==="Completed"||ge==="Error")||!M&&!ie?void 0:"disabled",pa=o.useMemo((()=>Oa(i.userRole)),[i.userRole]),ha=za(pa),y=e=>{A(e)},fa=ze,ga=i?.rewardsLastViewedTime==null,ba=k?.userEmail!=null&&re.fetchState==="Completed"&&qa(re.notificationSettings,k.userEmail,oe,i,_),Sa=o.useCallback((e=>{const l=t.state?.referrer;if(I.monthEndCloseChecks?.auditSummary!=null&&P.trackMonthCloseAuditPage(e.month,e.year,I.monthEndCloseChecks.reportEmailSentDate!=null?"closed":"in-review",I.monthEndCloseChecks.auditSummary.auditScorePercentage,!1,l??null),n(Ya(i.tenantId,e)),h[i.tenantId]!=null){const x=p(t.state?.pathnameStackToGoBack,t.pathname);s(`/${a}/month_end_close_checks/review/${f.currentSelectedView}/${e.month}-${e.year}`,{state:{pathnameStackToGoBack:x,referrer:f.currentSelectedView}})}n(ve(f.currentSelectedView)),f.reconciliation.selectedAccountId!=null&&n(Qa({selectedAccountId:void 0}))}),[f.reconciliation.selectedAccountId,f.currentSelectedView,i.tenantId,I.monthEndCloseChecks?.auditSummary,I.monthEndCloseChecks?.reportEmailSentDate,h,a,t.state,t.pathname]),ka=o.useMemo((()=>({zIndex:S?12:Be[2]})),[S]),Ea=E&&bt(t),ke=d.jsx(St,{signedInUser:k,currentTenantId:U.currentTenantId??"",tenants:U.fetchState==="Completed"?Qe:Se!=null?[Se]:[],rewardsConfiguration:{isRewardsTabVisible:D,isRewardsAnimated:ga,rewardsPlan:N.rewardsPlan},selectedMenu:C===!0?Ae("ai_cfo"):xe(t)&&ue!=="completed"?Ae("invoicing"):Et(t),isTenantDropdownDisabled:Ca,isSettings:kt(t),isInvoicing:xe(t)&&ue==="completed",isSettingsFeatureEnabled:Oe,currentTenant:i,isVendorsTabVisible:ha,isZeniAccountEnabled:Le,isChargeCardEnabled:Ue,isTreasuryEnabled:fa,isNotificationsTabVisible:ba,notificationCountDetails:ma,isExpenseAutomationEnabledForUser:se,isAiCfoAccessEnabled:E,skillsEnabled:ra&&E,routinesEnabled:ia===!0&&E,routines:la,selectedRoutineId:da,onRoutineSelect:ca,onNotificationIconClick:()=>{y(!1);const e=je?na===0&&oa>0?"notifications/comments":"notifications/tasks":"notifications/comments",l=p(t.state?.pathnameStackToGoBack,t.pathname);s(`${a}/${e}`,{state:{pathnameStackToGoBack:l}})},onZeniLogoClick:()=>{te.toggle()},handleTenantSelect:e=>{Ve(yt.TENANT_SWITCHING),y(!1),$t({dispatch:n,navigate:s,pathToNavigate:Bt(e.tenantEmailDomain,t),selectedTenant:e,signedInUser:k})},handleMenuChange:(e,l)=>{if(k!=null&&P.trackSidePanelClicked(e.type,e.group),y(!1),a==null)return;if(e.type==="routines")return H?(n(Te()),n(Xa()),void s(`/${a}/ai-cfo/routines`,{state:{pathnameStackToGoBack:p(t.state?.pathnameStackToGoBack,t.pathname),referrer:"Sidebar"}})):void X({location:t,navigate:s,mergeState:{referrer:"Sidebar"}});if(e.type==="skills")return H?(n(Ie()),n(Ka()),void s(`/${a}/ai-cfo/skills`,{state:{pathnameStackToGoBack:p(t.state?.pathnameStackToGoBack,t.pathname),referrer:"Sidebar"}})):void X({location:t,navigate:s,mergeState:{referrer:"Sidebar"}});if(n(W()),n(J()),e.type==="invoicing")return C&&b(!1),n(et({cacheOverride:!1})),void s(`../${a}/invoicing/overview`,{state:{pathnameStackToGoBack:p(t.state?.pathnameStackToGoBack,t.pathname),referrer:"Sidebar"}});if(C&&It(e.type)&&b(!1),e.type==="ai_cfo"){if(P.trackAICFOChatScreenStateChanged("viewed","left_menu",q??null,null),!H)return void X({location:t,navigate:s,mergeState:{referrer:"Sidebar"}});const Z=p(t.state?.pathnameStackToGoBack,t.pathname);return void s(`/${a}/ai-cfo/explore`,{state:{pathnameStackToGoBack:Z,referrer:"Sidebar"}})}const x=p(t.state?.pathnameStackToGoBack,t.pathname),Q=e.type,we=At(Q)&&Q!=="command_center";if(Q!=="command_center"&&!we||h[i.tenantId]==null||P.trackMonthEndCloseClicked(h[i.tenantId].month,h[i.tenantId].year,"Sidebar"),we&&h[i.tenantId]!=null){const Z=h[i.tenantId];return void s(`/${a}/month_end_close_checks/review/${e.type}/${Z.month}-${Z.year}`,{state:{pathnameStackToGoBack:x,message:l,referrer:"Sidebar"}})}const Ta=Tt(e.type);vt(e.type)?(q!=null&&n(at()),s(`/${a}/ai-cfo/${e.type}`,{state:{pathnameStackToGoBack:x.slice(0,-1),message:l,referrer:"Sidebar"}})):s(`../${a}/${Ta}`,{state:{pathnameStackToGoBack:x,message:l,referrer:"Sidebar"}})},onDeleteChatSession:e=>{n(Ja(e)),q===e&&z(e)},handleLogOutClick:()=>{y(!1);const e=p(t.state?.pathnameStackToGoBack,t.pathname);s("/signout",{replace:!0,state:{pathnameStackToGoBack:e,message:"logout"}})},handleMyProfileClick:()=>{s(`${a}/settings/my_profile`)},handleReferralsClick:()=>{s(`${a}/rewards/refer`)},handleBackClick:()=>{s(`${a}/dashboard`)},handleCockpitClick:()=>{window.open("/cockpit")},monthEndCloseChecksView:I,onPeriodChange:Sa,onCalendarOpen:Ze,aiCfoView:O,isAiCfo:Ea,isOnDashboard:M,isTaskManagerAccessEnabled:_,updateCurrentChatSessionId:e=>{n(Wa({sessionId:e,agentId:"controller"})),s(`../${a}/ai-cfo/${e}`,{state:{...t.state}})},halloweenAnimationEnabled:Xe,thanksGivingAnimationEnabled:Ke,christmasAnimationEnabled:ea,newYearAnimationEnabled:aa}),wa=d.jsx(_t,{position:"fixed",className:c.appBar,style:{borderBottom:Ge?`1px solid ${j.colors.grey2}`:""},children:d.jsxs(Dt,{style:{minHeight:wt},children:[d.jsx(Mt,{color:"inherit","aria-label":"open drawer",edge:"start",onClick:()=>y(!0),className:c.menuButton,size:"large",children:d.jsx(jt,{})}),d.jsx(Ht,{className:c.appBarZenilogo,onClick:()=>{te.toggle()}})]})}),Ee=_e((e=>e.breakpoints.up("md"))),Ia=_e((e=>e.breakpoints.down("md")));return a==null?null:d.jsxs(Pt,{className:c.root,children:[d.jsx(Ft,{}),Ye===!1?d.jsxs(d.Fragment,{children:[Ee||!M?null:wa,d.jsxs("nav",{className:c.drawer,children:[Ee?null:d.jsx(De,{container:window.document.body,variant:"temporary",open:V,onClose:()=>y(!1),PaperProps:{sx:{width:K,zIndex:Be[2],borderRight:"none",backgroundImage:"none",backgroundColor:j.colors.background}},ModalProps:{keepMounted:!0},children:ke}),Ia?null:d.jsx(De,{PaperProps:{sx:{width:K,borderRight:"none",backgroundImage:"none",backgroundColor:j.colors.background,...ka}},variant:"permanent",open:!0,children:ke})]})]}):null]})})),r1=({tenantEmailDomain:a})=>{const C=Me(),b=r((A=>Fe(A))),V={events:b.userRoleId!=null?[`private-encrypted-${b.userRoleId}.dashboard-user-notification`]:[],eventCallback:(A,S)=>{nt(S)&&Ba(S.mode)==="dashboard"&&C(Re({unreadCount:S.data.unread},"tasks"))}};return d.jsx(Vt,{tenantEmailDomain:a,...V})},jt=ee((a=>o.createElement("svg",{viewBox:"0 0 24 24",fill:"none",xmlns:"http://www.w3.org/2000/svg",width:"1em",height:"1em",...a},o.createElement("path",{fillRule:"evenodd",clipRule:"evenodd",d:"M0.604839 4.51889C0.333157 4.57797 0.0879194 4.8318 0.0182541 5.12602C-0.00534674 5.22569 -0.00534674 5.4412 0.0182541 5.54086C0.0523791 5.685 0.117181 5.80198 0.22956 5.92229C0.346814 6.04782 0.459133 6.11627 0.600351 6.14826C0.726193 6.17676 23.2738 6.17676 23.3997 6.14826C23.5409 6.11627 23.6532 6.04782 23.7704 5.92229C23.9348 5.74632 24 5.57908 24 5.33344C24 5.1793 23.9797 5.08352 23.9199 4.95575C23.8455 4.79698 23.6879 4.63709 23.5343 4.56468C23.3857 4.49468 24.2116 4.49926 11.9899 4.50058C2.66632 4.50157 0.669677 4.50479 0.604839 4.51889ZM0.669895 11.1732C0.365117 11.2113 0.0889356 11.4752 0.0182179 11.7958C-0.00468131 11.8996 -0.00469357 12.0996 0.0181935 12.2034C0.0806855 12.4867 0.305734 12.7294 0.581516 12.8108C0.65573 12.8327 1.1761 12.8337 12 12.8337C22.8591 12.8337 23.3441 12.8327 23.4192 12.8106C23.6933 12.7297 23.9196 12.4855 23.9818 12.2034C24.0047 12.0996 24.0047 11.8997 23.9818 11.7959C23.9201 11.516 23.7014 11.2776 23.425 11.1888C23.3558 11.1665 22.8817 11.1655 12.0544 11.164C5.84032 11.1631 0.717278 11.1672 0.669895 11.1732ZM0.594774 17.8516C0.458952 17.8831 0.344939 17.9535 0.22956 18.077C0.0652015 18.253 0 18.4202 0 18.6659C0 18.82 0.0203225 18.9158 0.0801289 19.0435C0.154452 19.2023 0.312097 19.3622 0.465726 19.4346C0.614214 19.5046 -0.209758 19.4999 12 19.4999C21.8294 19.4999 23.3082 19.4975 23.3881 19.4811C23.6596 19.4256 23.9122 19.1669 23.9817 18.8733C24.0053 18.7736 24.0053 18.5581 23.9817 18.4584C23.9476 18.3143 23.8828 18.1973 23.7704 18.077C23.6532 17.9515 23.5409 17.883 23.3997 17.851C23.2779 17.8235 0.713601 17.824 0.594774 17.8516Z",fill:"currentColor"}))))`
2
2
  height: 20px;
3
3
  width: 20px;
4
4
  color: ${a=>a.theme.colors.primary};
@@ -1 +1 @@
1
- import{j as u}from"./liveblocks-BPL36a6x.js";import{a as d}from"./sentry-_x3Yh1Jc.js";import{h as U,g as B,u as j,j as y,N as F,l as V,i as W,n as te,o as x}from"./core-DOBELRta.js";import{fF as P,YQ as w,Yx as R,HB as E,Hv as q,Hz as A,Ho as z,Yz as Y,Hs as ae,HD as oe,Hr as K,HG as G,HC as C}from"./zeni-epic-state-DXFYDM66.js";import{z as T,w as J,bZ as pe,o as O,bT as Q,b_ as le,E as Z,a8 as M,b$ as se,c0 as ne}from"./index-CXbL8CxL.js";import"./mui-wO6EIETx.js";import{u as X,i as re}from"./ReimbursementApprovalRuleDetailScreen-BqumfK_F.js";import ie from"./NotFoundScreen-rNwJ2-Qg.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},l=new e.Error().stack;l&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[l]="d85a50e5-e217-4122-9b22-bbf9146eab3b",e._sentryDebugIdIdentifier="sentry-dbid-d85a50e5-e217-4122-9b22-bbf9146eab3b")}catch{}})();const k="bill-approval-rule-update",ce=V((function(e){return{approvalView:w(e),billPaySetupApproverViewUpdateData:R(e).billPaySetupApproverViewUpdateData}}),(function(e,l){const{navigate:t,location:o}=l;return{onApprovalRulesEventReceived:a=>{a.endsWith(k)&&e(Y(!1))},onBackClick:()=>{O(o)?t("../../"):t("../../../bills/setup")},onDeleteRuleClick:a=>{e(z(a,!1))},onEditRuleClick:a=>{a!=null?(e(A(a)),t(`./${a}/edit`)):(e(A()),t("./new"))}}}))(J(pe)),ue=({isLoading:e})=>{const l=U(),t=B(),o=j(),[a,n]=d.useState(!1),[s,v]=d.useState(!1),p=y((r=>r.billPaySetupApproverViewState.fetchState)),f=y((r=>P(r))),c=y((r=>w(r))),S=y((r=>R(r).billPaySetupApproverViewUpdateData));if(d.useEffect((()=>{S?.updateStatus.fetchState==="Completed"&&o(E())}),[S]),d.useEffect((()=>{a||p!=="Not-Started"||e||(n(!0),o(q(!0,!0,!1)))}),[a,p,e,o]),T.getSignedInUser()==null)throw Error("Can't access billpay approval without signing in...");d.useEffect((()=>{c.allApprovalRules.length===0&&c.fetchState==="Completed"&&(s||(v(!0),o(A())),l("./new"))}),[s,c,o]);const g={events:f.companyId!=null?[`private-encrypted-${f.companyId}.${k}`]:[],eventCallback:(r,h,b)=>{r.endsWith(k)&&b.onApprovalRulesEventReceived(r)}};return f?.companyBillPayInfo?.info?.isBillPayTOSAccepted===!1?u.jsx(F,{to:"../../promo"}):u.jsx(ce,{currentTenant:f,location:t,navigate:l,...g})},L="bill-approval-rule-update",de=V((function(e){const l=w(e),t=R(e).billPaySetupApproverViewUpdateData,o={};for(const n of Object.values(e.vendorState.vendorByID))n?.id!=null&&(o[n.id]=n.name);const a={};for(const n of Object.values(e.classState.classesByKey))n?.classId!=null&&(a[n.classId]=n.className);return{approvalView:l,billPaySetupApproverViewUpdateData:t,vendorNamesById:o,departmentNamesById:a}}),(function(e,l){const{navigate:t,location:o}=l;return{onApprovalRulesEventReceived:a=>{a.endsWith(L)&&e(Y(!1))},onBackClick:()=>{O(o)?t("../../"):t("../../../bills/setup")},onDeleteRuleClick:a=>{e(z(a,!0))},onEditRuleClick:a=>{a!=null?(e(A(a)),t(`./${a}/edit`)):(e(A()),t("./new"))},onReorderRules:a=>{e(oe(a,!0))}}}))(J(le)),ve=()=>{const e=y((o=>P(o))),{isApprovalRulesV3Enabled:l,isLoading:t}=Q(e?.tenantId);return l?u.jsx(fe,{isLoading:t}):u.jsx(ue,{isLoading:t})},fe=({isLoading:e})=>{const l=U(),t=B(),o=j(),[a,n]=d.useState(!1),[s,v]=d.useState(!1),[p,f]=d.useState(!1),c=y((i=>i.billPaySetupApproverViewState.fetchState)),S=y((i=>i.billPaySetupApproverViewState.approverListState.fetchStatus.fetchState)),g=y((i=>P(i)));X();const r=y((i=>w(i))),h=y((i=>R(i).billPaySetupApproverViewUpdateData));if(d.useEffect((()=>{h?.updateStatus.fetchState==="Completed"&&o(E())}),[h]),d.useEffect((()=>{a||c!=="Not-Started"||e||(n(!0),o(q(!0,!0,!0)))}),[a,c,e,o]),d.useEffect((()=>{s||S!=="Not-Started"||e||(v(!0),o(ae(!1,!0)))}),[s,S,e,o]),T.getSignedInUser()==null)throw Error("Can't access billpay approval without signing in...");d.useEffect((()=>{r.allApprovalRules.length===0&&r.fetchState==="Completed"&&(p||(f(!0),o(A())),l("./new"))}),[p,r,o]);const b={events:g.companyId!=null?[`private-encrypted-${g.companyId}.${L}`]:[],eventCallback:(i,I,m)=>{i.endsWith(L)&&m.onApprovalRulesEventReceived(i)}};return g?.companyBillPayInfo?.info?.isBillPayTOSAccepted===!1?u.jsx(F,{to:"../../promo"}):u.jsx(de,{currentTenant:g,location:t,navigate:l,isLoading:e,...b})},ye=V((function(e,l){const t=R(e),o=t.billPaySetupApproverViewUpdateData?.type??"approval_create",a=o==="approval_create"&&t.allApprovalRules.length!==0;let n=t.allApprovalRules.length===0;return l.approvalRuleId&&(n=t.allApprovalRules.findIndex((s=>s.approvalRuleId===l.approvalRuleId))===0),{localData:t,hideUpperBoundField:a,isLowerBoundDisabled:n,approvalUpdateActionType:o}}),(function(e,l){const{navigate:t,approvalUpdateDataView:o,approverViewData:a,approvalRuleId:n}=l,s=o.billPaySetupApproverViewUpdateData?.type,v=O(l.location);return{onApprovalRuleDataUpdated:p=>{const f=S=>{const g=[];return S.forEach((r=>{const h=r.actors.selectedUsers.map((I=>({type:"user",userId:I.userId,isImplicitActor:!1}))),b=r.actors.selectedNonUsers.map((I=>{const m=!!re(I.value);return{type:m?"attribute":"role",subType:I.value,userId:void 0,idType:void 0,isImplicitActor:!m}})),i=h.concat(b);g.push({action:r.stepType.selectedOption,actors:i,operator:i.length>1?r.stepType.selectedOption==="require_approval"?"or":"and":"is"})})),g},c={amount:{type:"amount",comparator:"range",min:{amount:p.lowerBound,currencyCode:"USD",currencySymbol:"$"},max:{amount:p.upperBound,currencyCode:"USD",currencySymbol:"$"}}};if(s==="approval_create"){const S={criteria:c,steps:f(p.steps),isApplicableOnPendingApprovalEntity:p.applyToExistingBills.includes("applyToExistingBills")};e(C(S))}else{const S={approvalRuleId:n,criteria:c,steps:f(p.steps),isApplicableOnPendingApprovalEntity:p.applyToExistingBills.includes("applyToExistingBills")};e(C(S))}},onResetClick:()=>{e(E()),s==="approval_update"||v?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onBackClick:()=>{e(E()),s==="approval_update"||v?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onSaveRuleClick:()=>{e(G(!1))},onSaveRuleSuccess:()=>{t("../")}}}))(se);function Se(){const e=U(),l=j(),t=B(),{approvalRuleId:o}=W(),a=T.getSignedInUser(),n=Z(),s=y((c=>R(c))),v=y((c=>w(c))),[p,f]=d.useState(!1);if(d.useEffect((()=>{p||(f(!0),l(K(!0)))})),d.useEffect((()=>{v.fetchState==="Not-Started"&&e(o!=null?"../../":"../")}),[v,o]),a==null)throw Error("Can't access address page without signing in...");return s.approverListFetchStatus.fetchState=="Not-Started"||s.approverListFetchStatus.fetchState==="In-Progress"?u.jsx(M,{fetchState:s.approverListFetchStatus.fetchState,style:{backgroundColor:n.colors.grey5}}):u.jsx(ye,{navigate:e,approvalUpdateDataView:s,approvalRuleId:o,approverViewData:v,location:t})}const ge=V((function(e,l){const t=R(e),o=t.billPaySetupApproverViewUpdateData?.type??"approval_create",a=[],n={};for(const s of Object.values(e.vendorState.vendorByID))s?.id!=null&&(a.push(s.id),n[s.id]=s.name);return{localData:t,approvalUpdateActionType:o,allVendorIds:a,vendorNamesById:n,editingRuleId:o==="approval_update"?l.approvalRuleId:void 0,allApprovalRulesWithUser:w(e).allApprovalRules}}),(function(e,l){const{navigate:t,approvalUpdateDataView:o,approverViewData:a,approvalRuleId:n}=l,s=o.billPaySetupApproverViewUpdateData?.type,v=O(l.location);return{onApprovalRuleDataUpdated:p=>{const f=i=>{const I=[];return i.forEach((m=>{const N=m.actorKind?.selectedOption,ee=m.selectedRole?.selectedNonUsers??[];let D=[];N==="role"?D=ee.map((_=>({type:"attribute",subType:_.value,userId:void 0,idType:void 0,isImplicitActor:!1}))):N==="specific_person"&&(D=(m.persons?.selectedUsers??[]).map((_=>({type:"user",userId:_.userId,isImplicitActor:!1}))));const $=m.action??"require_approval";I.push({action:$,actors:D,operator:D.length>1?$==="require_approval"?"or":"and":"is"})})),I},c=p.amountCriteria,S=p.vendorCriteria,g=p.departmentCriteria,r={};if(c!=null&&c.comparator.selectedOption!=null){const i=c.comparator.selectedOption;r.amount={type:"amount",comparator:i,min:i==="less_than"?void 0:c.min,max:i==="greater_than"?void 0:c.max}}const h=S?.selection.selectedOptions??[];h.length>0&&(r.vendor={type:"vendor",operator:S?.operator.selectedOption??"is",vendorIds:h});const b=g?.selection.selectedOptions??[];if(b.length>0&&(r.department={type:"department",operator:g?.operator.selectedOption??"is",departmentIds:b}),s==="approval_create"){const i={name:p.name,description:p.description,separationOfDuties:p.separationOfDuties,criteria:r,steps:f(p.steps),isApplicableOnPendingApprovalEntity:p.applyToExistingBills.includes("applyToExistingBills")};e(C(i))}else{const i={approvalRuleId:n,name:p.name,description:p.description,separationOfDuties:p.separationOfDuties,criteria:r,steps:f(p.steps),isApplicableOnPendingApprovalEntity:p.applyToExistingBills.includes("applyToExistingBills")};e(C(i))}},onResetClick:()=>{e(E()),s==="approval_update"||v?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onBackClick:()=>{e(E()),s==="approval_update"||v?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onSaveRuleClick:()=>{e(G(!0))},onSaveRuleSuccess:()=>{t("../")},onEditExistingRule:p=>{e(A(p)),t(s==="approval_update"?`../../${p}/edit`:`../${p}/edit`)}}}))(ne);function H(){const e=y((t=>P(t))),{isApprovalRulesV3Enabled:l}=Q(e?.tenantId);return l?u.jsx(me,{}):u.jsx(Se,{})}function me(){const e=U(),l=j(),t=B(),{approvalRuleId:o}=W(),a=T.getSignedInUser(),n=Z(),s=y((c=>R(c))),v=y((c=>w(c))),[p,f]=d.useState(!1);if(X(),d.useEffect((()=>{p||(f(!0),l(K(!1)))})),d.useEffect((()=>{v.fetchState==="Not-Started"&&e(o!=null?"../../":"../")}),[v,o]),a==null)throw Error("Can't access address page without signing in...");return s.approverListFetchStatus.fetchState=="Not-Started"||s.approverListFetchStatus.fetchState==="In-Progress"?u.jsx(M,{fetchState:s.approverListFetchStatus.fetchState,style:{backgroundColor:n.colors.grey5}}):u.jsx(ge,{navigate:e,approvalUpdateDataView:s,approvalRuleId:o,approverViewData:v,location:t},o??"new")}function xe(){return u.jsxs(te,{children:[u.jsx(x,{path:"/",element:u.jsx(ve,{})}),u.jsx(x,{path:"/new",element:u.jsx(H,{})}),u.jsx(x,{path:"/:approvalRuleId/edit",element:u.jsx(H,{})}),u.jsx(x,{path:"*",element:u.jsx(ie,{})})]})}export{xe as B};
1
+ import{j as u}from"./liveblocks-BPL36a6x.js";import{a as d}from"./sentry-_x3Yh1Jc.js";import{h as U,g as B,u as j,j as y,N as F,l as V,i as W,n as te,o as x}from"./core-DOBELRta.js";import{fF as P,YQ as w,Yx as R,HB as E,Hv as q,Hz as A,Ho as z,Yz as Y,Hs as ae,HD as oe,Hr as K,HG as G,HC as C}from"./zeni-epic-state-DXFYDM66.js";import{z as T,w as J,bZ as pe,o as O,bT as Q,b_ as le,E as Z,a8 as M,b$ as se,c0 as ne}from"./index-D0or4oV9.js";import"./mui-wO6EIETx.js";import{u as X,i as re}from"./ReimbursementApprovalRuleDetailScreen-uAvwHmVJ.js";import ie from"./NotFoundScreen-3qucmnjW.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},l=new e.Error().stack;l&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[l]="d85a50e5-e217-4122-9b22-bbf9146eab3b",e._sentryDebugIdIdentifier="sentry-dbid-d85a50e5-e217-4122-9b22-bbf9146eab3b")}catch{}})();const k="bill-approval-rule-update",ce=V((function(e){return{approvalView:w(e),billPaySetupApproverViewUpdateData:R(e).billPaySetupApproverViewUpdateData}}),(function(e,l){const{navigate:t,location:o}=l;return{onApprovalRulesEventReceived:a=>{a.endsWith(k)&&e(Y(!1))},onBackClick:()=>{O(o)?t("../../"):t("../../../bills/setup")},onDeleteRuleClick:a=>{e(z(a,!1))},onEditRuleClick:a=>{a!=null?(e(A(a)),t(`./${a}/edit`)):(e(A()),t("./new"))}}}))(J(pe)),ue=({isLoading:e})=>{const l=U(),t=B(),o=j(),[a,n]=d.useState(!1),[s,v]=d.useState(!1),p=y((r=>r.billPaySetupApproverViewState.fetchState)),f=y((r=>P(r))),c=y((r=>w(r))),S=y((r=>R(r).billPaySetupApproverViewUpdateData));if(d.useEffect((()=>{S?.updateStatus.fetchState==="Completed"&&o(E())}),[S]),d.useEffect((()=>{a||p!=="Not-Started"||e||(n(!0),o(q(!0,!0,!1)))}),[a,p,e,o]),T.getSignedInUser()==null)throw Error("Can't access billpay approval without signing in...");d.useEffect((()=>{c.allApprovalRules.length===0&&c.fetchState==="Completed"&&(s||(v(!0),o(A())),l("./new"))}),[s,c,o]);const g={events:f.companyId!=null?[`private-encrypted-${f.companyId}.${k}`]:[],eventCallback:(r,h,b)=>{r.endsWith(k)&&b.onApprovalRulesEventReceived(r)}};return f?.companyBillPayInfo?.info?.isBillPayTOSAccepted===!1?u.jsx(F,{to:"../../promo"}):u.jsx(ce,{currentTenant:f,location:t,navigate:l,...g})},L="bill-approval-rule-update",de=V((function(e){const l=w(e),t=R(e).billPaySetupApproverViewUpdateData,o={};for(const n of Object.values(e.vendorState.vendorByID))n?.id!=null&&(o[n.id]=n.name);const a={};for(const n of Object.values(e.classState.classesByKey))n?.classId!=null&&(a[n.classId]=n.className);return{approvalView:l,billPaySetupApproverViewUpdateData:t,vendorNamesById:o,departmentNamesById:a}}),(function(e,l){const{navigate:t,location:o}=l;return{onApprovalRulesEventReceived:a=>{a.endsWith(L)&&e(Y(!1))},onBackClick:()=>{O(o)?t("../../"):t("../../../bills/setup")},onDeleteRuleClick:a=>{e(z(a,!0))},onEditRuleClick:a=>{a!=null?(e(A(a)),t(`./${a}/edit`)):(e(A()),t("./new"))},onReorderRules:a=>{e(oe(a,!0))}}}))(J(le)),ve=()=>{const e=y((o=>P(o))),{isApprovalRulesV3Enabled:l,isLoading:t}=Q(e?.tenantId);return l?u.jsx(fe,{isLoading:t}):u.jsx(ue,{isLoading:t})},fe=({isLoading:e})=>{const l=U(),t=B(),o=j(),[a,n]=d.useState(!1),[s,v]=d.useState(!1),[p,f]=d.useState(!1),c=y((i=>i.billPaySetupApproverViewState.fetchState)),S=y((i=>i.billPaySetupApproverViewState.approverListState.fetchStatus.fetchState)),g=y((i=>P(i)));X();const r=y((i=>w(i))),h=y((i=>R(i).billPaySetupApproverViewUpdateData));if(d.useEffect((()=>{h?.updateStatus.fetchState==="Completed"&&o(E())}),[h]),d.useEffect((()=>{a||c!=="Not-Started"||e||(n(!0),o(q(!0,!0,!0)))}),[a,c,e,o]),d.useEffect((()=>{s||S!=="Not-Started"||e||(v(!0),o(ae(!1,!0)))}),[s,S,e,o]),T.getSignedInUser()==null)throw Error("Can't access billpay approval without signing in...");d.useEffect((()=>{r.allApprovalRules.length===0&&r.fetchState==="Completed"&&(p||(f(!0),o(A())),l("./new"))}),[p,r,o]);const b={events:g.companyId!=null?[`private-encrypted-${g.companyId}.${L}`]:[],eventCallback:(i,I,m)=>{i.endsWith(L)&&m.onApprovalRulesEventReceived(i)}};return g?.companyBillPayInfo?.info?.isBillPayTOSAccepted===!1?u.jsx(F,{to:"../../promo"}):u.jsx(de,{currentTenant:g,location:t,navigate:l,isLoading:e,...b})},ye=V((function(e,l){const t=R(e),o=t.billPaySetupApproverViewUpdateData?.type??"approval_create",a=o==="approval_create"&&t.allApprovalRules.length!==0;let n=t.allApprovalRules.length===0;return l.approvalRuleId&&(n=t.allApprovalRules.findIndex((s=>s.approvalRuleId===l.approvalRuleId))===0),{localData:t,hideUpperBoundField:a,isLowerBoundDisabled:n,approvalUpdateActionType:o}}),(function(e,l){const{navigate:t,approvalUpdateDataView:o,approverViewData:a,approvalRuleId:n}=l,s=o.billPaySetupApproverViewUpdateData?.type,v=O(l.location);return{onApprovalRuleDataUpdated:p=>{const f=S=>{const g=[];return S.forEach((r=>{const h=r.actors.selectedUsers.map((I=>({type:"user",userId:I.userId,isImplicitActor:!1}))),b=r.actors.selectedNonUsers.map((I=>{const m=!!re(I.value);return{type:m?"attribute":"role",subType:I.value,userId:void 0,idType:void 0,isImplicitActor:!m}})),i=h.concat(b);g.push({action:r.stepType.selectedOption,actors:i,operator:i.length>1?r.stepType.selectedOption==="require_approval"?"or":"and":"is"})})),g},c={amount:{type:"amount",comparator:"range",min:{amount:p.lowerBound,currencyCode:"USD",currencySymbol:"$"},max:{amount:p.upperBound,currencyCode:"USD",currencySymbol:"$"}}};if(s==="approval_create"){const S={criteria:c,steps:f(p.steps),isApplicableOnPendingApprovalEntity:p.applyToExistingBills.includes("applyToExistingBills")};e(C(S))}else{const S={approvalRuleId:n,criteria:c,steps:f(p.steps),isApplicableOnPendingApprovalEntity:p.applyToExistingBills.includes("applyToExistingBills")};e(C(S))}},onResetClick:()=>{e(E()),s==="approval_update"||v?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onBackClick:()=>{e(E()),s==="approval_update"||v?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onSaveRuleClick:()=>{e(G(!1))},onSaveRuleSuccess:()=>{t("../")}}}))(se);function Se(){const e=U(),l=j(),t=B(),{approvalRuleId:o}=W(),a=T.getSignedInUser(),n=Z(),s=y((c=>R(c))),v=y((c=>w(c))),[p,f]=d.useState(!1);if(d.useEffect((()=>{p||(f(!0),l(K(!0)))})),d.useEffect((()=>{v.fetchState==="Not-Started"&&e(o!=null?"../../":"../")}),[v,o]),a==null)throw Error("Can't access address page without signing in...");return s.approverListFetchStatus.fetchState=="Not-Started"||s.approverListFetchStatus.fetchState==="In-Progress"?u.jsx(M,{fetchState:s.approverListFetchStatus.fetchState,style:{backgroundColor:n.colors.grey5}}):u.jsx(ye,{navigate:e,approvalUpdateDataView:s,approvalRuleId:o,approverViewData:v,location:t})}const ge=V((function(e,l){const t=R(e),o=t.billPaySetupApproverViewUpdateData?.type??"approval_create",a=[],n={};for(const s of Object.values(e.vendorState.vendorByID))s?.id!=null&&(a.push(s.id),n[s.id]=s.name);return{localData:t,approvalUpdateActionType:o,allVendorIds:a,vendorNamesById:n,editingRuleId:o==="approval_update"?l.approvalRuleId:void 0,allApprovalRulesWithUser:w(e).allApprovalRules}}),(function(e,l){const{navigate:t,approvalUpdateDataView:o,approverViewData:a,approvalRuleId:n}=l,s=o.billPaySetupApproverViewUpdateData?.type,v=O(l.location);return{onApprovalRuleDataUpdated:p=>{const f=i=>{const I=[];return i.forEach((m=>{const N=m.actorKind?.selectedOption,ee=m.selectedRole?.selectedNonUsers??[];let D=[];N==="role"?D=ee.map((_=>({type:"attribute",subType:_.value,userId:void 0,idType:void 0,isImplicitActor:!1}))):N==="specific_person"&&(D=(m.persons?.selectedUsers??[]).map((_=>({type:"user",userId:_.userId,isImplicitActor:!1}))));const $=m.action??"require_approval";I.push({action:$,actors:D,operator:D.length>1?$==="require_approval"?"or":"and":"is"})})),I},c=p.amountCriteria,S=p.vendorCriteria,g=p.departmentCriteria,r={};if(c!=null&&c.comparator.selectedOption!=null){const i=c.comparator.selectedOption;r.amount={type:"amount",comparator:i,min:i==="less_than"?void 0:c.min,max:i==="greater_than"?void 0:c.max}}const h=S?.selection.selectedOptions??[];h.length>0&&(r.vendor={type:"vendor",operator:S?.operator.selectedOption??"is",vendorIds:h});const b=g?.selection.selectedOptions??[];if(b.length>0&&(r.department={type:"department",operator:g?.operator.selectedOption??"is",departmentIds:b}),s==="approval_create"){const i={name:p.name,description:p.description,separationOfDuties:p.separationOfDuties,criteria:r,steps:f(p.steps),isApplicableOnPendingApprovalEntity:p.applyToExistingBills.includes("applyToExistingBills")};e(C(i))}else{const i={approvalRuleId:n,name:p.name,description:p.description,separationOfDuties:p.separationOfDuties,criteria:r,steps:f(p.steps),isApplicableOnPendingApprovalEntity:p.applyToExistingBills.includes("applyToExistingBills")};e(C(i))}},onResetClick:()=>{e(E()),s==="approval_update"||v?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onBackClick:()=>{e(E()),s==="approval_update"||v?t("../"):a.allApprovalRules.length===0&&a.fetchState==="Completed"?t("../../setup"):t("../")},onSaveRuleClick:()=>{e(G(!0))},onSaveRuleSuccess:()=>{t("../")},onEditExistingRule:p=>{e(A(p)),t(s==="approval_update"?`../../${p}/edit`:`../${p}/edit`)}}}))(ne);function H(){const e=y((t=>P(t))),{isApprovalRulesV3Enabled:l}=Q(e?.tenantId);return l?u.jsx(me,{}):u.jsx(Se,{})}function me(){const e=U(),l=j(),t=B(),{approvalRuleId:o}=W(),a=T.getSignedInUser(),n=Z(),s=y((c=>R(c))),v=y((c=>w(c))),[p,f]=d.useState(!1);if(X(),d.useEffect((()=>{p||(f(!0),l(K(!1)))})),d.useEffect((()=>{v.fetchState==="Not-Started"&&e(o!=null?"../../":"../")}),[v,o]),a==null)throw Error("Can't access address page without signing in...");return s.approverListFetchStatus.fetchState=="Not-Started"||s.approverListFetchStatus.fetchState==="In-Progress"?u.jsx(M,{fetchState:s.approverListFetchStatus.fetchState,style:{backgroundColor:n.colors.grey5}}):u.jsx(ge,{navigate:e,approvalUpdateDataView:s,approvalRuleId:o,approverViewData:v,location:t},o??"new")}function xe(){return u.jsxs(te,{children:[u.jsx(x,{path:"/",element:u.jsx(ve,{})}),u.jsx(x,{path:"/new",element:u.jsx(H,{})}),u.jsx(x,{path:"/:approvalRuleId/edit",element:u.jsx(H,{})}),u.jsx(x,{path:"*",element:u.jsx(ie,{})})]})}export{xe as B};
@@ -1,4 +1,4 @@
1
- import{j as a}from"./liveblocks-BPL36a6x.js";import{h as K,u as le,g as Q,i as te,j as k,N as ee,l as X,q as na,n as ia,o as y}from"./core-DOBELRta.js";import{fF as Z,Y7 as _e,bq as kt,S8 as oa,bo as wt,bJ as de,Y8 as Bt,GV as Ct,I6 as Ve,Hs as la,bn as Ae,Y9 as sa,Ya as ra,c8 as ca,Yb as da,l$ as xt,Yc as At,Yd as Et,IH as Ue,H8 as Ce,Ye as ua,GJ as at,Yf as pa,Mw as ma,GN as ba,GT as Dt,Yg as Se,Yh as Me,I7 as Ne,Yi as ha,Yj as ga,Ia as Oe,Yk as Sa,In as ya,Yl as Tt,HT as nt,HY as fa,Ym as Ia,Yn as ce,Yo as jt,Yp as Pt,Yq as Ft,gV as va,Hd as $e,cG as Rt,Yr as ka,gh as wa,Ys as Ba,Yt as Ca,d_ as Vt,dZ as $t,Yu as Ye,Yv as xa,Yw as Aa,WI as ze,Yx as Ea,WJ as ie,WK as He,Yy as Da,Yz as Ta,YA as ja,H_ as it,HX as Pa,YB as Fa,YC as Ra,YD as Va,HJ as $a,YE as La,YF as Ga,cu as Lt,da as Gt,ma as _a,bO as Ua,br as _t,bP as Ut,FZ as Ma,YG as Na,Mj as Oa,Mp as Ya,C9 as za,I8 as Ha,IO as Za,mn as ge,YH as Wa,YI as Mt,mR as qa,mh as Nt,mC as Ot,mB as ot,bE as pe,bN as Ja,YJ as Ka,YK as ye,kN as Qa,YL as lt,YM as Xa,kR as en,la as tn,J0 as an,YN as nn,mK as on,IS as ln,YO as st,IW as sn,I$ as rn,IZ as cn,IQ as dn,YP as Yt,H2 as un,YQ as pn,YR as mn,gG as bn,gF as hn,gE as gn,mq as Sn,mI as rt,mT as yn,uT as fn,mz as In,IU as vn,kX as kn,mY as wn,YS as Bn,kP as Cn,uK as xn,YT as An,HP as En,bK as Dn,bt as Tn,U7 as jn,dd as Pn,dc as Fn,cF as Rn,cM as Vn}from"./zeni-epic-state-DXFYDM66.js";import{E as ue,z as L,N as fe,at as Ze,c as oe,A as g,bj as We,a8 as se,I as A,a9 as Ee,k as j,bv as $n,a5 as H,aw as qe,p as T,a2 as Ie,bw as ct,bx as dt,by as Ln,aA as Gn,ag as _n,aT as Un,ac as zt,G as De,ah as Je,bz as Mn,af as Ht,bA as Nn,ar as On,V as Zt,w as Yn,bB as zn,bC as Hn,bD as Zn,bE as Wn,bF as qn,bG as Jn,bH as Kn,bI as Qn,bJ as Xn,R as ei,bK as ti,bs as ai,bL as ni,aj as ii,bM as oi,h as li}from"./index-CXbL8CxL.js";import{n as _,S as si}from"./mui-wO6EIETx.js";import{A as ut}from"./AddressScreen-dsCmoEfc.js";import{g as ne,a as Te,i as Wt,V as Ke,b as Qe,c as ri,v as ci,d as di,A as me,D as be}from"./DomesticWireDetailScreen-DSnjP_Z5.js";import{a as f}from"./sentry-_x3Yh1Jc.js";import{u as Xe}from"./useAskAiCfoHostNavButtonProps-gnFsttzV.js";import{u as qt}from"./useInitialThreadRequest-TFVuVZA_.js";import{u as ui}from"./BusinessVerificationPageScreen-fABxFj6p.js";import xe from"./NotFoundScreen-rNwJ2-Qg.js";import{D as pi}from"./DrawerScreen-C728nU-t.js";import{M as Jt}from"./MobileAppDrawer-CZL1M8HC.js";import{F as Kt}from"./FeaturePreviewScreen-BTcHNbYq.js";import{S as je}from"./SetupPagesScreen-Y9SYCogP.js";import{B as mi}from"./BillPayApprovalRoutes--p2o0UTq.js";import{F as bi}from"./ScreenRoutes-CiAckpHg.js";import"./recharts-Sp9X2zHo.js";import"./analytics-GZ8dIY_c.js";import"./plaid-C-eBmVPr.js";import"./dnd-0MaFz9wL.js";import"./stripe-cKAAJElX.js";import"./lottie-38LSfraF.js";import"./lexical-CAgOy6Q-.js";import"./pdf-B2N0erO1.js";import"./utils-BU0XThgM.js";import"./routePaths-7schl7H2.js";import"./InboxNotificationsProvider-Bd8tLMl8.js";import"./useTaskManagerAccess-CiaMEBoG.js";import"./analyticsHelper-B9ZU7ow3.js";import"./ReimbursementApprovalRuleDetailScreen-BqumfK_F.js";import"./getLocaleForTenant-Dfv4vBw9.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]="0b27945e-c21d-4532-bc86-bd924eb44c39",e._sentryDebugIdIdentifier="sentry-dbid-0b27945e-c21d-4532-bc86-bd924eb44c39")}catch{}})();const hi=X((function(e,t){const l=_e(e,t.billId),n=L.getSignedInUser(),c=e.tenantState.currentTenantId,r={userId:n?.userId??"",sessionId:n?.zeniSessionId??"",tenantId:c??""},u=H(t.location.state?.pathnameStackToGoBack);let o=!0;u.poppedPathname?.includes("bills")===!0&&(o=!1);let s=`${l.createdBy?.firstName??"Zeni"} ${l.createdBy?.lastName??""}`;Ae(n)||!l.createdBy?.email?.includes("zeni.ai")||(s="Zeni");let i=!1,d=!1;if(l?.billActivities.length>0){const{isApprovalorRejectBtnVisible:S,isMarkAsPaidBtnVisible:h}=sa(l.billActivities,ra(t.currentTenant),n);i=S,d=h}const p=ca(t.currentTenant?.userRole??[]),m=l.transactionDetails!=null&&da(l.transactionDetails,p,n);return{billDetails:l,isAccountingClassesEnabled:xt(e),createdBy:s,authParams:r,transactionAttachmentEndpoint:`${qe}/transaction_attachment`,signedInUser:n,showBackButton:o,isAdmin:p,isRealTimeApprovalEnabled:t.isRealTimeApprovalEnabled,showApproveRejectBtns:i,showMarkAsPaidButtonToApprover:d,hasZeniAssistAccess:t.hasZeniAssistAccess,analytics:j,showMarkAsPaidButtonToCreator:m}}),(function(e,t){const{billId:l,currentTenant:n,location:c,navigate:r}=t,{tenantEmailDomain:u}=n;return{redirectToBillsScreen:()=>{const o=ne(u),s=T(c.state?.pathnameStackToGoBack,c.pathname);r(o,{state:{pathnameStackToGoBack:s}})},redirectToEditableBillScreen:()=>{const o=T(c.state?.pathnameStackToGoBack,c.pathname);r("./edit",{state:{pathnameStackToGoBack:o}})},discardBillDetailsFromLocalStore:()=>{e(Se({}))},deleteBill:o=>{j.trackBillPayDeleteBill(l,o),e(Dt(l))},cancelAndDeleteBill:(o,s)=>{s===!0?j.trackBillPayCancelAndDeleteBill(l,o):j.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(at(l,o.type,"")):e(at(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=Te(u,o,s),d=T(c.state?.pathnameStackToGoBack,c.pathname);r(i,{state:{pathnameStackToGoBack:d}})},onBackClick:()=>{const o=H(t.location.state?.pathnameStackToGoBack),s=o.poppedPathname??ne(u);r(s,{state:{pathnameStackToGoBack:o.newStack}})},onRetryPaymentClick:()=>{const o=T(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(Ue(o?"paid":"pending_approval",o,s,l))},discardOutsideZeniPaymentData:()=>{e(At({billId:l}))}}}))($n);function gi(){const e=K(),t=le(),l=Q(),{billId:n}=te(),c=ue(),r=L.getSignedInUser(),u=fe(),o=k((z=>Z(z))),s=k((z=>_e(z,n??""))),i=s.transactionDetails?.billPayInfo.stage.code==="draft"&&s.transactionDetails.isDeleted===!1,d=qt(o?.companyId,{clearParams:s.fetchState==="Completed"&&!i}),{isAiCfoAccessEnabled:p,onAskAiCfoClick:m}=Xe({mobileExploreReferrer:"Bill Details"});Ze({isDataReady:s.fetchState==="Completed"});const S=o?.userRole!=null&&kt(o?.userRole),h=o?.company==null||o.company.featuresActivationInfo?.isBillPayFeatureEnabled&&!S,[b,I]=f.useState(!1),[E,C]=f.useState(!1),[x,U]=f.useState(!1),{useFeatureGate:D,useDynamicConfig:B}=oe(),{isFeatureEnabled:N}=D(g.isShowDeletedBillsFeatureEnabled),{isFeatureEnabled:V}=D(g.isBillPayCommentingEnabled),{isFeatureEnabled:W}=D(g.isBillPayDetectInsufficientFundsEnabled),{configValue:O}=B(We.zeniAssistConfig),v=oa(o),Y=wt(o.userRole),M=h&&de(u?.loggedInUserRoleMap),$=O.user_ids!=null&&r?.userId!=null&&O.user_ids.includes(r?.userId),{isFeatureEnabled:q}=D(g.isInternationalPaymentShaVsOurFeatureEnabled),{isFeatureEnabled:J}=D(g.billPaySetupShowInternationalPaymentByWise);if(f.useEffect((()=>{N&&s.transactionDetails?.isDeleted===!0||o.isZeni===!0&&r?.userEmailDomain==="zeni.ai"&&v===!1?U(!1):U(s.billActivities[0]?.isRealTimeApprovalEnabled&&(Y||M||s.allApprovers.find((z=>z.user.userId===r?.userId))!=null||s.transactionDetails?.lastUpdatedByUserId===r?.userId))}),[s.billActivities[0]?.isRealTimeApprovalEnabled,s.allApprovers,s.transactionDetails?.lastUpdatedByUserId,Y,M,o.isZeni,v,r]),f.useEffect((()=>{n!=null&&t(Bt(n))}),[n]),f.useEffect((()=>{b||s.fetchState=="Completed"||s.fetchState=="In-Progress"||(I(!0),t(Ct(n??"",N,$,!1)))}),[b,s,n,t]),f.useEffect((()=>{E||s.fetchState!="Completed"||s.transactionDetails?.billPayInfo.stage.code=="paid"||(C(!0),t(Ve(!1,N,$,J,n)),s.billActivities[0]?.isRealTimeApprovalEnabled===!0&&t(la()))}),[E,s,n,t,N,$,J]),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(ee,{to:`./edit${l.search}`}):s.deleteStatus.fetchState==="In-Progress"||s.cancelAndDeleteStatus.fetchState==="In-Progress"||s.cancelStatus.fetchState==="In-Progress"?a.jsx(se,{fetchState:s.deleteStatus.fetchState,style:{boxShadow:`0px 2px ${A.sp1} ${c.colors.dropShadowNormal}`}}):a.jsxs(a.Fragment,{children:[a.jsx(Ee,{analytics:j,onLoad:z=>(G=>{n!=null&&G.trackBillPayBillDetails(n,s.isRecurring)})(z)}),a.jsx(hi,{initialOpenThreadRequest:d??void 0,isShowDeletedBillsEnabled:N,location:l,navigate:e,isBillPayCommentingEnabled:V,isRealTimeApprovalEnabled:x,currentTenant:o,billId:n??"",isInternationalPaymentShaVsOurEnabled:q,hasZeniAssistAccess:$,isDetectInsufficientFundsEnabled:W,isAiCfoAccessEnabled:p,onAskAiCfoClick:m})]})}const Le=De.getLocalizedStrings().spendManagement.billPay.billDetails,pt=De.getLocalizedStrings().common,Si={containerWidth:new zt(100,58)},mt=X((function(e,t){const l=L.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:j,entityId:t.billId,showTitlebarIcon:r,showTitlebar:r&&t?.file!=null,uploadStatus:t.uploadStatus,shouldNotShowAttachment:u,style:{paddingTop:A.sp10,paddingRight:A.sp3,paddingBottom:"15px",paddingLeft:A.sp5,...t.showAutofill?{}:{backgroundColor:t.backgroundColor,paddingBottom:"128px"}}}}),(function(e,t){const l=L.getSignedInUser();return{onInvoiceUpload:n=>{n!=null&&(t.file!=null||t.billId!=null||t.isInitialEdit?(t.setPayload(n),t.setShowConfirmationPopup(!0)):e(Oe(n,t.isVendorRecommendationEnabled,t.billId)))},updateInvoiceUploadFetchState:n=>{e(ya({fetchState:{fetchState:n,error:void 0},billId:t.billId}))},onSkipAutofill:n=>{j?.trackBillPaySkipAutofill(),e(Ne(n))},onDeleteClick:()=>{e(Sa({billId:t.billId})),j?.trackInvoiceActionClick(t.billStage??"","delete",l?.userEmail??"",null)}}}))(Un);function w({appContent:e}){const t=le(),l=K(),{billId:n}=te(),c=Q(),r=c.pathname,u=r.includes("bill/new")||r.includes("/edit"),o=Ie(),s=ue(),i=L.getSignedInUser(),{useFeatureGate:d,useDynamicConfig:p}=oe(),{isFeatureEnabled:m}=d(g.isVendorRecommendationFeatureEnabled),{isFeatureEnabled:S}=d(g.isShowDeletedBillsFeatureEnabled),{isFeatureEnabled:h}=d(g.isDepositAccountsFeatureEnabled),{isFeatureEnabled:b}=d(g.billPaySetupShowInternationalPaymentByWise),{configValue:I}=p(We.zeniAssistConfig),E=I.user_ids!=null&&i?.userId!=null&&I.user_ids.includes(i?.userId),C=k((F=>Z(F)));ui();const[x,U]=f.useState(!1),[D,B]=f.useState(!1),[N,V]=f.useState(!1),[W,O]=f.useState(),v=k((F=>Me(F,m,h,n)));let Y=v.fetchState,M=v.file,$=v.showAutofill;const q=k((F=>_e(F,n??"")));u===!1&&(Y=q.fetchState,M=q.transactionDetails?.attachments?.[0],$=!1);const J=v.billPayInfo!=null&&v.billPayInfo.stage.code==="pending_approval"?v.billPayInfo.billStatus.code:v.billStage;f.useEffect((()=>{n==null&&t(Ne(!0))}),[n,t]),f.useEffect((()=>{Y==="Not-Started"&&(u&&D?B(!1):!u&&x&&U(!1))}),[n]),f.useEffect((()=>{x||n==null||u||(U(!0),t(Ct(n,S,E,!1)),D||(B(!0),t(Ve(!1,S,E,b,n)))),u&&!D&&(B(!0),t(Ve(!1,S,E,b,n)))}),[x,D,u,n,t,S,E,b]);const z={onOkClick:()=>{if(V(!1),!W)return;const F=M!=null?"replace":"upload";j?.trackInvoiceActionClick(J??"",F,i?.userEmail??"","yes"),t(ga({replaceBillData:!0,billId:n})),t(Oe(W,m,n))},onCancelClick:()=>{if(V(!1),!W)return;const F=M!=null?"replace":"upload";j?.trackInvoiceActionClick(J??"",F,i?.userEmail??"","no"),t(ha({file:W,billId:n}))}},G=f.useCallback((()=>{const F=H(c.state?.pathnameStackToGoBack),ve=F.poppedPathname??ne(C.tenantEmailDomain);t(Se({billId:n})),l(ve,{state:{pathnameStackToGoBack:F.newStack}})}),[c.state,C.tenantEmailDomain,n,t,l]);if(i==null)throw Error("Can't access address page without signing in...");if(Y==="Error"||q.fetchState==="Error")return a.jsx(xe,{});if(Y!="Completed")return n==null&&o!=="small"?a.jsx(ct,{fallback:G,children:a.jsxs(Pe,{windowSize:o,children:[a.jsx(ht,{}),a.jsx(Fe,{}),a.jsx(mt,{backgroundColor:s.colors.grey4,billId:n,file:M,showAutofill:!0,uploadStatus:v.uploadStatus,isVendorRecommendationEnabled:m,attachmentTitle:void 0,setShowConfirmationPopup:V,setPayload:O,showActionButtons:!1,isInitialEdit:!!v.isInitialEdit,billStage:J}),a.jsx(Re,{windowSize:o,children:a.jsx(dt,{isNewBill:!0})})]})}):a.jsxs(Pe,{windowSize:o,children:[o==="small"||$?null:a.jsx(bt,{children:a.jsx(Qt,{onClick:G,"data-testid":"nav-bar-back-click"})}),o!=="small"?a.jsx(Fe,{}):null,a.jsx(Ln,{}),a.jsx(Re,{windowSize:o,children:a.jsx(dt,{isNewBill:n==null})})]});{const F=v.billPayInfo!=null&&v.billPayInfo.stage.code==="pending_approval"?v.billPayInfo.billStatus.code:v.billStage;return a.jsx(ct,{fallback:G,children:a.jsxs(Pe,{windowSize:o,children:[$&&o!=="small"?a.jsx(ht,{}):null,N?a.jsx(Gn,{titleComponent:a.jsx(Bi,{children:Le.overwriteTitle}),descriptionComponent:a.jsx(Ci,{children:Le.overwriteDescription}),primaryButtonText:pt.yes,secondaryButtonText:pt.no,action:z,isEditPopup:!0}):null,o==="small"||$?null:a.jsx(bt,{children:a.jsx(yi,{})}),o!=="small"?a.jsx(Fe,{}):null,a.jsx(mt,{backgroundColor:s.colors.grey4,billId:n,file:M,showAutofill:$,uploadStatus:v.uploadStatus,isVendorRecommendationEnabled:m,attachmentTitle:fi(u,q,v),setShowConfirmationPopup:V,setPayload:O,showActionButtons:Ii(u,v),isInitialEdit:!!v.isInitialEdit,billStage:F}),a.jsx(Re,{windowSize:o,children:e})]})})}}function yi(){const{triggerBack:e}=Mn();return a.jsx(Qt,{onClick:e,"data-testid":"nav-bar-back-click"})}function fi(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(vi,{children:[a.jsx(ki,{children:`${Le.recurringBill.recurringCycle}
1
+ import{j as a}from"./liveblocks-BPL36a6x.js";import{h as K,u as le,g as Q,i as te,j as k,N as ee,l as X,q as na,n as ia,o as y}from"./core-DOBELRta.js";import{fF as Z,Y7 as _e,bq as kt,S8 as oa,bo as wt,bJ as de,Y8 as Bt,GV as Ct,I6 as Ve,Hs as la,bn as Ae,Y9 as sa,Ya as ra,c8 as ca,Yb as da,l$ as xt,Yc as At,Yd as Et,IH as Ue,H8 as Ce,Ye as ua,GJ as at,Yf as pa,Mw as ma,GN as ba,GT as Dt,Yg as Se,Yh as Me,I7 as Ne,Yi as ha,Yj as ga,Ia as Oe,Yk as Sa,In as ya,Yl as Tt,HT as nt,HY as fa,Ym as Ia,Yn as ce,Yo as jt,Yp as Pt,Yq as Ft,gV as va,Hd as $e,cG as Rt,Yr as ka,gh as wa,Ys as Ba,Yt as Ca,d_ as Vt,dZ as $t,Yu as Ye,Yv as xa,Yw as Aa,WI as ze,Yx as Ea,WJ as ie,WK as He,Yy as Da,Yz as Ta,YA as ja,H_ as it,HX as Pa,YB as Fa,YC as Ra,YD as Va,HJ as $a,YE as La,YF as Ga,cu as Lt,da as Gt,ma as _a,bO as Ua,br as _t,bP as Ut,FZ as Ma,YG as Na,Mj as Oa,Mp as Ya,C9 as za,I8 as Ha,IO as Za,mn as ge,YH as Wa,YI as Mt,mR as qa,mh as Nt,mC as Ot,mB as ot,bE as pe,bN as Ja,YJ as Ka,YK as ye,kN as Qa,YL as lt,YM as Xa,kR as en,la as tn,J0 as an,YN as nn,mK as on,IS as ln,YO as st,IW as sn,I$ as rn,IZ as cn,IQ as dn,YP as Yt,H2 as un,YQ as pn,YR as mn,gG as bn,gF as hn,gE as gn,mq as Sn,mI as rt,mT as yn,uT as fn,mz as In,IU as vn,kX as kn,mY as wn,YS as Bn,kP as Cn,uK as xn,YT as An,HP as En,bK as Dn,bt as Tn,U7 as jn,dd as Pn,dc as Fn,cF as Rn,cM as Vn}from"./zeni-epic-state-DXFYDM66.js";import{E as ue,z as L,N as fe,at as Ze,c as oe,A as g,bj as We,a8 as se,I as A,a9 as Ee,k as j,bv as $n,a5 as H,aw as qe,p as T,a2 as Ie,bw as ct,bx as dt,by as Ln,aA as Gn,ag as _n,aT as Un,ac as zt,G as De,ah as Je,bz as Mn,af as Ht,bA as Nn,ar as On,V as Zt,w as Yn,bB as zn,bC as Hn,bD as Zn,bE as Wn,bF as qn,bG as Jn,bH as Kn,bI as Qn,bJ as Xn,R as ei,bK as ti,bs as ai,bL as ni,aj as ii,bM as oi,h as li}from"./index-D0or4oV9.js";import{n as _,S as si}from"./mui-wO6EIETx.js";import{A as ut}from"./AddressScreen-C5gOC9K1.js";import{g as ne,a as Te,i as Wt,V as Ke,b as Qe,c as ri,v as ci,d as di,A as me,D as be}from"./DomesticWireDetailScreen-DdGRU08t.js";import{a as f}from"./sentry-_x3Yh1Jc.js";import{u as Xe}from"./useAskAiCfoHostNavButtonProps-eAE85_k_.js";import{u as qt}from"./useInitialThreadRequest-DYGeNL0J.js";import{u as ui}from"./BusinessVerificationPageScreen-_lNpLbtb.js";import xe from"./NotFoundScreen-3qucmnjW.js";import{D as pi}from"./DrawerScreen-BkWdrsyD.js";import{M as Jt}from"./MobileAppDrawer-C-ti4sM2.js";import{F as Kt}from"./FeaturePreviewScreen-DmuM1Efe.js";import{S as je}from"./SetupPagesScreen-CgVfrQ5w.js";import{B as mi}from"./BillPayApprovalRoutes-CbgUcPPn.js";import{F as bi}from"./ScreenRoutes-BgjTH3MD.js";import"./recharts-Sp9X2zHo.js";import"./analytics-GZ8dIY_c.js";import"./plaid-C-eBmVPr.js";import"./dnd-0MaFz9wL.js";import"./stripe-cKAAJElX.js";import"./lottie-38LSfraF.js";import"./lexical-CAgOy6Q-.js";import"./pdf-B2N0erO1.js";import"./utils-BU0XThgM.js";import"./routePaths-DTZH71MW.js";import"./InboxNotificationsProvider-Bd8tLMl8.js";import"./useTaskManagerAccess-CxAfFVI5.js";import"./analyticsHelper-DnGDW6mo.js";import"./ReimbursementApprovalRuleDetailScreen-uAvwHmVJ.js";import"./getLocaleForTenant-U4ff53sp.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]="0b27945e-c21d-4532-bc86-bd924eb44c39",e._sentryDebugIdIdentifier="sentry-dbid-0b27945e-c21d-4532-bc86-bd924eb44c39")}catch{}})();const hi=X((function(e,t){const l=_e(e,t.billId),n=L.getSignedInUser(),c=e.tenantState.currentTenantId,r={userId:n?.userId??"",sessionId:n?.zeniSessionId??"",tenantId:c??""},u=H(t.location.state?.pathnameStackToGoBack);let o=!0;u.poppedPathname?.includes("bills")===!0&&(o=!1);let s=`${l.createdBy?.firstName??"Zeni"} ${l.createdBy?.lastName??""}`;Ae(n)||!l.createdBy?.email?.includes("zeni.ai")||(s="Zeni");let i=!1,d=!1;if(l?.billActivities.length>0){const{isApprovalorRejectBtnVisible:S,isMarkAsPaidBtnVisible:h}=sa(l.billActivities,ra(t.currentTenant),n);i=S,d=h}const p=ca(t.currentTenant?.userRole??[]),m=l.transactionDetails!=null&&da(l.transactionDetails,p,n);return{billDetails:l,isAccountingClassesEnabled:xt(e),createdBy:s,authParams:r,transactionAttachmentEndpoint:`${qe}/transaction_attachment`,signedInUser:n,showBackButton:o,isAdmin:p,isRealTimeApprovalEnabled:t.isRealTimeApprovalEnabled,showApproveRejectBtns:i,showMarkAsPaidButtonToApprover:d,hasZeniAssistAccess:t.hasZeniAssistAccess,analytics:j,showMarkAsPaidButtonToCreator:m}}),(function(e,t){const{billId:l,currentTenant:n,location:c,navigate:r}=t,{tenantEmailDomain:u}=n;return{redirectToBillsScreen:()=>{const o=ne(u),s=T(c.state?.pathnameStackToGoBack,c.pathname);r(o,{state:{pathnameStackToGoBack:s}})},redirectToEditableBillScreen:()=>{const o=T(c.state?.pathnameStackToGoBack,c.pathname);r("./edit",{state:{pathnameStackToGoBack:o}})},discardBillDetailsFromLocalStore:()=>{e(Se({}))},deleteBill:o=>{j.trackBillPayDeleteBill(l,o),e(Dt(l))},cancelAndDeleteBill:(o,s)=>{s===!0?j.trackBillPayCancelAndDeleteBill(l,o):j.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(at(l,o.type,"")):e(at(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=Te(u,o,s),d=T(c.state?.pathnameStackToGoBack,c.pathname);r(i,{state:{pathnameStackToGoBack:d}})},onBackClick:()=>{const o=H(t.location.state?.pathnameStackToGoBack),s=o.poppedPathname??ne(u);r(s,{state:{pathnameStackToGoBack:o.newStack}})},onRetryPaymentClick:()=>{const o=T(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(Ue(o?"paid":"pending_approval",o,s,l))},discardOutsideZeniPaymentData:()=>{e(At({billId:l}))}}}))($n);function gi(){const e=K(),t=le(),l=Q(),{billId:n}=te(),c=ue(),r=L.getSignedInUser(),u=fe(),o=k((z=>Z(z))),s=k((z=>_e(z,n??""))),i=s.transactionDetails?.billPayInfo.stage.code==="draft"&&s.transactionDetails.isDeleted===!1,d=qt(o?.companyId,{clearParams:s.fetchState==="Completed"&&!i}),{isAiCfoAccessEnabled:p,onAskAiCfoClick:m}=Xe({mobileExploreReferrer:"Bill Details"});Ze({isDataReady:s.fetchState==="Completed"});const S=o?.userRole!=null&&kt(o?.userRole),h=o?.company==null||o.company.featuresActivationInfo?.isBillPayFeatureEnabled&&!S,[b,I]=f.useState(!1),[E,C]=f.useState(!1),[x,U]=f.useState(!1),{useFeatureGate:D,useDynamicConfig:B}=oe(),{isFeatureEnabled:N}=D(g.isShowDeletedBillsFeatureEnabled),{isFeatureEnabled:V}=D(g.isBillPayCommentingEnabled),{isFeatureEnabled:W}=D(g.isBillPayDetectInsufficientFundsEnabled),{configValue:O}=B(We.zeniAssistConfig),v=oa(o),Y=wt(o.userRole),M=h&&de(u?.loggedInUserRoleMap),$=O.user_ids!=null&&r?.userId!=null&&O.user_ids.includes(r?.userId),{isFeatureEnabled:q}=D(g.isInternationalPaymentShaVsOurFeatureEnabled),{isFeatureEnabled:J}=D(g.billPaySetupShowInternationalPaymentByWise);if(f.useEffect((()=>{N&&s.transactionDetails?.isDeleted===!0||o.isZeni===!0&&r?.userEmailDomain==="zeni.ai"&&v===!1?U(!1):U(s.billActivities[0]?.isRealTimeApprovalEnabled&&(Y||M||s.allApprovers.find((z=>z.user.userId===r?.userId))!=null||s.transactionDetails?.lastUpdatedByUserId===r?.userId))}),[s.billActivities[0]?.isRealTimeApprovalEnabled,s.allApprovers,s.transactionDetails?.lastUpdatedByUserId,Y,M,o.isZeni,v,r]),f.useEffect((()=>{n!=null&&t(Bt(n))}),[n]),f.useEffect((()=>{b||s.fetchState=="Completed"||s.fetchState=="In-Progress"||(I(!0),t(Ct(n??"",N,$,!1)))}),[b,s,n,t]),f.useEffect((()=>{E||s.fetchState!="Completed"||s.transactionDetails?.billPayInfo.stage.code=="paid"||(C(!0),t(Ve(!1,N,$,J,n)),s.billActivities[0]?.isRealTimeApprovalEnabled===!0&&t(la()))}),[E,s,n,t,N,$,J]),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(ee,{to:`./edit${l.search}`}):s.deleteStatus.fetchState==="In-Progress"||s.cancelAndDeleteStatus.fetchState==="In-Progress"||s.cancelStatus.fetchState==="In-Progress"?a.jsx(se,{fetchState:s.deleteStatus.fetchState,style:{boxShadow:`0px 2px ${A.sp1} ${c.colors.dropShadowNormal}`}}):a.jsxs(a.Fragment,{children:[a.jsx(Ee,{analytics:j,onLoad:z=>(G=>{n!=null&&G.trackBillPayBillDetails(n,s.isRecurring)})(z)}),a.jsx(hi,{initialOpenThreadRequest:d??void 0,isShowDeletedBillsEnabled:N,location:l,navigate:e,isBillPayCommentingEnabled:V,isRealTimeApprovalEnabled:x,currentTenant:o,billId:n??"",isInternationalPaymentShaVsOurEnabled:q,hasZeniAssistAccess:$,isDetectInsufficientFundsEnabled:W,isAiCfoAccessEnabled:p,onAskAiCfoClick:m})]})}const Le=De.getLocalizedStrings().spendManagement.billPay.billDetails,pt=De.getLocalizedStrings().common,Si={containerWidth:new zt(100,58)},mt=X((function(e,t){const l=L.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:j,entityId:t.billId,showTitlebarIcon:r,showTitlebar:r&&t?.file!=null,uploadStatus:t.uploadStatus,shouldNotShowAttachment:u,style:{paddingTop:A.sp10,paddingRight:A.sp3,paddingBottom:"15px",paddingLeft:A.sp5,...t.showAutofill?{}:{backgroundColor:t.backgroundColor,paddingBottom:"128px"}}}}),(function(e,t){const l=L.getSignedInUser();return{onInvoiceUpload:n=>{n!=null&&(t.file!=null||t.billId!=null||t.isInitialEdit?(t.setPayload(n),t.setShowConfirmationPopup(!0)):e(Oe(n,t.isVendorRecommendationEnabled,t.billId)))},updateInvoiceUploadFetchState:n=>{e(ya({fetchState:{fetchState:n,error:void 0},billId:t.billId}))},onSkipAutofill:n=>{j?.trackBillPaySkipAutofill(),e(Ne(n))},onDeleteClick:()=>{e(Sa({billId:t.billId})),j?.trackInvoiceActionClick(t.billStage??"","delete",l?.userEmail??"",null)}}}))(Un);function w({appContent:e}){const t=le(),l=K(),{billId:n}=te(),c=Q(),r=c.pathname,u=r.includes("bill/new")||r.includes("/edit"),o=Ie(),s=ue(),i=L.getSignedInUser(),{useFeatureGate:d,useDynamicConfig:p}=oe(),{isFeatureEnabled:m}=d(g.isVendorRecommendationFeatureEnabled),{isFeatureEnabled:S}=d(g.isShowDeletedBillsFeatureEnabled),{isFeatureEnabled:h}=d(g.isDepositAccountsFeatureEnabled),{isFeatureEnabled:b}=d(g.billPaySetupShowInternationalPaymentByWise),{configValue:I}=p(We.zeniAssistConfig),E=I.user_ids!=null&&i?.userId!=null&&I.user_ids.includes(i?.userId),C=k((F=>Z(F)));ui();const[x,U]=f.useState(!1),[D,B]=f.useState(!1),[N,V]=f.useState(!1),[W,O]=f.useState(),v=k((F=>Me(F,m,h,n)));let Y=v.fetchState,M=v.file,$=v.showAutofill;const q=k((F=>_e(F,n??"")));u===!1&&(Y=q.fetchState,M=q.transactionDetails?.attachments?.[0],$=!1);const J=v.billPayInfo!=null&&v.billPayInfo.stage.code==="pending_approval"?v.billPayInfo.billStatus.code:v.billStage;f.useEffect((()=>{n==null&&t(Ne(!0))}),[n,t]),f.useEffect((()=>{Y==="Not-Started"&&(u&&D?B(!1):!u&&x&&U(!1))}),[n]),f.useEffect((()=>{x||n==null||u||(U(!0),t(Ct(n,S,E,!1)),D||(B(!0),t(Ve(!1,S,E,b,n)))),u&&!D&&(B(!0),t(Ve(!1,S,E,b,n)))}),[x,D,u,n,t,S,E,b]);const z={onOkClick:()=>{if(V(!1),!W)return;const F=M!=null?"replace":"upload";j?.trackInvoiceActionClick(J??"",F,i?.userEmail??"","yes"),t(ga({replaceBillData:!0,billId:n})),t(Oe(W,m,n))},onCancelClick:()=>{if(V(!1),!W)return;const F=M!=null?"replace":"upload";j?.trackInvoiceActionClick(J??"",F,i?.userEmail??"","no"),t(ha({file:W,billId:n}))}},G=f.useCallback((()=>{const F=H(c.state?.pathnameStackToGoBack),ve=F.poppedPathname??ne(C.tenantEmailDomain);t(Se({billId:n})),l(ve,{state:{pathnameStackToGoBack:F.newStack}})}),[c.state,C.tenantEmailDomain,n,t,l]);if(i==null)throw Error("Can't access address page without signing in...");if(Y==="Error"||q.fetchState==="Error")return a.jsx(xe,{});if(Y!="Completed")return n==null&&o!=="small"?a.jsx(ct,{fallback:G,children:a.jsxs(Pe,{windowSize:o,children:[a.jsx(ht,{}),a.jsx(Fe,{}),a.jsx(mt,{backgroundColor:s.colors.grey4,billId:n,file:M,showAutofill:!0,uploadStatus:v.uploadStatus,isVendorRecommendationEnabled:m,attachmentTitle:void 0,setShowConfirmationPopup:V,setPayload:O,showActionButtons:!1,isInitialEdit:!!v.isInitialEdit,billStage:J}),a.jsx(Re,{windowSize:o,children:a.jsx(dt,{isNewBill:!0})})]})}):a.jsxs(Pe,{windowSize:o,children:[o==="small"||$?null:a.jsx(bt,{children:a.jsx(Qt,{onClick:G,"data-testid":"nav-bar-back-click"})}),o!=="small"?a.jsx(Fe,{}):null,a.jsx(Ln,{}),a.jsx(Re,{windowSize:o,children:a.jsx(dt,{isNewBill:n==null})})]});{const F=v.billPayInfo!=null&&v.billPayInfo.stage.code==="pending_approval"?v.billPayInfo.billStatus.code:v.billStage;return a.jsx(ct,{fallback:G,children:a.jsxs(Pe,{windowSize:o,children:[$&&o!=="small"?a.jsx(ht,{}):null,N?a.jsx(Gn,{titleComponent:a.jsx(Bi,{children:Le.overwriteTitle}),descriptionComponent:a.jsx(Ci,{children:Le.overwriteDescription}),primaryButtonText:pt.yes,secondaryButtonText:pt.no,action:z,isEditPopup:!0}):null,o==="small"||$?null:a.jsx(bt,{children:a.jsx(yi,{})}),o!=="small"?a.jsx(Fe,{}):null,a.jsx(mt,{backgroundColor:s.colors.grey4,billId:n,file:M,showAutofill:$,uploadStatus:v.uploadStatus,isVendorRecommendationEnabled:m,attachmentTitle:fi(u,q,v),setShowConfirmationPopup:V,setPayload:O,showActionButtons:Ii(u,v),isInitialEdit:!!v.isInitialEdit,billStage:F}),a.jsx(Re,{windowSize:o,children:e})]})})}}function yi(){const{triggerBack:e}=Mn();return a.jsx(Qt,{onClick:e,"data-testid":"nav-bar-back-click"})}function fi(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(vi,{children:[a.jsx(ki,{children:`${Le.recurringBill.recurringCycle}
2
2
  ${n}/${c}`}),a.jsx(wi,{})]}):void 0}function Ii(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 bt=_.div`
3
3
  margin-bottom: 20px;
4
4
  margin-top: 20px;
@@ -1,4 +1,4 @@
1
- import{a as k}from"./sentry-_x3Yh1Jc.js";import{u as Z,j as h,h as ne,g as se,i as oe,N as ie,l as re}from"./core-DOBELRta.js";import{fF as z,Hv as ce,Y$ as ue,BA as de,Sb as pe,HJ as le,KU as me,NH as fe,Ol as ye,Pa as Se,Z0 as ge,Z1 as Ie,Z2 as be,Z3 as he,Z4 as Te,Vf as De,Y5 as Oe,Vu as Ce,LY as Ve,Vv as ke,M0 as Ae,mH as we,gG as Ne,gF as Fe,gE as ve,uT as _e,uK as Ee,uH as Be,mz as xe,BJ as ze,BH as P,bE as R,BV as U,cE as Pe}from"./zeni-epic-state-DXFYDM66.js";import{bT as Re,N as Ue,c as Le,bj as Me,z as x,a9 as je,k as L,o as E,V as B,bV as He,af as Ze,p as M,aH as j}from"./index-CXbL8CxL.js";import{n as Ge}from"./mui-wO6EIETx.js";import{j as V}from"./liveblocks-BPL36a6x.js";import{d as H}from"./routePaths-7schl7H2.js";import{M as Ye}from"./MobileAppDrawer-CZL1M8HC.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},u=new t.Error().stack;u&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[u]="f2c4a6a0-1eb1-4b8c-9754-20d7d5afda8c",t._sentryDebugIdIdentifier="sentry-dbid-f2c4a6a0-1eb1-4b8c-9754-20d7d5afda8c")}catch{}})();function nt(){const t=Z(),u=h((r=>z(r))),n=u?.tenantId,{isApprovalRulesV3Enabled:i,isLoading:d}=Re(n),p=h((r=>r.billPaySetupApproverViewState.fetchState));k.useEffect((()=>{n==null||d||p==="Not-Started"&&t(ce(!0,!0,i))}),[n,d,i,p,t])}const $e=Ge.div`
1
+ import{a as k}from"./sentry-_x3Yh1Jc.js";import{u as Z,j as h,h as ne,g as se,i as oe,N as ie,l as re}from"./core-DOBELRta.js";import{fF as z,Hv as ce,Y$ as ue,BA as de,Sb as pe,HJ as le,KU as me,NH as fe,Ol as ye,Pa as Se,Z0 as ge,Z1 as Ie,Z2 as be,Z3 as he,Z4 as Te,Vf as De,Y5 as Oe,Vu as Ce,LY as Ve,Vv as ke,M0 as Ae,mH as we,gG as Ne,gF as Fe,gE as ve,uT as _e,uK as Ee,uH as Be,mz as xe,BJ as ze,BH as P,bE as R,BV as U,cE as Pe}from"./zeni-epic-state-DXFYDM66.js";import{bT as Re,N as Ue,c as Le,bj as Me,z as x,a9 as je,k as L,o as E,V as B,bV as He,af as Ze,p as M,aH as j}from"./index-D0or4oV9.js";import{n as Ge}from"./mui-wO6EIETx.js";import{j as V}from"./liveblocks-BPL36a6x.js";import{d as H}from"./routePaths-DTZH71MW.js";import{M as Ye}from"./MobileAppDrawer-C-ti4sM2.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},u=new t.Error().stack;u&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[u]="f2c4a6a0-1eb1-4b8c-9754-20d7d5afda8c",t._sentryDebugIdIdentifier="sentry-dbid-f2c4a6a0-1eb1-4b8c-9754-20d7d5afda8c")}catch{}})();function nt(){const t=Z(),u=h((r=>z(r))),n=u?.tenantId,{isApprovalRulesV3Enabled:i,isLoading:d}=Re(n),p=h((r=>r.billPaySetupApproverViewState.fetchState));k.useEffect((()=>{n==null||d||p==="Not-Started"&&t(ce(!0,!0,i))}),[n,d,i,p,t])}const $e=Ge.div`
2
2
  display: flex;
3
3
  min-height: 100%;
4
4
  width: 100%;
@@ -1,4 +1,4 @@
1
- import{j as S}from"./liveblocks-BPL36a6x.js";import{a as l}from"./sentry-_x3Yh1Jc.js";import{u as pe,h as he,g as Ce,j as M,i as fe,l as ge}from"./core-DOBELRta.js";import{a as Se,e7 as be,z as ye,e9 as Pe,eb as N,ec as we,bo as W,a9 as Ie,k as $,ed as H,en as Ee,G as ke,V as Ae,w as xe,eg as Te,eh as Ue,aw as _e,ek as Oe,el as ve,bl as Qe,em as Fe}from"./index-CXbL8CxL.js";import{gK as $e,fE as G,fF as je,g8 as De,jh as Ve,jd as Le,fG as z,gu as qe,go as Re,gq as B,gw as Me,gx as He,gy as ze,gz as Be,gA as Ne}from"./zeni-epic-state-DXFYDM66.js";import{D as We,n as D,P as Ge,S as Ke}from"./mui-wO6EIETx.js";import"./recharts-Sp9X2zHo.js";import"./analytics-GZ8dIY_c.js";import"./plaid-C-eBmVPr.js";import"./dnd-0MaFz9wL.js";import"./stripe-cKAAJElX.js";import"./lottie-38LSfraF.js";import"./lexical-CAgOy6Q-.js";import"./pdf-B2N0erO1.js";import"./utils-BU0XThgM.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]="888df119-e84d-43d4-9849-a7c00ecc232e",e._sentryDebugIdIdentifier="sentry-dbid-888df119-e84d-43d4-9849-a7c00ecc232e")}catch{}})();const K="chat-response-generated",Y="cards/ask",J="card_policy_hero";function j(e){return`/${e}/cards`}function X(e){return`/${e}/cards/policy`}const Ye=ge((function(e,a){const o=G(e),c=a.isSubmitting,d=Ue(e,{allUsers:a.allUsers,onCardPolicyVendorSearchTextChange:a.onCardPolicyVendorSearchTextChange});return{showSampleQuestions:a.sessionFromUrl==="new_chat"&&o.uiState.currentChatSessionId==null,aiCfoView:o,isSubmitting:c,isNewChatSession:a.sessionFromUrl==="new_chat",isFullView:!0,tableDownloadEndPoint:`${_e}/tableDownload`,exportDownloadEndPoint:Oe(),emailLinkQuestion:a.emailLinkQuestion,autoSubmitEmailLinkQuestion:a.autoSubmitEmailLinkQuestion,onEmailLinkQuestionProcessed:a.onEmailLinkQuestionProcessed,isFileUploadEnabled:a.isFileUploadEnabled,isUploadPromoVisible:a.isUploadPromoVisible,onUploadPromoClose:a.onUploadPromoClose,...d}}),(function(e,a){const{location:o,currentTenant:c,userId:d,navigate:m,currentChatSessionId:h,allSessionsWithOrderedQuestionAnswers:E,isAiCardCreationEnabled:x,isCardPolicyEnabled:T,cardPolicyPageContext:U}=a,i=c.tenantEmailDomain,C=o.state?.referrer,p=C===J?X(i):j(i);return{onEventReceived:(n,t)=>{if(n===K&&typeof t.text=="string"&&typeof t.metadata=="object"){const s=t,f=He(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,Fe(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,ze(s.visualization?.type??"")??null,b,s.summarized_title,s.metadata.message_id??null),e(Be({chatSessionId:s.metadata.chat_session_id,responseType:f,fetchState:{fetchState:"Completed",error:void 0}})),e(Ne({chatSessionId:s.metadata.chat_session_id,answerPayload:s,userId:d}))}},onSubmit:(n,t,s,f)=>{n&&Qe(e,n,t,h,E,d,f,s,U)},updateCurrentInput:n=>{e(B(n))},onStopSubmit:()=>{},onUpdateScrollYOffset:n=>{e(Me(n))},onSelectSampleQuestion:()=>{},onBackClick:()=>{m(-1)},onCloseClick:()=>{m(p,{state:{...o.state}}),e(B(""))},togglePageView:()=>{m(p,{state:N(o.state)}),a.setIsAiCfoOpen(!0)},onCopy:()=>{},onThumbsUp:()=>{},onThumbsDown:()=>{},onTogglePageView:()=>{m(-1)},onNewChatClick:()=>{h!=null&&e(Re()),m((function(n){return`/${n}/${Y}`})(i),{state:{...o.state}})},onToggleCotCollapsed:(n,t)=>{e(qe({questionAnswerId:n,isCollapsed:t}))},...ve(e,{isAiCardCreationEnabled:x,isCardPolicyEnabled:T,currentChatSessionId:h,onAfterCardsCreationSubmit:()=>{a.setIsAiCfoOpen(!0),m(j(i),{state:{...o.state}})},onAfterCardPolicySubmit:()=>{a.setIsAiCfoOpen(!0),m(`/${i}/cards/policy`,{state:{...o.state}})}})}}))(xe(Te)),{spendManagement:{chargeCard:{cardsAiCfoHero:Z,cardPolicyAiCfoHero:ee}}}=ke.getLocalizedStrings(),A=Z.pageTitle,Je=ee.pageTitle,Xe=Z.chatHeaderSubtitle,Ze=ee.chatHeaderSubtitle,St=({isFileUploadEnabled:e})=>{const{setIsAiCfoOpen:a}=Se(),o=pe(),c=he(),d=Ce(),[m,h]=l.useState(!1),{allUsers:E,isAiCardCreationEnabled:x,isCardPolicyEnabled:T,onCardPolicyVendorSearchTextChange:U}=be();l.useEffect((()=>{o($e())}),[o]);const i=M((r=>G(r))),C=ye.getSignedInUser(),{session_id:p}=fe(),n=M((r=>je(r))),t=i.uiState.currentChatSessionId,s=n.tenantEmailDomain,{handleUploadPromoClose:f,isUploadPromoVisible:b}=Pe({isFileUploadEnabled:e,tenantEmailDomain:s}),y=d.state,u=y?.aiCfoInitialQuestion??null,P=!!y?.aiCfoShouldSubmit,w=y?.referrer===J,te=w?"card_policy":void 0,se=l.useMemo((()=>({title:w?Je:A,subtitle:w?Ze:Xe})),[w]),[ae,_]=l.useState(null),[oe,O]=l.useState(!1),v=l.useRef(!1);l.useEffect((()=>{v.current||u==null||u===""||(_(u),O(P),v.current=!0)}),[u,P]);const ne=l.useCallback((()=>{_(null),O(!1),c(d.pathname,{replace:!0,state:N(d.state)})}),[d.pathname,d.state,c]),ie=n.masterTOSInfo,g=ie?.isMasterTOSAccepted??!1,k=l.useRef(null);l.useEffect((()=>{if(g&&k.current!=null){const{question:r,shouldSubmit:I}=k.current;k.current=null,_(r),O(I),v.current=!1}}),[g]);const{visitedSessions:V}=we(t),Q=i.fetchState,F=i.uiState.chatSessionsNextPageToken.hasMore||!i.uiState.chatSessionsFirstPageFetched,L=t!=null?i.fetchChatSessionHistoryByChatSessionId?.[t]?.fetchState??"Not-Started":"Not-Started",q=t==null||(i.uiState.chatHistoryNextPageToken[t]?.hasMore??!0),R=i.allSessionsWithOrderedQuestionAnswers,{currentSessionQuestionAnswers:re}=W(R,t),le=re.length===0;l.useEffect((()=>{t!=null&&p!==t&&c((function(r,I){return`/${r}/${Y}/${I}`})(s,t),{state:{...d.state},replace:!0})}),[t,p,s,c,d.state]),l.useEffect((()=>{p!=null&&t==null&&p!=="new_chat"&&o(De({sessionId:p,agentId:"controller"}))}),[]);const de=l.useMemo((()=>({events:V.map((r=>`private-encrypted-chat-${r}.${K}`)),eventCallback:(r,I,me)=>me.onEventReceived(r,I)})),[V]);if(l.useEffect((()=>{Q!=="In-Progress"&&F&&o(Ve())}),[Q,F,o]),l.useEffect((()=>{t!=null&&L!=="In-Progress"&&q&&C!=null&&Q==="Completed"&&!F&&o(Le(t,C.userId))}),[L,q,t,C,o]),C==null)throw Error("Can't access Cards AI CFO page without signing in...");const ce=p??"new_chat",ue=t!=null&&i.responseStateByChatSessionId?.[t]?.answer?.fetchState==="In-Progress";return S.jsxs(tt,{children:[S.jsx(Ie,{analytics:$,onLoad:r=>r.trackPageLoaded(Ae.Event.aiCFOPage)}),g?S.jsx(Ye,{...de,currentChatSessionId:t,allSessionsWithOrderedQuestionAnswers:R,allUsers:E,isAiCardCreationEnabled:x,isCardPolicyEnabled:T,openOnboardingPage:()=>h(!0),userId:C.userId,setIsAiCfoOpen:a,navigate:c,sessionFromUrl:ce,location:d,isSubmitting:ue,isEmptyChatWithSession:le,customPageTitle:A,chatHeader:se,currentTenant:n,emailLinkQuestion:ae??void 0,autoSubmitEmailLinkQuestion:oe,onEmailLinkQuestionProcessed:ne,isFileUploadEnabled:e,isUploadPromoVisible:b,onUploadPromoClose:f,onCardPolicyVendorSearchTextChange:U,cardPolicyPageContext:te}):S.jsx(H,{isTOSAccepted:g,acceptMasterTOSState:i.masterTOSAcceptanceState,customPageTitle:A,onCloseClick:()=>{c(w?X(s):j(s),{state:{...d.state}})},onCompleteClick:()=>{g||n.userRoleId==null||(u!=null&&u!==""&&(k.current={question:u,shouldSubmit:P}),o(z(n.userRoleId)))}}),S.jsx(We,{anchor:"right",open:m,transitionDuration:250,PaperProps:{component:st,style:{width:`${Ee}vw`}},slotProps:{backdrop:{style:{backgroundColor:"transparent",cursor:"pointer"}}},onClose:()=>h(!1),children:S.jsx(et,{onClick:r=>r.stopPropagation(),children:S.jsx(H,{isTOSAccepted:g,acceptMasterTOSState:i.masterTOSAcceptanceState,customPageTitle:A,onCloseClick:()=>h(!1),onCompleteClick:()=>{g||n.userRoleId==null||o(z(n.userRoleId)),h(!1)}})})})]})},et=D(Ke)`
1
+ import{j as S}from"./liveblocks-BPL36a6x.js";import{a as l}from"./sentry-_x3Yh1Jc.js";import{u as pe,h as he,g as Ce,j as M,i as fe,l as ge}from"./core-DOBELRta.js";import{a as Se,e7 as be,z as ye,e9 as Pe,eb as N,ec as we,bo as W,a9 as Ie,k as $,ed as H,en as Ee,G as ke,V as Ae,w as xe,eg as Te,eh as Ue,aw as _e,ek as Oe,el as ve,bl as Qe,em as Fe}from"./index-D0or4oV9.js";import{gK as $e,fE as G,fF as je,g8 as De,jh as Ve,jd as Le,fG as z,gu as qe,go as Re,gq as B,gw as Me,gx as He,gy as ze,gz as Be,gA as Ne}from"./zeni-epic-state-DXFYDM66.js";import{D as We,n as D,P as Ge,S as Ke}from"./mui-wO6EIETx.js";import"./recharts-Sp9X2zHo.js";import"./analytics-GZ8dIY_c.js";import"./plaid-C-eBmVPr.js";import"./dnd-0MaFz9wL.js";import"./stripe-cKAAJElX.js";import"./lottie-38LSfraF.js";import"./lexical-CAgOy6Q-.js";import"./pdf-B2N0erO1.js";import"./utils-BU0XThgM.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]="888df119-e84d-43d4-9849-a7c00ecc232e",e._sentryDebugIdIdentifier="sentry-dbid-888df119-e84d-43d4-9849-a7c00ecc232e")}catch{}})();const K="chat-response-generated",Y="cards/ask",J="card_policy_hero";function j(e){return`/${e}/cards`}function X(e){return`/${e}/cards/policy`}const Ye=ge((function(e,a){const o=G(e),c=a.isSubmitting,d=Ue(e,{allUsers:a.allUsers,onCardPolicyVendorSearchTextChange:a.onCardPolicyVendorSearchTextChange});return{showSampleQuestions:a.sessionFromUrl==="new_chat"&&o.uiState.currentChatSessionId==null,aiCfoView:o,isSubmitting:c,isNewChatSession:a.sessionFromUrl==="new_chat",isFullView:!0,tableDownloadEndPoint:`${_e}/tableDownload`,exportDownloadEndPoint:Oe(),emailLinkQuestion:a.emailLinkQuestion,autoSubmitEmailLinkQuestion:a.autoSubmitEmailLinkQuestion,onEmailLinkQuestionProcessed:a.onEmailLinkQuestionProcessed,isFileUploadEnabled:a.isFileUploadEnabled,isUploadPromoVisible:a.isUploadPromoVisible,onUploadPromoClose:a.onUploadPromoClose,...d}}),(function(e,a){const{location:o,currentTenant:c,userId:d,navigate:m,currentChatSessionId:h,allSessionsWithOrderedQuestionAnswers:E,isAiCardCreationEnabled:x,isCardPolicyEnabled:T,cardPolicyPageContext:U}=a,i=c.tenantEmailDomain,C=o.state?.referrer,p=C===J?X(i):j(i);return{onEventReceived:(n,t)=>{if(n===K&&typeof t.text=="string"&&typeof t.metadata=="object"){const s=t,f=He(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,Fe(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,ze(s.visualization?.type??"")??null,b,s.summarized_title,s.metadata.message_id??null),e(Be({chatSessionId:s.metadata.chat_session_id,responseType:f,fetchState:{fetchState:"Completed",error:void 0}})),e(Ne({chatSessionId:s.metadata.chat_session_id,answerPayload:s,userId:d}))}},onSubmit:(n,t,s,f)=>{n&&Qe(e,n,t,h,E,d,f,s,U)},updateCurrentInput:n=>{e(B(n))},onStopSubmit:()=>{},onUpdateScrollYOffset:n=>{e(Me(n))},onSelectSampleQuestion:()=>{},onBackClick:()=>{m(-1)},onCloseClick:()=>{m(p,{state:{...o.state}}),e(B(""))},togglePageView:()=>{m(p,{state:N(o.state)}),a.setIsAiCfoOpen(!0)},onCopy:()=>{},onThumbsUp:()=>{},onThumbsDown:()=>{},onTogglePageView:()=>{m(-1)},onNewChatClick:()=>{h!=null&&e(Re()),m((function(n){return`/${n}/${Y}`})(i),{state:{...o.state}})},onToggleCotCollapsed:(n,t)=>{e(qe({questionAnswerId:n,isCollapsed:t}))},...ve(e,{isAiCardCreationEnabled:x,isCardPolicyEnabled:T,currentChatSessionId:h,onAfterCardsCreationSubmit:()=>{a.setIsAiCfoOpen(!0),m(j(i),{state:{...o.state}})},onAfterCardPolicySubmit:()=>{a.setIsAiCfoOpen(!0),m(`/${i}/cards/policy`,{state:{...o.state}})}})}}))(xe(Te)),{spendManagement:{chargeCard:{cardsAiCfoHero:Z,cardPolicyAiCfoHero:ee}}}=ke.getLocalizedStrings(),A=Z.pageTitle,Je=ee.pageTitle,Xe=Z.chatHeaderSubtitle,Ze=ee.chatHeaderSubtitle,St=({isFileUploadEnabled:e})=>{const{setIsAiCfoOpen:a}=Se(),o=pe(),c=he(),d=Ce(),[m,h]=l.useState(!1),{allUsers:E,isAiCardCreationEnabled:x,isCardPolicyEnabled:T,onCardPolicyVendorSearchTextChange:U}=be();l.useEffect((()=>{o($e())}),[o]);const i=M((r=>G(r))),C=ye.getSignedInUser(),{session_id:p}=fe(),n=M((r=>je(r))),t=i.uiState.currentChatSessionId,s=n.tenantEmailDomain,{handleUploadPromoClose:f,isUploadPromoVisible:b}=Pe({isFileUploadEnabled:e,tenantEmailDomain:s}),y=d.state,u=y?.aiCfoInitialQuestion??null,P=!!y?.aiCfoShouldSubmit,w=y?.referrer===J,te=w?"card_policy":void 0,se=l.useMemo((()=>({title:w?Je:A,subtitle:w?Ze:Xe})),[w]),[ae,_]=l.useState(null),[oe,O]=l.useState(!1),v=l.useRef(!1);l.useEffect((()=>{v.current||u==null||u===""||(_(u),O(P),v.current=!0)}),[u,P]);const ne=l.useCallback((()=>{_(null),O(!1),c(d.pathname,{replace:!0,state:N(d.state)})}),[d.pathname,d.state,c]),ie=n.masterTOSInfo,g=ie?.isMasterTOSAccepted??!1,k=l.useRef(null);l.useEffect((()=>{if(g&&k.current!=null){const{question:r,shouldSubmit:I}=k.current;k.current=null,_(r),O(I),v.current=!1}}),[g]);const{visitedSessions:V}=we(t),Q=i.fetchState,F=i.uiState.chatSessionsNextPageToken.hasMore||!i.uiState.chatSessionsFirstPageFetched,L=t!=null?i.fetchChatSessionHistoryByChatSessionId?.[t]?.fetchState??"Not-Started":"Not-Started",q=t==null||(i.uiState.chatHistoryNextPageToken[t]?.hasMore??!0),R=i.allSessionsWithOrderedQuestionAnswers,{currentSessionQuestionAnswers:re}=W(R,t),le=re.length===0;l.useEffect((()=>{t!=null&&p!==t&&c((function(r,I){return`/${r}/${Y}/${I}`})(s,t),{state:{...d.state},replace:!0})}),[t,p,s,c,d.state]),l.useEffect((()=>{p!=null&&t==null&&p!=="new_chat"&&o(De({sessionId:p,agentId:"controller"}))}),[]);const de=l.useMemo((()=>({events:V.map((r=>`private-encrypted-chat-${r}.${K}`)),eventCallback:(r,I,me)=>me.onEventReceived(r,I)})),[V]);if(l.useEffect((()=>{Q!=="In-Progress"&&F&&o(Ve())}),[Q,F,o]),l.useEffect((()=>{t!=null&&L!=="In-Progress"&&q&&C!=null&&Q==="Completed"&&!F&&o(Le(t,C.userId))}),[L,q,t,C,o]),C==null)throw Error("Can't access Cards AI CFO page without signing in...");const ce=p??"new_chat",ue=t!=null&&i.responseStateByChatSessionId?.[t]?.answer?.fetchState==="In-Progress";return S.jsxs(tt,{children:[S.jsx(Ie,{analytics:$,onLoad:r=>r.trackPageLoaded(Ae.Event.aiCFOPage)}),g?S.jsx(Ye,{...de,currentChatSessionId:t,allSessionsWithOrderedQuestionAnswers:R,allUsers:E,isAiCardCreationEnabled:x,isCardPolicyEnabled:T,openOnboardingPage:()=>h(!0),userId:C.userId,setIsAiCfoOpen:a,navigate:c,sessionFromUrl:ce,location:d,isSubmitting:ue,isEmptyChatWithSession:le,customPageTitle:A,chatHeader:se,currentTenant:n,emailLinkQuestion:ae??void 0,autoSubmitEmailLinkQuestion:oe,onEmailLinkQuestionProcessed:ne,isFileUploadEnabled:e,isUploadPromoVisible:b,onUploadPromoClose:f,onCardPolicyVendorSearchTextChange:U,cardPolicyPageContext:te}):S.jsx(H,{isTOSAccepted:g,acceptMasterTOSState:i.masterTOSAcceptanceState,customPageTitle:A,onCloseClick:()=>{c(w?X(s):j(s),{state:{...d.state}})},onCompleteClick:()=>{g||n.userRoleId==null||(u!=null&&u!==""&&(k.current={question:u,shouldSubmit:P}),o(z(n.userRoleId)))}}),S.jsx(We,{anchor:"right",open:m,transitionDuration:250,PaperProps:{component:st,style:{width:`${Ee}vw`}},slotProps:{backdrop:{style:{backgroundColor:"transparent",cursor:"pointer"}}},onClose:()=>h(!1),children:S.jsx(et,{onClick:r=>r.stopPropagation(),children:S.jsx(H,{isTOSAccepted:g,acceptMasterTOSState:i.masterTOSAcceptanceState,customPageTitle:A,onCloseClick:()=>h(!1),onCompleteClick:()=>{g||n.userRoleId==null||o(z(n.userRoleId)),h(!1)}})})})]})},et=D(Ke)`
2
2
  display: flex;
3
3
  min-height: 100%;
4
4
  flex-direction: column;
@@ -1,4 +1,4 @@
1
- import{j as o}from"./liveblocks-BPL36a6x.js";import{u as me,j as d,h as de,g as he,i as Ne,N as Je,s as _t,l as Pe,t as _n,n as cs,o as ne}from"./core-DOBELRta.js";import{fS as Pt,$L as is,g2 as wt,bt as Te,$M as ds,$N as ls,fH as fn,$O as Pn,fQ as wn,$P as vn,$Q as Tn,$R as Fn,$S as xn,fR as Ln,g1 as Bn,$T as Rn,$U as us,fX as ms,fW as Cs,$V as ps,JZ as On,g4 as ia,$W as hs,$X as fs,fJ as gs,fI as bs,gh as ze,fZ as jn,fY as Un,$Y as Ss,f_ as ys,Jv as Is,Ju as ks,Jy as Es,JA as As,ga as Ds,fE as Mn,$Z as _s,$_ as Ps,gf as Nn,$$ as ws,gg as yt,JG as vs,JD as Ts,fF as fe,a00 as qa,dZ as Fe,di as xe,d_ as Le,g_ as da,cB as la,a01 as ua,a02 as vt,CV as Ga,m7 as Ka,a03 as za,Kd as ka,g5 as qe,Kf as Tt,lZ as Vn,a04 as ma,K1 as _a,a05 as Fs,a06 as xs,K4 as Ja,a07 as Ls,YY as Qa,g0 as Hn,Ka as ba,iq as Bs,a08 as $n,fT as Ca,br as Rs,a09 as Os,gG as Xa,gF as et,KJ as js,gE as at,a0a as Gn,cu as Kn,da as Us,YX as wa,Li as zn,a0b as gn,KU as Pa,a0c as Yn,Lj as Ms,Zl as Ns,Lk as Vs,Mp as Hs,C9 as $s,Mj as Gs,a0d as Ks,Ke as oa,a0e as zs,a0f as Ys,a0g as Zs,a0h as Ws,a0i as qs,a0j as Ft,a0k as Js,Ku as Zn,Kn as Qs,a0l as Xs,h0 as eo,a0m as Wn,KD as qn,KH as Jn,g$ as ao,a0n as to,L4 as Qn,a0o as no,a0p as ro,a0q as so,KF as Xn,Kq as er,K7 as ar,Kz as tr,Kx as nr,KB as oo,a0r as rr,a0s as co,gc as io,gd as lo,ge as uo,a0t as tt,g6 as sr,dc as xt,a0u as mo,a0v as Co,a0w as po,a0x as ho,KP as It,Lb as fo,L7 as go,KL as bo,L9 as So,K$ as yo,L1 as Io,a0y as or,Lh as $a,S8 as ko,a0z as Eo,a0A as Ao,a0B as Do,a0C as cr,a0D as _o,LE as Po,KT as ir,KO as Me,KS as wo,a0E as vo,a0F as To,J_ as Fo,a0G as dr,f$ as lr,a0H as xo,K0 as Lo,J$ as bn,a0I as Bo,a0J as Ro,a0K as Oo,Vg as jo,a0L as Lt,a0M as Uo,xf as ur,mH as Mo,ie as No,LJ as Vo,a0N as mr,fN as Ho,fO as $o,a0O as Go,dO as Ko,g3 as zo,Lz as Yo,Lt as We,bq as Zo,bJ as Wo,cG as qo,bK as Jo,U7 as Qo}from"./zeni-epic-state-DXFYDM66.js";import{N as Be,de as Cr,a5 as we,df as pr,dg as hr,dh as Xo,G as ea,at as Bt,di as ec,dj as ac,a as fr,e as gr,as as br,p as ke,c as le,A as Z,j as ya,dk as Sr,dl as tc,dm as nc,z as te,a8 as va,d3 as nt,dn as rc,dp as sc,dq as oc,a2 as Ta,bj as Qe,bF as Rt,dr as cc,ac as Fa,Z as rt,E as Ot,k as ae,w as st,ds as ic,bR as Sa,dt as kt,du as dc,a9 as jt,dv as lc,af as yr,aw as Et,dw as uc,ar as Ir,M as kr,V as Er,dx as mc,dy as Cc,dz as pc,dA as hc,dB as fc,dC as gc,dD as bc,I as Ya,dE as Sc,dF as yc,m as ht,R as Ic,dG as kc,dH as Ec,dI as Ac,aj as Dc,dJ as _c,dK as Pc,h as wc}from"./index-CXbL8CxL.js";import{n as Ve,D as Ar,S as vc}from"./mui-wO6EIETx.js";import{a as r}from"./sentry-_x3Yh1Jc.js";import{u as xa}from"./useAskAiCfoHostNavButtonProps-gnFsttzV.js";import{M as Ee}from"./MobileAppDrawer-CZL1M8HC.js";import{d as Ut}from"./recharts-Sp9X2zHo.js";import{g as _e,a as La,b as Dr,c as Re,d as Oe,e as Xe,f as aa,h as ta,A as Tc,i as Mt,P as Fc,j as Nt,s as Ia,k as _r,l as ca,m as Pr,n as xc,o as wr,p as Lc,S as Sn}from"./SetupPagesScreen-Y9SYCogP.js";import{u as vr}from"./useInitialThreadRequest-TFVuVZA_.js";import ot from"./NotFoundScreen-rNwJ2-Qg.js";import{u as Vt}from"./useChargeCardPusherEvents-BHookjIG.js";import{n as yn}from"./utils-BU0XThgM.js";import{t as Bc}from"./AddressScreen-dsCmoEfc.js";import"./analytics-GZ8dIY_c.js";import"./plaid-C-eBmVPr.js";import"./dnd-0MaFz9wL.js";import"./stripe-cKAAJElX.js";import"./lottie-38LSfraF.js";import"./lexical-CAgOy6Q-.js";import"./pdf-B2N0erO1.js";import"./InboxNotificationsProvider-Bd8tLMl8.js";import"./useTaskManagerAccess-CiaMEBoG.js";import"./BusinessVerificationPageScreen-fABxFj6p.js";import"./routePaths-7schl7H2.js";import"./analyticsHelper-B9ZU7ow3.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]="92cb6d11-adc1-465e-9aa9-7e94d35ef076",e._sentryDebugIdIdentifier="sentry-dbid-92cb6d11-adc1-465e-9aa9-7e94d35ef076")}catch{}})();const Rc=e=>{const a=e.cardHolderUser,n=`${a.firstName??""} ${a.lastName??""}`.trim()||a.email||a.userId;return{userId:a.userId,displayName:n,roleLabel:e.cardHolderRoles?.titleAtCompany}},Tr=e=>({id:e.id,isChecked:!1,cardName:e.cardName,last4:e.accountLast4,limitAmount:e.limit?.amount??0,limitCadence:e.creditLimitFrequency?.code,owner:Rc(e),utilizationAmount:(e.limit?.amount??0)-(e.available?.amount??0)});function Fr(){const e=me(),a=d((t=>Pt(t.cardPolicyState))),n=d((t=>is(t.cardPolicyState)));r.useEffect((()=>{n!==""||a==="Completed"&&n===""||a==="In-Progress"||e(wt())}),[e,a,n])}const{spendManagement:{chargeCard:{cardPolicyPage:In}}}=ea.getLocalizedStrings(),Oc=e=>jn(e,!1),jc=e=>Un(e.name,!1);function Uc(){const e=de(),a=he(),{tenantEmailDomain:n}=Ne(),t=me(),s=Be(),g=Te(s?.loggedInUserRoleMap),[b,h]=r.useState(!1),A=r.useCallback((O=>{h(O)}),[]),u=r.useCallback((()=>{A(!0)}),[A]),{isAiCfoAccessEnabled:m,onAskAiCfoClick:F}=xa({mobileExploreReferrer:"Card Policy"});r.useEffect((()=>()=>{t(ds()),t(ls()),t(fn())}),[t]);const w=d((O=>Pn(O.cardPolicyState))),p=d((O=>wn(O.cardPolicyState))),T=d((O=>vn(O.cardPolicyState))),B=d((O=>Tn(O.cardPolicyState))),S=d((O=>Fn(O.cardPolicyState))),l=d((O=>xn(O.cardPolicyState))),C=d((O=>Ln(O.cardPolicyState))),L=d((O=>Pt(O.cardPolicyState))),k=d((O=>O.chargeCardConfigState.receiptRequiredAboveAmount.amount)),_=d((O=>O.chargeCardConfigState.fetchState));r.useEffect((()=>{w!=="Completed"&&w!=="In-Progress"&&t(Bn())}),[t,w]),Fr();const D=d((O=>Rn(O.createCardPolicyState))),M=d((O=>us(O.createCardPolicyState))),E=d((O=>ms(O.cardPolicyState))),y=d((O=>Cs(O.cardPolicyState))),R=d((O=>ps(O.createCardPolicyState))),i=d((O=>On(O)));r.useEffect((()=>{i.fetchState==="Not-Started"&&t(ia(!1,!1,!1))}),[i.fetchState,t]);const f=r.useMemo((()=>p.map(Oc)),[p]),U=r.useMemo((()=>C.map(jc)),[C]),G=r.useMemo((()=>i.cards.filter((O=>!Cr(O.status.code))).map(Tr)),[i.cards]),j=w==="Completed"&&i.fetchState==="Completed"&&_==="Completed";r.useEffect((()=>{j&&R==null&&t(hs({cardsMasterList:G,defaultRequireReceiptAmount:k,suggestedAllowMerchants:T,suggestedBlockMerchants:B,suggestedAllowCategories:S,suggestedBlockCategories:l}))}),[_,t,j,R,G,k,T,B,S,l]);const x=r.useMemo((()=>Ut((O=>{t(wt(O))}),250)),[t]);r.useEffect((()=>()=>{x.cancel()}),[x]);const z=r.useCallback((O=>{x(O)}),[x]),H=D.fetchState,v=n!=null?`/${n}/cards/policy`:"..",P=r.useCallback((()=>{const O=we(a.state?.pathnameStackToGoBack),q=O.poppedPathname??v;e(q,{state:{pathnameStackToGoBack:O.newStack}})}),[a.state,e,v]),K=r.useCallback((()=>{e(v)}),[e,v]),W=r.useCallback((O=>{t(fs(O))}),[t]),I=r.useCallback((O=>{const q=pr(O);t(gs({templates:[q]}))}),[t]),N=r.useCallback((O=>{O.length!==0&&t(bs(O))}),[t]),V=r.useCallback((()=>{t(fn())}),[t]),Q=r.useRef(H);r.useEffect((()=>{const O=Q.current;Q.current=H,H==="Completed"&&O!=="Completed"&&M!=null&&(t(ze({messageSection:"card_policy_created",messageText:"success",type:"success"})),e(v))}),[t,H,M,e,v]);const c=H==="Error"?D.error?.message??In.createPolicyGenericErrorMessage:void 0;return g&&n!=null?R==null?o.jsxs(o.Fragment,{children:[o.jsx(Ee,{isAppContentDrawerOpen:b,handleDrawerToggle:A}),o.jsx(hr,{showUploadDocumentSection:!0,navBarTitle:In.createPageTitle,onBackClick:P,onClickMenuIcon:u,isAiCfoAccessEnabled:m,onAskAiCfoClick:F})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ee,{isAppContentDrawerOpen:b,handleDrawerToggle:A}),o.jsx(Xo,{formDraft:R,vendorSearchOptions:U,categorySearchOptions:f,isVendorSearchLoading:L==="In-Progress",onVendorSearchTextChange:z,submitState:H,submitErrorMessage:c,documentUploadState:E,uploadedFileName:y,isAiCfoAccessEnabled:m,onAskAiCfoClick:F,onBackClick:P,onCancelClick:K,onClickMenuIcon:u,onFormChange:W,onSubmit:I,onUploadDocument:N,onRemoveDocument:V})]}):o.jsx(Je,{to:"..",replace:!0})}const{spendManagement:{chargeCard:{cardPolicyPage:Mc}}}=ea.getLocalizedStrings(),Nc=e=>jn(e,!1),Vc=e=>Un(e.name,!1);function Hc(){const e=de(),a=he(),{tenantEmailDomain:n,templateId:t}=Ne(),s=me(),g=Be(),b=Te(g?.loggedInUserRoleMap),[h,A]=r.useState(!1),u=r.useCallback((c=>{A(c)}),[]),m=r.useCallback((()=>{u(!0)}),[u]),{isAiCfoAccessEnabled:F,onAskAiCfoClick:w}=xa({mobileExploreReferrer:"Card Policy"}),p=d((c=>Ss(c))),T=d((c=>Pn(c.cardPolicyState))),B=d((c=>wn(c.cardPolicyState))),S=d((c=>vn(c.cardPolicyState))),l=d((c=>Tn(c.cardPolicyState))),C=d((c=>Fn(c.cardPolicyState))),L=d((c=>xn(c.cardPolicyState))),k=d((c=>Ln(c.cardPolicyState))),_=d((c=>Pt(c.cardPolicyState))),D=d((c=>On(c))),M=d((c=>t!=null?ys(c.cardPolicyState,t):void 0)),E=r.useMemo((()=>p.templateId===t&&p.formDraft!=null?p.formDraft:M!=null?Is(M):void 0),[p.templateId,p.formDraft,M,t]);r.useEffect((()=>{if(t==null)return;const c=p.detailFetchState.fetchState;p.templateId===t&&(c==="Completed"||c==="In-Progress")||M!=null||s(ks(t))}),[s,t,p.templateId,p.detailFetchState.fetchState,M]),r.useEffect((()=>{T!=="Completed"&&T!=="In-Progress"&&s(Bn())}),[s,T]),Fr();const y=d((c=>c.chargeCardConfigState.receiptRequiredAboveAmount.amount));r.useEffect((()=>{D.fetchState==="Not-Started"&&s(ia(!1,!1,!1))}),[D.fetchState,s]);const R=r.useMemo((()=>B.map(Nc)),[B]),i=r.useMemo((()=>k.map(Vc)),[k]),f=r.useMemo((()=>D.cards.filter((c=>!Cr(c.status.code))).map(Tr)),[D.cards]);Bt({isDataReady:E!=null});const U=r.useMemo((()=>{if(E!=null)return ec({draft:E,cardRows:f,categorySearchOptions:R,vendorSearchOptions:i,defaultRequireReceiptAmount:y,suggestedAllowMerchants:S,suggestedBlockMerchants:l,suggestedAllowCategories:C,suggestedBlockCategories:L})}),[E,f,R,i,y,S,l,C,L]),[G,j]=r.useState(void 0),x=r.useRef(!1);r.useEffect((()=>{x.current||G!=null||U==null||(x.current=!0,j(U))}),[G,U]);const z=r.useCallback((c=>{j(c)}),[]),H=r.useMemo((()=>Ut((c=>{s(wt(c))}),250)),[s]);r.useEffect((()=>()=>{H.cancel()}),[H]);const v=r.useCallback((c=>{H(c)}),[H]),P=p.updateFetchState.fetchState,K=n!=null?`/${n}/cards/policy`:"..",W=r.useCallback((()=>{const c=we(a.state?.pathnameStackToGoBack),O=c.poppedPathname??K;e(O,{state:{pathnameStackToGoBack:c.newStack}})}),[a.state,e,K]),I=r.useCallback((()=>{e(K)}),[e,K]),N=r.useCallback((c=>{if(t==null)return;const O=pr(c);s(Es(O)),s(As(t))}),[s,t]),V=r.useRef(P);r.useEffect((()=>{const c=V.current;V.current=P,P==="Completed"&&c!=="Completed"&&(s(ze({messageSection:"card_policy_updated",messageText:"success",type:"success"})),e(K))}),[s,P,e,K]);const Q=P==="Error"?p.updateFetchState.error?.message??Mc.updatePolicyGenericErrorMessage:void 0;return!b||n==null||t==null?o.jsx(Je,{to:"..",replace:!0}):G!=null&&T==="Completed"&&D.fetchState==="Completed"?o.jsxs(o.Fragment,{children:[o.jsx(Ee,{isAppContentDrawerOpen:h,handleDrawerToggle:u}),o.jsx(ac,{templateName:p.template?.name??"",formDraft:G,vendorSearchOptions:i,categorySearchOptions:R,isVendorSearchLoading:_==="In-Progress",onVendorSearchTextChange:v,submitState:P,submitErrorMessage:Q,isAiCfoAccessEnabled:F,onAskAiCfoClick:w,onBackClick:W,onCancelClick:I,onClickMenuIcon:m,onFormChange:z,onSubmit:N})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ee,{isAppContentDrawerOpen:h,handleDrawerToggle:u}),o.jsx(hr,{showUploadDocumentSection:!1,navBarTitle:p.template?.name,onBackClick:W,onClickMenuIcon:m,isAiCfoAccessEnabled:F,onAskAiCfoClick:w})]})}function xr(e,a,n){return a?e.filter((t=>t!=null&&t.trim().length>0)).slice(0,n):[]}function Lr(e){return d((a=>e==null||e===""?{chips:ft,isResolved:!1}:(function(n){const t=n?.fetchState,s=t==="Completed"||t==="Error";return{chips:t==="Completed"?n?.suggestedQuestions??ft:ft,isResolved:s}})(Ds(a,e))),_t)}const ft=[],{spendManagement:{chargeCard:{cardPolicyAiCfoHero:{headline:$c,subheadline:Gc,pageTitle:Kc}}}}=ea.getLocalizedStrings(),zc=e=>{const a=e.cardsCount>0?e.cardsCount:e.appliedCards.length,n=e.allowedEntity.merchantNames.length+e.blockedEntity.merchantNames.length,t=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:a,vendorRestrictionsCount:n,categoryRestrictionsCount:t}};function Yc(){const e=de(),a=he(),{tenantEmailDomain:n}=Ne(),t=me(),s=Be(),g=Te(s?.loggedInUserRoleMap),[b,h]=r.useState(!1),A=r.useCallback((v=>{h(v)}),[]),u=r.useCallback((()=>{A(!0)}),[A]),{useFeatureGate:m}=le(),{isFeatureEnabled:F}=m(Z.isAiCfoFileUploadEnabled),{isFeatureEnabled:w}=m(Z.isCardPolicyEnabled),{isAiCfoAccessEnabled:p,onAskAiCfoClick:T}=xa({mobileExploreReferrer:"Card Policy"}),B=d((v=>_s(v))),S=d((v=>Rn(v.createCardPolicyState))),l=d((v=>Ps(v.createCardPolicyState))),C=d((v=>l==null?[]:Nn(v.aiCfoState,l).filter((P=>P.kind==="creating_policy"))),_t),L=S.fetchState==="In-Progress"?Math.max(C.length,1):0,k=d((v=>ws(v.createCardPolicyState))),_=ya(S.fetchState);r.useEffect((()=>{if(_==="In-Progress"&&S.fetchState==="Completed"&&l!=null)C.forEach((v=>{t(yt({chatSessionId:l,id:v.id,entityIds:k,kind:"created_policy"}))}));else if(_==="In-Progress"&&S.fetchState==="Error"&&l!=null){C.forEach((P=>{t(yt({chatSessionId:l,id:P.id,kind:"errored_policy"}))}));const v=S.error?.message!=null&&S.error.message.length>0?S.error.message:ea.getLocalizedStrings().common.errorMessage.somethingWentWrongPleaseTryAgain;t(ze({messageSection:"card_policy_created",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:v}]}))}}),[S.error?.message,S.fetchState,t,l,k,C,_]);const D=B.fetchState.fetchState;r.useEffect((()=>{D!=="Not-Started"&&D!=="Error"||t(vs())}),[t,D]);const M=B.archiveFetchState.fetchState,E=ya(M);r.useEffect((()=>{E==="In-Progress"&&M==="Completed"&&t(ze({messageSection:"card_policy_deleted",messageText:"success",type:"success"}))}),[M,t,E]);const y=r.useMemo((()=>B.templates.map(zc)),[B.templates]);Bt({isDataReady:B.fetchState.fetchState==="Completed"});const R=y.length>0||L>0,i=(function(v){const{hasAnyPolicies:P,isChargeCardAdmin:K,isFileUploadEnabled:W}=v,I=de(),N=he(),{tenantEmailDomain:V}=Ne(),{isAiCfoOpen:Q,setIsAiCfoOpen:c}=fr(),O=gr(),q=br(),se=d((J=>Mn(J))).createSessionAndSubmitState.fetchState==="In-Progress",{chips:X,isResolved:He}=Lr("card_policy"),Ae=r.useMemo((()=>xr(X,He,3)),[X,He]),[ge,re]=r.useState(""),be=q&&O&&V!=null&&!Q,ue=r.useCallback((J=>{if(V==null)return;const fa=ke(N.state?.pathnameStackToGoBack,N.pathname);I(`/${V}/cards/ask`,{state:{message:"",origin:"",pathnameStackToGoBack:fa,referrer:"card_policy_hero",aiCfoInitialQuestion:J,aiCfoShouldSubmit:J!=null&&J.trim().length>0}})}),[N.pathname,N.state,I,V]),oe=r.useCallback((J=>{J.trim().length!==0&&(re(""),ue(J))}),[ue]),Se=r.useCallback((()=>{const J=ge.trim();J.length!==0&&(re(""),ue(J))}),[ge,ue]),ee=r.useCallback((()=>{}),[]),De=r.useCallback((J=>{re(J)}),[]),ve=r.useCallback((()=>{c(!0)}),[c]),Ce=r.useCallback((()=>{ue(void 0)}),[ue]);return r.useMemo((()=>{if(be&&!P&&K)return{aiAgentName:Kc,headline:$c,subheadline:Gc,promptChips:Ae,composer:{currentInput:ge,isSubmitting:se,isFileUploadEnabled:W,onInputChange:De,onSubmit:Se,onStopSubmit:ee},onPromptClick:oe,onOpenSidePanel:ve,onOpenFullView:Ce,dataTestIdPrefix:"card-policy-ai-cfo-hero"}}),[ge,P,be,K,W,se,De,Ce,ve,oe,ee,Se,Ae])})({hasAnyPolicies:R,isChargeCardAdmin:g,isFileUploadEnabled:F}),f=w&&i!=null?o.jsx(Sr,{...i}):null,U=p&&f==null,G=r.useCallback((()=>{const v=we(a.state?.pathnameStackToGoBack),P=v.poppedPathname??"..";e(P,{state:{pathnameStackToGoBack:v.newStack}})}),[a.state,e]),j=r.useCallback((()=>{n!=null&&e(`/${n}/cards/policy/new`)}),[e,n]),x=r.useCallback((v=>{n!=null&&e(`/${n}/cards/policy/${v}/edit`)}),[e,n]),z=r.useCallback((v=>{t(Ts(v))}),[t]),H=B.fetchState.fetchState;return!R&&H!=="Completed"&&H!=="Error"?o.jsxs(o.Fragment,{children:[o.jsx(Ee,{isAppContentDrawerOpen:b,handleDrawerToggle:A}),o.jsx(tc,{onBackClick:G,onNewPolicyClick:j,onClickMenuIcon:u,isAiCfoAccessEnabled:p,onAskAiCfoClick:T})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ee,{isAppContentDrawerOpen:b,handleDrawerToggle:A}),o.jsx(nc,{policies:y,archivingTemplateId:B.archiveTargetTemplateId,pendingCreationCount:L,onBackClick:G,onNewPolicyClick:j,onEditPolicyClick:x,onArchivePolicyClick:z,onClickMenuIcon:u,policyAiCfoHero:f,isAiCfoAccessEnabled:U,onAskAiCfoClick:T})]})}function Zc(){const e=de(),{cardId:a}=Ne(),n=me(),t=te.getSignedInUser(),s=d((X=>fe(X))),g=Be(),b=Te(g?.loggedInUserRoleMap),{useFeatureGate:h}=le();if(t==null)throw Error("Can't access Add To Wallet Page without signing in...");const[A,u]=r.useState(!1),m=d((X=>qa(X).firstViewAfterActivation));if(a==null)throw Error("Empty card id is not valid...");const F=s.userRole.includes("charge_card_user"),{isFeatureEnabled:w}=h(Z.isChargeCardFeatureEnabled),p=!!s.companyChargeCardInfo?.info?.isChargeCardEnabled,{isFeatureEnabled:T}=h(Z.isDebitCardFeatureEnabled),B=Fe(s),S=xe(s),l=Le(T,s),C=s.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,L=Re({isDebitCardFeatureEnabled:T,isBankingOnlyTenant:l}),k=Oe({isCardsOnlyTenant:B,isChargeCardFeatureEnabled:w,isBookKeepingTenant:S,isDebitCardProductVisible:L,chargeCardsCreditAccountLimit:C}),_=!!s.companyDebitCardInfo?.info?.isDebitCardEnabled,D=d((X=>da(X,s.companyId))),M=la(D.controllers),{creditAccount:E,creditAccountRepayment:y}=d((X=>ua(X))),R=d((X=>X.classListState.fetchState)),i=!F&&k&&p,f=d((X=>vt(X,a,i,k))),[U,G]=r.useState(!1),j=f.chargeCard,x=j?.cardCreatedByUser?.userId,z=d((X=>x!=null?Ga(X.userRoleState,x):void 0)),H=z?.accountingClassIDs[0],v=d((X=>H!=null?Ka(X.classState,{classId:H,reportId:"class_list"}):void 0)),P=j?.cardHolderUser?.userId,K=d((X=>P!=null?Ga(X.userRoleState,P):void 0)),W=K?.accountingClassIDs[0],I=d((X=>W!=null?Ka(X.classState,{classId:W,reportId:"class_list"}):void 0)),N=j?.type.code==="business_physical_credit_card"||j?.type.code==="business_physical_debit_card",V=j?.type.code==="business_physical_debit_card";r.useEffect((()=>{m&&A===!1&&N&&(u(!0),setTimeout((()=>{n(za()),V&&n(ze({messageSection:"set_debit_card_pin",messageText:"success",type:"success",showStatusIcon:!0}))}),5e3))}),[m,A,N,V]),r.useEffect((()=>{U||f.fetchState==="Completed"||f.fetchState==="In-Progress"||a==null||(G(!0),n(ka(a,i,!1)))}),[U,f,a,n]),r.useEffect((()=>{if(f.fetchState==="Completed"&&(N===!1||N&&j?.status?.code!=="active"||j?.cardHolderUserId!==t.userId||m===!1&&A===!1||j?.type.code==="business_physical_debit_card"||j?.type.code==="business_virtual_debit_card")){const X=_e(s.tenantEmailDomain,a,t,j,m);e(X)}}),[f.fetchState,m,N]),r.useEffect((()=>{E.fetchState!=="Completed"&&E.fetchState!=="In-Progress"&&k&&p&&b&&n(qe()),y.fetchState!=="Completed"&&y.fetchState!=="In-Progress"&&k&&p&&b&&n(Tt()),R!=="Completed"&&R!=="In-Progress"&&n(Vn())}),[E.fetchState,y.fetchState,n,k,p,b,R]);const Q=()=>{if(t!=null&&a!=null){n(za());const X=_e(s.tenantEmailDomain,a,t);e(X)}},c=j?.type.code==="business_physical_debit_card"||j?.type.code==="business_virtual_debit_card",O=Xe(k,L,_,p),q=La(k,p,b,E,y),se=Dr(c,f);return f.fetchState!=="Completed"?o.jsx(va,{fetchState:"In-Progress"}):o.jsxs(o.Fragment,{children:[o.jsx(nt,{showConfetti:m}),o.jsx(rc,{onGotItClick:Q,isDebitCard:j?.type.code==="business_physical_debit_card",controllerEmails:M,isChargeCardFeatureEnabled:k,isDebitCardFeatureEnabled:L,isDebitCardSetupEnabled:_,isChargeCardSetupEnabled:p,productInformation:O,creditAccountInformation:q,debitAccountInformation:se,chargeCardDetailView:f,creditAccount:E,classListFetchState:R,creditAccountRepayment:y,cardIssuedByRoles:z?.userRoles,cardIssuedByDepartmentName:v?.className,cardHolderRoles:K?.userRoles,cardHolderDepartmentName:I?.className})]})}const Br="charge-card-transaction-update",Rr="charge-card-transaction-created",Or="charge-card-transaction-declined",jr="charge-card-transaction-updated",Ur="charge-card-transaction-receipt-uploaded",pa="charge-card-status-update",Ht="charge-card-spending-updated",ct="credit-account-balance-updated",it="charge-card-created",$t="charge-card-limit-updated",Gt="charge-card-limit-reset",Kt="charge-card-renamed",Wc="charge-card-department-updated",Mr="charge-card-repayment-completed",Nr="charge-card-payment-date-updated",Ba="charge-card-cashback-redeemed",Ra="charge-card-cashback-earned",ha=(e,a)=>e==null||e===""?[]:a.map((n=>`private-encrypted-${e}.${n}`)),qc=[Ra,Ba],Jc=Pe((function(e){const a=ma(e);return{insightsData:a.insight,cashbackByPeriod:a.cashbackByPeriod,uiState:a.uiState,cashbackSummary:a.cashbackSummary}}),(function(e){return{onColumnSortConfigChanged:(a,n)=>{e(Fs({uiState:{sortKey:a,sortOrder:n}}))}}}))(oc);function Qc(){const e=de(),a=me(),n=he(),t=te.getSignedInUser(),s=d((T=>fe(T))),{useFeatureGate:g}=le(),{isFeatureEnabled:b}=g(Z.isCardsCommentingEnabled),[h,A]=r.useState(!1),u=d((T=>ma(T))),m=vr(s.companyId,{clearParams:u.fetchState==="Completed"}),F=r.useCallback((()=>{const T=we(n.state?.pathnameStackToGoBack),B=T.poppedPathname??Xc(s.tenantEmailDomain);e(B,{state:{pathnameStackToGoBack:T.newStack}})}),[e,n,s.tenantEmailDomain]),w=aa(s);if(Vt({events:ha(w,qc),onEvent:T=>{switch(T){case Ra:case Ba:return void a(_a(!0))}},onSubscribed:()=>{a(_a(!0))}}),r.useEffect((()=>{h||u.fetchState==="Completed"||u.fetchState==="In-Progress"||(A(!0),a(_a()))}),[h,u,a]),t==null)throw Error("Can't access cashback detail page without signing in...");const p=u.cashbackSummary?.cashbackEarned?.amount!=null&&u.fetchState!=="Not-Started";return u.fetchState!=="In-Progress"||p?(u.cashbackSummary?.cashbackEarned?.amount??0)===0&&u.fetchState==="Completed"?o.jsx(ot,{}):o.jsx(Jc,{onBackClick:F,isCardsCommentingEnabled:b,initialOpenThreadRequest:m}):o.jsx(sc,{onBackClick:F})}const Xc=e=>`/${e}/cards`,ei={containerWidth:new Fa(100,58)},ai=({appContent:e})=>{const a=Ta(),n=me(),t=de(),{cardId:s}=Ne(),g=he(),{useDynamicConfig:b}=le(),[h,A]=r.useState(!1),[u,m]=r.useState(!1),[F,w]=r.useState(!1),[p,T]=r.useState(!1),B=te.getSignedInUser();if(B==null)throw Error("Can't access onboarding card page without signing in...");const S=d((I=>fe(I)));if(s==null)throw Error("Empty card id is not valid...");const{configValue:l}=b(Qe.zeniCardsConfig),C=l.max_charge_card_activation_attempts_by_card_id,L=d((I=>xs(I,s))),k=L.chargeCard,_=d((I=>I.chargeCardConfigState.fetchState)),{useFeatureGate:D}=le(),{isFeatureEnabled:M}=D(Z.isChargeCardFeatureEnabled),{isFeatureEnabled:E}=D(Z.isDebitCardFeatureEnabled),y=Le(E,S),R=Re({isDebitCardFeatureEnabled:E,isBankingOnlyTenant:y}),i=!!S.companyChargeCardInfo?.info?.isChargeCardEnabled,f=S.userRole.includes("charge_card_user"),U=Fe(S),G=xe(S),j=S.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,x=Oe({isCardsOnlyTenant:U,isChargeCardFeatureEnabled:M,isBookKeepingTenant:G,isDebitCardProductVisible:R,chargeCardsCreditAccountLimit:j}),z=!f&&x&&i;r.useEffect((()=>{h===!1&&_!=="In-Progress"&&_!=="Completed"&&(n(Ja()),A(!0)),u===!1&&L.fetchState==="Not-Started"&&(m(!0),n(ka(s,z,x)))}),[u,L.fetchState,h,_]);const H=k?.type.code==="business_physical_credit_card"||k?.type.code==="business_physical_debit_card";r.useEffect((()=>{if(L.fetchState==="Completed"){if(F===!1&&(H===!1||H&&k?.status?.code!=="inactive"||k?.cardHolderUserId!==B.userId)){const I=_e(S.tenantEmailDomain,s,B,k,!0),N=ke(g.state?.pathnameStackToGoBack,g.pathname);t(I,{state:{pathnameStackToGoBack:N}})}else if(F&&L.isRefreshingViewInBackground===!1&&k?.status?.code==="active"){n(Ls({chargeCardId:s}));const I=_e(S.tenantEmailDomain,s,B,k,!0),N=ke(g.state?.pathnameStackToGoBack,g.pathname);n(Qa()),t(I,{state:{pathnameStackToGoBack:N}})}}}),[L.fetchState,k?.type.code,F,L.isRefreshingViewInBackground]);const v=te.getZeniOtpTokenForCardHolder(s),P=d((I=>Hn(I.userState,B.userId))),K=()=>{k?.status?.code!=="active"&&n(ba(s,!0))};r.useEffect((()=>{L.updatePhysicalChargeCardAttemptFetchState.fetchState==="Completed"&&k?.cardActivationAttemptHistory.some((I=>I.statusCode==="success"))===!0&&F===!1&&(setTimeout(K,3e3),w(!0))}),[L.updatePhysicalChargeCardAttemptFetchState.fetchState,k?.cardActivationAttemptHistory]);const W=I=>{T(I)};if(_!=="Completed"||k==null)return o.jsx(va,{fetchState:"In-Progress"});if(k.shippingAddressId==null)throw Error("Can't access shippingAddressId.");if(P?.phone==null)throw Error("Can't access user phone number.");return o.jsxs(ri,{children:[o.jsx(Ee,{isAppContentDrawerOpen:p,handleDrawerToggle:W}),o.jsx(ti,{cardId:s,card:k,shippingAddressId:k.shippingAddressId,phone:P.phone,signedInUser:B,isSandboxEnv:Rt(),chargeCardDetailState:L,signedInUserToken:v,navigate:t,currentTenant:S,location:g,maxChargeCardActivationAttempts:C[s]!=null?C[s]:l.default_max_charge_card_activation_attempts!=null?l.default_max_charge_card_activation_attempts:3,chargeCardCashbackRatePerTransaction:l.charge_card_cashback_rate_per_transaction!=null?l.charge_card_cashback_rate_per_transaction:.0175,onClickMenuIcon:()=>{W(!0)}}),e!=null?o.jsx(ni,{windowSize:a,children:e}):null]})},ti=Pe((function(e,{chargeCardDetailState:a,shippingAddressId:n,location:t,cardId:s}){const g=Bs(e.addressState,n);if(g==null)throw Error("Can't access shippingAddress.");const b=$n(e,s),h=a.updateStatus,A=Ca(e,!1,!1,!1);let u=!1;A.fetchState==="Completed"&&A.cards.length<=1&&(u=!0);const m=t.state?.message==="comingFromV2UrlPath";return{showActivatePage:a.chargeCard?.providerCardCreateTime!=null&&a.chargeCard.providerCardCreateTime.add(24,"h").isBefore(Rs())||m,showMenuIcon:u,shippingAddress:g,vgsVaultId:rt.cardVaultId,twoFAView:b,activationWaitStatus:h,isRefreshingViewInBackground:a.isRefreshingViewInBackground}}),(function(e,a){const{navigate:n,cardId:t,location:s,currentTenant:g,chargeCardDetailState:b}=a,h=b.chargeCard?.cardProviderID,{tenantEmailDomain:A}=g;return{onGetOtp:u=>{h!=null&&e(at(u,"ChargeCardHolder",t))},onUpdatePhysicalChargeCardAttempt:u=>{e(js(t,u))},onResendOtp:u=>{h!=null&&e(et(u,"ChargeCardHolder",t))},onVerifyOtp:(u,m)=>{h!=null&&e(Xa(u,m,"ChargeCardHolder",t))},onVerifyOtpSuccess:u=>{u!=null&&te.saveZeniOtpTokenForCardHolder(u,t)},onCVVActivateSuccess:()=>{e(Os({chargeCardId:t}))},onBackClick:()=>{const u=we(s.state?.pathnameStackToGoBack),m=u.poppedPathname==null||u.poppedPathname.includes("onboard")===!0?ta(A):u.poppedPathname;n(m,{state:{pathnameStackToGoBack:u.newStack}})}}}))(cc),ni=Ve.div`
1
+ import{j as o}from"./liveblocks-BPL36a6x.js";import{u as me,j as d,h as de,g as he,i as Ne,N as Je,s as _t,l as Pe,t as _n,n as cs,o as ne}from"./core-DOBELRta.js";import{fS as Pt,$L as is,g2 as wt,bt as Te,$M as ds,$N as ls,fH as fn,$O as Pn,fQ as wn,$P as vn,$Q as Tn,$R as Fn,$S as xn,fR as Ln,g1 as Bn,$T as Rn,$U as us,fX as ms,fW as Cs,$V as ps,JZ as On,g4 as ia,$W as hs,$X as fs,fJ as gs,fI as bs,gh as ze,fZ as jn,fY as Un,$Y as Ss,f_ as ys,Jv as Is,Ju as ks,Jy as Es,JA as As,ga as Ds,fE as Mn,$Z as _s,$_ as Ps,gf as Nn,$$ as ws,gg as yt,JG as vs,JD as Ts,fF as fe,a00 as qa,dZ as Fe,di as xe,d_ as Le,g_ as da,cB as la,a01 as ua,a02 as vt,CV as Ga,m7 as Ka,a03 as za,Kd as ka,g5 as qe,Kf as Tt,lZ as Vn,a04 as ma,K1 as _a,a05 as Fs,a06 as xs,K4 as Ja,a07 as Ls,YY as Qa,g0 as Hn,Ka as ba,iq as Bs,a08 as $n,fT as Ca,br as Rs,a09 as Os,gG as Xa,gF as et,KJ as js,gE as at,a0a as Gn,cu as Kn,da as Us,YX as wa,Li as zn,a0b as gn,KU as Pa,a0c as Yn,Lj as Ms,Zl as Ns,Lk as Vs,Mp as Hs,C9 as $s,Mj as Gs,a0d as Ks,Ke as oa,a0e as zs,a0f as Ys,a0g as Zs,a0h as Ws,a0i as qs,a0j as Ft,a0k as Js,Ku as Zn,Kn as Qs,a0l as Xs,h0 as eo,a0m as Wn,KD as qn,KH as Jn,g$ as ao,a0n as to,L4 as Qn,a0o as no,a0p as ro,a0q as so,KF as Xn,Kq as er,K7 as ar,Kz as tr,Kx as nr,KB as oo,a0r as rr,a0s as co,gc as io,gd as lo,ge as uo,a0t as tt,g6 as sr,dc as xt,a0u as mo,a0v as Co,a0w as po,a0x as ho,KP as It,Lb as fo,L7 as go,KL as bo,L9 as So,K$ as yo,L1 as Io,a0y as or,Lh as $a,S8 as ko,a0z as Eo,a0A as Ao,a0B as Do,a0C as cr,a0D as _o,LE as Po,KT as ir,KO as Me,KS as wo,a0E as vo,a0F as To,J_ as Fo,a0G as dr,f$ as lr,a0H as xo,K0 as Lo,J$ as bn,a0I as Bo,a0J as Ro,a0K as Oo,Vg as jo,a0L as Lt,a0M as Uo,xf as ur,mH as Mo,ie as No,LJ as Vo,a0N as mr,fN as Ho,fO as $o,a0O as Go,dO as Ko,g3 as zo,Lz as Yo,Lt as We,bq as Zo,bJ as Wo,cG as qo,bK as Jo,U7 as Qo}from"./zeni-epic-state-DXFYDM66.js";import{N as Be,de as Cr,a5 as we,df as pr,dg as hr,dh as Xo,G as ea,at as Bt,di as ec,dj as ac,a as fr,e as gr,as as br,p as ke,c as le,A as Z,j as ya,dk as Sr,dl as tc,dm as nc,z as te,a8 as va,d3 as nt,dn as rc,dp as sc,dq as oc,a2 as Ta,bj as Qe,bF as Rt,dr as cc,ac as Fa,Z as rt,E as Ot,k as ae,w as st,ds as ic,bR as Sa,dt as kt,du as dc,a9 as jt,dv as lc,af as yr,aw as Et,dw as uc,ar as Ir,M as kr,V as Er,dx as mc,dy as Cc,dz as pc,dA as hc,dB as fc,dC as gc,dD as bc,I as Ya,dE as Sc,dF as yc,m as ht,R as Ic,dG as kc,dH as Ec,dI as Ac,aj as Dc,dJ as _c,dK as Pc,h as wc}from"./index-D0or4oV9.js";import{n as Ve,D as Ar,S as vc}from"./mui-wO6EIETx.js";import{a as r}from"./sentry-_x3Yh1Jc.js";import{u as xa}from"./useAskAiCfoHostNavButtonProps-eAE85_k_.js";import{M as Ee}from"./MobileAppDrawer-C-ti4sM2.js";import{d as Ut}from"./recharts-Sp9X2zHo.js";import{g as _e,a as La,b as Dr,c as Re,d as Oe,e as Xe,f as aa,h as ta,A as Tc,i as Mt,P as Fc,j as Nt,s as Ia,k as _r,l as ca,m as Pr,n as xc,o as wr,p as Lc,S as Sn}from"./SetupPagesScreen-CgVfrQ5w.js";import{u as vr}from"./useInitialThreadRequest-DYGeNL0J.js";import ot from"./NotFoundScreen-3qucmnjW.js";import{u as Vt}from"./useChargeCardPusherEvents-CLlJNBdI.js";import{n as yn}from"./utils-BU0XThgM.js";import{t as Bc}from"./AddressScreen-C5gOC9K1.js";import"./analytics-GZ8dIY_c.js";import"./plaid-C-eBmVPr.js";import"./dnd-0MaFz9wL.js";import"./stripe-cKAAJElX.js";import"./lottie-38LSfraF.js";import"./lexical-CAgOy6Q-.js";import"./pdf-B2N0erO1.js";import"./InboxNotificationsProvider-Bd8tLMl8.js";import"./useTaskManagerAccess-CxAfFVI5.js";import"./BusinessVerificationPageScreen-_lNpLbtb.js";import"./routePaths-DTZH71MW.js";import"./analyticsHelper-DnGDW6mo.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]="92cb6d11-adc1-465e-9aa9-7e94d35ef076",e._sentryDebugIdIdentifier="sentry-dbid-92cb6d11-adc1-465e-9aa9-7e94d35ef076")}catch{}})();const Rc=e=>{const a=e.cardHolderUser,n=`${a.firstName??""} ${a.lastName??""}`.trim()||a.email||a.userId;return{userId:a.userId,displayName:n,roleLabel:e.cardHolderRoles?.titleAtCompany}},Tr=e=>({id:e.id,isChecked:!1,cardName:e.cardName,last4:e.accountLast4,limitAmount:e.limit?.amount??0,limitCadence:e.creditLimitFrequency?.code,owner:Rc(e),utilizationAmount:(e.limit?.amount??0)-(e.available?.amount??0)});function Fr(){const e=me(),a=d((t=>Pt(t.cardPolicyState))),n=d((t=>is(t.cardPolicyState)));r.useEffect((()=>{n!==""||a==="Completed"&&n===""||a==="In-Progress"||e(wt())}),[e,a,n])}const{spendManagement:{chargeCard:{cardPolicyPage:In}}}=ea.getLocalizedStrings(),Oc=e=>jn(e,!1),jc=e=>Un(e.name,!1);function Uc(){const e=de(),a=he(),{tenantEmailDomain:n}=Ne(),t=me(),s=Be(),g=Te(s?.loggedInUserRoleMap),[b,h]=r.useState(!1),A=r.useCallback((O=>{h(O)}),[]),u=r.useCallback((()=>{A(!0)}),[A]),{isAiCfoAccessEnabled:m,onAskAiCfoClick:F}=xa({mobileExploreReferrer:"Card Policy"});r.useEffect((()=>()=>{t(ds()),t(ls()),t(fn())}),[t]);const w=d((O=>Pn(O.cardPolicyState))),p=d((O=>wn(O.cardPolicyState))),T=d((O=>vn(O.cardPolicyState))),B=d((O=>Tn(O.cardPolicyState))),S=d((O=>Fn(O.cardPolicyState))),l=d((O=>xn(O.cardPolicyState))),C=d((O=>Ln(O.cardPolicyState))),L=d((O=>Pt(O.cardPolicyState))),k=d((O=>O.chargeCardConfigState.receiptRequiredAboveAmount.amount)),_=d((O=>O.chargeCardConfigState.fetchState));r.useEffect((()=>{w!=="Completed"&&w!=="In-Progress"&&t(Bn())}),[t,w]),Fr();const D=d((O=>Rn(O.createCardPolicyState))),M=d((O=>us(O.createCardPolicyState))),E=d((O=>ms(O.cardPolicyState))),y=d((O=>Cs(O.cardPolicyState))),R=d((O=>ps(O.createCardPolicyState))),i=d((O=>On(O)));r.useEffect((()=>{i.fetchState==="Not-Started"&&t(ia(!1,!1,!1))}),[i.fetchState,t]);const f=r.useMemo((()=>p.map(Oc)),[p]),U=r.useMemo((()=>C.map(jc)),[C]),G=r.useMemo((()=>i.cards.filter((O=>!Cr(O.status.code))).map(Tr)),[i.cards]),j=w==="Completed"&&i.fetchState==="Completed"&&_==="Completed";r.useEffect((()=>{j&&R==null&&t(hs({cardsMasterList:G,defaultRequireReceiptAmount:k,suggestedAllowMerchants:T,suggestedBlockMerchants:B,suggestedAllowCategories:S,suggestedBlockCategories:l}))}),[_,t,j,R,G,k,T,B,S,l]);const x=r.useMemo((()=>Ut((O=>{t(wt(O))}),250)),[t]);r.useEffect((()=>()=>{x.cancel()}),[x]);const z=r.useCallback((O=>{x(O)}),[x]),H=D.fetchState,v=n!=null?`/${n}/cards/policy`:"..",P=r.useCallback((()=>{const O=we(a.state?.pathnameStackToGoBack),q=O.poppedPathname??v;e(q,{state:{pathnameStackToGoBack:O.newStack}})}),[a.state,e,v]),K=r.useCallback((()=>{e(v)}),[e,v]),W=r.useCallback((O=>{t(fs(O))}),[t]),I=r.useCallback((O=>{const q=pr(O);t(gs({templates:[q]}))}),[t]),N=r.useCallback((O=>{O.length!==0&&t(bs(O))}),[t]),V=r.useCallback((()=>{t(fn())}),[t]),Q=r.useRef(H);r.useEffect((()=>{const O=Q.current;Q.current=H,H==="Completed"&&O!=="Completed"&&M!=null&&(t(ze({messageSection:"card_policy_created",messageText:"success",type:"success"})),e(v))}),[t,H,M,e,v]);const c=H==="Error"?D.error?.message??In.createPolicyGenericErrorMessage:void 0;return g&&n!=null?R==null?o.jsxs(o.Fragment,{children:[o.jsx(Ee,{isAppContentDrawerOpen:b,handleDrawerToggle:A}),o.jsx(hr,{showUploadDocumentSection:!0,navBarTitle:In.createPageTitle,onBackClick:P,onClickMenuIcon:u,isAiCfoAccessEnabled:m,onAskAiCfoClick:F})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ee,{isAppContentDrawerOpen:b,handleDrawerToggle:A}),o.jsx(Xo,{formDraft:R,vendorSearchOptions:U,categorySearchOptions:f,isVendorSearchLoading:L==="In-Progress",onVendorSearchTextChange:z,submitState:H,submitErrorMessage:c,documentUploadState:E,uploadedFileName:y,isAiCfoAccessEnabled:m,onAskAiCfoClick:F,onBackClick:P,onCancelClick:K,onClickMenuIcon:u,onFormChange:W,onSubmit:I,onUploadDocument:N,onRemoveDocument:V})]}):o.jsx(Je,{to:"..",replace:!0})}const{spendManagement:{chargeCard:{cardPolicyPage:Mc}}}=ea.getLocalizedStrings(),Nc=e=>jn(e,!1),Vc=e=>Un(e.name,!1);function Hc(){const e=de(),a=he(),{tenantEmailDomain:n,templateId:t}=Ne(),s=me(),g=Be(),b=Te(g?.loggedInUserRoleMap),[h,A]=r.useState(!1),u=r.useCallback((c=>{A(c)}),[]),m=r.useCallback((()=>{u(!0)}),[u]),{isAiCfoAccessEnabled:F,onAskAiCfoClick:w}=xa({mobileExploreReferrer:"Card Policy"}),p=d((c=>Ss(c))),T=d((c=>Pn(c.cardPolicyState))),B=d((c=>wn(c.cardPolicyState))),S=d((c=>vn(c.cardPolicyState))),l=d((c=>Tn(c.cardPolicyState))),C=d((c=>Fn(c.cardPolicyState))),L=d((c=>xn(c.cardPolicyState))),k=d((c=>Ln(c.cardPolicyState))),_=d((c=>Pt(c.cardPolicyState))),D=d((c=>On(c))),M=d((c=>t!=null?ys(c.cardPolicyState,t):void 0)),E=r.useMemo((()=>p.templateId===t&&p.formDraft!=null?p.formDraft:M!=null?Is(M):void 0),[p.templateId,p.formDraft,M,t]);r.useEffect((()=>{if(t==null)return;const c=p.detailFetchState.fetchState;p.templateId===t&&(c==="Completed"||c==="In-Progress")||M!=null||s(ks(t))}),[s,t,p.templateId,p.detailFetchState.fetchState,M]),r.useEffect((()=>{T!=="Completed"&&T!=="In-Progress"&&s(Bn())}),[s,T]),Fr();const y=d((c=>c.chargeCardConfigState.receiptRequiredAboveAmount.amount));r.useEffect((()=>{D.fetchState==="Not-Started"&&s(ia(!1,!1,!1))}),[D.fetchState,s]);const R=r.useMemo((()=>B.map(Nc)),[B]),i=r.useMemo((()=>k.map(Vc)),[k]),f=r.useMemo((()=>D.cards.filter((c=>!Cr(c.status.code))).map(Tr)),[D.cards]);Bt({isDataReady:E!=null});const U=r.useMemo((()=>{if(E!=null)return ec({draft:E,cardRows:f,categorySearchOptions:R,vendorSearchOptions:i,defaultRequireReceiptAmount:y,suggestedAllowMerchants:S,suggestedBlockMerchants:l,suggestedAllowCategories:C,suggestedBlockCategories:L})}),[E,f,R,i,y,S,l,C,L]),[G,j]=r.useState(void 0),x=r.useRef(!1);r.useEffect((()=>{x.current||G!=null||U==null||(x.current=!0,j(U))}),[G,U]);const z=r.useCallback((c=>{j(c)}),[]),H=r.useMemo((()=>Ut((c=>{s(wt(c))}),250)),[s]);r.useEffect((()=>()=>{H.cancel()}),[H]);const v=r.useCallback((c=>{H(c)}),[H]),P=p.updateFetchState.fetchState,K=n!=null?`/${n}/cards/policy`:"..",W=r.useCallback((()=>{const c=we(a.state?.pathnameStackToGoBack),O=c.poppedPathname??K;e(O,{state:{pathnameStackToGoBack:c.newStack}})}),[a.state,e,K]),I=r.useCallback((()=>{e(K)}),[e,K]),N=r.useCallback((c=>{if(t==null)return;const O=pr(c);s(Es(O)),s(As(t))}),[s,t]),V=r.useRef(P);r.useEffect((()=>{const c=V.current;V.current=P,P==="Completed"&&c!=="Completed"&&(s(ze({messageSection:"card_policy_updated",messageText:"success",type:"success"})),e(K))}),[s,P,e,K]);const Q=P==="Error"?p.updateFetchState.error?.message??Mc.updatePolicyGenericErrorMessage:void 0;return!b||n==null||t==null?o.jsx(Je,{to:"..",replace:!0}):G!=null&&T==="Completed"&&D.fetchState==="Completed"?o.jsxs(o.Fragment,{children:[o.jsx(Ee,{isAppContentDrawerOpen:h,handleDrawerToggle:u}),o.jsx(ac,{templateName:p.template?.name??"",formDraft:G,vendorSearchOptions:i,categorySearchOptions:R,isVendorSearchLoading:_==="In-Progress",onVendorSearchTextChange:v,submitState:P,submitErrorMessage:Q,isAiCfoAccessEnabled:F,onAskAiCfoClick:w,onBackClick:W,onCancelClick:I,onClickMenuIcon:m,onFormChange:z,onSubmit:N})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ee,{isAppContentDrawerOpen:h,handleDrawerToggle:u}),o.jsx(hr,{showUploadDocumentSection:!1,navBarTitle:p.template?.name,onBackClick:W,onClickMenuIcon:m,isAiCfoAccessEnabled:F,onAskAiCfoClick:w})]})}function xr(e,a,n){return a?e.filter((t=>t!=null&&t.trim().length>0)).slice(0,n):[]}function Lr(e){return d((a=>e==null||e===""?{chips:ft,isResolved:!1}:(function(n){const t=n?.fetchState,s=t==="Completed"||t==="Error";return{chips:t==="Completed"?n?.suggestedQuestions??ft:ft,isResolved:s}})(Ds(a,e))),_t)}const ft=[],{spendManagement:{chargeCard:{cardPolicyAiCfoHero:{headline:$c,subheadline:Gc,pageTitle:Kc}}}}=ea.getLocalizedStrings(),zc=e=>{const a=e.cardsCount>0?e.cardsCount:e.appliedCards.length,n=e.allowedEntity.merchantNames.length+e.blockedEntity.merchantNames.length,t=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:a,vendorRestrictionsCount:n,categoryRestrictionsCount:t}};function Yc(){const e=de(),a=he(),{tenantEmailDomain:n}=Ne(),t=me(),s=Be(),g=Te(s?.loggedInUserRoleMap),[b,h]=r.useState(!1),A=r.useCallback((v=>{h(v)}),[]),u=r.useCallback((()=>{A(!0)}),[A]),{useFeatureGate:m}=le(),{isFeatureEnabled:F}=m(Z.isAiCfoFileUploadEnabled),{isFeatureEnabled:w}=m(Z.isCardPolicyEnabled),{isAiCfoAccessEnabled:p,onAskAiCfoClick:T}=xa({mobileExploreReferrer:"Card Policy"}),B=d((v=>_s(v))),S=d((v=>Rn(v.createCardPolicyState))),l=d((v=>Ps(v.createCardPolicyState))),C=d((v=>l==null?[]:Nn(v.aiCfoState,l).filter((P=>P.kind==="creating_policy"))),_t),L=S.fetchState==="In-Progress"?Math.max(C.length,1):0,k=d((v=>ws(v.createCardPolicyState))),_=ya(S.fetchState);r.useEffect((()=>{if(_==="In-Progress"&&S.fetchState==="Completed"&&l!=null)C.forEach((v=>{t(yt({chatSessionId:l,id:v.id,entityIds:k,kind:"created_policy"}))}));else if(_==="In-Progress"&&S.fetchState==="Error"&&l!=null){C.forEach((P=>{t(yt({chatSessionId:l,id:P.id,kind:"errored_policy"}))}));const v=S.error?.message!=null&&S.error.message.length>0?S.error.message:ea.getLocalizedStrings().common.errorMessage.somethingWentWrongPleaseTryAgain;t(ze({messageSection:"card_policy_created",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:v}]}))}}),[S.error?.message,S.fetchState,t,l,k,C,_]);const D=B.fetchState.fetchState;r.useEffect((()=>{D!=="Not-Started"&&D!=="Error"||t(vs())}),[t,D]);const M=B.archiveFetchState.fetchState,E=ya(M);r.useEffect((()=>{E==="In-Progress"&&M==="Completed"&&t(ze({messageSection:"card_policy_deleted",messageText:"success",type:"success"}))}),[M,t,E]);const y=r.useMemo((()=>B.templates.map(zc)),[B.templates]);Bt({isDataReady:B.fetchState.fetchState==="Completed"});const R=y.length>0||L>0,i=(function(v){const{hasAnyPolicies:P,isChargeCardAdmin:K,isFileUploadEnabled:W}=v,I=de(),N=he(),{tenantEmailDomain:V}=Ne(),{isAiCfoOpen:Q,setIsAiCfoOpen:c}=fr(),O=gr(),q=br(),se=d((J=>Mn(J))).createSessionAndSubmitState.fetchState==="In-Progress",{chips:X,isResolved:He}=Lr("card_policy"),Ae=r.useMemo((()=>xr(X,He,3)),[X,He]),[ge,re]=r.useState(""),be=q&&O&&V!=null&&!Q,ue=r.useCallback((J=>{if(V==null)return;const fa=ke(N.state?.pathnameStackToGoBack,N.pathname);I(`/${V}/cards/ask`,{state:{message:"",origin:"",pathnameStackToGoBack:fa,referrer:"card_policy_hero",aiCfoInitialQuestion:J,aiCfoShouldSubmit:J!=null&&J.trim().length>0}})}),[N.pathname,N.state,I,V]),oe=r.useCallback((J=>{J.trim().length!==0&&(re(""),ue(J))}),[ue]),Se=r.useCallback((()=>{const J=ge.trim();J.length!==0&&(re(""),ue(J))}),[ge,ue]),ee=r.useCallback((()=>{}),[]),De=r.useCallback((J=>{re(J)}),[]),ve=r.useCallback((()=>{c(!0)}),[c]),Ce=r.useCallback((()=>{ue(void 0)}),[ue]);return r.useMemo((()=>{if(be&&!P&&K)return{aiAgentName:Kc,headline:$c,subheadline:Gc,promptChips:Ae,composer:{currentInput:ge,isSubmitting:se,isFileUploadEnabled:W,onInputChange:De,onSubmit:Se,onStopSubmit:ee},onPromptClick:oe,onOpenSidePanel:ve,onOpenFullView:Ce,dataTestIdPrefix:"card-policy-ai-cfo-hero"}}),[ge,P,be,K,W,se,De,Ce,ve,oe,ee,Se,Ae])})({hasAnyPolicies:R,isChargeCardAdmin:g,isFileUploadEnabled:F}),f=w&&i!=null?o.jsx(Sr,{...i}):null,U=p&&f==null,G=r.useCallback((()=>{const v=we(a.state?.pathnameStackToGoBack),P=v.poppedPathname??"..";e(P,{state:{pathnameStackToGoBack:v.newStack}})}),[a.state,e]),j=r.useCallback((()=>{n!=null&&e(`/${n}/cards/policy/new`)}),[e,n]),x=r.useCallback((v=>{n!=null&&e(`/${n}/cards/policy/${v}/edit`)}),[e,n]),z=r.useCallback((v=>{t(Ts(v))}),[t]),H=B.fetchState.fetchState;return!R&&H!=="Completed"&&H!=="Error"?o.jsxs(o.Fragment,{children:[o.jsx(Ee,{isAppContentDrawerOpen:b,handleDrawerToggle:A}),o.jsx(tc,{onBackClick:G,onNewPolicyClick:j,onClickMenuIcon:u,isAiCfoAccessEnabled:p,onAskAiCfoClick:T})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ee,{isAppContentDrawerOpen:b,handleDrawerToggle:A}),o.jsx(nc,{policies:y,archivingTemplateId:B.archiveTargetTemplateId,pendingCreationCount:L,onBackClick:G,onNewPolicyClick:j,onEditPolicyClick:x,onArchivePolicyClick:z,onClickMenuIcon:u,policyAiCfoHero:f,isAiCfoAccessEnabled:U,onAskAiCfoClick:T})]})}function Zc(){const e=de(),{cardId:a}=Ne(),n=me(),t=te.getSignedInUser(),s=d((X=>fe(X))),g=Be(),b=Te(g?.loggedInUserRoleMap),{useFeatureGate:h}=le();if(t==null)throw Error("Can't access Add To Wallet Page without signing in...");const[A,u]=r.useState(!1),m=d((X=>qa(X).firstViewAfterActivation));if(a==null)throw Error("Empty card id is not valid...");const F=s.userRole.includes("charge_card_user"),{isFeatureEnabled:w}=h(Z.isChargeCardFeatureEnabled),p=!!s.companyChargeCardInfo?.info?.isChargeCardEnabled,{isFeatureEnabled:T}=h(Z.isDebitCardFeatureEnabled),B=Fe(s),S=xe(s),l=Le(T,s),C=s.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,L=Re({isDebitCardFeatureEnabled:T,isBankingOnlyTenant:l}),k=Oe({isCardsOnlyTenant:B,isChargeCardFeatureEnabled:w,isBookKeepingTenant:S,isDebitCardProductVisible:L,chargeCardsCreditAccountLimit:C}),_=!!s.companyDebitCardInfo?.info?.isDebitCardEnabled,D=d((X=>da(X,s.companyId))),M=la(D.controllers),{creditAccount:E,creditAccountRepayment:y}=d((X=>ua(X))),R=d((X=>X.classListState.fetchState)),i=!F&&k&&p,f=d((X=>vt(X,a,i,k))),[U,G]=r.useState(!1),j=f.chargeCard,x=j?.cardCreatedByUser?.userId,z=d((X=>x!=null?Ga(X.userRoleState,x):void 0)),H=z?.accountingClassIDs[0],v=d((X=>H!=null?Ka(X.classState,{classId:H,reportId:"class_list"}):void 0)),P=j?.cardHolderUser?.userId,K=d((X=>P!=null?Ga(X.userRoleState,P):void 0)),W=K?.accountingClassIDs[0],I=d((X=>W!=null?Ka(X.classState,{classId:W,reportId:"class_list"}):void 0)),N=j?.type.code==="business_physical_credit_card"||j?.type.code==="business_physical_debit_card",V=j?.type.code==="business_physical_debit_card";r.useEffect((()=>{m&&A===!1&&N&&(u(!0),setTimeout((()=>{n(za()),V&&n(ze({messageSection:"set_debit_card_pin",messageText:"success",type:"success",showStatusIcon:!0}))}),5e3))}),[m,A,N,V]),r.useEffect((()=>{U||f.fetchState==="Completed"||f.fetchState==="In-Progress"||a==null||(G(!0),n(ka(a,i,!1)))}),[U,f,a,n]),r.useEffect((()=>{if(f.fetchState==="Completed"&&(N===!1||N&&j?.status?.code!=="active"||j?.cardHolderUserId!==t.userId||m===!1&&A===!1||j?.type.code==="business_physical_debit_card"||j?.type.code==="business_virtual_debit_card")){const X=_e(s.tenantEmailDomain,a,t,j,m);e(X)}}),[f.fetchState,m,N]),r.useEffect((()=>{E.fetchState!=="Completed"&&E.fetchState!=="In-Progress"&&k&&p&&b&&n(qe()),y.fetchState!=="Completed"&&y.fetchState!=="In-Progress"&&k&&p&&b&&n(Tt()),R!=="Completed"&&R!=="In-Progress"&&n(Vn())}),[E.fetchState,y.fetchState,n,k,p,b,R]);const Q=()=>{if(t!=null&&a!=null){n(za());const X=_e(s.tenantEmailDomain,a,t);e(X)}},c=j?.type.code==="business_physical_debit_card"||j?.type.code==="business_virtual_debit_card",O=Xe(k,L,_,p),q=La(k,p,b,E,y),se=Dr(c,f);return f.fetchState!=="Completed"?o.jsx(va,{fetchState:"In-Progress"}):o.jsxs(o.Fragment,{children:[o.jsx(nt,{showConfetti:m}),o.jsx(rc,{onGotItClick:Q,isDebitCard:j?.type.code==="business_physical_debit_card",controllerEmails:M,isChargeCardFeatureEnabled:k,isDebitCardFeatureEnabled:L,isDebitCardSetupEnabled:_,isChargeCardSetupEnabled:p,productInformation:O,creditAccountInformation:q,debitAccountInformation:se,chargeCardDetailView:f,creditAccount:E,classListFetchState:R,creditAccountRepayment:y,cardIssuedByRoles:z?.userRoles,cardIssuedByDepartmentName:v?.className,cardHolderRoles:K?.userRoles,cardHolderDepartmentName:I?.className})]})}const Br="charge-card-transaction-update",Rr="charge-card-transaction-created",Or="charge-card-transaction-declined",jr="charge-card-transaction-updated",Ur="charge-card-transaction-receipt-uploaded",pa="charge-card-status-update",Ht="charge-card-spending-updated",ct="credit-account-balance-updated",it="charge-card-created",$t="charge-card-limit-updated",Gt="charge-card-limit-reset",Kt="charge-card-renamed",Wc="charge-card-department-updated",Mr="charge-card-repayment-completed",Nr="charge-card-payment-date-updated",Ba="charge-card-cashback-redeemed",Ra="charge-card-cashback-earned",ha=(e,a)=>e==null||e===""?[]:a.map((n=>`private-encrypted-${e}.${n}`)),qc=[Ra,Ba],Jc=Pe((function(e){const a=ma(e);return{insightsData:a.insight,cashbackByPeriod:a.cashbackByPeriod,uiState:a.uiState,cashbackSummary:a.cashbackSummary}}),(function(e){return{onColumnSortConfigChanged:(a,n)=>{e(Fs({uiState:{sortKey:a,sortOrder:n}}))}}}))(oc);function Qc(){const e=de(),a=me(),n=he(),t=te.getSignedInUser(),s=d((T=>fe(T))),{useFeatureGate:g}=le(),{isFeatureEnabled:b}=g(Z.isCardsCommentingEnabled),[h,A]=r.useState(!1),u=d((T=>ma(T))),m=vr(s.companyId,{clearParams:u.fetchState==="Completed"}),F=r.useCallback((()=>{const T=we(n.state?.pathnameStackToGoBack),B=T.poppedPathname??Xc(s.tenantEmailDomain);e(B,{state:{pathnameStackToGoBack:T.newStack}})}),[e,n,s.tenantEmailDomain]),w=aa(s);if(Vt({events:ha(w,qc),onEvent:T=>{switch(T){case Ra:case Ba:return void a(_a(!0))}},onSubscribed:()=>{a(_a(!0))}}),r.useEffect((()=>{h||u.fetchState==="Completed"||u.fetchState==="In-Progress"||(A(!0),a(_a()))}),[h,u,a]),t==null)throw Error("Can't access cashback detail page without signing in...");const p=u.cashbackSummary?.cashbackEarned?.amount!=null&&u.fetchState!=="Not-Started";return u.fetchState!=="In-Progress"||p?(u.cashbackSummary?.cashbackEarned?.amount??0)===0&&u.fetchState==="Completed"?o.jsx(ot,{}):o.jsx(Jc,{onBackClick:F,isCardsCommentingEnabled:b,initialOpenThreadRequest:m}):o.jsx(sc,{onBackClick:F})}const Xc=e=>`/${e}/cards`,ei={containerWidth:new Fa(100,58)},ai=({appContent:e})=>{const a=Ta(),n=me(),t=de(),{cardId:s}=Ne(),g=he(),{useDynamicConfig:b}=le(),[h,A]=r.useState(!1),[u,m]=r.useState(!1),[F,w]=r.useState(!1),[p,T]=r.useState(!1),B=te.getSignedInUser();if(B==null)throw Error("Can't access onboarding card page without signing in...");const S=d((I=>fe(I)));if(s==null)throw Error("Empty card id is not valid...");const{configValue:l}=b(Qe.zeniCardsConfig),C=l.max_charge_card_activation_attempts_by_card_id,L=d((I=>xs(I,s))),k=L.chargeCard,_=d((I=>I.chargeCardConfigState.fetchState)),{useFeatureGate:D}=le(),{isFeatureEnabled:M}=D(Z.isChargeCardFeatureEnabled),{isFeatureEnabled:E}=D(Z.isDebitCardFeatureEnabled),y=Le(E,S),R=Re({isDebitCardFeatureEnabled:E,isBankingOnlyTenant:y}),i=!!S.companyChargeCardInfo?.info?.isChargeCardEnabled,f=S.userRole.includes("charge_card_user"),U=Fe(S),G=xe(S),j=S.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,x=Oe({isCardsOnlyTenant:U,isChargeCardFeatureEnabled:M,isBookKeepingTenant:G,isDebitCardProductVisible:R,chargeCardsCreditAccountLimit:j}),z=!f&&x&&i;r.useEffect((()=>{h===!1&&_!=="In-Progress"&&_!=="Completed"&&(n(Ja()),A(!0)),u===!1&&L.fetchState==="Not-Started"&&(m(!0),n(ka(s,z,x)))}),[u,L.fetchState,h,_]);const H=k?.type.code==="business_physical_credit_card"||k?.type.code==="business_physical_debit_card";r.useEffect((()=>{if(L.fetchState==="Completed"){if(F===!1&&(H===!1||H&&k?.status?.code!=="inactive"||k?.cardHolderUserId!==B.userId)){const I=_e(S.tenantEmailDomain,s,B,k,!0),N=ke(g.state?.pathnameStackToGoBack,g.pathname);t(I,{state:{pathnameStackToGoBack:N}})}else if(F&&L.isRefreshingViewInBackground===!1&&k?.status?.code==="active"){n(Ls({chargeCardId:s}));const I=_e(S.tenantEmailDomain,s,B,k,!0),N=ke(g.state?.pathnameStackToGoBack,g.pathname);n(Qa()),t(I,{state:{pathnameStackToGoBack:N}})}}}),[L.fetchState,k?.type.code,F,L.isRefreshingViewInBackground]);const v=te.getZeniOtpTokenForCardHolder(s),P=d((I=>Hn(I.userState,B.userId))),K=()=>{k?.status?.code!=="active"&&n(ba(s,!0))};r.useEffect((()=>{L.updatePhysicalChargeCardAttemptFetchState.fetchState==="Completed"&&k?.cardActivationAttemptHistory.some((I=>I.statusCode==="success"))===!0&&F===!1&&(setTimeout(K,3e3),w(!0))}),[L.updatePhysicalChargeCardAttemptFetchState.fetchState,k?.cardActivationAttemptHistory]);const W=I=>{T(I)};if(_!=="Completed"||k==null)return o.jsx(va,{fetchState:"In-Progress"});if(k.shippingAddressId==null)throw Error("Can't access shippingAddressId.");if(P?.phone==null)throw Error("Can't access user phone number.");return o.jsxs(ri,{children:[o.jsx(Ee,{isAppContentDrawerOpen:p,handleDrawerToggle:W}),o.jsx(ti,{cardId:s,card:k,shippingAddressId:k.shippingAddressId,phone:P.phone,signedInUser:B,isSandboxEnv:Rt(),chargeCardDetailState:L,signedInUserToken:v,navigate:t,currentTenant:S,location:g,maxChargeCardActivationAttempts:C[s]!=null?C[s]:l.default_max_charge_card_activation_attempts!=null?l.default_max_charge_card_activation_attempts:3,chargeCardCashbackRatePerTransaction:l.charge_card_cashback_rate_per_transaction!=null?l.charge_card_cashback_rate_per_transaction:.0175,onClickMenuIcon:()=>{W(!0)}}),e!=null?o.jsx(ni,{windowSize:a,children:e}):null]})},ti=Pe((function(e,{chargeCardDetailState:a,shippingAddressId:n,location:t,cardId:s}){const g=Bs(e.addressState,n);if(g==null)throw Error("Can't access shippingAddress.");const b=$n(e,s),h=a.updateStatus,A=Ca(e,!1,!1,!1);let u=!1;A.fetchState==="Completed"&&A.cards.length<=1&&(u=!0);const m=t.state?.message==="comingFromV2UrlPath";return{showActivatePage:a.chargeCard?.providerCardCreateTime!=null&&a.chargeCard.providerCardCreateTime.add(24,"h").isBefore(Rs())||m,showMenuIcon:u,shippingAddress:g,vgsVaultId:rt.cardVaultId,twoFAView:b,activationWaitStatus:h,isRefreshingViewInBackground:a.isRefreshingViewInBackground}}),(function(e,a){const{navigate:n,cardId:t,location:s,currentTenant:g,chargeCardDetailState:b}=a,h=b.chargeCard?.cardProviderID,{tenantEmailDomain:A}=g;return{onGetOtp:u=>{h!=null&&e(at(u,"ChargeCardHolder",t))},onUpdatePhysicalChargeCardAttempt:u=>{e(js(t,u))},onResendOtp:u=>{h!=null&&e(et(u,"ChargeCardHolder",t))},onVerifyOtp:(u,m)=>{h!=null&&e(Xa(u,m,"ChargeCardHolder",t))},onVerifyOtpSuccess:u=>{u!=null&&te.saveZeniOtpTokenForCardHolder(u,t)},onCVVActivateSuccess:()=>{e(Os({chargeCardId:t}))},onBackClick:()=>{const u=we(s.state?.pathnameStackToGoBack),m=u.poppedPathname==null||u.poppedPathname.includes("onboard")===!0?ta(A):u.poppedPathname;n(m,{state:{pathnameStackToGoBack:u.newStack}})}}}))(cc),ni=Ve.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  width: ${e=>`${ei.containerWidth.value(e.windowSize)}%`};