@zeniai/web-app-ui 5.4.22-dev → 5.4.22-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 (74) hide show
  1. package/dist/assets/{AccountMappingScreen-C5mOiJ2U.js → AccountMappingScreen-CqBmv3P0.js} +1 -1
  2. package/dist/assets/{ActualMatchingMatchDetailScreen-wHD8fSWU.js → ActualMatchingMatchDetailScreen-C18ULFui.js} +1 -1
  3. package/dist/assets/{AddressRoutes-CVWN9CJv.js → AddressRoutes-DcrBeuZZ.js} +1 -1
  4. package/dist/assets/{AddressScreen-DgUwrml_.js → AddressScreen-BVizi07H.js} +1 -1
  5. package/dist/assets/{AiCfoScreen-yDQ2sphg.js → AiCfoScreen-DocFe0IU.js} +1 -1
  6. package/dist/assets/{AppDrawer-DzYZBC2G.js → AppDrawer-MZfZEsF3.js} +1 -1
  7. package/dist/assets/{BillPayApprovalRoutes-BcCgse3-.js → BillPayApprovalRoutes-C0prBF5m.js} +1 -1
  8. package/dist/assets/{BillPayRoutes-HAS0-pNc.js → BillPayRoutes-B0bTM1N1.js} +1 -1
  9. package/dist/assets/{BusinessVerificationPageScreen-DM_jBIuD.js → BusinessVerificationPageScreen-CdT5YCya.js} +1 -1
  10. package/dist/assets/{CardsAiCfoScreen-yrI2CL7M.js → CardsAiCfoScreen-mC2dN25g.js} +1 -1
  11. package/dist/assets/{ChargeCardRoutes-DgtmFgR6.js → ChargeCardRoutes-snm4_qnH.js} +1 -1
  12. package/dist/assets/{CompanyPassportScreen-BLtXgkEd.js → CompanyPassportScreen-CC7A9ebT.js} +1 -1
  13. package/dist/assets/{ConnectionAuthScreen-CuZmfRIp.js → ConnectionAuthScreen-DyBecMUz.js} +1 -1
  14. package/dist/assets/{CustomerOnboardingAuthScreen-BjmJLllh.js → CustomerOnboardingAuthScreen-CzPQ6hPn.js} +1 -1
  15. package/dist/assets/{CustomerOnboardingRoutes-C0b805o-.js → CustomerOnboardingRoutes-Fqi_xQ8j.js} +1 -1
  16. package/dist/assets/{CustomersRoutes-DD5Gx1mW.js → CustomersRoutes-DHtFoA_j.js} +1 -1
  17. package/dist/assets/{DashboardRoutes-C8RZkkYj.js → DashboardRoutes-DIfQCdfV.js} +1 -1
  18. package/dist/assets/{DefaultTenantHome-C6Ygdgwt.js → DefaultTenantHome-BXHCzE_E.js} +1 -1
  19. package/dist/assets/{DomesticWireDetailScreen-BxClNf2J.js → DomesticWireDetailScreen-pNAj50PJ.js} +1 -1
  20. package/dist/assets/{DrawerScreen-BHaectiO.js → DrawerScreen-Ba5DQb-t.js} +1 -1
  21. package/dist/assets/{EntityDetailRoutes-BJzuW7dq.js → EntityDetailRoutes-CRmd3CZq.js} +1 -1
  22. package/dist/assets/{ExpenseAutomationRoutes-BKrWZyYV.js → ExpenseAutomationRoutes-CqjUPpuq.js} +1 -1
  23. package/dist/assets/{FallBackRoute-DuMHkNqk.js → FallBackRoute-Ba8DnNt0.js} +2 -2
  24. package/dist/assets/{FeaturePreviewScreen-DHt0WFS8.js → FeaturePreviewScreen-C15dgqam.js} +1 -1
  25. package/dist/assets/{HubSpotOAuthCallbackScreen-Di0pbhHE.js → HubSpotOAuthCallbackScreen-Bj536BjH.js} +1 -1
  26. package/dist/assets/{InvoicingRoutes-Bsq4ym98.js → InvoicingRoutes-BjTaT2Ks.js} +1 -1
  27. package/dist/assets/{MagicLinkRoutes-DJX5Nm1n.js → MagicLinkRoutes-DzWLI6xy.js} +1 -1
  28. package/dist/assets/{MagicLinkSignInScreen-CD7Pya_j.js → MagicLinkSignInScreen-IWCCJ9ka.js} +1 -1
  29. package/dist/assets/{MobileAppDrawer-BWNb5zLN.js → MobileAppDrawer-CCAbxLE2.js} +1 -1
  30. package/dist/assets/{NotFoundScreen-DXy-BCit.js → NotFoundScreen-uAMK84U0.js} +1 -1
  31. package/dist/assets/{NotificationRoutes-B2xHVaqf.js → NotificationRoutes-k2xOmZgN.js} +1 -1
  32. package/dist/assets/{OAuthConsentScreen-BA2eBLib.js → OAuthConsentScreen-C_U40gXc.js} +1 -1
  33. package/dist/assets/{PandLWithForecastRoutes-Dm5Vnr71.js → PandLWithForecastRoutes-CWaWZqMn.js} +1 -1
  34. package/dist/assets/{PaymentLinkScreen-CndVAq3p.js → PaymentLinkScreen-BSjOZXP5.js} +1 -1
  35. package/dist/assets/{PeopleRoutes-kralZgbz.js → PeopleRoutes-CGvU4cdC.js} +1 -1
  36. package/dist/assets/{PerformanceRoutes-DJhuo9qY.js → PerformanceRoutes-DBkwWedw.js} +1 -1
  37. package/dist/assets/{QBOConnectionScreen-DroXrkno.js → QBOConnectionScreen-BcfAhM15.js} +1 -1
  38. package/dist/assets/{ReimbursementApprovalRoutes-B2ftFL0O.js → ReimbursementApprovalRoutes-CujO88Gv.js} +1 -1
  39. package/dist/assets/{ReimbursementApprovalRuleDetailScreen-CHTcY28V.js → ReimbursementApprovalRuleDetailScreen-CHtkyq9-.js} +1 -1
  40. package/dist/assets/{ReimbursementRoutes-CI3m7PHD.js → ReimbursementRoutes-Df3Aw7DR.js} +1 -1
  41. package/dist/assets/{ReportsRoutes-C7A0Ycu_.js → ReportsRoutes-Ul2BNSj_.js} +1 -1
  42. package/dist/assets/{RewardsRoutes-Dkg4zGB8.js → RewardsRoutes-BdM-p5F5.js} +1 -1
  43. package/dist/assets/{ScheduleDetailsPrepaidExpensesScreen-ZwdXW6K5.js → ScheduleDetailsPrepaidExpensesScreen-7Oe1wEIe.js} +1 -1
  44. package/dist/assets/{ScreenRoutes-B_WT7FAm.js → ScreenRoutes-2L_gx3e5.js} +2 -2
  45. package/dist/assets/{SettingsRoutes-_XBnyBgG.js → SettingsRoutes-CfzdYXCx.js} +1 -1
  46. package/dist/assets/{SetupPagesScreen-D6ssIWb0.js → SetupPagesScreen-DRxKoFqN.js} +1 -1
  47. package/dist/assets/{SignInScreen-H_SOl_FQ.js → SignInScreen-FEFXu8DO.js} +1 -1
  48. package/dist/assets/{SignOutScreen-OFswrnt8.js → SignOutScreen-Cj5aMtR8.js} +1 -1
  49. package/dist/assets/{TaskListScreen-Bmj5V_dR.js → TaskListScreen-CE88Gj9z.js} +1 -1
  50. package/dist/assets/{TaskRoutes-D6cEqDZN.js → TaskRoutes-C4KiUyaQ.js} +1 -1
  51. package/dist/assets/{TransactionDetailRoutes-D-b6zdg4.js → TransactionDetailRoutes-DU02DHgR.js} +1 -1
  52. package/dist/assets/{TransactionDetailScreen-JBKbtouq.js → TransactionDetailScreen-DjsUNuX8.js} +1 -1
  53. package/dist/assets/{TransactionListRoutes-THtfycHC.js → TransactionListRoutes-DouUxWQV.js} +1 -1
  54. package/dist/assets/{TreasuryRoutes-CgHwdyKd.js → TreasuryRoutes-B34-6WTm.js} +1 -1
  55. package/dist/assets/{VendorsRoutes-jETcYESc.js → VendorsRoutes-l3RUFxeF.js} +1 -1
  56. package/dist/assets/{WiseConfirmationScreen-BpRHCykr.js → WiseConfirmationScreen-CaYZ0YWP.js} +1 -1
  57. package/dist/assets/{ZeniAccountRoutes-C8cr5UMy.js → ZeniAccountRoutes-D866CG7l.js} +1 -1
  58. package/dist/assets/{ZeniAccountStatementScreen-DAs1_LIC.js → ZeniAccountStatementScreen-DcZ-Zp7O.js} +1 -1
  59. package/dist/assets/{analyticsHelper-CWMk7_rd.js → analyticsHelper-CVZpPd-a.js} +1 -1
  60. package/dist/assets/{getLocaleForTenant-B8EqveGi.js → getLocaleForTenant-dn31VMO2.js} +1 -1
  61. package/dist/assets/{index-CnIO6_IQ.js → index-DtThPd2q.js} +6 -6
  62. package/dist/assets/{routePaths-CV12X_S-.js → routePaths-DXYV831_.js} +1 -1
  63. package/dist/assets/{useActualMatchingMatchDetail-D-Ym3wTm.js → useActualMatchingMatchDetail-D9tjidmB.js} +1 -1
  64. package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-Dqg5VVaq.js → useAiCfoDashboardSuggestedQuestionsChips-piDOTVXb.js} +1 -1
  65. package/dist/assets/{useAskAiCfoHostNavButtonProps-DXFswt7R.js → useAskAiCfoHostNavButtonProps-DSKusWDa.js} +1 -1
  66. package/dist/assets/{useChargeCardPusherEvents-Cq6Y4mMW.js → useChargeCardPusherEvents-fpHDIIMx.js} +1 -1
  67. package/dist/assets/{useEmailConnectResultRefresh-qgk6N8cm.js → useEmailConnectResultRefresh-DAA2Py_6.js} +1 -1
  68. package/dist/assets/{useInitialThreadRequest-DAUsQlCl.js → useInitialThreadRequest-DrEeSZz_.js} +1 -1
  69. package/dist/assets/{useIsCustomersTabEnabled-C6mkabn2.js → useIsCustomersTabEnabled-C9FFBZXp.js} +1 -1
  70. package/dist/assets/{useTaskManagerAccess-Cm5trA3i.js → useTaskManagerAccess-CT25hqtF.js} +1 -1
  71. package/dist/assets/{useTaskManagerPusherEvents-C1gzc-aA.js → useTaskManagerPusherEvents-DKQsgy5z.js} +1 -1
  72. package/dist/assets/{withTransactionSidePanel-D-hDwbdr.js → withTransactionSidePanel-Dbd91mHL.js} +1 -1
  73. package/dist/index.html +1 -1
  74. package/package.json +1 -1
@@ -1,4 +1,4 @@
1
- import{j as L}from"./liveblocks-BLpmr1Pv.js";import{a as i}from"./sentry-DWNq3t8E.js";import{h as H,g as K,u as X,j as A,s as W,l as Z}from"./core-CbdTrw7T.js";import{az as ee,p as te,_ as B,z as ne,B as q,be as ae,c as ce,R as oe}from"./index-CnIO6_IQ.js";import{bm as se,fJ as ie,g_ as ue,oR as J,YP as re,il as G,gl as le,oE as de,YQ as pe,YR as ge,YS as me,uG as Ae,mb as be,oC as Ie,oy as ye,oN as fe,oJ as Se,io as Ee,YT as he,YU as ve}from"./zeni-epic-state-C5DO1jkr.js";import{n as we}from"./mui-DNGY4bFU.js";import{M as Ce}from"./MobileAppDrawer-BWNb5zLN.js";import{q as Q}from"./QBOConnectionScreen-DroXrkno.js";import{g as E,a as h,m as ze}from"./accountMappingHelper-DSd2V454.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new n.Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="a056ddca-3622-41e9-ad7c-70d0e2cac2e7",n._sentryDebugIdIdentifier="sentry-dbid-a056ddca-3622-41e9-ad7c-70d0e2cac2e7")}catch{}})();const r="zeni_pending_projects_enable",l={pending:"pending",ready:"ready"},xe=we.div`
1
+ import{j as L}from"./liveblocks-BLpmr1Pv.js";import{a as i}from"./sentry-DWNq3t8E.js";import{h as H,g as K,u as X,j as A,s as W,l as Z}from"./core-CbdTrw7T.js";import{az as ee,p as te,_ as B,z as ne,B as q,be as ae,c as ce,R as oe}from"./index-DtThPd2q.js";import{bm as se,fJ as ie,g_ as ue,oR as J,YP as re,il as G,gl as le,oE as de,YQ as pe,YR as ge,YS as me,uG as Ae,mb as be,oC as Ie,oy as ye,oN as fe,oJ as Se,io as Ee,YT as he,YU as ve}from"./zeni-epic-state-C5DO1jkr.js";import{n as we}from"./mui-DNGY4bFU.js";import{M as Ce}from"./MobileAppDrawer-CCAbxLE2.js";import{q as Q}from"./QBOConnectionScreen-BcfAhM15.js";import{g as E,a as h,m as ze}from"./accountMappingHelper-DSd2V454.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new n.Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="a056ddca-3622-41e9-ad7c-70d0e2cac2e7",n._sentryDebugIdIdentifier="sentry-dbid-a056ddca-3622-41e9-ad7c-70d0e2cac2e7")}catch{}})();const r="zeni_pending_projects_enable",l={pending:"pending",ready:"ready"},xe=we.div`
2
2
  display: flex;
3
3
  height: 100%;
4
4
  width: 100%;
@@ -1 +1 @@
1
- import{j as s}from"./liveblocks-BLpmr1Pv.js";import{a as y}from"./sentry-DWNq3t8E.js";import{a5 as A,c1 as R}from"./index-CnIO6_IQ.js";import"./mui-DNGY4bFU.js";import{u as F}from"./useActualMatchingMatchDetail-D-Ym3wTm.js";import b from"./NotFoundScreen-DXy-BCit.js";import{i as P,h as U,g as w}from"./core-CbdTrw7T.js";import"./zeni-epic-state-C5DO1jkr.js";import"./recharts-CTh_JhT_.js";import"./analytics-Vgn85Ur_.js";import"./plaid-DhfTjhua.js";import"./dnd-DuiAlI7w.js";import"./stripe-cKAAJElX.js";import"./lottie-Lb1ftKY1.js";import"./lexical-B-vxEaRQ.js";import"./pdf-B1uD4Ovv.js";import"./utils-CrhrpmD8.js";import"./stripSplatSuffix-DP9nmQOu.js";import"./decodeURIComponentSafe-D7APy95S.js";import"./routePaths-CV12X_S-.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]="6b4cdc4c-35ab-4475-8d41-1aeb473de315",t._sentryDebugIdIdentifier="sentry-dbid-6b4cdc4c-35ab-4475-8d41-1aeb473de315")}catch{}})();function V(){const{matchId:t,tenantEmailDomain:e}=P(),o=U(),n=w(),k=F(t??""),r=y.useCallback((()=>{const v=A(n.state?.pathnameStackToGoBack);o(v.poppedPathname??`/${e??""}/month_end_close_checks/review`,{state:{pathnameStackToGoBack:v.newStack}})}),[n.state,o,e]);if(t==null)return s.jsx(b,{});const{match:i,detailFetchState:a,handleOpenBill:l,handleRefresh:c,handleUndoReversal:h,handleApproveAndReverse:d,handleIgnoreMatchSuggestion:p,lastMatchResults:f,lastUndoResults:g,refreshStatus:m,ignoreStatus:u,matchAndReverseStatus:S,undoReversalStatus:I}=k;return i==null?a.fetchState==="Not-Started"||a.fetchState==="In-Progress"?s.jsx(R,{detailFetchState:a.fetchState,isIgnoreInFlight:u.fetchState==="In-Progress",isApproveInFlight:S.fetchState==="In-Progress",isUndoInFlight:I.fetchState==="In-Progress",refreshStatus:m.fetchState,onNavigateBack:r,onOpenBill:l,onApproveAndReverse:d,onIgnoreMatchSuggestion:p,onRefresh:c,onUndoReversal:h,lastMatchResults:f,lastUndoResults:g}):s.jsx(b,{}):s.jsx(R,{match:i,detailFetchState:a.fetchState,isIgnoreInFlight:u.fetchState==="In-Progress",isApproveInFlight:S.fetchState==="In-Progress",isUndoInFlight:I.fetchState==="In-Progress",refreshStatus:m.fetchState,onNavigateBack:r,onOpenBill:l,onApproveAndReverse:d,onIgnoreMatchSuggestion:p,onRefresh:c,onUndoReversal:h,lastMatchResults:f,lastUndoResults:g})}export{V as default};
1
+ import{j as s}from"./liveblocks-BLpmr1Pv.js";import{a as y}from"./sentry-DWNq3t8E.js";import{a5 as A,c1 as R}from"./index-DtThPd2q.js";import"./mui-DNGY4bFU.js";import{u as F}from"./useActualMatchingMatchDetail-D9tjidmB.js";import b from"./NotFoundScreen-uAMK84U0.js";import{i as P,h as U,g as w}from"./core-CbdTrw7T.js";import"./zeni-epic-state-C5DO1jkr.js";import"./recharts-CTh_JhT_.js";import"./analytics-Vgn85Ur_.js";import"./plaid-DhfTjhua.js";import"./dnd-DuiAlI7w.js";import"./stripe-cKAAJElX.js";import"./lottie-Lb1ftKY1.js";import"./lexical-B-vxEaRQ.js";import"./pdf-B1uD4Ovv.js";import"./utils-CrhrpmD8.js";import"./stripSplatSuffix-DP9nmQOu.js";import"./decodeURIComponentSafe-D7APy95S.js";import"./routePaths-DXYV831_.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]="6b4cdc4c-35ab-4475-8d41-1aeb473de315",t._sentryDebugIdIdentifier="sentry-dbid-6b4cdc4c-35ab-4475-8d41-1aeb473de315")}catch{}})();function V(){const{matchId:t,tenantEmailDomain:e}=P(),o=U(),n=w(),k=F(t??""),r=y.useCallback((()=>{const v=A(n.state?.pathnameStackToGoBack);o(v.poppedPathname??`/${e??""}/month_end_close_checks/review`,{state:{pathnameStackToGoBack:v.newStack}})}),[n.state,o,e]);if(t==null)return s.jsx(b,{});const{match:i,detailFetchState:a,handleOpenBill:l,handleRefresh:c,handleUndoReversal:h,handleApproveAndReverse:d,handleIgnoreMatchSuggestion:p,lastMatchResults:f,lastUndoResults:g,refreshStatus:m,ignoreStatus:u,matchAndReverseStatus:S,undoReversalStatus:I}=k;return i==null?a.fetchState==="Not-Started"||a.fetchState==="In-Progress"?s.jsx(R,{detailFetchState:a.fetchState,isIgnoreInFlight:u.fetchState==="In-Progress",isApproveInFlight:S.fetchState==="In-Progress",isUndoInFlight:I.fetchState==="In-Progress",refreshStatus:m.fetchState,onNavigateBack:r,onOpenBill:l,onApproveAndReverse:d,onIgnoreMatchSuggestion:p,onRefresh:c,onUndoReversal:h,lastMatchResults:f,lastUndoResults:g}):s.jsx(b,{}):s.jsx(R,{match:i,detailFetchState:a.fetchState,isIgnoreInFlight:u.fetchState==="In-Progress",isApproveInFlight:S.fetchState==="In-Progress",isUndoInFlight:I.fetchState==="In-Progress",refreshStatus:m.fetchState,onNavigateBack:r,onOpenBill:l,onApproveAndReverse:d,onIgnoreMatchSuggestion:p,onRefresh:c,onUndoReversal:h,lastMatchResults:f,lastUndoResults:g})}export{V as default};
@@ -1 +1 @@
1
- import{j as e}from"./liveblocks-BLpmr1Pv.js";import{A as i}from"./AddressScreen-DgUwrml_.js";import s from"./NotFoundScreen-DXy-BCit.js";import"./sentry-DWNq3t8E.js";import{n as d,o as r}from"./core-CbdTrw7T.js";import"./zeni-epic-state-C5DO1jkr.js";import"./recharts-CTh_JhT_.js";import"./index-CnIO6_IQ.js";import"./mui-DNGY4bFU.js";import"./analytics-Vgn85Ur_.js";import"./plaid-DhfTjhua.js";import"./dnd-DuiAlI7w.js";import"./stripe-cKAAJElX.js";import"./lottie-Lb1ftKY1.js";import"./lexical-B-vxEaRQ.js";import"./pdf-B1uD4Ovv.js";import"./utils-CrhrpmD8.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]="c1501551-0737-433d-9247-7e0f507b1a6b",t._sentryDebugIdIdentifier="sentry-dbid-c1501551-0737-433d-9247-7e0f507b1a6b")}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-BLpmr1Pv.js";import{A as i}from"./AddressScreen-BVizi07H.js";import s from"./NotFoundScreen-uAMK84U0.js";import"./sentry-DWNq3t8E.js";import{n as d,o as r}from"./core-CbdTrw7T.js";import"./zeni-epic-state-C5DO1jkr.js";import"./recharts-CTh_JhT_.js";import"./index-DtThPd2q.js";import"./mui-DNGY4bFU.js";import"./analytics-Vgn85Ur_.js";import"./plaid-DhfTjhua.js";import"./dnd-DuiAlI7w.js";import"./stripe-cKAAJElX.js";import"./lottie-Lb1ftKY1.js";import"./lexical-B-vxEaRQ.js";import"./pdf-B1uD4Ovv.js";import"./utils-CrhrpmD8.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]="c1501551-0737-433d-9247-7e0f507b1a6b",t._sentryDebugIdIdentifier="sentry-dbid-c1501551-0737-433d-9247-7e0f507b1a6b")}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-BLpmr1Pv.js";import{a as b}from"./sentry-DWNq3t8E.js";import{h as T,u as P,g as j,i as E,j as B,l as M}from"./core-CbdTrw7T.js";import{a2 as $,z as D,V as L,a8 as R,a9 as K,c as _,R as S,a4 as z,W as h,a5 as F}from"./index-CnIO6_IQ.js";import{a1R as C,iB as N,fJ as U,a1r as V,c8 as G,_x as O,mT as q}from"./zeni-epic-state-C5DO1jkr.js";import{u as H,n as J}from"./mui-DNGY4bFU.js";import W from"./NotFoundScreen-DXy-BCit.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]="315f4835-921a-46c2-9b3a-e9fe39ac6fb7",e._sentryDebugIdIdentifier="sentry-dbid-315f4835-921a-46c2-9b3a-e9fe39ac6fb7")}catch{}})();const Q=J.div`
1
+ import{j as r}from"./liveblocks-BLpmr1Pv.js";import{a as b}from"./sentry-DWNq3t8E.js";import{h as T,u as P,g as j,i as E,j as B,l as M}from"./core-CbdTrw7T.js";import{a2 as $,z as D,V as L,a8 as R,a9 as K,c as _,R as S,a4 as z,W as h,a5 as F}from"./index-DtThPd2q.js";import{a1R as C,iB as N,fJ as U,a1r as V,c8 as G,_x as O,mT as q}from"./zeni-epic-state-C5DO1jkr.js";import{u as H,n as J}from"./mui-DNGY4bFU.js";import W from"./NotFoundScreen-uAMK84U0.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]="315f4835-921a-46c2-9b3a-e9fe39ac6fb7",e._sentryDebugIdIdentifier="sentry-dbid-315f4835-921a-46c2-9b3a-e9fe39ac6fb7")}catch{}})();const Q=J.div`
2
2
  display: flex;
3
3
  height: 100vh;
4
4
  width: 100%;
