@zeniai/web-app-ui 5.4.20-qa → 5.4.21-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (169) hide show
  1. package/dist/assets/{AccountMappingScreen-C1RnOF0n.js → AccountMappingScreen-CykY8jdu.js} +2 -2
  2. package/dist/assets/{ActualMatchingMatchDetailScreen-B0LF-DvP.js → ActualMatchingMatchDetailScreen-UFhJKVUq.js} +1 -1
  3. package/dist/assets/AddressRoutes-D_IpH71K.js +1 -0
  4. package/dist/assets/AddressScreen-DXVWlMXp.js +9 -0
  5. package/dist/assets/AiCfoScreen-UfYXu56F.js +22 -0
  6. package/dist/assets/AppDrawer-ky_X7SdS.js +10 -0
  7. package/dist/assets/{BillPayApprovalRoutes-d_qnRv_k.js → BillPayApprovalRoutes-BHV3_xPL.js} +1 -1
  8. package/dist/assets/{BillPayRoutes-Knm7u9m6.js → BillPayRoutes-DwoZ4Wej.js} +18 -18
  9. package/dist/assets/BusinessVerificationPageScreen-DcJAu1U8.js +9 -0
  10. package/dist/assets/CardsAiCfoScreen-o65vXGHV.js +14 -0
  11. package/dist/assets/{ChargeCardRoutes-TX6d5LBT.js → ChargeCardRoutes-CX_ID8PO.js} +11 -11
  12. package/dist/assets/CompanyPassportScreen-wpe4W-A1.js +1 -0
  13. package/dist/assets/ConnectionAuthScreen-D5XNzpDd.js +11 -0
  14. package/dist/assets/CustomerOnboardingAuthScreen-H9oLbmaI.js +1 -0
  15. package/dist/assets/CustomerOnboardingRoutes-Crv7_qXD.js +30 -0
  16. package/dist/assets/CustomersRoutes-CsT3I1KS.js +8 -0
  17. package/dist/assets/DashboardRoutes-CkNHYlwe.js +20 -0
  18. package/dist/assets/{DefaultTenantHome-CoJMpOnn.js → DefaultTenantHome-BMhKHh4Y.js} +1 -1
  19. package/dist/assets/DomesticWireDetailScreen-BsNFmHCW.js +18 -0
  20. package/dist/assets/DrawerScreen-DPBr2rYW.js +1 -0
  21. package/dist/assets/EntityDetailRoutes-BEbJufIv.js +1 -0
  22. package/dist/assets/{ExpenseAutomationRoutes-8LBIl5LC.js → ExpenseAutomationRoutes-BWV2tipJ.js} +6 -6
  23. package/dist/assets/FeaturePreviewScreen-Co6UN19B.js +1 -0
  24. package/dist/assets/HubSpotOAuthCallbackScreen-BM3fROhV.js +1 -0
  25. package/dist/assets/InboxNotificationsProvider-iLGG8Hne.js +1 -0
  26. package/dist/assets/InvoicingRoutes-BDKU1kok.js +3 -0
  27. package/dist/assets/MagicLinkRoutes-LlQPtwmF.js +72 -0
  28. package/dist/assets/MagicLinkSignInScreen-DiuwGQZA.js +12 -0
  29. package/dist/assets/MobileAppDrawer-Ct61dQgI.js +1 -0
  30. package/dist/assets/NotFoundScreen-BThXAXPU.js +1 -0
  31. package/dist/assets/NotificationRoutes-Bq6Q_RnE.js +1 -0
  32. package/dist/assets/OAuthConsentScreen-QNvpnHLR.js +1 -0
  33. package/dist/assets/PandLWithForecastRoutes-spqAx7Nj.js +1 -0
  34. package/dist/assets/{PaymentLinkScreen-urZ7U9SC.js → PaymentLinkScreen-Xa9F1vkq.js} +5 -5
  35. package/dist/assets/PeopleRoutes-BOxWPOrb.js +22 -0
  36. package/dist/assets/PerformanceRoutes-DIk329y5.js +1 -0
  37. package/dist/assets/{Preview-Dhga7S3h.js → Preview-CfQKOy5n.js} +1 -1
  38. package/dist/assets/{QBOConnectionScreen-Cllizgjx.js → QBOConnectionScreen-OL7fpWNi.js} +22 -22
  39. package/dist/assets/ReimbursementApprovalRoutes-Cz6prEK3.js +1 -0
  40. package/dist/assets/ReimbursementApprovalRuleDetailScreen-CsHKBNa1.js +1 -0
  41. package/dist/assets/ReimbursementRoutes-BJsGbiLA.js +68 -0
  42. package/dist/assets/ReportsRoutes-Q_1D8cZK.js +1 -0
  43. package/dist/assets/RewardsRoutes-Dl2249xj.js +1 -0
  44. package/dist/assets/{ScheduleDetailsPrepaidExpensesScreen-C1AIWmci.js → ScheduleDetailsPrepaidExpensesScreen-BdjCOE8f.js} +5 -5
  45. package/dist/assets/ScreenRoutes-n390CBhV.js +2 -0
  46. package/dist/assets/{SettingsRoutes-Bk6BvUvm.js → SettingsRoutes-BpaF5UCO.js} +6 -6
  47. package/dist/assets/{SetupPagesScreen-B0Rr7fey.js → SetupPagesScreen-B4mnKcCt.js} +5 -5
  48. package/dist/assets/SignInScreen-U-UH-98t.js +1 -0
  49. package/dist/assets/SignOutScreen-Bb8QCtlv.js +9 -0
  50. package/dist/assets/{TaskListScreen-DJRKceku.js → TaskListScreen-cAzkNljY.js} +2 -2
  51. package/dist/assets/TaskRoutes-DWGwCtaS.js +9 -0
  52. package/dist/assets/TransactionDetailRoutes-DN0MAIjC.js +1 -0
  53. package/dist/assets/{TransactionDetailScreen-BeMygB7E.js → TransactionDetailScreen-BXxFjzdw.js} +2 -2
  54. package/dist/assets/{TransactionListRoutes-B_dIALM9.js → TransactionListRoutes-DydlnHAH.js} +1 -1
  55. package/dist/assets/TreasuryRoutes-B4mGKq9W.js +37 -0
  56. package/dist/assets/{VendorsRoutes-jnQiOZos.js → VendorsRoutes-D1ROPhMq.js} +18 -18
  57. package/dist/assets/WiseConfirmationScreen-B63B7RbG.js +12 -0
  58. package/dist/assets/ZeniAccountRoutes-CZ-mVo79.js +57 -0
  59. package/dist/assets/ZeniAccountStatementScreen-BkBxUanJ.js +9 -0
  60. package/dist/assets/{accountMappingHelper-D5RLPl0Q.js → accountMappingHelper-D9GxJ4jJ.js} +1 -1
  61. package/dist/assets/{analytics-B_BCmETJ.js → analytics-BSiwA26E.js} +1 -1
  62. package/dist/assets/{analyticsHelper-CY3FldM6.js → analyticsHelper-Vk8jtaRR.js} +1 -1
  63. package/dist/assets/{core-GrVUbJGD.js → core-Drb9PBdf.js} +1 -1
  64. package/dist/assets/{decodeURIComponentSafe-C1t-__r9.js → decodeURIComponentSafe-BeDShQ8t.js} +1 -1
  65. package/dist/assets/{dnd-Cc3q8XS9.js → dnd-BrXK45tY.js} +1 -1
  66. package/dist/assets/{empty-BWUoD4Zv.js → empty-CWmPtLB4.js} +1 -1
  67. package/dist/assets/{empty-D0ciM-5y.js → empty-De4DQHyL.js} +1 -1
  68. package/dist/assets/{emptyVideoElement-DkmV6O6O.js → emptyVideoElement-BiGfqLLw.js} +1 -1
  69. package/dist/assets/epic-Bbr0Pn8Q.js +2 -0
  70. package/dist/assets/expenseAutomationHelper-X3OcZ-IX.js +1 -0
  71. package/dist/assets/{getLocaleForTenant-E8yaJhog.js → getLocaleForTenant-DdWfA4jD.js} +1 -1
  72. package/dist/assets/{index-Dw849GIn.js → index-Bt49Udfl.js} +1 -1
  73. package/dist/assets/{index-DcN2E4lO.js → index-CYlJ1a_s.js} +1 -1
  74. package/dist/assets/{index-fEZlh4Dc.js → index-CfHkHPtG.js} +2 -2
  75. package/dist/assets/index-D05GaSwv.js +1 -0
  76. package/dist/assets/{index-Bh0ZMqWQ.js → index-DIUoYuXz.js} +1 -1
  77. package/dist/assets/{index-CL0RkSdG.js → index-Rm-5en55.js} +1 -1
  78. package/dist/assets/index-t6kaSbkJ.js +1 -0
  79. package/dist/assets/{index-eXyO65Ih.js → index-z_GphMeq.js} +15750 -15711
  80. package/dist/assets/{lexical-C0CQ8hW2.js → lexical-5AsGuqwY.js} +1 -1
  81. package/dist/assets/{liveblocks-Vz4gvIdI.js → liveblocks-njwIYHC1.js} +1 -1
  82. package/dist/assets/{lottie-7o7Nu0hF.js → lottie-C-ls43Md.js} +1 -1
  83. package/dist/assets/{mui-CuMgG_27.js → mui-B5W8_mOr.js} +1 -1
  84. package/dist/assets/{pathToGoBack-6-e3rsC8.js → pathToGoBack-BVrXlWbG.js} +1 -1
  85. package/dist/assets/{pdf-Dl24vdfn.js → pdf-BZk_6t2l.js} +3 -3
  86. package/dist/assets/{pdf-lib-fawjhojL.js → pdf-lib-DPpp3HiM.js} +1 -1
  87. package/dist/assets/{plaid-DEbV2MCp.js → plaid-Cr5PEIle.js} +1 -1
  88. package/dist/assets/{pusher-BruElsMX.js → pusher-CSQbRJHx.js} +1 -1
  89. package/dist/assets/{react-B2vUC3AA.js → react-CXOn4Sf8.js} +1 -1
  90. package/dist/assets/{react-suoBZax1.js → react-DYFog7aV.js} +1 -1
  91. package/dist/assets/{react-Ds2rCLjL.js → react-DctGkwQV.js} +1 -1
  92. package/dist/assets/{react-CnHsUdIx.js → react-Dh24EN9G.js} +1 -1
  93. package/dist/assets/{react-BUjsymiG.js → react-N1WgNt-u.js} +1 -1
  94. package/dist/assets/{react-Ch583KjZ.js → react-mPSX53PV.js} +1 -1
  95. package/dist/assets/{recharts-Cz5M2Ami.js → recharts-CA6HYyTi.js} +1 -1
  96. package/dist/assets/{reportTimeframe-B4ojXbeQ.js → reportTimeframe-BbZLWisn.js} +1 -1
  97. package/dist/assets/routePaths-DR8gB3XS.js +1 -0
  98. package/dist/assets/{sentry-Y8vuE8aQ.js → sentry-VFPS4V5K.js} +1 -1
  99. package/dist/assets/{stripSplatSuffix-DBJKfIbL.js → stripSplatSuffix-DKTWsyEu.js} +1 -1
  100. package/dist/assets/{url-DhQWTUYg.js → url-CvFWVqy3.js} +1 -1
  101. package/dist/assets/{url-DLR2uoac.js → url-DK4U3B1Z.js} +1 -1
  102. package/dist/assets/useActualMatchingMatchDetail-C8BSOHSu.js +1 -0
  103. package/dist/assets/useAiCfoDashboardSuggestedQuestionsChips-CyHYQDPy.js +1 -0
  104. package/dist/assets/useAskAiCfoHostNavButtonProps-BV1kovUD.js +1 -0
  105. package/dist/assets/{useChargeCardPusherEvents-aMKf6KAu.js → useChargeCardPusherEvents-BW-fScDD.js} +1 -1
  106. package/dist/assets/{useDeviceId-KzHLS1Iv.js → useDeviceId-B5JBZYk7.js} +1 -1
  107. package/dist/assets/useEmailConnectResultRefresh-DQJDDPj6.js +1 -0
  108. package/dist/assets/useEnsureVendorListLoaded-T6HLY1O3.js +1 -0
  109. package/dist/assets/{useInitialThreadRequest-zNumU9hI.js → useInitialThreadRequest-CE7-w0Ve.js} +1 -1
  110. package/dist/assets/useIsCustomersTabEnabled-CxdytBTD.js +1 -0
  111. package/dist/assets/useTaskManagerAccess-D-MaKZ1u.js +1 -0
  112. package/dist/assets/{useTaskManagerPusherEvents-CN3jrzrj.js → useTaskManagerPusherEvents-UBdwYUHJ.js} +1 -1
  113. package/dist/assets/{utils-PKPkEQd5.js → utils-CibnWgOj.js} +1 -1
  114. package/dist/assets/{withTransactionSidePanel-D9vq13QQ.js → withTransactionSidePanel-BLWvlaZt.js} +2 -2
  115. package/dist/assets/{zeni-epic-state-COBHVss0.js → zeni-epic-state-9qkFzYai.js} +7 -7
  116. package/dist/index.html +1 -1
  117. package/package.json +3 -3
  118. package/dist/assets/AddressRoutes-nzlEbpLZ.js +0 -1
  119. package/dist/assets/AddressScreen-BMW5PBGV.js +0 -9
  120. package/dist/assets/AiCfoScreen-X6l8TO3I.js +0 -22
  121. package/dist/assets/AppDrawer-zwdzlFaD.js +0 -10
  122. package/dist/assets/BusinessVerificationPageScreen-mjhVHH4O.js +0 -9
  123. package/dist/assets/CardsAiCfoScreen-B6cIfYHl.js +0 -14
  124. package/dist/assets/CompanyPassportScreen-BWtavadn.js +0 -1
  125. package/dist/assets/ConnectionAuthScreen-k0c3LH8h.js +0 -11
  126. package/dist/assets/CustomerOnboardingAuthScreen-BKNrdOGe.js +0 -1
  127. package/dist/assets/CustomerOnboardingRoutes-BAceZmH-.js +0 -30
  128. package/dist/assets/DashboardRoutes-C1cQM1iq.js +0 -20
  129. package/dist/assets/DomesticWireDetailScreen-CN_AwtpO.js +0 -18
  130. package/dist/assets/DrawerScreen-D7I-GzS4.js +0 -1
  131. package/dist/assets/EntityDetailRoutes-DRcTK4xX.js +0 -1
  132. package/dist/assets/FeaturePreviewScreen-DZWG45PX.js +0 -1
  133. package/dist/assets/HubSpotOAuthCallbackScreen-BaMHkeHO.js +0 -1
  134. package/dist/assets/InboxNotificationsProvider-gHb6rSEv.js +0 -1
  135. package/dist/assets/InvoicingRoutes-CfS4mAJT.js +0 -3
  136. package/dist/assets/MagicLinkRoutes-BWTSKuZR.js +0 -72
  137. package/dist/assets/MagicLinkSignInScreen-BBiLqeC6.js +0 -12
  138. package/dist/assets/MobileAppDrawer-nKSb2sKG.js +0 -1
  139. package/dist/assets/NotFoundScreen-lrXID2D2.js +0 -1
  140. package/dist/assets/NotificationRoutes-CLz6VAM_.js +0 -1
  141. package/dist/assets/OAuthConsentScreen-DLGkSjxy.js +0 -1
  142. package/dist/assets/PandLWithForecastRoutes-BRH3UvCo.js +0 -1
  143. package/dist/assets/PeopleRoutes-DC0KccAq.js +0 -22
  144. package/dist/assets/PerformanceRoutes-CGtga_hp.js +0 -1
  145. package/dist/assets/ReimbursementApprovalRoutes-DwWMn7cn.js +0 -1
  146. package/dist/assets/ReimbursementApprovalRuleDetailScreen-O-yHh4uj.js +0 -1
  147. package/dist/assets/ReimbursementRoutes-BXVuYLRT.js +0 -68
  148. package/dist/assets/ReportsRoutes-Barssrna.js +0 -1
  149. package/dist/assets/RewardsRoutes-BgUVgwGN.js +0 -1
  150. package/dist/assets/ScreenRoutes-mJWUDJcG.js +0 -2
  151. package/dist/assets/SignInScreen-BM3Vo8Sm.js +0 -1
  152. package/dist/assets/SignOutScreen-WK9PJrGQ.js +0 -9
  153. package/dist/assets/TaskRoutes-D4jH7PJl.js +0 -9
  154. package/dist/assets/TransactionDetailRoutes-Sp9ULYUl.js +0 -1
  155. package/dist/assets/TreasuryRoutes-7AIyWRUd.js +0 -37
  156. package/dist/assets/WiseConfirmationScreen-CPdMEGDQ.js +0 -12
  157. package/dist/assets/ZeniAccountRoutes-BipwR7h6.js +0 -57
  158. package/dist/assets/ZeniAccountStatementScreen-CFGV8Doe.js +0 -9
  159. package/dist/assets/epic-CPqi4BTJ.js +0 -2
  160. package/dist/assets/expenseAutomationHelper-BqqNQc4E.js +0 -1
  161. package/dist/assets/index-DG7Ul_N4.js +0 -1
  162. package/dist/assets/index-quhlDe1C.js +0 -1
  163. package/dist/assets/routePaths-C4nWRb1J.js +0 -1
  164. package/dist/assets/useActualMatchingMatchDetail-rg_uxZt8.js +0 -1
  165. package/dist/assets/useAiCfoDashboardSuggestedQuestionsChips-KYBucxDc.js +0 -1
  166. package/dist/assets/useAskAiCfoHostNavButtonProps-Gb5FxzST.js +0 -1
  167. package/dist/assets/useEmailConnectResultRefresh-BbKupJnC.js +0 -1
  168. package/dist/assets/useEnsureVendorListLoaded-c7kW69ou.js +0 -1
  169. package/dist/assets/useTaskManagerAccess-gL3vn6YT.js +0 -1