@@ -1,4 +1,4 @@
1
- import{j as S}from"./liveblocks-BLpmr1Pv.js";import{a as n}from"./sentry-DWNq3t8E.js";import{u as Lt,h as Ut,i as Vt,g as Bt,j as v,l as Ft}from"./core-CbdTrw7T.js";import{ee as Mt,g as $t,n as Nt,ef as Gt,z as Ht,a2 as qt,eg as zt,eh as Wt,ei as Yt,aE as Ve,ej as We,ek as Kt,aD as Ye,a5 as ge,a9 as ce,c as M,el as me,em as Jt,en as Xt,ax as Zt,R as es,w as ts,eo as ss,ep as ns,aj as as,eq as os,er as is,es as rs,et as ls,s as us,aw as Be,eu as ds}from"./index-CnIO6_IQ.js";import{fI as F,gx as R,Ve as cs,a3Q as ms,a3R as Ss,jY as hs,a3S as ps,jV as fs,a3T as Se,jB as K,k2 as J,jH as Ie,jo as he,jm as gs,k4 as Is,jQ as Ke,Vm as Fe,gz as $,gO as Cs,Vl as ks,V7 as Me,fJ as bs,jf as vs,a3U as Es,gc as Ps,jx as ws,jt as ys,fK as pe,gj as xs,a3V as Rs,a3W as Ts,a3X as Os,gy as js,gs as $e,kg as Ne,gu as Ge,gA as As,a3Y as He,k5 as _s,jq as Ds,jK as Qs,k0 as qe,jN as Ls,gB as Us,gC as Vs,gD as Bs,gE as Fs}from"./zeni-epic-state-C5DO1jkr.js";import{D as Ms,n as N,S as $s,v as Ns}from"./mui-DNGY4bFU.js";import{u as Gs}from"./useAiCfoDashboardSuggestedQuestionsChips-Dqg5VVaq.js";import{p as Hs}from"./pathToGoBack-CJCquoqC.js";import{l as qs}from"./routePaths-CV12X_S-.js";import{u as zs}from"./useTaskManagerPusherEvents-C1gzc-aA.js";import"./recharts-CTh_JhT_.js";import"./analytics-Vgn85Ur_.js";import"./plaid-DhfTjhua.js";import"./dnd-DuiAlI7w.js";import"./stripe-cKAAJElX.js";import"./lottie-Lb1ftKY1.js";import"./lexical-B-vxEaRQ.js";import"./pdf-B1uD4Ovv.js";import"./utils-CrhrpmD8.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new t.Error().stack;r&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[r]="61f61cec-a0b5-4e86-a6fc-4a97e751fbd9",t._sentryDebugIdIdentifier="sentry-dbid-61f61cec-a0b5-4e86-a6fc-4a97e751fbd9")}catch{}})();const Ws=["claimed","running","succeeded","failed","timeout"],fe=t=>typeof t=="string"&&t!=="",Je="chat-response-generated";function Ys(t,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 h=R(t).skills.find((s=>s.macroId===r.savedMacroId));return h==null?void 0:{status:"saved",command:h.name}}const Ks=Ft((function(t,r){const h=F(t),s=r.isSubmitting,d=h.uiState?.currentChatSessionId,l=d!=null?xs(t.aiCfoState,d):[],i=ns(t,{allUsers:r.allUsers,onCardPolicyVendorSearchTextChange:r.onCardPolicyVendorSearchTextChange}),g=Rs(t),p=Ts(t),f=Os(t);return{showSampleQuestions:r.sessionFromUrl==="explore"&&h.uiState.currentChatSessionId==null,aiCfoView:h,isSubmitting:s,isNewChatSession:r.sessionFromUrl==="new_chat"||r.sessionFromUrl==="explore",isFullView:!0,tableDownloadEndPoint:`${as}/tableDownload`,exportDownloadEndPoint:rs(),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:R(t).skills,skillSaveState:Ys(t,f),skillsEnabled:R(t).skillsEnabled,skillsList:R(t).skills,skillsListError:R(t).fetchState==="Error",skillsListLoading:R(t).fetchState==="In-Progress",skillsCanPublish:R(t).canPublish,skillSaving:f.fetchState==="In-Progress",skillSaveError:f.fetchState==="Error",skillVersionHistory:g.macroId!=null?{macroId:g.macroId,versions:g.versions,error:g.fetchState==="Error",loading:g.fetchState==="In-Progress"}:void 0,skillRestoreBody:p.macroId!=null&&p.version!=null?{macroId:p.macroId,version:p.version,instructions:p.instructions,error:p.fetchState==="Error",loading:p.fetchState==="In-Progress"}:void 0,skillDetail:J(t).detail,skillDetailError:J(t).fetchState==="Error",skillDetailLoading:J(t).fetchState==="In-Progress",syntheticAnswers:l,resolveSyntheticAnswerCardTile:is(t),resolveSyntheticAnswerPolicyTile:os(t),...i}}),(function(t,r){const{location:h,currentTenant:s,userId:d,navigate:l,currentChatSessionId:i,allSessionsWithOrderedQuestionAnswers:g,isAiCardCreationEnabled:p,isCardPolicyEnabled:f,setIsAiCfoOpen:U}=r,V=s.tenantEmailDomain;return{onEventReceived:(a,o)=>{if(a===Je&&typeof o.text=="string"&&typeof o.metadata=="object"){const c=o,O=Us(c.type),E=c.metadata.chat_session_id??null,{currentChatSession:j,currentQuestionAnswer:G,currentQuestionAnswerSummary:A}=Ye(g,E);O!=="answer"?M.trackAICFOChatResponseGenerated(O,G?.question.questionText??"",c.text,E,ds(A,j),c.metadata.message_id??null):M.trackAICFOChatAnswerGenerated(c.text,G?.question.questionText??"",(c.follow_up_questions?.length??0)>0,!!c.assumptions,!!c.insights,c.visualization!=null,Vs(c.visualization?.type??"")??null,E,c.summarized_title,c.metadata.message_id??null),t(Bs({chatSessionId:c.metadata.chat_session_id,responseType:O,fetchState:{fetchState:"Completed",error:void 0}})),t(Fs({chatSessionId:c.metadata.chat_session_id,answerPayload:c,userId:d}))}},onSubmit:(a,o,c,O,E)=>{a&&Be(t,a,o,i,g,d,O,c,void 0,E)},onFetchSkills:()=>{t(Ke())},onOpenSkill:a=>{t(Ie({macroId:a})),t(Ls({macroId:a}))},onSaveSkill:(a,o)=>{t(qe({draft:a,macroId:o}))},onSaveSkillDraft:a=>{const o=a.displayName?.trim()??"",c=a.name?.trim()??"";t(qe({draft:{name:o.length>0?o:c,description:a.description?.trim()??null,instructions:a.instructions,visibility:"private"}}))},onFetchSkillVersionBody:(a,o)=>{t(Qs({macroId:a,version:o}))},onDeleteSkill:a=>{t(Ds({macroId:a}))},onSetSkillVisibility:(a,o)=>{t(_s({macroId:a,visibility:o}))},onCloseSkillDetail:()=>{t(He())},onRunSkill:(a,o)=>{t($()),t($e()),Be(t,o,"user_input",void 0,g,d,void 0,void 0,void 0,a),t(He())},updateCurrentInput:a=>{t(Ge(a))},onStopSubmit:()=>{},onUpdateScrollYOffset:a=>{t(As(a))},onSelectSampleQuestion:()=>{},onBackClick:()=>{l(-1)},onCloseClick:()=>{const a=ge(h.state?.pathnameStackToGoBack),o=a.poppedPathname??Hs(1);l(o,{state:{...h.state,pathnameStackToGoBack:a.newStack}}),t(Ge(""))},togglePageView:()=>{const a=ge(h.state?.pathnameStackToGoBack),o=a.poppedPathname??`/${s.tenantEmailDomain}/dashboard`;l(o,{state:{...We(h.state),pathnameStackToGoBack:a.newStack,message:"open_ai_cfo_drawer"}}),U(!0)},onCopy:()=>{},onThumbsUp:(a,o)=>{i!=null&&o?.messageId!=null&&t(Ne(i,o.messageId,"positive",o.questionText,o.answerText))},onThumbsDown:(a,o)=>{i!=null&&o?.messageId!=null&&t(Ne(i,o.messageId,"negative",o.questionText,o.answerText))},onTogglePageView:()=>{l(-1)},onNewChatClick:()=>{t($()),i!=null&&t($e());const a=us(h.state?.pathnameStackToGoBack,h.pathname);l(`/${s.tenantEmailDomain}/ai-cfo/new_chat`,{state:{pathnameStackToGoBack:a.slice(0,-1),referrer:"Sidebar"}})},onToggleCotCollapsed:(a,o)=>{t(js({questionAnswerId:a,isCollapsed:o}))},onMenuClick:r.onMenuClick,...ls(t,{isAiCardCreationEnabled:p,isCardPolicyEnabled:f,currentChatSessionId:i,onAfterCardsCreationSubmit:()=>{U(!0),l(`/${V}/cards`,{state:{...h.state}})},onAfterCardPolicySubmit:()=>{U(!0),l(`/${V}/cards/policy`,{state:{...h.state}})}})}}))(ts(ss)),bn=({isFileUploadEnabled:t})=>{const r=Mt(),{setIsAiCfoOpen:h}=$t(),s=Lt(),d=Ut(),{session_id:l}=Vt(),i=Bt(),g=new URLSearchParams(i.search).get("routine")??void 0,[p,f]=n.useState(!1),U=v((e=>F(e).uiState.isSkillsBrowserOpen===!0)),V=v((e=>R(e).skillsEnabled)),a=v((e=>F(e).uiState.isRoutinesBrowserOpen===!0)),o=v((e=>cs(e))),c=v((e=>ms(e))),O=v((e=>Ss(e))),[E,j]=n.useState(void 0),[G,A]=n.useState(!1),[Xe,Ce]=n.useState(void 0),Ze=n.useCallback((()=>{Ce(void 0),j(void 0),A(!0)}),[]),et=n.useCallback((e=>{j(e),A(!0)}),[]),tt=n.useCallback((()=>{j(void 0),A(!1)}),[]),st=n.useCallback((e=>{s(hs({draft:e,...E!=null&&{scheduleId:E.scheduleId}})),j(void 0),A(!1)}),[s,E]),P=g,ke=o.routines.find((e=>e.scheduleId===P)),C=v((e=>ps(e))),nt=n.useCallback((e=>{s(fs({scheduleId:e.scheduleId}))}),[s]);n.useEffect((()=>{s(P!=null?K({scheduleId:P}):Se())}),[s,P]);const B=ke?.macroId,at=v((e=>J(e))),be=B!=null&&B!==""&&at.fetchState==="Not-Started";n.useEffect((()=>{be&&B!=null&&s(Ie({macroId:B}))}),[s,be,B]);const ot=v((e=>F(e).uiState.currentChatSessionId))??l,k=o.routines.find((e=>e.scheduleId===g))??o.routines.find((e=>e.scheduleId===Nt(ot))),T=k?.scheduleId??null,[ve,it]=n.useState(!0);n.useEffect((()=>{T!=null&&s(K({scheduleId:T}))}),[s,T]);const Ee=C.runs.some((e=>e.status==="claimed"||e.status==="running"))===!0;n.useEffect((()=>{if(P==null||Ee!==!0)return;const e=window.setInterval((()=>{s(K({scheduleId:P})),s(he())}),5e3);return()=>window.clearInterval(e)}),[s,Ee,P]);const rt=n.useCallback((e=>{Ce(e),j(void 0),A(!0)}),[]),lt=n.useCallback((e=>{s(gs({scheduleId:e.scheduleId}))}),[s]),ut=n.useCallback(((e,m)=>{s(Is({enabled:m,scheduleId:e.scheduleId}))}),[s]);n.useEffect((()=>{a&&s(he())}),[s,a]);const Pe=v((e=>R(e).skills)),X=n.useMemo((()=>Pe.map((e=>({macroId:e.macroId,name:e.displayName??e.name})))),[Pe]),dt=n.useCallback((e=>{s(Ie({macroId:e}))}),[s]),Z=n.useCallback((()=>{s(Ke()),s(Fe())}),[s]),ct=n.useCallback((()=>{s($())}),[s]),{allUsers:mt,isAiCardCreationEnabled:St,isCardPolicyEnabled:ht,onCardPolicyVendorSearchTextChange:pt}=Gt();n.useEffect((()=>{s(Cs())}),[s]);const I=v((e=>F(e))),y=Ht.getSignedInUser();n.useEffect((()=>l==="routines"?(s($()),void s(ks())):l==="skills"?(s(Se()),s(Me()),void s(Fe())):(T==null&&s(Se()),s(Me()),void s($()))),[s,T,g,l]);const ft=qt(),_=Zt(ft),b=v((e=>bs(e))),u=I.uiState.currentChatSessionId,w=b.tenantEmailDomain,L=w!=null&&w!=="",ee=n.useCallback((e=>{L&&d(`/${w}/ai-cfo/routines?routine=${encodeURIComponent(e.scheduleId)}`)}),[L,d,w]),te=n.useCallback((()=>{L&&d(`/${w}/ai-cfo/routines`)}),[L,d,w]),se=n.useCallback(((e,m)=>{const D=e.sessionId??C.sessionId;D!=null&&L&&d(`/${w}/ai-cfo/${D}?routine=${encodeURIComponent(m)}`)}),[L,d,C.sessionId,w]),gt=n.useMemo((()=>k==null?void 0:{error:C.fetchState==="Error",kind:"routineRuns",loading:C.fetchState==="In-Progress"||C.fetchState==="Not-Started",routineName:k.name,schedule:zt(k),skillName:k.isAdHoc===!0?void 0:X.find((e=>e.macroId===k.macroId))?.name,onOpenSkill:k.isAdHoc===!0?void 0:Z,runs:C.runs,tzName:k.tzName,unreadCount:k.unreadRuns,open:ve,onToggle:()=>it((e=>!e)),onOpenRun:e=>se(e,k.scheduleId),onOpenRoutine:()=>ee(k),onOpenRoutines:te}),[Z,te,ee,se,ve,k,C.fetchState,C.runs,X]),{handleUploadPromoClose:It,isUploadPromoVisible:Ct}=Wt({isFileUploadEnabled:t,tenantEmailDomain:w}),ne=Yt({currentTenant:b,currentChatSessionId:u,aiCfoView:I,skillsEnabled:V,onCloseSkills:ct,onOpenSkills:Z}),{isSuggestedQuestionsLoading:kt,suggestedPromptQuestions:bt}=Gs(),H=i.state,q=H?.aiCfoInitialQuestion,we=!!H?.aiCfoShouldSubmit;n.useEffect((()=>{const e=i.state;if(e?.[Ve]!==!0)return;f(!0);const m={...e};delete m[Ve],d(i,{replace:!0,state:m})}),[i.pathname,i.search,i.state,d]);const[vt,ae]=n.useState(null),[Et,oe]=n.useState(!1),[Pt,ie]=n.useState(void 0),[wt,re]=n.useState(void 0),ye=n.useRef(!1);n.useEffect((()=>{if(!ye.current&&q!=null&&q!==""){const e=i.state;ae(q),oe(we),ie(e?.aiCfoInitialSubmissionSource!=null?e.aiCfoInitialSubmissionSource:void 0);const m=e?.aiCfoSuggestionIndex;re(typeof m=="number"?m:void 0),ye.current=!0}}),[q,we,i.state]);const yt=n.useCallback((()=>{ae(null),oe(!1),ie(void 0),re(void 0),d(i.pathname,{replace:!0,state:We(i.state)})}),[i.pathname,i.state,d]),xe=n.useMemo((()=>new URLSearchParams(i.search)),[i.search]),Re=xe.get("ref")??H?.aiCfoRef,le=xe.get("emailRefId")??H?.aiCfoEmailRefId,Te=n.useRef(!1);n.useEffect((()=>{Te.current||Re!=="month-end-email"||le==null||u!=null||y==null||(s(vs("controller",y.userId,le,"MONTH_END_EMAIL")),Te.current=!0)}),[Re,le,u,s,y]);const z=I.uiState.lastContextMessage;n.useEffect((()=>{z!=null&&z!==""&&u!=null&&(ae(z),oe(!0),ie(void 0),re(void 0),s(Es()))}),[z,u,s]);const xt=b.masterTOSInfo,x=xt?.isMasterTOSAccepted??!1,{visitedSessions:Oe}=Kt(u),W=I.fetchState,Y=I.uiState.chatSessionsNextPageToken.hasMore||!I.uiState.chatSessionsFirstPageFetched,je=u!=null?I.fetchChatSessionHistoryByChatSessionId?.[u]?.fetchState??"Not-Started":"Not-Started",Ae=u==null||(I.uiState.chatHistoryNextPageToken[u]?.hasMore??!0),_e=I.allSessionsWithOrderedQuestionAnswers,{currentSessionQuestionAnswers:Rt}=Ye(_e,u),Tt=Rt.length===0;n.useEffect((()=>{x||_||d("../dashboard",{state:{...i.state,message:"open_ai_cfo_drawer"}})}),[x,_,d,i.state]);const Ot=n.useCallback((()=>{const e=ge(i.state?.pathnameStackToGoBack),m=b.tenantEmailDomain;d(e.poppedPathname??(m!=null?`/${m}/dashboard`:".."),{state:{...i.state,pathnameStackToGoBack:e.newStack}})}),[b.tenantEmailDomain,i.state,d]),De=n.useRef(void 0),Qe=n.useRef(void 0);n.useEffect((()=>{const e=l!==De.current,m=u!==Qe.current;De.current=l,Qe.current=u,l!==u&&(!e||l==null||qs(l)?m&&u!=null&&d(`../ai-cfo/${u}`,{state:{...i.state}}):s(Ps({sessionId:l,agentId:"controller"})))}),[u,l]);const jt=n.useMemo((()=>({events:Oe.map((e=>`private-encrypted-chat-${e}.${Je}`)),eventCallback:(e,m,D)=>D.onEventReceived(e,m)})),[Oe]);n.useEffect((()=>{W!=="In-Progress"&&Y&&s(ws())}),[W,Y,s]),n.useEffect((()=>{u!=null&&je!=="In-Progress"&&Ae&&y!=null&&(l===u||W==="Completed"&&!Y)&&s(ys(u,y.userId))}),[je,W,Ae,Y,u,y,l,s]);const ue=y?.userId,At=n.useMemo((()=>{return ue==null?[]:[(e=ue,`private-encrypted-routines-${e}.routine-run-updated`)];var e}),[ue]),Le=n.useCallback((e=>{const m=e!=null&&(e===P||e===T);(a||m)&&s(he()),m&&s(K({scheduleId:e}))}),[s,a,T,P]);zs({events:At,onSubscribed:()=>Le(P??T),onEvent:(e,m)=>{const D=(de=>{if(de==null||typeof de!="object")return null;const Q=de;return fe(Q.schedule_id)&&fe(Q.run_id)?{scheduleId:Q.schedule_id,runId:Q.run_id,status:Ws.find((Qt=>Qt===Q.status))??null,finishedAt:fe(Q.finished_at)?Q.finished_at:null}:null})(m);D!=null&&Le(D.scheduleId)}});const Ue=e=>e.trackAICFOOnboardingScreenStateChanged("open","first_visit");if(y==null||l==null)throw Error("Can't access AI Controller page without signing in...");const _t=u!=null&&I.responseStateByChatSessionId?.[u]?.answer?.fetchState==="In-Progress";if(!x&&_)return S.jsxs(Xs,{children:[S.jsx(ce,{analytics:M,onLoad:Ue}),ne.drawerElement,S.jsx(Zs,{children:S.jsx(ze,{children:S.jsx(me,{isTOSAccepted:!1,acceptMasterTOSState:I.masterTOSAcceptanceState,onCloseClick:Ot,onCompleteClick:()=>{b.userRoleId!=null&&s(pe(b.userRoleId))}})})})]});const Dt=S.jsxs(S.Fragment,{children:[p&&!x?S.jsx(ce,{analytics:M,onLoad:Ue}):null,S.jsx(me,{isTOSAccepted:x,acceptMasterTOSState:I.masterTOSAcceptanceState,showHeader:!1,togglePageView:x?()=>f(!1):void 0,onCloseClick:()=>f(!1),onCompleteClick:()=>{x||b.userRoleId==null||s(pe(b.userRoleId)),f(!1)}})]});return S.jsxs(S.Fragment,{children:[S.jsxs(Js,{children:[S.jsx(ce,{analytics:M,onLoad:e=>e.trackPageLoaded(es.Event.aiCFOPage)}),_&&ne.drawerElement,S.jsx(Ks,{answerExportEndPoint:r,...jt,currentChatSessionId:u,allSessionsWithOrderedQuestionAnswers:_e,allUsers:mt,isAiCardCreationEnabled:St,isCardPolicyEnabled:ht,openOnboardingPage:()=>f(!0),userId:y.userId,setIsAiCfoOpen:h,navigate:d,sessionFromUrl:l,location:i,isSubmitting:_t,isEmptyChatWithSession:Tt,currentTenant:b,emailLinkQuestion:vt??void 0,autoSubmitEmailLinkQuestion:Et,onEmailLinkQuestionProcessed:yt,routedInitialQuestionSource:Pt,routedInitialQuestionSuggestionIndex:wt,onCardPolicyVendorSearchTextChange:pt,onMenuClick:_?ne.open:void 0,isFileUploadEnabled:t,isUploadPromoVisible:Ct,onUploadPromoClose:It,exploreSuggestedPromptQuestions:bt,exploreSuggestedPromptQuestionsLoading:kt,isSkillsOpen:U,isRoutinesOpen:a,routineCanCreate:O,routineEditing:E,routineEditorOpen:G,routineListError:o.fetchState==="Error",routineListLoading:o.fetchState==="In-Progress",routineMaxRoutines:o.maxRoutines,routineSaveError:c.fetchState==="Error",routineSaving:c.fetchState==="In-Progress",routineSchedulableSkills:X,routines:o.routines,onRoutineCreate:Ze,onRoutineDelete:lt,routineHistoryError:C.fetchState==="Error",routineHistoryLoading:C.fetchState==="In-Progress",chatSidePanel:gt,routineDetail:ke,routineRunningScheduleId:c.runningScheduleId,routineRuns:C.runs,onRoutineEdit:et,onRoutineOpenRun:(e,m)=>se(m,e.scheduleId),onRoutineRun:nt,onRoutineCloseDetail:te,onRoutineDraft:rt,routineDraftPrompt:Xe,onRoutineOpenDetail:ee,onRoutineEditorCancel:tt,onRoutineLoadSkillInstructions:dt,onRoutineSave:st,onRoutineSetEnabled:ut,isCreateSkillEnabled:V,promoDismissalScope:w}),p&&_?S.jsx(Ms,{anchor:"right",open:p,transitionDuration:250,PaperProps:{component:en,style:{width:"100%"}},slotProps:{backdrop:{style:{backgroundColor:"transparent",cursor:"pointer"}}},onClose:()=>f(!1),children:S.jsx(ze,{onClick:e=>e.stopPropagation(),children:S.jsx(me,{isTOSAccepted:x,acceptMasterTOSState:I.masterTOSAcceptanceState,onCloseClick:()=>f(!1),onCompleteClick:()=>{x||b.userRoleId==null||s(pe(b.userRoleId)),f(!1)}})})}):null]}),p&&!_?S.jsx(Jt,{open:p,onClose:()=>f(!1),children:S.jsx(Xt,{children:Dt})}):null]})},ze=N($s)`
1
+ import{j as S}from"./liveblocks-BLpmr1Pv.js";import{a as n}from"./sentry-DWNq3t8E.js";import{u as Lt,h as Ut,i as Vt,g as Bt,j as v,l as Ft}from"./core-CbdTrw7T.js";import{ee as Mt,g as $t,n as Nt,ef as Gt,z as Ht,a2 as qt,eg as zt,eh as Wt,ei as Yt,aE as Ve,ej as We,ek as Kt,aD as Ye,a5 as ge,a9 as ce,c as M,el as me,em as Jt,en as Xt,ax as Zt,R as es,w as ts,eo as ss,ep as ns,aj as as,eq as os,er as is,es as rs,et as ls,s as us,aw as Be,eu as ds}from"./index-DtThPd2q.js";import{fI as F,gx as R,Ve as cs,a3Q as ms,a3R as Ss,jY as hs,a3S as ps,jV as fs,a3T as Se,jB as K,k2 as J,jH as Ie,jo as he,jm as gs,k4 as Is,jQ as Ke,Vm as Fe,gz as $,gO as Cs,Vl as ks,V7 as Me,fJ as bs,jf as vs,a3U as Es,gc as Ps,jx as ws,jt as ys,fK as pe,gj as xs,a3V as Rs,a3W as Ts,a3X as Os,gy as js,gs as $e,kg as Ne,gu as Ge,gA as As,a3Y as He,k5 as _s,jq as Ds,jK as Qs,k0 as qe,jN as Ls,gB as Us,gC as Vs,gD as Bs,gE as Fs}from"./zeni-epic-state-C5DO1jkr.js";import{D as Ms,n as N,S as $s,v as Ns}from"./mui-DNGY4bFU.js";import{u as Gs}from"./useAiCfoDashboardSuggestedQuestionsChips-piDOTVXb.js";import{p as Hs}from"./pathToGoBack-CJCquoqC.js";import{l as qs}from"./routePaths-DXYV831_.js";import{u as zs}from"./useTaskManagerPusherEvents-DKQsgy5z.js";import"./recharts-CTh_JhT_.js";import"./analytics-Vgn85Ur_.js";import"./plaid-DhfTjhua.js";import"./dnd-DuiAlI7w.js";import"./stripe-cKAAJElX.js";import"./lottie-Lb1ftKY1.js";import"./lexical-B-vxEaRQ.js";import"./pdf-B1uD4Ovv.js";import"./utils-CrhrpmD8.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new t.Error().stack;r&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[r]="61f61cec-a0b5-4e86-a6fc-4a97e751fbd9",t._sentryDebugIdIdentifier="sentry-dbid-61f61cec-a0b5-4e86-a6fc-4a97e751fbd9")}catch{}})();const Ws=["claimed","running","succeeded","failed","timeout"],fe=t=>typeof t=="string"&&t!=="",Je="chat-response-generated";function Ys(t,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 h=R(t).skills.find((s=>s.macroId===r.savedMacroId));return h==null?void 0:{status:"saved",command:h.name}}const Ks=Ft((function(t,r){const h=F(t),s=r.isSubmitting,d=h.uiState?.currentChatSessionId,l=d!=null?xs(t.aiCfoState,d):[],i=ns(t,{allUsers:r.allUsers,onCardPolicyVendorSearchTextChange:r.onCardPolicyVendorSearchTextChange}),g=Rs(t),p=Ts(t),f=Os(t);return{showSampleQuestions:r.sessionFromUrl==="explore"&&h.uiState.currentChatSessionId==null,aiCfoView:h,isSubmitting:s,isNewChatSession:r.sessionFromUrl==="new_chat"||r.sessionFromUrl==="explore",isFullView:!0,tableDownloadEndPoint:`${as}/tableDownload`,exportDownloadEndPoint:rs(),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:R(t).skills,skillSaveState:Ys(t,f),skillsEnabled:R(t).skillsEnabled,skillsList:R(t).skills,skillsListError:R(t).fetchState==="Error",skillsListLoading:R(t).fetchState==="In-Progress",skillsCanPublish:R(t).canPublish,skillSaving:f.fetchState==="In-Progress",skillSaveError:f.fetchState==="Error",skillVersionHistory:g.macroId!=null?{macroId:g.macroId,versions:g.versions,error:g.fetchState==="Error",loading:g.fetchState==="In-Progress"}:void 0,skillRestoreBody:p.macroId!=null&&p.version!=null?{macroId:p.macroId,version:p.version,instructions:p.instructions,error:p.fetchState==="Error",loading:p.fetchState==="In-Progress"}:void 0,skillDetail:J(t).detail,skillDetailError:J(t).fetchState==="Error",skillDetailLoading:J(t).fetchState==="In-Progress",syntheticAnswers:l,resolveSyntheticAnswerCardTile:is(t),resolveSyntheticAnswerPolicyTile:os(t),...i}}),(function(t,r){const{location:h,currentTenant:s,userId:d,navigate:l,currentChatSessionId:i,allSessionsWithOrderedQuestionAnswers:g,isAiCardCreationEnabled:p,isCardPolicyEnabled:f,setIsAiCfoOpen:U}=r,V=s.tenantEmailDomain;return{onEventReceived:(a,o)=>{if(a===Je&&typeof o.text=="string"&&typeof o.metadata=="object"){const c=o,O=Us(c.type),E=c.metadata.chat_session_id??null,{currentChatSession:j,currentQuestionAnswer:G,currentQuestionAnswerSummary:A}=Ye(g,E);O!=="answer"?M.trackAICFOChatResponseGenerated(O,G?.question.questionText??"",c.text,E,ds(A,j),c.metadata.message_id??null):M.trackAICFOChatAnswerGenerated(c.text,G?.question.questionText??"",(c.follow_up_questions?.length??0)>0,!!c.assumptions,!!c.insights,c.visualization!=null,Vs(c.visualization?.type??"")??null,E,c.summarized_title,c.metadata.message_id??null),t(Bs({chatSessionId:c.metadata.chat_session_id,responseType:O,fetchState:{fetchState:"Completed",error:void 0}})),t(Fs({chatSessionId:c.metadata.chat_session_id,answerPayload:c,userId:d}))}},onSubmit:(a,o,c,O,E)=>{a&&Be(t,a,o,i,g,d,O,c,void 0,E)},onFetchSkills:()=>{t(Ke())},onOpenSkill:a=>{t(Ie({macroId:a})),t(Ls({macroId:a}))},onSaveSkill:(a,o)=>{t(qe({draft:a,macroId:o}))},onSaveSkillDraft:a=>{const o=a.displayName?.trim()??"",c=a.name?.trim()??"";t(qe({draft:{name:o.length>0?o:c,description:a.description?.trim()??null,instructions:a.instructions,visibility:"private"}}))},onFetchSkillVersionBody:(a,o)=>{t(Qs({macroId:a,version:o}))},onDeleteSkill:a=>{t(Ds({macroId:a}))},onSetSkillVisibility:(a,o)=>{t(_s({macroId:a,visibility:o}))},onCloseSkillDetail:()=>{t(He())},onRunSkill:(a,o)=>{t($()),t($e()),Be(t,o,"user_input",void 0,g,d,void 0,void 0,void 0,a),t(He())},updateCurrentInput:a=>{t(Ge(a))},onStopSubmit:()=>{},onUpdateScrollYOffset:a=>{t(As(a))},onSelectSampleQuestion:()=>{},onBackClick:()=>{l(-1)},onCloseClick:()=>{const a=ge(h.state?.pathnameStackToGoBack),o=a.poppedPathname??Hs(1);l(o,{state:{...h.state,pathnameStackToGoBack:a.newStack}}),t(Ge(""))},togglePageView:()=>{const a=ge(h.state?.pathnameStackToGoBack),o=a.poppedPathname??`/${s.tenantEmailDomain}/dashboard`;l(o,{state:{...We(h.state),pathnameStackToGoBack:a.newStack,message:"open_ai_cfo_drawer"}}),U(!0)},onCopy:()=>{},onThumbsUp:(a,o)=>{i!=null&&o?.messageId!=null&&t(Ne(i,o.messageId,"positive",o.questionText,o.answerText))},onThumbsDown:(a,o)=>{i!=null&&o?.messageId!=null&&t(Ne(i,o.messageId,"negative",o.questionText,o.answerText))},onTogglePageView:()=>{l(-1)},onNewChatClick:()=>{t($()),i!=null&&t($e());const a=us(h.state?.pathnameStackToGoBack,h.pathname);l(`/${s.tenantEmailDomain}/ai-cfo/new_chat`,{state:{pathnameStackToGoBack:a.slice(0,-1),referrer:"Sidebar"}})},onToggleCotCollapsed:(a,o)=>{t(js({questionAnswerId:a,isCollapsed:o}))},onMenuClick:r.onMenuClick,...ls(t,{isAiCardCreationEnabled:p,isCardPolicyEnabled:f,currentChatSessionId:i,onAfterCardsCreationSubmit:()=>{U(!0),l(`/${V}/cards`,{state:{...h.state}})},onAfterCardPolicySubmit:()=>{U(!0),l(`/${V}/cards/policy`,{state:{...h.state}})}})}}))(ts(ss)),bn=({isFileUploadEnabled:t})=>{const r=Mt(),{setIsAiCfoOpen:h}=$t(),s=Lt(),d=Ut(),{session_id:l}=Vt(),i=Bt(),g=new URLSearchParams(i.search).get("routine")??void 0,[p,f]=n.useState(!1),U=v((e=>F(e).uiState.isSkillsBrowserOpen===!0)),V=v((e=>R(e).skillsEnabled)),a=v((e=>F(e).uiState.isRoutinesBrowserOpen===!0)),o=v((e=>cs(e))),c=v((e=>ms(e))),O=v((e=>Ss(e))),[E,j]=n.useState(void 0),[G,A]=n.useState(!1),[Xe,Ce]=n.useState(void 0),Ze=n.useCallback((()=>{Ce(void 0),j(void 0),A(!0)}),[]),et=n.useCallback((e=>{j(e),A(!0)}),[]),tt=n.useCallback((()=>{j(void 0),A(!1)}),[]),st=n.useCallback((e=>{s(hs({draft:e,...E!=null&&{scheduleId:E.scheduleId}})),j(void 0),A(!1)}),[s,E]),P=g,ke=o.routines.find((e=>e.scheduleId===P)),C=v((e=>ps(e))),nt=n.useCallback((e=>{s(fs({scheduleId:e.scheduleId}))}),[s]);n.useEffect((()=>{s(P!=null?K({scheduleId:P}):Se())}),[s,P]);const B=ke?.macroId,at=v((e=>J(e))),be=B!=null&&B!==""&&at.fetchState==="Not-Started";n.useEffect((()=>{be&&B!=null&&s(Ie({macroId:B}))}),[s,be,B]);const ot=v((e=>F(e).uiState.currentChatSessionId))??l,k=o.routines.find((e=>e.scheduleId===g))??o.routines.find((e=>e.scheduleId===Nt(ot))),T=k?.scheduleId??null,[ve,it]=n.useState(!0);n.useEffect((()=>{T!=null&&s(K({scheduleId:T}))}),[s,T]);const Ee=C.runs.some((e=>e.status==="claimed"||e.status==="running"))===!0;n.useEffect((()=>{if(P==null||Ee!==!0)return;const e=window.setInterval((()=>{s(K({scheduleId:P})),s(he())}),5e3);return()=>window.clearInterval(e)}),[s,Ee,P]);const rt=n.useCallback((e=>{Ce(e),j(void 0),A(!0)}),[]),lt=n.useCallback((e=>{s(gs({scheduleId:e.scheduleId}))}),[s]),ut=n.useCallback(((e,m)=>{s(Is({enabled:m,scheduleId:e.scheduleId}))}),[s]);n.useEffect((()=>{a&&s(he())}),[s,a]);const Pe=v((e=>R(e).skills)),X=n.useMemo((()=>Pe.map((e=>({macroId:e.macroId,name:e.displayName??e.name})))),[Pe]),dt=n.useCallback((e=>{s(Ie({macroId:e}))}),[s]),Z=n.useCallback((()=>{s(Ke()),s(Fe())}),[s]),ct=n.useCallback((()=>{s($())}),[s]),{allUsers:mt,isAiCardCreationEnabled:St,isCardPolicyEnabled:ht,onCardPolicyVendorSearchTextChange:pt}=Gt();n.useEffect((()=>{s(Cs())}),[s]);const I=v((e=>F(e))),y=Ht.getSignedInUser();n.useEffect((()=>l==="routines"?(s($()),void s(ks())):l==="skills"?(s(Se()),s(Me()),void s(Fe())):(T==null&&s(Se()),s(Me()),void s($()))),[s,T,g,l]);const ft=qt(),_=Zt(ft),b=v((e=>bs(e))),u=I.uiState.currentChatSessionId,w=b.tenantEmailDomain,L=w!=null&&w!=="",ee=n.useCallback((e=>{L&&d(`/${w}/ai-cfo/routines?routine=${encodeURIComponent(e.scheduleId)}`)}),[L,d,w]),te=n.useCallback((()=>{L&&d(`/${w}/ai-cfo/routines`)}),[L,d,w]),se=n.useCallback(((e,m)=>{const D=e.sessionId??C.sessionId;D!=null&&L&&d(`/${w}/ai-cfo/${D}?routine=${encodeURIComponent(m)}`)}),[L,d,C.sessionId,w]),gt=n.useMemo((()=>k==null?void 0:{error:C.fetchState==="Error",kind:"routineRuns",loading:C.fetchState==="In-Progress"||C.fetchState==="Not-Started",routineName:k.name,schedule:zt(k),skillName:k.isAdHoc===!0?void 0:X.find((e=>e.macroId===k.macroId))?.name,onOpenSkill:k.isAdHoc===!0?void 0:Z,runs:C.runs,tzName:k.tzName,unreadCount:k.unreadRuns,open:ve,onToggle:()=>it((e=>!e)),onOpenRun:e=>se(e,k.scheduleId),onOpenRoutine:()=>ee(k),onOpenRoutines:te}),[Z,te,ee,se,ve,k,C.fetchState,C.runs,X]),{handleUploadPromoClose:It,isUploadPromoVisible:Ct}=Wt({isFileUploadEnabled:t,tenantEmailDomain:w}),ne=Yt({currentTenant:b,currentChatSessionId:u,aiCfoView:I,skillsEnabled:V,onCloseSkills:ct,onOpenSkills:Z}),{isSuggestedQuestionsLoading:kt,suggestedPromptQuestions:bt}=Gs(),H=i.state,q=H?.aiCfoInitialQuestion,we=!!H?.aiCfoShouldSubmit;n.useEffect((()=>{const e=i.state;if(e?.[Ve]!==!0)return;f(!0);const m={...e};delete m[Ve],d(i,{replace:!0,state:m})}),[i.pathname,i.search,i.state,d]);const[vt,ae]=n.useState(null),[Et,oe]=n.useState(!1),[Pt,ie]=n.useState(void 0),[wt,re]=n.useState(void 0),ye=n.useRef(!1);n.useEffect((()=>{if(!ye.current&&q!=null&&q!==""){const e=i.state;ae(q),oe(we),ie(e?.aiCfoInitialSubmissionSource!=null?e.aiCfoInitialSubmissionSource:void 0);const m=e?.aiCfoSuggestionIndex;re(typeof m=="number"?m:void 0),ye.current=!0}}),[q,we,i.state]);const yt=n.useCallback((()=>{ae(null),oe(!1),ie(void 0),re(void 0),d(i.pathname,{replace:!0,state:We(i.state)})}),[i.pathname,i.state,d]),xe=n.useMemo((()=>new URLSearchParams(i.search)),[i.search]),Re=xe.get("ref")??H?.aiCfoRef,le=xe.get("emailRefId")??H?.aiCfoEmailRefId,Te=n.useRef(!1);n.useEffect((()=>{Te.current||Re!=="month-end-email"||le==null||u!=null||y==null||(s(vs("controller",y.userId,le,"MONTH_END_EMAIL")),Te.current=!0)}),[Re,le,u,s,y]);const z=I.uiState.lastContextMessage;n.useEffect((()=>{z!=null&&z!==""&&u!=null&&(ae(z),oe(!0),ie(void 0),re(void 0),s(Es()))}),[z,u,s]);const xt=b.masterTOSInfo,x=xt?.isMasterTOSAccepted??!1,{visitedSessions:Oe}=Kt(u),W=I.fetchState,Y=I.uiState.chatSessionsNextPageToken.hasMore||!I.uiState.chatSessionsFirstPageFetched,je=u!=null?I.fetchChatSessionHistoryByChatSessionId?.[u]?.fetchState??"Not-Started":"Not-Started",Ae=u==null||(I.uiState.chatHistoryNextPageToken[u]?.hasMore??!0),_e=I.allSessionsWithOrderedQuestionAnswers,{currentSessionQuestionAnswers:Rt}=Ye(_e,u),Tt=Rt.length===0;n.useEffect((()=>{x||_||d("../dashboard",{state:{...i.state,message:"open_ai_cfo_drawer"}})}),[x,_,d,i.state]);const Ot=n.useCallback((()=>{const e=ge(i.state?.pathnameStackToGoBack),m=b.tenantEmailDomain;d(e.poppedPathname??(m!=null?`/${m}/dashboard`:".."),{state:{...i.state,pathnameStackToGoBack:e.newStack}})}),[b.tenantEmailDomain,i.state,d]),De=n.useRef(void 0),Qe=n.useRef(void 0);n.useEffect((()=>{const e=l!==De.current,m=u!==Qe.current;De.current=l,Qe.current=u,l!==u&&(!e||l==null||qs(l)?m&&u!=null&&d(`../ai-cfo/${u}`,{state:{...i.state}}):s(Ps({sessionId:l,agentId:"controller"})))}),[u,l]);const jt=n.useMemo((()=>({events:Oe.map((e=>`private-encrypted-chat-${e}.${Je}`)),eventCallback:(e,m,D)=>D.onEventReceived(e,m)})),[Oe]);n.useEffect((()=>{W!=="In-Progress"&&Y&&s(ws())}),[W,Y,s]),n.useEffect((()=>{u!=null&&je!=="In-Progress"&&Ae&&y!=null&&(l===u||W==="Completed"&&!Y)&&s(ys(u,y.userId))}),[je,W,Ae,Y,u,y,l,s]);const ue=y?.userId,At=n.useMemo((()=>{return ue==null?[]:[(e=ue,`private-encrypted-routines-${e}.routine-run-updated`)];var e}),[ue]),Le=n.useCallback((e=>{const m=e!=null&&(e===P||e===T);(a||m)&&s(he()),m&&s(K({scheduleId:e}))}),[s,a,T,P]);zs({events:At,onSubscribed:()=>Le(P??T),onEvent:(e,m)=>{const D=(de=>{if(de==null||typeof de!="object")return null;const Q=de;return fe(Q.schedule_id)&&fe(Q.run_id)?{scheduleId:Q.schedule_id,runId:Q.run_id,status:Ws.find((Qt=>Qt===Q.status))??null,finishedAt:fe(Q.finished_at)?Q.finished_at:null}:null})(m);D!=null&&Le(D.scheduleId)}});const Ue=e=>e.trackAICFOOnboardingScreenStateChanged("open","first_visit");if(y==null||l==null)throw Error("Can't access AI Controller page without signing in...");const _t=u!=null&&I.responseStateByChatSessionId?.[u]?.answer?.fetchState==="In-Progress";if(!x&&_)return S.jsxs(Xs,{children:[S.jsx(ce,{analytics:M,onLoad:Ue}),ne.drawerElement,S.jsx(Zs,{children:S.jsx(ze,{children:S.jsx(me,{isTOSAccepted:!1,acceptMasterTOSState:I.masterTOSAcceptanceState,onCloseClick:Ot,onCompleteClick:()=>{b.userRoleId!=null&&s(pe(b.userRoleId))}})})})]});const Dt=S.jsxs(S.Fragment,{children:[p&&!x?S.jsx(ce,{analytics:M,onLoad:Ue}):null,S.jsx(me,{isTOSAccepted:x,acceptMasterTOSState:I.masterTOSAcceptanceState,showHeader:!1,togglePageView:x?()=>f(!1):void 0,onCloseClick:()=>f(!1),onCompleteClick:()=>{x||b.userRoleId==null||s(pe(b.userRoleId)),f(!1)}})]});return S.jsxs(S.Fragment,{children:[S.jsxs(Js,{children:[S.jsx(ce,{analytics:M,onLoad:e=>e.trackPageLoaded(es.Event.aiCFOPage)}),_&&ne.drawerElement,S.jsx(Ks,{answerExportEndPoint:r,...jt,currentChatSessionId:u,allSessionsWithOrderedQuestionAnswers:_e,allUsers:mt,isAiCardCreationEnabled:St,isCardPolicyEnabled:ht,openOnboardingPage:()=>f(!0),userId:y.userId,setIsAiCfoOpen:h,navigate:d,sessionFromUrl:l,location:i,isSubmitting:_t,isEmptyChatWithSession:Tt,currentTenant:b,emailLinkQuestion:vt??void 0,autoSubmitEmailLinkQuestion:Et,onEmailLinkQuestionProcessed:yt,routedInitialQuestionSource:Pt,routedInitialQuestionSuggestionIndex:wt,onCardPolicyVendorSearchTextChange:pt,onMenuClick:_?ne.open:void 0,isFileUploadEnabled:t,isUploadPromoVisible:Ct,onUploadPromoClose:It,exploreSuggestedPromptQuestions:bt,exploreSuggestedPromptQuestionsLoading:kt,isSkillsOpen:U,isRoutinesOpen:a,routineCanCreate:O,routineEditing:E,routineEditorOpen:G,routineListError:o.fetchState==="Error",routineListLoading:o.fetchState==="In-Progress",routineMaxRoutines:o.maxRoutines,routineSaveError:c.fetchState==="Error",routineSaving:c.fetchState==="In-Progress",routineSchedulableSkills:X,routines:o.routines,onRoutineCreate:Ze,onRoutineDelete:lt,routineHistoryError:C.fetchState==="Error",routineHistoryLoading:C.fetchState==="In-Progress",chatSidePanel:gt,routineDetail:ke,routineRunningScheduleId:c.runningScheduleId,routineRuns:C.runs,onRoutineEdit:et,onRoutineOpenRun:(e,m)=>se(m,e.scheduleId),onRoutineRun:nt,onRoutineCloseDetail:te,onRoutineDraft:rt,routineDraftPrompt:Xe,onRoutineOpenDetail:ee,onRoutineEditorCancel:tt,onRoutineLoadSkillInstructions:dt,onRoutineSave:st,onRoutineSetEnabled:ut,isCreateSkillEnabled:V,promoDismissalScope:w}),p&&_?S.jsx(Ms,{anchor:"right",open:p,transitionDuration:250,PaperProps:{component:en,style:{width:"100%"}},slotProps:{backdrop:{style:{backgroundColor:"transparent",cursor:"pointer"}}},onClose:()=>f(!1),children:S.jsx(ze,{onClick:e=>e.stopPropagation(),children:S.jsx(me,{isTOSAccepted:x,acceptMasterTOSState:I.masterTOSAcceptanceState,onCloseClick:()=>f(!1),onCompleteClick:()=>{x||b.userRoleId==null||s(pe(b.userRoleId)),f(!1)}})})}):null]}),p&&!_?S.jsx(Jt,{open:p,onClose:()=>f(!1),children:S.jsx(Xt,{children:Dt})}):null]})},ze=N($s)`
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-BLpmr1Pv.js";import{a as o,R as $a}from"./sentry-DWNq3t8E.js";import{u as Fe,j as r,g as Ba,h as xa,q as H}from"./core-CbdTrw7T.js";import{fJ as Ze,V5 as Va,V6 as Ge,gd as Aa,gz as K,V7 as ee,jQ as ye,jo as Te,V8 as _a,V9 as Da,gT as Ma,qt as Fa,Va as Za,Vb as $e,gq as Ga,Vc as x,fI as Ra,gx as ja,Vd as Ha,Ve as La,Vf as Pa,Vg as Be,Vh as Na,Vi as xe,Vj as Oa,E$ as Ua,gr as qa,h6 as za,cO as Ya,Vk as Ja,h9 as Qa,r4 as Wa,gc as Xa,ji as Ka,Vl as et,Vm as at,x8 as tt,gs as nt}from"./zeni-epic-state-C5DO1jkr.js";import{w as ot,f as st,g as rt,j as it,p as lt,_ as m,k as dt,u as ct,a as ut,h as mt,m as Ct,i as pt,q as ht,n as ft,o as gt,z as bt,c as L,s as h,v as Ve,x as St,y as kt,A as Ae,B as Et,X as _e,C as wt,Y as It,D as te,E as ae,F as vt,H as yt,I as Tt,L as $t,J as Bt,M as xt,N as Vt,O as At}from"./index-CnIO6_IQ.js";import{u as _t,q as Dt,r as Mt,I as Ft,p as De,t as Zt,D as Me,s as ne}from"./mui-DNGY4bFU.js";import{u as Gt}from"./InboxNotificationsProvider-CiKEEv6Q.js";import{u as Rt}from"./useTaskManagerAccess-Cm5trA3i.js";import{u as jt}from"./useIsCustomersTabEnabled-C6mkabn2.js";import{u as Ht}from"./expenseAutomationHelper-CgTsmmCm.js";import"./recharts-CTh_JhT_.js";import"./analytics-Vgn85Ur_.js";import"./plaid-DhfTjhua.js";import"./dnd-DuiAlI7w.js";import"./stripe-cKAAJElX.js";import"./lottie-Lb1ftKY1.js";import"./lexical-B-vxEaRQ.js";import"./pdf-B1uD4Ovv.js";import"./utils-CrhrpmD8.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]="755fcc74-3289-455e-967e-d7c6d9394a60",a._sentryDebugIdIdentifier="sentry-dbid-755fcc74-3289-455e-967e-d7c6d9394a60")}catch{}})();const V="AppDrawer",c={root:`${V}-root`,drawer:`${V}-drawer`,appBar:`${V}-appBar`,menuButton:`${V}-menuButton`,appBarZenilogo:`${V}-appBarZenilogo`,drawerZenilogo:`${V}-drawerZenilogo`},Lt=ne("div",{slot:"Root"})((({theme:a})=>({[`&.${c.root}`]:{display:"flex"},[`& .${c.drawer}`]:{[a.breakpoints.up("md")]:{width:te,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"}}))),Pt=ot((function({tenantEmailDomain:a}){const{isAiCfoOpen:C,setIsAiCfoOpen:S}=rt(),[P,A]=$a.useState(!1),[k,Re]=o.useState(!1),t=Ba(),s=xa(),oe=Aa(),se=it(),n=Fe(),[je,He]=o.useState(!1),N=_t(),re=t.pathname.includes("/ai-cfo/");o.useEffect((()=>{re||(n(K()),n(ee()))}),[n,re]),o.useEffect((()=>{n(K()),n(ee())}),[n,a]);const{useFeatureGate:u}=lt(),{isFeatureEnabled:ie}=u(m.isDebitCardFeatureEnabled),E=dt(),i=r((e=>Ze(e))),O=i.masterTOSInfo?.isMasterTOSAccepted??!1,{setLoading:Le}=ct(),w=ut(),{isTaskManagerAccessEnabled:_,isZeniUser:Pe}=Rt(E),le=mt(),I=Ct(),D=(function(e=2e3){const[l,p]=o.useState(!1);return o.useEffect((()=>{if(l)return;const B=window.requestIdleCallback;if(B==null){const X=window.setTimeout((()=>p(!0)),e);return()=>window.clearTimeout(X)}const R=B((()=>p(!0)),{timeout:e});return()=>{window.cancelIdleCallback?.(R)}}),[e,l]),l})();o.useEffect((()=>{D&&I&&w&&(n(ye()),n(Te()))}),[n,D,I,i.tenantId,w]);const[U,Ne]=o.useState(void 0),Oe=!!i.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:Ue}=u(m.isChargeCardFeatureEnabled),qe=pt(i,Ue,ie),{isFeatureEnabled:ze}=u(m.isSettingsFeatureEnabled),{isFeatureEnabled:M}=u(m.isReferralFeatureEnabled),Ye=i.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",de=r((e=>_a(e)));o.useEffect((()=>{const e=()=>{He(window.scrollY>10)};return window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}}),[]);const q=r((e=>Da(e))),f=r((e=>e.expenseAutomationViewState.selectedPeriodByTenantId)),g=r((e=>Ma(e))),{monthEndCloseChecksView:v}=g,Je=H("/signout")!==null,F=H("/:tenantEmailDomain/dashboard")!==null,ce=H("/:tenantEmailDomain/reports")!==null,b=H("/:tenantEmailDomain/onboarding/*")!==null,ue=Ht();o.useEffect((()=>{D&&I&&M&&!b&&q.fetchState==="Not-Started"&&n(Fa(!0))}),[D,I,M,q.fetchState,b]),o.useEffect((()=>{if(ue){const e=t.state?.origin;if(e!=null){const l=Za(e);l!=null&&n($e(l))}}}),[ue,t.state]);const Qe=Je||b,z=r((e=>e.tenantState)),We=r((e=>z.fetchState==="Completed"?Ga(e):[])),{isFeatureEnabled:Xe}=u(m.isApAgingFeatureEnabled),{isFeatureEnabled:Ke}=u(m.isArAgingFeatureEnabled),{isFeatureEnabled:ea}=u(m.isDashboardSidebarHalloweenAnimationEnabled),{isFeatureEnabled:aa}=u(m.isDashboardSidebarThanksGivingAnimationEnabled),{isFeatureEnabled:ta}=u(m.isDashboardSidebarChristmasAnimationEnabled),{isFeatureEnabled:na}=u(m.isDashboardSidebarNewYearAnimationEnabled),oa=r((e=>x(e).totalUnreadCount)),sa=r((e=>x(e).notificationDetailsByTab.tasks.uiState.unreadCount)),ra=r((e=>x(e).notificationDetailsByTab.comments.uiState.unreadCount)),ia=r((e=>x(e).reducedFetchCountState)),me=r((e=>x(e).notificationDetailsByTab.tasks.fetchCountState)),Y=r((e=>Ra(e))),la=r((e=>ja(e).skillsEnabled)),da=r((e=>Ha(e))),Ce=r((e=>La(e).routines)),ca=o.useMemo((()=>Ce.filter((e=>e.sessionId!=null)).map((e=>({cadence:ht(e),name:e.name,scheduleId:e.scheduleId,sessionId:e.sessionId,unreadRuns:e.unreadRuns})))),[Ce]),ua=new URLSearchParams(t.search).get("routine")??ft(t.pathname.split("/ai-cfo/")[1])??void 0,ma=o.useCallback(((e,l)=>{s(l!=null&&l!==""?`/${a}/ai-cfo/${encodeURIComponent(l)}`:`/${a}/ai-cfo/routines?routine=${encodeURIComponent(e)}`)}),[s,a]),{status:pe}=r(Pa),[y,J]=o.useState(void 0),Q=Y.uiState.currentChatSessionId,Z=y!=null?Y.deleteChatSessionStateByChatSessionId[y]?.fetchState:void 0,he=gt(Z),{inboxNotifications:W,isLoading:fe,isFetchingMore:ge,hasFetchedAll:be,fetchMore:Ca}=Gt(),G=r((e=>x(e).notificationDetailsByTab.comments.fetchCountState));o.useEffect((()=>{const e=setTimeout((()=>Ca?.()),0);return()=>clearTimeout(e)})),o.useEffect((()=>{if(y!=null)return he==="In-Progress"&&Z==="Completed"?(n(Be({chatSessionId:y})),J(void 0),void s(`/${a}/ai-cfo/explore`,{state:{...t.state,referrer:"Sidebar"}})):void(Z==="Error"&&(n(Be({chatSessionId:y})),J(void 0)))}),[n,t.state,s,Z,y,he,a]),o.useEffect((()=>{if(fe===!1&&ge===!1&&be===!0&&i?.companyId!=null&&W!=null){const e=`dashboard_${i.companyId}`;Ne(W.filter((l=>l.roomId===e&&l.readAt==null)).length)}}),[fe,ge,be,i?.companyId,W]),o.useEffect((()=>{I&&_&&!b&&me.fetchState==="Not-Started"&&oe.tenantId!=null&&n(Na("task_manager","dashboard"))}),[I,_,b,me.fetchState,oe.tenantId,n]),o.useEffect((()=>{b||G.fetchState!=="Not-Started"||n(xe({fetchCountState:{fetchState:"In-Progress",error:void 0}},"comments"))}),[b,G.fetchState,n]),o.useEffect((()=>{if(U!=null){const{fetchState:e}=G;e!=="In-Progress"&&e!=="Completed"||(e==="In-Progress"&&n(xe({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),n(Ge({unreadCount:U},"comments")))}}),[U,G.fetchState]);const pa={fetchStatus:ia,count:oa},T=[];Xe===!1&&T.push("accounts_payable_aging"),Ke===!1&&T.push("accounts_receivable_aging"),T.push("zeni_accounts_promo_card","treasury_promo_card"),M===!1&&T.push("rewards_card"),le===!1&&T.push("expense_automation_card");const Se=r((e=>Oa(e,T).fetchState)),ke=r((e=>Ua(e).fetchState)),Ee=a!=null?bt.getSignedInUserTenant(a):null,we=r((e=>Ee?.tenantId!=null?qa(e,Ee.tenantId):void 0)),ha=F&&(Se==="Completed"||Se==="Error")||ce&&(ke==="Completed"||ke==="Error")||!F&&!ce?void 0:"disabled",fa=o.useMemo((()=>za(i.userRole)),[i.userRole]),ga=Ya(fa),ba=jt(),$=e=>{A(e)},Sa=Ye,ka=i?.rewardsLastViewedTime==null,Ea=E?.userEmail!=null&&de.fetchState==="Completed"&&Ja(de.notificationSettings,E.userEmail,ie,i,_),wa=o.useCallback((e=>{const l=t.state?.referrer;if(v.monthEndCloseChecks?.auditSummary!=null&&L.trackMonthCloseAuditPage(e.month,e.year,v.monthEndCloseChecks.reportEmailSentDate!=null?"closed":"in-review",v.monthEndCloseChecks.auditSummary.auditScorePercentage,!1,l??null),n(Qa(i.tenantId,e)),f[i.tenantId]!=null){const p=h(t.state?.pathnameStackToGoBack,t.pathname);s(`/${a}/month_end_close_checks/review/${g.currentSelectedView}/${e.month}-${e.year}`,{state:{pathnameStackToGoBack:p,referrer:g.currentSelectedView}})}n($e(g.currentSelectedView)),g.reconciliation.selectedAccountId!=null&&n(Wa({selectedAccountId:void 0}))}),[g.reconciliation.selectedAccountId,g.currentSelectedView,i.tenantId,v.monthEndCloseChecks?.auditSummary,v.monthEndCloseChecks?.reportEmailSentDate,f,a,t.state,t.pathname]),Ia=o.useMemo((()=>({zIndex:k?12:Ve[2]})),[k]),va=w&&St(t),Ie=d.jsx(kt,{signedInUser:E,currentTenantId:z.currentTenantId??"",tenants:z.fetchState==="Completed"?We:we!=null?[we]:[],rewardsConfiguration:{isRewardsTabVisible:M,isRewardsAnimated:ka,rewardsPlan:q.rewardsPlan},selectedMenu:C===!0?_e("ai_cfo"):Ae(t)&&pe!=="completed"?_e("invoicing"):wt(t),isTenantDropdownDisabled:ha,isSettings:Et(t),isInvoicing:Ae(t)&&pe==="completed",isSettingsFeatureEnabled:ze,currentTenant:i,isVendorsTabVisible:ga,isCustomersTabVisible:ba,isZeniAccountEnabled:Oe,isChargeCardEnabled:qe,isTreasuryEnabled:Sa,isNotificationsTabVisible:Ea,notificationCountDetails:pa,isExpenseAutomationEnabledForUser:le,isAiCfoAccessEnabled:w,skillsEnabled:la&&w,routinesEnabled:da===!0&&w,routines:ca,selectedRoutineId:ua,onRoutineSelect:ma,onNotificationIconClick:()=>{$(!1);const e=Pe?sa===0&&ra>0?"notifications/comments":"notifications/tasks":"notifications/comments",l=h(t.state?.pathnameStackToGoBack,t.pathname);s(`${a}/${e}`,{state:{pathnameStackToGoBack:l}})},onZeniLogoClick:()=>{se.toggle()},handleTenantSelect:e=>{Le($t.TENANT_SWITCHING),$(!1),Bt({dispatch:n,navigate:s,pathToNavigate:xt(e.tenantEmailDomain,t),selectedTenant:e,signedInUser:E})},handleMenuChange:(e,l)=>{if(E!=null&&L.trackSidePanelClicked(e.type,e.group),$(!1),a==null)return;if(e.type==="routines")return O?(n(Te()),n(et()),void s(`/${a}/ai-cfo/routines`,{state:{pathnameStackToGoBack:h(t.state?.pathnameStackToGoBack,t.pathname),referrer:"Sidebar"}})):void ae({location:t,navigate:s,mergeState:{referrer:"Sidebar"}});if(e.type==="skills")return O?(n(ye()),n(at()),void s(`/${a}/ai-cfo/skills`,{state:{pathnameStackToGoBack:h(t.state?.pathnameStackToGoBack,t.pathname),referrer:"Sidebar"}})):void ae({location:t,navigate:s,mergeState:{referrer:"Sidebar"}});if(n(K()),n(ee()),e.type==="invoicing")return C&&S(!1),n(tt({cacheOverride:!1})),void s(`../${a}/invoicing/overview`,{state:{pathnameStackToGoBack:h(t.state?.pathnameStackToGoBack,t.pathname),referrer:"Sidebar"}});if(C&&vt(e.type)&&S(!1),e.type==="ai_cfo"){if(L.trackAICFOChatScreenStateChanged("viewed","left_menu",Q??null,null),!O)return void ae({location:t,navigate:s,mergeState:{referrer:"Sidebar"}});const j=h(t.state?.pathnameStackToGoBack,t.pathname);return void s(`/${a}/ai-cfo/explore`,{state:{pathnameStackToGoBack:j,referrer:"Sidebar"}})}const p=h(t.state?.pathnameStackToGoBack,t.pathname),B=e.type,R=At(B)&&B!=="command_center";if(B!=="command_center"&&!R||f[i.tenantId]==null||L.trackMonthEndCloseClicked(f[i.tenantId].month,f[i.tenantId].year,"Sidebar"),R&&f[i.tenantId]!=null){const j=f[i.tenantId];return void s(`/${a}/month_end_close_checks/review/${e.type}/${j.month}-${j.year}`,{state:{pathnameStackToGoBack:p,message:l,referrer:"Sidebar"}})}const X=yt(e.type);Tt(e.type)?(Q!=null&&n(nt()),s(`/${a}/ai-cfo/${e.type}`,{state:{pathnameStackToGoBack:p.slice(0,-1),message:l,referrer:"Sidebar"}})):s(`../${a}/${X}`,{state:{pathnameStackToGoBack:p,message:l,referrer:"Sidebar"}})},onDeleteChatSession:e=>{n(Ka(e)),Q===e&&J(e)},handleLogOutClick:()=>{$(!1);const e=h(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:v,onPeriodChange:wa,onCalendarOpen:Re,aiCfoView:Y,isAiCfo:va,isOnDashboard:F,isTaskManagerAccessEnabled:_,updateCurrentChatSessionId:e=>{n(Xa({sessionId:e,agentId:"controller"})),s(`../${a}/ai-cfo/${e}`,{state:{...t.state}})},halloweenAnimationEnabled:ea,thanksGivingAnimationEnabled:aa,christmasAnimationEnabled:ta,newYearAnimationEnabled:na}),ya=d.jsx(Dt,{position:"fixed",className:c.appBar,style:{borderBottom:je?`1px solid ${N.colors.grey2}`:""},children:d.jsxs(Mt,{style:{minHeight:It},children:[d.jsx(Ft,{color:"inherit","aria-label":"open drawer",edge:"start",onClick:()=>$(!0),className:c.menuButton,size:"large",children:d.jsx(Nt,{})}),d.jsx(Ot,{className:c.appBarZenilogo,onClick:()=>{se.toggle()}})]})}),ve=De((e=>e.breakpoints.up("md"))),Ta=De((e=>e.breakpoints.down("md")));return a==null?null:d.jsxs(Lt,{className:c.root,children:[d.jsx(Zt,{}),Qe===!1?d.jsxs(d.Fragment,{children:[ve||!F?null:ya,d.jsxs("nav",{className:c.drawer,children:[ve?null:d.jsx(Me,{container:window.document.body,variant:"temporary",open:P,onClose:()=>$(!1),PaperProps:{sx:{width:te,zIndex:Ve[2],borderRight:"none",backgroundImage:"none",backgroundColor:N.colors.background}},ModalProps:{keepMounted:!0},children:Ie}),Ta?null:d.jsx(Me,{PaperProps:{sx:{width:te,borderRight:"none",backgroundImage:"none",backgroundColor:N.colors.background,...Ia}},variant:"permanent",open:!0,children:Ie})]})]}):null]})})),c1=({tenantEmailDomain:a})=>{const C=Fe(),S=r((A=>Ze(A))),P={events:S.userRoleId!=null?[`private-encrypted-${S.userRoleId}.dashboard-user-notification`]:[],eventCallback:(A,k)=>{st(k)&&Va(k.mode)==="dashboard"&&C(Ge({unreadCount:k.data.unread},"tasks"))}};return d.jsx(Pt,{tenantEmailDomain:a,...P})},Nt=ne((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-BLpmr1Pv.js";import{a as o,R as $a}from"./sentry-DWNq3t8E.js";import{u as Fe,j as r,g as Ba,h as xa,q as H}from"./core-CbdTrw7T.js";import{fJ as Ze,V5 as Va,V6 as Ge,gd as Aa,gz as K,V7 as ee,jQ as ye,jo as Te,V8 as _a,V9 as Da,gT as Ma,qt as Fa,Va as Za,Vb as $e,gq as Ga,Vc as x,fI as Ra,gx as ja,Vd as Ha,Ve as La,Vf as Pa,Vg as Be,Vh as Na,Vi as xe,Vj as Oa,E$ as Ua,gr as qa,h6 as za,cO as Ya,Vk as Ja,h9 as Qa,r4 as Wa,gc as Xa,ji as Ka,Vl as et,Vm as at,x8 as tt,gs as nt}from"./zeni-epic-state-C5DO1jkr.js";import{w as ot,f as st,g as rt,j as it,p as lt,_ as m,k as dt,u as ct,a as ut,h as mt,m as Ct,i as pt,q as ht,n as ft,o as gt,z as bt,c as L,s as h,v as Ve,x as St,y as kt,A as Ae,B as Et,X as _e,C as wt,Y as It,D as te,E as ae,F as vt,H as yt,I as Tt,L as $t,J as Bt,M as xt,N as Vt,O as At}from"./index-DtThPd2q.js";import{u as _t,q as Dt,r as Mt,I as Ft,p as De,t as Zt,D as Me,s as ne}from"./mui-DNGY4bFU.js";import{u as Gt}from"./InboxNotificationsProvider-CiKEEv6Q.js";import{u as Rt}from"./useTaskManagerAccess-CT25hqtF.js";import{u as jt}from"./useIsCustomersTabEnabled-C9FFBZXp.js";import{u as Ht}from"./expenseAutomationHelper-CgTsmmCm.js";import"./recharts-CTh_JhT_.js";import"./analytics-Vgn85Ur_.js";import"./plaid-DhfTjhua.js";import"./dnd-DuiAlI7w.js";import"./stripe-cKAAJElX.js";import"./lottie-Lb1ftKY1.js";import"./lexical-B-vxEaRQ.js";import"./pdf-B1uD4Ovv.js";import"./utils-CrhrpmD8.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]="755fcc74-3289-455e-967e-d7c6d9394a60",a._sentryDebugIdIdentifier="sentry-dbid-755fcc74-3289-455e-967e-d7c6d9394a60")}catch{}})();const V="AppDrawer",c={root:`${V}-root`,drawer:`${V}-drawer`,appBar:`${V}-appBar`,menuButton:`${V}-menuButton`,appBarZenilogo:`${V}-appBarZenilogo`,drawerZenilogo:`${V}-drawerZenilogo`},Lt=ne("div",{slot:"Root"})((({theme:a})=>({[`&.${c.root}`]:{display:"flex"},[`& .${c.drawer}`]:{[a.breakpoints.up("md")]:{width:te,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"}}))),Pt=ot((function({tenantEmailDomain:a}){const{isAiCfoOpen:C,setIsAiCfoOpen:S}=rt(),[P,A]=$a.useState(!1),[k,Re]=o.useState(!1),t=Ba(),s=xa(),oe=Aa(),se=it(),n=Fe(),[je,He]=o.useState(!1),N=_t(),re=t.pathname.includes("/ai-cfo/");o.useEffect((()=>{re||(n(K()),n(ee()))}),[n,re]),o.useEffect((()=>{n(K()),n(ee())}),[n,a]);const{useFeatureGate:u}=lt(),{isFeatureEnabled:ie}=u(m.isDebitCardFeatureEnabled),E=dt(),i=r((e=>Ze(e))),O=i.masterTOSInfo?.isMasterTOSAccepted??!1,{setLoading:Le}=ct(),w=ut(),{isTaskManagerAccessEnabled:_,isZeniUser:Pe}=Rt(E),le=mt(),I=Ct(),D=(function(e=2e3){const[l,p]=o.useState(!1);return o.useEffect((()=>{if(l)return;const B=window.requestIdleCallback;if(B==null){const X=window.setTimeout((()=>p(!0)),e);return()=>window.clearTimeout(X)}const R=B((()=>p(!0)),{timeout:e});return()=>{window.cancelIdleCallback?.(R)}}),[e,l]),l})();o.useEffect((()=>{D&&I&&w&&(n(ye()),n(Te()))}),[n,D,I,i.tenantId,w]);const[U,Ne]=o.useState(void 0),Oe=!!i.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:Ue}=u(m.isChargeCardFeatureEnabled),qe=pt(i,Ue,ie),{isFeatureEnabled:ze}=u(m.isSettingsFeatureEnabled),{isFeatureEnabled:M}=u(m.isReferralFeatureEnabled),Ye=i.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",de=r((e=>_a(e)));o.useEffect((()=>{const e=()=>{He(window.scrollY>10)};return window.addEventListener("scroll",e),()=>{window.removeEventListener("scroll",e)}}),[]);const q=r((e=>Da(e))),f=r((e=>e.expenseAutomationViewState.selectedPeriodByTenantId)),g=r((e=>Ma(e))),{monthEndCloseChecksView:v}=g,Je=H("/signout")!==null,F=H("/:tenantEmailDomain/dashboard")!==null,ce=H("/:tenantEmailDomain/reports")!==null,b=H("/:tenantEmailDomain/onboarding/*")!==null,ue=Ht();o.useEffect((()=>{D&&I&&M&&!b&&q.fetchState==="Not-Started"&&n(Fa(!0))}),[D,I,M,q.fetchState,b]),o.useEffect((()=>{if(ue){const e=t.state?.origin;if(e!=null){const l=Za(e);l!=null&&n($e(l))}}}),[ue,t.state]);const Qe=Je||b,z=r((e=>e.tenantState)),We=r((e=>z.fetchState==="Completed"?Ga(e):[])),{isFeatureEnabled:Xe}=u(m.isApAgingFeatureEnabled),{isFeatureEnabled:Ke}=u(m.isArAgingFeatureEnabled),{isFeatureEnabled:ea}=u(m.isDashboardSidebarHalloweenAnimationEnabled),{isFeatureEnabled:aa}=u(m.isDashboardSidebarThanksGivingAnimationEnabled),{isFeatureEnabled:ta}=u(m.isDashboardSidebarChristmasAnimationEnabled),{isFeatureEnabled:na}=u(m.isDashboardSidebarNewYearAnimationEnabled),oa=r((e=>x(e).totalUnreadCount)),sa=r((e=>x(e).notificationDetailsByTab.tasks.uiState.unreadCount)),ra=r((e=>x(e).notificationDetailsByTab.comments.uiState.unreadCount)),ia=r((e=>x(e).reducedFetchCountState)),me=r((e=>x(e).notificationDetailsByTab.tasks.fetchCountState)),Y=r((e=>Ra(e))),la=r((e=>ja(e).skillsEnabled)),da=r((e=>Ha(e))),Ce=r((e=>La(e).routines)),ca=o.useMemo((()=>Ce.filter((e=>e.sessionId!=null)).map((e=>({cadence:ht(e),name:e.name,scheduleId:e.scheduleId,sessionId:e.sessionId,unreadRuns:e.unreadRuns})))),[Ce]),ua=new URLSearchParams(t.search).get("routine")??ft(t.pathname.split("/ai-cfo/")[1])??void 0,ma=o.useCallback(((e,l)=>{s(l!=null&&l!==""?`/${a}/ai-cfo/${encodeURIComponent(l)}`:`/${a}/ai-cfo/routines?routine=${encodeURIComponent(e)}`)}),[s,a]),{status:pe}=r(Pa),[y,J]=o.useState(void 0),Q=Y.uiState.currentChatSessionId,Z=y!=null?Y.deleteChatSessionStateByChatSessionId[y]?.fetchState:void 0,he=gt(Z),{inboxNotifications:W,isLoading:fe,isFetchingMore:ge,hasFetchedAll:be,fetchMore:Ca}=Gt(),G=r((e=>x(e).notificationDetailsByTab.comments.fetchCountState));o.useEffect((()=>{const e=setTimeout((()=>Ca?.()),0);return()=>clearTimeout(e)})),o.useEffect((()=>{if(y!=null)return he==="In-Progress"&&Z==="Completed"?(n(Be({chatSessionId:y})),J(void 0),void s(`/${a}/ai-cfo/explore`,{state:{...t.state,referrer:"Sidebar"}})):void(Z==="Error"&&(n(Be({chatSessionId:y})),J(void 0)))}),[n,t.state,s,Z,y,he,a]),o.useEffect((()=>{if(fe===!1&&ge===!1&&be===!0&&i?.companyId!=null&&W!=null){const e=`dashboard_${i.companyId}`;Ne(W.filter((l=>l.roomId===e&&l.readAt==null)).length)}}),[fe,ge,be,i?.companyId,W]),o.useEffect((()=>{I&&_&&!b&&me.fetchState==="Not-Started"&&oe.tenantId!=null&&n(Na("task_manager","dashboard"))}),[I,_,b,me.fetchState,oe.tenantId,n]),o.useEffect((()=>{b||G.fetchState!=="Not-Started"||n(xe({fetchCountState:{fetchState:"In-Progress",error:void 0}},"comments"))}),[b,G.fetchState,n]),o.useEffect((()=>{if(U!=null){const{fetchState:e}=G;e!=="In-Progress"&&e!=="Completed"||(e==="In-Progress"&&n(xe({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),n(Ge({unreadCount:U},"comments")))}}),[U,G.fetchState]);const pa={fetchStatus:ia,count:oa},T=[];Xe===!1&&T.push("accounts_payable_aging"),Ke===!1&&T.push("accounts_receivable_aging"),T.push("zeni_accounts_promo_card","treasury_promo_card"),M===!1&&T.push("rewards_card"),le===!1&&T.push("expense_automation_card");const Se=r((e=>Oa(e,T).fetchState)),ke=r((e=>Ua(e).fetchState)),Ee=a!=null?bt.getSignedInUserTenant(a):null,we=r((e=>Ee?.tenantId!=null?qa(e,Ee.tenantId):void 0)),ha=F&&(Se==="Completed"||Se==="Error")||ce&&(ke==="Completed"||ke==="Error")||!F&&!ce?void 0:"disabled",fa=o.useMemo((()=>za(i.userRole)),[i.userRole]),ga=Ya(fa),ba=jt(),$=e=>{A(e)},Sa=Ye,ka=i?.rewardsLastViewedTime==null,Ea=E?.userEmail!=null&&de.fetchState==="Completed"&&Ja(de.notificationSettings,E.userEmail,ie,i,_),wa=o.useCallback((e=>{const l=t.state?.referrer;if(v.monthEndCloseChecks?.auditSummary!=null&&L.trackMonthCloseAuditPage(e.month,e.year,v.monthEndCloseChecks.reportEmailSentDate!=null?"closed":"in-review",v.monthEndCloseChecks.auditSummary.auditScorePercentage,!1,l??null),n(Qa(i.tenantId,e)),f[i.tenantId]!=null){const p=h(t.state?.pathnameStackToGoBack,t.pathname);s(`/${a}/month_end_close_checks/review/${g.currentSelectedView}/${e.month}-${e.year}`,{state:{pathnameStackToGoBack:p,referrer:g.currentSelectedView}})}n($e(g.currentSelectedView)),g.reconciliation.selectedAccountId!=null&&n(Wa({selectedAccountId:void 0}))}),[g.reconciliation.selectedAccountId,g.currentSelectedView,i.tenantId,v.monthEndCloseChecks?.auditSummary,v.monthEndCloseChecks?.reportEmailSentDate,f,a,t.state,t.pathname]),Ia=o.useMemo((()=>({zIndex:k?12:Ve[2]})),[k]),va=w&&St(t),Ie=d.jsx(kt,{signedInUser:E,currentTenantId:z.currentTenantId??"",tenants:z.fetchState==="Completed"?We:we!=null?[we]:[],rewardsConfiguration:{isRewardsTabVisible:M,isRewardsAnimated:ka,rewardsPlan:q.rewardsPlan},selectedMenu:C===!0?_e("ai_cfo"):Ae(t)&&pe!=="completed"?_e("invoicing"):wt(t),isTenantDropdownDisabled:ha,isSettings:Et(t),isInvoicing:Ae(t)&&pe==="completed",isSettingsFeatureEnabled:ze,currentTenant:i,isVendorsTabVisible:ga,isCustomersTabVisible:ba,isZeniAccountEnabled:Oe,isChargeCardEnabled:qe,isTreasuryEnabled:Sa,isNotificationsTabVisible:Ea,notificationCountDetails:pa,isExpenseAutomationEnabledForUser:le,isAiCfoAccessEnabled:w,skillsEnabled:la&&w,routinesEnabled:da===!0&&w,routines:ca,selectedRoutineId:ua,onRoutineSelect:ma,onNotificationIconClick:()=>{$(!1);const e=Pe?sa===0&&ra>0?"notifications/comments":"notifications/tasks":"notifications/comments",l=h(t.state?.pathnameStackToGoBack,t.pathname);s(`${a}/${e}`,{state:{pathnameStackToGoBack:l}})},onZeniLogoClick:()=>{se.toggle()},handleTenantSelect:e=>{Le($t.TENANT_SWITCHING),$(!1),Bt({dispatch:n,navigate:s,pathToNavigate:xt(e.tenantEmailDomain,t),selectedTenant:e,signedInUser:E})},handleMenuChange:(e,l)=>{if(E!=null&&L.trackSidePanelClicked(e.type,e.group),$(!1),a==null)return;if(e.type==="routines")return O?(n(Te()),n(et()),void s(`/${a}/ai-cfo/routines`,{state:{pathnameStackToGoBack:h(t.state?.pathnameStackToGoBack,t.pathname),referrer:"Sidebar"}})):void ae({location:t,navigate:s,mergeState:{referrer:"Sidebar"}});if(e.type==="skills")return O?(n(ye()),n(at()),void s(`/${a}/ai-cfo/skills`,{state:{pathnameStackToGoBack:h(t.state?.pathnameStackToGoBack,t.pathname),referrer:"Sidebar"}})):void ae({location:t,navigate:s,mergeState:{referrer:"Sidebar"}});if(n(K()),n(ee()),e.type==="invoicing")return C&&S(!1),n(tt({cacheOverride:!1})),void s(`../${a}/invoicing/overview`,{state:{pathnameStackToGoBack:h(t.state?.pathnameStackToGoBack,t.pathname),referrer:"Sidebar"}});if(C&&vt(e.type)&&S(!1),e.type==="ai_cfo"){if(L.trackAICFOChatScreenStateChanged("viewed","left_menu",Q??null,null),!O)return void ae({location:t,navigate:s,mergeState:{referrer:"Sidebar"}});const j=h(t.state?.pathnameStackToGoBack,t.pathname);return void s(`/${a}/ai-cfo/explore`,{state:{pathnameStackToGoBack:j,referrer:"Sidebar"}})}const p=h(t.state?.pathnameStackToGoBack,t.pathname),B=e.type,R=At(B)&&B!=="command_center";if(B!=="command_center"&&!R||f[i.tenantId]==null||L.trackMonthEndCloseClicked(f[i.tenantId].month,f[i.tenantId].year,"Sidebar"),R&&f[i.tenantId]!=null){const j=f[i.tenantId];return void s(`/${a}/month_end_close_checks/review/${e.type}/${j.month}-${j.year}`,{state:{pathnameStackToGoBack:p,message:l,referrer:"Sidebar"}})}const X=yt(e.type);Tt(e.type)?(Q!=null&&n(nt()),s(`/${a}/ai-cfo/${e.type}`,{state:{pathnameStackToGoBack:p.slice(0,-1),message:l,referrer:"Sidebar"}})):s(`../${a}/${X}`,{state:{pathnameStackToGoBack:p,message:l,referrer:"Sidebar"}})},onDeleteChatSession:e=>{n(Ka(e)),Q===e&&J(e)},handleLogOutClick:()=>{$(!1);const e=h(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:v,onPeriodChange:wa,onCalendarOpen:Re,aiCfoView:Y,isAiCfo:va,isOnDashboard:F,isTaskManagerAccessEnabled:_,updateCurrentChatSessionId:e=>{n(Xa({sessionId:e,agentId:"controller"})),s(`../${a}/ai-cfo/${e}`,{state:{...t.state}})},halloweenAnimationEnabled:ea,thanksGivingAnimationEnabled:aa,christmasAnimationEnabled:ta,newYearAnimationEnabled:na}),ya=d.jsx(Dt,{position:"fixed",className:c.appBar,style:{borderBottom:je?`1px solid ${N.colors.grey2}`:""},children:d.jsxs(Mt,{style:{minHeight:It},children:[d.jsx(Ft,{color:"inherit","aria-label":"open drawer",edge:"start",onClick:()=>$(!0),className:c.menuButton,size:"large",children:d.jsx(Nt,{})}),d.jsx(Ot,{className:c.appBarZenilogo,onClick:()=>{se.toggle()}})]})}),ve=De((e=>e.breakpoints.up("md"))),Ta=De((e=>e.breakpoints.down("md")));return a==null?null:d.jsxs(Lt,{className:c.root,children:[d.jsx(Zt,{}),Qe===!1?d.jsxs(d.Fragment,{children:[ve||!F?null:ya,d.jsxs("nav",{className:c.drawer,children:[ve?null:d.jsx(Me,{container:window.document.body,variant:"temporary",open:P,onClose:()=>$(!1),PaperProps:{sx:{width:te,zIndex:Ve[2],borderRight:"none",backgroundImage:"none",backgroundColor:N.colors.background}},ModalProps:{keepMounted:!0},children:Ie}),Ta?null:d.jsx(Me,{PaperProps:{sx:{width:te,borderRight:"none",backgroundImage:"none",backgroundColor:N.colors.background,...Ia}},variant:"permanent",open:!0,children:Ie})]})]}):null]})})),c1=({tenantEmailDomain:a})=>{const C=Fe(),S=r((A=>Ze(A))),P={events:S.userRoleId!=null?[`private-encrypted-${S.userRoleId}.dashboard-user-notification`]:[],eventCallback:(A,k)=>{st(k)&&Va(k.mode)==="dashboard"&&C(Ge({unreadCount:k.data.unread},"tasks"))}};return d.jsx(Pt,{tenantEmailDomain:a,...P})},Nt=ne((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-BLpmr1Pv.js";import{a as d}from"./sentry-DWNq3t8E.js";import{h as U,g as j,u as B,j as y,N as W,l as V,i as q,n as te,o as x}from"./core-CbdTrw7T.js";import{fJ as P,Xz as w,Xg as R,IA as E,Iu as X,Iy as A,In as z,Xi as K,Ir as ae,IC as oe,Iq as J,IF as G,IB as C}from"./zeni-epic-state-C5DO1jkr.js";import{z as k,w as H,bh as pe,B as O,b0 as M,bi as le,a8 as Q,bj as se,bk as ne}from"./index-CnIO6_IQ.js";import{u as Y}from"./mui-DNGY4bFU.js";import{u as Z}from"./useEnsureVendorListLoaded-CIShbpK4.js";import{i as re}from"./ReimbursementApprovalRuleDetailScreen-CHTcY28V.js";import ie from"./NotFoundScreen-DXy-BCit.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]="83691e95-825f-44fb-ad1e-1c5ed4bf2ab7",e._sentryDebugIdIdentifier="sentry-dbid-83691e95-825f-44fb-ad1e-1c5ed4bf2ab7")}catch{}})();const _="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(_)&&e(K(!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"))}}}))(H(pe)),ue=({isLoading:e})=>{const l=U(),t=j(),o=B(),[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))),m=y((r=>R(r).billPaySetupApproverViewUpdateData));if(d.useEffect((()=>{m?.updateStatus.fetchState==="Completed"&&o(E())}),[m]),d.useEffect((()=>{a||p!=="Not-Started"||e||(n(!0),o(X(!0,!0,!1)))}),[a,p,e,o]),k.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 S={events:f.companyId!=null?[`private-encrypted-${f.companyId}.${_}`]:[],eventCallback:(r,h,I)=>{r.endsWith(_)&&I.onApprovalRulesEventReceived(r)}};return f?.companyBillPayInfo?.info?.isBillPayTOSAccepted===!1?u.jsx(W,{to:"../../promo"}):u.jsx(ce,{currentTenant:f,location:t,navigate:l,...S})},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(K(!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))}}}))(H(le)),ve=()=>{const e=y((o=>P(o))),{isApprovalRulesV3Enabled:l,isLoading:t}=M(e?.tenantId);return l?u.jsx(fe,{isLoading:t}):u.jsx(ue,{isLoading:t})},fe=({isLoading:e})=>{const l=U(),t=j(),o=B(),[a,n]=d.useState(!1),[s,v]=d.useState(!1),[p,f]=d.useState(!1),c=y((i=>i.billPaySetupApproverViewState.fetchState)),m=y((i=>i.billPaySetupApproverViewState.approverListState.fetchStatus.fetchState)),S=y((i=>P(i)));Z();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(X(!0,!0,!0)))}),[a,c,e,o]),d.useEffect((()=>{s||m!=="Not-Started"||e||(v(!0),o(ae(!1,!0)))}),[s,m,e,o]),k.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 I={events:S.companyId!=null?[`private-encrypted-${S.companyId}.${L}`]:[],eventCallback:(i,b,g)=>{i.endsWith(L)&&g.onApprovalRulesEventReceived(i)}};return S?.companyBillPayInfo?.info?.isBillPayTOSAccepted===!1?u.jsx(W,{to:"../../promo"}):u.jsx(de,{currentTenant:S,location:t,navigate:l,isLoading:e,...I})},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=m=>{const S=[];return m.forEach((r=>{const h=r.actors.selectedUsers.map((b=>({type:"user",userId:b.userId,isImplicitActor:!1}))),I=r.actors.selectedNonUsers.map((b=>{const g=!!re(b.value);return{type:g?"attribute":"role",subType:b.value,userId:void 0,idType:void 0,isImplicitActor:!g}})),i=h.concat(I);S.push({action:r.stepType.selectedOption,actors:i,operator:i.length>1?r.stepType.selectedOption==="require_approval"?"or":"and":"is"})})),S},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 m={criteria:c,steps:f(p.steps),isApplicableOnPendingApprovalEntity:p.applyToExistingBills.includes("applyToExistingBills")};e(C(m))}else{const m={approvalRuleId:n,criteria:c,steps:f(p.steps),isApplicableOnPendingApprovalEntity:p.applyToExistingBills.includes("applyToExistingBills")};e(C(m))}},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 me(){const e=U(),l=B(),t=j(),{approvalRuleId:o}=q(),a=k.getSignedInUser(),n=Y(),s=y((c=>R(c))),v=y((c=>w(c))),[p,f]=d.useState(!1);if(d.useEffect((()=>{p||(f(!0),l(J(!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(Q,{fetchState:s.approverListFetchStatus.fetchState,style:{backgroundColor:n.colors.grey5}}):u.jsx(ye,{navigate:e,approvalUpdateDataView:s,approvalRuleId:o,approverViewData:v,location:t})}const Se=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 b=[];return i.forEach((g=>{const N=g.actorKind?.selectedOption,ee=g.selectedRole?.selectedNonUsers??[];let D=[];N==="role"?D=ee.map((T=>({type:"attribute",subType:T.value,userId:void 0,idType:void 0,isImplicitActor:!1}))):N==="specific_person"&&(D=(g.persons?.selectedUsers??[]).map((T=>({type:"user",userId:T.userId,isImplicitActor:!1}))));const $=g.action??"require_approval";b.push({action:$,actors:D,operator:D.length>1?$==="require_approval"?"or":"and":"is"})})),b},c=p.amountCriteria,m=p.vendorCriteria,S=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=m?.selection.selectedOptions??[];h.length>0&&(r.vendor={type:"vendor",operator:m?.operator.selectedOption??"is",vendorIds:h});const I=S?.selection.selectedOptions??[];if(I.length>0&&(r.department={type:"department",operator:S?.operator.selectedOption??"is",departmentIds:I}),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 F(){const e=y((t=>P(t))),{isApprovalRulesV3Enabled:l}=M(e?.tenantId);return l?u.jsx(ge,{}):u.jsx(me,{})}function ge(){const e=U(),l=B(),t=j(),{approvalRuleId:o}=q(),a=k.getSignedInUser(),n=Y(),s=y((c=>R(c))),v=y((c=>w(c))),[p,f]=d.useState(!1);if(Z(),d.useEffect((()=>{p||(f(!0),l(J(!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(Q,{fetchState:s.approverListFetchStatus.fetchState,style:{backgroundColor:n.colors.grey5}}):u.jsx(Se,{navigate:e,approvalUpdateDataView:s,approvalRuleId:o,approverViewData:v,location:t},o??"new")}function Ce(){return u.jsxs(te,{children:[u.jsx(x,{path:"/",element:u.jsx(ve,{})}),u.jsx(x,{path:"/new",element:u.jsx(F,{})}),u.jsx(x,{path:"/:approvalRuleId/edit",element:u.jsx(F,{})}),u.jsx(x,{path:"*",element:u.jsx(ie,{})})]})}export{Ce as B};
1
+ import{j as u}from"./liveblocks-BLpmr1Pv.js";import{a as d}from"./sentry-DWNq3t8E.js";import{h as U,g as j,u as B,j as y,N as W,l as V,i as q,n as te,o as x}from"./core-CbdTrw7T.js";import{fJ as P,Xz as w,Xg as R,IA as E,Iu as X,Iy as A,In as z,Xi as K,Ir as ae,IC as oe,Iq as J,IF as G,IB as C}from"./zeni-epic-state-C5DO1jkr.js";import{z as k,w as H,bh as pe,B as O,b0 as M,bi as le,a8 as Q,bj as se,bk as ne}from"./index-DtThPd2q.js";import{u as Y}from"./mui-DNGY4bFU.js";import{u as Z}from"./useEnsureVendorListLoaded-CIShbpK4.js";import{i as re}from"./ReimbursementApprovalRuleDetailScreen-CHtkyq9-.js";import ie from"./NotFoundScreen-uAMK84U0.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]="83691e95-825f-44fb-ad1e-1c5ed4bf2ab7",e._sentryDebugIdIdentifier="sentry-dbid-83691e95-825f-44fb-ad1e-1c5ed4bf2ab7")}catch{}})();const _="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(_)&&e(K(!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"))}}}))(H(pe)),ue=({isLoading:e})=>{const l=U(),t=j(),o=B(),[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))),m=y((r=>R(r).billPaySetupApproverViewUpdateData));if(d.useEffect((()=>{m?.updateStatus.fetchState==="Completed"&&o(E())}),[m]),d.useEffect((()=>{a||p!=="Not-Started"||e||(n(!0),o(X(!0,!0,!1)))}),[a,p,e,o]),k.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 S={events:f.companyId!=null?[`private-encrypted-${f.companyId}.${_}`]:[],eventCallback:(r,h,I)=>{r.endsWith(_)&&I.onApprovalRulesEventReceived(r)}};return f?.companyBillPayInfo?.info?.isBillPayTOSAccepted===!1?u.jsx(W,{to:"../../promo"}):u.jsx(ce,{currentTenant:f,location:t,navigate:l,...S})},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(K(!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))}}}))(H(le)),ve=()=>{const e=y((o=>P(o))),{isApprovalRulesV3Enabled:l,isLoading:t}=M(e?.tenantId);return l?u.jsx(fe,{isLoading:t}):u.jsx(ue,{isLoading:t})},fe=({isLoading:e})=>{const l=U(),t=j(),o=B(),[a,n]=d.useState(!1),[s,v]=d.useState(!1),[p,f]=d.useState(!1),c=y((i=>i.billPaySetupApproverViewState.fetchState)),m=y((i=>i.billPaySetupApproverViewState.approverListState.fetchStatus.fetchState)),S=y((i=>P(i)));Z();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(X(!0,!0,!0)))}),[a,c,e,o]),d.useEffect((()=>{s||m!=="Not-Started"||e||(v(!0),o(ae(!1,!0)))}),[s,m,e,o]),k.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 I={events:S.companyId!=null?[`private-encrypted-${S.companyId}.${L}`]:[],eventCallback:(i,b,g)=>{i.endsWith(L)&&g.onApprovalRulesEventReceived(i)}};return S?.companyBillPayInfo?.info?.isBillPayTOSAccepted===!1?u.jsx(W,{to:"../../promo"}):u.jsx(de,{currentTenant:S,location:t,navigate:l,isLoading:e,...I})},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=m=>{const S=[];return m.forEach((r=>{const h=r.actors.selectedUsers.map((b=>({type:"user",userId:b.userId,isImplicitActor:!1}))),I=r.actors.selectedNonUsers.map((b=>{const g=!!re(b.value);return{type:g?"attribute":"role",subType:b.value,userId:void 0,idType:void 0,isImplicitActor:!g}})),i=h.concat(I);S.push({action:r.stepType.selectedOption,actors:i,operator:i.length>1?r.stepType.selectedOption==="require_approval"?"or":"and":"is"})})),S},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 m={criteria:c,steps:f(p.steps),isApplicableOnPendingApprovalEntity:p.applyToExistingBills.includes("applyToExistingBills")};e(C(m))}else{const m={approvalRuleId:n,criteria:c,steps:f(p.steps),isApplicableOnPendingApprovalEntity:p.applyToExistingBills.includes("applyToExistingBills")};e(C(m))}},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 me(){const e=U(),l=B(),t=j(),{approvalRuleId:o}=q(),a=k.getSignedInUser(),n=Y(),s=y((c=>R(c))),v=y((c=>w(c))),[p,f]=d.useState(!1);if(d.useEffect((()=>{p||(f(!0),l(J(!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(Q,{fetchState:s.approverListFetchStatus.fetchState,style:{backgroundColor:n.colors.grey5}}):u.jsx(ye,{navigate:e,approvalUpdateDataView:s,approvalRuleId:o,approverViewData:v,location:t})}const Se=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 b=[];return i.forEach((g=>{const N=g.actorKind?.selectedOption,ee=g.selectedRole?.selectedNonUsers??[];let D=[];N==="role"?D=ee.map((T=>({type:"attribute",subType:T.value,userId:void 0,idType:void 0,isImplicitActor:!1}))):N==="specific_person"&&(D=(g.persons?.selectedUsers??[]).map((T=>({type:"user",userId:T.userId,isImplicitActor:!1}))));const $=g.action??"require_approval";b.push({action:$,actors:D,operator:D.length>1?$==="require_approval"?"or":"and":"is"})})),b},c=p.amountCriteria,m=p.vendorCriteria,S=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=m?.selection.selectedOptions??[];h.length>0&&(r.vendor={type:"vendor",operator:m?.operator.selectedOption??"is",vendorIds:h});const I=S?.selection.selectedOptions??[];if(I.length>0&&(r.department={type:"department",operator:S?.operator.selectedOption??"is",departmentIds:I}),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 F(){const e=y((t=>P(t))),{isApprovalRulesV3Enabled:l}=M(e?.tenantId);return l?u.jsx(ge,{}):u.jsx(me,{})}function ge(){const e=U(),l=B(),t=j(),{approvalRuleId:o}=q(),a=k.getSignedInUser(),n=Y(),s=y((c=>R(c))),v=y((c=>w(c))),[p,f]=d.useState(!1);if(Z(),d.useEffect((()=>{p||(f(!0),l(J(!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(Q,{fetchState:s.approverListFetchStatus.fetchState,style:{backgroundColor:n.colors.grey5}}):u.jsx(Se,{navigate:e,approvalUpdateDataView:s,approvalRuleId:o,approverViewData:v,location:t},o??"new")}function Ce(){return u.jsxs(te,{children:[u.jsx(x,{path:"/",element:u.jsx(ve,{})}),u.jsx(x,{path:"/new",element:u.jsx(F,{})}),u.jsx(x,{path:"/:approvalRuleId/edit",element:u.jsx(F,{})}),u.jsx(x,{path:"*",element:u.jsx(ie,{})})]})}export{Ce as B};
@@ -1,4 +1,4 @@
1
- import{j as t}from"./liveblocks-BLpmr1Pv.js";import{h as q,u as le,g as K,i as ee,j as v,N as Y,l as Q,q as tt,n as nt,o as y}from"./core-CbdTrw7T.js";import{fJ as H,WS as _e,bp as Ia,Tp as it,bn as va,bK as de,WT as ka,HQ as wa,Jd as Re,Ir as ot,bm as Ce,WU as lt,WV as st,c8 as rt,WW as ct,mb as xa,WX as Ba,WY as Ca,JH as Ue,I7 as xe,WZ as dt,HE as ea,W_ as ut,Nz as pt,HI as mt,HO as Aa,W$ as Se,X0 as Ge,Je as Me,I4 as Da,X1 as bt,X2 as ht,Jh as Oe,X3 as gt,Jn as St,X4 as Ea,IS as aa,IX as yt,X5 as ft,X6 as ce,X7 as Ta,X8 as ja,X9 as Pa,g_ as It,Ic as Ve,cz as Fa,Xa as vt,gl as kt,Xb as wt,Xc as xt,er as Ra,eq as Va,Xd as Ne,Xe as Bt,Xf as Ct,VY as ze,Xg as At,V_ as ie,VZ as Xe,Xh as Dt,Xi as Et,Xj as Tt,IZ as ta,IW as jt,Xk as Pt,Xl as Ft,Xm as Rt,II as Vt,Xn as $t,Xo as Lt,cm as $a,ec as La,mm as _t,bP as Ut,bw as _a,bQ as Ua,GU as Gt,Xp as Mt,Nm as Ot,Ns as Nt,CY as zt,Jf as Xt,JO as Wt,mz as ge,Xq as Zt,Xr as Ga,n1 as Ht,mt as Ma,mO as Oa,mN as na,bF as pe,bO as Jt,Xs as qt,Xt as ye,kZ as Kt,Xu as ia,Xv as Qt,l1 as Yt,lm as en,K0 as an,Xw as tn,mW as nn,JS as on,Xx as oa,JW as ln,J$ as sn,JZ as rn,JQ as cn,Xy as Na,HZ as dn,Xz as un,XA as pn,gK as mn,gJ as bn,gI as hn,mC as gn,mU as la,n3 as Sn,vr as yn,mL as fn,JU as In,l7 as vn,n8 as kn,XB as wn,k$ as xn,vi as Bn,XC as Cn,IO as An,bL as Dn,bs as En,hb as Tn,ef as jn,ee as Pn,cy as Fn,cF as Rn}from"./zeni-epic-state-C5DO1jkr.js";import{z as V,V as fe,al as We,p as oe,_ as f,au as Ze,a8 as se,N as A,a9 as Ae,c as E,aH as Vn,a5 as Z,aj as He,s as D,a2 as Ie,aI as sa,aJ as ra,aK as $n,aL as Ln,ag as _n,aM as Un,ac as za,G as De,ah as Je,aN as Gn,af as Xa,aO as Mn,aC as On,R as Wa,w as Nn,aP as zn,aQ as Xn,aR as Wn,aS as Zn,aT as Hn,aU as Jn,aV as qn,aW as Kn,aX as Qn,j as Yn,aY as ei,aZ as ai,a_ as ti,az as ni,a$ as ii,i as oi}from"./index-CnIO6_IQ.js";import{u as ue,n as _,S as li}from"./mui-DNGY4bFU.js";import{A as ca}from"./AddressScreen-DgUwrml_.js";import{g as ne,a as Ee,i as Za,V as qe,b as Ke,c as si,v as ri,d as ci,A as me,D as be}from"./DomesticWireDetailScreen-BxClNf2J.js";import{a as g}from"./sentry-DWNq3t8E.js";import{u as Qe}from"./useAskAiCfoHostNavButtonProps-DXFswt7R.js";import{u as Ha}from"./useInitialThreadRequest-DAUsQlCl.js";import{u as di}from"./BusinessVerificationPageScreen-DM_jBIuD.js";import Be from"./NotFoundScreen-DXy-BCit.js";import{D as ui}from"./DrawerScreen-BHaectiO.js";import{M as Ja}from"./MobileAppDrawer-BWNb5zLN.js";import{F as qa}from"./FeaturePreviewScreen-DHt0WFS8.js";import{S as Te}from"./SetupPagesScreen-D6ssIWb0.js";import{B as pi}from"./BillPayApprovalRoutes-BcCgse3-.js";import{F as mi}from"./FallBackRoute-DuMHkNqk.js";import"./recharts-CTh_JhT_.js";import"./analytics-Vgn85Ur_.js";import"./plaid-DhfTjhua.js";import"./dnd-DuiAlI7w.js";import"./stripe-cKAAJElX.js";import"./lottie-Lb1ftKY1.js";import"./lexical-B-vxEaRQ.js";import"./pdf-B1uD4Ovv.js";import"./utils-CrhrpmD8.js";import"./routePaths-CV12X_S-.js";import"./InboxNotificationsProvider-CiKEEv6Q.js";import"./useTaskManagerAccess-Cm5trA3i.js";import"./useIsCustomersTabEnabled-C6mkabn2.js";import"./analyticsHelper-CWMk7_rd.js";import"./useEnsureVendorListLoaded-CIShbpK4.js";import"./ReimbursementApprovalRuleDetailScreen-CHTcY28V.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]="4e6c5acf-a9d2-40e5-9d49-85f47d365ab2",e._sentryDebugIdIdentifier="sentry-dbid-4e6c5acf-a9d2-40e5-9d49-85f47d365ab2")}catch{}})();const bi=Q((function(e,a){const l=_e(e,a.billId),n=V.getSignedInUser(),c=e.tenantState.currentTenantId,r={userId:n?.userId??"",sessionId:n?.zeniSessionId??"",tenantId:c??""},u=Z(a.location.state?.pathnameStackToGoBack);let o=!0;u.poppedPathname?.includes("bills")===!0&&(o=!1);let s=`${l.createdBy?.firstName??"Zeni"} ${l.createdBy?.lastName??""}`;Ce(n)||!l.createdBy?.email?.includes("zeni.ai")||(s="Zeni");let i=!1,d=!1;if(l?.billActivities.length>0){const{isApprovalorRejectBtnVisible:S,isMarkAsPaidBtnVisible:h}=lt(l.billActivities,st(a.currentTenant),n);i=S,d=h}const p=rt(a.currentTenant?.userRole??[]),m=l.transactionDetails!=null&&ct(l.transactionDetails,p,n);return{billDetails:l,isAccountingClassesEnabled:xa(e),createdBy:s,authParams:r,transactionAttachmentEndpoint:`${He}/transaction_attachment`,signedInUser:n,showBackButton:o,isAdmin:p,isRealTimeApprovalEnabled:a.isRealTimeApprovalEnabled,showApproveRejectBtns:i,showMarkAsPaidButtonToApprover:d,hasZeniAssistAccess:a.hasZeniAssistAccess,analytics:E,showMarkAsPaidButtonToCreator:m}}),(function(e,a){const{billId:l,currentTenant:n,location:c,navigate:r}=a,{tenantEmailDomain:u}=n;return{redirectToBillsScreen:()=>{const o=ne(u),s=D(c.state?.pathnameStackToGoBack,c.pathname);r(o,{state:{pathnameStackToGoBack:s}})},redirectToEditableBillScreen:()=>{const o=D(c.state?.pathnameStackToGoBack,c.pathname);r("./edit",{state:{pathnameStackToGoBack:o}})},discardBillDetailsFromLocalStore:()=>{e(Se({}))},deleteBill:o=>{E.trackBillPayDeleteBill(l,o),e(Aa(l))},cancelAndDeleteBill:(o,s)=>{s===!0?E.trackBillPayCancelAndDeleteBill(l,o):E.trackBillPayCancelBill(l),e(mt(l,s))},onSaveRealTimeApprovals:o=>{e(pt(l,"bill_pay",o))},updateEditRealTimeApproverClicked:o=>{e(ut({isEdit:o,entityId:l,entityType:"bill_pay"}))},approveOrRejectBill:o=>{o.type==="approved"?e(ea(l,o.type,"")):e(ea(l,o.type,o.description??""))},retryOrRefundBill:o=>{o.type==="retry"?e(xe(l,"retry")):e(xe(l,"refund"))},onAddNewRule:()=>{r("../../bills/approval-rules")},onAttachmentClick:(o,s)=>{const i=Ee(u,o,s),d=D(c.state?.pathnameStackToGoBack,c.pathname);r(i,{state:{pathnameStackToGoBack:d}})},onBackClick:()=>{const o=Z(a.location.state?.pathnameStackToGoBack),s=o.poppedPathname??ne(u);r(s,{state:{pathnameStackToGoBack:o.newStack}})},onRetryPaymentClick:()=>{const o=D(c.state?.pathnameStackToGoBack,c.pathname);r("./edit",{state:{pathnameStackToGoBack:o}}),e(dt({billId:a.billId}))},onRefundPaymentClick:()=>{e(xe(a.billId,"refund"))},saveBillDetails:(o,s,i)=>{o&&e(Ca({data:i,billId:l})),e(Ue(o?"paid":"pending_approval",o,s,l))},discardOutsideZeniPaymentData:()=>{e(Ba({billId:l}))}}}))(Vn);function hi(){const e=q(),a=le(),l=K(),{billId:n}=ee(),c=ue(),r=V.getSignedInUser(),u=fe(),o=v((U=>H(U))),s=v((U=>_e(U,n??""))),i=s.transactionDetails?.billPayInfo.stage.code==="draft"&&s.transactionDetails.isDeleted===!1,d=Ha(o?.companyId,{clearParams:s.fetchState==="Completed"&&!i}),{isAiCfoAccessEnabled:p,onAskAiCfoClick:m}=Qe({mobileExploreReferrer:"Bill Details"});We({isDataReady:s.fetchState==="Completed"});const S=o?.userRole!=null&&Ia(o?.userRole),h=o?.company==null||o.company.featuresActivationInfo?.isBillPayFeatureEnabled&&!S,[b,C]=g.useState(!1),[I,j]=g.useState(!1),[B,T]=g.useState(!1),{useFeatureGate:k,useDynamicConfig:$}=oe(),{isFeatureEnabled:N}=k(f.isShowDeletedBillsFeatureEnabled),{isFeatureEnabled:G}=k(f.isBillPayDetectInsufficientFundsEnabled),{configValue:z}=$(Ze.zeniAssistConfig),X=it(o),w=va(o.userRole),M=h&&de(u?.loggedInUserRoleMap),L=z.user_ids!=null&&r?.userId!=null&&z.user_ids.includes(r?.userId),{isFeatureEnabled:W}=k(f.isInternationalPaymentShaVsOurFeatureEnabled),{isFeatureEnabled:J}=k(f.billPaySetupShowInternationalPaymentByWise);if(g.useEffect((()=>{N&&s.transactionDetails?.isDeleted===!0||o.isZeni===!0&&r?.userEmailDomain==="zeni.ai"&&X===!1?T(!1):T(s.billActivities[0]?.isRealTimeApprovalEnabled&&(w||M||s.allApprovers.find((U=>U.user.userId===r?.userId))!=null||s.transactionDetails?.lastUpdatedByUserId===r?.userId))}),[s.billActivities[0]?.isRealTimeApprovalEnabled,s.allApprovers,s.transactionDetails?.lastUpdatedByUserId,w,M,o.isZeni,X,r]),g.useEffect((()=>{n!=null&&a(ka(n))}),[n]),g.useEffect((()=>{b||s.fetchState=="Completed"||s.fetchState=="In-Progress"||(C(!0),a(wa(n??"",N,L,!1)))}),[b,s,n,a]),g.useEffect((()=>{I||s.fetchState!="Completed"||s.transactionDetails?.billPayInfo.stage.code=="paid"||(j(!0),a(Re(!1,N,L,J,n)),s.billActivities[0]?.isRealTimeApprovalEnabled===!0&&a(ot()))}),[I,s,n,a,N,L,J]),r==null)throw Error("Can't access address page without signing in...");return s.transactionDetails?.billPayInfo.stage.code==="draft"&&s.transactionDetails.isDeleted===!1?t.jsx(Y,{to:`./edit${l.search}`}):s.deleteStatus.fetchState==="In-Progress"||s.cancelAndDeleteStatus.fetchState==="In-Progress"||s.cancelStatus.fetchState==="In-Progress"?t.jsx(se,{fetchState:s.deleteStatus.fetchState,style:{boxShadow:`0px 2px ${A.sp1} ${c.colors.dropShadowNormal}`}}):t.jsxs(t.Fragment,{children:[t.jsx(Ae,{analytics:E,onLoad:U=>(O=>{n!=null&&O.trackBillPayBillDetails(n,s.isRecurring)})(U)}),t.jsx(bi,{initialOpenThreadRequest:d??void 0,isShowDeletedBillsEnabled:N,location:l,navigate:e,isRealTimeApprovalEnabled:B,currentTenant:o,billId:n??"",isInternationalPaymentShaVsOurEnabled:W,hasZeniAssistAccess:L,isDetectInsufficientFundsEnabled:G,isAiCfoAccessEnabled:p,onAskAiCfoClick:m})]})}const $e=De.getLocalizedStrings().spendManagement.billPay.billDetails,da=De.getLocalizedStrings().common,gi={containerWidth:new za(100,58)},ua=Q((function(e,a){const l=V.getSignedInUser(),n=e.tenantState.currentTenantId,c={userId:l?.userId??"",sessionId:l?.zeniSessionId??"",tenantId:n??""},r=a.showActionButtons,u=r&&a.file==null;return{uploadInvoiceEndPoint:`${Xa.communicationAgentMicroServiceBaseUrl}`,authParams:c,billId:a.billId,file:a.file,showAutofill:a.showAutofill,analytics:E,entityId:a.billId,showTitlebarIcon:r,showTitlebar:r&&a?.file!=null,uploadStatus:a.uploadStatus,shouldNotShowAttachment:u,style:{paddingTop:A.sp10,paddingRight:A.sp3,paddingBottom:"15px",paddingLeft:A.sp5,...a.showAutofill?{}:{backgroundColor:a.backgroundColor,paddingBottom:"128px"}}}}),(function(e,a){const l=V.getSignedInUser();return{onInvoiceUpload:n=>{n!=null&&(a.file!=null||a.billId!=null||a.isInitialEdit?(a.setPayload(n),a.setShowConfirmationPopup(!0)):e(Oe(n,a.isVendorRecommendationEnabled,a.billId)))},updateInvoiceUploadFetchState:n=>{e(St({fetchState:{fetchState:n,error:void 0},billId:a.billId}))},onSkipAutofill:n=>{E?.trackBillPaySkipAutofill(),e(Me(n))},onDeleteClick:()=>{e(gt({billId:a.billId})),E?.trackInvoiceActionClick(a.billStage??"","delete",l?.userEmail??"",null)}}}))(Un);function x({appContent:e}){const a=le(),l=q(),{billId:n}=ee(),c=K(),r=c.pathname,u=r.includes("bill/new")||r.includes("/edit"),o=Ie(),s=ue(),i=V.getSignedInUser(),{useFeatureGate:d,useDynamicConfig:p}=oe(),{isFeatureEnabled:m}=d(f.isVendorRecommendationFeatureEnabled),{isFeatureEnabled:S}=d(f.isShowDeletedBillsFeatureEnabled),{isFeatureEnabled:h}=d(f.isDepositAccountsFeatureEnabled),{isFeatureEnabled:b}=d(f.billPaySetupShowInternationalPaymentByWise),{configValue:C}=p(Ze.zeniAssistConfig),I=C.user_ids!=null&&i?.userId!=null&&C.user_ids.includes(i?.userId),j=v((P=>H(P)));di();const[B,T]=g.useState(!1),[k,$]=g.useState(!1),[N,G]=g.useState(!1),[z,X]=g.useState(),w=v((P=>Ge(P,m,h,n)));let M=w.fetchState,L=w.file,W=w.showAutofill;const J=v((P=>_e(P,n??"")));u===!1&&(M=J.fetchState,L=J.transactionDetails?.attachments?.[0],W=!1);const U=w.billPayInfo!=null&&w.billPayInfo.stage.code==="pending_approval"?w.billPayInfo.billStatus.code:w.billStage;g.useEffect((()=>{n==null&&a(Me(!0))}),[n,a]),g.useEffect((()=>{M==="Not-Started"&&(u&&k?$(!1):!u&&B&&T(!1))}),[n]),g.useEffect((()=>{B||n==null||u||(T(!0),a(wa(n,S,I,!1)),a(Da(n)),k||($(!0),a(Re(!1,S,I,b,n)))),u&&!k&&($(!0),a(Re(!1,S,I,b,n)))}),[B,k,u,n,a,S,I,b]);const O={onOkClick:()=>{if(G(!1),!z)return;const P=L!=null?"replace":"upload";E?.trackInvoiceActionClick(U??"",P,i?.userEmail??"","yes"),a(ht({replaceBillData:!0,billId:n})),a(Oe(z,m,n))},onCancelClick:()=>{if(G(!1),!z)return;const P=L!=null?"replace":"upload";E?.trackInvoiceActionClick(U??"",P,i?.userEmail??"","no"),a(bt({file:z,billId:n}))}},ae=g.useCallback((()=>{const P=Z(c.state?.pathnameStackToGoBack),ve=P.poppedPathname??ne(j.tenantEmailDomain);a(Se({billId:n})),l(ve,{state:{pathnameStackToGoBack:P.newStack}})}),[c.state,j.tenantEmailDomain,n,a,l]);if(i==null)throw Error("Can't access address page without signing in...");if(M==="Error"||J.fetchState==="Error")return t.jsx(Be,{});if(M!="Completed")return n==null&&o!=="small"?t.jsx(sa,{fallback:ae,children:t.jsxs(je,{windowSize:o,children:[t.jsx(ma,{}),t.jsx(Pe,{}),t.jsx(ua,{backgroundColor:s.colors.grey4,billId:n,file:L,showAutofill:!0,uploadStatus:w.uploadStatus,isVendorRecommendationEnabled:m,attachmentTitle:void 0,setShowConfirmationPopup:G,setPayload:X,showActionButtons:!1,isInitialEdit:!!w.isInitialEdit,billStage:U}),t.jsx(Fe,{windowSize:o,children:t.jsx(ra,{isNewBill:!0})})]})}):t.jsxs(je,{windowSize:o,children:[o==="small"||W?null:t.jsx(pa,{children:t.jsx(Ka,{onClick:ae,"data-testid":"nav-bar-back-click"})}),o!=="small"?t.jsx(Pe,{}):null,t.jsx($n,{}),t.jsx(Fe,{windowSize:o,children:t.jsx(ra,{isNewBill:n==null})})]});{const P=w.billPayInfo!=null&&w.billPayInfo.stage.code==="pending_approval"?w.billPayInfo.billStatus.code:w.billStage;return t.jsx(sa,{fallback:ae,children:t.jsxs(je,{windowSize:o,children:[W&&o!=="small"?t.jsx(ma,{}):null,N?t.jsx(Ln,{titleComponent:t.jsx(wi,{children:$e.overwriteTitle}),descriptionComponent:t.jsx(xi,{children:$e.overwriteDescription}),primaryButtonText:da.yes,secondaryButtonText:da.no,action:O,isEditPopup:!0}):null,o==="small"||W?null:t.jsx(pa,{children:t.jsx(Si,{})}),o!=="small"?t.jsx(Pe,{}):null,t.jsx(ua,{backgroundColor:s.colors.grey4,billId:n,file:L,showAutofill:W,uploadStatus:w.uploadStatus,isVendorRecommendationEnabled:m,attachmentTitle:yi(u,J,w),setShowConfirmationPopup:G,setPayload:X,showActionButtons:fi(u,w),isInitialEdit:!!w.isInitialEdit,billStage:P}),t.jsx(Fe,{windowSize:o,children:e})]})})}}function Si(){const{triggerBack:e}=Gn();return t.jsx(Ka,{onClick:e,"data-testid":"nav-bar-back-click"})}function yi(e,a,l){let n,c;return e?(n=l.recurringConfig?.currentInstance,c=l.recurringConfig?.totalPaymentCycles):(n=a.transactionDetails?.recurringBillInstance,c=a.recurringBillConfigDetail?.totalPaymentCycles),a?.isRecurring===!0?t.jsxs(Ii,{children:[t.jsx(vi,{children:`${$e.recurringBill.recurringCycle}
1
+ import{j as t}from"./liveblocks-BLpmr1Pv.js";import{h as q,u as le,g as K,i as ee,j as v,N as Y,l as Q,q as tt,n as nt,o as y}from"./core-CbdTrw7T.js";import{fJ as H,WS as _e,bp as Ia,Tp as it,bn as va,bK as de,WT as ka,HQ as wa,Jd as Re,Ir as ot,bm as Ce,WU as lt,WV as st,c8 as rt,WW as ct,mb as xa,WX as Ba,WY as Ca,JH as Ue,I7 as xe,WZ as dt,HE as ea,W_ as ut,Nz as pt,HI as mt,HO as Aa,W$ as Se,X0 as Ge,Je as Me,I4 as Da,X1 as bt,X2 as ht,Jh as Oe,X3 as gt,Jn as St,X4 as Ea,IS as aa,IX as yt,X5 as ft,X6 as ce,X7 as Ta,X8 as ja,X9 as Pa,g_ as It,Ic as Ve,cz as Fa,Xa as vt,gl as kt,Xb as wt,Xc as xt,er as Ra,eq as Va,Xd as Ne,Xe as Bt,Xf as Ct,VY as ze,Xg as At,V_ as ie,VZ as Xe,Xh as Dt,Xi as Et,Xj as Tt,IZ as ta,IW as jt,Xk as Pt,Xl as Ft,Xm as Rt,II as Vt,Xn as $t,Xo as Lt,cm as $a,ec as La,mm as _t,bP as Ut,bw as _a,bQ as Ua,GU as Gt,Xp as Mt,Nm as Ot,Ns as Nt,CY as zt,Jf as Xt,JO as Wt,mz as ge,Xq as Zt,Xr as Ga,n1 as Ht,mt as Ma,mO as Oa,mN as na,bF as pe,bO as Jt,Xs as qt,Xt as ye,kZ as Kt,Xu as ia,Xv as Qt,l1 as Yt,lm as en,K0 as an,Xw as tn,mW as nn,JS as on,Xx as oa,JW as ln,J$ as sn,JZ as rn,JQ as cn,Xy as Na,HZ as dn,Xz as un,XA as pn,gK as mn,gJ as bn,gI as hn,mC as gn,mU as la,n3 as Sn,vr as yn,mL as fn,JU as In,l7 as vn,n8 as kn,XB as wn,k$ as xn,vi as Bn,XC as Cn,IO as An,bL as Dn,bs as En,hb as Tn,ef as jn,ee as Pn,cy as Fn,cF as Rn}from"./zeni-epic-state-C5DO1jkr.js";import{z as V,V as fe,al as We,p as oe,_ as f,au as Ze,a8 as se,N as A,a9 as Ae,c as E,aH as Vn,a5 as Z,aj as He,s as D,a2 as Ie,aI as sa,aJ as ra,aK as $n,aL as Ln,ag as _n,aM as Un,ac as za,G as De,ah as Je,aN as Gn,af as Xa,aO as Mn,aC as On,R as Wa,w as Nn,aP as zn,aQ as Xn,aR as Wn,aS as Zn,aT as Hn,aU as Jn,aV as qn,aW as Kn,aX as Qn,j as Yn,aY as ei,aZ as ai,a_ as ti,az as ni,a$ as ii,i as oi}from"./index-DtThPd2q.js";import{u as ue,n as _,S as li}from"./mui-DNGY4bFU.js";import{A as ca}from"./AddressScreen-BVizi07H.js";import{g as ne,a as Ee,i as Za,V as qe,b as Ke,c as si,v as ri,d as ci,A as me,D as be}from"./DomesticWireDetailScreen-pNAj50PJ.js";import{a as g}from"./sentry-DWNq3t8E.js";import{u as Qe}from"./useAskAiCfoHostNavButtonProps-DSKusWDa.js";import{u as Ha}from"./useInitialThreadRequest-DrEeSZz_.js";import{u as di}from"./BusinessVerificationPageScreen-CdT5YCya.js";import Be from"./NotFoundScreen-uAMK84U0.js";import{D as ui}from"./DrawerScreen-Ba5DQb-t.js";import{M as Ja}from"./MobileAppDrawer-CCAbxLE2.js";import{F as qa}from"./FeaturePreviewScreen-C15dgqam.js";import{S as Te}from"./SetupPagesScreen-DRxKoFqN.js";import{B as pi}from"./BillPayApprovalRoutes-C0prBF5m.js";import{F as mi}from"./FallBackRoute-Ba8DnNt0.js";import"./recharts-CTh_JhT_.js";import"./analytics-Vgn85Ur_.js";import"./plaid-DhfTjhua.js";import"./dnd-DuiAlI7w.js";import"./stripe-cKAAJElX.js";import"./lottie-Lb1ftKY1.js";import"./lexical-B-vxEaRQ.js";import"./pdf-B1uD4Ovv.js";import"./utils-CrhrpmD8.js";import"./routePaths-DXYV831_.js";import"./InboxNotificationsProvider-CiKEEv6Q.js";import"./useTaskManagerAccess-CT25hqtF.js";import"./useIsCustomersTabEnabled-C9FFBZXp.js";import"./analyticsHelper-CVZpPd-a.js";import"./useEnsureVendorListLoaded-CIShbpK4.js";import"./ReimbursementApprovalRuleDetailScreen-CHtkyq9-.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]="4e6c5acf-a9d2-40e5-9d49-85f47d365ab2",e._sentryDebugIdIdentifier="sentry-dbid-4e6c5acf-a9d2-40e5-9d49-85f47d365ab2")}catch{}})();const bi=Q((function(e,a){const l=_e(e,a.billId),n=V.getSignedInUser(),c=e.tenantState.currentTenantId,r={userId:n?.userId??"",sessionId:n?.zeniSessionId??"",tenantId:c??""},u=Z(a.location.state?.pathnameStackToGoBack);let o=!0;u.poppedPathname?.includes("bills")===!0&&(o=!1);let s=`${l.createdBy?.firstName??"Zeni"} ${l.createdBy?.lastName??""}`;Ce(n)||!l.createdBy?.email?.includes("zeni.ai")||(s="Zeni");let i=!1,d=!1;if(l?.billActivities.length>0){const{isApprovalorRejectBtnVisible:S,isMarkAsPaidBtnVisible:h}=lt(l.billActivities,st(a.currentTenant),n);i=S,d=h}const p=rt(a.currentTenant?.userRole??[]),m=l.transactionDetails!=null&&ct(l.transactionDetails,p,n);return{billDetails:l,isAccountingClassesEnabled:xa(e),createdBy:s,authParams:r,transactionAttachmentEndpoint:`${He}/transaction_attachment`,signedInUser:n,showBackButton:o,isAdmin:p,isRealTimeApprovalEnabled:a.isRealTimeApprovalEnabled,showApproveRejectBtns:i,showMarkAsPaidButtonToApprover:d,hasZeniAssistAccess:a.hasZeniAssistAccess,analytics:E,showMarkAsPaidButtonToCreator:m}}),(function(e,a){const{billId:l,currentTenant:n,location:c,navigate:r}=a,{tenantEmailDomain:u}=n;return{redirectToBillsScreen:()=>{const o=ne(u),s=D(c.state?.pathnameStackToGoBack,c.pathname);r(o,{state:{pathnameStackToGoBack:s}})},redirectToEditableBillScreen:()=>{const o=D(c.state?.pathnameStackToGoBack,c.pathname);r("./edit",{state:{pathnameStackToGoBack:o}})},discardBillDetailsFromLocalStore:()=>{e(Se({}))},deleteBill:o=>{E.trackBillPayDeleteBill(l,o),e(Aa(l))},cancelAndDeleteBill:(o,s)=>{s===!0?E.trackBillPayCancelAndDeleteBill(l,o):E.trackBillPayCancelBill(l),e(mt(l,s))},onSaveRealTimeApprovals:o=>{e(pt(l,"bill_pay",o))},updateEditRealTimeApproverClicked:o=>{e(ut({isEdit:o,entityId:l,entityType:"bill_pay"}))},approveOrRejectBill:o=>{o.type==="approved"?e(ea(l,o.type,"")):e(ea(l,o.type,o.description??""))},retryOrRefundBill:o=>{o.type==="retry"?e(xe(l,"retry")):e(xe(l,"refund"))},onAddNewRule:()=>{r("../../bills/approval-rules")},onAttachmentClick:(o,s)=>{const i=Ee(u,o,s),d=D(c.state?.pathnameStackToGoBack,c.pathname);r(i,{state:{pathnameStackToGoBack:d}})},onBackClick:()=>{const o=Z(a.location.state?.pathnameStackToGoBack),s=o.poppedPathname??ne(u);r(s,{state:{pathnameStackToGoBack:o.newStack}})},onRetryPaymentClick:()=>{const o=D(c.state?.pathnameStackToGoBack,c.pathname);r("./edit",{state:{pathnameStackToGoBack:o}}),e(dt({billId:a.billId}))},onRefundPaymentClick:()=>{e(xe(a.billId,"refund"))},saveBillDetails:(o,s,i)=>{o&&e(Ca({data:i,billId:l})),e(Ue(o?"paid":"pending_approval",o,s,l))},discardOutsideZeniPaymentData:()=>{e(Ba({billId:l}))}}}))(Vn);function hi(){const e=q(),a=le(),l=K(),{billId:n}=ee(),c=ue(),r=V.getSignedInUser(),u=fe(),o=v((U=>H(U))),s=v((U=>_e(U,n??""))),i=s.transactionDetails?.billPayInfo.stage.code==="draft"&&s.transactionDetails.isDeleted===!1,d=Ha(o?.companyId,{clearParams:s.fetchState==="Completed"&&!i}),{isAiCfoAccessEnabled:p,onAskAiCfoClick:m}=Qe({mobileExploreReferrer:"Bill Details"});We({isDataReady:s.fetchState==="Completed"});const S=o?.userRole!=null&&Ia(o?.userRole),h=o?.company==null||o.company.featuresActivationInfo?.isBillPayFeatureEnabled&&!S,[b,C]=g.useState(!1),[I,j]=g.useState(!1),[B,T]=g.useState(!1),{useFeatureGate:k,useDynamicConfig:$}=oe(),{isFeatureEnabled:N}=k(f.isShowDeletedBillsFeatureEnabled),{isFeatureEnabled:G}=k(f.isBillPayDetectInsufficientFundsEnabled),{configValue:z}=$(Ze.zeniAssistConfig),X=it(o),w=va(o.userRole),M=h&&de(u?.loggedInUserRoleMap),L=z.user_ids!=null&&r?.userId!=null&&z.user_ids.includes(r?.userId),{isFeatureEnabled:W}=k(f.isInternationalPaymentShaVsOurFeatureEnabled),{isFeatureEnabled:J}=k(f.billPaySetupShowInternationalPaymentByWise);if(g.useEffect((()=>{N&&s.transactionDetails?.isDeleted===!0||o.isZeni===!0&&r?.userEmailDomain==="zeni.ai"&&X===!1?T(!1):T(s.billActivities[0]?.isRealTimeApprovalEnabled&&(w||M||s.allApprovers.find((U=>U.user.userId===r?.userId))!=null||s.transactionDetails?.lastUpdatedByUserId===r?.userId))}),[s.billActivities[0]?.isRealTimeApprovalEnabled,s.allApprovers,s.transactionDetails?.lastUpdatedByUserId,w,M,o.isZeni,X,r]),g.useEffect((()=>{n!=null&&a(ka(n))}),[n]),g.useEffect((()=>{b||s.fetchState=="Completed"||s.fetchState=="In-Progress"||(C(!0),a(wa(n??"",N,L,!1)))}),[b,s,n,a]),g.useEffect((()=>{I||s.fetchState!="Completed"||s.transactionDetails?.billPayInfo.stage.code=="paid"||(j(!0),a(Re(!1,N,L,J,n)),s.billActivities[0]?.isRealTimeApprovalEnabled===!0&&a(ot()))}),[I,s,n,a,N,L,J]),r==null)throw Error("Can't access address page without signing in...");return s.transactionDetails?.billPayInfo.stage.code==="draft"&&s.transactionDetails.isDeleted===!1?t.jsx(Y,{to:`./edit${l.search}`}):s.deleteStatus.fetchState==="In-Progress"||s.cancelAndDeleteStatus.fetchState==="In-Progress"||s.cancelStatus.fetchState==="In-Progress"?t.jsx(se,{fetchState:s.deleteStatus.fetchState,style:{boxShadow:`0px 2px ${A.sp1} ${c.colors.dropShadowNormal}`}}):t.jsxs(t.Fragment,{children:[t.jsx(Ae,{analytics:E,onLoad:U=>(O=>{n!=null&&O.trackBillPayBillDetails(n,s.isRecurring)})(U)}),t.jsx(bi,{initialOpenThreadRequest:d??void 0,isShowDeletedBillsEnabled:N,location:l,navigate:e,isRealTimeApprovalEnabled:B,currentTenant:o,billId:n??"",isInternationalPaymentShaVsOurEnabled:W,hasZeniAssistAccess:L,isDetectInsufficientFundsEnabled:G,isAiCfoAccessEnabled:p,onAskAiCfoClick:m})]})}const $e=De.getLocalizedStrings().spendManagement.billPay.billDetails,da=De.getLocalizedStrings().common,gi={containerWidth:new za(100,58)},ua=Q((function(e,a){const l=V.getSignedInUser(),n=e.tenantState.currentTenantId,c={userId:l?.userId??"",sessionId:l?.zeniSessionId??"",tenantId:n??""},r=a.showActionButtons,u=r&&a.file==null;return{uploadInvoiceEndPoint:`${Xa.communicationAgentMicroServiceBaseUrl}`,authParams:c,billId:a.billId,file:a.file,showAutofill:a.showAutofill,analytics:E,entityId:a.billId,showTitlebarIcon:r,showTitlebar:r&&a?.file!=null,uploadStatus:a.uploadStatus,shouldNotShowAttachment:u,style:{paddingTop:A.sp10,paddingRight:A.sp3,paddingBottom:"15px",paddingLeft:A.sp5,...a.showAutofill?{}:{backgroundColor:a.backgroundColor,paddingBottom:"128px"}}}}),(function(e,a){const l=V.getSignedInUser();return{onInvoiceUpload:n=>{n!=null&&(a.file!=null||a.billId!=null||a.isInitialEdit?(a.setPayload(n),a.setShowConfirmationPopup(!0)):e(Oe(n,a.isVendorRecommendationEnabled,a.billId)))},updateInvoiceUploadFetchState:n=>{e(St({fetchState:{fetchState:n,error:void 0},billId:a.billId}))},onSkipAutofill:n=>{E?.trackBillPaySkipAutofill(),e(Me(n))},onDeleteClick:()=>{e(gt({billId:a.billId})),E?.trackInvoiceActionClick(a.billStage??"","delete",l?.userEmail??"",null)}}}))(Un);function x({appContent:e}){const a=le(),l=q(),{billId:n}=ee(),c=K(),r=c.pathname,u=r.includes("bill/new")||r.includes("/edit"),o=Ie(),s=ue(),i=V.getSignedInUser(),{useFeatureGate:d,useDynamicConfig:p}=oe(),{isFeatureEnabled:m}=d(f.isVendorRecommendationFeatureEnabled),{isFeatureEnabled:S}=d(f.isShowDeletedBillsFeatureEnabled),{isFeatureEnabled:h}=d(f.isDepositAccountsFeatureEnabled),{isFeatureEnabled:b}=d(f.billPaySetupShowInternationalPaymentByWise),{configValue:C}=p(Ze.zeniAssistConfig),I=C.user_ids!=null&&i?.userId!=null&&C.user_ids.includes(i?.userId),j=v((P=>H(P)));di();const[B,T]=g.useState(!1),[k,$]=g.useState(!1),[N,G]=g.useState(!1),[z,X]=g.useState(),w=v((P=>Ge(P,m,h,n)));let M=w.fetchState,L=w.file,W=w.showAutofill;const J=v((P=>_e(P,n??"")));u===!1&&(M=J.fetchState,L=J.transactionDetails?.attachments?.[0],W=!1);const U=w.billPayInfo!=null&&w.billPayInfo.stage.code==="pending_approval"?w.billPayInfo.billStatus.code:w.billStage;g.useEffect((()=>{n==null&&a(Me(!0))}),[n,a]),g.useEffect((()=>{M==="Not-Started"&&(u&&k?$(!1):!u&&B&&T(!1))}),[n]),g.useEffect((()=>{B||n==null||u||(T(!0),a(wa(n,S,I,!1)),a(Da(n)),k||($(!0),a(Re(!1,S,I,b,n)))),u&&!k&&($(!0),a(Re(!1,S,I,b,n)))}),[B,k,u,n,a,S,I,b]);const O={onOkClick:()=>{if(G(!1),!z)return;const P=L!=null?"replace":"upload";E?.trackInvoiceActionClick(U??"",P,i?.userEmail??"","yes"),a(ht({replaceBillData:!0,billId:n})),a(Oe(z,m,n))},onCancelClick:()=>{if(G(!1),!z)return;const P=L!=null?"replace":"upload";E?.trackInvoiceActionClick(U??"",P,i?.userEmail??"","no"),a(bt({file:z,billId:n}))}},ae=g.useCallback((()=>{const P=Z(c.state?.pathnameStackToGoBack),ve=P.poppedPathname??ne(j.tenantEmailDomain);a(Se({billId:n})),l(ve,{state:{pathnameStackToGoBack:P.newStack}})}),[c.state,j.tenantEmailDomain,n,a,l]);if(i==null)throw Error("Can't access address page without signing in...");if(M==="Error"||J.fetchState==="Error")return t.jsx(Be,{});if(M!="Completed")return n==null&&o!=="small"?t.jsx(sa,{fallback:ae,children:t.jsxs(je,{windowSize:o,children:[t.jsx(ma,{}),t.jsx(Pe,{}),t.jsx(ua,{backgroundColor:s.colors.grey4,billId:n,file:L,showAutofill:!0,uploadStatus:w.uploadStatus,isVendorRecommendationEnabled:m,attachmentTitle:void 0,setShowConfirmationPopup:G,setPayload:X,showActionButtons:!1,isInitialEdit:!!w.isInitialEdit,billStage:U}),t.jsx(Fe,{windowSize:o,children:t.jsx(ra,{isNewBill:!0})})]})}):t.jsxs(je,{windowSize:o,children:[o==="small"||W?null:t.jsx(pa,{children:t.jsx(Ka,{onClick:ae,"data-testid":"nav-bar-back-click"})}),o!=="small"?t.jsx(Pe,{}):null,t.jsx($n,{}),t.jsx(Fe,{windowSize:o,children:t.jsx(ra,{isNewBill:n==null})})]});{const P=w.billPayInfo!=null&&w.billPayInfo.stage.code==="pending_approval"?w.billPayInfo.billStatus.code:w.billStage;return t.jsx(sa,{fallback:ae,children:t.jsxs(je,{windowSize:o,children:[W&&o!=="small"?t.jsx(ma,{}):null,N?t.jsx(Ln,{titleComponent:t.jsx(wi,{children:$e.overwriteTitle}),descriptionComponent:t.jsx(xi,{children:$e.overwriteDescription}),primaryButtonText:da.yes,secondaryButtonText:da.no,action:O,isEditPopup:!0}):null,o==="small"||W?null:t.jsx(pa,{children:t.jsx(Si,{})}),o!=="small"?t.jsx(Pe,{}):null,t.jsx(ua,{backgroundColor:s.colors.grey4,billId:n,file:L,showAutofill:W,uploadStatus:w.uploadStatus,isVendorRecommendationEnabled:m,attachmentTitle:yi(u,J,w),setShowConfirmationPopup:G,setPayload:X,showActionButtons:fi(u,w),isInitialEdit:!!w.isInitialEdit,billStage:P}),t.jsx(Fe,{windowSize:o,children:e})]})})}}function Si(){const{triggerBack:e}=Gn();return t.jsx(Ka,{onClick:e,"data-testid":"nav-bar-back-click"})}function yi(e,a,l){let n,c;return e?(n=l.recurringConfig?.currentInstance,c=l.recurringConfig?.totalPaymentCycles):(n=a.transactionDetails?.recurringBillInstance,c=a.recurringBillConfigDetail?.totalPaymentCycles),a?.isRecurring===!0?t.jsxs(Ii,{children:[t.jsx(vi,{children:`${$e.recurringBill.recurringCycle}
2
2
  ${n}/${c}`}),t.jsx(ki,{})]}):void 0}function fi(e,a){const l=a.billActivities?.[0],n=a.billStage==="pending_approval"&&l?.areApprovalsSerialized===!0&&l?.currentPendingStepIndex===0;return e&&(a.billStage==="draft"||n)}const pa=_.div`
3
3
  margin-bottom: 20px;
4
4
  margin-top: 20px;
@@ -1,4 +1,4 @@
1
- import{a as O}from"./sentry-DWNq3t8E.js";import{u as q,j as h,h as se,g as oe,i as ie,N as re,l as ce}from"./core-CbdTrw7T.js";import{fJ as R,Iu as ue,II as de,LU as le,OK as pe,Po as me,Qd as fe,a18 as ye,Cn as Se,Tt as ge,a1l as Ie,a1m as he,a1n as be,a1o as Te,a1p as Ce,a1q as De,a1r as Oe,YV as ke,a1s as Ve,N4 as we,MY as Ae,a1t as Ne,N0 as ve,mT as Fe,gK as _e,gJ as xe,gI as Ee,vr as Be,vi as Re,vf as ze,mL as Pe,Cw as Le,Cu as z,bF as P,CI as L,cw as Ue}from"./zeni-epic-state-C5DO1jkr.js";import{b0 as Me,V as je,p as Ge,au as Ke,z as B,a9 as qe,c as U,B as x,R as E,d0 as Je,af as Ye,s as M,bg as j}from"./index-CnIO6_IQ.js";import{n as Ze}from"./mui-DNGY4bFU.js";import{j as w}from"./liveblocks-BLpmr1Pv.js";import{d as G}from"./routePaths-CV12X_S-.js";import{M as $e}from"./MobileAppDrawer-BWNb5zLN.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="e8a48be9-16e9-413a-9aef-d92170f1817a",e._sentryDebugIdIdentifier="sentry-dbid-e8a48be9-16e9-413a-9aef-d92170f1817a")}catch{}})();function it(){const e=q(),r=h((u=>R(u))),a=r?.tenantId,{isApprovalRulesV3Enabled:s,isLoading:l}=Me(a),p=h((u=>u.billPaySetupApproverViewState.fetchState));O.useEffect((()=>{a==null||l||p==="Not-Started"&&e(ue(!0,!0,s))}),[a,l,s,p,e])}function K(e,r,a,s=!1){switch(r){case"zeni_accounts":e(fe(a,!0,s));break;case"zeni_treasury":e(me(a,!0,s));break;case"reimbursement":e(pe(a,!0,s));break;case"charge_cards":e(le(a,!0,s));break;default:e(de(a,!0,s))}}const Qe=Ze.div`
1
+ import{a as O}from"./sentry-DWNq3t8E.js";import{u as q,j as h,h as se,g as oe,i as ie,N as re,l as ce}from"./core-CbdTrw7T.js";import{fJ as R,Iu as ue,II as de,LU as le,OK as pe,Po as me,Qd as fe,a18 as ye,Cn as Se,Tt as ge,a1l as Ie,a1m as he,a1n as be,a1o as Te,a1p as Ce,a1q as De,a1r as Oe,YV as ke,a1s as Ve,N4 as we,MY as Ae,a1t as Ne,N0 as ve,mT as Fe,gK as _e,gJ as xe,gI as Ee,vr as Be,vi as Re,vf as ze,mL as Pe,Cw as Le,Cu as z,bF as P,CI as L,cw as Ue}from"./zeni-epic-state-C5DO1jkr.js";import{b0 as Me,V as je,p as Ge,au as Ke,z as B,a9 as qe,c as U,B as x,R as E,d0 as Je,af as Ye,s as M,bg as j}from"./index-DtThPd2q.js";import{n as Ze}from"./mui-DNGY4bFU.js";import{j as w}from"./liveblocks-BLpmr1Pv.js";import{d as G}from"./routePaths-DXYV831_.js";import{M as $e}from"./MobileAppDrawer-CCAbxLE2.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},r=new e.Error().stack;r&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[r]="e8a48be9-16e9-413a-9aef-d92170f1817a",e._sentryDebugIdIdentifier="sentry-dbid-e8a48be9-16e9-413a-9aef-d92170f1817a")}catch{}})();function it(){const e=q(),r=h((u=>R(u))),a=r?.tenantId,{isApprovalRulesV3Enabled:s,isLoading:l}=Me(a),p=h((u=>u.billPaySetupApproverViewState.fetchState));O.useEffect((()=>{a==null||l||p==="Not-Started"&&e(ue(!0,!0,s))}),[a,l,s,p,e])}function K(e,r,a,s=!1){switch(r){case"zeni_accounts":e(fe(a,!0,s));break;case"zeni_treasury":e(me(a,!0,s));break;case"reimbursement":e(pe(a,!0,s));break;case"charge_cards":e(le(a,!0,s));break;default:e(de(a,!0,s))}}const Qe=Ze.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-BLpmr1Pv.js";import{a as r}from"./sentry-DWNq3t8E.js";import{u as he,h as Ce,g as fe,j as M,i as ge,l as Se}from"./core-CbdTrw7T.js";import{ee as be,g as ye,ef as Pe,z as Ie,eh as we,ej as W,ek as Ee,aD as G,a9 as ke,c as F,el as H,ev as xe,G as Ae,R as Te,w as Oe,eo as Ue,ep as ve,aj as _e,es as Qe,et as je,aw as De,eu as Fe}from"./index-CnIO6_IQ.js";import{gO as $e,fI as J,fJ as Le,gc as Ve,jx as Re,jt as qe,fK as N,gy as Be,gs as Me,gu as z,gA as He,gB as Ne,gC as ze,gD as We,gE as Ge}from"./zeni-epic-state-C5DO1jkr.js";import{D as Je,n as L,v as Ke,S as Ye}from"./mui-DNGY4bFU.js";import"./recharts-CTh_JhT_.js";import"./analytics-Vgn85Ur_.js";import"./plaid-DhfTjhua.js";import"./dnd-DuiAlI7w.js";import"./stripe-cKAAJElX.js";import"./lottie-Lb1ftKY1.js";import"./lexical-B-vxEaRQ.js";import"./pdf-B1uD4Ovv.js";import"./utils-CrhrpmD8.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new t.Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="ac55cec6-9f99-4f00-aa81-c54290655787",t._sentryDebugIdIdentifier="sentry-dbid-ac55cec6-9f99-4f00-aa81-c54290655787")}catch{}})();const K="chat-response-generated",Y="cards/ask",X="card_policy_hero";function $(t){return`/${t}/cards`}function Z(t){return`/${t}/cards/policy`}const Xe=Se((function(t,s){const c=J(t),l=s.isSubmitting,u=ve(t,{allUsers:s.allUsers,onCardPolicyVendorSearchTextChange:s.onCardPolicyVendorSearchTextChange});return{showSampleQuestions:s.sessionFromUrl==="new_chat"&&c.uiState.currentChatSessionId==null,aiCfoView:c,isSubmitting:l,isNewChatSession:s.sessionFromUrl==="new_chat",isFullView:!0,tableDownloadEndPoint:`${_e}/tableDownload`,exportDownloadEndPoint:Qe(),emailLinkQuestion:s.emailLinkQuestion,autoSubmitEmailLinkQuestion:s.autoSubmitEmailLinkQuestion,onEmailLinkQuestionProcessed:s.onEmailLinkQuestionProcessed,isFileUploadEnabled:s.isFileUploadEnabled,isUploadPromoVisible:s.isUploadPromoVisible,onUploadPromoClose:s.onUploadPromoClose,...u}}),(function(t,s){const{location:c,currentTenant:l,userId:u,navigate:o,currentChatSessionId:y,allSessionsWithOrderedQuestionAnswers:C,isAiCardCreationEnabled:x,isCardPolicyEnabled:A,cardPolicyPageContext:T}=s,f=l.tenantEmailDomain,d=c.state?.referrer,h=d===X?Z(f):$(f);return{onEventReceived:(a,n)=>{if(a===K&&typeof n.text=="string"&&typeof n.metadata=="object"){const e=n,m=Ne(e.type),P=e.metadata.chat_session_id??null,{currentChatSession:O,currentQuestionAnswer:b,currentQuestionAnswerSummary:p}=G(C,P);m!=="answer"?F.trackAICFOChatResponseGenerated(m,b?.question.questionText??"",e.text,P,Fe(p,O),e.metadata.message_id??null):F.trackAICFOChatAnswerGenerated(e.text,b?.question.questionText??"",(e.follow_up_questions?.length??0)>0,!!e.assumptions,!!e.insights,e.visualization!=null,ze(e.visualization?.type??"")??null,P,e.summarized_title,e.metadata.message_id??null),t(We({chatSessionId:e.metadata.chat_session_id,responseType:m,fetchState:{fetchState:"Completed",error:void 0}})),t(Ge({chatSessionId:e.metadata.chat_session_id,answerPayload:e,userId:u}))}},onSubmit:(a,n,e,m)=>{a&&De(t,a,n,y,C,u,m,e,T)},updateCurrentInput:a=>{t(z(a))},onStopSubmit:()=>{},onUpdateScrollYOffset:a=>{t(He(a))},onSelectSampleQuestion:()=>{},onBackClick:()=>{o(-1)},onCloseClick:()=>{o(h,{state:{...c.state}}),t(z(""))},togglePageView:()=>{o(h,{state:W(c.state)}),s.setIsAiCfoOpen(!0)},onCopy:()=>{},onThumbsUp:()=>{},onThumbsDown:()=>{},onTogglePageView:()=>{o(-1)},onNewChatClick:()=>{y!=null&&t(Me()),o((function(a){return`/${a}/${Y}`})(f),{state:{...c.state}})},onToggleCotCollapsed:(a,n)=>{t(Be({questionAnswerId:a,isCollapsed:n}))},...je(t,{isAiCardCreationEnabled:x,isCardPolicyEnabled:A,currentChatSessionId:y,onAfterCardsCreationSubmit:()=>{s.setIsAiCfoOpen(!0),o($(f),{state:{...c.state}})},onAfterCardPolicySubmit:()=>{s.setIsAiCfoOpen(!0),o(`/${f}/cards/policy`,{state:{...c.state}})}})}}))(Oe(Ue)),{spendManagement:{chargeCard:{cardsAiCfoHero:ee,cardPolicyAiCfoHero:te}}}=Ae.getLocalizedStrings(),k=ee.pageTitle,Ze=te.pageTitle,et=ee.chatHeaderSubtitle,tt=te.chatHeaderSubtitle,yt=({isFileUploadEnabled:t})=>{const s=be(),{setIsAiCfoOpen:c}=ye(),l=he(),u=Ce(),o=fe(),[y,C]=r.useState(!1),{allUsers:x,isAiCardCreationEnabled:A,isCardPolicyEnabled:T,onCardPolicyVendorSearchTextChange:f}=Pe();r.useEffect((()=>{l($e())}),[l]);const d=M((i=>J(i))),h=Ie.getSignedInUser(),{session_id:a}=ge(),n=M((i=>Le(i))),e=d.uiState.currentChatSessionId,m=n.tenantEmailDomain,{handleUploadPromoClose:P,isUploadPromoVisible:O}=we({isFileUploadEnabled:t,tenantEmailDomain:m}),b=o.state,p=b?.aiCfoInitialQuestion??null,U=!!b?.aiCfoShouldSubmit,I=b?.referrer===X,se=I?"card_policy":void 0,ae=r.useMemo((()=>({title:I?Ze:k,subtitle:I?tt:et})),[I]),[oe,v]=r.useState(null),[ne,_]=r.useState(!1),Q=r.useRef(!1);r.useEffect((()=>{Q.current||p==null||p===""||(v(p),_(U),Q.current=!0)}),[p,U]);const ie=r.useCallback((()=>{v(null),_(!1),u(o.pathname,{replace:!0,state:W(o.state)})}),[o.pathname,o.state,u]),re=n.masterTOSInfo,g=re?.isMasterTOSAccepted??!1,E=r.useRef(null);r.useEffect((()=>{if(g&&E.current!=null){const{question:i,shouldSubmit:w}=E.current;E.current=null,v(i),_(w),Q.current=!1}}),[g]);const{visitedSessions:V}=Ee(e),j=d.fetchState,D=d.uiState.chatSessionsNextPageToken.hasMore||!d.uiState.chatSessionsFirstPageFetched,R=e!=null?d.fetchChatSessionHistoryByChatSessionId?.[e]?.fetchState??"Not-Started":"Not-Started",q=e==null||(d.uiState.chatHistoryNextPageToken[e]?.hasMore??!0),B=d.allSessionsWithOrderedQuestionAnswers,{currentSessionQuestionAnswers:le}=G(B,e),ce=le.length===0;r.useEffect((()=>{e!=null&&a!==e&&u((function(i,w){return`/${i}/${Y}/${w}`})(m,e),{state:{...o.state},replace:!0})}),[e,a,m,u,o.state]),r.useEffect((()=>{a!=null&&e==null&&a!=="new_chat"&&l(Ve({sessionId:a,agentId:"controller"}))}),[]);const de=r.useMemo((()=>({events:V.map((i=>`private-encrypted-chat-${i}.${K}`)),eventCallback:(i,w,pe)=>pe.onEventReceived(i,w)})),[V]);if(r.useEffect((()=>{j!=="In-Progress"&&D&&l(Re())}),[j,D,l]),r.useEffect((()=>{e!=null&&R!=="In-Progress"&&q&&h!=null&&j==="Completed"&&!D&&l(qe(e,h.userId))}),[R,q,e,h,l]),h==null)throw Error("Can't access Cards AI CFO page without signing in...");const ue=a??"new_chat",me=e!=null&&d.responseStateByChatSessionId?.[e]?.answer?.fetchState==="In-Progress";return S.jsxs(at,{children:[S.jsx(ke,{analytics:F,onLoad:i=>i.trackPageLoaded(Te.Event.aiCFOPage)}),g?S.jsx(Xe,{answerExportEndPoint:s,...de,currentChatSessionId:e,allSessionsWithOrderedQuestionAnswers:B,allUsers:x,isAiCardCreationEnabled:A,isCardPolicyEnabled:T,openOnboardingPage:()=>C(!0),userId:h.userId,setIsAiCfoOpen:c,navigate:u,sessionFromUrl:ue,location:o,isSubmitting:me,isEmptyChatWithSession:ce,customPageTitle:k,chatHeader:ae,currentTenant:n,emailLinkQuestion:oe??void 0,autoSubmitEmailLinkQuestion:ne,onEmailLinkQuestionProcessed:ie,isFileUploadEnabled:t,isUploadPromoVisible:O,onUploadPromoClose:P,onCardPolicyVendorSearchTextChange:f,cardPolicyPageContext:se}):S.jsx(H,{isTOSAccepted:g,acceptMasterTOSState:d.masterTOSAcceptanceState,customPageTitle:k,onCloseClick:()=>{u(I?Z(m):$(m),{state:{...o.state}})},onCompleteClick:()=>{g||n.userRoleId==null||(p!=null&&p!==""&&(E.current={question:p,shouldSubmit:U}),l(N(n.userRoleId)))}}),S.jsx(Je,{anchor:"right",open:y,transitionDuration:250,PaperProps:{component:ot,style:{width:`${xe}vw`}},slotProps:{backdrop:{style:{backgroundColor:"transparent",cursor:"pointer"}}},onClose:()=>C(!1),children:S.jsx(st,{onClick:i=>i.stopPropagation(),children:S.jsx(H,{isTOSAccepted:g,acceptMasterTOSState:d.masterTOSAcceptanceState,customPageTitle:k,onCloseClick:()=>C(!1),onCompleteClick:()=>{g||n.userRoleId==null||l(N(n.userRoleId)),C(!1)}})})})]})},st=L(Ye)`
1
+ import{j as S}from"./liveblocks-BLpmr1Pv.js";import{a as r}from"./sentry-DWNq3t8E.js";import{u as he,h as Ce,g as fe,j as M,i as ge,l as Se}from"./core-CbdTrw7T.js";import{ee as be,g as ye,ef as Pe,z as Ie,eh as we,ej as W,ek as Ee,aD as G,a9 as ke,c as F,el as H,ev as xe,G as Ae,R as Te,w as Oe,eo as Ue,ep as ve,aj as _e,es as Qe,et as je,aw as De,eu as Fe}from"./index-DtThPd2q.js";import{gO as $e,fI as J,fJ as Le,gc as Ve,jx as Re,jt as qe,fK as N,gy as Be,gs as Me,gu as z,gA as He,gB as Ne,gC as ze,gD as We,gE as Ge}from"./zeni-epic-state-C5DO1jkr.js";import{D as Je,n as L,v as Ke,S as Ye}from"./mui-DNGY4bFU.js";import"./recharts-CTh_JhT_.js";import"./analytics-Vgn85Ur_.js";import"./plaid-DhfTjhua.js";import"./dnd-DuiAlI7w.js";import"./stripe-cKAAJElX.js";import"./lottie-Lb1ftKY1.js";import"./lexical-B-vxEaRQ.js";import"./pdf-B1uD4Ovv.js";import"./utils-CrhrpmD8.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new t.Error().stack;s&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[s]="ac55cec6-9f99-4f00-aa81-c54290655787",t._sentryDebugIdIdentifier="sentry-dbid-ac55cec6-9f99-4f00-aa81-c54290655787")}catch{}})();const K="chat-response-generated",Y="cards/ask",X="card_policy_hero";function $(t){return`/${t}/cards`}function Z(t){return`/${t}/cards/policy`}const Xe=Se((function(t,s){const c=J(t),l=s.isSubmitting,u=ve(t,{allUsers:s.allUsers,onCardPolicyVendorSearchTextChange:s.onCardPolicyVendorSearchTextChange});return{showSampleQuestions:s.sessionFromUrl==="new_chat"&&c.uiState.currentChatSessionId==null,aiCfoView:c,isSubmitting:l,isNewChatSession:s.sessionFromUrl==="new_chat",isFullView:!0,tableDownloadEndPoint:`${_e}/tableDownload`,exportDownloadEndPoint:Qe(),emailLinkQuestion:s.emailLinkQuestion,autoSubmitEmailLinkQuestion:s.autoSubmitEmailLinkQuestion,onEmailLinkQuestionProcessed:s.onEmailLinkQuestionProcessed,isFileUploadEnabled:s.isFileUploadEnabled,isUploadPromoVisible:s.isUploadPromoVisible,onUploadPromoClose:s.onUploadPromoClose,...u}}),(function(t,s){const{location:c,currentTenant:l,userId:u,navigate:o,currentChatSessionId:y,allSessionsWithOrderedQuestionAnswers:C,isAiCardCreationEnabled:x,isCardPolicyEnabled:A,cardPolicyPageContext:T}=s,f=l.tenantEmailDomain,d=c.state?.referrer,h=d===X?Z(f):$(f);return{onEventReceived:(a,n)=>{if(a===K&&typeof n.text=="string"&&typeof n.metadata=="object"){const e=n,m=Ne(e.type),P=e.metadata.chat_session_id??null,{currentChatSession:O,currentQuestionAnswer:b,currentQuestionAnswerSummary:p}=G(C,P);m!=="answer"?F.trackAICFOChatResponseGenerated(m,b?.question.questionText??"",e.text,P,Fe(p,O),e.metadata.message_id??null):F.trackAICFOChatAnswerGenerated(e.text,b?.question.questionText??"",(e.follow_up_questions?.length??0)>0,!!e.assumptions,!!e.insights,e.visualization!=null,ze(e.visualization?.type??"")??null,P,e.summarized_title,e.metadata.message_id??null),t(We({chatSessionId:e.metadata.chat_session_id,responseType:m,fetchState:{fetchState:"Completed",error:void 0}})),t(Ge({chatSessionId:e.metadata.chat_session_id,answerPayload:e,userId:u}))}},onSubmit:(a,n,e,m)=>{a&&De(t,a,n,y,C,u,m,e,T)},updateCurrentInput:a=>{t(z(a))},onStopSubmit:()=>{},onUpdateScrollYOffset:a=>{t(He(a))},onSelectSampleQuestion:()=>{},onBackClick:()=>{o(-1)},onCloseClick:()=>{o(h,{state:{...c.state}}),t(z(""))},togglePageView:()=>{o(h,{state:W(c.state)}),s.setIsAiCfoOpen(!0)},onCopy:()=>{},onThumbsUp:()=>{},onThumbsDown:()=>{},onTogglePageView:()=>{o(-1)},onNewChatClick:()=>{y!=null&&t(Me()),o((function(a){return`/${a}/${Y}`})(f),{state:{...c.state}})},onToggleCotCollapsed:(a,n)=>{t(Be({questionAnswerId:a,isCollapsed:n}))},...je(t,{isAiCardCreationEnabled:x,isCardPolicyEnabled:A,currentChatSessionId:y,onAfterCardsCreationSubmit:()=>{s.setIsAiCfoOpen(!0),o($(f),{state:{...c.state}})},onAfterCardPolicySubmit:()=>{s.setIsAiCfoOpen(!0),o(`/${f}/cards/policy`,{state:{...c.state}})}})}}))(Oe(Ue)),{spendManagement:{chargeCard:{cardsAiCfoHero:ee,cardPolicyAiCfoHero:te}}}=Ae.getLocalizedStrings(),k=ee.pageTitle,Ze=te.pageTitle,et=ee.chatHeaderSubtitle,tt=te.chatHeaderSubtitle,yt=({isFileUploadEnabled:t})=>{const s=be(),{setIsAiCfoOpen:c}=ye(),l=he(),u=Ce(),o=fe(),[y,C]=r.useState(!1),{allUsers:x,isAiCardCreationEnabled:A,isCardPolicyEnabled:T,onCardPolicyVendorSearchTextChange:f}=Pe();r.useEffect((()=>{l($e())}),[l]);const d=M((i=>J(i))),h=Ie.getSignedInUser(),{session_id:a}=ge(),n=M((i=>Le(i))),e=d.uiState.currentChatSessionId,m=n.tenantEmailDomain,{handleUploadPromoClose:P,isUploadPromoVisible:O}=we({isFileUploadEnabled:t,tenantEmailDomain:m}),b=o.state,p=b?.aiCfoInitialQuestion??null,U=!!b?.aiCfoShouldSubmit,I=b?.referrer===X,se=I?"card_policy":void 0,ae=r.useMemo((()=>({title:I?Ze:k,subtitle:I?tt:et})),[I]),[oe,v]=r.useState(null),[ne,_]=r.useState(!1),Q=r.useRef(!1);r.useEffect((()=>{Q.current||p==null||p===""||(v(p),_(U),Q.current=!0)}),[p,U]);const ie=r.useCallback((()=>{v(null),_(!1),u(o.pathname,{replace:!0,state:W(o.state)})}),[o.pathname,o.state,u]),re=n.masterTOSInfo,g=re?.isMasterTOSAccepted??!1,E=r.useRef(null);r.useEffect((()=>{if(g&&E.current!=null){const{question:i,shouldSubmit:w}=E.current;E.current=null,v(i),_(w),Q.current=!1}}),[g]);const{visitedSessions:V}=Ee(e),j=d.fetchState,D=d.uiState.chatSessionsNextPageToken.hasMore||!d.uiState.chatSessionsFirstPageFetched,R=e!=null?d.fetchChatSessionHistoryByChatSessionId?.[e]?.fetchState??"Not-Started":"Not-Started",q=e==null||(d.uiState.chatHistoryNextPageToken[e]?.hasMore??!0),B=d.allSessionsWithOrderedQuestionAnswers,{currentSessionQuestionAnswers:le}=G(B,e),ce=le.length===0;r.useEffect((()=>{e!=null&&a!==e&&u((function(i,w){return`/${i}/${Y}/${w}`})(m,e),{state:{...o.state},replace:!0})}),[e,a,m,u,o.state]),r.useEffect((()=>{a!=null&&e==null&&a!=="new_chat"&&l(Ve({sessionId:a,agentId:"controller"}))}),[]);const de=r.useMemo((()=>({events:V.map((i=>`private-encrypted-chat-${i}.${K}`)),eventCallback:(i,w,pe)=>pe.onEventReceived(i,w)})),[V]);if(r.useEffect((()=>{j!=="In-Progress"&&D&&l(Re())}),[j,D,l]),r.useEffect((()=>{e!=null&&R!=="In-Progress"&&q&&h!=null&&j==="Completed"&&!D&&l(qe(e,h.userId))}),[R,q,e,h,l]),h==null)throw Error("Can't access Cards AI CFO page without signing in...");const ue=a??"new_chat",me=e!=null&&d.responseStateByChatSessionId?.[e]?.answer?.fetchState==="In-Progress";return S.jsxs(at,{children:[S.jsx(ke,{analytics:F,onLoad:i=>i.trackPageLoaded(Te.Event.aiCFOPage)}),g?S.jsx(Xe,{answerExportEndPoint:s,...de,currentChatSessionId:e,allSessionsWithOrderedQuestionAnswers:B,allUsers:x,isAiCardCreationEnabled:A,isCardPolicyEnabled:T,openOnboardingPage:()=>C(!0),userId:h.userId,setIsAiCfoOpen:c,navigate:u,sessionFromUrl:ue,location:o,isSubmitting:me,isEmptyChatWithSession:ce,customPageTitle:k,chatHeader:ae,currentTenant:n,emailLinkQuestion:oe??void 0,autoSubmitEmailLinkQuestion:ne,onEmailLinkQuestionProcessed:ie,isFileUploadEnabled:t,isUploadPromoVisible:O,onUploadPromoClose:P,onCardPolicyVendorSearchTextChange:f,cardPolicyPageContext:se}):S.jsx(H,{isTOSAccepted:g,acceptMasterTOSState:d.masterTOSAcceptanceState,customPageTitle:k,onCloseClick:()=>{u(I?Z(m):$(m),{state:{...o.state}})},onCompleteClick:()=>{g||n.userRoleId==null||(p!=null&&p!==""&&(E.current={question:p,shouldSubmit:U}),l(N(n.userRoleId)))}}),S.jsx(Je,{anchor:"right",open:y,transitionDuration:250,PaperProps:{component:ot,style:{width:`${xe}vw`}},slotProps:{backdrop:{style:{backgroundColor:"transparent",cursor:"pointer"}}},onClose:()=>C(!1),children:S.jsx(st,{onClick:i=>i.stopPropagation(),children:S.jsx(H,{isTOSAccepted:g,acceptMasterTOSState:d.masterTOSAcceptanceState,customPageTitle:k,onCloseClick:()=>C(!1),onCompleteClick:()=>{g||n.userRoleId==null||l(N(n.userRoleId)),C(!1)}})})})]})},st=L(Ye)`
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-BLpmr1Pv.js";import{u as le,j as d,h as ie,g as me,i as Ve,N as Qe,s as _t,l as Pe,t as _n,n as os,o as ne}from"./core-CbdTrw7T.js";import{fW as Dt,Zv as cs,g6 as Pt,bs as Fe,Zw as is,Zx as ds,fL as hn,Zy as Dn,fU as Pn,Zz as wn,ZA as Tn,ZB as vn,ZC as Fn,fV as xn,g5 as Ln,ZD as Bn,ZE as ls,f$ as us,f_ as ms,ZF as Cs,KZ as Rn,g8 as ia,ZG as ps,ZH as hs,fN as fs,fM as gs,gl as Ke,g1 as On,g0 as Un,ZI as bs,g2 as Ss,Kv as ys,Ku as Is,Ky as ks,KA as Es,ge as As,fI as jn,ZJ as _s,ZK as Ds,gj as Mn,ZL as Ps,gk as St,KG as ws,KD as Ts,fJ as ge,ZM as Wa,eq as xe,d4 as Le,er as Be,h3 as da,ct as la,ZN as ua,ZO as wt,DI as Ga,mj as $a,ZP as Za,Ld as Ia,g9 as Je,Lf as Tt,m9 as Nn,ZQ as ma,L1 as _a,ZR as vs,ZS as Fs,L4 as qa,ZT as xs,ZU as Ja,g4 as Vn,La as ga,iC as Ls,ZV as Hn,fX as Ca,bw as Bs,ZW as Rs,gK as Qa,gJ as Xa,LJ as Os,gI as et,ZX as Gn,cm as $n,ec as Us,ZY as Pa,Mi as Zn,ZZ as fn,LU as Da,Z_ as zn,Mj as js,Yx as Ms,Mk as Ns,Ns as Vs,CY as Hs,Nm as Gs,Z$ as $s,Le as oa,_0 as Zs,_1 as zs,_2 as Ks,_3 as Ys,_4 as Ws,_5 as vt,_6 as qs,Lu as Kn,Ln as Js,_7 as Qs,h5 as Xs,_8 as Yn,LD as Wn,LH as qn,h4 as eo,_9 as ao,M4 as Jn,_a as to,_b as no,_c as ro,LF as Qn,Lq as Xn,L7 as er,Lz as ar,Lx as tr,LB as so,_d as nr,_e as oo,gg as co,gh as io,gi as lo,_f as at,ga as rr,ee as Ft,_g as uo,_h as mo,_i as Co,_j as po,LP as yt,Mb as ho,M7 as fo,LL as go,M9 as bo,L$ as So,M1 as yo,_k as sr,Mh as Ha,Tp as Io,_l as ko,_m as Eo,_n as Ao,_o as or,_p as _o,ME as Do,LT as cr,LO as Ne,LS as Po,_q as wo,_r as To,K_ as vo,_s as ir,g3 as dr,_t as Fo,L0 as xo,K$ as gn,_u as Lo,_v as Bo,_w as Ro,_x as Oo,_y as xt,_z as Uo,xY as lr,mT as jo,is as Mo,MJ as No,_A as ur,fR as Vo,fS as Ho,_B as Go,dB as $o,g7 as Zo,Mz as zo,Mt as qe,bp as Ko,bK as Yo,cz as Wo,bL as qo,hb as Jo}from"./zeni-epic-state-C5DO1jkr.js";import{V as Re,bs as mr,a5 as we,bt as Cr,bu as pr,bv as Qo,G as aa,al as Lt,bw as Xo,bx as ec,g as hr,a as fr,ar as gr,s as Ee,p as de,_ as q,o as Sa,by as br,bz as ac,bA as tc,z as te,a8 as wa,bB as tt,bC as nc,bD as rc,bE as sc,a2 as Ta,au as Xe,aT as Bt,bF as oc,ac as va,W as nt,c as ee,w as rt,bG as cc,bH as ba,bI as It,bJ as ic,a9 as Rt,bK as dc,af as Sr,aj as kt,bL as lc,aC as yr,K as Ir,R as kr,aB as uc,bM as mc,bN as Cc,bO as pc,bP as hc,bQ as fc,bR as gc,N as za,bS as bc,bT as Sc,v as pt,j as yc,bU as Ic,bV as kc,bW as Ec,az as Ac,bX as _c,bY as Dc,i as Pc}from"./index-CnIO6_IQ.js";import{n as He,u as Ot,D as Er,S as wc}from"./mui-DNGY4bFU.js";import{a as r}from"./sentry-DWNq3t8E.js";import{u as Fa}from"./useAskAiCfoHostNavButtonProps-DXFswt7R.js";import{M as Ae}from"./MobileAppDrawer-BWNb5zLN.js";import{d as Ut}from"./recharts-CTh_JhT_.js";import{g as De,a as xa,b as Ar,c as Oe,d as Ue,e as ea,f as ta,h as na,A as Tc,i as jt,P as vc,j as Mt,s as ya,k as _r,l as ca,m as Dr,n as Fc,o as Pr,p as xc,S as bn}from"./SetupPagesScreen-D6ssIWb0.js";import{u as wr}from"./useInitialThreadRequest-DAUsQlCl.js";import st from"./NotFoundScreen-DXy-BCit.js";import{u as Nt}from"./useChargeCardPusherEvents-Cq6Y4mMW.js";import{n as Sn}from"./utils-CrhrpmD8.js";import{t as Lc}from"./AddressScreen-DgUwrml_.js";import"./analytics-Vgn85Ur_.js";import"./plaid-DhfTjhua.js";import"./dnd-DuiAlI7w.js";import"./stripe-cKAAJElX.js";import"./lottie-Lb1ftKY1.js";import"./lexical-B-vxEaRQ.js";import"./pdf-B1uD4Ovv.js";import"./InboxNotificationsProvider-CiKEEv6Q.js";import"./useTaskManagerAccess-Cm5trA3i.js";import"./useIsCustomersTabEnabled-C6mkabn2.js";import"./BusinessVerificationPageScreen-DM_jBIuD.js";import"./routePaths-CV12X_S-.js";import"./analyticsHelper-CWMk7_rd.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]="6c3cb974-63c3-4efb-999b-8acf18e8db62",e._sentryDebugIdIdentifier="sentry-dbid-6c3cb974-63c3-4efb-999b-8acf18e8db62")}catch{}})();const Bc=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:Bc(e),utilizationAmount:(e.limit?.amount??0)-(e.available?.amount??0)});function vr(){const e=le(),a=d((t=>Dt(t.cardPolicyState))),n=d((t=>cs(t.cardPolicyState)));r.useEffect((()=>{n!==""||a==="Completed"&&n===""||a==="In-Progress"||e(Pt())}),[e,a,n])}const{spendManagement:{chargeCard:{cardPolicyPage:yn}}}=aa.getLocalizedStrings(),Rc=e=>On(e,!1),Oc=e=>Un(e.name,!1);function Uc(){const e=ie(),a=me(),{tenantEmailDomain:n}=Ve(),t=le(),s=Re(),f=Fe(s?.loggedInUserRoleMap),[b,m]=r.useState(!1),A=r.useCallback((P=>{m(P)}),[]),u=r.useCallback((()=>{A(!0)}),[A]),{isAiCfoAccessEnabled:l,onAskAiCfoClick:B}=Fa({mobileExploreReferrer:"Card Policy"});r.useEffect((()=>()=>{t(is()),t(ds()),t(hn())}),[t]);const _=d((P=>Dn(P.cardPolicyState))),C=d((P=>Pn(P.cardPolicyState))),O=d((P=>wn(P.cardPolicyState))),U=d((P=>Tn(P.cardPolicyState))),S=d((P=>vn(P.cardPolicyState))),c=d((P=>Fn(P.cardPolicyState))),p=d((P=>xn(P.cardPolicyState))),x=d((P=>Dt(P.cardPolicyState))),E=d((P=>P.chargeCardConfigState.receiptRequiredAboveAmount.amount)),I=d((P=>P.chargeCardConfigState.fetchState));r.useEffect((()=>{_!=="Completed"&&_!=="In-Progress"&&t(Ln())}),[t,_]),vr();const k=d((P=>Bn(P.createCardPolicyState))),V=d((P=>ls(P.createCardPolicyState))),w=d((P=>us(P.cardPolicyState))),y=d((P=>ms(P.cardPolicyState))),F=d((P=>Cs(P.createCardPolicyState))),i=d((P=>Rn(P)));r.useEffect((()=>{i.fetchState==="Not-Started"&&t(ia(!1,!1,!1))}),[i.fetchState,t]);const g=r.useMemo((()=>C.map(Rc)),[C]),R=r.useMemo((()=>p.map(Oc)),[p]),G=r.useMemo((()=>i.cards.filter((P=>!mr(P.status.code))).map(Tr)),[i.cards]),M=_==="Completed"&&i.fetchState==="Completed"&&I==="Completed";r.useEffect((()=>{M&&F==null&&t(ps({cardsMasterList:G,defaultRequireReceiptAmount:E,suggestedAllowMerchants:O,suggestedBlockMerchants:U,suggestedAllowCategories:S,suggestedBlockCategories:c}))}),[I,t,M,F,G,E,O,U,S,c]);const L=r.useMemo((()=>Ut((P=>{t(Pt(P))}),250)),[t]);r.useEffect((()=>()=>{L.cancel()}),[L]);const z=r.useCallback((P=>{L(P)}),[L]),j=k.fetchState,h=n!=null?`/${n}/cards/policy`:"..",H=r.useCallback((()=>{const P=we(a.state?.pathnameStackToGoBack),ae=P.poppedPathname??h;e(ae,{state:{pathnameStackToGoBack:P.newStack}})}),[a.state,e,h]),K=r.useCallback((()=>{e(h)}),[e,h]),D=r.useCallback((P=>{t(hs(P))}),[t]),W=r.useCallback((P=>{const ae=Cr(P);t(fs({templates:[ae]}))}),[t]),N=r.useCallback((P=>{P.length!==0&&t(gs(P))}),[t]),$=r.useCallback((()=>{t(hn())}),[t]),v=r.useRef(j);r.useEffect((()=>{const P=v.current;v.current=j,j==="Completed"&&P!=="Completed"&&V!=null&&(t(Ke({messageSection:"card_policy_created",messageText:"success",type:"success"})),e(h))}),[t,j,V,e,h]);const T=j==="Error"?k.error?.message??yn.createPolicyGenericErrorMessage:void 0;return f&&n!=null?F==null?o.jsxs(o.Fragment,{children:[o.jsx(Ae,{isAppContentDrawerOpen:b,handleDrawerToggle:A}),o.jsx(pr,{showUploadDocumentSection:!0,navBarTitle:yn.createPageTitle,onBackClick:H,onClickMenuIcon:u,isAiCfoAccessEnabled:l,onAskAiCfoClick:B})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ae,{isAppContentDrawerOpen:b,handleDrawerToggle:A}),o.jsx(Qo,{formDraft:F,vendorSearchOptions:R,categorySearchOptions:g,isVendorSearchLoading:x==="In-Progress",onVendorSearchTextChange:z,submitState:j,submitErrorMessage:T,documentUploadState:w,uploadedFileName:y,isAiCfoAccessEnabled:l,onAskAiCfoClick:B,onBackClick:H,onCancelClick:K,onClickMenuIcon:u,onFormChange:D,onSubmit:W,onUploadDocument:N,onRemoveDocument:$})]}):o.jsx(Qe,{to:"..",replace:!0})}const{spendManagement:{chargeCard:{cardPolicyPage:jc}}}=aa.getLocalizedStrings(),Mc=e=>On(e,!1),Nc=e=>Un(e.name,!1);function Vc(){const e=ie(),a=me(),{tenantEmailDomain:n,templateId:t}=Ve(),s=le(),f=Re(),b=Fe(f?.loggedInUserRoleMap),[m,A]=r.useState(!1),u=r.useCallback((T=>{A(T)}),[]),l=r.useCallback((()=>{u(!0)}),[u]),{isAiCfoAccessEnabled:B,onAskAiCfoClick:_}=Fa({mobileExploreReferrer:"Card Policy"}),C=d((T=>bs(T))),O=d((T=>Dn(T.cardPolicyState))),U=d((T=>Pn(T.cardPolicyState))),S=d((T=>wn(T.cardPolicyState))),c=d((T=>Tn(T.cardPolicyState))),p=d((T=>vn(T.cardPolicyState))),x=d((T=>Fn(T.cardPolicyState))),E=d((T=>xn(T.cardPolicyState))),I=d((T=>Dt(T.cardPolicyState))),k=d((T=>Rn(T))),V=d((T=>t!=null?Ss(T.cardPolicyState,t):void 0)),w=r.useMemo((()=>C.templateId===t&&C.formDraft!=null?C.formDraft:V!=null?ys(V):void 0),[C.templateId,C.formDraft,V,t]);r.useEffect((()=>{if(t==null)return;const T=C.detailFetchState.fetchState;C.templateId===t&&(T==="Completed"||T==="In-Progress")||V!=null||s(Is(t))}),[s,t,C.templateId,C.detailFetchState.fetchState,V]),r.useEffect((()=>{O!=="Completed"&&O!=="In-Progress"&&s(Ln())}),[s,O]),vr();const y=d((T=>T.chargeCardConfigState.receiptRequiredAboveAmount.amount));r.useEffect((()=>{k.fetchState==="Not-Started"&&s(ia(!1,!1,!1))}),[k.fetchState,s]);const F=r.useMemo((()=>U.map(Mc)),[U]),i=r.useMemo((()=>E.map(Nc)),[E]),g=r.useMemo((()=>k.cards.filter((T=>!mr(T.status.code))).map(Tr)),[k.cards]);Lt({isDataReady:w!=null});const R=r.useMemo((()=>{if(w!=null)return Xo({draft:w,cardRows:g,categorySearchOptions:F,vendorSearchOptions:i,defaultRequireReceiptAmount:y,suggestedAllowMerchants:S,suggestedBlockMerchants:c,suggestedAllowCategories:p,suggestedBlockCategories:x})}),[w,g,F,i,y,S,c,p,x]),[G,M]=r.useState(void 0),L=r.useRef(!1);r.useEffect((()=>{L.current||G!=null||R==null||(L.current=!0,M(R))}),[G,R]);const z=r.useCallback((T=>{M(T)}),[]),j=r.useMemo((()=>Ut((T=>{s(Pt(T))}),250)),[s]);r.useEffect((()=>()=>{j.cancel()}),[j]);const h=r.useCallback((T=>{j(T)}),[j]),H=C.updateFetchState.fetchState,K=n!=null?`/${n}/cards/policy`:"..",D=r.useCallback((()=>{const T=we(a.state?.pathnameStackToGoBack),P=T.poppedPathname??K;e(P,{state:{pathnameStackToGoBack:T.newStack}})}),[a.state,e,K]),W=r.useCallback((()=>{e(K)}),[e,K]),N=r.useCallback((T=>{if(t==null)return;const P=Cr(T);s(ks(P)),s(Es(t))}),[s,t]),$=r.useRef(H);r.useEffect((()=>{const T=$.current;$.current=H,H==="Completed"&&T!=="Completed"&&(s(Ke({messageSection:"card_policy_updated",messageText:"success",type:"success"})),e(K))}),[s,H,e,K]);const v=H==="Error"?C.updateFetchState.error?.message??jc.updatePolicyGenericErrorMessage:void 0;return!b||n==null||t==null?o.jsx(Qe,{to:"..",replace:!0}):G!=null&&O==="Completed"&&k.fetchState==="Completed"?o.jsxs(o.Fragment,{children:[o.jsx(Ae,{isAppContentDrawerOpen:m,handleDrawerToggle:u}),o.jsx(ec,{templateName:C.template?.name??"",formDraft:G,vendorSearchOptions:i,categorySearchOptions:F,isVendorSearchLoading:I==="In-Progress",onVendorSearchTextChange:h,submitState:H,submitErrorMessage:v,isAiCfoAccessEnabled:B,onAskAiCfoClick:_,onBackClick:D,onCancelClick:W,onClickMenuIcon:l,onFormChange:z,onSubmit:N})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ae,{isAppContentDrawerOpen:m,handleDrawerToggle:u}),o.jsx(pr,{showUploadDocumentSection:!1,navBarTitle:C.template?.name,onBackClick:D,onClickMenuIcon:l,isAiCfoAccessEnabled:B,onAskAiCfoClick:_})]})}function Fr(e,a,n){return a?e.filter((t=>t!=null&&t.trim().length>0)).slice(0,n):[]}function xr(e){return d((a=>e==null||e===""?{chips:ht,isResolved:!1}:(function(n){const t=n?.fetchState,s=t==="Completed"||t==="Error";return{chips:t==="Completed"?n?.suggestedQuestions??ht:ht,isResolved:s}})(As(a,e))),_t)}const ht=[],{spendManagement:{chargeCard:{cardPolicyAiCfoHero:{headline:Hc,subheadline:Gc,pageTitle:$c}}}}=aa.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 zc(){const e=ie(),a=me(),{tenantEmailDomain:n}=Ve(),t=le(),s=Re(),f=Fe(s?.loggedInUserRoleMap),[b,m]=r.useState(!1),A=r.useCallback((h=>{m(h)}),[]),u=r.useCallback((()=>{A(!0)}),[A]),{useFeatureGate:l}=de(),{isFeatureEnabled:B}=l(q.isAiCfoFileUploadEnabled),{isFeatureEnabled:_}=l(q.isCardPolicyEnabled),{isAiCfoAccessEnabled:C,onAskAiCfoClick:O}=Fa({mobileExploreReferrer:"Card Policy"}),U=d((h=>_s(h))),S=d((h=>Bn(h.createCardPolicyState))),c=d((h=>Ds(h.createCardPolicyState))),p=d((h=>c==null?[]:Mn(h.aiCfoState,c).filter((H=>H.kind==="creating_policy"))),_t),x=S.fetchState==="In-Progress"?Math.max(p.length,1):0,E=d((h=>Ps(h.createCardPolicyState))),I=Sa(S.fetchState);r.useEffect((()=>{if(I==="In-Progress"&&S.fetchState==="Completed"&&c!=null)p.forEach((h=>{t(St({chatSessionId:c,id:h.id,entityIds:E,kind:"created_policy"}))}));else if(I==="In-Progress"&&S.fetchState==="Error"&&c!=null){p.forEach((H=>{t(St({chatSessionId:c,id:H.id,kind:"errored_policy"}))}));const h=S.error?.message!=null&&S.error.message.length>0?S.error.message:aa.getLocalizedStrings().common.errorMessage.somethingWentWrongPleaseTryAgain;t(Ke({messageSection:"card_policy_created",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:h}]}))}}),[S.error?.message,S.fetchState,t,c,E,p,I]);const k=U.fetchState.fetchState;r.useEffect((()=>{k!=="Not-Started"&&k!=="Error"||t(ws())}),[t,k]);const V=U.archiveFetchState.fetchState,w=Sa(V);r.useEffect((()=>{w==="In-Progress"&&V==="Completed"&&t(Ke({messageSection:"card_policy_deleted",messageText:"success",type:"success"}))}),[V,t,w]);const y=r.useMemo((()=>U.templates.map(Zc)),[U.templates]);Lt({isDataReady:U.fetchState.fetchState==="Completed"});const F=y.length>0||x>0,i=(function(h){const{hasAnyPolicies:H,isChargeCardAdmin:K,isFileUploadEnabled:D}=h,W=ie(),N=me(),{tenantEmailDomain:$}=Ve(),{isAiCfoOpen:v,setIsAiCfoOpen:T}=hr(),P=fr(),ae=gr(),Ce=d((J=>jn(J))).createSessionAndSubmitState.fetchState==="In-Progress",{chips:X,isResolved:Te}=xr("card_policy"),Ie=r.useMemo((()=>Fr(X,Te,3)),[X,Te]),[re,be]=r.useState(""),pe=ae&&P&&$!=null&&!v,he=r.useCallback((J=>{if($==null)return;const Ge=Ee(N.state?.pathnameStackToGoBack,N.pathname);W(`/${$}/cards/ask`,{state:{message:"",origin:"",pathnameStackToGoBack:Ge,referrer:"card_policy_hero",aiCfoInitialQuestion:J,aiCfoShouldSubmit:J!=null&&J.trim().length>0}})}),[N.pathname,N.state,W,$]),oe=r.useCallback((J=>{J.trim().length!==0&&(be(""),he(J))}),[he]),Q=r.useCallback((()=>{const J=re.trim();J.length!==0&&(be(""),he(J))}),[re,he]),Se=r.useCallback((()=>{}),[]),_e=r.useCallback((J=>{be(J)}),[]),fe=r.useCallback((()=>{T(!0)}),[T]),ve=r.useCallback((()=>{he(void 0)}),[he]);return r.useMemo((()=>{if(pe&&!H&&K)return{aiAgentName:$c,headline:Hc,subheadline:Gc,promptChips:Ie,composer:{currentInput:re,isSubmitting:Ce,isFileUploadEnabled:D,onInputChange:_e,onSubmit:Q,onStopSubmit:Se},onPromptClick:oe,onOpenSidePanel:fe,onOpenFullView:ve,dataTestIdPrefix:"card-policy-ai-cfo-hero"}}),[re,H,pe,K,D,Ce,_e,ve,fe,oe,Se,Q,Ie])})({hasAnyPolicies:F,isChargeCardAdmin:f,isFileUploadEnabled:B}),g=_&&i!=null?o.jsx(br,{...i}):null,R=C&&g==null,G=r.useCallback((()=>{const h=we(a.state?.pathnameStackToGoBack),H=h.poppedPathname??"..";e(H,{state:{pathnameStackToGoBack:h.newStack}})}),[a.state,e]),M=r.useCallback((()=>{n!=null&&e(`/${n}/cards/policy/new`)}),[e,n]),L=r.useCallback((h=>{n!=null&&e(`/${n}/cards/policy/${h}/edit`)}),[e,n]),z=r.useCallback((h=>{t(Ts(h))}),[t]),j=U.fetchState.fetchState;return!F&&j!=="Completed"&&j!=="Error"?o.jsxs(o.Fragment,{children:[o.jsx(Ae,{isAppContentDrawerOpen:b,handleDrawerToggle:A}),o.jsx(ac,{onBackClick:G,onNewPolicyClick:M,onClickMenuIcon:u,isAiCfoAccessEnabled:C,onAskAiCfoClick:O})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ae,{isAppContentDrawerOpen:b,handleDrawerToggle:A}),o.jsx(tc,{policies:y,archivingTemplateId:U.archiveTargetTemplateId,pendingCreationCount:x,onBackClick:G,onNewPolicyClick:M,onEditPolicyClick:L,onArchivePolicyClick:z,onClickMenuIcon:u,policyAiCfoHero:g,isAiCfoAccessEnabled:R,onAskAiCfoClick:O})]})}function Kc(){const e=ie(),{cardId:a}=Ve(),n=le(),t=te.getSignedInUser(),s=d((X=>ge(X))),f=Re(),b=Fe(f?.loggedInUserRoleMap),{useFeatureGate:m}=de();if(t==null)throw Error("Can't access Add To Wallet Page without signing in...");const[A,u]=r.useState(!1),l=d((X=>Wa(X).firstViewAfterActivation));if(a==null)throw Error("Empty card id is not valid...");const B=s.userRole.includes("charge_card_user"),{isFeatureEnabled:_}=m(q.isChargeCardFeatureEnabled),C=!!s.companyChargeCardInfo?.info?.isChargeCardEnabled,{isFeatureEnabled:O}=m(q.isDebitCardFeatureEnabled),U=xe(s),S=Le(s),c=Be(O,s),p=s.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,x=Oe({isDebitCardFeatureEnabled:O,isBankingOnlyTenant:c}),E=Ue({isCardsOnlyTenant:U,isChargeCardFeatureEnabled:_,isBookKeepingTenant:S,isDebitCardProductVisible:x,chargeCardsCreditAccountLimit:p}),I=!!s.companyDebitCardInfo?.info?.isDebitCardEnabled,k=d((X=>da(X,s.companyId))),V=la(k.controllers),{creditAccount:w,creditAccountRepayment:y}=d((X=>ua(X))),F=d((X=>X.classListState.fetchState)),i=!B&&E&&C,g=d((X=>wt(X,a,i,E))),[R,G]=r.useState(!1),M=g.chargeCard,L=M?.cardCreatedByUser?.userId,z=d((X=>L!=null?Ga(X.userRoleState,L):void 0)),j=z?.accountingClassIDs[0],h=d((X=>j!=null?$a(X.classState,{classId:j,reportId:"class_list"}):void 0)),H=M?.cardHolderUser?.userId,K=d((X=>H!=null?Ga(X.userRoleState,H):void 0)),D=K?.accountingClassIDs[0],W=d((X=>D!=null?$a(X.classState,{classId:D,reportId:"class_list"}):void 0)),N=M?.type.code==="business_physical_credit_card"||M?.type.code==="business_physical_debit_card",$=M?.type.code==="business_physical_debit_card";r.useEffect((()=>{l&&A===!1&&N&&(u(!0),setTimeout((()=>{n(Za()),$&&n(Ke({messageSection:"set_debit_card_pin",messageText:"success",type:"success",showStatusIcon:!0}))}),5e3))}),[l,A,N,$]),r.useEffect((()=>{R||g.fetchState==="Completed"||g.fetchState==="In-Progress"||a==null||(G(!0),n(Ia(a,i,!1)))}),[R,g,a,n]),r.useEffect((()=>{if(g.fetchState==="Completed"&&(N===!1||N&&M?.status?.code!=="active"||M?.cardHolderUserId!==t.userId||l===!1&&A===!1||M?.type.code==="business_physical_debit_card"||M?.type.code==="business_virtual_debit_card")){const X=De(s.tenantEmailDomain,a,t,M,l);e(X)}}),[g.fetchState,l,N]),r.useEffect((()=>{w.fetchState!=="Completed"&&w.fetchState!=="In-Progress"&&E&&C&&b&&n(Je()),y.fetchState!=="Completed"&&y.fetchState!=="In-Progress"&&E&&C&&b&&n(Tt()),F!=="Completed"&&F!=="In-Progress"&&n(Nn())}),[w.fetchState,y.fetchState,n,E,C,b,F]);const v=()=>{if(t!=null&&a!=null){n(Za());const X=De(s.tenantEmailDomain,a,t);e(X)}},T=M?.type.code==="business_physical_debit_card"||M?.type.code==="business_virtual_debit_card",P=ea(E,x,I,C),ae=xa(E,C,b,w,y),Ce=Ar(T,g);return g.fetchState!=="Completed"?o.jsx(wa,{fetchState:"In-Progress"}):o.jsxs(o.Fragment,{children:[o.jsx(tt,{showConfetti:l}),o.jsx(nc,{onGotItClick:v,isDebitCard:M?.type.code==="business_physical_debit_card",controllerEmails:V,isChargeCardFeatureEnabled:E,isDebitCardFeatureEnabled:x,isDebitCardSetupEnabled:I,isChargeCardSetupEnabled:C,productInformation:P,creditAccountInformation:ae,debitAccountInformation:Ce,chargeCardDetailView:g,creditAccount:w,classListFetchState:F,creditAccountRepayment:y,cardIssuedByRoles:z?.userRoles,cardIssuedByDepartmentName:h?.className,cardHolderRoles:K?.userRoles,cardHolderDepartmentName:W?.className})]})}const Lr="charge-card-transaction-update",Br="charge-card-transaction-created",Rr="charge-card-transaction-declined",Or="charge-card-transaction-updated",Ur="charge-card-transaction-receipt-uploaded",pa="charge-card-status-update",Vt="charge-card-spending-updated",ot="credit-account-balance-updated",ct="charge-card-created",Ht="charge-card-limit-updated",Gt="charge-card-limit-reset",$t="charge-card-renamed",Yc="charge-card-department-updated",jr="charge-card-repayment-completed",Mr="charge-card-payment-date-updated",La="charge-card-cashback-redeemed",Ba="charge-card-cashback-earned",ha=(e,a)=>e==null||e===""?[]:a.map((n=>`private-encrypted-${e}.${n}`)),Wc=[Ba,La],qc=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(vs({uiState:{sortKey:a,sortOrder:n}}))}}}))(sc);function Jc(){const e=ie(),a=le(),n=me(),t=te.getSignedInUser(),s=d((_=>ge(_))),[f,b]=r.useState(!1),m=d((_=>ma(_))),A=wr(s.companyId,{clearParams:m.fetchState==="Completed"}),u=r.useCallback((()=>{const _=we(n.state?.pathnameStackToGoBack),C=_.poppedPathname??Qc(s.tenantEmailDomain);e(C,{state:{pathnameStackToGoBack:_.newStack}})}),[e,n,s.tenantEmailDomain]),l=ta(s);if(Nt({events:ha(l,Wc),onEvent:_=>{switch(_){case Ba:case La:return void a(_a(!0))}},onSubscribed:()=>{a(_a(!0))}}),r.useEffect((()=>{f||m.fetchState==="Completed"||m.fetchState==="In-Progress"||(b(!0),a(_a()))}),[f,m,a]),t==null)throw Error("Can't access cashback detail page without signing in...");const B=m.cashbackSummary?.cashbackEarned?.amount!=null&&m.fetchState!=="Not-Started";return m.fetchState!=="In-Progress"||B?(m.cashbackSummary?.cashbackEarned?.amount??0)===0&&m.fetchState==="Completed"?o.jsx(st,{}):o.jsx(qc,{onBackClick:u,initialOpenThreadRequest:A}):o.jsx(rc,{onBackClick:u})}const Qc=e=>`/${e}/cards`,Xc={containerWidth:new va(100,58)},ei=({appContent:e})=>{const a=Ta(),n=le(),t=ie(),{cardId:s}=Ve(),f=me(),{useDynamicConfig:b}=de(),[m,A]=r.useState(!1),[u,l]=r.useState(!1),[B,_]=r.useState(!1),[C,O]=r.useState(!1),U=te.getSignedInUser();if(U==null)throw Error("Can't access onboarding card page without signing in...");const S=d((W=>ge(W)));if(s==null)throw Error("Empty card id is not valid...");const{configValue:c}=b(Xe.zeniCardsConfig),p=c.max_charge_card_activation_attempts_by_card_id,x=d((W=>Fs(W,s))),E=x.chargeCard,I=d((W=>W.chargeCardConfigState.fetchState)),{useFeatureGate:k}=de(),{isFeatureEnabled:V}=k(q.isChargeCardFeatureEnabled),{isFeatureEnabled:w}=k(q.isDebitCardFeatureEnabled),y=Be(w,S),F=Oe({isDebitCardFeatureEnabled:w,isBankingOnlyTenant:y}),i=!!S.companyChargeCardInfo?.info?.isChargeCardEnabled,g=S.userRole.includes("charge_card_user"),R=xe(S),G=Le(S),M=S.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,L=Ue({isCardsOnlyTenant:R,isChargeCardFeatureEnabled:V,isBookKeepingTenant:G,isDebitCardProductVisible:F,chargeCardsCreditAccountLimit:M}),z=!g&&L&&i;r.useEffect((()=>{m===!1&&I!=="In-Progress"&&I!=="Completed"&&(n(qa()),A(!0)),u===!1&&x.fetchState==="Not-Started"&&(l(!0),n(Ia(s,z,L)))}),[u,x.fetchState,m,I]);const j=E?.type.code==="business_physical_credit_card"||E?.type.code==="business_physical_debit_card";r.useEffect((()=>{if(x.fetchState==="Completed"){if(B===!1&&(j===!1||j&&E?.status?.code!=="inactive"||E?.cardHolderUserId!==U.userId)){const W=De(S.tenantEmailDomain,s,U,E,!0),N=Ee(f.state?.pathnameStackToGoBack,f.pathname);t(W,{state:{pathnameStackToGoBack:N}})}else if(B&&x.isRefreshingViewInBackground===!1&&E?.status?.code==="active"){n(xs({chargeCardId:s}));const W=De(S.tenantEmailDomain,s,U,E,!0),N=Ee(f.state?.pathnameStackToGoBack,f.pathname);n(Ja()),t(W,{state:{pathnameStackToGoBack:N}})}}}),[x.fetchState,E?.type.code,B,x.isRefreshingViewInBackground]);const h=te.getZeniOtpTokenForCardHolder(s),H=d((W=>Vn(W.userState,U.userId))),K=()=>{E?.status?.code!=="active"&&n(ga(s,!0))};r.useEffect((()=>{x.updatePhysicalChargeCardAttemptFetchState.fetchState==="Completed"&&E?.cardActivationAttemptHistory.some((W=>W.statusCode==="success"))===!0&&B===!1&&(setTimeout(K,3e3),_(!0))}),[x.updatePhysicalChargeCardAttemptFetchState.fetchState,E?.cardActivationAttemptHistory]);const D=W=>{O(W)};if(I!=="Completed"||E==null)return o.jsx(wa,{fetchState:"In-Progress"});if(E.shippingAddressId==null)throw Error("Can't access shippingAddressId.");if(H?.phone==null)throw Error("Can't access user phone number.");return o.jsxs(ni,{children:[o.jsx(Ae,{isAppContentDrawerOpen:C,handleDrawerToggle:D}),o.jsx(ai,{cardId:s,card:E,shippingAddressId:E.shippingAddressId,phone:H.phone,signedInUser:U,isSandboxEnv:Bt(),chargeCardDetailState:x,signedInUserToken:h,navigate:t,currentTenant:S,location:f,maxChargeCardActivationAttempts:p[s]!=null?p[s]:c.default_max_charge_card_activation_attempts!=null?c.default_max_charge_card_activation_attempts:3,chargeCardCashbackRatePerTransaction:c.charge_card_cashback_rate_per_transaction!=null?c.charge_card_cashback_rate_per_transaction:.0175,onClickMenuIcon:()=>{D(!0)}}),e!=null?o.jsx(ti,{windowSize:a,children:e}):null]})},ai=Pe((function(e,{chargeCardDetailState:a,shippingAddressId:n,location:t,cardId:s}){const f=Ls(e.addressState,n);if(f==null)throw Error("Can't access shippingAddress.");const b=Hn(e,s),m=a.updateStatus,A=Ca(e,!1,!1,!1);let u=!1;A.fetchState==="Completed"&&A.cards.length<=1&&(u=!0);const l=t.state?.message==="comingFromV2UrlPath";return{showActivatePage:a.chargeCard?.providerCardCreateTime!=null&&a.chargeCard.providerCardCreateTime.add(24,"h").isBefore(Bs())||l,showMenuIcon:u,shippingAddress:f,vgsVaultId:nt.cardVaultId,twoFAView:b,activationWaitStatus:m,isRefreshingViewInBackground:a.isRefreshingViewInBackground}}),(function(e,a){const{navigate:n,cardId:t,location:s,currentTenant:f,chargeCardDetailState:b}=a,m=b.chargeCard?.cardProviderID,{tenantEmailDomain:A}=f;return{onGetOtp:u=>{m!=null&&e(et(u,"ChargeCardHolder",t))},onUpdatePhysicalChargeCardAttempt:u=>{e(Os(t,u))},onResendOtp:u=>{m!=null&&e(Xa(u,"ChargeCardHolder",t))},onVerifyOtp:(u,l)=>{m!=null&&e(Qa(u,l,"ChargeCardHolder",t))},onVerifyOtpSuccess:u=>{u!=null&&te.saveZeniOtpTokenForCardHolder(u,t)},onCVVActivateSuccess:()=>{e(Rs({chargeCardId:t}))},onBackClick:()=>{const u=we(s.state?.pathnameStackToGoBack),l=u.poppedPathname==null||u.poppedPathname.includes("onboard")===!0?na(A):u.poppedPathname;n(l,{state:{pathnameStackToGoBack:u.newStack}})}}}))(oc),ti=He.div`
1
+ import{j as o}from"./liveblocks-BLpmr1Pv.js";import{u as le,j as d,h as ie,g as me,i as Ve,N as Qe,s as _t,l as Pe,t as _n,n as os,o as ne}from"./core-CbdTrw7T.js";import{fW as Dt,Zv as cs,g6 as Pt,bs as Fe,Zw as is,Zx as ds,fL as hn,Zy as Dn,fU as Pn,Zz as wn,ZA as Tn,ZB as vn,ZC as Fn,fV as xn,g5 as Ln,ZD as Bn,ZE as ls,f$ as us,f_ as ms,ZF as Cs,KZ as Rn,g8 as ia,ZG as ps,ZH as hs,fN as fs,fM as gs,gl as Ke,g1 as On,g0 as Un,ZI as bs,g2 as Ss,Kv as ys,Ku as Is,Ky as ks,KA as Es,ge as As,fI as jn,ZJ as _s,ZK as Ds,gj as Mn,ZL as Ps,gk as St,KG as ws,KD as Ts,fJ as ge,ZM as Wa,eq as xe,d4 as Le,er as Be,h3 as da,ct as la,ZN as ua,ZO as wt,DI as Ga,mj as $a,ZP as Za,Ld as Ia,g9 as Je,Lf as Tt,m9 as Nn,ZQ as ma,L1 as _a,ZR as vs,ZS as Fs,L4 as qa,ZT as xs,ZU as Ja,g4 as Vn,La as ga,iC as Ls,ZV as Hn,fX as Ca,bw as Bs,ZW as Rs,gK as Qa,gJ as Xa,LJ as Os,gI as et,ZX as Gn,cm as $n,ec as Us,ZY as Pa,Mi as Zn,ZZ as fn,LU as Da,Z_ as zn,Mj as js,Yx as Ms,Mk as Ns,Ns as Vs,CY as Hs,Nm as Gs,Z$ as $s,Le as oa,_0 as Zs,_1 as zs,_2 as Ks,_3 as Ys,_4 as Ws,_5 as vt,_6 as qs,Lu as Kn,Ln as Js,_7 as Qs,h5 as Xs,_8 as Yn,LD as Wn,LH as qn,h4 as eo,_9 as ao,M4 as Jn,_a as to,_b as no,_c as ro,LF as Qn,Lq as Xn,L7 as er,Lz as ar,Lx as tr,LB as so,_d as nr,_e as oo,gg as co,gh as io,gi as lo,_f as at,ga as rr,ee as Ft,_g as uo,_h as mo,_i as Co,_j as po,LP as yt,Mb as ho,M7 as fo,LL as go,M9 as bo,L$ as So,M1 as yo,_k as sr,Mh as Ha,Tp as Io,_l as ko,_m as Eo,_n as Ao,_o as or,_p as _o,ME as Do,LT as cr,LO as Ne,LS as Po,_q as wo,_r as To,K_ as vo,_s as ir,g3 as dr,_t as Fo,L0 as xo,K$ as gn,_u as Lo,_v as Bo,_w as Ro,_x as Oo,_y as xt,_z as Uo,xY as lr,mT as jo,is as Mo,MJ as No,_A as ur,fR as Vo,fS as Ho,_B as Go,dB as $o,g7 as Zo,Mz as zo,Mt as qe,bp as Ko,bK as Yo,cz as Wo,bL as qo,hb as Jo}from"./zeni-epic-state-C5DO1jkr.js";import{V as Re,bs as mr,a5 as we,bt as Cr,bu as pr,bv as Qo,G as aa,al as Lt,bw as Xo,bx as ec,g as hr,a as fr,ar as gr,s as Ee,p as de,_ as q,o as Sa,by as br,bz as ac,bA as tc,z as te,a8 as wa,bB as tt,bC as nc,bD as rc,bE as sc,a2 as Ta,au as Xe,aT as Bt,bF as oc,ac as va,W as nt,c as ee,w as rt,bG as cc,bH as ba,bI as It,bJ as ic,a9 as Rt,bK as dc,af as Sr,aj as kt,bL as lc,aC as yr,K as Ir,R as kr,aB as uc,bM as mc,bN as Cc,bO as pc,bP as hc,bQ as fc,bR as gc,N as za,bS as bc,bT as Sc,v as pt,j as yc,bU as Ic,bV as kc,bW as Ec,az as Ac,bX as _c,bY as Dc,i as Pc}from"./index-DtThPd2q.js";import{n as He,u as Ot,D as Er,S as wc}from"./mui-DNGY4bFU.js";import{a as r}from"./sentry-DWNq3t8E.js";import{u as Fa}from"./useAskAiCfoHostNavButtonProps-DSKusWDa.js";import{M as Ae}from"./MobileAppDrawer-CCAbxLE2.js";import{d as Ut}from"./recharts-CTh_JhT_.js";import{g as De,a as xa,b as Ar,c as Oe,d as Ue,e as ea,f as ta,h as na,A as Tc,i as jt,P as vc,j as Mt,s as ya,k as _r,l as ca,m as Dr,n as Fc,o as Pr,p as xc,S as bn}from"./SetupPagesScreen-DRxKoFqN.js";import{u as wr}from"./useInitialThreadRequest-DrEeSZz_.js";import st from"./NotFoundScreen-uAMK84U0.js";import{u as Nt}from"./useChargeCardPusherEvents-fpHDIIMx.js";import{n as Sn}from"./utils-CrhrpmD8.js";import{t as Lc}from"./AddressScreen-BVizi07H.js";import"./analytics-Vgn85Ur_.js";import"./plaid-DhfTjhua.js";import"./dnd-DuiAlI7w.js";import"./stripe-cKAAJElX.js";import"./lottie-Lb1ftKY1.js";import"./lexical-B-vxEaRQ.js";import"./pdf-B1uD4Ovv.js";import"./InboxNotificationsProvider-CiKEEv6Q.js";import"./useTaskManagerAccess-CT25hqtF.js";import"./useIsCustomersTabEnabled-C9FFBZXp.js";import"./BusinessVerificationPageScreen-CdT5YCya.js";import"./routePaths-DXYV831_.js";import"./analyticsHelper-CVZpPd-a.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]="6c3cb974-63c3-4efb-999b-8acf18e8db62",e._sentryDebugIdIdentifier="sentry-dbid-6c3cb974-63c3-4efb-999b-8acf18e8db62")}catch{}})();const Bc=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:Bc(e),utilizationAmount:(e.limit?.amount??0)-(e.available?.amount??0)});function vr(){const e=le(),a=d((t=>Dt(t.cardPolicyState))),n=d((t=>cs(t.cardPolicyState)));r.useEffect((()=>{n!==""||a==="Completed"&&n===""||a==="In-Progress"||e(Pt())}),[e,a,n])}const{spendManagement:{chargeCard:{cardPolicyPage:yn}}}=aa.getLocalizedStrings(),Rc=e=>On(e,!1),Oc=e=>Un(e.name,!1);function Uc(){const e=ie(),a=me(),{tenantEmailDomain:n}=Ve(),t=le(),s=Re(),f=Fe(s?.loggedInUserRoleMap),[b,m]=r.useState(!1),A=r.useCallback((P=>{m(P)}),[]),u=r.useCallback((()=>{A(!0)}),[A]),{isAiCfoAccessEnabled:l,onAskAiCfoClick:B}=Fa({mobileExploreReferrer:"Card Policy"});r.useEffect((()=>()=>{t(is()),t(ds()),t(hn())}),[t]);const _=d((P=>Dn(P.cardPolicyState))),C=d((P=>Pn(P.cardPolicyState))),O=d((P=>wn(P.cardPolicyState))),U=d((P=>Tn(P.cardPolicyState))),S=d((P=>vn(P.cardPolicyState))),c=d((P=>Fn(P.cardPolicyState))),p=d((P=>xn(P.cardPolicyState))),x=d((P=>Dt(P.cardPolicyState))),E=d((P=>P.chargeCardConfigState.receiptRequiredAboveAmount.amount)),I=d((P=>P.chargeCardConfigState.fetchState));r.useEffect((()=>{_!=="Completed"&&_!=="In-Progress"&&t(Ln())}),[t,_]),vr();const k=d((P=>Bn(P.createCardPolicyState))),V=d((P=>ls(P.createCardPolicyState))),w=d((P=>us(P.cardPolicyState))),y=d((P=>ms(P.cardPolicyState))),F=d((P=>Cs(P.createCardPolicyState))),i=d((P=>Rn(P)));r.useEffect((()=>{i.fetchState==="Not-Started"&&t(ia(!1,!1,!1))}),[i.fetchState,t]);const g=r.useMemo((()=>C.map(Rc)),[C]),R=r.useMemo((()=>p.map(Oc)),[p]),G=r.useMemo((()=>i.cards.filter((P=>!mr(P.status.code))).map(Tr)),[i.cards]),M=_==="Completed"&&i.fetchState==="Completed"&&I==="Completed";r.useEffect((()=>{M&&F==null&&t(ps({cardsMasterList:G,defaultRequireReceiptAmount:E,suggestedAllowMerchants:O,suggestedBlockMerchants:U,suggestedAllowCategories:S,suggestedBlockCategories:c}))}),[I,t,M,F,G,E,O,U,S,c]);const L=r.useMemo((()=>Ut((P=>{t(Pt(P))}),250)),[t]);r.useEffect((()=>()=>{L.cancel()}),[L]);const z=r.useCallback((P=>{L(P)}),[L]),j=k.fetchState,h=n!=null?`/${n}/cards/policy`:"..",H=r.useCallback((()=>{const P=we(a.state?.pathnameStackToGoBack),ae=P.poppedPathname??h;e(ae,{state:{pathnameStackToGoBack:P.newStack}})}),[a.state,e,h]),K=r.useCallback((()=>{e(h)}),[e,h]),D=r.useCallback((P=>{t(hs(P))}),[t]),W=r.useCallback((P=>{const ae=Cr(P);t(fs({templates:[ae]}))}),[t]),N=r.useCallback((P=>{P.length!==0&&t(gs(P))}),[t]),$=r.useCallback((()=>{t(hn())}),[t]),v=r.useRef(j);r.useEffect((()=>{const P=v.current;v.current=j,j==="Completed"&&P!=="Completed"&&V!=null&&(t(Ke({messageSection:"card_policy_created",messageText:"success",type:"success"})),e(h))}),[t,j,V,e,h]);const T=j==="Error"?k.error?.message??yn.createPolicyGenericErrorMessage:void 0;return f&&n!=null?F==null?o.jsxs(o.Fragment,{children:[o.jsx(Ae,{isAppContentDrawerOpen:b,handleDrawerToggle:A}),o.jsx(pr,{showUploadDocumentSection:!0,navBarTitle:yn.createPageTitle,onBackClick:H,onClickMenuIcon:u,isAiCfoAccessEnabled:l,onAskAiCfoClick:B})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ae,{isAppContentDrawerOpen:b,handleDrawerToggle:A}),o.jsx(Qo,{formDraft:F,vendorSearchOptions:R,categorySearchOptions:g,isVendorSearchLoading:x==="In-Progress",onVendorSearchTextChange:z,submitState:j,submitErrorMessage:T,documentUploadState:w,uploadedFileName:y,isAiCfoAccessEnabled:l,onAskAiCfoClick:B,onBackClick:H,onCancelClick:K,onClickMenuIcon:u,onFormChange:D,onSubmit:W,onUploadDocument:N,onRemoveDocument:$})]}):o.jsx(Qe,{to:"..",replace:!0})}const{spendManagement:{chargeCard:{cardPolicyPage:jc}}}=aa.getLocalizedStrings(),Mc=e=>On(e,!1),Nc=e=>Un(e.name,!1);function Vc(){const e=ie(),a=me(),{tenantEmailDomain:n,templateId:t}=Ve(),s=le(),f=Re(),b=Fe(f?.loggedInUserRoleMap),[m,A]=r.useState(!1),u=r.useCallback((T=>{A(T)}),[]),l=r.useCallback((()=>{u(!0)}),[u]),{isAiCfoAccessEnabled:B,onAskAiCfoClick:_}=Fa({mobileExploreReferrer:"Card Policy"}),C=d((T=>bs(T))),O=d((T=>Dn(T.cardPolicyState))),U=d((T=>Pn(T.cardPolicyState))),S=d((T=>wn(T.cardPolicyState))),c=d((T=>Tn(T.cardPolicyState))),p=d((T=>vn(T.cardPolicyState))),x=d((T=>Fn(T.cardPolicyState))),E=d((T=>xn(T.cardPolicyState))),I=d((T=>Dt(T.cardPolicyState))),k=d((T=>Rn(T))),V=d((T=>t!=null?Ss(T.cardPolicyState,t):void 0)),w=r.useMemo((()=>C.templateId===t&&C.formDraft!=null?C.formDraft:V!=null?ys(V):void 0),[C.templateId,C.formDraft,V,t]);r.useEffect((()=>{if(t==null)return;const T=C.detailFetchState.fetchState;C.templateId===t&&(T==="Completed"||T==="In-Progress")||V!=null||s(Is(t))}),[s,t,C.templateId,C.detailFetchState.fetchState,V]),r.useEffect((()=>{O!=="Completed"&&O!=="In-Progress"&&s(Ln())}),[s,O]),vr();const y=d((T=>T.chargeCardConfigState.receiptRequiredAboveAmount.amount));r.useEffect((()=>{k.fetchState==="Not-Started"&&s(ia(!1,!1,!1))}),[k.fetchState,s]);const F=r.useMemo((()=>U.map(Mc)),[U]),i=r.useMemo((()=>E.map(Nc)),[E]),g=r.useMemo((()=>k.cards.filter((T=>!mr(T.status.code))).map(Tr)),[k.cards]);Lt({isDataReady:w!=null});const R=r.useMemo((()=>{if(w!=null)return Xo({draft:w,cardRows:g,categorySearchOptions:F,vendorSearchOptions:i,defaultRequireReceiptAmount:y,suggestedAllowMerchants:S,suggestedBlockMerchants:c,suggestedAllowCategories:p,suggestedBlockCategories:x})}),[w,g,F,i,y,S,c,p,x]),[G,M]=r.useState(void 0),L=r.useRef(!1);r.useEffect((()=>{L.current||G!=null||R==null||(L.current=!0,M(R))}),[G,R]);const z=r.useCallback((T=>{M(T)}),[]),j=r.useMemo((()=>Ut((T=>{s(Pt(T))}),250)),[s]);r.useEffect((()=>()=>{j.cancel()}),[j]);const h=r.useCallback((T=>{j(T)}),[j]),H=C.updateFetchState.fetchState,K=n!=null?`/${n}/cards/policy`:"..",D=r.useCallback((()=>{const T=we(a.state?.pathnameStackToGoBack),P=T.poppedPathname??K;e(P,{state:{pathnameStackToGoBack:T.newStack}})}),[a.state,e,K]),W=r.useCallback((()=>{e(K)}),[e,K]),N=r.useCallback((T=>{if(t==null)return;const P=Cr(T);s(ks(P)),s(Es(t))}),[s,t]),$=r.useRef(H);r.useEffect((()=>{const T=$.current;$.current=H,H==="Completed"&&T!=="Completed"&&(s(Ke({messageSection:"card_policy_updated",messageText:"success",type:"success"})),e(K))}),[s,H,e,K]);const v=H==="Error"?C.updateFetchState.error?.message??jc.updatePolicyGenericErrorMessage:void 0;return!b||n==null||t==null?o.jsx(Qe,{to:"..",replace:!0}):G!=null&&O==="Completed"&&k.fetchState==="Completed"?o.jsxs(o.Fragment,{children:[o.jsx(Ae,{isAppContentDrawerOpen:m,handleDrawerToggle:u}),o.jsx(ec,{templateName:C.template?.name??"",formDraft:G,vendorSearchOptions:i,categorySearchOptions:F,isVendorSearchLoading:I==="In-Progress",onVendorSearchTextChange:h,submitState:H,submitErrorMessage:v,isAiCfoAccessEnabled:B,onAskAiCfoClick:_,onBackClick:D,onCancelClick:W,onClickMenuIcon:l,onFormChange:z,onSubmit:N})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ae,{isAppContentDrawerOpen:m,handleDrawerToggle:u}),o.jsx(pr,{showUploadDocumentSection:!1,navBarTitle:C.template?.name,onBackClick:D,onClickMenuIcon:l,isAiCfoAccessEnabled:B,onAskAiCfoClick:_})]})}function Fr(e,a,n){return a?e.filter((t=>t!=null&&t.trim().length>0)).slice(0,n):[]}function xr(e){return d((a=>e==null||e===""?{chips:ht,isResolved:!1}:(function(n){const t=n?.fetchState,s=t==="Completed"||t==="Error";return{chips:t==="Completed"?n?.suggestedQuestions??ht:ht,isResolved:s}})(As(a,e))),_t)}const ht=[],{spendManagement:{chargeCard:{cardPolicyAiCfoHero:{headline:Hc,subheadline:Gc,pageTitle:$c}}}}=aa.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 zc(){const e=ie(),a=me(),{tenantEmailDomain:n}=Ve(),t=le(),s=Re(),f=Fe(s?.loggedInUserRoleMap),[b,m]=r.useState(!1),A=r.useCallback((h=>{m(h)}),[]),u=r.useCallback((()=>{A(!0)}),[A]),{useFeatureGate:l}=de(),{isFeatureEnabled:B}=l(q.isAiCfoFileUploadEnabled),{isFeatureEnabled:_}=l(q.isCardPolicyEnabled),{isAiCfoAccessEnabled:C,onAskAiCfoClick:O}=Fa({mobileExploreReferrer:"Card Policy"}),U=d((h=>_s(h))),S=d((h=>Bn(h.createCardPolicyState))),c=d((h=>Ds(h.createCardPolicyState))),p=d((h=>c==null?[]:Mn(h.aiCfoState,c).filter((H=>H.kind==="creating_policy"))),_t),x=S.fetchState==="In-Progress"?Math.max(p.length,1):0,E=d((h=>Ps(h.createCardPolicyState))),I=Sa(S.fetchState);r.useEffect((()=>{if(I==="In-Progress"&&S.fetchState==="Completed"&&c!=null)p.forEach((h=>{t(St({chatSessionId:c,id:h.id,entityIds:E,kind:"created_policy"}))}));else if(I==="In-Progress"&&S.fetchState==="Error"&&c!=null){p.forEach((H=>{t(St({chatSessionId:c,id:H.id,kind:"errored_policy"}))}));const h=S.error?.message!=null&&S.error.message.length>0?S.error.message:aa.getLocalizedStrings().common.errorMessage.somethingWentWrongPleaseTryAgain;t(Ke({messageSection:"card_policy_created",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"_api-error_",variableValue:h}]}))}}),[S.error?.message,S.fetchState,t,c,E,p,I]);const k=U.fetchState.fetchState;r.useEffect((()=>{k!=="Not-Started"&&k!=="Error"||t(ws())}),[t,k]);const V=U.archiveFetchState.fetchState,w=Sa(V);r.useEffect((()=>{w==="In-Progress"&&V==="Completed"&&t(Ke({messageSection:"card_policy_deleted",messageText:"success",type:"success"}))}),[V,t,w]);const y=r.useMemo((()=>U.templates.map(Zc)),[U.templates]);Lt({isDataReady:U.fetchState.fetchState==="Completed"});const F=y.length>0||x>0,i=(function(h){const{hasAnyPolicies:H,isChargeCardAdmin:K,isFileUploadEnabled:D}=h,W=ie(),N=me(),{tenantEmailDomain:$}=Ve(),{isAiCfoOpen:v,setIsAiCfoOpen:T}=hr(),P=fr(),ae=gr(),Ce=d((J=>jn(J))).createSessionAndSubmitState.fetchState==="In-Progress",{chips:X,isResolved:Te}=xr("card_policy"),Ie=r.useMemo((()=>Fr(X,Te,3)),[X,Te]),[re,be]=r.useState(""),pe=ae&&P&&$!=null&&!v,he=r.useCallback((J=>{if($==null)return;const Ge=Ee(N.state?.pathnameStackToGoBack,N.pathname);W(`/${$}/cards/ask`,{state:{message:"",origin:"",pathnameStackToGoBack:Ge,referrer:"card_policy_hero",aiCfoInitialQuestion:J,aiCfoShouldSubmit:J!=null&&J.trim().length>0}})}),[N.pathname,N.state,W,$]),oe=r.useCallback((J=>{J.trim().length!==0&&(be(""),he(J))}),[he]),Q=r.useCallback((()=>{const J=re.trim();J.length!==0&&(be(""),he(J))}),[re,he]),Se=r.useCallback((()=>{}),[]),_e=r.useCallback((J=>{be(J)}),[]),fe=r.useCallback((()=>{T(!0)}),[T]),ve=r.useCallback((()=>{he(void 0)}),[he]);return r.useMemo((()=>{if(pe&&!H&&K)return{aiAgentName:$c,headline:Hc,subheadline:Gc,promptChips:Ie,composer:{currentInput:re,isSubmitting:Ce,isFileUploadEnabled:D,onInputChange:_e,onSubmit:Q,onStopSubmit:Se},onPromptClick:oe,onOpenSidePanel:fe,onOpenFullView:ve,dataTestIdPrefix:"card-policy-ai-cfo-hero"}}),[re,H,pe,K,D,Ce,_e,ve,fe,oe,Se,Q,Ie])})({hasAnyPolicies:F,isChargeCardAdmin:f,isFileUploadEnabled:B}),g=_&&i!=null?o.jsx(br,{...i}):null,R=C&&g==null,G=r.useCallback((()=>{const h=we(a.state?.pathnameStackToGoBack),H=h.poppedPathname??"..";e(H,{state:{pathnameStackToGoBack:h.newStack}})}),[a.state,e]),M=r.useCallback((()=>{n!=null&&e(`/${n}/cards/policy/new`)}),[e,n]),L=r.useCallback((h=>{n!=null&&e(`/${n}/cards/policy/${h}/edit`)}),[e,n]),z=r.useCallback((h=>{t(Ts(h))}),[t]),j=U.fetchState.fetchState;return!F&&j!=="Completed"&&j!=="Error"?o.jsxs(o.Fragment,{children:[o.jsx(Ae,{isAppContentDrawerOpen:b,handleDrawerToggle:A}),o.jsx(ac,{onBackClick:G,onNewPolicyClick:M,onClickMenuIcon:u,isAiCfoAccessEnabled:C,onAskAiCfoClick:O})]}):o.jsxs(o.Fragment,{children:[o.jsx(Ae,{isAppContentDrawerOpen:b,handleDrawerToggle:A}),o.jsx(tc,{policies:y,archivingTemplateId:U.archiveTargetTemplateId,pendingCreationCount:x,onBackClick:G,onNewPolicyClick:M,onEditPolicyClick:L,onArchivePolicyClick:z,onClickMenuIcon:u,policyAiCfoHero:g,isAiCfoAccessEnabled:R,onAskAiCfoClick:O})]})}function Kc(){const e=ie(),{cardId:a}=Ve(),n=le(),t=te.getSignedInUser(),s=d((X=>ge(X))),f=Re(),b=Fe(f?.loggedInUserRoleMap),{useFeatureGate:m}=de();if(t==null)throw Error("Can't access Add To Wallet Page without signing in...");const[A,u]=r.useState(!1),l=d((X=>Wa(X).firstViewAfterActivation));if(a==null)throw Error("Empty card id is not valid...");const B=s.userRole.includes("charge_card_user"),{isFeatureEnabled:_}=m(q.isChargeCardFeatureEnabled),C=!!s.companyChargeCardInfo?.info?.isChargeCardEnabled,{isFeatureEnabled:O}=m(q.isDebitCardFeatureEnabled),U=xe(s),S=Le(s),c=Be(O,s),p=s.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,x=Oe({isDebitCardFeatureEnabled:O,isBankingOnlyTenant:c}),E=Ue({isCardsOnlyTenant:U,isChargeCardFeatureEnabled:_,isBookKeepingTenant:S,isDebitCardProductVisible:x,chargeCardsCreditAccountLimit:p}),I=!!s.companyDebitCardInfo?.info?.isDebitCardEnabled,k=d((X=>da(X,s.companyId))),V=la(k.controllers),{creditAccount:w,creditAccountRepayment:y}=d((X=>ua(X))),F=d((X=>X.classListState.fetchState)),i=!B&&E&&C,g=d((X=>wt(X,a,i,E))),[R,G]=r.useState(!1),M=g.chargeCard,L=M?.cardCreatedByUser?.userId,z=d((X=>L!=null?Ga(X.userRoleState,L):void 0)),j=z?.accountingClassIDs[0],h=d((X=>j!=null?$a(X.classState,{classId:j,reportId:"class_list"}):void 0)),H=M?.cardHolderUser?.userId,K=d((X=>H!=null?Ga(X.userRoleState,H):void 0)),D=K?.accountingClassIDs[0],W=d((X=>D!=null?$a(X.classState,{classId:D,reportId:"class_list"}):void 0)),N=M?.type.code==="business_physical_credit_card"||M?.type.code==="business_physical_debit_card",$=M?.type.code==="business_physical_debit_card";r.useEffect((()=>{l&&A===!1&&N&&(u(!0),setTimeout((()=>{n(Za()),$&&n(Ke({messageSection:"set_debit_card_pin",messageText:"success",type:"success",showStatusIcon:!0}))}),5e3))}),[l,A,N,$]),r.useEffect((()=>{R||g.fetchState==="Completed"||g.fetchState==="In-Progress"||a==null||(G(!0),n(Ia(a,i,!1)))}),[R,g,a,n]),r.useEffect((()=>{if(g.fetchState==="Completed"&&(N===!1||N&&M?.status?.code!=="active"||M?.cardHolderUserId!==t.userId||l===!1&&A===!1||M?.type.code==="business_physical_debit_card"||M?.type.code==="business_virtual_debit_card")){const X=De(s.tenantEmailDomain,a,t,M,l);e(X)}}),[g.fetchState,l,N]),r.useEffect((()=>{w.fetchState!=="Completed"&&w.fetchState!=="In-Progress"&&E&&C&&b&&n(Je()),y.fetchState!=="Completed"&&y.fetchState!=="In-Progress"&&E&&C&&b&&n(Tt()),F!=="Completed"&&F!=="In-Progress"&&n(Nn())}),[w.fetchState,y.fetchState,n,E,C,b,F]);const v=()=>{if(t!=null&&a!=null){n(Za());const X=De(s.tenantEmailDomain,a,t);e(X)}},T=M?.type.code==="business_physical_debit_card"||M?.type.code==="business_virtual_debit_card",P=ea(E,x,I,C),ae=xa(E,C,b,w,y),Ce=Ar(T,g);return g.fetchState!=="Completed"?o.jsx(wa,{fetchState:"In-Progress"}):o.jsxs(o.Fragment,{children:[o.jsx(tt,{showConfetti:l}),o.jsx(nc,{onGotItClick:v,isDebitCard:M?.type.code==="business_physical_debit_card",controllerEmails:V,isChargeCardFeatureEnabled:E,isDebitCardFeatureEnabled:x,isDebitCardSetupEnabled:I,isChargeCardSetupEnabled:C,productInformation:P,creditAccountInformation:ae,debitAccountInformation:Ce,chargeCardDetailView:g,creditAccount:w,classListFetchState:F,creditAccountRepayment:y,cardIssuedByRoles:z?.userRoles,cardIssuedByDepartmentName:h?.className,cardHolderRoles:K?.userRoles,cardHolderDepartmentName:W?.className})]})}const Lr="charge-card-transaction-update",Br="charge-card-transaction-created",Rr="charge-card-transaction-declined",Or="charge-card-transaction-updated",Ur="charge-card-transaction-receipt-uploaded",pa="charge-card-status-update",Vt="charge-card-spending-updated",ot="credit-account-balance-updated",ct="charge-card-created",Ht="charge-card-limit-updated",Gt="charge-card-limit-reset",$t="charge-card-renamed",Yc="charge-card-department-updated",jr="charge-card-repayment-completed",Mr="charge-card-payment-date-updated",La="charge-card-cashback-redeemed",Ba="charge-card-cashback-earned",ha=(e,a)=>e==null||e===""?[]:a.map((n=>`private-encrypted-${e}.${n}`)),Wc=[Ba,La],qc=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(vs({uiState:{sortKey:a,sortOrder:n}}))}}}))(sc);function Jc(){const e=ie(),a=le(),n=me(),t=te.getSignedInUser(),s=d((_=>ge(_))),[f,b]=r.useState(!1),m=d((_=>ma(_))),A=wr(s.companyId,{clearParams:m.fetchState==="Completed"}),u=r.useCallback((()=>{const _=we(n.state?.pathnameStackToGoBack),C=_.poppedPathname??Qc(s.tenantEmailDomain);e(C,{state:{pathnameStackToGoBack:_.newStack}})}),[e,n,s.tenantEmailDomain]),l=ta(s);if(Nt({events:ha(l,Wc),onEvent:_=>{switch(_){case Ba:case La:return void a(_a(!0))}},onSubscribed:()=>{a(_a(!0))}}),r.useEffect((()=>{f||m.fetchState==="Completed"||m.fetchState==="In-Progress"||(b(!0),a(_a()))}),[f,m,a]),t==null)throw Error("Can't access cashback detail page without signing in...");const B=m.cashbackSummary?.cashbackEarned?.amount!=null&&m.fetchState!=="Not-Started";return m.fetchState!=="In-Progress"||B?(m.cashbackSummary?.cashbackEarned?.amount??0)===0&&m.fetchState==="Completed"?o.jsx(st,{}):o.jsx(qc,{onBackClick:u,initialOpenThreadRequest:A}):o.jsx(rc,{onBackClick:u})}const Qc=e=>`/${e}/cards`,Xc={containerWidth:new va(100,58)},ei=({appContent:e})=>{const a=Ta(),n=le(),t=ie(),{cardId:s}=Ve(),f=me(),{useDynamicConfig:b}=de(),[m,A]=r.useState(!1),[u,l]=r.useState(!1),[B,_]=r.useState(!1),[C,O]=r.useState(!1),U=te.getSignedInUser();if(U==null)throw Error("Can't access onboarding card page without signing in...");const S=d((W=>ge(W)));if(s==null)throw Error("Empty card id is not valid...");const{configValue:c}=b(Xe.zeniCardsConfig),p=c.max_charge_card_activation_attempts_by_card_id,x=d((W=>Fs(W,s))),E=x.chargeCard,I=d((W=>W.chargeCardConfigState.fetchState)),{useFeatureGate:k}=de(),{isFeatureEnabled:V}=k(q.isChargeCardFeatureEnabled),{isFeatureEnabled:w}=k(q.isDebitCardFeatureEnabled),y=Be(w,S),F=Oe({isDebitCardFeatureEnabled:w,isBankingOnlyTenant:y}),i=!!S.companyChargeCardInfo?.info?.isChargeCardEnabled,g=S.userRole.includes("charge_card_user"),R=xe(S),G=Le(S),M=S.companyChargeCardInfo?.info?.chargeCardsCreditAccountLimit??0,L=Ue({isCardsOnlyTenant:R,isChargeCardFeatureEnabled:V,isBookKeepingTenant:G,isDebitCardProductVisible:F,chargeCardsCreditAccountLimit:M}),z=!g&&L&&i;r.useEffect((()=>{m===!1&&I!=="In-Progress"&&I!=="Completed"&&(n(qa()),A(!0)),u===!1&&x.fetchState==="Not-Started"&&(l(!0),n(Ia(s,z,L)))}),[u,x.fetchState,m,I]);const j=E?.type.code==="business_physical_credit_card"||E?.type.code==="business_physical_debit_card";r.useEffect((()=>{if(x.fetchState==="Completed"){if(B===!1&&(j===!1||j&&E?.status?.code!=="inactive"||E?.cardHolderUserId!==U.userId)){const W=De(S.tenantEmailDomain,s,U,E,!0),N=Ee(f.state?.pathnameStackToGoBack,f.pathname);t(W,{state:{pathnameStackToGoBack:N}})}else if(B&&x.isRefreshingViewInBackground===!1&&E?.status?.code==="active"){n(xs({chargeCardId:s}));const W=De(S.tenantEmailDomain,s,U,E,!0),N=Ee(f.state?.pathnameStackToGoBack,f.pathname);n(Ja()),t(W,{state:{pathnameStackToGoBack:N}})}}}),[x.fetchState,E?.type.code,B,x.isRefreshingViewInBackground]);const h=te.getZeniOtpTokenForCardHolder(s),H=d((W=>Vn(W.userState,U.userId))),K=()=>{E?.status?.code!=="active"&&n(ga(s,!0))};r.useEffect((()=>{x.updatePhysicalChargeCardAttemptFetchState.fetchState==="Completed"&&E?.cardActivationAttemptHistory.some((W=>W.statusCode==="success"))===!0&&B===!1&&(setTimeout(K,3e3),_(!0))}),[x.updatePhysicalChargeCardAttemptFetchState.fetchState,E?.cardActivationAttemptHistory]);const D=W=>{O(W)};if(I!=="Completed"||E==null)return o.jsx(wa,{fetchState:"In-Progress"});if(E.shippingAddressId==null)throw Error("Can't access shippingAddressId.");if(H?.phone==null)throw Error("Can't access user phone number.");return o.jsxs(ni,{children:[o.jsx(Ae,{isAppContentDrawerOpen:C,handleDrawerToggle:D}),o.jsx(ai,{cardId:s,card:E,shippingAddressId:E.shippingAddressId,phone:H.phone,signedInUser:U,isSandboxEnv:Bt(),chargeCardDetailState:x,signedInUserToken:h,navigate:t,currentTenant:S,location:f,maxChargeCardActivationAttempts:p[s]!=null?p[s]:c.default_max_charge_card_activation_attempts!=null?c.default_max_charge_card_activation_attempts:3,chargeCardCashbackRatePerTransaction:c.charge_card_cashback_rate_per_transaction!=null?c.charge_card_cashback_rate_per_transaction:.0175,onClickMenuIcon:()=>{D(!0)}}),e!=null?o.jsx(ti,{windowSize:a,children:e}):null]})},ai=Pe((function(e,{chargeCardDetailState:a,shippingAddressId:n,location:t,cardId:s}){const f=Ls(e.addressState,n);if(f==null)throw Error("Can't access shippingAddress.");const b=Hn(e,s),m=a.updateStatus,A=Ca(e,!1,!1,!1);let u=!1;A.fetchState==="Completed"&&A.cards.length<=1&&(u=!0);const l=t.state?.message==="comingFromV2UrlPath";return{showActivatePage:a.chargeCard?.providerCardCreateTime!=null&&a.chargeCard.providerCardCreateTime.add(24,"h").isBefore(Bs())||l,showMenuIcon:u,shippingAddress:f,vgsVaultId:nt.cardVaultId,twoFAView:b,activationWaitStatus:m,isRefreshingViewInBackground:a.isRefreshingViewInBackground}}),(function(e,a){const{navigate:n,cardId:t,location:s,currentTenant:f,chargeCardDetailState:b}=a,m=b.chargeCard?.cardProviderID,{tenantEmailDomain:A}=f;return{onGetOtp:u=>{m!=null&&e(et(u,"ChargeCardHolder",t))},onUpdatePhysicalChargeCardAttempt:u=>{e(Os(t,u))},onResendOtp:u=>{m!=null&&e(Xa(u,"ChargeCardHolder",t))},onVerifyOtp:(u,l)=>{m!=null&&e(Qa(u,l,"ChargeCardHolder",t))},onVerifyOtpSuccess:u=>{u!=null&&te.saveZeniOtpTokenForCardHolder(u,t)},onCVVActivateSuccess:()=>{e(Rs({chargeCardId:t}))},onBackClick:()=>{const u=we(s.state?.pathnameStackToGoBack),l=u.poppedPathname==null||u.poppedPathname.includes("onboard")===!0?na(A):u.poppedPathname;n(l,{state:{pathnameStackToGoBack:u.newStack}})}}}))(oc),ti=He.div`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  width: ${e=>`${Xc.containerWidth.value(e.windowSize)}%`};