@@ -1,20 +0,0 @@
1
- import{j as d}from"./liveblocks-Vz4gvIdI.js";import{i as Q,j as S,g as J,u as Z,h as ee,l as se,k as pa,n as St,o as F,N as On}from"./core-GrVUbJGD.js";import{fI as L,WI as at,bG as K,br as xe,Yh as Tn,ke as wn,Yi as Ht,Yj as xn,kh as _t,Yk as Je,Yl as Pn,km as Fn,Ym as Wt,Yn as Rn,kq as kt,Yo as et,Yp as Bn,Yq as jn,X0 as Mn,ls as Yn,Yr as Ln,bn as nt,Ys as fa,XG as he,bc as ha,lG as ga,lp as ba,XI as ge,XH as oe,fH as Ca,gd as Un,gt as yt,Yt as Vn,Yu as Gn,Yv as Sa,lU as It,W1 as Le,di as Ue,EC as Nn,Yw as De,Ev as Ve,Ew as Ge,EV as Pe,EP as be,EA as Ne,Yx as qn,c1 as qe,Yy as zn,Yz as Kn,YA as _a,lZ as Et,ED as Zn,YB as Oe,YC as $n,ek as ot,AB as ka,YD as Qn,YE as ya,YF as Hn,YG as Wn,YH as Xn,YI as vt,VD as Dt,ul as Fe,m3 as Re,q1 as Ot,EG as Jn,YJ as le,F3 as Tt,AI as eo,AP as to,YK as ao,YL as no,Ex as Xt,YM as oo,AE as Te,Az as Aa,YN as Jt,YO as so,YP as wt,VC as xt,CM as Ia,YQ as ro,YR as Ea,YS as io,YT as co,YU as lo,YV as Pt,p$ as Ft,EF as uo,YW as de,C$ as mo,D6 as po,YX as fo,YY as ho,Ez as ea,YZ as go,CK as va,Y_ as ta,Y$ as bo,bq as Da,F8 as Oa,Z0 as Co,Z1 as Ta,Z2 as So,Z3 as _o,Z4 as ko,Z5 as Rt,q0 as Bt,EE as yo,Z6 as ue,F0 as Ao,F2 as Io,Z7 as Eo,Z8 as vo,Ey as aa,Z9 as Do,F6 as wa,Za as na,Zb as Oo,Zc as To,Zd as xa,q3 as Pa,C7 as wo,de as xo,pY as Po,UZ as Fo,qd as Ro,Ze as Bo,Zf as jo,Zg as Mo,b5 as jt,q7 as Yo,ih as Lo,gL as Uo,q6 as Vo,li as Go,q4 as No,q2 as qo,e1 as zo,e0 as Ko}from"./zeni-epic-state-COBHVss0.js";import{z as U,at as re,l as R,k as O,G as H,bc as Zo,aq as ze,a6 as Ke,bd as Fa,S as q,be as $o,bf as Ra,bg as Qo,bh as Ho,a as Ba,_ as ja,e as Ma,ap as Wo,bi as Xo,am as Jo,p as Ce,bj as Ya,y as me,bk as La,bl as Ua,as as Va,bm as es,ag as Ze,N as M,M as $e,bn as ts,I as as,bo as ns,f as os,j as ss,a2 as rs,ao as is,bp as cs,bq as ls,br as ds,bs as we}from"./index-eXyO65Ih.js";import{u as us,n as Mt}from"./mui-CuMgG_27.js";import{a as b}from"./sentry-Y8vuE8aQ.js";import{w as Ga}from"./withTransactionSidePanel-D9vq13QQ.js";import{c as Na,t as Be,f as Se,b as Yt,a as Lt,v as ms}from"./routePaths-C4nWRb1J.js";import{u as ie}from"./useAskAiCfoHostNavButtonProps-Gb5FxzST.js";import Ye from"./NotFoundScreen-lrXID2D2.js";import{t as st}from"./reportTimeframe-B4ojXbeQ.js";import{u as Ut}from"./useInitialThreadRequest-zNumU9hI.js";import{t as qa}from"./analyticsHelper-CY3FldM6.js";import{C as ps}from"./CompanyPassportScreen-BWtavadn.js";import{u as fs}from"./useAiCfoDashboardSuggestedQuestionsChips-KYBucxDc.js";import{F as hs}from"./FeaturePreviewScreen-DZWG45PX.js";import"./recharts-Cz5M2Ami.js";import"./analytics-B_BCmETJ.js";import"./plaid-DEbV2MCp.js";import"./dnd-Cc3q8XS9.js";import"./stripe-cKAAJElX.js";import"./lottie-7o7Nu0hF.js";import"./lexical-C0CQ8hW2.js";import"./pdf-Dl24vdfn.js";import"./utils-PKPkEQd5.js";import"./TransactionDetailScreen-BeMygB7E.js";import"./decodeURIComponentSafe-C1t-__r9.js";import"./expenseAutomationHelper-BqqNQc4E.js";import"./stripSplatSuffix-DBJKfIbL.js";import"./MobileAppDrawer-nKSb2sKG.js";import"./InboxNotificationsProvider-gHb6rSEv.js";import"./useTaskManagerAccess-gL3vn6YT.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]="1fd9062a-6506-4d5e-8b63-53c11be2fb3d",e._sentryDebugIdIdentifier="sentry-dbid-1fd9062a-6506-4d5e-8b63-53c11be2fb3d")}catch{}})();const gs=Ga((function({openTransactionPanel:e,panelContent:a,sidePanelIsOpen:t,sidePanelIsFullView:n}){const{vendorId:o,reportDate:r}=Q(),s=U.getSignedInUser(),i=S((D=>D.tenantState.currentTenantId)),c=S((D=>L(D))),{tenantEmailDomain:m}=Q(),u=J(),p=c?.companyName??"",h={userId:s?.userId??"",sessionId:s?.zeniSessionId??"",tenantId:i??""},l=b.useMemo((()=>({authParams:h,companyName:p,downloadEndPoint:`${re}/agingDetailedReport`,timezone:at()})),[]),f=b.useMemo((()=>r!=null?K(r):xe()),[r]),C=Z(),g=ee(),k=S((D=>Tn(D,f,o))),E=b.useCallback((()=>{o!=null&&k.fetchState!=="In-Progress"&&k.fetchState!=="Completed"&&C(wn(o,f))}),[f]),A=b.useCallback((()=>{g("../../",{relative:"path"})}),[]),_=b.useCallback(((D,w)=>{C(Ht({sortKey:D,sortOrder:w}))}),[]),x=b.useCallback((D=>{C(Ht({downloadState:D}))}),[]),V=b.useCallback((D=>{if(e)e(D.transactionId,D.transactionType);else if(m!=null){const w=Na({id:D.transactionId,type:D.transactionType},m);g(w);const y=R(u.state?.pathnameStackToGoBack,u.pathname);g(w,{state:{pathnameStackToGoBack:y}})}}),[m,e]),v=b.useCallback((()=>{k.vendor!=null&&O.trackApAgingDetail("AP Aging",f.format(H.getLocalizedStrings().dateFormat.analytics.YYYYDashMMDashDDFormat),k.vendor.id,k.vendor.name)}),[k.vendor,f]);return b.useEffect((()=>{E()}),[]),b.useEffect((()=>{k.fetchState==="Completed"&&v()}),[v,k.fetchState]),d.jsx(Zo,{apAgingDetail:k,downloadParams:l,reportDate:f,analytics:O,onTransactionClick:V,onReload:E,onBackClick:A,onColumnSortConfigChanged:_,updateDownloadStateHandler:x,panelContent:a,sidePanelIsOpen:t,sidePanelIsFullView:n})})),bs=()=>{const e=Z(),a=ee(),t=S((_=>xn(_))),{isAiCfoAccessEnabled:n,onAskAiCfoClick:o}=ie({mobileExploreReferrer:"AP Aging"});ze({isDataReady:t.fetchState==="Completed"});const r=U.getSignedInUser(),s=S((_=>_.tenantState.currentTenantId)),i=S((_=>L(_))),c=i?.companyName??"",m={userId:r?.userId??"",sessionId:r?.zeniSessionId??"",tenantId:s??""},u=b.useMemo((()=>({authParams:m,companyName:c,downloadEndPoint:`${re}/agingReport`,timezone:at()})),[]),p=t.apAgingUIState.selectedDate??xe(),h=b.useCallback((()=>{t.fetchState!=="In-Progress"&&t.fetchState!=="Completed"&&e(_t(p))}),[]);b.useEffect((()=>{h()}),[]);const l=b.useCallback((()=>{a("../",{relative:"path"})}),[]),f=b.useCallback((_=>{e(Je({searchString:_}))}),[]),C=b.useCallback(((_,x)=>{e(Je({sortKey:x,sortOrder:_}))}),[]),g=b.useCallback((_=>{a(`./${_}/${p.format(H.getLocalizedStrings().dateFormat.analytics.YYYYDashMMDashDDFormat)}`)}),[p]),k=b.useCallback((_=>{e(Je({downloadState:_}))}),[]),E=b.useCallback(((_,x)=>{}),[]),A=b.useCallback(((_,x)=>{e(Je({selectedDate:_,agingDateSelectionType:x})),e(_t(_))}),[]);return d.jsxs(d.Fragment,{children:[t.fetchState==="Completed"?d.jsx(Ke,{analytics:O,onLoad:_=>_.trackPageLoaded(q.Event.agingReport,"AP Aging")}):null,d.jsx(Fa,{uiState:t.apAgingUIState,report:t,downloadParams:u,analytics:O,onReloadReport:h,onBackClick:l,onSearchTextChange:f,onSortOrderChange:C,onEntityNameClick:g,updateDownloadStateHandler:k,onSelectedDateChanged:A,onNodeCollapseToggled:E,isAiCfoAccessEnabled:n,onAskAiCfoClick:o})]})},Cs=Ga((function({openTransactionPanel:e,panelContent:a,sidePanelIsOpen:t,sidePanelIsFullView:n}){const{customerId:o,reportDate:r}=Q(),s=U.getSignedInUser(),i=S((v=>L(v))),{tenantEmailDomain:c}=Q(),m=J(),u=i.companyName,p={userId:s?.userId??"",sessionId:s?.zeniSessionId??"",tenantId:i.tenantId},h=b.useMemo((()=>({authParams:p,companyName:u,downloadEndPoint:`${re}/agingDetailedReport`,timezone:at()})),[]),l=b.useMemo((()=>r!=null?K(r):xe()),[r]),f=Z(),C=ee(),g=S((v=>Pn(v,l,o))),k=b.useCallback((()=>{o!=null&&g.fetchState!=="In-Progress"&&g.fetchState!=="Completed"&&f(Fn(o,l))}),[l]),E=b.useCallback((()=>{C("../../",{relative:"path"})}),[]),A=b.useCallback(((v,D)=>{f(Wt({sortKey:v,sortOrder:D}))}),[]),_=b.useCallback((v=>{f(Wt({downloadState:v}))}),[]),x=b.useCallback((v=>{if(e)e(v.transactionId,v.transactionType);else if(c!=null){const D=Na({id:v.transactionId,type:v.transactionType},c);C(D);const w=R(m.state?.pathnameStackToGoBack,m.pathname);C(D,{state:{pathnameStackToGoBack:w}})}}),[c,e]),V=b.useCallback((()=>{g.customer!=null&&O.trackArAgingDetail("AR Aging",l.format(H.getLocalizedStrings().dateFormat.analytics.YYYYDashMMDashDDFormat),g.customer.id,g.customer.name)}),[g.customer,l]);return b.useEffect((()=>{k()}),[]),b.useEffect((()=>{g.fetchState==="Completed"&&V()}),[g.fetchState,V]),d.jsx($o,{arAgingDetail:g,downloadParams:h,reportDate:l,analytics:O,onTransactionClick:x,onReload:k,onBackClick:E,onColumnSortConfigChanged:A,updateDownloadStateHandler:_,panelContent:a,sidePanelIsOpen:t,sidePanelIsFullView:n})})),Ss=()=>{const e=Z(),a=ee(),t=S((A=>Rn(A))),{isAiCfoAccessEnabled:n,onAskAiCfoClick:o}=ie({mobileExploreReferrer:"AR Aging"});ze({isDataReady:t.fetchState==="Completed"});const r=U.getSignedInUser(),s=S((A=>L(A))),i=s.companyName,c={userId:r?.userId??"",sessionId:r?.zeniSessionId??"",tenantId:s.tenantId},m=b.useMemo((()=>({authParams:c,companyName:i,downloadEndPoint:`${re}/agingReport`,timezone:at()})),[]),u=t.arAgingUIState.selectedDate??xe(),p=b.useCallback((()=>{t.fetchState!=="In-Progress"&&t.fetchState!=="Completed"&&e(kt(u))}),[]);b.useEffect((()=>{p()}),[]);const h=b.useCallback((()=>{a("../",{relative:"path"})}),[]),l=b.useCallback((A=>{e(et({searchString:A}))}),[]),f=b.useCallback(((A,_)=>{e(et({sortKey:_,sortOrder:A}))}),[]),C=b.useCallback((A=>{a(`./${A}/${u.format(H.getLocalizedStrings().dateFormat.analytics.YYYYDashMMDashDDFormat)}`)}),[u]),g=b.useCallback((A=>{e(et({downloadState:A}))}),[]),k=b.useCallback(((A,_)=>{e(et({selectedDate:A,agingDateSelectionType:_})),e(kt(A))}),[]),E=b.useCallback(((A,_)=>{e(Bn({nodeId:A,isCollapsed:_}))}),[]);return d.jsxs(d.Fragment,{children:[t.fetchState==="Completed"?d.jsx(Ke,{analytics:O,onLoad:A=>A.trackPageLoaded(q.Event.agingReport,"AR Aging")}):null,d.jsx(Fa,{uiState:t.arAgingUIState,report:t,downloadParams:m,analytics:O,onReloadReport:p,onBackClick:h,onSearchTextChange:l,onSortOrderChange:f,onEntityNameClick:C,updateDownloadStateHandler:g,onSelectedDateChanged:k,onNodeCollapseToggled:E,isAiCfoAccessEnabled:n,onAskAiCfoClick:o})]})},za=(e,a)=>({key:a,title:e.accountName,amount:e.balance?.available,logoUri:e.logo?.toString(),source:e});function Ka(e,a){const t=Mn(a.firstMonthOfFY);return{onItemClick:(n,o)=>{const r=o.accountName===""?o.accountDescription:o.accountName,s=Be(a.tenantEmailDomain,o.accountId,o.accountType,r,"quarter",t,!1),i=R(a.location.state?.pathnameStackToGoBack,a.location.pathname);a.navigate(s,{state:{pathnameStackToGoBack:i,referrer:a.referrerType}})},onSetAccountsStatementDate:(n,o)=>{e(Yn(n,o))}}}const _s=se((function(e){const a=jn(e).accountsInOrder.map(((t,n)=>za(t,n)));return{sectionTitle:H.getLocalizedStrings().balanceCard.cashBalanceSectionTitle,transactionArray:a,fetchState:e.cashBalanceState.fetchState,analytics:O}}),Ka)(Ra),ks=se((function(e){const a=Ln(e).accountsInOrder.map(((o,r)=>za(o,r))),t=U.getSignedInUser(),n=nt(t);return{sectionTitle:H.getLocalizedStrings().balanceCard.cardBalanceSectionTitle,transactionArray:a,isZeniUser:n,fetchState:e.cardBalanceState.fetchState,analytics:O}}),Ka)(Ra);function ys(){const e=ee(),a=J(),{tenantEmailDomain:t}=Q(),n=S((o=>L(o).company?.companyInfo.firstMonthOfFY??1));return S((o=>o.cashBalanceState.fetchState))==="Error"?d.jsx(Ye,{}):d.jsx(_s,{tenantEmailDomain:t,location:a,referrerType:"Cash Balance",navigate:e,firstMonthOfFY:n})}function As(){const e=ee(),a=J(),{tenantEmailDomain:t}=Q(),n=S((o=>L(o).company?.companyInfo.firstMonthOfFY??1));return S((o=>o.cardBalanceState.fetchState))==="Error"?d.jsx(Ye,{}):d.jsx(ks,{tenantEmailDomain:t,location:a,referrerType:"Card Balance",navigate:e,firstMonthOfFY:n})}const Is=Mt.div`
2
- display: flex;
3
- flex: 1 1 auto;
4
- min-height: 100%;
5
- flex-direction: column;
6
- background-color: ${e=>e.theme.colors.grey4};
7
- `,Es=Mt.div`
8
- display: flex;
9
- flex: 1 1 auto;
10
- flex-direction: column;
11
- align-items: center;
12
- background-color: ${e=>e.theme.colors.grey4};
13
- `;function vs({title:e,reportId:a,entityAutoCompleteView:t,autoCompleteText:n,isAiCfoAccessEnabled:o,onAskAiCfoClick:r}){const s=ee(),i=Z(),c=J(),{tenantEmailDomain:m}=Q(),u=us();return d.jsxs(Is,{children:[d.jsx(Qo,{source:a==="cash_balance"?"CashBalanceDetailScreen":"CardBalanceDetailScreen",title:e,onBackClick:()=>{s("../")},hideSearchBtn:!0,backgroundColor:u.colors.grey4,searchAutoComplete:{autoCompleteData:{entityAutoCompleteView:t,autoCompleteText:n},autoCompleteActions:{onAutoCompleteInputChange:p=>{p.trim().length>=2?i(ge({searchString:p,searchOrigin:"navbar"})):p.trim().length===0&&i(oe("navbar"))},onAutoCompleteEntity:p=>{n!=null&&O?.trackSearch(q.Event.search,Ds(a),p.type,p.name,n);const h=Se(p,m),l=R(c.state?.pathnameStackToGoBack,c.pathname);s(h,{state:{pathnameStackToGoBack:l}})}}},rightSideComponent:d.jsx(Ho,{isAiCfoAccessEnabled:o,onAskAiCfoClick:r})}),d.jsx(Es,{children:a==="cash_balance"?d.jsx(ys,{}):d.jsx(As,{})})]})}function oa(){const e=J(),a=Z(),t=S((l=>l.cashBalanceState.fetchState)),n=S((l=>l.cardBalanceState.fetchState)),o=U.getSignedInUser();if(o==null)throw Error("Can't access dashboard detail without signing in...");const r=fa((l=>{const f=ha(l,"/").split("/");return f[f.length-1]})(e.pathname));let s="Not-Started",i="";const c=H.getLocalizedStrings();switch(r){case"cash_balance":s=t,i=c.common.texts.cashBalance;break;case"card_balance":s=n,i=c.reportTitleById.card_balance;break;default:console.error(`${r} is not supported!`)}const{isAiCfoAccessEnabled:m,onAskAiCfoClick:u}=ie({mobileExploreReferrer:r==="card_balance"?"Card Balance":"Cash Balance"});ze({isDataReady:s==="Completed"});const p=S((l=>l.entityAutoCompleteState.autoCompleteText.navbar)),h=S((l=>he(l,"navbar")));return b.useEffect((()=>{s==="Not-Started"&&(function(l,f){switch(f){case"card_balance":l(ba());break;case"cash_balance":l(ga());break;default:throw new Error(`balance report type ${f} is not yet supported`)}})(a,r)}),[o,a,s]),d.jsxs(d.Fragment,{children:[s==="Completed"?d.jsx(Ke,{analytics:O,onLoad:l=>((f,C)=>{switch(C){case"card_balance":f.trackPageLoaded(q.Event.cardBalance);break;case"cash_balance":f.trackPageLoaded(q.Event.cashBalance);break;default:console.error(`Analytics: Not tracking Page Loaded for ${C}!`)}})(l,r)}):null,d.jsx(vs,{title:i,reportId:r,autoCompleteText:p,entityAutoCompleteView:h,isAiCfoAccessEnabled:m,onAskAiCfoClick:u})]})}const Ds=e=>{switch(e){case"cash_balance":return"Cash Balance";case"card_balance":return"Card Balance";default:return"Dashboard"}},Os=[],sa="insights_section";function Qe(e){const{mobileExploreReferrer:a}=e,t=Z(),n=ee(),o=J(),{tenantEmailDomain:r}=Q(),{setIsAiCfoOpen:s,setAiCfoSidePanelQuestionToSubmit:i}=Ba(),c=ja(),m=Va(c),u=pa(),p=S((B=>B.tenantState.fetchState==="Completed"||B.tenantState.activeTenantFetchState.fetchState==="Completed"?L(B):void 0)),h=p?.masterTOSInfo?.isMasterTOSAccepted??!1,l=S((B=>Ca(B))),f=l.uiState?.currentChatSessionId,C=l.allSessionsWithOrderedQuestionAnswers??Os,g=U.getSignedInUser()?.userId,k=Ma(),E=Wo()&&k&&r!=null,A=Xo(),_=Jo(!0),x=S((B=>A!=null?Un(B,A):void 0)),{useDynamicConfig:V}=Ce(),{configValue:v}=V(Ya.aiCfoMessageDynamicConfig),D=b.useMemo((()=>Array.isArray(v.default_message_list)?v.default_message_list:[]),[v.default_message_list]),w=b.useMemo((()=>D.slice(0,2)),[D]),y=A!=null&&x!=null&&x.fetchState!=="Completed"&&x.fetchState!=="Error"&&(_||x.fetchState==="In-Progress"),T=b.useMemo((()=>{if(A==null||x?.fetchState==="Error")return w;if(y)return[];const B=(x?.suggestedQuestions??[]).map((te=>te.trim())).filter((te=>te.length>0)).slice(0,2);return B.length===0?w:B}),[w,y,A,x?.fetchState,x?.suggestedQuestions]),ce=b.useCallback(((B,te)=>{if(g==null||B.trim()==="")return;if(!h)return void me({location:o,navigate:n,mergeState:{referrer:a,aiCfoInitialQuestion:B,aiCfoInitialSubmissionSource:sa,aiCfoSuggestionIndex:te}});const We=La(u.getState());if(m){const Xe=R(o.state?.pathnameStackToGoBack,o.pathname);n(`/${r}/ai-cfo/explore`,{state:{message:"",origin:"",pathnameStackToGoBack:Xe,referrer:a,aiCfoInitialQuestion:B,aiCfoShouldSubmit:!We}})}else{if(We)return t(yt(B)),void s(!0);i(B),s(!0),Ua(t,B,sa,f,C,g,te,void 0)}}),[C,f,t,h,m,o,a,n,s,i,u,r,g]),ye=b.useCallback((()=>{if(h)if(m){const B=R(o.state?.pathnameStackToGoBack,o.pathname);n(`/${r}/ai-cfo/explore`,{state:{message:"",origin:"",pathnameStackToGoBack:B,referrer:a}})}else s(!0);else me({location:o,navigate:n,mergeState:{referrer:a}})}),[h,m,o,a,n,s,r]);return b.useMemo((()=>{if(E)return{isSuggestedQuestionsLoading:y,onAskSomethingElseClick:ye,onSuggestedQuestionClick:ce,suggestedQuestions:T}}),[E,y,ye,ce,T])}const He=es,Ts=se((function(e){const a=Vn(e),t=Gn(e),n=Sa(e),{scrollPosition:o,...r}=n,s=H.getLocalizedStrings().reportTitleById.cash_in_cash_out,i=U.getSignedInUser(),c=e.tenantState.currentTenantId,m=L(e),u=m?.companyName??"",p={userId:i?.userId??"",sessionId:i?.zeniSessionId??"",tenantId:c??""},h=e.entityAutoCompleteState.autoCompleteText.navbar,l=he(e,"navbar");return{selectedRangeReport:a,reportLabels:{reportTitle:s},highlightedRangeReport:t,uiState:r,scrollPosition:o,downloadParams:{downloadState:a.downloadState,currentTenantCompanyName:u,statementEndPoint:`${re}/statement`,authParams:p},analytics:O,autoCompleteData:{autoCompleteText:h,entityAutoCompleteView:l}}}),(function(e,a){return{updateDownloadStateHandler:t=>{e(qn(t))},onTimeframeSelectionChanged:()=>{},onCOABalancesRangeChanged:(t,n)=>{e(Ne(t,n)),e(De({resetLeftScroll:!0}))},onThisPeriodChanged:t=>{e(Pe("month")),e(be(a.firstMonthOfFY,t)),e(De({resetLeftScroll:!0}))},onAdditionalBalanceSelectionChanged:(t,n,o)=>{e(Ve(a.firstMonthOfFY,t,o,n)),n.length>0&&e(Ge(a.firstMonthOfFY,n.includes("this_period_vs_last_period")?"compare_mode_amount":"compare_mode_percent",o,n)),a.isCompareModeOn!==t&&setTimeout((()=>e(De({resetLeftScroll:!0}))),50)},onElementCollapseStateChanged:(t,n)=>{e(De({nodeCollapseState:{nodeId:t,isCollapsed:n}}))},onTableScroll:t=>{e(De({scrollPosition:t}))},autoCompleteActions:{onAutoCompleteInputChange:t=>{t.trim().length>=2?e(ge({searchString:t,searchOrigin:"navbar"})):t.trim().length===0&&e(oe("navbar"))},onAutoCompleteEntity:t=>{const n=Se(t,a.tenantEmailDomain),o=R(a.location.state?.pathnameStackToGoBack,a.location.pathname);a.navigate(n,{state:{pathnameStackToGoBack:o}})}},onBackClick:()=>{a.navigate("../")},onCustomDateRangeChanged:(t,n)=>{e(It(t,n));const o=K(t),r=K(n),s=Le(a.firstMonthOfFY,"month",{startDate:o,endDate:r})??a.selectedCOABalancesRange.numberOfPeriods,{startOfTimeframeFY:i,endOfTimeframeFY:c}=Ue(r,a.firstMonthOfFY,"month"),m={numberOfPeriods:s,orderBy:a.selectedCOABalancesRange.orderBy,thisPeriod:{startDate:i,endDate:c}};e(Nn({selectedCOABalancesRange:m,highlightedCOABalancesRange:m,isCustomDateRange:!0,customStartDate:t,customEndDate:n})),e(De({resetLeftScroll:!0}))},onInitialDateRangeAvailable:()=>{}}}))(He),ws=e=>{const{tenantEmailDomain:a,location:t,navigate:n}=e,o=Ze(),{isAiCfoAccessEnabled:r,onAskAiCfoClick:s}=ie({mobileExploreReferrer:"DashboardCashInCashOut"}),i=Qe({mobileExploreReferrer:"DashboardCashInCashOut"}),c=S((h=>Sa(h))),m=c.mode==="compare_mode",{useFeatureGate:u}=Ce(),{isFeatureEnabled:p}=u(M.isReportsCustomDateRangeEnabled);return d.jsx(Ts,{firstMonthOfFY:e.firstMonthOfFY,tenantEmailDomain:a,location:t,isCompareModeOn:m,isCustomDateRangeEnabled:p,selectedCOABalancesRange:c.selectedCOABalancesRange,navigate:n,insightsSectionAiCfoInfo:i,isAiCfoAccessEnabled:r,onAskAiCfoClick:s,meetingUrl:qe(o("dashboard_report_filters"))})},xs=e=>{let a,t;switch(e.balanceTimeFrame){case"month":case"quarter":a=e.balanceTimeFrame,t=ot(e);break;case"year":a="quarter",t={startDate:e.endDate.startOf("quarter"),endDate:e.endDate};break;case"free_range":console.error("free_range timeframe is not supported!")}return{timeframe:a,timePeriod:t}},Ps=se((function(e){const a=zn(e),t=Kn(e),n=_a(e),{scrollPosition:o,...r}=n,s=H.getLocalizedStrings().reportTitleById.cash_position,i=U.getSignedInUser(),c=e.tenantState.currentTenantId,m=L(e),u=m?.companyName??"",p={userId:i?.userId??"",sessionId:i?.zeniSessionId??"",tenantId:c??""},h=e.entityAutoCompleteState.autoCompleteText.navbar,l=he(e,"navbar");return{selectedRangeReport:a,reportLabels:{reportTitle:s},highlightedRangeReport:t,uiState:r,scrollPosition:o,downloadParams:{downloadState:a.downloadState,currentTenantCompanyName:u,statementEndPoint:`${re}/statement`,authParams:p},analytics:O,autoCompleteData:{autoCompleteText:h,entityAutoCompleteView:l}}}),(function(e,a){return{updateDownloadStateHandler:t=>{e($n(t))},onTimeframeSelectionChanged:t=>{e(Pe(t)),setTimeout((()=>e(Oe({resetLeftScroll:!0}))),50)},onCOABalancesRangeChanged:(t,n)=>{e(Ne(t,n)),e(Oe({resetLeftScroll:!0}))},onThisPeriodChanged:t=>{e(be(a.firstMonthOfFY,t)),e(Oe({resetLeftScroll:!0}))},onAdditionalBalanceSelectionChanged:(t,n,o)=>{e(Ve(a.firstMonthOfFY,t,o,n)),n.length>0&&e(Ge(a.firstMonthOfFY,n.includes("this_period_vs_last_period")?"compare_mode_amount":"compare_mode_percent",o,n)),a.isCompareModeOn!==t&&setTimeout((()=>e(Oe({resetLeftScroll:!0}))),50)},onAccountBalanceClick:(t,n)=>{const{timePeriod:o,timeframe:r}=xs(n),s=t.accountName===""?t.accountDescription:t.accountName;if(o!=null&&r!=null){const i=Be(a.tenantEmailDomain,t.accountId,t.accountType,s,r,o),c=R(a.location.state?.pathnameStackToGoBack,a.location.pathname);a.navigate(i,{state:{pathnameStackToGoBack:c,referrer:"Cash Position"}})}},autoCompleteActions:{onAutoCompleteInputChange:t=>{t.trim().length>=2?e(ge({searchString:t,searchOrigin:"navbar"})):t.trim().length===0&&e(oe("navbar"))},onAutoCompleteEntity:t=>{const n=Se(t,a.tenantEmailDomain),o=R(a.location.state?.pathnameStackToGoBack,a.location.pathname);a.navigate(n,{state:{pathnameStackToGoBack:o}})}},onTableScroll:t=>{e(Oe({scrollPosition:t}))},onBackClick:()=>{a.navigate("../")},onCustomDateRangeChanged:(t,n,o)=>{e(Et(!0,t,n));const r=K(t),s=K(n),i=st(o??a.timeframe),c=Le(a.firstMonthOfFY,i,{startDate:r,endDate:s})??a.selectedCOABalancesRange.numberOfPeriods,{startOfTimeframeFY:m,endOfTimeframeFY:u}=Ue(s,a.firstMonthOfFY,i),p={numberOfPeriods:c,orderBy:a.selectedCOABalancesRange.orderBy,thisPeriod:{startDate:m,endDate:u}};e(Zn({selectedCOABalancesRange:p,highlightedCOABalancesRange:p,isCustomDateRange:!0,customStartDate:t,customEndDate:n})),e(Oe({resetLeftScroll:!0}))},onInitialDateRangeAvailable:()=>{}}}))(He),Fs=e=>{const{tenantEmailDomain:a,location:t,navigate:n}=e,o=Ze(),{isAiCfoAccessEnabled:r,onAskAiCfoClick:s}=ie({mobileExploreReferrer:"DashboardCashPosition"}),i=Qe({mobileExploreReferrer:"DashboardCashPosition"}),c=S((h=>_a(h))),m=c.mode==="compare_mode",{useFeatureGate:u}=Ce(),{isFeatureEnabled:p}=u(M.isReportsCustomDateRangeEnabled);return d.jsx(Ps,{firstMonthOfFY:e.firstMonthOfFY,tenantEmailDomain:a,location:t,isCompareModeOn:m,isCustomDateRangeEnabled:p,timeframe:c.timeframe,selectedCOABalancesRange:c.selectedCOABalancesRange,navigate:n,insightsSectionAiCfoInfo:i,isAiCfoAccessEnabled:r,onAskAiCfoClick:s,meetingUrl:qe(o("dashboard_report_filters"))})},z=(e,a,t,n)=>{e===!1?a!=null&&n("../../",{relative:"path"}):a!==t&&(a!=null&&a.length>0?n(`../${t}`,{replace:!0}):n(`./forecast/${t}`,{replace:!0}))},Rs=e=>{let a,t;switch(e.balanceTimeFrame){case"month":case"quarter":a=e.balanceTimeFrame,t=ot(e);break;case"year":a="quarter",t={startDate:e.endDate.startOf("quarter"),endDate:e.endDate};break;case"free_range":console.error("free_range timeframe is not supported!")}return{timeframe:a,timePeriod:t}},Bs=se((function(e){const a=ka(e),t=Qn(e),n=ya(e),o=Hn(e),r=Wn(e),s=Xn(e),i=vt(e),{scrollPosition:c,...m}=i,u=t.reportTitle,p=U.getSignedInUser(),h=e.tenantState.currentTenantId,l=L(e),f=l?.companyName??"",C={userId:p?.userId??"",sessionId:p?.zeniSessionId??"",tenantId:h??""},g=e.entityAutoCompleteState.autoCompleteText.navbar,k=he(e,"navbar"),E=Dt(l);return{selectedRangeReport:a,selectedClassesViewRangeReport:n,selectedProjectViewRangeReport:r,reportLabels:{reportTitle:u},highlightedRangeReport:t,highlightedClassesViewRangeReport:o,highlightedProjectViewRangeReport:s,uiState:m,scrollPosition:c,downloadParams:{downloadState:a.downloadState,currentTenantCompanyName:f,statementEndPoint:`${re}/statement`,authParams:C},analytics:O,isZeniUser:nt(p),autoCompleteData:{autoCompleteText:g,entityAutoCompleteView:k},isZeniCOAUsed:E,isAccountingClassesEnabled:Re(e),isAccountingProjectsEnabled:Fe(e)}}),(function(e,a){return{updateDownloadStateHandler:t=>{e(so(t))},onTimeframeSelectionChanged:t=>{e(Pe(t)),setTimeout((()=>e(le({resetLeftScroll:!0}))),50)},onCOABalancesRangeChanged:(t,n)=>{e(Ne(t,n)),e(le({resetLeftScroll:!0}))},onThisPeriodChanged:t=>{e(be(a.firstMonthOfFY,t)),e(le({resetLeftScroll:!0}))},onAdditionalBalanceSelectionChanged:(t,n,o)=>{e(Ve(a.firstMonthOfFY,t,o,n)),n.length>0&&(e(Ge(a.firstMonthOfFY,n.includes("this_period_vs_last_period")?"compare_mode_amount":"compare_mode_percent",o,n)),a.forecastIdFromUrlPath!=null&&t==1&&z(!1,a.forecastIdFromUrlPath,"",a.navigate)),a.isCompareModeOn!==t&&setTimeout((()=>e(le({resetLeftScroll:!0}))),50)},onAccountBalanceClick:(t,n)=>{const{timePeriod:o,timeframe:r}=Rs(n);if(o!=null&&r!=null){const s=t.accountName===""?t.accountDescription:t.accountName,i=t.projectsViewParentId?.projectId!=null?Yt(a.tenantEmailDomain,t.accountId,t.accountType,t.projectsViewParentId.projectId,s,r,o):t.classesViewParentId!=null&&t.classesViewParentId.parentClassId!=null?Lt(a.tenantEmailDomain,t.accountId,t.accountType,t.classesViewParentId.parentClassId?.[0],s,r,o):Be(a.tenantEmailDomain,t.accountId,t.accountType,s,r,o),c=R(a.location.state?.pathnameStackToGoBack,a.location.pathname);a.navigate(i,{state:{pathnameStackToGoBack:c,referrer:"Burn Rate"}})}},onElementCollapseStateChanged:(t,n)=>{a.accountViewMode!=="project"?e(le({nodeCollapseState:{nodeId:t,isCollapsed:n}})):e(Jt({nodeCollapseState:{nodeId:t,isCollapsed:n}}))},onTableScroll:t=>{a.accountViewMode!=="project"?e(le({scrollPosition:t})):e(Jt({scrollPosition:t}))},autoCompleteActions:{onAutoCompleteInputChange:t=>{t.trim().length>=2?e(ge({searchString:t,searchOrigin:"navbar"})):t.trim().length===0&&e(oe("navbar"))},onAutoCompleteEntity:t=>{const n=Se(t,a.tenantEmailDomain),o=R(a.location.state?.pathnameStackToGoBack,a.location.pathname);a.navigate(n,{state:{pathnameStackToGoBack:o}})}},onBackClick:()=>{a.selectedForecastId!=null?a.navigate("../../../"):a.navigate("../")},onForecastToggle:(t,n)=>{e(Te(a.firstMonthOfFY,t==="forecast_mode",t==="forecast_mode"?3:1,n)),t==="forecast_mode"?(e(Xt({viewMode:"account_group"})),e(Aa(!1,n?.id)),n!=null&&z(!0,a.forecastIdFromUrlPath,n?.id??"",a.navigate)):z(!1,a.forecastIdFromUrlPath,n?.id??"",a.navigate),e(le({resetLeftScroll:!0}))},onUpdateAccountViewMode:t=>{a.analytics?.trackGroupBySwitch(t==="classes"?"Classes":t==="project"?"Projects":"Accounts","Burn Rate"),e(Xt({viewMode:t})),e(oo({viewMode:t}))},onUpdateClassesToFilterOut:t=>{e(no({classesToFilterOut:t}))},onUpdateProjectsToFilterOut:t=>{e(ao({projectsToFilterOut:t}))},onOpenAccountViewMode:()=>{a.isAccountingClassesEnabled&&e(eo()),a.isAccountingProjectsEnabled&&e(to())},onResyncReports:()=>{e(Tt(a.accountViewMode==="project"?"net_burn_or_income_by_projects":"net_burn_or_income_by_classes"))},onCustomDateRangeChanged:(t,n,o)=>{e(Ot(!0,a.selectedForecastId||void 0,!0,t,n));const r=K(t),s=K(n),i=st(o??a.timeframe),c=Le(a.firstMonthOfFY,i,{startDate:r,endDate:s})??a.selectedCOABalancesRange.numberOfPeriods,{startOfTimeframeFY:m,endOfTimeframeFY:u}=Ue(s,a.firstMonthOfFY,i),p={numberOfPeriods:c,orderBy:a.selectedCOABalancesRange.orderBy,thisPeriod:{startDate:m,endDate:u}};e(Jn({selectedCOABalancesRange:p,highlightedCOABalancesRange:p,isCustomDateRange:!0,customStartDate:t,customEndDate:n})),e(le({resetLeftScroll:!0}))},onInitialDateRangeAvailable:()=>{}}}))(He),js=e=>{const a=Z(),{tenantEmailDomain:t,location:n,navigate:o,forecastIdFromUrlPath:r}=e,s=Ze(),{isAiCfoAccessEnabled:i,onAskAiCfoClick:c}=ie({mobileExploreReferrer:"DashboardNetBurnOrIncome"}),m=Qe({mobileExploreReferrer:"DashboardNetBurnOrIncome"}),u=S((y=>vt(y))),p=u.isForecastModeOn,h=u.timeframe,l=u.selectedForecast?.id,f=S((y=>wt(y.forecastState,l??""))),C=S((y=>ka(y))),g=S((y=>xt(y))),k=S((y=>Re(y))),E=S((y=>Fe(y))),A=S((y=>ya(y).uiState.accountViewMode)),_=u.mode==="compare_mode",{useFeatureGate:x}=Ce(),{isFeatureEnabled:V}=x(M.isReportsCustomDateRangeEnabled),v=C.dataAvailable;b.useEffect((()=>{if(l!=null&&p===!0&&(z(p,r,l,o),f!=null)){const y=f?.forecastPeriod,T=v!=null&&y.endDate.isAfter(v?.endDate)===!0?v:y;a(be(e.firstMonthOfFY,{startDate:T.endDate.startOf(h),endDate:T?.endDate}))}}),[l]);const D=$e(),w=Ut(D?.currentTenant?.companyId,{clearParams:C.fetchState==="Completed"});return d.jsx(Bs,{firstMonthOfFY:e.firstMonthOfFY,tenantEmailDomain:t,selectedForecastId:r,forecastIdFromUrlPath:r,location:n,isAccountingClassesEnabled:k,isAccountingProjectsEnabled:E,accountViewMode:A,isCompareModeOn:_,isCustomDateRangeEnabled:V,timeframe:u.timeframe,selectedCOABalancesRange:u.selectedCOABalancesRange,navigate:o,analytics:O,reportsResyncFetchState:g.reportsResyncFetchState,insightsSectionAiCfoInfo:m,isAiCfoAccessEnabled:i,onAskAiCfoClick:c,initialOpenThreadRequest:w,meetingUrl:qe(s("dashboard_report_filters"))})},Ms=e=>{let a,t;switch(e.balanceTimeFrame){case"month":case"quarter":a=e.balanceTimeFrame,t=ot(e);break;case"year":a="quarter",t={startDate:e.endDate.startOf("quarter"),endDate:e.endDate};break;case"free_range":console.error("free_range timeframe is not supported!")}return{timeframe:a,timePeriod:t}},Ys=se((function(e){const a=Ia(e),t=ro(e),n=Ea(e),o=io(e),r=co(e),s=lo(e),i=Pt(e),{scrollPosition:c,...m}=i,u=H.getLocalizedStrings().common.texts.operatingExpenses,p=U.getSignedInUser(),h=e.tenantState.currentTenantId,l=L(e),f=l?.companyName??"",C={userId:p?.userId??"",sessionId:p?.zeniSessionId??"",tenantId:h??""},g=e.entityAutoCompleteState.autoCompleteText.navbar,k=he(e,"navbar"),E=Dt(l);return{selectedRangeReport:a,selectedClassesViewRangeReport:n,selectedProjectViewRangeReport:r,reportLabels:{reportTitle:u},highlightedRangeReport:t,highlightedClassesViewRangeReport:o,highlightedProjectViewRangeReport:s,uiState:m,scrollPosition:c,downloadParams:{downloadState:a.downloadState,currentTenantCompanyName:f,statementEndPoint:`${re}/statement`,authParams:C},analytics:O,isZeniUser:nt(p),autoCompleteData:{autoCompleteText:g,entityAutoCompleteView:k},isZeniCOAUsed:E,isAccountingClassesEnabled:Re(e),isAccountingProjectsEnabled:Fe(e)}}),(function(e,a){return{updateDownloadStateHandler:t=>{e(bo(t))},onTimeframeSelectionChanged:t=>{e(Pe(t)),setTimeout((()=>e(de({resetLeftScroll:!0}))),50)},onCOABalancesRangeChanged:(t,n)=>{e(Ne(t,n)),e(de({resetLeftScroll:!0}))},onThisPeriodChanged:t=>{e(be(a.firstMonthOfFY,t)),e(de({resetLeftScroll:!0}))},onAdditionalBalanceSelectionChanged:(t,n,o)=>{e(Ve(a.firstMonthOfFY,t,o,n)),n.length>0&&(e(Ge(a.firstMonthOfFY,n.includes("this_period_vs_last_period")?"compare_mode_amount":"compare_mode_percent",o,n)),a.forecastIdFromUrlPath!=null&&t==1&&z(!1,a.forecastIdFromUrlPath,"",a.navigate)),a.isCompareModeOn!==t&&setTimeout((()=>e(de({resetLeftScroll:!0}))),50)},onAccountBalanceClick:a.hasTransactionAccess!==!0?void 0:(t,n)=>{const{timePeriod:o,timeframe:r}=Ms(n);if(o!=null&&r!=null){const s=t.accountName===""?t.accountDescription:t.accountName,i=t.projectsViewParentId?.projectId!=null?Yt(a.tenantEmailDomain,t.accountId,t.accountType,t.projectsViewParentId.projectId,s,r,o):t.classesViewParentId!=null&&t.classesViewParentId.parentClassId!=null?Lt(a.tenantEmailDomain,t.accountId,t.accountType,t.classesViewParentId.parentClassId?.[0],s,r,o):Be(a.tenantEmailDomain,t.accountId,t.accountType,s,r,o),c=R(a.location.state?.pathnameStackToGoBack,a.location.pathname);a.navigate(i,{state:{pathnameStackToGoBack:c,referrer:"Operating Expenses"}})}},onElementCollapseStateChanged:(t,n)=>{a.accountViewMode!=="project"?e(de({nodeCollapseState:{nodeId:t,isCollapsed:n}})):e(ta({nodeCollapseState:{nodeId:t,isCollapsed:n}}))},onTableScroll:t=>{a.accountViewMode!=="project"?e(de({scrollPosition:t})):e(ta({scrollPosition:t}))},autoCompleteActions:{onAutoCompleteInputChange:t=>{t.trim().length>=2?e(ge({searchString:t,searchOrigin:"navbar"})):t.trim().length===0&&e(oe("navbar"))},onAutoCompleteEntity:t=>{const n=Se(t,a.tenantEmailDomain),o=R(a.location.state?.pathnameStackToGoBack,a.location.pathname);a.navigate(n,{state:{pathnameStackToGoBack:o}})}},onBackClick:()=>{a.selectedForecastId!=null?a.navigate("../../../"):a.navigate("../")},onForecastToggle:(t,n)=>{e(Te(a.firstMonthOfFY,t==="forecast_mode",t==="forecast_mode"?3:1,n)),t=="forecast_mode"?(e(ea({viewMode:"account_group"})),e(va(!1,n?.id)),n!=null&&z(!0,a.forecastIdFromUrlPath,n?.id??"",a.navigate)):z(!1,a.forecastIdFromUrlPath,n?.id??"",a.navigate),e(de({resetLeftScroll:!0}))},onUpdateAccountViewMode:t=>{a.analytics?.trackGroupBySwitch(t==="classes"?"Classes":t==="project"?"Projects":"Accounts","Operating Expenses"),e(ea({viewMode:t})),e(go({viewMode:t}))},onUpdateClassesToFilterOut:t=>{e(ho({classesToFilterOut:t}))},onUpdateProjectsToFilterOut:t=>{e(fo({projectsToFilterOut:t}))},onOpenAccountViewMode:()=>{a.isAccountingClassesEnabled&&e(mo()),a.isAccountingProjectsEnabled&&e(po())},onResyncReports:()=>{e(Tt(a.accountViewMode==="project"?"operating_expenses_by_projects":"operating_expenses_by_classes"))},onCustomDateRangeChanged:(t,n,o)=>{e(Ft(!0,a.selectedForecastId||void 0,!0,t,n));const r=K(t),s=K(n),i=st(o??a.timeframe),c=Le(a.firstMonthOfFY,i,{startDate:r,endDate:s})??a.selectedCOABalancesRange.numberOfPeriods,{startOfTimeframeFY:m,endOfTimeframeFY:u}=Ue(s,a.firstMonthOfFY,i),p={numberOfPeriods:c,orderBy:a.selectedCOABalancesRange.orderBy,thisPeriod:{startDate:m,endDate:u}};e(uo({selectedCOABalancesRange:p,highlightedCOABalancesRange:p,isCustomDateRange:!0,customStartDate:t,customEndDate:n})),e(de({resetLeftScroll:!0}))},onInitialDateRangeAvailable:()=>{}}}))(He),Ls=e=>{const a=Z(),{tenantEmailDomain:t,location:n,navigate:o,forecastIdFromUrlPath:r}=e,s=Ze(),{isAiCfoAccessEnabled:i,onAskAiCfoClick:c}=ie({mobileExploreReferrer:"DashboardOpEx"}),m=Qe({mobileExploreReferrer:"DashboardOpEx"}),u=S((T=>Pt(T))),p=u.isForecastModeOn,h=u.timeframe,l=u.selectedForecast?.id,f=S((T=>wt(T.forecastState,l??""))),C=S((T=>Ia(T))),g=S((T=>xt(T))),k=S((T=>Re(T))),E=S((T=>Fe(T))),A=S((T=>Ea(T).uiState.accountViewMode)),_=u.mode==="compare_mode",{useFeatureGate:x}=Ce(),{isFeatureEnabled:V}=x(M.isReportsCustomDateRangeEnabled),v=C.dataAvailable;b.useEffect((()=>{if(l!=null&&p===!0&&(z(p,r,l,o),f!=null)){const T=f?.forecastPeriod,ce=v!=null&&T.endDate.isAfter(v?.endDate)===!0?v:T;a(be(e.firstMonthOfFY,{startDate:ce.endDate.startOf(h),endDate:ce?.endDate}))}}),[l]);const D=$e(),w=D?.loggedInUserRole!=null&&Da(D?.loggedInUserRole)!==!0,y=Ut(D?.currentTenant?.companyId,{clearParams:C.fetchState==="Completed"});return d.jsx(Ys,{firstMonthOfFY:e.firstMonthOfFY,tenantEmailDomain:t,selectedForecastId:r,location:n,isAccountingClassesEnabled:k,isAccountingProjectsEnabled:E,accountViewMode:A,isCompareModeOn:_,isCustomDateRangeEnabled:V,timeframe:u.timeframe,selectedCOABalancesRange:u.selectedCOABalancesRange,navigate:o,forecastIdFromUrlPath:r,analytics:O,hasTransactionAccess:w,reportsResyncFetchState:g.reportsResyncFetchState,insightsSectionAiCfoInfo:m,isAiCfoAccessEnabled:i,onAskAiCfoClick:c,initialOpenThreadRequest:y,meetingUrl:qe(s("dashboard_report_filters"))})},Us=e=>{let a,t;switch(e.balanceTimeFrame){case"month":case"quarter":a=e.balanceTimeFrame,t=ot(e);break;case"year":a="quarter",t={startDate:e.endDate.startOf("quarter"),endDate:e.endDate};break;case"free_range":console.error("free_range timeframe is not supported!")}return{timeframe:a,timePeriod:t}},Vs=se((function(e){const a=Oa(e),t=Co(e),n=Ta(e),o=So(e),r=_o(e),s=ko(e),i=Rt(e),{scrollPosition:c,...m}=i,u=H.getLocalizedStrings().common.texts.revenue,p=U.getSignedInUser(),h=e.tenantState.currentTenantId,l=L(e),f=l?.companyName??"",C={userId:p?.userId??"",sessionId:p?.zeniSessionId??"",tenantId:h??""},g=e.entityAutoCompleteState.autoCompleteText.navbar,k=he(e,"navbar"),E=Dt(l);return{selectedRangeReport:a,selectedClassesViewRangeReport:n,selectedProjectViewRangeReport:r,reportLabels:{reportTitle:u},highlightedRangeReport:t,highlightedClassesViewRangeReport:o,highlightedProjectViewRangeReport:s,uiState:m,scrollPosition:c,downloadParams:{downloadState:a.downloadState,currentTenantCompanyName:f,statementEndPoint:`${re}/statement`,authParams:C},analytics:O,isZeniUser:nt(p),autoCompleteData:{autoCompleteText:g,entityAutoCompleteView:k},isZeniCOAUsed:E,isAccountingClassesEnabled:Re(e),isAccountingProjectsEnabled:Fe(e)}}),(function(e,a){return{updateDownloadStateHandler:t=>{e(Oo(t))},onTimeframeSelectionChanged:t=>{e(Pe(t)),setTimeout((()=>e(ue({resetLeftScroll:!0}))),50)},onCOABalancesRangeChanged:(t,n)=>{e(Ne(t,n)),e(ue({resetLeftScroll:!0}))},onThisPeriodChanged:t=>{e(be(a.firstMonthOfFY,t)),e(ue({resetLeftScroll:!0}))},onAdditionalBalanceSelectionChanged:(t,n,o)=>{e(Ve(a.firstMonthOfFY,t,o,n)),n.length>0&&(e(Ge(a.firstMonthOfFY,n.includes("this_period_vs_last_period")?"compare_mode_amount":"compare_mode_percent",o,n)),a.forecastIdFromUrlPath!=null&&t==1&&z(!1,a.forecastIdFromUrlPath,"",a.navigate)),a.isCompareModeOn!==t&&setTimeout((()=>e(ue({resetLeftScroll:!0}))),50)},onAccountBalanceClick:(t,n)=>{const{timePeriod:o,timeframe:r}=Us(n);if(o!=null&&r!=null){const s=t.accountName===""?t.accountDescription:t.accountName,i=t.projectsViewParentId?.projectId!=null?Yt(a.tenantEmailDomain,t.accountId,t.accountType,t.projectsViewParentId.projectId,s,r,o):t.classesViewParentId!=null&&t.classesViewParentId.parentClassId!=null?Lt(a.tenantEmailDomain,t.accountId,t.accountType,t.classesViewParentId.parentClassId?.[0],s,r,o):Be(a.tenantEmailDomain,t.accountId,t.accountType,s,r,o),c=R(a.location.state?.pathnameStackToGoBack,a.location.pathname);a.navigate(i,{state:{pathnameStackToGoBack:c,referrer:"Revenues"}})}},onElementCollapseStateChanged:(t,n)=>{a.accountViewMode!=="project"?e(ue({nodeCollapseState:{nodeId:t,isCollapsed:n}})):e(na({nodeCollapseState:{nodeId:t,isCollapsed:n}}))},onTableScroll:t=>{a.accountViewMode!=="project"?e(ue({scrollPosition:t})):e(na({scrollPosition:t}))},autoCompleteActions:{onAutoCompleteInputChange:t=>{t.trim().length>=2?e(ge({searchString:t,searchOrigin:"navbar"})):t.trim().length===0&&e(oe("navbar"))},onAutoCompleteEntity:t=>{const n=Se(t,a.tenantEmailDomain),o=R(a.location.state?.pathnameStackToGoBack,a.location.pathname);a.navigate(n,{state:{pathnameStackToGoBack:o}})}},onBackClick:()=>{a.selectedForecastId!=null?a.navigate("../../../"):a.navigate("../")},onForecastToggle:(t,n)=>{e(Te(a.firstMonthOfFY,t==="forecast_mode",t==="forecast_mode"?3:1,n)),t==="forecast_mode"?(e(aa({viewMode:"account_group"})),e(wa(!1,n?.id)),n!=null&&z(!0,a.forecastIdFromUrlPath,n?.id??"",a.navigate)):z(!1,a.forecastIdFromUrlPath,n?.id??"",a.navigate),e(ue({resetLeftScroll:!0}))},onUpdateAccountViewMode:t=>{a.analytics?.trackGroupBySwitch(t==="classes"?"Classes":t==="project"?"Projects":"Accounts","Revenues"),e(aa({viewMode:t})),e(Do({viewMode:t}))},onUpdateClassesToFilterOut:t=>{e(vo({classesToFilterOut:t}))},onUpdateProjectsToFilterOut:t=>{e(Eo({projectsToFilterOut:t}))},onOpenAccountViewMode:()=>{a.isAccountingClassesEnabled&&e(Ao()),a.isAccountingProjectsEnabled&&e(Io())},onResyncReports:()=>{e(Tt(a.accountViewMode==="project"?"revenue_by_projects":"revenue_by_classes"))},onCustomDateRangeChanged:(t,n,o)=>{e(Bt(!0,a.selectedForecastId||void 0,!0,t,n));const r=K(t),s=K(n),i=st(o??a.timeframe),c=Le(a.firstMonthOfFY,i,{startDate:r,endDate:s})??a.selectedCOABalancesRange.numberOfPeriods,{startOfTimeframeFY:m,endOfTimeframeFY:u}=Ue(s,a.firstMonthOfFY,i),p={numberOfPeriods:c,orderBy:a.selectedCOABalancesRange.orderBy,thisPeriod:{startDate:m,endDate:u}};e(yo({selectedCOABalancesRange:p,highlightedCOABalancesRange:p,isCustomDateRange:!0,customStartDate:t,customEndDate:n})),e(ue({resetLeftScroll:!0}))},onInitialDateRangeAvailable:()=>{}}}))(He),Gs=e=>{const a=Z(),{tenantEmailDomain:t,location:n,navigate:o,forecastIdFromUrlPath:r}=e,s=Ze(),{isAiCfoAccessEnabled:i,onAskAiCfoClick:c}=ie({mobileExploreReferrer:"DashboardRevenue"}),m=Qe({mobileExploreReferrer:"DashboardRevenue"}),u=S((y=>Rt(y))),p=u.isForecastModeOn,h=u.timeframe,l=u.selectedForecast?.id,f=S((y=>wt(y.forecastState,l??""))),C=S((y=>Oa(y))),g=C.dataAvailable,k=u.mode==="compare_mode",{useFeatureGate:E}=Ce(),{isFeatureEnabled:A}=E(M.isReportsCustomDateRangeEnabled),_=S((y=>Re(y))),x=S((y=>Fe(y))),V=S((y=>Ta(y).uiState.accountViewMode)),v=S((y=>xt(y)));b.useEffect((()=>{if(l!=null&&p===!0&&(z(p,r,l,o),f!=null)){const y=f?.forecastPeriod,T=g!=null&&y.endDate.isAfter(g?.endDate)===!0?g:y;a(be(e.firstMonthOfFY,{startDate:T.endDate.startOf(h),endDate:T?.endDate}))}}),[l]);const D=$e(),w=Ut(D?.currentTenant?.companyId,{clearParams:C.fetchState==="Completed"});return d.jsx(Vs,{firstMonthOfFY:e.firstMonthOfFY,tenantEmailDomain:t,selectedForecastId:r,isAccountingClassesEnabled:_,isAccountingProjectsEnabled:x,accountViewMode:V,isCompareModeOn:k,isCustomDateRangeEnabled:A,timeframe:u.timeframe,selectedCOABalancesRange:u.selectedCOABalancesRange,location:n,navigate:o,forecastIdFromUrlPath:r,analytics:O,reportsResyncFetchState:v.reportsResyncFetchState,insightsSectionAiCfoInfo:m,isAiCfoAccessEnabled:i,onAskAiCfoClick:c,initialOpenThreadRequest:w,meetingUrl:qe(s("dashboard_report_filters"))})},Ns=e=>{let a,t;if(e.endDate!=null)switch(e.timePeriod){case"this_month_to_date":case"last_month":case"this_week_to_date":case"last_week":a="month",t={startDate:e.endDate.startOf("month"),endDate:e.endDate};break;case"last_3_months":case"last_6_months":case"last_12_months":case"this_year_to_date":case"last_year":a="quarter",t={startDate:e.endDate.startOf("quarter"),endDate:e.endDate};break;default:console.error(`this timeperiod ${e.timePeriod} is not supported!`)}return{timeframe:a,timePeriod:t}},qs=se((function(e){const a=To(e),t=e.entityAutoCompleteState.autoCompleteText.navbar,n=he(e,"navbar");return{report:a,analytics:O,autoCompleteData:{autoCompleteText:t,entityAutoCompleteView:n}}}),(function(e,a){return{onTimeframeSelectionChanged:t=>{O.trackTimeframeSwitch(qa(t),"Top Expenses"),e(xa(t))},onAccountBalanceClick:(t,n)=>{const{timePeriod:o,timeframe:r}=Ns(n),s=t.accountName===""?t.accountDescription:t.accountName;if(o!=null&&r!=null){const i=Be(a.tenantEmailDomain,t.accountId,t.accountType,s,r,o),c=R(a.location.state?.pathnameStackToGoBack,a.location.pathname);a.navigate(i,{state:{pathnameStackToGoBack:c,referrer:"Top Expenses"}})}},autoCompleteActions:{onAutoCompleteInputChange:t=>{t.trim().length>=2?e(ge({searchString:t,searchOrigin:"navbar"})):t.trim().length===0&&e(oe("navbar"))},onAutoCompleteEntity:t=>{const n=Se(t,a.tenantEmailDomain),o=R(a.location.state?.pathnameStackToGoBack,a.location.pathname);a.navigate(n,{state:{pathnameStackToGoBack:o}})}},onBackClick:()=>{a.navigate("../")}}}))(ts),zs=e=>{const{tenantEmailDomain:a,location:t,navigate:n}=e;return d.jsx(qs,{tenantEmailDomain:a,location:t,navigate:n})},Ks=Mt.div`
14
- display: flex;
15
- flex: 1 1 auto;
16
- min-height: 100%;
17
- flex-direction: column;
18
- background-color: ${e=>e.theme.colors.grey5};
19
- align-items: center;
20
- `;function Zs({fetchState:e,firstMonthOfFY:a,reportId:t,forecastId:n}){const o=ee(),r=J(),{tenantEmailDomain:s}=Q();let i;ze({isDataReady:!0});const c={firstMonthOfFY:a,tenantEmailDomain:s,location:r,navigate:o,forecastIdFromUrlPath:n,fetchState:e};switch(t){case"operating_expenses":i=d.jsx(Ls,{...c});break;case"revenue":i=d.jsx(Gs,{...c});break;case"net_burn_or_income":i=d.jsx(js,{...c});break;case"cash_position":i=d.jsx(Fs,{...c});break;case"top_expenses":i=d.jsx(zs,{...c});break;case"cash_in_cash_out":i=d.jsx(ws,{...c});break;default:console.error(`${t} is not supported!`),i=null}return i!=null?d.jsx(Ks,{children:i}):null}function pe(){const e=J(),a=Z(),{forecastId:t}=Q();let n="Not-Started";const o=S((l=>Pt(l).fetchState)),r=S((l=>Rt(l).fetchState)),s=S((l=>vt(l).fetchState)),i=S((l=>l.cashPositionState.fetchState)),c=S((l=>l.topExState.fetchState)),m=S((l=>l.cashInCashOutState.fetchState));if(U.getSignedInUser()==null)throw Error("Can't access dashboard detail without signing in...");const u=S((l=>L(l))),p=u?.company?.companyInfo?.firstMonthOfFY??1,h=fa((l=>{const f=ha(l,"/").split("/");return t!=null?f[f.length-3]:f[f.length-1]})(e.pathname));switch(h){case"operating_expenses":n=o;break;case"revenue":n=r;break;case"net_burn_or_income":n=s;break;case"cash_position":n=i;break;case"top_expenses":n=c;break;case"cash_in_cash_out":n=m;break;default:console.error(`${h} is not supported!`)}return b.useEffect((()=>{n==="Not-Started"&&(function(l,f,C,g){switch(f){case"operating_expenses":l(Ft(!0)),g!=null&&(l(Te(C,!0,3,{id:g,index:0})),l(va(!1,g)));break;case"revenue":l(Bt(!0)),g!=null&&(l(Te(C,!0,3,{id:g,index:0})),l(wa(!1,g)));break;case"net_burn_or_income":l(Ot(!0)),g!=null&&(l(Te(C,!0,3,{id:g,index:0})),l(Aa(!1,g)));break;case"cash_position":l(Et(!0));break;case"top_expenses":l(Pa());break;case"cash_in_cash_out":l(It());break;default:throw new Error(`report type ${f} is not yet supported`)}})(a,h,p,t)}),[t]),d.jsxs(d.Fragment,{children:[n==="Completed"?d.jsx(Ke,{analytics:O,onLoad:l=>((f,C)=>{const g=e.state?.referrer;switch(C){case"operating_expenses":f.trackPageLoaded(q.Event.operatingExpenses,g);break;case"revenue":f.trackPageLoaded(q.Event.revenues,g);break;case"net_burn_or_income":f.trackPageLoaded(q.Event.burnRate,g);break;case"cash_position":f.trackPageLoaded(q.Event.cashPosition,g);break;case"top_expenses":f.trackPageLoaded(q.Event.topExpenses,g);break;case"cash_in_cash_out":f.trackPageLoaded(q.Event.cashInCashOut,g);break;default:console.error(`Analytics: Not tracking Page Loaded for ${C}!`)}})(l,h)}):null,d.jsx(Zs,{firstMonthOfFY:p,fetchState:n,reportId:h,forecastId:t})]})}var mt=typeof navigator<"u"&&navigator.userAgent.toLowerCase().indexOf("firefox")>0;function pt(e,a,t,n){e.addEventListener?e.addEventListener(a,t,n):e.attachEvent&&e.attachEvent("on".concat(a),(function(){t(window.event)}))}function Za(e,a){for(var t=a.slice(0,a.length-1),n=0;n<t.length;n++)t[n]=e[t[n].toLowerCase()];return t}function $a(e){typeof e!="string"&&(e="");for(var a=(e=e.replace(/\s/g,"")).split(","),t=a.lastIndexOf("");t>=0;)a[t-1]+=",",a.splice(t,1),t=a.lastIndexOf("");return a}for(var Vt={backspace:8,tab:9,clear:12,enter:13,return:13,esc:27,escape:27,space:32,left:37,up:38,right:39,down:40,del:46,delete:46,ins:45,insert:45,home:36,end:35,pageup:33,pagedown:34,capslock:20,num_0:96,num_1:97,num_2:98,num_3:99,num_4:100,num_5:101,num_6:102,num_7:103,num_8:104,num_9:105,num_multiply:106,num_add:107,num_enter:108,num_subtract:109,num_decimal:110,num_divide:111,"⇪":20,",":188,".":190,"/":191,"`":192,"-":mt?173:189,"=":mt?61:187,";":mt?59:186,"'":222,"[":219,"]":221,"\\":220},fe={"⇧":16,shift:16,"⌥":18,alt:18,option:18,"⌃":17,ctrl:17,control:17,"⌘":91,cmd:91,command:91},At={16:"shiftKey",18:"altKey",17:"ctrlKey",91:"metaKey",shiftKey:16,ctrlKey:17,altKey:18,metaKey:91},Y={16:!1,18:!1,17:!1,91:!1},j={},tt=1;tt<20;tt++)Vt["f".concat(tt)]=111+tt;var P=[],ra=!1,Qa="all",ia=[],rt=function(e){return Vt[e.toLowerCase()]||fe[e.toLowerCase()]||e.toUpperCase().charCodeAt(0)};function ca(e){Qa=e||"all"}function Me(){return Qa||"all"}var ft=function(e){var a=e.key,t=e.scope,n=e.method,o=e.splitKey,r=o===void 0?"+":o;$a(a).forEach((function(s){var i=s.split(r),c=i.length,m=i[c-1],u=m==="*"?"*":rt(m);if(j[u]){t||(t=Me());var p=c>1?Za(fe,i):[];j[u]=j[u].filter((function(h){return!((!n||h.method===n)&&h.scope===t&&(function(l,f){for(var C=l.length>=f.length?l:f,g=l.length>=f.length?f:l,k=!0,E=0;E<C.length;E++)g.indexOf(C[E])===-1&&(k=!1);return k})(h.mods,p))}))}}))};function la(e,a,t,n){var o;if(a.element===n&&(a.scope===t||a.scope==="all")){for(var r in o=a.mods.length>0,Y)Object.prototype.hasOwnProperty.call(Y,r)&&(!Y[r]&&a.mods.indexOf(+r)>-1||Y[r]&&a.mods.indexOf(+r)===-1)&&(o=!1);(a.mods.length!==0||Y[16]||Y[18]||Y[17]||Y[91])&&!o&&a.shortcut!=="*"||a.method(e,a)===!1&&(e.preventDefault?e.preventDefault():e.returnValue=!1,e.stopPropagation&&e.stopPropagation(),e.cancelBubble&&(e.cancelBubble=!0))}}function da(e,a){var t=j["*"],n=e.keyCode||e.which||e.charCode;if(N.filter.call(this,e)){if(n!==93&&n!==224||(n=91),P.indexOf(n)===-1&&n!==229&&P.push(n),["ctrlKey","altKey","shiftKey","metaKey"].forEach((function(f){var C=At[f];e[f]&&P.indexOf(C)===-1?P.push(C):!e[f]&&P.indexOf(C)>-1?P.splice(P.indexOf(C),1):f==="metaKey"&&e[f]&&P.length===3&&(e.ctrlKey||e.shiftKey||e.altKey||(P=P.slice(P.indexOf(C))))})),n in Y){for(var o in Y[n]=!0,fe)fe[o]===n&&(N[o]=!0);if(!t)return}for(var r in Y)Object.prototype.hasOwnProperty.call(Y,r)&&(Y[r]=e[At[r]]);e.getModifierState&&(!e.altKey||e.ctrlKey)&&e.getModifierState("AltGraph")&&(P.indexOf(17)===-1&&P.push(17),P.indexOf(18)===-1&&P.push(18),Y[17]=!0,Y[18]=!0);var s=Me();if(t)for(var i=0;i<t.length;i++)t[i].scope===s&&(e.type==="keydown"&&t[i].keydown||e.type==="keyup"&&t[i].keyup)&&la(e,t[i],s,a);if(n in j){for(var c=0;c<j[n].length;c++)if((e.type==="keydown"&&j[n][c].keydown||e.type==="keyup"&&j[n][c].keyup)&&j[n][c].key){for(var m=j[n][c],u=m.splitKey,p=m.key.split(u),h=[],l=0;l<p.length;l++)h.push(rt(p[l]));h.sort().join("")===P.sort().join("")&&la(e,m,s,a)}}}}function N(e,a,t){P=[];var n=$a(e),o=[],r="all",s=document,i=0,c=!1,m=!0,u="+",p=!1;for(t===void 0&&typeof a=="function"&&(t=a),Object.prototype.toString.call(a)==="[object Object]"&&(a.scope&&(r=a.scope),a.element&&(s=a.element),a.keyup&&(c=a.keyup),a.keydown!==void 0&&(m=a.keydown),a.capture!==void 0&&(p=a.capture),typeof a.splitKey=="string"&&(u=a.splitKey)),typeof a=="string"&&(r=a);i<n.length;i++)o=[],(e=n[i].split(u)).length>1&&(o=Za(fe,e)),(e=(e=e[e.length-1])==="*"?"*":rt(e))in j||(j[e]=[]),j[e].push({keyup:c,keydown:m,scope:r,mods:o,shortcut:n[i],method:t,key:n[i],splitKey:u,element:s});s!==void 0&&!(function(h){return ia.indexOf(h)>-1})(s)&&window&&(ia.push(s),pt(s,"keydown",(function(h){da(h,s)}),p),ra||(ra=!0,pt(window,"focus",(function(){P=[]}),p)),pt(s,"keyup",(function(h){da(h,s),(function(l){var f=l.keyCode||l.which||l.charCode,C=P.indexOf(f);if(C>=0&&P.splice(C,1),l.key&&l.key.toLowerCase()==="meta"&&P.splice(0,P.length),f!==93&&f!==224||(f=91),f in Y)for(var g in Y[f]=!1,fe)fe[g]===f&&(N[g]=!1)})(h)}),p))}var ht={setScope:ca,getScope:Me,deleteScope:function(e,a){var t,n;for(var o in e||(e=Me()),j)if(Object.prototype.hasOwnProperty.call(j,o))for(t=j[o],n=0;n<t.length;)t[n].scope===e?t.splice(n,1):n++;Me()===e&&ca(a||"all")},getPressedKeyCodes:function(){return P.slice(0)},isPressed:function(e){return typeof e=="string"&&(e=rt(e)),P.indexOf(e)!==-1},filter:function(e){var a=e.target||e.srcElement,t=a.tagName,n=!0;return!a.isContentEditable&&(t!=="INPUT"&&t!=="TEXTAREA"&&t!=="SELECT"||a.readOnly)||(n=!1),n},trigger:function(e){var a=arguments.length>1&&arguments[1]!==void 0?arguments[1]:"all";Object.keys(j).forEach((function(t){var n=j[t].find((function(o){return o.scope===a&&o.shortcut===e}));n&&n.method&&n.method()}))},unbind:function(e){if(e===void 0)Object.keys(j).forEach((function(s){return delete j[s]}));else if(Array.isArray(e))e.forEach((function(s){s.key&&ft(s)}));else if(typeof e=="object")e.key&&ft(e);else if(typeof e=="string"){for(var a=arguments.length,t=new Array(a>1?a-1:0),n=1;n<a;n++)t[n-1]=arguments[n];var o=t[0],r=t[1];typeof o=="function"&&(r=o,o=""),ft({key:e,scope:o,method:r,splitKey:"+"})}},keyMap:Vt,modifier:fe,modifierMap:At};for(var gt in ht)Object.prototype.hasOwnProperty.call(ht,gt)&&(N[gt]=ht[gt]);if(typeof window<"u"){var $s=window.hotkeys;N.noConflict=function(e){return e&&window.hotkeys===N&&(window.hotkeys=$s),N},window.hotkeys=N}N.filter=function(){return!0};var ua=function(e,a){var t=e.target,n=t&&t.tagName;return!!(n&&a&&a.includes(n))};function Qs(e,a,t,n){t instanceof Array&&(n=t,t=void 0);var o=t||{},r=o.enableOnTags,s=o.filter,i=o.keyup,c=o.keydown,m=o.filterPreventDefault,u=m===void 0||m,p=o.enabled,h=p===void 0||p,l=o.enableOnContentEditable,f=l!==void 0&&l,C=b.useRef(null),g=b.useCallback((function(k,E){var A,_;return s&&!s(k)?!u:!!(ua(k,["INPUT","TEXTAREA","SELECT"])&&!ua(k,r)||(A=k.target)!=null&&A.isContentEditable&&!f)||!!(C.current===null||document.activeElement===C.current||(_=C.current)!=null&&_.contains(document.activeElement))&&(a(k,E),!0)}),n?[C,r,s].concat(n):[C,r,s]);return b.useEffect((function(){if(h)return i&&c!==!0&&(t.keydown=!1),N(e,t||{},g),function(){return N.unbind(e,g)};N.unbind(e,g)}),[g,e,h]),C}N.isPressed;const Hs=[],bt="dashboard_card",ne="ai_cfo_dashboard_card";function ma(e,a){return a?e.some((t=>String(t)===ne))?e.slice():[ne,...e]:e.filter((t=>String(t)!==ne))}const Ws=["net_burn_or_income_story_card","cash_balance","task_card","card_balance","zeni_promo_card","insights_dashboard","information_card","company_details","bill_pay_promo_card","bill_pay_card","reimbursement_card","reimbursement_promo_card","rewards_card"],Xs=(e,a,t,n,o)=>({card:{dimension:jt(t),cardType:n,cardIndex:o,fetchState:a,disableAnimations:!1,spansFullDashboardWidth:!1},data:e.status!=null?{balanceAmount:e.balance?.available,lastUpdatedTime:e.status.lastRefreshSuccessTime,changePercent:e.balance?.change?.percent,changeComparedToDate:e.balance?.change?.since}:void 0}),je=(e,a,t,n,o)=>({card:{dimension:jt(t),cardType:n,cardIndex:o,fetchState:a,disableAnimations:!1,spansFullDashboardWidth:!1},data:e}),Js=(e,a,t,n)=>je(void 0,e,we,a,t),er=e=>{const a=jt(we);return a.height=we.height+10,{card:{dimension:a,cardType:ne,cardIndex:e,fetchState:"Completed",disableAnimations:!1,spansFullDashboardWidth:!0}}},tr=se((function(e,a){const t=or(a.dashboardReport),n=a.passedCardsOrdered,o=a.dashboardReport.reportsInOrder,{isInterestedInChargeCard:r,cardsCreditLimit:s,cashbackRate:i}=a;let c=n.map(((m,u)=>{if(m==="reimbursement_promo_card"||m==="bill_pay_promo_card")return Js(t,m,u);if(m==="zeni_promo_card")return je({isExpressedInterest:r,creditLimit:s,cashbackRate:i,fetchState:"Completed"},a.cardBalanceFetchState,we,m,u);if(m==="information_card")return je(void 0,"Completed",we,m,u);if(m===ne)return er(u);{const p=o.find((h=>h?.reportId===m));return p?(function(h,l,f,C){const g=h.reportId;switch(g){case"card_balance":case"cash_balance":return[Xs(h,l,f,g,C)];case"expense_automation_card":case"operating_expenses":case"revenue":case"top_expenses":case"cash_position":case"cash_in_cash_out":case"insights_dashboard":case"company_details":case"task_card":case"bill_pay_card":case"reimbursement_card":case"net_burn_or_income":case"accounts_payable_aging":case"accounts_receivable_aging":case"rewards_card":return[je(h,l,f,g,C)];case"net_burn_or_income_story_card":return[je(h,l,f,"net_burn_or_income_story_card",C)];default:return console.error(`card type ${g} not yet supported!`),[]}})(p,p.fetchState,we,u):[]}})).flat();return a.isSummaryCardsFiltered===!0&&(c=c.filter((m=>Ws.includes(m.card.cardType)==0)).filter((m=>{const u=m.data?.availableNumberOfPeriods;return u!=null?u>0:m.card.cardType!="top_expenses"||m.data==null||(function(p){if(p==null||p.length===0)return!0;let h=!0;for(const l of p)if(l.balance.available.amount!==0){h=!1;break}return h})(m.data.topExpenses.accountsOrdered)===!1}))),{cardDataArray:c,autoCompleteData:{autoCompleteText:e.entityAutoCompleteState.autoCompleteText.navbar,entityAutoCompleteView:he(e,"navbar")},analytics:O,isReimbursementEnabled:a.isReimbursementEnabled,isBillPayEnabled:a.isBillPayEnabled}}),(function(e,a){const t=a.tenantId,n=U.getSignedInUser();return{cardActions:{onCardClick:(o,r,s,i)=>{if(console.warn(`onCardClick at ${o} for the type ${r}`),r==="zeni_promo_card"&&i!=null)O.trackDashboardCardClicked("cards promo",2),O.trackZeniCardsPromoCardClicked(a.isChargeCardFeatureEnabled,i,2,`${n?.firstName??""} ${n?.lastName??""}`,a.isChargeCardFeatureEnabled?a.cardsCreditLimit:void 0),i==="Learn More"?window.open("https://www.zeni.ai/product/business-credit-card","_blank"):a.navigate("../cards/promo",{relative:"path"});else if(a.isForecastOn)switch(r){case"net_burn_or_income":case"operating_expenses":case"revenue":a.navigate(`${r}/forecast/${a.selectedForecastOnDashboard}`,{state:{referrer:s}});break;default:a.navigate(`${r}`,{state:{referrer:s}})}else r==="rewards_card"?(n!=null&&O.trackDashboardCardClicked("rewards promo",o+1),a.navigate("../../rewards/refer",{state:{referrer:s}})):r==="expense_automation_card"?(O.trackMonthEndCloseClicked(a.selectedPeriod.month,a.selectedPeriod.year,"Dashboard"),a.navigate("../../month_end_close_checks/review",{state:{referrer:"Dashboard"}})):a.navigate(`${r}`,{state:{referrer:s}})},onReloadData:(o,r)=>{const s=[];a.isApAgingFeatureEnabled===!1&&s.push("accounts_payable_aging"),a.isArAgingFeatureEnabled===!1&&s.push("accounts_receivable_aging"),a.isRewardsFeatureEnabled===!1&&s.push("rewards_card"),(function(i,c,m,u){if(c!==ne)switch(c){case"card_balance":i(ba());break;case"cash_balance":i(ga());break;case"operating_expenses":i(Ft(!0));break;case"revenue":i(Bt(!0));break;case"net_burn_or_income":i(Ot(!0));break;case"net_burn_or_income_story_card":i(qo(!0));break;case"cash_position":i(Et(!0));break;case"top_expenses":i(Pa());break;case"cash_in_cash_out":i(It());break;case"insights_dashboard":i(No());break;case"bill_pay_card":i(Go());break;case"reimbursement_card":i(Vo());break;case"company_details":i(Uo(m));break;case"task_card":i(Lo());break;case"accounts_payable_aging":u.includes("accounts_payable_aging")===!1&&i(_t(xe()));break;case"accounts_receivable_aging":i(kt(xe()));break;case"rewards_card":u.includes("rewards_card")===!1&&i(Yo(!0));break;default:throw new Error(`report type ${c} is not yet supported`)}})(e,r,a.companyId,s)},onTimeframeChange:(o,r)=>{O.trackTimeframeSwitch(qa(r),nr(o),"Dashboard"),(function(s,i,c){switch(i){case"operating_expenses":case"revenue":case"net_burn_or_income":case"cash_position":s(Pe(c));break;case"top_expenses":s(xa(c));break;default:throw new Error(`report type ${i} doesn't support changeTimeframe`)}})(e,o,r)},onUpdateSelectedInsightIndex:o=>{e(Mo(o))},onCategoryClick:(o,r,s)=>{o==="bill-pay"?a.navigate("../bills",{state:{tab:r,subTab:s},relative:"path"}):o==="reimbursement"?a.navigate("../reimbursements",{state:{tab:r,subTab:s},relative:"path"}):o==="uncategorized-account-mapping"?a.navigate("../settings/accounting",{relative:"path"}):o==="show-all-tasks"?a.navigate("../tasks",{relative:"path"}):a.navigate(`../../transactions/${o}`)},onCardBtnClick:o=>{if(o==="bill_pay_promo_card"){const r="../bills",s=R(a.location.state?.pathnameStackToGoBack,a.location.pathname);a.navigate(r,{state:{pathnameStackToGoBack:s},relative:"path"})}else if(o==="reimbursement_promo_card"){const r="../reimbursements",s=R(a.location.state?.pathnameStackToGoBack,a.location.pathname);a.navigate(r,{state:{pathnameStackToGoBack:s},relative:"path"})}},onSaveClick:(o,r,s)=>{o==="net_burn_or_income_story_card"&&(O.trackUpdateBurnRateCalculatorSettings(r,s,Bo(s)),e(jo(t,r,s)))}},autoCompleteActions:{onAutoCompleteInputChange:o=>{o.trim().length>=2?e(ge({searchString:o,searchOrigin:"navbar"})):o.trim().length===0&&e(oe("navbar"))},onCancelAutoComplete:()=>{e(oe("navbar"))},onAutoCompleteEntity:o=>{let r="";r=o.type!=="vendor"||o.detailType!=="bank_merchant"&&o.detailType!=="card_merchant"?Se(o,a.tenantEmailDomain):ms(o.zeniId,o.qboId,a.tenantEmailDomain);const s=R(a.location.state?.pathnameStackToGoBack,a.location.pathname);a.navigate(r,{state:{pathnameStackToGoBack:s,referrer:"Search"}})}}}}))(ds);function ar(){const e=pa(),a=ja(),t=Va(a),{isAiCfoOpen:n,setIsAiCfoOpen:o,setAiCfoSidePanelQuestionToSubmit:r}=Ba(),s=ee(),i=Z(),c=J(),m=U.getSignedInUser(),{useFeatureGate:u,useDynamicConfig:p}=Ce(),[h,l]=b.useState(!1),[f,C]=b.useState(!1),g=Ma(),{tenantEmailDomain:k}=Q(),{isAiCfoAccessEnabled:E,onAskAiCfoClick:A}=ie({mobileExploreReferrer:"Dashboard"}),_=S((I=>I.tenantState.fetchState==="Completed"||I.tenantState.activeTenantFetchState.fetchState==="Completed"?L(I):void 0)),x=_??U.getSignedInUserTenant(k),{isCardsShuttingDown:V,shutdownContent:v}=as(x?.tenantId,_?.company?.managementInfo?.receiverEmails),D=b.useMemo((()=>V===!0&&v!=null?d.jsx(ns,{shutdownContent:v}):null),[V,v]),w=_?.masterTOSInfo?.isMasterTOSAccepted??!1,y=x.tenantId,T=x.companyId;b.useEffect((()=>{h===!1&&c.state?.message==="activation"&&(i(wo(T)),l(!0))}),[c.state,h,T,i]),b.useEffect((()=>{g&&!f&&c.state?.message==="open_ai_cfo_drawer"&&(C(!0),w?(o(!0),s({pathname:c.pathname,search:c.search,hash:c.hash},{replace:!0,state:{...c.state,message:void 0}})):me({location:c,navigate:s,mergeState:{referrer:"Dashboard",message:void 0}}))}),[c,f,g,w,o,s]);const{isFeatureEnabled:ce}=u(M.isApAgingFeatureEnabled),ye=os(),B=ss(ye),{isFeatureEnabled:te}=u(M.isArAgingFeatureEnabled),{isFeatureEnabled:We}=u(M.isDepositAccountsFeatureEnabled),{isFeatureEnabled:Xe}=u(M.isReferralFeatureEnabled),{isFeatureEnabled:Ha}=u(M.isChargeCardFeatureEnabled),{isFeatureEnabled:Wa}=u(M.isAiCfoFileUploadEnabled),{isFeatureEnabled:Xa}=u(M.isDashboardSidebarChristmasAnimationEnabled),{isFeatureEnabled:Ja}=u(M.isDashboardSidebarNewYearAnimationEnabled),{isFeatureEnabled:en}=u(M.aiAuditScorePercentage),{configValue:Gt}=p(Ya.zeniCardsConfig),tn=Gt.charge_card_cashback_rate_per_transaction==null?.0175:Gt.charge_card_cashback_rate_per_transaction;if(c.state?.message==="activation"){const I=rs(c.state?.pathnameStackToGoBack);s(c.pathname,{state:{...c.state,message:void 0,pathnameStackToGoBack:I.newStack}})}const[Nt,an]=b.useState(!1),[it,nn]=b.useState(!1);Qs("command+p, Control+p",(I=>{nn(!it),I.preventDefault()}),{enableOnContentEditable:!0,enableOnTags:["INPUT","SELECT","TEXTAREA"]},[it]);const qt=_?.externalConnections?.accounting[0]?.isValid;if(m==null)throw Error("Can't access dashboard without signing in...");const _e=S((I=>L(I)?.excludedResources)),on=S((I=>I.expenseAutomationViewState.selectedPeriodByTenantId)),sn=!!_?.companyReimbursementInfo?.info?.isReimbursementEnabled,rn=!!_?.companyBillPayInfo?.info?.isBillPayEnabled,cn=$e(),$=[],zt=_e?.resources?.find((I=>I.resource==="/reports/top_expenses"))==null,ln=_e?.resources?.find((I=>I.resource==="/reports/task_card"))==null,Kt=_?.userRole!=null&&Da(_?.userRole),dn=_e?.resources?.find((I=>I.resource==="/bills"))==null&&!Kt,un=_e?.resources?.find((I=>I.resource==="/reimbursements"))==null,mn=xo(cn?.loggedInUserRoleMap),pn=_?.company?.companyChargeCardInfo?.chargeCardsCreditAccountLimit??0,fn=_?.companyChargeCardInfo?.info?.isCompanyInterestedInChargeCard??!1;zt===!1&&$.push("top_expenses"),ln===!1&&$.push("task_card"),dn===!1&&$.push("bill_pay_card","bill_pay_promo_card"),ce===!1&&$.push("accounts_payable_aging"),te===!1&&$.push("accounts_receivable_aging"),(ye===!1||Kt)&&$.push("expense_automation_card"),un===!1&&$.push("reimbursement_card","reimbursement_promo_card"),$.push("zeni_accounts_promo_card","treasury_promo_card"),Xe===!1&&$.push("rewards_card");const{areTenantIdsInSync:Zt}=is();b.useLayoutEffect((()=>{Nt&&B===ye||qt!==!0||!Zt||_e?.fetchState!=="Completed"&&_e?.fetchState!=="Error"||(an(!0),i(Po(m.userId,T,y,!0,!1,$)))}),[Nt,m,y,i,zt,qt,_e?.fetchState,Zt]);const hn=S((I=>I.reportUIOptionsState.forecastOnDashboard.isForecastModeOn)),gn=S((I=>I.revenueState.uiState.selectedForecast?.id)),bn=S((I=>I.cardBalanceState.fetchState)),ke=S((I=>Fo(I,$))),Cn=ke.fetchState,Sn=b.useMemo((()=>ma(ke.cardsOrdered,E)),[ke.cardsOrdered,E]),_n=b.useMemo((()=>ma(ke.cardsForDashboardUI,E)),[ke.cardsForDashboardUI,E]);ze({isDataReady:!0});const{isSuggestedQuestionsLoading:kn,suggestedPromptQuestions:yn}=fs(),$t=S((I=>Ca(I))),Ae=$t.uiState?.currentChatSessionId,ct=$t.allSessionsWithOrderedQuestionAnswers??Hs,{currentSessionQuestionAnswers:An}=cs(ct,Ae),Qt=An.length===0,In=b.useCallback(((I,W,ae)=>{const Ie=m?.userId;if(Ie==null)return;const G=I.trim();if(G.length===0&&W.length===0)return;if(!w)return void me({location:c,navigate:s,mergeState:{referrer:"Dashboard",...G.length>0?{aiCfoInitialQuestion:G,aiCfoInitialSubmissionSource:bt,...typeof ae=="number"?{aiCfoSuggestionIndex:ae}:{}}:{}}});const X=La(e.getState()),Ee=()=>{const ve=R(c.state?.pathnameStackToGoBack,c.pathname);s(`/${k}/ai-cfo/explore`,{state:{message:"",origin:"",pathnameStackToGoBack:ve,referrer:"Dashboard",aiCfoInitialQuestion:G,aiCfoShouldSubmit:!X&&G.length>0,aiCfoInitialSubmissionSource:bt,...typeof ae=="number"?{aiCfoSuggestionIndex:ae}:{}}})};return t?W.length>0?void o(!0):void Ee():W.length>0?X?(i(yt(G)),void o(!0)):(r(G.length>0?G:null),o(!0),void(G.length>0&&Ua(i,G,bt,Ae,ct,Ie,ae,W.length>0?W:void 0))):(X&&i(yt(G)),void Ee())}),[ct,Ae,i,w,t,c,s,r,o,m?.userId,e,k]),En=b.useCallback((()=>{w?o(!0):me({location:c,navigate:s,mergeState:{referrer:"Dashboard"}})}),[w,c,s,o]),vn=b.useCallback((()=>{if(!w)return void me({location:c,navigate:s,mergeState:{referrer:"Dashboard"}});if(k==null)return;const I=R(c.state?.pathnameStackToGoBack,c.pathname);s(`/${k}/ai-cfo/explore`,{state:{pathnameStackToGoBack:I,referrer:"Dashboard"}})}),[w,c,s,k]),Dn=b.useCallback((()=>{if(w)if(t){if(k==null||_==null)return;const I=Ae==null||Qt?`/${k}/ai-cfo/explore`:`/${k}/ai-cfo/${Ae}`,W=c.state?.pathnameStackToGoBack??[],ae=R(W,c.pathname);s(I,{state:{...c.state,pathnameStackToGoBack:ae,[ls]:!0}})}else me({location:c,navigate:s,mergeState:{referrer:"Dashboard"}});else me({location:c,navigate:s,mergeState:{referrer:"Dashboard"}})}),[w,t,c,s,k,_,Ae,Qt]);return d.jsxs(d.Fragment,{children:[Cn==="Completed"?d.jsx(Ke,{analytics:O,onLoad:I=>{I.trackPageLoaded(q.Event.dashboard)}}):null,d.jsx(tr,{cardsShutdownBanner:D,maxColumns:n?2:void 0,isAiCfoAccessEnabled:E,onAskAiCfoClick:A,onAiCfoDashboardOpenPanel:En,onAiCfoDashboardOpenScopePage:Dn,isAiCfoFileUploadEnabled:Wa===!0&&t===!1,onAiCfoDashboardPromptSubmit:In,onAiCfoDashboardExpandToFullPage:vn,aiCfoDashboardShouldClearPromptOnSubmit:w,aiCfoDashboardSuggestedPromptQuestions:yn,aiCfoDashboardSuggestedPromptQuestionsLoading:kn,onDragAndDropCard:(I,W)=>{if(I===ne||W===ne)return;const ae=(function(X,Ee,ve){const lt=ve.indexOf(X),dt=ve.indexOf(Ee);if(lt===-1||dt===-1||lt===dt)return ve;const ut=[...ve];return ut.splice(lt,1),ut.splice(dt,0,X),ut})(I,W,Sn),Ie=ae.filter((X=>X!==ne)),G=ke.cardsOrdered;(Ie.length!==G.length||Ie.some(((X,Ee)=>X!==G[Ee])))&&i(Ro(Ie))},dashboardReport:ke,passedCardsOrdered:_n,tenantId:y,companyId:T,tenantEmailDomain:k,location:c,navigate:s,isApAgingFeatureEnabled:ce,isArAgingFeatureEnabled:te,isBillPayEnabled:rn,isReimbursementEnabled:sn,isSummaryCardsFiltered:it,isForecastOn:hn,selectedForecastOnDashboard:gn,isVisitingFirstTime:h,isZeniAccountEnabled:We,isRewardsFeatureEnabled:Xe,selectedPeriod:on[y],isChargeCardFeatureEnabled:Ha,isUserHasCardsAccess:mn,cardsCreditLimit:pn,cashbackRate:tn,isInterestedInChargeCard:fn,cardBalanceFetchState:bn,christmasAnimationEnabled:Xa,newYearAnimationEnabled:Ja,aiAuditScorePercentageEnabled:en})]})}const nr=e=>{switch(e){case"operating_expenses":return"Operating Expenses";case"revenue":return"Revenues";case"top_expenses":return"Top Expenses";case"net_burn_or_income":return"Burn Rate";case"cash_in_cash_out":return"Cash In, Cash Out";case"cash_position":return"Cash Position"}return"Dashboard"},or=e=>e.fetchState!=="Error"?e.fetchState:e.reportsInOrder.map((a=>a.fetchState)).reduce(((a,t)=>a==="In-Progress"||a==="Not-Started"?a:t));function Ct(){return d.jsxs(St,{children:[d.jsx(F,{path:"/",element:d.jsx(pe,{})}),d.jsx(F,{path:"/:forecastId",element:d.jsx(pe,{})}),d.jsx(F,{path:"/:forecastId/*",element:d.jsx(Ye,{})})]})}function Mr(){const e=$e(),a=e?.excludedResources?.find((m=>m.resource==="/reports/top_expenses"))==null,{useFeatureGate:t}=Ce(),{isFeatureEnabled:n}=t(M.isApAgingFeatureEnabled),{isFeatureEnabled:o}=t(M.isArAgingFeatureEnabled),r=S((m=>L(m))),{isFeatureEnabled:s}=t(M.isDebitCardFeatureEnabled),i=zo(s,r),c=Ko(r);return i===!0||c===!0?d.jsx(St,{children:d.jsx(F,{path:"/*",element:d.jsx(hs,{})})}):d.jsxs(St,{children:[d.jsx(F,{path:"/",element:d.jsx(ar,{})}),d.jsx(F,{path:"cash_balance/*",element:d.jsx(oa,{})}),d.jsx(F,{path:"card_balance/*",element:d.jsx(oa,{})}),d.jsx(F,{path:"operating_expenses/*",element:d.jsx(pe,{})}),d.jsx(F,{path:"operating_expenses/forecast/*",element:d.jsx(Ct,{})}),d.jsx(F,{path:"revenue/forecast/*",element:d.jsx(Ct,{})}),d.jsx(F,{path:"revenue/*",element:d.jsx(pe,{})}),d.jsx(F,{path:"net_burn_or_income/forecast/*",element:d.jsx(Ct,{})}),d.jsx(F,{path:"net_burn_or_income/*",element:d.jsx(pe,{})}),n===!0&&d.jsxs(d.Fragment,{children:[d.jsx(F,{path:"accounts_payable_aging/*",element:d.jsx(bs,{})}),d.jsx(F,{path:"accounts_payable_aging/:vendorId/:reportDate/*",element:d.jsx(gs,{})})]}),o&&d.jsxs(d.Fragment,{children:[d.jsx(F,{path:"accounts_receivable_aging/:customerId/:reportDate/*",element:d.jsx(Cs,{})}),d.jsx(F,{path:"accounts_receivable_aging/*",element:d.jsx(Ss,{})})]}),d.jsx(F,{path:"cash_position/*",element:d.jsx(pe,{})}),d.jsx(F,{path:"top_expenses/*",element:a===!0?d.jsx(pe,{}):d.jsx(Ye,{})}),d.jsx(F,{path:"cash_in_cash_out/*",element:d.jsx(pe,{})}),d.jsx(F,{path:"company_details",element:d.jsx(ps,{})}),d.jsx(F,{path:"referrals/*",element:d.jsx(On,{to:"../../rewards/refer",replace:!0})}),d.jsx(F,{path:"*",element:d.jsx(Ye,{})})]})}export{Mr as default};
@@ -1,18 +0,0 @@
1
- import{j as l}from"./liveblocks-Vz4gvIdI.js";import{h as w,g as C,j as h,l as A,i as V}from"./core-GrVUbJGD.js";import{ZW as k,_1 as W,gJ as X,gI as J,gH as Q,kT as q,XH as K,uZ as L,fI as B,Zt as D,kR as T,ZX as S,_4 as F,kP as G,la as j}from"./zeni-epic-state-COBHVss0.js";import{bO as M,_ as R,p as N,z as Z,a2 as p,N as v,a5 as _,bP as Y,F as U,bQ as ee,l as te}from"./index-eXyO65Ih.js";import{u as H,n as O}from"./mui-CuMgG_27.js";import"./sentry-Y8vuE8aQ.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="f426f1ed-a293-405b-a0d5-ef3622153fed",e._sentryDebugIdIdentifier="sentry-dbid-f426f1ed-a293-405b-a0d5-ef3622153fed")}catch{}})();const ae=A(null,(function(e,t){return{onSaveVendor:a=>{e(q(t.vendorId!==void 0?t.vendorId:void 0,t.billId,void 0,t.isExpressPayPage)),e(K("common")),a!=null&&e(L(a))},onGetOtp:a=>{e(Q(a,"BillPayVendor"))},onResendOtp:a=>{e(J(a,"BillPayVendor"))},onVerifyOtp:(a,n)=>{e(X(a,n,"BillPayVendor"))},onVerifyOtpSuccess:(a,n,o)=>{e(W(a,n,o))}}}))(M);function z({vendorId:e,billId:t,isExpressPayPage:a}){const n=w(),o=C(),s=h((r=>k(r,e)));return l.jsx(ae,{location:o,navigate:n,vendorId:e,billId:t,vendorViewDetails:s,isExpressPayPage:a??!1})}const ne=O.div`
2
- display: flex;
3
- height: 100vh;
4
- width: 100%;
5
- flex: 1 1 auto;
6
- flex-direction: column;
7
- align-items: center;
8
- background-color: ${e=>e.theme.colors.grey4};
9
- `,oe=A((function(e,t){const{vendorId:a,billId:n}=t,o=k(e,a),s=D(e,t.isVendorRecommendationEnabled,t.isZeniAccountsFeatureEnabled,n);return{billId:n,isDisabled:o.bankAccountCreationState.fetchState==="In-Progress"?"readonly":void 0,vendorViewDetails:o,file:s.file,bankAccountContext:t.bankAccountContext}}),(function(e,t){const{navigate:a,location:n,vendorId:o}=t;return{onFetchBankName:s=>{e(j(s))},onSaveHandler:s=>{e(G(t.bankAccountContext,s,"standard",o))},onCancel:()=>{(()=>{const s=p(n.state?.pathnameStackToGoBack),r=s.poppedPathname??P();a(r,{state:{pathnameStackToGoBack:s.newStack}})})(),e(S())},onACHDetailsUpdated:s=>{const{bankAccountSection:r}=s;e(F({data:r}))},onBackClick:()=>{if(e(T({fetchState:"Not-Started"})),t.bankAccountContext==="express-pay")a("../",{relative:"path"});else{const s=p(t.location.state?.pathnameStackToGoBack),r=s.poppedPathname??P(0);t.navigate(r,{state:{pathnameStackToGoBack:s.newStack}})}e(S())}}}))(Y);function fe({vendorIdParam:e,accountContext:t}){const a=w(),n=C(),o=R(),{vendorId:s,billId:r}=V(),c=e??s,{useFeatureGate:d}=N(),i=Z.getSignedInUser(),b=h((u=>B(u))),g=H(),I=p(n.state?.pathnameStackToGoBack),f=t??(I.poppedPathname?.includes("vendor")===!0?"vendor":"billDetail"),m=h((u=>k(u,c))),{isFeatureEnabled:x}=d(v.isVendorRecommendationFeatureEnabled),{isFeatureEnabled:y}=d(v.isDepositAccountsFeatureEnabled);if(i==null)throw Error("Can't access address page without signing in...");return f==="billDetail"&&m.editVendorState?.saveStatus.fetchState==="In-Progress"?l.jsx(_,{fetchState:m.editVendorState?.saveStatus.fetchState??"Not-Started",style:{backgroundColor:g.colors.grey5}}):l.jsxs(ne,{windowSize:o,children:[l.jsx(z,{vendorId:c,billId:r}),l.jsx(oe,{location:n,navigate:a,billId:r,vendorId:c,currentTenant:b,bankAccountContext:f,isVendorRecommendationEnabled:x,isZeniAccountsFeatureEnabled:y})]})}const P=(e=2)=>{let t="../";for(let a=0;a<e;a++)t=`${t}../`;return t},me=(e,t,a)=>{let n=`/${e}/bill/${encodeURIComponent(t)}`;return a=="draft"&&(n+="/edit"),n},he=e=>`/${e}/bills`,ke=(e,t)=>{let a=`/${e}/bill`;return a=t!=null?a.concat(`/${t}/edit`):a.concat("/new"),a},E=(e,t,a,n)=>{let o=`/${e}/bill`;return o+=a!=null?`/${a}/edit/vendor`:"/new/vendor",o+=n!=null?`/${n}/edit/${t}`:`/create/${t}`,o};function Se(e,t,a){return E(e,"ach",t,a)}function ve(e,t,a){return E(e,"domestic",t,a)}function ge(e,t,a){return E(e,"international",t,a)}const se=(e,t,a)=>{let n=`/${e}/bill/`;return n=a!=null?n.concat(`${encodeURIComponent(a)}/${t}/`):n.concat(`new/${t}/`),n},de=O.div`
10
- display: flex;
11
- height: 100vh;
12
- width: 100%;
13
- flex: 1 1 auto;
14
- flex-direction: column;
15
- align-items: center;
16
- background-color: ${e=>e.theme.colors.grey4};
17
- box-shadow: ${e=>`0px 2px ${U.sp1} ${e.theme.colors.dropShadowNormal}`};
18
- `,re=A((function(e,t){const{vendorId:a,billId:n}=t,o=k(e,a),s=D(e,t.isVendorRecommendationEnabled,t.isZeniAccountsFeatureEnabled,n);return{billId:n,isDisabled:o.bankAccountCreationState.fetchState==="In-Progress"?"readonly":void 0,vendorViewDetails:o,file:s.file,bankAccountContext:t.bankAccountContext}}),(function(e,t){const{billId:a,navigate:n,location:o,vendorId:s,currentTenant:r}=t,{tenantEmailDomain:c}=r;return{onFetchBankName:d=>{e(j(d))},onSaveHandler:d=>{e(G(t.bankAccountContext,d,"us-domestic",s))},onWireDetailsUpdated:d=>{const{bankAccountSection:i}=d;e(F({data:i}))},onCancel:()=>{(()=>{const d=p(o.state?.pathnameStackToGoBack),i=d.poppedPathname??$();n(i,{state:{pathnameStackToGoBack:d.newStack}})})(),e(S())},onAddressClick:d=>{if(t.bankAccountContext==="express-pay")n("./add-address");else{const i=se(c,d,a),b=te(o.state?.pathnameStackToGoBack,o.pathname);n(i,{state:{pathnameStackToGoBack:b}})}},onBackClick:()=>{if(e(T({fetchState:"Not-Started"})),t.bankAccountContext==="express-pay")n("../",{relative:"path"});else{const d=p(t.location.state?.pathnameStackToGoBack),i=d.poppedPathname??$(0);t.navigate(i,{state:{pathnameStackToGoBack:d.newStack}})}e(S())}}}))(ee);function Ie({vendorIdParam:e,accountContext:t}){const a=w(),n=C(),o=R(),{vendorId:s,billId:r}=V(),c=e??s,d=Z.getSignedInUser(),{useFeatureGate:i}=N(),b=H(),g=h((u=>B(u))),I=p(n.state?.pathnameStackToGoBack),f=t??(I.poppedPathname?.includes("vendor")===!0?"vendor":"billDetail"),m=h((u=>k(u,c))),{isFeatureEnabled:x}=i(v.isVendorRecommendationFeatureEnabled),{isFeatureEnabled:y}=i(v.isDepositAccountsFeatureEnabled);if(d==null)throw Error("Can't access address page without signing in...");return f==="billDetail"&&m.editVendorState?.saveStatus.fetchState==="In-Progress"?l.jsx(_,{fetchState:m.editVendorState?.saveStatus.fetchState??"Not-Started",style:{backgroundColor:b.colors.grey5,boxShadow:`0px 2px ${U.sp1} ${b.colors.dropShadowNormal}`}}):l.jsxs(de,{windowSize:o,children:[l.jsx(z,{vendorId:c,billId:r}),l.jsx(re,{location:n,navigate:a,billId:r,vendorId:c,currentTenant:g,bankAccountContext:f,isVendorRecommendationEnabled:x,isZeniAccountsFeatureEnabled:y})]})}const $=(e=2)=>{let t="../";for(let a=0;a<e;a++)t=`${t}../`;return t};export{fe as A,Ie as D,z as V,me as a,se as b,ke as c,ve as d,he as g,ge as i,Se as v};
@@ -1 +0,0 @@
1
- import{j as i}from"./liveblocks-Vz4gvIdI.js";import{_ as l,a9 as c}from"./index-eXyO65Ih.js";import{u as f,D as p}from"./mui-CuMgG_27.js";import"./sentry-Y8vuE8aQ.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]="7343a8d4-dee6-4ca7-9ab3-2b3236099e14",e._sentryDebugIdIdentifier="sentry-dbid-7343a8d4-dee6-4ca7-9ab3-2b3236099e14")}catch{}})();const b={drawerLeftMargin:new c(0,0,240)};function h(e){const{isOpen:r,drawerLeftMargin:o,children:a,onClose:t}=e,n=l(),s=o?.valuePx(n)??b.drawerLeftMargin.valuePx(n),d=f();return i.jsx(p,{anchor:"right",open:r,PaperProps:{style:{width:`calc(100% - ${s})`}},slotProps:{backdrop:{style:{backgroundColor:d.colors.black,opacity:.8,cursor:"pointer"}}},onClose:t,children:a})}export{h as D};
@@ -1 +0,0 @@
1
- import{j as s}from"./liveblocks-Vz4gvIdI.js";import{a as d}from"./sentry-Y8vuE8aQ.js";import{h as A,u as B,g as X,i as q,j as l,N as F,l as N,n as O,o as _}from"./core-GrVUbJGD.js";import{XZ as Y,fI as $,X1 as H,n3 as M,S$ as I,Y2 as R,XG as W,m3 as z,T0 as S,X6 as V,X7 as Z,XI as J,XH as K}from"./zeni-epic-state-COBHVss0.js";import{b9 as L,k as Q,a2 as U,l as tt}from"./index-eXyO65Ih.js";import"./mui-CuMgG_27.js";import{d as b}from"./decodeURIComponentSafe-C1t-__r9.js";import{w as et}from"./withTransactionSidePanel-D9vq13QQ.js";import{f as at,c as nt}from"./routePaths-C4nWRb1J.js";import"./recharts-Cz5M2Ami.js";import"./analytics-B_BCmETJ.js";import"./plaid-DEbV2MCp.js";import"./dnd-Cc3q8XS9.js";import"./stripe-cKAAJElX.js";import"./lottie-7o7Nu0hF.js";import"./lexical-C0CQ8hW2.js";import"./pdf-Dl24vdfn.js";import"./utils-PKPkEQd5.js";import"./useAskAiCfoHostNavButtonProps-Gb5FxzST.js";import"./TransactionDetailScreen-BeMygB7E.js";import"./useInitialThreadRequest-zNumU9hI.js";import"./expenseAutomationHelper-BqqNQc4E.js";import"./stripSplatSuffix-DBJKfIbL.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new a.Error().stack;t&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[t]="0c068df5-b76e-4639-a33b-73d2d67b8a6c",a._sentryDebugIdIdentifier="sentry-dbid-0c068df5-b76e-4639-a33b-73d2d67b8a6c")}catch{}})();const ot=N((function(a,t){const e=t.entity,o=R(a,t.entity,"EntityDetail");return{selectedEntity:e,autoCompleteData:{autoCompleteText:e.name,entityAutoCompleteView:W(a,"common")},trendWithTransactionsReport:o,analytics:Q,isAccountingClassesEnabled:z(a)}}),(function(a,t){return{onTransactionItemClick:e=>{if(t.openTransactionPanel)return void t.openTransactionPanel(e.id,e.type);const o=`${nt(e,t.tenantEmailDomain)}`,c=tt(t.location.state?.pathnameStackToGoBack,t.location.pathname);t.navigate(o,{state:{pathnameStackToGoBack:c}})},autoCompleteActions:{onAutoCompleteInputChange:e=>{e.trim().length>=2?a(J({searchString:e,searchOrigin:"common"})):e.trim().length===0&&a(K("common"))},onAutoCompleteEntity:e=>{const o=at(e,t.tenantEmailDomain);a(V()),a(Z()),t.resetTrendIsFetchedStates(),t.navigate(o,{replace:!0,state:{pathnameStackToGoBack:t.location.state?.pathnameStackToGoBack}})},onCancelAutoComplete:()=>{const e=U(t.location.state?.pathnameStackToGoBack),o=e.poppedPathname??k();t.navigate(o,{state:{pathnameStackToGoBack:e.newStack}})}},onTrendSelectedPeriodChange:e=>{if(t.closeSidePanel?.(),e==null)t.defaultTransactionTimePeriod!=null&&a(S(t.entity,"EntityDetail",{timeframe:"quarter",timePeriod:t.defaultTransactionTimePeriod}));else{const o=e.currentTimePeriod==null?e.addTimePeriod:{startDate:e.addTimePeriod.startDate,endDate:e.currentTimePeriod.endDate};a(I(t.entity,"EntityDetail",{timeframe:e.timeframe,timePeriod:e.addTimePeriod})),a(S(t.entity,"EntityDetail",{timeframe:e.timeframe,timePeriod:o}))}}}}))(L),it=et((function({entityType:a,...t}){const e=A(),o=B(),c=X(),[m,T]=d.useState(!1),[h,D]=d.useState(!1),{tenantEmailDomain:C,entityIdEncoded:w,entityNameEncoded:x}=q(),r=b(w??""),p=b(x??""),u=rt(r,p),j=[r,p].filter((n=>n!=null)),i={name:p,id:r,type:a,zeniId:r,qboId:r},g=l((n=>Y(n.customerIncomeState,n.vendorExpenseState,n.trendState,i,"quarter"))),G=l((n=>$(n).company?.companyInfo.firstMonthOfFY??1)),f=l((n=>H(n.trendWithTransactionsState,i,"EntityDetail")));d.useEffect((()=>{m===!1&&u===!0&&(T(!0),o(M(i)))}),[m,u,i]);const E=l((n=>n.trendState.fetchState)),P=f?.selectedPeriod?.timePeriod??g,v=(function(n,y){return n!=null&&y!=null?{startDate:n.startDate,endDate:y?.endDate}:y})(f?.selectedPeriod?.timePeriod,g);return d.useEffect((()=>{m===!0&&h===!1&&E==="Completed"&&(D(!0),P!=null&&o(I(i,"EntityDetail",{timeframe:f?.selectedPeriod?.timeframe??"quarter",timePeriod:P})))}),[m,h,E]),u?s.jsx(ot,{firstMonthOfFY:G,tenantEmailDomain:C,location:c,navigate:e,entity:i,defaultTransactionTimePeriod:v,resetTrendIsFetchedStates:()=>{T(!1),D(!1)},...t}):s.jsx(F,{to:k(j.length)})})),rt=(a,t)=>t!=null&&t.length>0&&a!=null&&a.length>0,k=(a=2)=>{let t="../";for(let e=0;e<a;e++)t=`${t}../`;return t};function Gt({entityType:a}){return s.jsx(O,{children:s.jsx(_,{path:"/:entityIdEncoded/:entityNameEncoded/*",element:s.jsx(it,{entityType:a})})})}export{Gt as EntityDetailRoutes,Gt as default};
@@ -1 +0,0 @@
1
- import{j as s}from"./liveblocks-Vz4gvIdI.js";import{a as r}from"./sentry-Y8vuE8aQ.js";import{au as i,av as b,r as f,a2 as l}from"./index-eXyO65Ih.js";import"./mui-CuMgG_27.js";import p from"./NotFoundScreen-lrXID2D2.js";import{h as m,g as u}from"./core-GrVUbJGD.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="3e0b62bd-24c2-4dc7-beeb-ffec556cb516",e._sentryDebugIdIdentifier="sentry-dbid-3e0b62bd-24c2-4dc7-beeb-ffec556cb516")}catch{}})();const _=()=>{const e=m(),t=u(),a=r.useCallback((()=>{window.open("https://www.zeni.ai/demo/request","_blank")}),[]),c=r.useCallback((()=>{(()=>{const n=l(t.state?.pathnameStackToGoBack),d=n.poppedPathname??k();e(d,{state:{pathnameStackToGoBack:n.newStack}})})()}),[]),o=i(t.pathname);return o!=null?s.jsx(b,{menuItem:f(o),onDemoClick:a,onGoBack:c}):s.jsx(p,{})},k=(e=2)=>{let t="../";for(let a=0;a<e;a++)t=`${t}../`;return t};export{_ as F};
@@ -1 +0,0 @@
1
- import{a as i}from"./sentry-Y8vuE8aQ.js";import{u as l,h as f,g as m}from"./core-GrVUbJGD.js";import{i0 as p,Vm as g,Vn as _}from"./zeni-epic-state-COBHVss0.js";import{u as b,L as h,z as y}from"./index-eXyO65Ih.js";import"./liveblocks-Vz4gvIdI.js";import"./recharts-Cz5M2Ami.js";import"./mui-CuMgG_27.js";import"./analytics-B_BCmETJ.js";import"./plaid-DEbV2MCp.js";import"./dnd-Cc3q8XS9.js";import"./stripe-cKAAJElX.js";import"./lottie-7o7Nu0hF.js";import"./lexical-C0CQ8hW2.js";import"./pdf-Dl24vdfn.js";import"./utils-PKPkEQd5.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new e.Error().stack;n&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[n]="41668f96-8f56-4b64-9d99-b7348ccd25ec",e._sentryDebugIdIdentifier="sentry-dbid-41668f96-8f56-4b64-9d99-b7348ccd25ec")}catch{}})();function V(){const e=l(),n=f(),r=m(),{setLoading:o,clearAllLoading:u}=b(),s=i.useRef(!1);return i.useLayoutEffect((()=>{o(h.CONNECTION_AUTH)}),[o]),i.useEffect((()=>{if(s.current)return;s.current=!0;const a=new URLSearchParams(r.search).get("code"),c=sessionStorage.getItem("hubspot_oauth_pending");if(sessionStorage.removeItem("hubspot_oauth_pending"),a!=null&&c!=null){const t=JSON.parse(c);e(p(t.tenant_id,t.connection_id,g("revenue"),_("hubspot"),{authorization_code:a,client_id:t.client_id,client_secret:t.client_secret,redirect_uri:t.redirect_uri}))}u();const d=y.getActiveTenantForUser();n(d?.tenantEmailDomain!=null?`/${d.tenantEmailDomain}/settings/integrations`:"/",{replace:!0})}),[]),null}export{V as default};
@@ -1 +0,0 @@
1
- import{n as s}from"./liveblocks-Vz4gvIdI.js";import{j as c}from"./core-GrVUbJGD.js";import{fI as f}from"./zeni-epic-state-COBHVss0.js";import"./sentry-Y8vuE8aQ.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},o=new e.Error().stack;o&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[o]="25fc1afa-344c-4436-b7c0-ce0cb6697f63",e._sentryDebugIdIdentifier="sentry-dbid-25fc1afa-344c-4436-b7c0-ce0cb6697f63")}catch{}})();const b=()=>c((e=>f(e))).tenantId==null?{inboxNotifications:[],isLoading:!1,isFetchingMore:!1,hasFetchedAll:!0,fetchMore:()=>null}:(()=>{const{inboxNotifications:e,isLoading:o,isFetchingMore:i,hasFetchedAll:t,fetchMore:n}=s();return{inboxNotifications:e,isLoading:o,isFetchingMore:i,hasFetchedAll:t,fetchMore:n}})();export{b as u};
@@ -1,3 +0,0 @@
1
- import{j as c}from"./liveblocks-Vz4gvIdI.js";import{a as r}from"./sentry-Y8vuE8aQ.js";import{u as $,h as L,i as R,j as E,t as oe,l as O,s as z,g as ae,N as H,n as ge,o as x}from"./core-GrVUbJGD.js";import{a6 as st,k as g,ao as F,S as l,cd as rt,ce as dt,cf as lt,cg as ut,ch as gt,ci as mt,cj as vt,ck as pt,cl as St,cm as ft,cn as It,co as ht,l as ce,cp as Ct,cq as kt,z as te,ac as pe,cr as Et,cs as yt,ct as bt,cu as xt,cv as At,cw as Dt,cx as jt,cy as $t,cz as Lt,cA as Pt,M as wt,ag as pn,cB as Rt,cC as _t,cD as Ft,cE as Tt,cF as Ot,cG as Mt,cH as Nt,cI as Ut,cJ as Bt,cK as Vt,cL as Ht,t as en,j as Ue,cM as qt,cN as Qt,cO as zt,cP as Kt,cQ as Gt,cR as Wt,cS as Yt,bt as Jt}from"./index-eXyO65Ih.js";import"./mui-CuMgG_27.js";import{A as Z}from"./AddressScreen-BMW5PBGV.js";import M from"./NotFoundScreen-lrXID2D2.js";import{_R as Zt,_S as Xt,vA as nn,v as ei,_T as X,wb as Se,_U as Be,_V as W,wO as Pe,wV as ni,dY as Sn,wZ as fn,_W as Ve,wS as ti,yy as tn,wa as on,_X as In,_Y as Y,x8 as we,xc as ii,_Z as oi,xm as ai,__ as hn,xf as Cn,z6 as ci,_$ as he,$0 as an,$1 as kn,w6 as si,$2 as ri,v_ as di,$3 as li,yL as ui,$4 as En,yU as be,$5 as gi,yR as mi,$6 as He,gk as qe,$7 as le,$8 as ue,xu as vi,wg as cn,wl as yn,wj as pi,wd as Si,xn as fi,wn as Ii,xw as hi,c$ as bn,$9 as Re,xF as xn,xD as Q,xB as G,xA as Ci,$a as fe,y$ as xe,$b as ki,w8 as An,$c as Qe,fI as Ce,ww as _e,wt as Fe,wG as Dn,wF as ze,wq as Ei,wz as jn,wI as me,Wp as $n,wc as Ke,wD as yi,wE as bi,wC as xi,$d as Ai,xd as Di,x9 as Ln,$e as Pn,vR as Ae,$f as ji,vK as $i,$g as Li,z5 as Pi,za as K,z4 as wi,yc as ke,$h as Ri,$i as wn,zj as De,$j as _i,zg as Fi,$k as Rn,yf as Ti,yg as q,yj as Oi,$l as _n,yt as je,$m as Mi,xv as Fn,UV as Tn,$n as Ni,yD as Ui,$o as On,$p as sn,$q as Bi,$r as Vi,A6 as Hi,$s as qi,$t as Mn,zq as Nn,$u as Un,A4 as $e,$v as Qi,A1 as zi,$w as Ki,$x as Gi,$y as Wi,$z as Yi,$A as Ji,$B as rn,$C as Zi,ei as Xi,Aa as eo,$D as Ge,xP as no,xK as to,d1 as Te,$E as ee,xT as Bn,x$ as Vn,$F as We,xU as ie,y4 as io,y7 as Hn,$G as oo,$H as Oe,y3 as ao,$I as qn,zV as Le,zQ as co,$J as so,zv as ro,$K as lo,zW as uo,z_ as go,$L as Ye,wQ as Qn,zH as mo,wR as vo,$M as po,$N as zn,ca as So,mw as fo,mx as Io,$O as dn,wP as ne,go as ho,mD as Co,zN as Kn,Am as ko,zK as Gn,v6 as Eo,uW as yo,hW as bo,Vm as ln,Vn as xo,GO as Wn,Aj as Ao,hO as Do,Ag as jo,$P as $o,$Q as Lo,As as Po,Ar as wo,$R as Ro,$S as Yn,Ap as _o,$T as Fo,$U as To,yH as Oo,$V as Mo}from"./zeni-epic-state-COBHVss0.js";import{M as No}from"./MobileAppDrawer-nKSb2sKG.js";import{q as Ie}from"./QBOConnectionScreen-Cllizgjx.js";import"./recharts-Cz5M2Ami.js";import"./analytics-B_BCmETJ.js";import"./plaid-DEbV2MCp.js";import"./dnd-Cc3q8XS9.js";import"./stripe-cKAAJElX.js";import"./lottie-7o7Nu0hF.js";import"./lexical-C0CQ8hW2.js";import"./pdf-Dl24vdfn.js";import"./utils-PKPkEQd5.js";import"./InboxNotificationsProvider-gHb6rSEv.js";import"./useTaskManagerAccess-gL3vn6YT.js";import"./empty-D0ciM-5y.js";import"./pdf-lib-fawjhojL.js";import"./index-CL0RkSdG.js";import"./url-DhQWTUYg.js";import"./index-quhlDe1C.js";import"./decodeURIComponentSafe-C1t-__r9.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]="7ca4d5c3-85b0-4ec0-b0b7-b7add6993323",t._sentryDebugIdIdentifier="sentry-dbid-7ca4d5c3-85b0-4ec0-b0b7-b7add6993323")}catch{}})();const w=({event:t,isReady:e=!0})=>e?c.jsx(st,{analytics:g,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function Uo(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),{fetchState:m,hasMore:S,items:f,nextCursor:I,auditLogEntityRouteOptions:C,auditLogListSortFieldOptions:h}=E(Zt),y=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),D=`/${n??""}/invoicing`,b=r.useCallback(((_,U)=>{const T=Xt(D,_,U,C);T!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{entity:_,entityId:U,fromScreen:"audit_log",toScreen:_}),e(T))}),[C,e,D]);r.useEffect((()=>{const _=setTimeout((()=>u(a)),300);return()=>clearTimeout(_)}),[a]),r.useEffect((()=>{i&&t(nn({filters:y,keepExistingListItems:!1,sort:v}))}),[i,y,v,t]);const A=m==="Not-Started"||m==="In-Progress"&&f.length===0,k=m==="In-Progress"&&f.length>0,j=m==="Completed";return N(m)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingAuditLogPage,isReady:j}),c.jsx(rt,{auditLogEntityRouteOptions:C,auditLogListSortFieldOptions:h,entries:f,hasMore:S,isLoading:A,isLoadingMore:k,searchValue:a,sortState:d,onEntityLinkClick:b,onLoadMore:()=>{S&&I!=null&&t(nn({cursor:I,filters:y,keepExistingListItems:!0,sort:v}))},onSearchChange:o,onSortChange:p})]})}const Jn=["company","email","firstName","invoiceNotes","lastName","notes","phone","vatNumber"],Me=t=>typeof t=="string"||typeof t=="number"||typeof t=="boolean"?t:Array.isArray(t)?t.map(Me):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).map((([e,n])=>[e,Me(n)]))):null;function B(t,e,n=[]){const i=t,a=e,o=[...new Set([...Object.keys(i),...Object.keys(a??{})])].filter((u=>{if(a==null)return(d=i[u])!=null&&d!==""&&(Array.isArray(d)?d.length>0:typeof d!="object"||Object.keys(d).length>0);var d;return!(i[u]==null&&a[u]==null)&&!ei(i[u],a[u])})).sort(),s=Object.fromEntries(o.filter((u=>!n.includes(u))).map((u=>[u,Me(i[u])])));return{fieldsChanged:o,formValues:s}}function Ee(t,e=!1){const n=$(),i=E((s=>X(s).productNextCursor!=null)),a=E((s=>X(s).productNextCursor)),o=E((s=>X(s).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&o!=="Not-Started"||n(Se({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&o!=="In-Progress"&&i&&a!=null&&n(Se({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,o,i,a])}function se(t,e,n,i){const[a,o]=r.useState(0),[s,u]=r.useState(!1),d=r.useRef(t);return r.useEffect((()=>{const p=d.current==="In-Progress";d.current=t,t==="Completed"&&p&&n!=null&&(u(!0),i(n))}),[t,n,i]),r.useEffect((()=>{s&&!e&&(u(!1),o((p=>p+1)))}),[s,e]),a}const Bo=new Set(["plan"]),Vo=O((function(t,e){const{view:n}=e;return{applicableItemOptions:n.applicableItemOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboClassHierarchy:n.qboClassHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:n.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",itemId:e.itemId,localData:n.localData,plan:n.plan}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${n}/catalog`),onLifecycleAction:i!==""?a=>{i!==""&&(g.trackInvoicingActionClick(l.Event.invoicingCatalogItemLifecycleAction,{action:a,fromScreen:"catalog_item_detail",itemId:i}),t(ti({action:a,id:i})))}:void 0,onEditChange:a=>{i!==""&&t(Ve({id:i,localData:a}))},onSaveEdit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemEdited,{itemId:i,mode:"edit",...B(e.view.localData,Sn(e.view.plan))}),t(fn({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&t(ni({action:o,id:a,parentItemId:i}))}}}))(dt);function Ho(){const t=$(),e=L(),{item_id:n,tenantEmailDomain:i}=R(),[a]=oe(),{areTenantIdsInSync:o}=F(),s=(u=a.get("kind"))!=null&&Bo.has(u)?u:"plan";var u;const d=E((y=>Be(y,n))),{pageFetchState:p}=d,v=p.fetchState;r.useEffect((()=>(t(W({id:n})),()=>{t(W({id:n}))})),[t,n]),r.useEffect((()=>{o&&t(Pe({id:n,kind:s}))}),[o,n,s,t]);const m=r.useCallback((y=>t(Pe({cacheOverride:!0,id:y,kind:s}))),[t,s]),S=se(d.fetchState,d.isFormLoading,n,m),f=v==="Completed"&&!d.isFormLoading;Ee(o,!0);const[I,C]=r.useState(f?n:void 0);r.useEffect((()=>{n!=null&&f&&C(n)}),[n,f]);const h=I!==n&&(v==="Not-Started"||v==="In-Progress"||d.isFormLoading);return N(v)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCatalogItemDetailPage,isReady:f}),c.jsx(Vo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:s,isLoading:h,view:d},S)]})}const qo=new Set(["addon","charge","plan"]),Qo=new Set(["plan"]),zo=O((function(t,e){const n=Be(t,e.itemId);return{fieldHelp:n.fieldHelp,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,applicabilityValues:n.applicabilityValues,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,applicableItemOptions:n.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save catalog item.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedItem:n.plan,pricingModelValues:n.pricingModelValues,prorationValues:n.prorationValues,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,tierTypeValues:n.tierTypeValues}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e,a=i!=null?`${n}/catalog/${encodeURIComponent(i)}`:`${n}/catalog`;return{onBack:()=>{t(W({id:i})),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemFormCancelled),t(W({id:i})),e.navigate(`${n}/catalog`)},onChange:o=>{t(Ve({id:i,localData:o}))},onSubmit:()=>{t(fn({id:i}))}}}),(function({savedItem:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemSaved,{itemId:i.itemId,mode:e.mode,...B(e.localData,t!=null?Sn(t):void 0)}),n.onSubmit()}}}))(lt);function Ko(){const t=$(),e=L(),{item_id:n,tenantEmailDomain:i}=R(),[a]=oe(),{areTenantIdsInSync:o}=F(),s=n!=null,u=a.get("type"),d=u!=null&&qo.has(u)?u:void 0,p=(v=a.get("kind"))!=null&&Qo.has(v)?v:"plan";var v;const m=E((f=>Be(f,n)));Ee(o,!0);const S=r.useRef();return r.useEffect((()=>(clearTimeout(S.current),()=>{S.current=setTimeout((()=>{t(W({id:n}))}),0)})),[n,t]),r.useEffect((()=>{o&&t(Pe({id:n,kind:p}))}),[o,n,p,t]),r.useEffect((()=>{s||d==null||m.localData.catalogType===d||t(Ve({localData:{...m.localData,catalogType:d}}))}),[s,d,m.localData?.catalogType,t]),r.useEffect((()=>{if(m.fetchState==="Completed"){const f=m.savedItemId??n,I=f!=null?`/${i}/invoicing/catalog/${encodeURIComponent(f)}`:`/${i}/invoicing/catalog`;e(I),t(W({id:n}))}}),[m.fetchState,m.savedItemId,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCatalogItemFormPage}),c.jsx(zo,{navigate:e,tenantEmailDomain:i,defaultType:d,isEdit:s,itemId:n})]})}const Go={addons:"addon",all:"item",charges:"charge",plans:"plan"},Wo=O((function(t,e){const n=X(t),i=e.activeTab==="plans",a=e.activeTab==="all",o=i?n.plans:a?[...n.plans,...n.products]:n.products,s=i||a&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:a&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:s==="Not-Started"||s==="In-Progress"&&o.length===0,isLoadingMore:s==="In-Progress"&&o.length>0,planRows:n.planRows,productRows:n.productRows}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",a=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const s=Go[e.activeTab];g.trackInvoicingActionClick(l.Event.invoicingAddCatalogItemClicked,{itemType:s}),e.navigate(`${n}/catalog/new?type=${s}`)},onItemClick:(s,u)=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemRowClicked,{itemId:u}),e.navigate(`${n}/catalog/${encodeURIComponent(u)}`)},onLoadMore:()=>{if(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"catalog",tab:e.activeTab}),a)return e.planNextCursor!=null&&t(on({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&t(Se({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));o!=null&&t(i?on({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):Se({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(ut);function Yo(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState("plans"),[d,p]=r.useState(""),[v,m]=r.useState(null),S=r.useMemo((()=>v!=null?{dir:v.direction,field:v.columnKey}:void 0),[v]),f=d.trim()!==""?d.trim():void 0,I=r.useMemo((()=>({search:f,type:"plan"})),[f]),C=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),h=E((j=>X(j))),y=h.planFilters.search,D=h.planSort,b=h.planNextCursor,A=h.productNextCursor,k=h.fetchState==="Completed";return r.useEffect((()=>{const j=setTimeout((()=>p(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t(tn({cacheOverride:!1,planFilters:I,productFilters:C,planSort:S,productSort:S}))}),[i,t,I,C,S]),r.useEffect((()=>{i&&(f!==y||S?.field!==D?.field||S?.dir!==D?.dir)&&t(tn({cacheOverride:!0,planFilters:I,productFilters:C,planSort:S,productSort:S}))}),[y,D,i,t,I,C,f,S]),N(h.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCatalogPage,isReady:k}),c.jsx(Wo,{navigate:e,tenantEmailDomain:n,activeTab:s,searchValue:a,sortState:v,planFilters:I,productFilters:C,sort:S,planNextCursor:b,productNextCursor:A,onSearchChange:o,onTabChange:u,onSortChange:m})]})}const Jo=O((function(t,e){const n=In(t,e.couponId);return{fieldHelp:n.fieldHelp,applyOnOptions:n.applyOnOptions,discountTypeOptions:n.discountTypeOptions,durationTypeOptions:n.durationTypeOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save coupon.":void 0,isQboConnected:n.isQboConnected,isQboPickerDataLoading:n.isQboPickerDataLoading,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedCoupon:n.coupon,periodUnitOptions:n.periodUnitOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,a=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>{t(Y({id:i})),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCouponFormCancelled),t(Y({id:i})),e.navigate(`${n}/discounts`)},onChange:o=>{t(oi({id:i,localData:o}))},onSubmit:()=>{t(ii({id:i}))}}}),(function({savedCoupon:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCouponSaved,{couponId:i.couponId,mode:e.mode,...B(e.localData,t!=null?ai(t):void 0)}),n.onSubmit()}}}))(gt);function Zo(){const t=$(),e=L(),{coupon_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),{fetchState:o,savedCouponId:s}=E((d=>In(d,n))),u=r.useRef();return r.useEffect((()=>(clearTimeout(u.current),()=>{u.current=setTimeout((()=>{t(Y({id:n}))}),0)})),[n,t]),r.useEffect((()=>{a&&t(we({id:n}))}),[a,n,t]),r.useEffect((()=>{if(o==="Completed"){const d=s??n,p=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(p),t(Y({id:n}))}}),[o,s,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCouponFormPage}),c.jsx(Jo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Xo=O((function(t){const e=hn(t);return{fieldHelp:e.fieldHelp,customers:e.customers,planNames:e.planNames,errorMessage:e.fetchState==="Error"?e.error?.message??"Failed to create invoice. Please try again.":void 0,isSubmitting:e.fetchState==="In-Progress",localData:e.localData,settings:e.settings}}),(function(t){return{dispatch:t}}),(function(t,{dispatch:e},n){const i=`/${n.tenantEmailDomain}/invoicing`;return{...t,onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:a=>{e(kn(a))},onSubmit:()=>{const a=ri(t.localData);g.trackInvoicingActionClick(l.Event.invoicingInvoiceCreated,{customerId:a.customer_id,lineItemCount:a.line_items?.length,mode:"create",...B(t.localData,void 0,["memo"])}),e(di(a))}}}))(vt);function ea(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),[i]=oe(),{areTenantIdsInSync:a}=F(),o=i.get("customerId"),s=E((b=>hn(b))),u=s.fetchState,d=s.localData,p=s.savedInvoiceId,v=E(Cn),m=E((b=>ci(b))),S=E(he),f=m.fetchState==="Not-Started"||m.fetchState==="In-Progress"&&v==null,I=S.fetchState==="Not-Started"||S.fetchState==="In-Progress"&&S.customers.length===0,C=f||I,h=m.fetchState==="Completed"&&S.fetchState==="Completed";r.useEffect((()=>(t(an()),()=>{t(an())})),[t]);const y=r.useRef(!1);r.useEffect((()=>{y.current||o==null||o===""||d.customerId!==""||(y.current=!0,t(kn({...d,customerId:o})))}),[o,d,t]),r.useEffect((()=>{a&&t(si({cacheOverride:!1}))}),[a,t]);const D=r.useRef(u);return r.useEffect((()=>{const b=D.current;if(D.current=u,b!=="Completed"&&u==="Completed"){const A=p!=null?`/${n}/invoicing/invoices/${encodeURIComponent(p)}`:`/${n}/invoicing/invoices`;e(A)}}),[u,p,e,n]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCreateInvoicePage,isReady:h}),C?c.jsx(mt,{}):c.jsx(Xo,{navigate:e,tenantEmailDomain:n})]})}const na=O((function(t,e){const{detailView:n}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:n.creditNote,creditNoteId:e.creditNoteId,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${n}/credits`),onCustomerClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(pt);function ta(){const t=$(),e=L(),{credit_note_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),o=E((u=>li(u,n??""))),s=o.fetchState==="Completed";return r.useEffect((()=>{a&&n!=null&&t(ui({id:n}))}),[a,n,t]),N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCreditDetailPage,isReady:s}),c.jsx(na,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:o})]})}const ia=O((function(t){const e=En(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",creditNotes:e.creditNotes,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.creditNotes.length===0,isLoadingMore:n==="In-Progress"&&e.creditNotes.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"credits",status:e.activeStatus}),t(mi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(St);function oa(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,creditNoteListFetchState:h}=E((D=>{const b=En(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,creditNoteListFetchState:b.fetchState}}),z),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(be({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(be({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCreditsListPage,isReady:y}),c.jsx(ia,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,onSearchChange:o,onStatusChange:D=>{t(gi(D)),t(be({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const Zn=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},aa=O((function(t,e){const{editView:n,hasLoadedRecord:i}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,hasUnsavedBillingAddress:n.hasUnsavedBillingAddress,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:!i&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),hasPaymentLinkEmailPreviewFailed:n.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:n.emailPreviewFetchState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",paymentLinkEmailPreview:n.emailPreview,isSendingPaymentLink:n.record.sendLinkState.fetchState==="In-Progress",localData:n.localData,paymentMethods:n.record.paymentMethods,sendPaymentLinkErrorMessage:n.record.sendLinkState.fetchState==="Error"?n.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:n.record.stripeConnected}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${n}/customers`),onChange:a=>{t(Re({id:i,localData:a}))},onCreateInvoice:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onCreatePromotionalCredits:()=>{g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customer_detail"}),e.onCreatePromotionalCredits()},onNewSubscription:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`)},onDiscardEdit:()=>{t(Q(G)),t(Ci({id:i}))},onOpenAddress:()=>{const a=Zn(e.tenantEmailDomain??"",G,i),o=ce(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:a=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerEdited,{customerId:i,mode:"edit",...B(a,e.editView.record.invoicingCustomer!=null?bn(e.editView.record.invoicingCustomer):void 0,Jn)}),t(Re({id:i,localData:a})),t(xn({id:i}))},onFetchPaymentLinkEmailPreview:a=>t(hi({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,s)=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentLinkSent,{customerId:i,fromScreen:"customer_detail"}),t(Ii({body:s,customerId:i,email:a,subject:o}))},onSubscriptionClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)}}}))(ht);function ca(){const t=$(),e=L(),n=ae(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=F(),s=E((T=>He(T,i))),u=s.pageFetchState.fetchState,d=u==="Completed"&&!s.isFormLoading,[p,v]=r.useState(!1),[m,S]=r.useState(!1),[f,I]=r.useState(d?i:void 0);r.useEffect((()=>{i!=null&&d&&I(i)}),[i,d]);const C=f===i,{plaidTokenFetchState:h,promotionalCreditSubmitState:y}=s,{paymentMethodSaveState:D,setupIntentFetchState:b,stripeConnected:A}=s.record,k=r.useRef(s.record.sendLinkState.fetchState);r.useEffect((()=>{const T=s.record.sendLinkState.fetchState;k.current!=="Error"&&T==="Error"&&t(qe({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),k.current=T}),[t,s.record.sendLinkState.fetchState]);const j=b.fetchState==="Error"?b.error?.message??"Failed to start card setup.":D.fetchState==="Error"?D.error?.message??"Failed to save payment method.":h.fetchState==="Error"?h.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(t(le()),t(ue()),()=>{t(le()),t(ue())})),[t]),r.useEffect((()=>{n.state?.openPromotionalCreditsDialog===!0&&(S(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{o&&i!=null&&t(vi({id:i}))}),[o,i,t]),r.useEffect((()=>{o&&i!=null&&A&&t(cn({customerId:i}))}),[o,i,t,A]);const _=r.useCallback((T=>t(yn({id:T}))),[t]),U=se(s.fetchState,s.isFormLoading,i,_);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCustomerDetailPage,isReady:d}),c.jsx(aa,{customerId:i??"",editView:s,hasLoadedRecord:C,location:n,navigate:e,tenantEmailDomain:a,onAddPaymentMethod:()=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentMethodAddClicked,{customerId:i??"",fromScreen:"customer_detail"}),t(le()),i!=null&&A&&t(cn({customerId:i})),v(!0)},onCreatePromotionalCredits:()=>{t(ue()),S(!0)}},U),c.jsx(ft,{errorMessage:j,isCreatingSetupIntent:b.fetchState==="In-Progress",isSaving:D.fetchState==="In-Progress",open:p,plaidLinkToken:s.record.plaidLinkToken,saveSucceeded:D.fetchState==="Completed",setupIntent:s.record.setupIntent,stripeConnected:A,onChooseCard:()=>{i!=null&&t(Si({customerId:i}))},onClose:()=>{v(!1),t(le())},onSavePaymentMethod:T=>{i!=null&&(g.trackInvoicingActionClick(l.Event.invoicingPaymentMethodSaved,{customerId:i,fromScreen:"customer_detail"}),t(pi({customerId:i,data:T})))}}),c.jsx(It,{currentBalance:s.record.invoicingCustomer?.promotionalCredits,currencyCode:s.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:y.fetchState==="Error"?y.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:y.fetchState==="In-Progress",open:m,submitSucceeded:y.fetchState==="Completed",onClose:()=>{S(!1),t(ue())},onSubmit:({amount:T,description:de})=>{i!=null&&(g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsAdded,{amount:T,customerId:i,fromScreen:"customer_detail"}),t(fi({amount:T,customerId:i,currencyCode:s.record.invoicingCustomer?.preferredCurrencyCode,description:de})))}})]})}const sa=O((function(t,e){const n=He(t,e.customerId);return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save customer.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedCustomer:n.record.invoicingCustomer}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,a=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>{t(fe({id:i})),t(Q(G)),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerFormCancelled),t(fe({id:i})),t(Q(G)),e.navigate(`${n}/customers`)},onChange:o=>{t(Re({id:i,localData:o}))},onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"customer",fromScreen:"customer_form"});const o=Zn(e.tenantEmailDomain??"",G,i),s=ce(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.keepDraftOnLeave(),e.navigate(o,{state:{pathnameStackToGoBack:s}})},onSubmit:()=>{t(xn({id:i}))}}}),(function({savedCustomer:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerSaved,{customerId:i.customerId,mode:e.mode,...B(e.localData,t!=null?bn(t):void 0,Jn)}),n.onSubmit()}}}))(Ct);function ra(){const t=$(),e=L(),n=ae(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=F(),{fetchState:s,savedCustomerId:u}=E((m=>He(m,i))),d=r.useRef(!1),p=r.useCallback((()=>{d.current=!0}),[]),v=r.useRef();return r.useEffect((()=>(clearTimeout(v.current),d.current=!1,()=>{d.current||(v.current=setTimeout((()=>{t(fe({id:i})),t(Q(G))}),0))})),[i,t]),r.useEffect((()=>{o&&i!=null&&t(yn({id:i}))}),[o,i,t]),r.useEffect((()=>{if(s==="Completed"){const m=u??i,S=m!=null?`/${a}/invoicing/customers/${encodeURIComponent(m)}`:`/${a}/invoicing/customers`;e(S),t(fe({id:i}))}}),[s,u,i,t,e,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCustomerFormPage}),c.jsx(sa,{customerId:i,keepDraftOnLeave:p,location:n,navigate:e,tenantEmailDomain:a})]})}const da=O((function(t){const e=he(t),{fetchState:n}=e;return{addressesById:t.addressState.addressesById,columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",customers:e.customers,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.customers.length===0,isLoadingMore:n==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,a)=>{switch(a){case"createInvoice":g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":g.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"customers",status:e.activeStatus}),t(An({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(kt);function la(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,customerListFetchState:h}=E((D=>{const b=he(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,customerListFetchState:b.fetchState}}),z),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(xe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(xe({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingCustomersListPage,isReady:y}),c.jsx(da,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,onSearchChange:o,onStatusChange:D=>{t(ki(D)),t(xe({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const Ne=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),ua=O((function(t,e){const{authParams:n,csvDownloadUrl:i,filters:a,sessionId:o,view:s}=e,u=o==null?void 0:s.diagnosticsBySession[o],d=u?.fetch.fetchState??"Not-Started";return{authParams:n,csvDownloadUrl:i,diagnostics:u?.items??[],errorMessage:d==="Error"?u?.fetch.error?.message:void 0,expired:u?.expired??!1,filters:a,hasMore:u?.nextCursor!=null,isLoading:d==="Not-Started"||d==="In-Progress",isLoadingMore:d==="In-Progress"&&(u?.items.length??0)>0,session:Ne(s,o)}}),(function(t,e){const{filters:n,navigate:i,sessionId:a,tenantEmailDomain:o,view:s}=e,u=a==null?void 0:s.diagnosticsBySession[a],d=Ne(s,a),p=s.actionStateByKind.retry?.fetchState==="In-Progress",v=s.actionStateByKind.rollback?.fetchState==="In-Progress",m=d?.status==="done"&&d.rollback_available_until!=null&&new Date(d.rollback_available_until).getTime()>Date.now()&&!v;return{onBack:()=>i(`/${o}/invoicing/data_import`),onDownloadCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"download_csv",fromScreen:"data_import_detail",sessionId:a})},onDownloadError:()=>{t(qe({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{a!=null&&u?.nextCursor!=null&&t(Fe({...n,cursor:u.nextCursor,sessionId:a}))},onRetry:d?.status!=="failed"||p?void 0:()=>{a!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_detail",sessionId:a}),t(ze(a)))},onRollback:m?()=>{a!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"rollback",fromScreen:"data_import_detail",sessionId:a}),t(Dn(a)))}:void 0}}))(Et);function ga(){const t=$(),e=L(),{sessionId:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),[o,s]=r.useState({}),u=E(Qe),d=E(Ce),p=r.useMemo((()=>{const C=te.getSignedInUser();return{userId:C?.userId??"",sessionId:C?.zeniSessionId??"",tenantId:d.tenantId}}),[d.tenantId]),v=Ne(u,n),m=n==null?void 0:u.diagnosticsBySession[n];r.useEffect((()=>{a&&n!=null&&t(_e(n))}),[a,t,n]),r.useEffect((()=>{if(!a||n==null)return;const C=setTimeout((()=>{t(Fe({...o,sessionId:n}))}),300);return()=>clearTimeout(C)}),[a,t,o,n]);const S=v?.status==="scanning"||v?.status==="importing";r.useEffect((()=>{if(!a||n==null||!S)return;const C=setInterval((()=>{t(_e(n)),t(Fe({...o,sessionId:n}))}),3e3);return()=>clearInterval(C)}),[a,t,o,S,n]);const f=r.useMemo((()=>{if(n==null)return"";const C=new URLSearchParams;o.moduleId!=null&&C.set("module_id",o.moduleId),o.level!=null&&C.set("level",o.level),o.outcome!=null&&C.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&C.set("search",o.search.trim());const h=C.toString();return`${pe?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${h===""?"":`?${h}`}`}),[o,n]),I=m?.fetch.fetchState??"Not-Started";return N(I)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDataImportDetailPage,isReady:v!=null&&I!=="Not-Started"}),c.jsx(ua,{authParams:p,csvDownloadUrl:f,filters:o,navigate:e,sessionId:n,tenantEmailDomain:i,view:u,onFiltersChange:s})]})}const Xn=t=>`invoicing_active_migration:${t}`,ve=(t,e)=>{if(t!=null&&t!=="")try{const n=Xn(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},ma=O((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:a,statusRows:o}=e.view;return{isLoading:!(a.fetchState!=="Not-Started"&&a.fetchState!=="In-Progress"||o.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:o}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,a=o=>{const s=o??null;t(me(s)),ve(i,s),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),a(o)},onNewImport:()=>{g.trackInvoicingActionClick(l.Event.invoicingNewImportClicked),a()},onRetrySession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),t(ze(o)),a(o)},onRollbackSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),t(Dn(o))},onViewSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),n(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(yt);function va(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),a=E(Qe);r.useEffect((()=>{i&&(t(Ei()),t(jn()))}),[i,t]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDataImportHubPage,isReady:o}),c.jsx(ma,{navigate:e,tenantEmailDomain:n,view:a})]})}const pa=O((function(t,e){const{activeId:n,authParams:i,integrationsView:a,settings:o,templatesDownloadUrl:s,view:u}=e,{actionStateByKind:d,sessionDetail:p,sessions:v}=u,m=a.externalConnections?.revenue?.find((f=>f.connectionName==="chargebee")),S=n!=null?p[n]:void 0;return{authParams:i,templatesDownloadUrl:s,chargebeeConnected:o?.chargebee_connected===!0||(m?.isValid??!1),chargebeeConnectorAvailable:m!=null,chargebeeSite:o?.chargebee_site,connectError:d.connect?.error?.message,connecting:d.connect?.fetchState==="In-Progress",retrying:d.retry?.fetchState==="In-Progress",session:S??v.find((f=>f.id===n)),starting:d.start?.fetchState==="In-Progress",uploading:d.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:a}=e;return{onBack:e.onBack,onDownloadError:()=>{t(qe({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onDownloadTemplates:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportTemplatesDownloaded)},onFetchFromChargebee:()=>{g.trackInvoicingActionClick(l.Event.invoicingChargebeeConnectClicked),t(xi())},onGoToIntegrations:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"settings_integrations"}),i(`/${a}/invoicing/settings`)},onGoToOverview:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"overview"}),i(`/${a}/invoicing/overview`)},onRetry:()=>{n!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_migrate",sessionId:n}),t(ze(n)))},onSaveLater:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportStarted),n!=null&&t(bi(n))},onUpload:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportFileUploaded),t(yi({files:o}))},onViewDetails:n==null?void 0:()=>i(`/${a}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(bt);function Sa(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),a=E(Cn),o=E(Ce),s=r.useMemo((()=>{const h=te.getSignedInUser();return{userId:h?.userId??"",sessionId:h?.zeniSessionId??"",tenantId:o.tenantId}}),[o.tenantId]),u=`${pe?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/templates`,d=o.companyId??te.getSignedInUserTenant(n??"")?.companyId,p=E((h=>$n(h,d))),v=E(Qe),{activeMigrationSessionId:m}=v,S=m??void 0,f=S!=null?v.sessionDetail[S]??v.sessions.find((h=>h.id===S)):void 0;r.useEffect((()=>{i&&(t(Ke()),t(jn()))}),[i,t]),r.useEffect((()=>{if(m!=null)return;const h=(y=>{if(y==null||y==="")return null;try{return sessionStorage.getItem(Xn(y))}catch{return null}})(n);h!=null&&t(me(h))}),[m,t,n]),r.useEffect((()=>{ve(n,m)}),[m,n]);const I=f?.status,C=I==="scanning"||I==="importing";return r.useEffect((()=>{if(!i||S==null||!C)return;const h=setInterval((()=>{t(_e(S))}),3e3);return()=>clearInterval(h)}),[i,S,C,t]),r.useEffect((()=>{I==="done"&&(t(me(null)),ve(n,null))}),[t,I,n]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDataImportMigratePage}),c.jsx(pa,{activeId:S,authParams:s,integrationsView:p,navigate:e,settings:a,templatesDownloadUrl:u,tenantEmailDomain:n,view:v,onBack:()=>{t(me(null)),ve(n,null),e(`/${n}/invoicing/data_import`)}})]})}const fa=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,discountsAccountName:n.discountsAccountName,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${n}/discounts`),onLifecycleAction:a=>{g.trackInvoicingActionClick(l.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discount_detail",status:e.editView.coupon?.status}),t(Ln({action:a,id:i}))},onSaveEdit:a=>{const{coupon:o}=e.editView;g.trackInvoicingActionClick(l.Event.invoicingCouponEdited,{couponId:i,mode:"edit",...B(a,{invoice_name:o?.invoiceName,invoice_notes:o?.invoiceNotes,max_redemptions:o?.maxRedemptions,name:o?.name},["invoice_notes"])}),t(Di({data:a,id:i}))}}}))(xt);function Ia(){const t=$(),e=L(),{coupon_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),o=E((I=>Ai(I,n))),s=o.actionState.fetchState==="In-Progress",u=o.pageFetchState.fetchState,d=u==="Completed",[p,v]=r.useState(d?n:void 0);r.useEffect((()=>{n!=null&&d&&v(n)}),[n,d]);const m=p===n;r.useEffect((()=>(t(Y({id:n})),()=>{t(Y({id:n}))})),[n,t]),r.useEffect((()=>{a&&t(we({id:n}))}),[a,n,t]);const S=r.useCallback((I=>t(we({cacheOverride:!0,id:I}))),[t]),f=se(o.fetchState,o.isFormLoading,n,S);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDiscountDetailPage,isReady:d}),c.jsx(fa,{hasLoadedRecord:m,couponId:n??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:s,navigate:e,tenantEmailDomain:i},f)]})}const ha=O((function(t){const e=Pn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,discountLifecycleActionOptions:e.discountLifecycleActionOptions,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",coupons:e.coupons,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.coupons.length===0,isLoadingMore:n==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,a)=>{g.trackInvoicingActionClick(l.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discounts_list"}),t(Ln({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"discounts",status:e.activeStatus}),t($i({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(At);function Ca(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,couponListFetchState:h,runningDiscountActionId:y}=E((b=>{const A=Pn(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,couponListFetchState:A.fetchState,runningDiscountActionId:A.runningActionId??null}}),z),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(Ae({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Ae({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDiscountsListPage,isReady:D}),c.jsx(ha,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,runningDiscountActionId:y,onSearchChange:o,onStatusChange:b=>{t(ji(b)),t(Ae({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const ka=O((function(t,e){const{readView:n}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:n.dunningCase,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress",step:n.step}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,a=i!=="",{dunningCase:o}=e.readView,s={amount:o?.amount?.amount,caseId:i,customerId:o?.customerID,invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID};return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:u=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:u,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(u)}`)},onCancel:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"cancel",fromScreen:"dunning_detail"}),t(K({action:"cancel",id:i}))}:void 0,onResolve:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"resolve",fromScreen:"dunning_detail"}),t(K({action:"resolve",id:i}))}:void 0,onResume:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"resume",fromScreen:"dunning_detail"}),t(K({action:"resume",id:i}))}:void 0,onRetry:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"retry",fromScreen:"dunning_detail"}),t(K({action:"retry",id:i}))}:void 0}}))(jt);function Ea(){const t=$(),e=L(),{case_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),o=E((k=>Li(k,n??""))),s=o.fetchState==="Completed",u=o.dunningCase?.invoiceID,[d,p]=r.useState("idle"),[v,m]=r.useState(!1),[S,f]=r.useState(),[I,C]=r.useState(!1),h=r.useCallback((()=>{p("idle"),m(!1),f(void 0),C(!1)}),[]),y=r.useCallback((()=>{if(n==null)return;t(Pi({id:n})),p("idle"),m(!1);const k=o.emailPreview.preview;f(k==null?void 0:{body:k.body,cc:k.cc,subject:k.subject,to:k.to}),C(!0)}),[n,t,o.emailPreview.preview]),D=r.useCallback((k=>{n!=null&&d!=="pending"&&(m(!1),p("pending"),g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{action:"send-email",amount:o.dunningCase?.amount?.amount,caseId:n,customerId:o.dunningCase?.customerID,fromScreen:"dunning_detail",invoiceId:o.dunningCase?.invoiceID,status:o.dunningCase?.status,subscriptionId:o.dunningCase?.subscriptionID}),t(K({action:"send-email",body:k,id:n})))}),[n,t,d,o.dunningCase]),b=r.useMemo((()=>o.emailPreview.preview==null?void 0:{bodyToken:o.emailPreview.preview.bodyToken,renderedHtmlTemplate:o.emailPreview.preview.renderedHtmlTemplate,subjectToken:o.emailPreview.preview.subjectToken}),[o.emailPreview.preview]);r.useEffect((()=>{a&&n!=null&&t(wi({id:n}))}),[a,n,t]),r.useEffect((()=>{a&&u!=null&&t(ke({invoiceId:u}))}),[a,u,t]),r.useEffect((()=>{p("idle"),m(!1),f(void 0),C(!1)}),[n]),r.useEffect((()=>{a||(p("idle"),m(!1),f(void 0),C(!1))}),[a]),r.useEffect((()=>{I&&S==null&&o.emailPreview.preview!=null&&f({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,S,I]),r.useEffect((()=>{d==="pending"&&(o.actionState.fetchState!=="In-Progress"?v&&o.actionState.fetchState==="Completed"?(n!=null&&t(Ri({id:n})),h()):v&&o.actionState.fetchState==="Error"&&p("failed"):m(!0))}),[n,h,t,d,v,o.actionState.fetchState]);const A=u!=null&&o.linkedInvoice?.id===u?o.linkedInvoice.dunningAttempts:void 0;return N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDunningDetailPage,isReady:s}),c.jsx(ka,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:o,dunningAttempts:A,onSendEmail:y}),c.jsx(Dt,{initialDraft:S,isPreviewLoading:o.emailPreview.fetchState==="Not-Started"||o.emailPreview.fetchState==="In-Progress",isSending:d==="pending",onClose:h,onSend:D,open:I,preview:b,previewErrorMessage:o.emailPreview.fetchState==="Error"?o.emailPreview.error?.message:void 0,sendErrorMessage:d==="failed"?o.actionState.error?.message:void 0})]})}const ya=O((function(t){const e=wn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:n==="In-Progress"&&e.dunningCases.length>0,stepById:e.stepById,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=a=>{const o=e.dunningCases.find((s=>s.id===a));return{amount:o?.amount?.amount,caseId:a,customerId:o?.customerID,fromScreen:"dunning_list",invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID}};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${n}/data_import`),onDunningCaseClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingDunningCaseRowClicked,i(a)),e.navigate(`${n}/dunning/${encodeURIComponent(a)}`)},onRowAction:(a,o)=>{o!=="retry"&&o!=="resume"&&o!=="resolve"&&o!=="cancel"||(g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...i(a),action:o}),t(K({action:o,id:a})))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"dunning",status:e.activeStatus}),t(Fi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))($t);function ba(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,dunningCaseListFetchState:h,dunningCases:y}=E((b=>{const A=wn(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,dunningCaseListFetchState:A.fetchState,dunningCases:A.dunningCases}}),z),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(De({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(De({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDunningListPage,isReady:D}),c.jsx(ya,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:d,filters:m,sort:v,dunningCases:y,nextCursor:C,onSearchChange:o,onStatusChange:b=>{t(_i(b)),t(De({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const xa=O((function(t,e){const{view:n}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:n.billingAddress,invoice:n.invoice,invoiceId:e.invoiceId,shippingAddress:n.shippingAddress,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isSaving:n.actionState.fetchState==="In-Progress",isVoiding:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e,{invoice:a}=e.view,o={amount:a?.total?.amount,customerId:a?.customerID,invoiceId:i,status:a?.status};return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(s)}`)},onIssueCreditNote:()=>{g.trackInvoicingActionClick(l.Event.invoicingIssueCreditNoteClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{g.trackInvoicingActionClick(l.Event.invoicingRecordPaymentClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceRegenerated,{...o,fromScreen:"invoice_detail"}),t(q({action:"regenerate",invoiceId:i}))},onSaveEdit:s=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceEdited,{...o,fromScreen:"invoice_detail",mode:"edit",...B(s,{due_date:a?.dueDate?.format("YYYY-MM-DD")??"",notes:(a?.notes??[]).map((u=>u.note)).filter((u=>u!=null&&u!=="")).join(`
2
- `),po_number:a?.poNumber??""},["notes"])}),t(Oi({data:{due_date:s.due_date!==""?s.due_date:void 0,notes:s.notes.trim()!==""?s.notes.split(`
3
- `).map((u=>u.trim())).filter((u=>u!=="")).map((u=>({note:u}))):void 0,po_number:s.po_number!==""?s.po_number:null},invoiceId:i}))},onSendReminder:()=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceReminderSent,{...o,fromScreen:"invoice_detail"}),t(q({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:s,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(s)}`)},onVoid:s=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,{...o,fromScreen:"invoice_detail"}),t(q({action:"void",invoiceId:i,body:s}))}}}))(Lt);function Aa(){const t=$(),e=L(),{invoice_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),o=E((f=>Rn(f,n??""))),s=o.pageFetchState.fetchState,u=s==="Completed",[d,p]=r.useState(u?n:void 0);r.useEffect((()=>{n!=null&&u&&p(n)}),[n,u]);const v=d===n;r.useEffect((()=>{a&&n!=null&&t(Ti({invoiceId:n}))}),[a,n,t]);const m=r.useCallback((f=>t(ke({invoiceId:f}))),[t]),S=se(o.actionState.fetchState,o.fetchState==="In-Progress",n,m);return N(s)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingInvoiceDetailPage,isReady:u}),c.jsx(xa,{invoiceId:n??"",hasLoadedRecord:v,navigate:e,tenantEmailDomain:i,view:o},S)]})}const Da=O((function(t){const e=_n(t),{fetchState:n}=e;return{counts:e.counts,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,invoices:e.invoices,statusOptions:e.statusOptions,isLoading:n==="Not-Started"||n==="In-Progress"&&e.invoices.length===0,isLoadingMore:n==="In-Progress"&&e.invoices.length>0,kpis:e.kpis,kpisLoading:e.kpisFetchState.fetchState==="Not-Started"||e.kpisFetchState.fetchState==="In-Progress"&&e.kpis==null,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=a=>{const o=e.invoices.find((s=>s.id===a));return{amount:o?.total?.amount,customerId:o?.customerID,fromScreen:"invoices_list",invoiceId:a,status:o?.status}};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onCreateInvoice:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked),e.navigate(`${n}/invoices/create`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"invoices"}),e.navigate(`${n}/data_import`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceRowClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onRowAction:(a,o)=>{switch(o){case"recordPayment":g.trackInvoicingActionClick(l.Event.invoicingRecordPaymentClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}/record-payment`);break;case"issueCreditNote":g.trackInvoicingActionClick(l.Event.invoicingIssueCreditNoteClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}/issue-credit-note`);break;case"sendReminder":g.trackInvoicingActionClick(l.Event.invoicingInvoiceReminderSent,i(a)),t(q({action:"send-reminder",invoiceId:a}));break;case"regenerate":g.trackInvoicingActionClick(l.Event.invoicingInvoiceRegenerated,i(a)),t(q({action:"regenerate",invoiceId:a}));break;case"void":g.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,i(a)),t(q({action:"void",invoiceId:a}))}},onVoidInvoice:(a,o)=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,i(a)),t(q({action:"void",invoiceId:a,body:o}))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"invoices",status:e.activeStatus}),t(Fn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Pt);function ja(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,invoiceListFetchState:h,voidingInvoiceId:y,invoices:D}=E((A=>{const k=_n(A);return{activeStatus:k.activeTab,appliedSearch:k.filters.search,appliedSort:A.invoicingInvoiceListState.sort,nextCursor:k.nextCursor,invoiceListFetchState:k.fetchState,voidingInvoiceId:k.runningActionId,invoices:k.invoices}}),z),b=h==="Completed";return r.useEffect((()=>{const A=setTimeout((()=>u(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&t(je({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(je({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingInvoicesListPage,isReady:b}),c.jsx(Da,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:d,filters:m,sort:v,invoices:D,nextCursor:C,voidingInvoiceId:y,onSearchChange:o,onStatusChange:A=>{t(Mi(A)),t(je({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}function un(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),i=wt(),a=pn(),[o,s]=r.useState(!1),{acceptTermsState:u,status:d}=E(Tn),p=Ni(i?.loggedInUserRoleMap),v=`/${n}/invoicing`,m=S=>{s(S)};return d==="completed"?c.jsx(H,{to:`${v}/overview`,replace:!0}):d==="settings"&&p?c.jsx(H,{to:`${v}/settings`,replace:!0}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingPromoPage}),c.jsx(No,{isAppContentDrawerOpen:o,handleDrawerToggle:m}),c.jsx(Rt,{analytics:g,isAccepting:u.fetchState==="In-Progress",isReadOnlyUser:!p,meetingUrl:a("invoicing_promo"),onAcceptClick:()=>{g.trackInvoicingActionClick(l.Event.invoicingTermsAccepted),t(Ui())},onBackClick:()=>{e(`/${n}`)},onClickMenuIcon:()=>{m(!0)}})]})}const $a=O((function(t,e){const n=On(t,e.invoiceId),{invoice:i,localData:a,reasonCodeOptions:o,submitState:s,typeOptions:u}=n;return{fieldHelp:n.fieldHelp,amountDue:i?.amountDue,currencyCode:i?.currencyCode??"USD",customerName:i?.customerName??"",errorMessage:s.fetchState==="Error"?s.error?.message??"Failed to issue credit note. Please try again.":void 0,invoiceNumber:i?.invoiceNumber??e.invoiceId,isSubmitting:s.fetchState==="In-Progress",localData:a,reasonCodeOptions:o,typeOptions:u}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing/invoices/${encodeURIComponent(e.invoiceId)}`,i=()=>e.navigate(n);return{onBack:i,onCancel:i,onChange:a=>{t(qi({localData:a}))},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreditNoteIssued,{invoiceId:e.invoiceId}),t(Hi())}}}))(_t);function La(){const t=$(),e=L(),{invoice_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),{fetchState:o,invoice:s,isPageReady:u,issuedCreditNoteId:d,submitState:p}=E((f=>On(f,n??""))),v=`/${i}/invoicing`,m=r.useRef(null);r.useEffect((()=>(t(sn()),m.current=null,()=>{t(sn())})),[t,n]),r.useEffect((()=>{a&&n!=null&&t(ke({invoiceId:n}))}),[a,t,n]),r.useEffect((()=>{s!=null&&n!=null&&o==="Completed"&&m.current!==n&&(m.current=n,t(Bi({localData:Vi(s)})))}),[t,o,s,n]);const S=r.useRef(p.fetchState);return r.useEffect((()=>{const f=S.current;S.current=p.fetchState,f!=="Completed"&&p.fetchState==="Completed"&&d!=null&&e(`${v}/credits/${encodeURIComponent(d)}`)}),[d,e,p.fetchState,v]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingIssueCreditNotePage,isReady:u}),c.jsx($a,{invoiceId:n??"",navigate:e,tenantEmailDomain:i})]})}const Pa=O((function(t){return{invoicingOverview:Mn(t)}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onRefresh:()=>{g.trackInvoicingActionClick(l.Event.invoicingOverviewRefreshed),t(Nn(e.selectedPeriod,!0))},onSubscriptionClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionTileClicked,{subscriptionId:i}),e.navigate(`${n}/subscriptions/${i}`)},onViewInvoices:()=>{g.trackInvoicingActionClick(l.Event.invoicingViewInvoicesClicked),e.navigate(`${n}/invoices`)},onViewPayments:()=>{g.trackInvoicingActionClick(l.Event.invoicingViewPaymentsClicked),e.navigate(`${n}/payments`)}}}))(Ft);function wa(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a]=r.useState((()=>{const s=new Date;return{month:s.getMonth()+1,year:s.getFullYear()}})),o=E((s=>Mn(s).fetchState))==="Completed";return r.useEffect((()=>{i&&t(Nn(a))}),[i,t,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingOverviewPage,isReady:o}),c.jsx(Pa,{navigate:e,selectedPeriod:a,tenantEmailDomain:n})]})}const Ra=O((function(t){const e=Un(t),{fetchState:n}=e;return{columns:e.columns,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.transactions.length===0,isLoadingMore:n==="In-Progress"&&e.transactions.length>0,tabIds:e.tabIds,transactions:e.transactions}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeType:e.activeType,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTypeChange:e.onTypeChange,onViewTransactionCustomer:e.onViewTransactionCustomer,onViewTransactionInvoice:e.onViewTransactionInvoice,onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"payments"}),e.navigate(`${n}/data_import`)},onTransactionClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentRowClicked,{transactionId:i}),e.navigate(`${n}/payments/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"payments",tab:e.activeType}),t(zi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Tt);function _a(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeType:S,appliedSearch:f,appliedSort:I,nextCursor:C,transactionListFetchState:h,transactions:y}=E((j=>{const _=Un(j);return{activeType:_.activeTab,appliedSearch:_.filters.search,appliedSort:_.sort,nextCursor:_.nextCursor,transactionListFetchState:_.fetchState,transactions:_.transactions}}),z),D=h==="Completed",b=`/${n}/invoicing`,A=r.useCallback((j=>{const _=y.find((T=>T.id===j)),U=_?.linkedInvoices?.[0]?.invoiceID??_?.invoiceID;U!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"payments_list",invoiceId:U,toScreen:"invoice"}),e(`${b}/invoices/${encodeURIComponent(U)}`))}),[e,b,y]),k=r.useCallback((j=>{const _=y.find((U=>U.id===j))?.customerID;_!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:_,fromScreen:"payments_list",toScreen:"customer"}),e(`${b}/customers/${encodeURIComponent(_)}`))}),[e,b,y]);return r.useEffect((()=>{const j=setTimeout((()=>u(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t($e({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t($e({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingPaymentsListPage,isReady:D}),c.jsx(Ra,{navigate:e,tenantEmailDomain:n,activeType:S,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,onSearchChange:o,onTypeChange:j=>{t(Qi(j)),t($e({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p,onViewTransactionCustomer:k,onViewTransactionInvoice:A})]})}const Fa=t=>{const e=[t.firstName,t.lastName].filter((n=>n!=null&&n.trim()!=="")).join(" ").trim();return(t.company!=null&&t.company.trim()!==""?t.company.trim():"")||e||(t.email!=null&&t.email.trim()!==""?t.email.trim():"")||t.id};function gn(){const t=$(),e=L(),{invoice_id:n,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=F(),o=n!=null&&n!=="",s=E(he),u=E((k=>Ki(k))),d=E(Gi),p=E((k=>Rn(k,n??""))),v=p.invoice,m=`/${i}/invoicing`,S=r.useRef(null),f=r.useRef("");r.useEffect((()=>{t(Wi()),S.current=null,f.current=""}),[t,n]),r.useEffect((()=>{a&&t(o&&n!=null?ke({invoiceId:n}):An({filters:{},keepExistingListItems:!1}))}),[a,t,n,o]),r.useEffect((()=>{o&&v!=null&&n!=null&&p.fetchState==="Completed"&&S.current!==n&&(S.current=n,t(Yi({contextInvoiceId:n,localData:Ji(v)})))}),[t,v,n,p.fetchState,o]),r.useEffect((()=>{if(o)return;const k=u.localData.customerId;k!==""&&k!==f.current&&(f.current=k,t(Fn({filters:{customerId:k},keepExistingListItems:!1})),u.localData.invoiceToLink!==""&&t(rn({localData:{...u.localData,customerId:k,invoiceToLink:""}})))}),[t,u.localData,o]);const I=r.useRef(d.fetchState);r.useEffect((()=>{const k=I.current;if(I.current=d.fetchState,k!=="Completed"&&d.fetchState==="Completed"){if(d.recordedInvoiceId!=null)return void e(`${m}/invoices/${encodeURIComponent(d.recordedInvoiceId)}`);e(`${m}/payments`)}}),[e,d.fetchState,d.recordedInvoiceId,m]);const C=r.useMemo((()=>s.customers.map((k=>({id:k.id,name:Fa(k)})))),[s.customers]),h=E((k=>Zi(k,u.localData.customerId))),y=r.useMemo((()=>h.map((k=>{return{amountDue:(j=k.amountDue,_=Xi.currencySymbol,Nt("0,0.00",j,_)),amountDueValue:k.amountDue,id:k.id,label:k.invoiceNumber};var j,_}))),[h]),D=r.useMemo((()=>{if(!o||v==null)return;const k=v.currencyCode??"USD",j=v.amountDue?.amount??0;return{amountDue:Ot("0,0.00",v.amountDue),amountDueValue:j,currencyCode:k,customerName:v.customerName??v.customerID,invoiceId:v.id,invoiceNumber:v.invoiceNumber??v.id}}),[v,o]),b=o?`${m}/invoices/${encodeURIComponent(n??"")}`:`${m}/payments`,A=!o||p.fetchState==="Completed"&&u.localData.invoiceToLink!=="";return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingRecordPaymentPage,isReady:A}),c.jsx(Mt,{customers:C,fieldHelp:u.fieldHelp,errorMessage:d.fetchState==="Error"?d.error?.message??"Failed to record payment. Please try again.":void 0,gatewayOptions:u.gatewayOptions,invoiceContext:D,invoiceOptions:y,isSubmitting:d.fetchState==="In-Progress",localData:u.localData,mode:o?"invoice":"customer",paymentMethodOptions:u.paymentMethodOptions,onBack:()=>{e(b)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingRecordPaymentCancelled),e(b)},onChange:k=>{t(rn({localData:k}))},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentRecorded,{customerId:u.localData.customerId,invoiceId:o?n:u.localData.invoiceToLink,paymentMethod:u.localData.paymentMethod}),t(eo(o?n??void 0:void 0))}})]})}const et=(t,e,n)=>{const i=`/${t}/invoicing/subscriptions/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},Ta=O((function(t,e){const{editView:n}=e,i=n.subscription,a=i?.status,o=a!=null&&e.commercialEditAllowedFromStatuses.includes(a);return{cancelReasonCodeOptions:n.cancelReasonCodeOptions,fieldHelp:n.fieldHelp,addons:n.addons,canEditCommercial:o,charges:n.charges,coupons:n.coupons,estimate:n.estimate,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),isRunningAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",lifecycleActionOptions:e.lifecycleActionOptions,localData:n.localData,plans:n.plans,shippingAddressLabel:n.shippingAddressLabel,hasUnsavedShippingAddress:n.hasUnsavedShippingAddress,subscription:i}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,a=i!=="",o=(s,u)=>{const{subscription:d}=e.editView;g.trackInvoicingActionClick(l.Event.invoicingSubscriptionLifecycleAction,{action:s,amount:d?.mrr?.amount,customerId:d?.customerID,fromScreen:"subscription_detail",status:d?.status,subscriptionId:i}),t(Hn({action:s,id:i,body:u}))};return{onBack:()=>e.navigate(`${n}/subscriptions`),onChange:s=>{t(ee({id:i,localData:s}))},onChangeTermEnd:a?s=>{const u=s?.trim()??"";u!==""&&o("change_term_end",{term_ends_at:u})}:void 0,onCustomerClick:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${n}/customers/${encodeURIComponent(s)}`,"_blank","noopener,noreferrer")},onDiscardEdit:()=>{t(Q(ie)),t(io({id:i}))},onOpenAddress:()=>{const s=et(e.tenantEmailDomain??"",ie,i),u=ce(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(s,{state:{pathnameStackToGoBack:u}})},onViewInvoices:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"subscription_detail",subscriptionId:i,toScreen:"invoices"}),e.navigate(`${n}/invoices`)},onCloseEstimate:()=>{t(We())},onRequestEstimate:s=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionEstimateCalculation,{mode:"edit",subscriptionId:i,...B(s,Te(e.editView.subscription))}),t(ee({id:i,localData:s})),t(Vn({id:i}))},onSaveEdit:s=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionEdited,{mode:"edit",subscriptionId:i,...B(s,Te(e.editView.subscription))}),t(ee({id:i,localData:s})),t(Bn({id:i}))},onCancelSubscription:a?s=>{o("cancel",{cancel_reason_code:s.cancelReasonCode,end_of_term:!1,...s.cancelReason!=null&&s.cancelReason.trim()!==""?{cancel_reason:s.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:a?(s,u)=>{s!=="pause"?o(s):o(s,u!=null&&u.trim()!==""?{resume_date:u.trim()}:void 0)}:void 0}}))(Ut);function Oa(){const t=$(),e=L(),n=ae(),{subscription_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=F(),s=E((y=>Ge(y,i))),{subscriptionCommercialEditAllowedFromStatuses:u,subscriptionLifecycleActionOptions:d,subscriptionMetadataEditAllowedFromStatuses:p}=s,v=s.pageFetchState.fetchState,m=v==="Completed"&&!s.isFormLoading,[S,f]=r.useState(m?i:void 0);r.useEffect((()=>{i!=null&&m&&f(i)}),[i,m]);const I=S===i;Ee(o),r.useEffect((()=>{o&&i!=null&&t(no({id:i}))}),[o,i,t]);const C=r.useCallback((y=>t(to({id:y}))),[t]),h=se(s.fetchState,s.isFormLoading,i,C);return N(v)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingSubscriptionDetailPage,isReady:m}),c.jsx(Ta,{hasLoadedRecord:I,commercialEditAllowedFromStatuses:u,editView:s,lifecycleActionOptions:d,location:n,metadataEditAllowedFromStatuses:p,navigate:e,subscriptionId:i??"",tenantEmailDomain:a},h)]})}const Ma=O((function(t,e){const n=Ge(t,e.subscriptionId);return{fieldHelp:n.fieldHelp,addons:n.addons,charges:n.charges,coupons:n.coupons,customers:n.customers,estimate:n.estimate,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save subscription.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,plans:n.plans,savedSubscription:n.subscription,shippingAddressLabel:n.shippingAddressLabel}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e;return{onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionFormCancelled),t(Oe({id:i})),t(Q(ie)),i==null?e.navigate(`${n}/subscriptions`):e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)},onChange:a=>{t(ee({id:i,localData:a}))},onCloseEstimate:()=>{t(We())},onRequestEstimate:()=>{t(Vn({id:i}))},onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"subscription",fromScreen:"subscription_form"});const a=et(e.tenantEmailDomain??"",ie,i),o=ce(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.keepDraftOnLeave(),e.navigate(a,{state:{pathnameStackToGoBack:o}})},onSubmit:()=>{t(Bn({id:i}))}}}),(function({savedSubscription:t,...e},n,i){const a=()=>({mode:e.mode,subscriptionId:i.subscriptionId,...B(e.localData,t!=null?Te(t):void 0)});return{...i,...e,...n,onRequestEstimate:()=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionEstimateCalculation,a()),n.onRequestEstimate()},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionSaved,a()),n.onSubmit()}}}))(Bt);function Na(){const t=$(),e=L(),n=ae(),{subscription_id:i,tenantEmailDomain:a}=R(),[o]=oe(),{areTenantIdsInSync:s}=F(),u=o.get("customerId"),{fetchState:d,savedSubscriptionId:p}=E((C=>oo(C,i))),v=E((C=>Ge(C,i).localData));Ee(s);const m=r.useRef(!1),S=r.useCallback((()=>{m.current=!0}),[]),f=r.useRef();r.useEffect((()=>(clearTimeout(f.current),m.current=!1,()=>{m.current||(f.current=setTimeout((()=>{t(Oe({id:i})),t(Q(ie)),t(We())}),0))})),[i,t]),r.useEffect((()=>{s&&t(ao({subscriptionId:i}))}),[s,i,t]);const I=r.useRef(!1);return r.useEffect((()=>{I.current||i!=null||u==null||u===""||v.customerId!==""||(I.current=!0,t(ee({id:i,localData:{...v,customerId:u}})))}),[u,i,v,t]),r.useEffect((()=>{if(d==="Completed"){const C=p??i,h=C!=null?`/${a}/invoicing/subscriptions/${encodeURIComponent(C)}`:`/${a}/invoicing/subscriptions`;e(h),t(Oe({id:i}))}}),[d,p,i,t,e,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingSubscriptionFormPage}),c.jsx(Ma,{keepDraftOnLeave:S,location:n,navigate:e,subscriptionId:i,tenantEmailDomain:a})]})}const Ua=O((function(t){const e=qn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.subscriptions.length===0,isLoadingMore:n==="In-Progress"&&e.subscriptions.length>0,cancelReasonCodeOptions:e.cancelReasonCodeOptions,lifecycleActionOptions:e.subscriptionLifecycleActionOptions,subscriptions:e.subscriptions,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=(a,o,s)=>{const u=e.subscriptions.find((d=>d.id===a));g.trackInvoicingActionClick(l.Event.invoicingSubscriptionLifecycleAction,{action:o,amount:u?.mrr?.amount,customerId:u?.customerID,fromScreen:"subscriptions_list",status:u?.status,subscriptionId:a}),t(Hn({action:o,id:a,body:s}))};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onAddSubscription:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked),e.navigate(`${n}/subscriptions/new`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"subscriptions"}),e.navigate(`${n}/data_import`)},onChangeTermEnd:(a,o)=>{const s=o?.trim()??"";s!==""&&i(a,"change_term_end",{term_ends_at:s})},onSubscriptionAction:(a,o,s)=>{o!=="pause"?i(a,o):i(a,o,s!=null&&s.trim()!==""?{resume_date:s.trim()}:void 0)},onCancelSubscription:(a,o)=>{i(a,"cancel",{cancel_reason_code:o.cancelReasonCode,end_of_term:!1,...o.cancelReason!=null&&o.cancelReason.trim()!==""?{cancel_reason:o.cancelReason.trim()}:{}})},onSubscriptionClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionRowClicked,{subscriptionId:a}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onViewSubscriptionInvoices:()=>{e.navigate(`${n}/invoices`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"subscriptions",status:e.activeStatus}),t(ro({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Vt);function Ba(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:C,subscriptionListFetchState:h,runningActionSubscriptionId:y,subscriptions:D}=E((k=>{const j=qn(k);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:j.sort,nextCursor:j.nextCursor,subscriptionListFetchState:j.fetchState,runningActionSubscriptionId:j.runningActionId??null,subscriptions:j.subscriptions}}),z),b=h==="Completed";r.useEffect((()=>{const k=setTimeout((()=>u(a)),300);return()=>clearTimeout(k)}),[a]),r.useEffect((()=>{i&&t(Le({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Le({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]);const A=r.useRef(y);return r.useEffect((()=>{const k=A.current!=null&&y==null;A.current=y,k&&i&&t(co())}),[y,i,t]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingSubscriptionsListPage,isReady:b}),c.jsx(Ua,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,runningActionSubscriptionId:y,subscriptions:D,onSearchChange:o,onStatusChange:k=>{t(so(k)),t(Le({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const Va=O((function(t,e){const{readView:n}=e;return{isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress",transaction:n.transaction,transactionId:e.transactionId}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{transactionId:i}=e;return{onBack:()=>e.navigate(`${n}/payments`),onCustomerClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"transaction_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(a)}`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onSubscriptionClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onCapture:i!==""?()=>{g.trackInvoicingActionClick(l.Event.invoicingTransactionCaptured,{transactionId:i}),t(go({action:"capture",id:i}))}:void 0}}))(Ht);function Ha(){const t=$(),e=L(),{tenantEmailDomain:n,transaction_id:i}=R(),{areTenantIdsInSync:a}=F(),o=E((u=>lo(u,i??""))),s=o.fetchState==="Completed";return r.useEffect((()=>{a&&i!=null&&t(uo({id:i}))}),[a,i,t]),N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingTransactionDetailPage,isReady:s}),c.jsx(Va,{navigate:e,tenantEmailDomain:n,transactionId:i??"",readView:o})]})}function nt(t={}){const{enabled:e=!0,fetchSyncHealth:n=!1,loadAccountingPickers:i=!1,reuseCached:a=!1}=t,o=$(),{areTenantIdsInSync:s}=F(),u=E(Ye),d=u.connection?.connected===!0,p=u.connectionFetchState.fetchState;return r.useEffect((()=>{e&&s&&(a&&p!=="Not-Started"||o(Qn()),n&&o(mo()))}),[s,o,e,n,a]),r.useEffect((()=>{e&&s&&d&&i&&o(vo())}),[s,o,e,d,i]),{isQboConnected:d,qboView:u}}const qa={branding:"invoicing_branding_save",dunning:"invoicing_dunning_settings_save",quickbooks:"invoicing_qbo_settings_save"};function re(t){const e=$(),{areTenantIdsInSync:n}=F(),{tenantEmailDomain:i}=R(),{fetchState:a,fieldHelp:o,logoFile:s,saveState:u,settings:d,stripeConnectState:p}=E(po),{configError:v,configFetchState:m,dunningScheduleActionOptions:S,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:I,qboSyncStatusOptions:C}=E(zn),h=E(Ye);nt({enabled:t==="quickbooks",fetchSyncHealth:!0,loadAccountingPickers:!0});const y=E(Ce),D=t==="dunning"||t==="quickbooks",b=y.companyId??te.getSignedInUserTenant(i??"")?.companyId,A=E((P=>$n(P,b))),k=So(y.userRole??[]),j=y.tenantId??"",_=te.getSignedInUser(),U={userId:_?.userId??"",sessionId:_?.zeniSessionId??"",tenantId:j},T=s?.fileId,de=E((P=>T!=null&&T!==""?fo(P,T):void 0)),Je=E((P=>T!=null&&T!==""?Io(P,T):void 0)),tt=T!=null&&T!==""&&de!=null?{[T]:de}:{},it=T!=null&&T!==""&&Je!=null?{[T]:Je}:{};r.useEffect((()=>(e(dn()),()=>{e(dn())})),[e]),r.useEffect((()=>{n&&(a!=="Not-Started"&&a!=="Error"||e(Ke()))}),[n,e,a]),r.useEffect((()=>{n&&D&&m==="Not-Started"&&e(ne())}),[n,e,m,D]),r.useEffect((()=>{if(!n)return;const P=_?.userId;P!=null&&P!==""&&j!==""&&en.shouldFetchActiveTenant(j)&&(en.markActiveTenantFetchStarted(j),e(ho(P,j,_?.zeniSessionId)))}),[n,e,_?.userId,_?.zeniSessionId,j]);const ot=S.length>0||f.length>0,at=a==="Not-Started"||a==="In-Progress"&&d==null||D&&!ot&&(m==="Not-Started"||m==="In-Progress"),ct=a==="Completed"&&(!D||m==="Completed"),Ze=A.externalConnections?.revenue?.find((P=>P.connectionName==="chargebee"))?.connectionId,ye=pe?.invoicingMicroServiceBaseUrl,Xe=ye!=null&&ye.length>0?`${ye}/1.0/webhooks/stripe`:"",J={deleteConnectionError:A.externalConnections?.deleteConnectionError?.message,deleteConnectionState:A.externalConnections?.deleteConnectionState??"Not-Started",integrationsView:A,isAdmin:k,isStripeBusy:p.fetchState==="In-Progress",onConnectStripe:P=>{g.trackInvoicingActionClick(l.Event.invoicingStripeConnectClicked,{fromScreen:t??"hub"}),e(jo(P))},onDisconnect:(P,V)=>{j!==""&&(g.trackInvoicingActionClick(l.Event.invoicingIntegrationDisconnected,{entity:V,entityId:P,fromScreen:t??"hub"}),e(Do(j,P,ln(V))))},onDisconnectStripe:()=>{g.trackInvoicingActionClick(l.Event.invoicingStripeDisconnected,{fromScreen:t??"hub"}),e(Ao())},onReconnectQBO:()=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"reconnect",fromScreen:t??"hub"});const P=y.tenantEmailDomain??i??"";Ie.init("/connection/auth",P),Ie.handleClick()},onRefreshQBO:()=>{A.integrations.refreshQBO.fetchState!=="In-Progress"&&(g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"refresh",fromScreen:t??"hub"}),e(Wn()))},onSaveChargeBeeCredentials:(P,V)=>{Ze!=null&&j!==""&&(g.trackInvoicingActionClick(l.Event.invoicingChargebeeCredentialsSaved,{fromScreen:t??"hub"}),e(bo(j,Ze,ln("revenue"),xo("chargebee"),{api_key:P,site:V})))},saveChargeBeeError:A.externalConnections?.saveAPIKeyConnectionError?.message,saveChargeBeeState:A.externalConnections?.saveAPIKeyConnectionState??"Not-Started",settings:d,stripeError:p.fetchState==="Error"?p.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Xe};return{authParams:U,deleteFileStatusById:tt,fieldHelp:o,dunningScheduleActionOptions:S,filesEndPoint:pe?.fileMicroServiceBaseUrl??"",integrationsSectionProps:J,isInvoicingPageReady:ct,isLoading:at,isSaving:u.fetchState==="In-Progress",isStripeBusy:p.fetchState==="In-Progress",logoFile:s,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:I,qboSyncStatusOptions:C,qboView:h,saveErrorMessage:u.fetchState==="Error"?u.error?.message??"Failed to save settings.":D&&m==="Error"?v?.message??"Failed to load invoicing configuration.":void 0,settings:d,stripeError:p.fetchState==="Error"?p.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Xe,updateFileStatusById:it,onConnectStripe:J.onConnectStripe,onDeleteFile:P=>{g.trackInvoicingActionClick(l.Event.invoicingLogoRemoved,{fromScreen:t??"hub"}),e(yo(P,j))},onDisconnectStripe:J.onDisconnectStripe,onEditFileName:(P,V)=>{g.trackInvoicingActionClick(l.Event.invoicingLogoRenamed,{fromScreen:t??"hub"}),e(Eo(P,V.split(".")[0],j))},onReconnectQBO:J.onReconnectQBO,onRefreshQBO:J.onRefreshQBO,onRetryQboSyncTask:P=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"retry_task",entityId:P,fromScreen:t??"hub"}),e(Gn(P))},onSave:P=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{fieldsChanged:Object.keys(P).filter((V=>JSON.stringify(P[V])!==JSON.stringify(d?.[V]))),tab:t??"hub"}),e(ko({settings:P,snackbarSection:qa[t??""]}))},onStartQboBackfill:P=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"backfill",fromScreen:t??"hub"}),e(Kn(P))},updateFilesEntity:P=>{g.trackInvoicingActionClick(l.Event.invoicingLogoUploaded,{fromScreen:t??"hub"}),e(Co({files:P}))}}}function mn({appContent:t}){const e=L(),n=ae(),i=$(),{tenantEmailDomain:a}=R(),o=re("branding"),s=E((d=>$o(d)));r.useEffect((()=>{s.saveState.fetchState==="Completed"&&i(Lo())}),[s.saveState.fetchState,i]);const u=Ue(s.saveState.fetchState);return r.useEffect((()=>{u==="In-Progress"&&s.saveState.fetchState==="Completed"&&e("..")}),[u,s.saveState.fetchState,e]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingBrandingSettingsPage,isReady:o.isInvoicingPageReady}),c.jsx(qt,{address:s.address,fieldHelp:s.fieldHelp,addressLabel:s.addressLabel,appContent:t,authParams:o.authParams,dateFormatOptions:s.dateFormatOptions,deleteFileStatusById:o.deleteFileStatusById,filesEndPoint:o.filesEndPoint,isLoading:o.isLoading,isSaving:o.isSaving,localData:s.localData,logoFile:o.logoFile,saveErrorMessage:o.saveErrorMessage,settings:o.settings,updateFileStatusById:o.updateFileStatusById,onBackClick:()=>e(".."),onChange:d=>{i(Ro({localData:d}))},onDeleteFile:o.onDeleteFile,onEditFileName:o.onEditFileName,onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"branding",fromScreen:"settings_branding"});const d=`/${a}/invoicing/settings/branding/${wo}/`,p=ce(n.state?.pathnameStackToGoBack,n.pathname);e(d,{state:{pathnameStackToGoBack:p}})},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{tab:"branding"}),i(Po())},updateFilesEntity:o.updateFilesEntity})]})}function Qa(){const t=L(),e=re("dunning");return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingDunningSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(Qt,{dunningScheduleActionOptions:e.dunningScheduleActionOptions,isLoading:e.isLoading,isSaving:e.isSaving,saveErrorMessage:e.saveErrorMessage,settings:e.settings,onBackClick:()=>t(".."),onSave:e.onSave})]})}function za(){const t=L(),e=re("integrations");return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingIntegrationsSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(zt,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>t("../quickbooks"),onOpenPaymentDestination:()=>t("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>t("..")})]})}function Ka(){const t=L(),e=re("payment-destination");return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingPaymentDestinationSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(Kt,{fieldHelp:e.fieldHelp,isLoading:e.isLoading,isStripeBusy:e.isStripeBusy,saveErrorMessage:e.saveErrorMessage,settings:e.settings,stripeError:e.stripeError,stripeWebhookUrl:e.stripeWebhookUrl,onBackClick:()=>t(".."),onConnectStripe:e.onConnectStripe})]})}const Ga=["autoCreateItems","closedPeriodVoidAsCreditMemo","customerMatching","isSyncEnabled","syncStartDate","trackingCategoriesEnabled"],Wa=O((function(t){const e=Yn(t);return{accountMappingKindOptions:e.accountMappingKindOptions,fieldHelp:e.fieldHelp,accounts:e.accounts,connection:e.connection,customerMatchingOptions:e.customerMatchingOptions,isBackfilling:e.backfillState.fetchState==="In-Progress",isLoading:e.isLoading,isSaving:e.saveState.fetchState==="In-Progress",isSyncEnabledSaved:e.isSyncEnabledSaved,localData:e.localData,nestedAccountHierarchy:e.nestedAccountHierarchy,retryFetchStateByTaskId:e.retryFetchStateByTaskId,salesTaxPostingAccountName:e.salesTaxPostingAccountName,saveErrorMessage:e.saveState.fetchState==="Error"?e.saveState.error?.message:void 0,syncHealth:e.syncHealth,syncStatusOptions:e.syncStatusOptions}}),(function(t){return{onChange:e=>{t(To({localData:e}))},onReset:()=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsReset,{tab:"quickbooks"}),t(Fo())},onRetryTask:e=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"retry_task",entityId:e,fromScreen:"settings_qbo"}),t(Gn(e))},onStartBackfill:e=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"backfill",fromScreen:"settings_qbo"}),t(Kn(e))}}}))(Gt);function Ya(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),i=E(Ce),{configFetchState:a,localData:o,savedLocalData:s,saveState:u,settingsFetchState:d}=E(Yn),p=r.useMemo((()=>{return m=o,S=s,[...[...new Set([...Object.keys(m.accountIdByMappingCode),...Object.keys(S.accountIdByMappingCode)])].some((f=>(m.accountIdByMappingCode[f]??"")!==(S.accountIdByMappingCode[f]??"")))?["account_mappings"]:[],...Ga.filter((f=>m[f]!==S[f]))];var m,S}),[o,s]),v=Ue(u.fetchState);return r.useEffect((()=>{v==="In-Progress"&&u.fetchState==="Completed"&&e("..")}),[e,v,u.fetchState]),r.useEffect((()=>{d!=="Not-Started"&&d!=="Error"||t(Ke())}),[t,d]),r.useEffect((()=>{a==="Not-Started"&&t(ne())}),[a,t]),nt({fetchSyncHealth:!0,loadAccountingPickers:!0}),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingQboSettingsPage}),c.jsx(Wa,{onBackClick:()=>e(".."),onReconnect:()=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"reconnect",fromScreen:"settings_qbo"}),Ie.init("/connection/auth",i.tenantEmailDomain??n??""),Ie.handleClick()},onRefresh:()=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"refresh",fromScreen:"settings_qbo"}),t(Wn())},onSave:()=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{fieldsChanged:p,tab:"quickbooks"}),t(_o())}})]})}const Ja={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function Za(){const t=pn(),e=$(),n=L(),[i,a]=oe(),o=re(),{canEnableInvoicing:s,isEnablingInvoicing:u,isInvoicingEnabled:d,isQboConfigured:p,isStripeConnected:v}=E(zn),m=i.get("tab");return r.useEffect((()=>{if(m==null)return;const S=Ja[m];a({},{replace:!0}),S!=null&&n(S,{replace:!0})}),[m,n,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:l.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),c.jsx(Wt,{analytics:g,integrationsSectionProps:{...o.integrationsSectionProps,onConfigureQBO:()=>n("quickbooks"),onOpenPaymentDestination:()=>n("payment-destination")},isEnablingInvoicing:u,isLoading:o.isLoading,meetingUrl:t("invoicing_settings"),settings:o.settings,onBrandingClick:()=>n("branding"),onDunningClick:()=>n("dunning"),canEnableInvoicing:s,isQboConfigured:p,isStripePaymentsReady:v,onEnableInvoicingClick:d?void 0:()=>{g.trackInvoicingActionClick(l.Event.invoicingEnableClicked),e(Oo())}})]})}function vn(){return c.jsxs(ge,{children:[c.jsx(x,{index:!0,element:c.jsx(Za,{})}),c.jsx(x,{path:"payment-destination",element:c.jsx(Ka,{})}),c.jsx(x,{path:"branding",element:c.jsx(mn,{})}),c.jsx(x,{path:"branding/:addressType",element:c.jsx(mn,{appContent:c.jsx(Z,{isSubPage:!0,hideAddressBackButton:!0})})}),c.jsx(x,{path:"integrations",element:c.jsx(za,{})}),c.jsx(x,{path:"dunning",element:c.jsx(Qa,{})}),c.jsx(x,{path:"quickbooks",element:c.jsx(Ya,{})}),c.jsx(x,{path:"*",element:c.jsx(H,{to:"..",replace:!0})})]})}function Ac(){const t=$(),e=L(),{tenantEmailDomain:n}=R(),{areTenantIdsInSync:i}=F(),{enableState:a,fetchState:o,status:s}=E(Tn),u=Ue(a.fetchState),d=`/${n}/invoicing`,p=r.useRef(!1),v=E((m=>Ye(m).connectionFetchState.fetchState));return r.useEffect((()=>{i&&(o!=="Not-Started"?o!=="Error"||p.current||(p.current=!0,t(ne({cacheOverride:!1}))):t(ne({cacheOverride:!1})))}),[i,t,o]),r.useEffect((()=>{i&&v==="Not-Started"&&t(Qn())}),[i,t,v]),r.useEffect((()=>{u==="In-Progress"&&a.fetchState==="Completed"&&(e(`${d}/catalog`),t(Mo()))}),[u,a.fetchState,d,t,e]),s!=null||o==="Error"&&p.current?s==null?c.jsx(Jt,{onGoHome:()=>e(`/${n??""}`),onReload:()=>t(ne({cacheOverride:!0}))}):s==="not_started"?c.jsxs(ge,{children:[c.jsx(x,{path:"promo",element:c.jsx(un,{})}),c.jsx(x,{path:"*",element:c.jsx(H,{to:`${d}/promo`,replace:!0})})]}):s==="settings"?c.jsxs(ge,{children:[c.jsx(x,{path:"promo",element:c.jsx(un,{})}),c.jsx(x,{path:"settings/*",element:c.jsx(vn,{})}),c.jsx(x,{path:"*",element:c.jsx(H,{to:`${d}/settings`,replace:!0})})]}):c.jsxs(ge,{children:[c.jsx(x,{path:"/",element:c.jsx(H,{to:"overview",replace:!0})}),c.jsx(x,{path:"overview",element:c.jsx(wa,{})}),c.jsx(x,{path:"promo",element:c.jsx(H,{to:`${d}/overview`,replace:!0})}),c.jsx(x,{path:"customers",element:c.jsx(la,{})}),c.jsx(x,{path:"customers/new",element:c.jsx(ra,{})}),c.jsx(x,{path:"customers/new/:addressType",element:c.jsx(Z,{})}),c.jsx(x,{path:"customers/:customer_id",element:c.jsx(ca,{})}),c.jsx(x,{path:"customers/:customer_id/:addressType",element:c.jsx(Z,{})}),c.jsx(x,{path:"subscriptions",element:c.jsx(Ba,{})}),c.jsx(x,{path:"subscriptions/new",element:c.jsx(Na,{})}),c.jsx(x,{path:"subscriptions/new/:addressType",element:c.jsx(Z,{})}),c.jsx(x,{path:"subscriptions/:subscription_id",element:c.jsx(Oa,{})}),c.jsx(x,{path:"subscriptions/:subscription_id/:addressType",element:c.jsx(Z,{})}),c.jsx(x,{path:"invoices",element:c.jsx(ja,{})}),c.jsx(x,{path:"invoices/create",element:c.jsx(ea,{})}),c.jsx(x,{path:"invoices/:invoice_id",element:c.jsx(Aa,{})}),c.jsx(x,{path:"invoices/:invoice_id/record-payment",element:c.jsx(gn,{})}),c.jsx(x,{path:"invoices/:invoice_id/issue-credit-note",element:c.jsx(La,{})}),c.jsx(x,{path:"payments",element:c.jsx(_a,{})}),c.jsx(x,{path:"payments/record",element:c.jsx(gn,{})}),c.jsx(x,{path:"payments/:transaction_id",element:c.jsx(Ha,{})}),c.jsx(x,{path:"credits",element:c.jsx(oa,{})}),c.jsx(x,{path:"credits/:credit_note_id",element:c.jsx(ta,{})}),c.jsx(x,{path:"discounts",element:c.jsx(Ca,{})}),c.jsx(x,{path:"discounts/new",element:c.jsx(Zo,{})}),c.jsx(x,{path:"discounts/:coupon_id",element:c.jsx(Ia,{})}),c.jsx(x,{path:"dunning",element:c.jsx(ba,{})}),c.jsx(x,{path:"dunning/:case_id",element:c.jsx(Ea,{})}),c.jsx(x,{path:"catalog",element:c.jsx(Yo,{})}),c.jsx(x,{path:"catalog/new",element:c.jsx(Ko,{})}),c.jsx(x,{path:"catalog/:item_id",element:c.jsx(Ho,{})}),c.jsx(x,{path:"settings/*",element:c.jsx(vn,{})}),c.jsx(x,{path:"audit_log",element:c.jsx(Uo,{})}),c.jsx(x,{path:"data_import",element:c.jsx(va,{})}),c.jsx(x,{path:"data_import/migrate",element:c.jsx(Sa,{})}),c.jsx(x,{path:"data_import/:sessionId",element:c.jsx(ga,{})}),c.jsx(x,{path:"*",element:c.jsx(M,{})})]}):c.jsx(Yt,{fetchState:"In-Progress"})}export{Ac as default};