@zeniai/web-app-ui 5.3.71-qa → 5.3.72-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 (150) hide show
  1. package/dist/assets/{AccountMappingScreen-Da8kjow8.js → AccountMappingScreen-Dv_mcE-s.js} +2 -2
  2. package/dist/assets/{ActualMatchingMatchDetailScreen-RoPWu4_o.js → ActualMatchingMatchDetailScreen-DQhBSzc_.js} +1 -1
  3. package/dist/assets/AddressRoutes-CY6bt6oR.js +1 -0
  4. package/dist/assets/{AddressScreen-CPpf4Cpj.js → AddressScreen-DAE2XqXc.js} +2 -2
  5. package/dist/assets/AiCfoScreen-BPlLSgy4.js +22 -0
  6. package/dist/assets/{AppDrawer-BxZ3HI7E.js → AppDrawer-B_kTdlDU.js} +2 -2
  7. package/dist/assets/{BillPayApprovalRoutes-c7b3I5yJ.js → BillPayApprovalRoutes-txmAkDB9.js} +1 -1
  8. package/dist/assets/{BillPayRoutes-BDhRNd6v.js → BillPayRoutes-CWUxKmBT.js} +18 -18
  9. package/dist/assets/BusinessVerificationPageScreen-BvUcXpAj.js +9 -0
  10. package/dist/assets/CardsAiCfoScreen-nNC3ePcB.js +14 -0
  11. package/dist/assets/{ChargeCardRoutes-CWxqs0Z9.js → ChargeCardRoutes-Bbt0_9Bb.js} +6 -6
  12. package/dist/assets/{CompanyPassportScreen-CIym85mw.js → CompanyPassportScreen-rWKenTzd.js} +1 -1
  13. package/dist/assets/ConnectionAuthScreen-CztazncJ.js +11 -0
  14. package/dist/assets/CustomerOnboardingAuthScreen-yZ66vYtS.js +1 -0
  15. package/dist/assets/CustomerOnboardingRoutes-D8GPJqi3.js +30 -0
  16. package/dist/assets/{DashboardRoutes-Bq7IQcLO.js → DashboardRoutes-B_JSZLqZ.js} +3 -3
  17. package/dist/assets/{DefaultTenantHome-Bpge3yFF.js → DefaultTenantHome-IBmbS2vi.js} +1 -1
  18. package/dist/assets/{DomesticWireDetailScreen-ZaeUg4I5.js → DomesticWireDetailScreen-DdWDhL04.js} +4 -4
  19. package/dist/assets/{DrawerScreen-bhsbfXgO.js → DrawerScreen-I1OXPpov.js} +1 -1
  20. package/dist/assets/EntityDetailRoutes-DxNEAh7j.js +1 -0
  21. package/dist/assets/{ExpenseAutomationRoutes-Dab9nQ3b.js → ExpenseAutomationRoutes-BJiDP5Wv.js} +6 -6
  22. package/dist/assets/FeaturePreviewScreen-BbHZWhrI.js +1 -0
  23. package/dist/assets/HubSpotOAuthCallbackScreen-CEvleGfK.js +1 -0
  24. package/dist/assets/{InboxNotificationsProvider-Vlyx5Pej.js → InboxNotificationsProvider-CH-l5W7V.js} +1 -1
  25. package/dist/assets/InvoicingRoutes-CaFgkG0d.js +2 -0
  26. package/dist/assets/{MagicLinkRoutes-DonztJNa.js → MagicLinkRoutes-DEWQ6tjb.js} +20 -20
  27. package/dist/assets/MagicLinkSignInScreen-D7kTTahR.js +12 -0
  28. package/dist/assets/MobileAppDrawer-8BZVS4o3.js +1 -0
  29. package/dist/assets/NotFoundScreen-DnqoRCYC.js +1 -0
  30. package/dist/assets/NotificationRoutes-B6eJv18K.js +1 -0
  31. package/dist/assets/OAuthConsentScreen-9x_SIQZM.js +1 -0
  32. package/dist/assets/PandLWithForecastRoutes-2XL-q-Jt.js +1 -0
  33. package/dist/assets/{PaymentLinkScreen-43J_ZGED.js → PaymentLinkScreen-C1S1ghTR.js} +5 -5
  34. package/dist/assets/PeopleRoutes-DVpXinz3.js +22 -0
  35. package/dist/assets/PerformanceRoutes-BRj-_-uP.js +1 -0
  36. package/dist/assets/{Preview-DqlOJJpJ.js → Preview-Ch5xsyMl.js} +1 -1
  37. package/dist/assets/{QBOConnectionScreen-Czz6muQW.js → QBOConnectionScreen-Dnjt4r9I.js} +1 -1
  38. package/dist/assets/ReimbursementApprovalRoutes-CzHkAZyB.js +1 -0
  39. package/dist/assets/{ReimbursementApprovalRuleDetailScreen-DN9la9Dm.js → ReimbursementApprovalRuleDetailScreen-DulfuoGj.js} +1 -1
  40. package/dist/assets/{ReimbursementRoutes-BGNOeI_H.js → ReimbursementRoutes-BE0aOAON.js} +7 -7
  41. package/dist/assets/{ReportsRoutes-D-cpB-sX.js → ReportsRoutes-NzIYaPVq.js} +1 -1
  42. package/dist/assets/RewardsRoutes-CwZUzIe1.js +1 -0
  43. package/dist/assets/{ScheduleDetailsPrepaidExpensesScreen-CNF1ceQn.js → ScheduleDetailsPrepaidExpensesScreen-JrbhJns8.js} +5 -5
  44. package/dist/assets/ScreenRoutes-DwyFQCfk.js +2 -0
  45. package/dist/assets/{SettingsRoutes-D_LLhbJv.js → SettingsRoutes-C1rh1f5s.js} +6 -6
  46. package/dist/assets/SetupPagesScreen-Cl5BAT-o.js +29 -0
  47. package/dist/assets/SignInScreen-_U7Bj35k.js +1 -0
  48. package/dist/assets/SignOutScreen-BgEdGGQF.js +9 -0
  49. package/dist/assets/TaskListScreen-CvKGMIZk.js +9 -0
  50. package/dist/assets/TaskRoutes-CEJdgyOG.js +9 -0
  51. package/dist/assets/TransactionDetailRoutes-S-naEoj9.js +1 -0
  52. package/dist/assets/{TransactionDetailScreen-CWo5MdmD.js → TransactionDetailScreen-CNGUSd_b.js} +2 -2
  53. package/dist/assets/TransactionListRoutes-ChCViJl9.js +1 -0
  54. package/dist/assets/{TreasuryRoutes-B1C-ovJX.js → TreasuryRoutes-xGBsDsbG.js} +3 -3
  55. package/dist/assets/{VendorsRoutes-DoSPbM9C.js → VendorsRoutes-CxbN9ffS.js} +13 -13
  56. package/dist/assets/WiseConfirmationScreen--1X8GtN8.js +12 -0
  57. package/dist/assets/ZeniAccountRoutes-DKMn9Mvs.js +57 -0
  58. package/dist/assets/{ZeniAccountStatementScreen-kiOSzYpp.js → ZeniAccountStatementScreen-CY8Yij9t.js} +2 -2
  59. package/dist/assets/{accountMappingHelper-CeXF1Q4Q.js → accountMappingHelper-CnG-eRj3.js} +1 -1
  60. package/dist/assets/{analytics-DI5uqxwC.js → analytics-DlzSqyvZ.js} +1 -1
  61. package/dist/assets/{analyticsHelper-Df3DOmUB.js → analyticsHelper-Cq1viJip.js} +1 -1
  62. package/dist/assets/{core-_cqItzd_.js → core-D07hD3KT.js} +1 -1
  63. package/dist/assets/{decodeURIComponentSafe-CzbN3zRu.js → decodeURIComponentSafe-D3MFRtCF.js} +1 -1
  64. package/dist/assets/{dnd-BzHSvmGV.js → dnd-B-KpYfWT.js} +1 -1
  65. package/dist/assets/{empty-CTsBwHYQ.js → empty-DRbThjIF.js} +1 -1
  66. package/dist/assets/{empty-IeCSs-Vp.js → empty-aXh7noZx.js} +1 -1
  67. package/dist/assets/{emptyVideoElement-BDIFj1OP.js → emptyVideoElement-BZocj0UF.js} +1 -1
  68. package/dist/assets/epic-Du2AdUHP.js +2 -0
  69. package/dist/assets/expenseAutomationHelper-CL7YOVzM.js +1 -0
  70. package/dist/assets/{getLocaleForTenant-DNtLZSig.js → getLocaleForTenant-4ThGApJK.js} +1 -1
  71. package/dist/assets/{index-_QekaZI8.js → index-54OCX1PW.js} +1 -1
  72. package/dist/assets/{index-DVhAab8j.js → index-B1xlAtau.js} +16884 -16790
  73. package/dist/assets/{index-CFtxbACp.js → index-BIOOl02m.js} +1 -1
  74. package/dist/assets/{index-z7nFmc82.js → index-BVdX_ubi.js} +2 -2
  75. package/dist/assets/{index-LjABwt4q.js → index-BxmwktwS.js} +1 -1
  76. package/dist/assets/{index-B_Z1rAKT.js → index-D5s14gxd.js} +1 -1
  77. package/dist/assets/{index-CMOD4X8_.js → index-YyHAbx34.js} +1 -1
  78. package/dist/assets/{index-aNhAY0yh.js → index-z9Fh-4S1.js} +1 -1
  79. package/dist/assets/{lexical-CXRKir6z.js → lexical-NIxvAmS2.js} +1 -1
  80. package/dist/assets/{liveblocks-gNIoHksP.js → liveblocks-CQOAuUNI.js} +1 -1
  81. package/dist/assets/{lottie-CjJcvZ3r.js → lottie-BIKpYE12.js} +1 -1
  82. package/dist/assets/{mui-CDH3xRD_.js → mui-XiTT8YBC.js} +1 -1
  83. package/dist/assets/{pathToGoBack-DqZRBX-C.js → pathToGoBack-RICxbZCJ.js} +1 -1
  84. package/dist/assets/{pdf-BZVEJwNE.js → pdf-Dli3mGO_.js} +3 -3
  85. package/dist/assets/{pdf-lib-DnzapqoA.js → pdf-lib-D9XJLVoD.js} +1 -1
  86. package/dist/assets/{plaid-Dvn5Z296.js → plaid-BG3pJamN.js} +1 -1
  87. package/dist/assets/{pusher-CcIFKuUn.js → pusher-D9DkHuMx.js} +1 -1
  88. package/dist/assets/{react-CPb70X99.js → react-BLzCbojr.js} +1 -1
  89. package/dist/assets/{react-AHfmXvhq.js → react-C-5ZNsBH.js} +1 -1
  90. package/dist/assets/{react-DClAw2ak.js → react-C1d1ocIu.js} +1 -1
  91. package/dist/assets/{react-t3XyoKqw.js → react-CrrxpEIc.js} +1 -1
  92. package/dist/assets/{react-DAXlQZC6.js → react-D2I9LF0A.js} +1 -1
  93. package/dist/assets/{react-CuiiYztJ.js → react-DkT18Fv5.js} +1 -1
  94. package/dist/assets/{recharts-BgEcqT8y.js → recharts-CgYqsGTH.js} +1 -1
  95. package/dist/assets/{routePaths-DM8AEJT0.js → routePaths-Byv4I0Ax.js} +1 -1
  96. package/dist/assets/{sentry-BzzHvh63.js → sentry-pp_6zWNc.js} +1 -1
  97. package/dist/assets/{stripSplatSuffix-D8FyJbXM.js → stripSplatSuffix-DA-gXJ77.js} +1 -1
  98. package/dist/assets/{url-BuE-ZvDR.js → url-TK5h7pVR.js} +1 -1
  99. package/dist/assets/{url-0BMhJWUX.js → url-yI9BET_f.js} +1 -1
  100. package/dist/assets/useActualMatchingMatchDetail-DTg70T-B.js +1 -0
  101. package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-C6pX9M29.js → useAiCfoDashboardSuggestedQuestionsChips-BtQMXCJn.js} +1 -1
  102. package/dist/assets/useAskAiCfoHostNavButtonProps-gzIjh_Rc.js +1 -0
  103. package/dist/assets/{useChargeCardPusherEvents-pc-PEvCr.js → useChargeCardPusherEvents-BYYn6vOu.js} +1 -1
  104. package/dist/assets/{useDeviceId-DYE-WS_B.js → useDeviceId-DCPRNX-s.js} +1 -1
  105. package/dist/assets/useEmailConnectResultRefresh-C_tEfW8U.js +1 -0
  106. package/dist/assets/{useInitialThreadRequest-CSR_bJDf.js → useInitialThreadRequest-Cuwjfmqu.js} +1 -1
  107. package/dist/assets/useTaskManagerAccess-Y5qsn5_D.js +1 -0
  108. package/dist/assets/{useTaskManagerPusherEvents-C0fOaGqk.js → useTaskManagerPusherEvents-CgwVJFYR.js} +1 -1
  109. package/dist/assets/{utils-DZX8_JTm.js → utils-CrOdvv6w.js} +1 -1
  110. package/dist/assets/{withTransactionSidePanel-BKXId2BT.js → withTransactionSidePanel-BqueNlFJ.js} +4 -4
  111. package/dist/assets/{zeni-epic-state-ClqSlu6d.js → zeni-epic-state-B3TABHgO.js} +6 -6
  112. package/dist/index.html +1 -1
  113. package/package.json +4 -4
  114. package/dist/assets/AddressRoutes-C13OMsQB.js +0 -1
  115. package/dist/assets/AiCfoScreen-C1Zi5BWJ.js +0 -22
  116. package/dist/assets/BusinessVerificationPageScreen-CaVy5wIy.js +0 -9
  117. package/dist/assets/CardsAiCfoScreen-BHtNOqz6.js +0 -14
  118. package/dist/assets/ConnectionAuthScreen-C6aejitU.js +0 -11
  119. package/dist/assets/CustomerOnboardingAuthScreen-abpr3s2K.js +0 -1
  120. package/dist/assets/CustomerOnboardingRoutes-DVMAQtsb.js +0 -30
  121. package/dist/assets/EntityDetailRoutes-bilW2_CZ.js +0 -1
  122. package/dist/assets/FeaturePreviewScreen-ADHB7kMI.js +0 -1
  123. package/dist/assets/HubSpotOAuthCallbackScreen-7DU1Mbfq.js +0 -1
  124. package/dist/assets/InvoicingRoutes-CiTJXDwp.js +0 -2
  125. package/dist/assets/MagicLinkSignInScreen-DdvxD6Sl.js +0 -12
  126. package/dist/assets/MobileAppDrawer-Boi7lIY0.js +0 -1
  127. package/dist/assets/NotFoundScreen-XQ69x1V9.js +0 -1
  128. package/dist/assets/NotificationRoutes-CjruMuyg.js +0 -1
  129. package/dist/assets/OAuthConsentScreen-fv9EuWPU.js +0 -1
  130. package/dist/assets/PandLWithForecastRoutes-CwPS1KT_.js +0 -1
  131. package/dist/assets/PeopleRoutes-B4wBQVwY.js +0 -22
  132. package/dist/assets/PerformanceRoutes-BaUrr9_i.js +0 -1
  133. package/dist/assets/ReimbursementApprovalRoutes-BoJxAtXM.js +0 -1
  134. package/dist/assets/RewardsRoutes-Cp5QwRpd.js +0 -1
  135. package/dist/assets/ScreenRoutes-DSM6zpE1.js +0 -2
  136. package/dist/assets/SetupPagesScreen-PMDfztMD.js +0 -29
  137. package/dist/assets/SignInScreen-DXEwLRRd.js +0 -1
  138. package/dist/assets/SignOutScreen-rRGrVkZi.js +0 -9
  139. package/dist/assets/TaskListScreen-C_FDDeaV.js +0 -9
  140. package/dist/assets/TaskRoutes-DIOgMKYK.js +0 -9
  141. package/dist/assets/TransactionDetailRoutes-C6i9gm0l.js +0 -1
  142. package/dist/assets/TransactionListRoutes-DMziXkI4.js +0 -1
  143. package/dist/assets/WiseConfirmationScreen-CYU0SXmY.js +0 -12
  144. package/dist/assets/ZeniAccountRoutes-4rPFLUgD.js +0 -57
  145. package/dist/assets/epic-BpPMSALI.js +0 -2
  146. package/dist/assets/expenseAutomationHelper-CTin--xN.js +0 -1
  147. package/dist/assets/useActualMatchingMatchDetail-CQqHF-gN.js +0 -1
  148. package/dist/assets/useAskAiCfoHostNavButtonProps-DQSYAHEz.js +0 -1
  149. package/dist/assets/useEmailConnectResultRefresh-XR0U1MaM.js +0 -1
  150. package/dist/assets/useTaskManagerAccess-CZYVdWyJ.js +0 -1
@@ -1,15 +1,15 @@
1
- import{j as k}from"./liveblocks-gNIoHksP.js";import{u as ge,h as nt,g as Te,j as F,i as Be,t as Jn,l as Yn,n as Hn,o as We,N as Wn}from"./core-_cqItzd_.js";import{fI as ke,a1a as Kn,q3 as Me,Uk as Qn,A9 as Xn,a1b as Zn,a1c as es,a1d as ts,a1e as Ct,a1f as Qe,gk as Pt,a1g as ia,eY as as,g3 as ns,a1h as la,a1i as Xe,qW as ss,uX as os,gV as cs,gT as is,a1j as ls,r7 as rs,rg as ds,qe as us,qs as Ra,gS as ue,gU as ms,a1k as ps,qO as Da,rh as hs,qp as Ss,qk as gs,v1 as Cs,gR as Oe,a1l as tt,Cj as Fa,MG as _a,a1m as Ma,FE as Oa,a1n as fs,e$ as Is,f1 as ks,sY as bt,X4 as ra,X6 as Ts,m5 as Ps,X7 as bs,mc as ys,dm as vs,DC as yt,a1o as Es,a1p as As,a1q as xs,a1r as ws,fp as vt,sM as da,WZ as Rs,a1s as Ds,a1t as Fs,me as _s,a1u as Ms,Rm as Os,md as Us,m2 as Bs,qH as Ua,rm as at,tz as Ba,tV as Vs,Ua as Va,rl as ua,ro as ja,rq as js,bF as zs,nB as $s,ny as Ls,rp as Ze,rn as Se,a1v as Gs,rH as ma,a1w as Ns,a1x as qs,sQ as Js,sR as Ys,WV as Hs,V$ as Ws,a0E as Ks,a1y as Qs,W$ as pa,W_ as Ke,a1z as ha,mt as Xs,a1A as Zs,a1B as eo,a1C as to,a1D as ao,qC as no,a1E as so,a1F as oo,a1G as co,rx as io,mg as lo,m7 as ro,a1H as uo,mf as Sa,Xh as mo,a1I as po,a1J as ho,uy as So,u9 as go,u8 as ft,a1K as Co,a1L as fo,a1M as Io,a1N as ko,nM as To,br as Po,nH as ga,nt as bo,a1O as yo,h2 as vo,nE as Eo,s_ as Ao,t0 as xo,sJ as wo,W2 as Ro,W3 as Do,F6 as Fo,F5 as _o,Fm as Mo,a1P as Ca,sP as Oo,sk as Uo,a1Q as Bo,s0 as Vo,s5 as jo,sg as zo,s3 as $o,a1R as Lo,rY as Go,sf as No,sV as qo,a1S as Jo,t6 as Yo,sD as Ho,tc as Wo,sI as Ko,rI as Qo,a1T as Xo,q_ as Zo,qy as ec,qF as fa,rs as tc,a1U as ac,a1V as nc,a1W as sc,a1X as oc,a1Y as cc,a1Z as ic,a1_ as lc,tg as rc,a1$ as dc,a20 as uc,a21 as Ia,uJ as mc,u0 as pc,tR as ka,tP as hc,a22 as Sc,tE as gc,tj as Cc,tS as fc,a23 as Ic,a24 as kc,tp as Tc,a25 as Pc,tk as bc,to as yc,tm as vc,tY as Ec}from"./zeni-epic-state-ClqSlu6d.js";import za from"./NotFoundScreen-XQ69x1V9.js";import{a as s,R as $a}from"./sentry-BzzHvh63.js";import{n as Pe,S as Ac}from"./mui-CDH3xRD_.js";import{_ as Ve,f as H,n as W,p as ee,aq as La,as as Ga,dO as xc,dP as wc,z as st,dQ as Rc,dR as Dc,dS as Fc,ae as Ue,dT as _c,dU as Ta,ba as Pa,dV as Mc,a7 as Na,dW as Oc,m as et,a as Uc,dX as Bc,dY as Vc,c as jc,P as zc,dZ as $c,d_ as Lc,d$ as Gc,b4 as Nc,bs as qc,ab as Jc,b5 as Yc,b6 as Hc,G as Wc,w as Kc,e0 as Qc,av as ba,e1 as Xc}from"./index-DVhAab8j.js";import{u as qa}from"./useAskAiCfoHostNavButtonProps-DQSYAHEz.js";import{g as ya,b as Zc,c as ei,h as ti,a as ai,i as ni,r as si,C as oi}from"./TransactionDetailScreen-CWo5MdmD.js";import{u as ci,a as ii}from"./useActualMatchingMatchDetail-CQqHF-gN.js";import{d as li}from"./decodeURIComponentSafe-CzbN3zRu.js";import{m as Ja,a as Ya}from"./expenseAutomationHelper-CTin--xN.js";import{u as Ha,a as Wa,w as ri}from"./withTransactionSidePanel-BKXId2BT.js";import{b as di,S as ui,a as mi,J as pi}from"./ScheduleDetailsPrepaidExpensesScreen-CNF1ceQn.js";import{s as va,i as Ka,h as hi,v as Si,c as gi}from"./routePaths-DM8AEJT0.js";import{a as It}from"./accountMappingHelper-CeXF1Q4Q.js";import{D as Ci}from"./DrawerScreen-bhsbfXgO.js";import"./recharts-BgEcqT8y.js";import"./analytics-DI5uqxwC.js";import"./plaid-Dvn5Z296.js";import"./dnd-BzHSvmGV.js";import"./stripe-cKAAJElX.js";import"./lottie-CjJcvZ3r.js";import"./lexical-CXRKir6z.js";import"./pdf-BZVEJwNE.js";import"./utils-DZX8_JTm.js";import"./useInitialThreadRequest-CSR_bJDf.js";import"./stripSplatSuffix-D8FyJbXM.js";import"./pathToGoBack-DqZRBX-C.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new t.Error().stack;n&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[n]="26242889-a134-46aa-90a7-ac6653843244",t._sentryDebugIdIdentifier="sentry-dbid-26242889-a134-46aa-90a7-ac6653843244")}catch{}})();const fi=()=>{const t=ge(),n=nt(),S=Te(),g=F((p=>ke(p))),{useFeatureGate:d}=Ve(),{isFeatureEnabled:i}=d(H.isRealtimeInsightsFeatureEnabled),{isFeatureEnabled:r}=d(H.aiAuditScorePercentage),A=F((p=>p.expenseAutomationViewState.selectedPeriodByTenantId)),l=F((p=>Kn(p,g.tenantId))),{isAiCfoAccessEnabled:v,onAskAiCfoClick:x}=qa({mobileExploreReferrer:"Month-End Close Overview"}),P=s.useCallback(((p,b,_=!1)=>{t(Me({tenantId:b,period:{month:p.month,year:p.year},refreshViewInBackground:_}))}),[]),C=s.useCallback((p=>{const b=S.state?.referrer;l.monthEndCloseChecks?.auditSummary!=null&&W.trackMonthCloseAuditPage(p.month,p.year,l.monthEndCloseChecks.reportEmailSentDate!=null?"closed":"in-review",l.monthEndCloseChecks.auditSummary.auditScorePercentage,!1,b??null),t(Qn(g.tenantId,p))}),[g.tenantId,l.monthEndCloseChecks?.auditSummary,l.monthEndCloseChecks?.reportEmailSentDate]),f=A[g.tenantId],m=s.useCallback((()=>{const p=S.state?.referrer;l.monthEndCloseChecks?.auditSummary!=null&&W.trackMonthCloseAuditPage(f.month,f.year,l.monthEndCloseChecks.reportEmailSentDate!=null?"closed":"in-review",l.monthEndCloseChecks.auditSummary.auditScorePercentage,!0,p??null),P(f,g.tenantId,!0)}),[P,f,g.tenantId,l.monthEndCloseChecks?.auditSummary,l.monthEndCloseChecks?.reportEmailSentDate]),z=ee(S.state?.pathnameStackToGoBack,S.pathname),w=s.useCallback((()=>{if(l.monthEndCloseChecks!=null&&f!=null){const p=l.monthEndCloseChecks.monthEndCloseCheckList.find((b=>b.progress<100));if(p!=null)return void n(`./${p.id}/${f.month}-${f.year}`,{state:{pathnameStackToGoBack:z,message:"comingFromOverview"}});n(`./month_end_insights/${f.month}-${f.year}`,{state:{pathnameStackToGoBack:z,message:"comingFromOverview"}})}}),[l.monthEndCloseChecks,f]),{areTenantIdsInSync:I}=La();return Ga({isDataReady:l.fetchState==="Completed"}),s.useEffect((()=>{f!=null&&l.fetchState!=="In-Progress"&&l.fetchState!=="Completed"&&I&&P(f,g.tenantId)}),[P,f,l.fetchState,g.tenantId,I]),s.useEffect((()=>{f!=null&&l.monthClosePerformanceTrendFetchStatus.fetchState!=="In-Progress"&&l.monthClosePerformanceTrendFetchStatus.fetchState!=="Completed"&&I&&t(Xn(f))}),[f,l.monthClosePerformanceTrendFetchStatus.fetchState,I]),s.useEffect((()=>{const p=setInterval((()=>{l.fetchState!=="In-Progress"&&l.fetchState==="Completed"&&m()}),3e5);return()=>clearInterval(p)}),[l.fetchState]),s.useEffect((()=>{if(l.fetchState==="Completed"&&l.monthEndCloseChecks?.auditSummary!=null){const p=S.state?.referrer;W.trackMonthCloseAuditPage(l.selectedPeriod.month,l.selectedPeriod.year,l.monthEndCloseChecks.reportEmailSentDate!=null?"closed":"in-review",l.monthEndCloseChecks.auditSummary.auditScorePercentage,!1,p??null)}}),[l.fetchState,l.selectedPeriod,l.monthEndCloseChecks?.auditSummary,l.monthEndCloseChecks?.reportEmailSentDate]),k.jsx(Ii,{children:k.jsx(xc,{monthEndCloseChecksView:l,isRealtimeInsightsFeatureEnabled:i,onMonthEndCheckClick:p=>{n(`./${p}/${f.month}-${f.year}`,{state:{pathnameStackToGoBack:z,message:"comingFromOverview",referrer:"Expense Automation - Overview"}})},onPeriodChange:C,handleReviewButtonClick:w,onBackClick:()=>{n("../../dashboard")},onReload:m,isAiCfoAccessEnabled:v,onAskAiCfoClick:x,aiAuditScorePercentageEnabled:r})})},Ii=Pe.div`
1
+ import{j as k}from"./liveblocks-CQOAuUNI.js";import{u as ge,h as nt,g as Te,j as F,i as Be,t as Jn,l as Yn,n as Hn,o as We,N as Wn}from"./core-D07hD3KT.js";import{fI as ke,a1e as Xn,q3 as Me,Uo as Kn,Aa as Qn,a1f as Zn,a1g as es,a1h as ts,a1i as Ct,a1j as Ke,gk as bt,a1k as ia,eY as as,g3 as ns,a1l as la,a1m as Qe,qW as ss,uX as os,gV as cs,gT as is,a1n as ls,r7 as rs,rg as ds,qe as us,qs as Ra,gS as ue,gU as ms,a1o as ps,qO as Da,rh as hs,qp as Ss,qk as gs,v1 as Cs,gR as Oe,a1p as tt,Ck as Fa,MK as _a,a1q as Ma,FF as Oa,a1r as fs,e$ as Is,f1 as ks,sY as Pt,X8 as ra,Xa as Ts,m5 as bs,Xb as Ps,mc as ys,dm as vs,DD as yt,a1s as Es,a1t as As,a1u as xs,a1v as ws,fp as vt,sM as da,X1 as Rs,a1w as Ds,a1x as Fs,me as _s,a1y as Ms,Rq as Os,md as Us,m2 as Bs,qH as Ua,rm as at,tz as Ba,tV as Vs,Ue as Va,rl as ua,ro as ja,rq as js,bF as zs,nB as Ls,ny as $s,rp as Ze,rn as Se,a1z as Gs,rH as ma,a1A as qs,a1B as Ns,sQ as Js,sR as Ys,WZ as Hs,W3 as Ws,a0I as Xs,a1C as Ks,X3 as pa,X2 as Xe,a1D as ha,mt as Qs,a1E as Zs,a1F as eo,a1G as to,a1H as ao,qC as no,a1I as so,a1J as oo,a1K as co,rx as io,mg as lo,m7 as ro,a1L as uo,mf as Sa,Xl as mo,a1M as po,a1N as ho,uy as So,u9 as go,u8 as ft,a1O as Co,a1P as fo,a1Q as Io,a1R as ko,nM as To,br as bo,nH as ga,nt as Po,a1S as yo,h2 as vo,nE as Eo,s_ as Ao,t0 as xo,sJ as wo,W6 as Ro,W7 as Do,F7 as Fo,F6 as _o,Fn as Mo,a1T as Ca,sP as Oo,sk as Uo,a1U as Bo,s0 as Vo,s5 as jo,sg as zo,s3 as Lo,a1V as $o,rY as Go,sf as qo,sV as No,a1W as Jo,t6 as Yo,sD as Ho,tc as Wo,sI as Xo,rI as Ko,a1X as Qo,q_ as Zo,qy as ec,qF as fa,rs as tc,a1Y as ac,a1Z as nc,a1_ as sc,a1$ as oc,a20 as cc,a21 as ic,a22 as lc,tg as rc,a23 as dc,a24 as uc,a25 as Ia,uJ as mc,u0 as pc,tR as ka,tP as hc,a26 as Sc,tE as gc,tj as Cc,tS as fc,a27 as Ic,a28 as kc,tp as Tc,a29 as bc,tk as Pc,to as yc,tm as vc,tY as Ec}from"./zeni-epic-state-B3TABHgO.js";import za from"./NotFoundScreen-DnqoRCYC.js";import{a as s,R as La}from"./sentry-pp_6zWNc.js";import{n as be,S as Ac}from"./mui-XiTT8YBC.js";import{H as Ve,y as H,k as W,p as ee,aq as $a,as as Ga,dO as xc,dP as wc,z as st,dQ as Rc,dR as Dc,dS as Fc,ae as Ue,dT as _c,dU as Ta,ba,dV as Mc,a7 as qa,dW as Oc,j as et,a as Uc,dX as Bc,dY as Vc,D as jc,W as zc,dZ as Lc,d_ as $c,d$ as Gc,b4 as qc,bs as Nc,ab as Jc,b5 as Yc,b6 as Hc,G as Wc,w as Xc,e0 as Kc,av as Pa,e1 as Qc}from"./index-B1xlAtau.js";import{u as Na}from"./useAskAiCfoHostNavButtonProps-gzIjh_Rc.js";import{g as ya,b as Zc,c as ei,h as ti,a as ai,i as ni,r as si,C as oi}from"./TransactionDetailScreen-CNGUSd_b.js";import{u as ci,a as ii}from"./useActualMatchingMatchDetail-DTg70T-B.js";import{d as li}from"./decodeURIComponentSafe-D3MFRtCF.js";import{m as Ja,a as Ya}from"./expenseAutomationHelper-CL7YOVzM.js";import{u as Ha,a as Wa,w as ri}from"./withTransactionSidePanel-BqueNlFJ.js";import{b as di,S as ui,a as mi,J as pi}from"./ScheduleDetailsPrepaidExpensesScreen-JrbhJns8.js";import{s as va,i as Xa,h as hi,v as Si,c as gi}from"./routePaths-Byv4I0Ax.js";import{a as It}from"./accountMappingHelper-CnG-eRj3.js";import{D as Ci}from"./DrawerScreen-I1OXPpov.js";import"./recharts-CgYqsGTH.js";import"./analytics-DlzSqyvZ.js";import"./plaid-BG3pJamN.js";import"./dnd-B-KpYfWT.js";import"./stripe-cKAAJElX.js";import"./lottie-BIKpYE12.js";import"./lexical-NIxvAmS2.js";import"./pdf-Dli3mGO_.js";import"./utils-CrOdvv6w.js";import"./useInitialThreadRequest-Cuwjfmqu.js";import"./stripSplatSuffix-DA-gXJ77.js";import"./pathToGoBack-RICxbZCJ.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},n=new t.Error().stack;n&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[n]="a8fe0bc1-4851-4054-9e2d-a7adeebe8928",t._sentryDebugIdIdentifier="sentry-dbid-a8fe0bc1-4851-4054-9e2d-a7adeebe8928")}catch{}})();const fi=()=>{const t=ge(),n=nt(),S=Te(),g=F((p=>ke(p))),{useFeatureGate:d}=Ve(),{isFeatureEnabled:i}=d(H.isRealtimeInsightsFeatureEnabled),{isFeatureEnabled:r}=d(H.aiAuditScorePercentage),A=F((p=>p.expenseAutomationViewState.selectedPeriodByTenantId)),l=F((p=>Xn(p,g.tenantId))),{isAiCfoAccessEnabled:v,onAskAiCfoClick:x}=Na({mobileExploreReferrer:"Month-End Close Overview"}),b=s.useCallback(((p,P,_=!1)=>{t(Me({tenantId:P,period:{month:p.month,year:p.year},refreshViewInBackground:_}))}),[]),C=s.useCallback((p=>{const P=S.state?.referrer;l.monthEndCloseChecks?.auditSummary!=null&&W.trackMonthCloseAuditPage(p.month,p.year,l.monthEndCloseChecks.reportEmailSentDate!=null?"closed":"in-review",l.monthEndCloseChecks.auditSummary.auditScorePercentage,!1,P??null),t(Kn(g.tenantId,p))}),[g.tenantId,l.monthEndCloseChecks?.auditSummary,l.monthEndCloseChecks?.reportEmailSentDate]),f=A[g.tenantId],m=s.useCallback((()=>{const p=S.state?.referrer;l.monthEndCloseChecks?.auditSummary!=null&&W.trackMonthCloseAuditPage(f.month,f.year,l.monthEndCloseChecks.reportEmailSentDate!=null?"closed":"in-review",l.monthEndCloseChecks.auditSummary.auditScorePercentage,!0,p??null),b(f,g.tenantId,!0)}),[b,f,g.tenantId,l.monthEndCloseChecks?.auditSummary,l.monthEndCloseChecks?.reportEmailSentDate]),z=ee(S.state?.pathnameStackToGoBack,S.pathname),w=s.useCallback((()=>{if(l.monthEndCloseChecks!=null&&f!=null){const p=l.monthEndCloseChecks.monthEndCloseCheckList.find((P=>P.progress<100));if(p!=null)return void n(`./${p.id}/${f.month}-${f.year}`,{state:{pathnameStackToGoBack:z,message:"comingFromOverview"}});n(`./month_end_insights/${f.month}-${f.year}`,{state:{pathnameStackToGoBack:z,message:"comingFromOverview"}})}}),[l.monthEndCloseChecks,f]),{areTenantIdsInSync:I}=$a();return Ga({isDataReady:l.fetchState==="Completed"}),s.useEffect((()=>{f!=null&&l.fetchState!=="In-Progress"&&l.fetchState!=="Completed"&&I&&b(f,g.tenantId)}),[b,f,l.fetchState,g.tenantId,I]),s.useEffect((()=>{f!=null&&l.monthClosePerformanceTrendFetchStatus.fetchState!=="In-Progress"&&l.monthClosePerformanceTrendFetchStatus.fetchState!=="Completed"&&I&&t(Qn(f))}),[f,l.monthClosePerformanceTrendFetchStatus.fetchState,I]),s.useEffect((()=>{const p=setInterval((()=>{l.fetchState!=="In-Progress"&&l.fetchState==="Completed"&&m()}),3e5);return()=>clearInterval(p)}),[l.fetchState]),s.useEffect((()=>{if(l.fetchState==="Completed"&&l.monthEndCloseChecks?.auditSummary!=null){const p=S.state?.referrer;W.trackMonthCloseAuditPage(l.selectedPeriod.month,l.selectedPeriod.year,l.monthEndCloseChecks.reportEmailSentDate!=null?"closed":"in-review",l.monthEndCloseChecks.auditSummary.auditScorePercentage,!1,p??null)}}),[l.fetchState,l.selectedPeriod,l.monthEndCloseChecks?.auditSummary,l.monthEndCloseChecks?.reportEmailSentDate]),k.jsx(Ii,{children:k.jsx(xc,{monthEndCloseChecksView:l,isRealtimeInsightsFeatureEnabled:i,onMonthEndCheckClick:p=>{n(`./${p}/${f.month}-${f.year}`,{state:{pathnameStackToGoBack:z,message:"comingFromOverview",referrer:"Expense Automation - Overview"}})},onPeriodChange:C,handleReviewButtonClick:w,onBackClick:()=>{n("../../dashboard")},onReload:m,isAiCfoAccessEnabled:v,onAskAiCfoClick:x,aiAuditScorePercentageEnabled:r})})},Ii=be.div`
2
2
  display: flex;
3
3
  height: 100vh;
4
4
  width: 100%;
5
5
  flex: 1 1 auto;
6
6
  flex-direction: column;
7
7
  background-color: ${t=>t.theme.colors.grey4};
8
- `;function ki({isFullView:t,matchId:n,onClose:S}){const{match:g,detailFetchState:d,handleOpenBill:i,handleApproveAndReverse:r,handleIgnoreMatchSuggestion:A,handleRefresh:l,handleUndoReversal:v,lastMatchResults:x,lastUndoResults:P,refreshStatus:C,ignoreStatus:f,matchAndReverseStatus:m,undoReversalStatus:z}=ci(n);return k.jsx(wc,{match:g,detailFetchState:d.fetchState,isRenderedInPanel:!t,isApproveInFlight:m.fetchState==="In-Progress",isIgnoreInFlight:f.fetchState==="In-Progress",isUndoInFlight:z.fetchState==="In-Progress",refreshStatus:C.fetchState,onNavigateBack:S,onOpenBill:i,onApproveAndReverse:r,onIgnoreMatchSuggestion:A,onRefresh:l,onUndoReversal:v,lastMatchResults:x,lastUndoResults:P})}const Ti=/^match\/([^/?]+)$/,Pi=Wa({displayNamePrefix:"withActualMatchingSidePanel",usePanelSetup:function(t){const{useFeatureGate:n}=Ve(),{isFeatureEnabled:S}=n(H.isTransactionDetailSplitViewEnabled),{isFeatureEnabled:g}=n(H.isAccrualEnabled),d=(function(r=!0){const A=nt(),l=Te(),v=Be(),x=Ja(v),P=Ha({childPathPattern:Ti,enabled:r,listPath:x}),C=P.matchGroups[0]!=null&&P.matchGroups[0]!==""?li(P.matchGroups[0]):void 0,f=v.tenantEmailDomain??l.pathname.split("/").find(Boolean)??"",m=s.useRef({isOpen:P.isOpen,matchId:C});m.current={isOpen:P.isOpen,matchId:C};const z=s.useCallback((p=>{!P.isMobile&&r?m.current.isOpen&&m.current.matchId===p?P.closePanel():P.navigateToChild(`match/${encodeURIComponent(p)}`,{replace:m.current.isOpen}):A(`/${f}/expense-automation/actual-matching/${encodeURIComponent(p)}`)}),[A,P.isMobile,P.navigateToChild,P.closePanel,r,f]),w=s.useCallback((()=>{if(C==null)return;const p=ee(l.state?.pathnameStackToGoBack,`${l.pathname}${l.search}`);A(`/${f}/expense-automation/actual-matching/${encodeURIComponent(C)}`,{state:{pathnameStackToGoBack:p}})}),[l.pathname,l.search,l.state,C,A,f]),I=P.isOpen&&C!=null;return{closePanel:P.closePanel,isOpen:I,maximize:w,matchId:r&&I?C:void 0,openPanel:z}})(t&&g===!0&&S===!0),i=s.useMemo((()=>{if(d.isOpen&&d.matchId!=null)return k.jsx(ki,{isFullView:!1,matchId:d.matchId,onClose:d.closePanel},d.matchId)}),[d.closePanel,d.isOpen,d.matchId]);return{injectedProps:s.useMemo((()=>({closeMatchSidePanel:d.closePanel,isMatchPanelOpen:d.isOpen,matchPanelContent:i,matchPanelMatchId:d.matchId,openMatchPanel:d.openPanel})),[i,d.closePanel,d.isOpen,d.matchId,d.openPanel]),selectedItemId:d.matchId,sidePanel:{closePanel:d.closePanel,maximize:d.maximize}}}}),bi=$a.memo((({reconciliation:t,selectedDrawerAccountId:n,onClose:S,onFetchLinkTokenClick:g,onEstablishConnectionClick:d})=>{const i=ge(),{useFeatureGate:r}=Ve(),{isFeatureEnabled:A}=r(H.isReconV3Enabled),{isFeatureEnabled:l}=r(H.isReconciliationCombinedStatementEnabled),v=st.getSignedInUser(),x=F((y=>ke(y))),P=s.useMemo((()=>({userId:v?.userId??"",sessionId:v?.zeniSessionId??"",tenantId:x?.tenantId??""})),[v?.userId,v?.zeniSessionId,x?.tenantId]),{accountReconciliationsByAccountID:C,excludedAccountIDs:f,monthYearPeriod:m,statementUploadChosen:z}=t,w=C[n],I=s.useMemo((()=>Zn(C,n)),[C,n]),p=s.useMemo((()=>es(C)),[C]),b=s.useMemo((()=>ts(C,n)),[C,n]),_=s.useRef(!1),G=s.useCallback((y=>{_.current=y,Ta(n,y)}),[n]),N=s.useCallback((y=>{i(Ct({accountId:n,selectedPeriod:m,dismissedToBackground:!0,backgroundCompletedSteps:y.completedSteps,startedAtMs:y.startedAtMs,totalDurationSeconds:y.totalDurationSeconds})),y.accountMappings!=null&&i(Qe({accountId:n,selectedPeriod:m,localData:{combinedStatementAccountMappings:y.accountMappings}})),w!=null&&requestAnimationFrame((()=>{_.current||i(Pt({messageSection:"statement_parsing_in_progress",messageText:"success",type:"info",showStatusIcon:!0,variables:[{variableName:"_account_name_",variableValue:Rc(w)}]}))}))}),[i,m,w,n]),q=s.useCallback((()=>{i(Ct({accountId:n,selectedPeriod:m,dismissedToBackground:!1}))}),[i,n,m]),h=s.useCallback((y=>{i(ia({accountId:n,selectedPeriod:m,backgroundCompletedSteps:y}))}),[i,m,n]),L=s.useCallback((()=>{i(ia({accountId:n,selectedPeriod:m,backgroundCompletedSteps:0})),i(Ct({accountId:n,selectedPeriod:m,dismissedToBackground:!1}))}),[i,m,n]);s.useEffect((()=>()=>{Ta(null,!1)}),[]);const e=w?.parsedStatementData?.statementUpload?.statementMeta?.statementUploadId??w?.accountReconEntity.statementMetaData?.statementUploadId,a=w?.statementDateConflict?.previousReconciliationInfo?.reconciledByUserId,c=F((y=>a!=null&&a!==""?as(ns(y.userState,a)):"")),u=s.useCallback((()=>{i(la({accountId:n,selectedPeriod:m}))}),[i,n,m]),T=s.useCallback((()=>{i(la({accountId:n,selectedPeriod:m})),i(Xe({statementUploadChosen:!0}))}),[i,n,m]),E=(y,Z)=>{i(Cs(y,Z.split(".")[0]))},D=(y,Z)=>{if(Z===!0){const ne=w?.combinedStatementGroupId??w?.parsedStatementData?.statementUpload?.statementMeta?.combinedStatementGroupId??w?.parsedStatementData?.statementUpload?.combinedStatementDetails?.combinedStatementGroupId;if(ne!=null&&ne!=="")return void i(Ss({accountId:n,selectedPeriod:m,combinedStatementGroupId:ne,fileId:y}))}e!=null&&i(gs({accountId:n,selectedPeriod:m,fileId:y,statementUploadId:e}))},M=()=>{i(Xe({statementUploadChosen:!1}))},J=y=>{i(hs({accountId:n,selectedPeriod:m,payload:y,statementAccountScope:l===!0?w?.localData?.statementAccountScope??"single_account":"single_account"}))},Y=s.useCallback(((y,Z,ne)=>{i(ss({accountId:y,selectedPeriod:Z,statementUploadId:ne}))}),[i]),oe=s.useCallback(((y,Z,ne,Q,ce)=>{ce!=null&&ce!==""&&i(os(ce)),i(Q==null||Q===""?is({accountId:y,selectedPeriod:Z,statementUploadId:ne}):cs({accountId:y,selectedPeriod:Z,statementUploadId:ne,combinedStatementGroupId:Q}))}),[i]),ae=s.useCallback(((y,Z)=>{Z!==""&&i(ls({accountId:n,selectedPeriod:m,statementUpdateLocalData:y,statementUploadId:Z}))}),[i,n,m]),be=s.useCallback((()=>{e!=null&&i(w?.localData?.statementAccountScope!=="multi_account"?ds({accountId:n,selectedPeriod:m,statementUploadId:e}):rs({accountId:n,selectedPeriod:m,statementUploadId:e}))}),[i,w?.localData?.statementAccountScope,n,m,e]),ye=s.useCallback((y=>{e!=null&&i(us({accountId:n,selectedPeriod:m,statementUploadId:e,accountMappings:y}))}),[i,m,n,e]),ve=s.useCallback((()=>{i(Xe({statementUploadChosen:!0}))}),[i]),K=y=>{i(Qe({accountId:n,selectedPeriod:m,localData:{accountSource:y}}))},ot=y=>{i(Qe({accountId:n,selectedPeriod:m,localData:{statementAccountScope:y}}))},Ee=s.useCallback((()=>{i(Ra({accountId:n}))}),[i,n]),B=s.useCallback((y=>{i(ue(m,y,!0)),S()}),[i,m,S]),ct=s.useCallback((()=>{i(ms({accountId:n,selectedPeriod:m,statementProcessingFailed:!1})),i(ps({accountId:n,selectedPeriod:m}))}),[i,n,m]),Ae=s.useCallback((()=>{i(Da({accountId:n}))}),[i,n]),je=f.includes(n)?t.excludedAccountReconciliationByAccountID[n]:void 0;if(je!=null)return k.jsx(Ea,{children:k.jsx(Aa,{$isV3:A===!0,children:k.jsx(Dc,{excludedAccountReconciliation:je,includeAccountFetch:t.includeAccountFetchState,isReconV3Enabled:A,onDismissClick:S,onIncludeIntoReconciliation:Ae})})});if(w!=null){const y=A===!0?k.jsx(Fc,{excludeAccountFetch:t.excludeAccountFetchState,accountReconciliation:w,monthYearPeriod:m,onDismissClick:S,plaidConnectionDetails:t.plaidConnectionDetails,onFetchLinkTokenClick:g,onEstablishConnectionClick:d,onEditFileName:E,onDeleteFile:D,onSelectSourceType:K,onSelectStatementAccountScope:ot,isReconciliationCombinedStatementEnabled:l===!0,ledgerAccounts:I,statementOverrideWarningAccountIds:b,unavailableLedgerAccountIds:p,onConfirmStatementMapping:ye,filesEndPoint:Ue.fileMicroServiceBaseUrl,authParams:P,openFilePicker:z,onStatementUploadSuccess:J,onUploadWindowOpenedOnce:M,onExcludeFromReconciliation:Ee,onRetryParsing:Y,onFetchStatementParseInfo:oe,onReviewClicked:B,statementProcessingFailed:w.statementProcessingFailed,statementProcessingDismissedToBackground:w.statementProcessingDismissedToBackground,onDismissStatementProcessingFailed:ct,onContinueInBackground:N,onClearStatementProcessingDismissedToBackground:q,onResetStatementProcessingProgress:L,onStatementProcessingProgressChange:h,onStatementFlowVisibilityChange:G,onReuploadStatement:ve,onStatementFormDataChange:ae,onStatementConfirmSave:be,reconciledByName:c,onDismissDateConflict:u,onReuploadAfterDateConflict:T,isReconV3Enabled:A}):k.jsx(_c,{excludeAccountFetch:t.excludeAccountFetchState,accountReconciliation:w,monthYearPeriod:m,onDismissClick:S,plaidConnectionDetails:t.plaidConnectionDetails,onFetchLinkTokenClick:g,onEstablishConnectionClick:d,onEditFileName:E,onDeleteFile:D,onSelectSourceType:K,filesEndPoint:Ue.fileMicroServiceBaseUrl,authParams:P,openFilePicker:z,onStatementUploadSuccess:J,onUploadWindowOpenedOnce:M,onExcludeFromReconciliation:Ee});return k.jsx(Ea,{children:k.jsx(Aa,{$isV3:A===!0,children:y})})}return null})),Ea=Pe.div`
8
+ `;function ki({isFullView:t,matchId:n,onClose:S}){const{match:g,detailFetchState:d,handleOpenBill:i,handleApproveAndReverse:r,handleIgnoreMatchSuggestion:A,handleRefresh:l,handleUndoReversal:v,lastMatchResults:x,lastUndoResults:b,refreshStatus:C,ignoreStatus:f,matchAndReverseStatus:m,undoReversalStatus:z}=ci(n);return k.jsx(wc,{match:g,detailFetchState:d.fetchState,isRenderedInPanel:!t,isApproveInFlight:m.fetchState==="In-Progress",isIgnoreInFlight:f.fetchState==="In-Progress",isUndoInFlight:z.fetchState==="In-Progress",refreshStatus:C.fetchState,onNavigateBack:S,onOpenBill:i,onApproveAndReverse:r,onIgnoreMatchSuggestion:A,onRefresh:l,onUndoReversal:v,lastMatchResults:x,lastUndoResults:b})}const Ti=/^match\/([^/?]+)$/,bi=Wa({displayNamePrefix:"withActualMatchingSidePanel",usePanelSetup:function(t){const{useFeatureGate:n}=Ve(),{isFeatureEnabled:S}=n(H.isTransactionDetailSplitViewEnabled),{isFeatureEnabled:g}=n(H.isAccrualEnabled),d=(function(r=!0){const A=nt(),l=Te(),v=Be(),x=Ja(v),b=Ha({childPathPattern:Ti,enabled:r,listPath:x}),C=b.matchGroups[0]!=null&&b.matchGroups[0]!==""?li(b.matchGroups[0]):void 0,f=v.tenantEmailDomain??l.pathname.split("/").find(Boolean)??"",m=s.useRef({isOpen:b.isOpen,matchId:C});m.current={isOpen:b.isOpen,matchId:C};const z=s.useCallback((p=>{!b.isMobile&&r?m.current.isOpen&&m.current.matchId===p?b.closePanel():b.navigateToChild(`match/${encodeURIComponent(p)}`,{replace:m.current.isOpen}):A(`/${f}/expense-automation/actual-matching/${encodeURIComponent(p)}`)}),[A,b.isMobile,b.navigateToChild,b.closePanel,r,f]),w=s.useCallback((()=>{if(C==null)return;const p=ee(l.state?.pathnameStackToGoBack,`${l.pathname}${l.search}`);A(`/${f}/expense-automation/actual-matching/${encodeURIComponent(C)}`,{state:{pathnameStackToGoBack:p}})}),[l.pathname,l.search,l.state,C,A,f]),I=b.isOpen&&C!=null;return{closePanel:b.closePanel,isOpen:I,maximize:w,matchId:r&&I?C:void 0,openPanel:z}})(t&&g===!0&&S===!0),i=s.useMemo((()=>{if(d.isOpen&&d.matchId!=null)return k.jsx(ki,{isFullView:!1,matchId:d.matchId,onClose:d.closePanel},d.matchId)}),[d.closePanel,d.isOpen,d.matchId]);return{injectedProps:s.useMemo((()=>({closeMatchSidePanel:d.closePanel,isMatchPanelOpen:d.isOpen,matchPanelContent:i,matchPanelMatchId:d.matchId,openMatchPanel:d.openPanel})),[i,d.closePanel,d.isOpen,d.matchId,d.openPanel]),selectedItemId:d.matchId,sidePanel:{closePanel:d.closePanel,maximize:d.maximize}}}}),Pi=La.memo((({reconciliation:t,selectedDrawerAccountId:n,onClose:S,onFetchLinkTokenClick:g,onEstablishConnectionClick:d})=>{const i=ge(),{useFeatureGate:r}=Ve(),{isFeatureEnabled:A}=r(H.isReconV3Enabled),{isFeatureEnabled:l}=r(H.isReconciliationCombinedStatementEnabled),v=st.getSignedInUser(),x=F((y=>ke(y))),b=s.useMemo((()=>({userId:v?.userId??"",sessionId:v?.zeniSessionId??"",tenantId:x?.tenantId??""})),[v?.userId,v?.zeniSessionId,x?.tenantId]),{accountReconciliationsByAccountID:C,excludedAccountIDs:f,monthYearPeriod:m,statementUploadChosen:z}=t,w=C[n],I=s.useMemo((()=>Zn(C,n)),[C,n]),p=s.useMemo((()=>es(C)),[C]),P=s.useMemo((()=>ts(C,n)),[C,n]),_=s.useRef(!1),G=s.useCallback((y=>{_.current=y,Ta(n,y)}),[n]),q=s.useCallback((y=>{i(Ct({accountId:n,selectedPeriod:m,dismissedToBackground:!0,backgroundCompletedSteps:y.completedSteps,startedAtMs:y.startedAtMs,totalDurationSeconds:y.totalDurationSeconds})),y.accountMappings!=null&&i(Ke({accountId:n,selectedPeriod:m,localData:{combinedStatementAccountMappings:y.accountMappings}})),w!=null&&requestAnimationFrame((()=>{_.current||i(bt({messageSection:"statement_parsing_in_progress",messageText:"success",type:"info",showStatusIcon:!0,variables:[{variableName:"_account_name_",variableValue:Rc(w)}]}))}))}),[i,m,w,n]),N=s.useCallback((()=>{i(Ct({accountId:n,selectedPeriod:m,dismissedToBackground:!1}))}),[i,n,m]),h=s.useCallback((y=>{i(ia({accountId:n,selectedPeriod:m,backgroundCompletedSteps:y}))}),[i,m,n]),$=s.useCallback((()=>{i(ia({accountId:n,selectedPeriod:m,backgroundCompletedSteps:0})),i(Ct({accountId:n,selectedPeriod:m,dismissedToBackground:!1}))}),[i,m,n]);s.useEffect((()=>()=>{Ta(null,!1)}),[]);const e=w?.parsedStatementData?.statementUpload?.statementMeta?.statementUploadId??w?.accountReconEntity.statementMetaData?.statementUploadId,a=w?.statementDateConflict?.previousReconciliationInfo?.reconciledByUserId,c=F((y=>a!=null&&a!==""?as(ns(y.userState,a)):"")),u=s.useCallback((()=>{i(la({accountId:n,selectedPeriod:m}))}),[i,n,m]),T=s.useCallback((()=>{i(la({accountId:n,selectedPeriod:m})),i(Qe({statementUploadChosen:!0}))}),[i,n,m]),E=(y,Z)=>{i(Cs(y,Z.split(".")[0]))},D=(y,Z)=>{if(Z===!0){const ne=w?.combinedStatementGroupId??w?.parsedStatementData?.statementUpload?.statementMeta?.combinedStatementGroupId??w?.parsedStatementData?.statementUpload?.combinedStatementDetails?.combinedStatementGroupId;if(ne!=null&&ne!=="")return void i(Ss({accountId:n,selectedPeriod:m,combinedStatementGroupId:ne,fileId:y}))}e!=null&&i(gs({accountId:n,selectedPeriod:m,fileId:y,statementUploadId:e}))},M=()=>{i(Qe({statementUploadChosen:!1}))},J=y=>{i(hs({accountId:n,selectedPeriod:m,payload:y,statementAccountScope:l===!0?w?.localData?.statementAccountScope??"single_account":"single_account"}))},Y=s.useCallback(((y,Z,ne)=>{i(ss({accountId:y,selectedPeriod:Z,statementUploadId:ne}))}),[i]),oe=s.useCallback(((y,Z,ne,K,ce)=>{ce!=null&&ce!==""&&i(os(ce)),i(K==null||K===""?is({accountId:y,selectedPeriod:Z,statementUploadId:ne}):cs({accountId:y,selectedPeriod:Z,statementUploadId:ne,combinedStatementGroupId:K}))}),[i]),ae=s.useCallback(((y,Z)=>{Z!==""&&i(ls({accountId:n,selectedPeriod:m,statementUpdateLocalData:y,statementUploadId:Z}))}),[i,n,m]),Pe=s.useCallback((()=>{e!=null&&i(w?.localData?.statementAccountScope!=="multi_account"?ds({accountId:n,selectedPeriod:m,statementUploadId:e}):rs({accountId:n,selectedPeriod:m,statementUploadId:e}))}),[i,w?.localData?.statementAccountScope,n,m,e]),ye=s.useCallback((y=>{e!=null&&i(us({accountId:n,selectedPeriod:m,statementUploadId:e,accountMappings:y}))}),[i,m,n,e]),ve=s.useCallback((()=>{i(Qe({statementUploadChosen:!0}))}),[i]),X=y=>{i(Ke({accountId:n,selectedPeriod:m,localData:{accountSource:y}}))},ot=y=>{i(Ke({accountId:n,selectedPeriod:m,localData:{statementAccountScope:y}}))},Ee=s.useCallback((()=>{i(Ra({accountId:n}))}),[i,n]),B=s.useCallback((y=>{i(ue(m,y,!0)),S()}),[i,m,S]),ct=s.useCallback((()=>{i(ms({accountId:n,selectedPeriod:m,statementProcessingFailed:!1})),i(ps({accountId:n,selectedPeriod:m}))}),[i,n,m]),Ae=s.useCallback((()=>{i(Da({accountId:n}))}),[i,n]),je=f.includes(n)?t.excludedAccountReconciliationByAccountID[n]:void 0;if(je!=null)return k.jsx(Ea,{children:k.jsx(Aa,{$isV3:A===!0,children:k.jsx(Dc,{excludedAccountReconciliation:je,includeAccountFetch:t.includeAccountFetchState,isReconV3Enabled:A,onDismissClick:S,onIncludeIntoReconciliation:Ae})})});if(w!=null){const y=A===!0?k.jsx(Fc,{excludeAccountFetch:t.excludeAccountFetchState,accountReconciliation:w,monthYearPeriod:m,onDismissClick:S,plaidConnectionDetails:t.plaidConnectionDetails,onFetchLinkTokenClick:g,onEstablishConnectionClick:d,onEditFileName:E,onDeleteFile:D,onSelectSourceType:X,onSelectStatementAccountScope:ot,isReconciliationCombinedStatementEnabled:l===!0,ledgerAccounts:I,statementOverrideWarningAccountIds:P,unavailableLedgerAccountIds:p,onConfirmStatementMapping:ye,filesEndPoint:Ue.fileMicroServiceBaseUrl,authParams:b,openFilePicker:z,onStatementUploadSuccess:J,onUploadWindowOpenedOnce:M,onExcludeFromReconciliation:Ee,onRetryParsing:Y,onFetchStatementParseInfo:oe,onReviewClicked:B,statementProcessingFailed:w.statementProcessingFailed,statementProcessingDismissedToBackground:w.statementProcessingDismissedToBackground,onDismissStatementProcessingFailed:ct,onContinueInBackground:q,onClearStatementProcessingDismissedToBackground:N,onResetStatementProcessingProgress:$,onStatementProcessingProgressChange:h,onStatementFlowVisibilityChange:G,onReuploadStatement:ve,onStatementFormDataChange:ae,onStatementConfirmSave:Pe,reconciledByName:c,onDismissDateConflict:u,onReuploadAfterDateConflict:T,isReconV3Enabled:A}):k.jsx(_c,{excludeAccountFetch:t.excludeAccountFetchState,accountReconciliation:w,monthYearPeriod:m,onDismissClick:S,plaidConnectionDetails:t.plaidConnectionDetails,onFetchLinkTokenClick:g,onEstablishConnectionClick:d,onEditFileName:E,onDeleteFile:D,onSelectSourceType:X,filesEndPoint:Ue.fileMicroServiceBaseUrl,authParams:b,openFilePicker:z,onStatementUploadSuccess:J,onUploadWindowOpenedOnce:M,onExcludeFromReconciliation:Ee});return k.jsx(Ea,{children:k.jsx(Aa,{$isV3:A===!0,children:y})})}return null})),Ea=be.div`
9
9
  display: flex;
10
10
  flex-direction: column;
11
11
  height: 100%;
12
- `,Aa=Pe.div`
12
+ `,Aa=be.div`
13
13
  flex: 1;
14
14
  min-height: 0;
15
15
  display: flex;
@@ -18,11 +18,11 @@ import{j as k}from"./liveblocks-gNIoHksP.js";import{u as ge,h as nt,g as Te,j as
18
18
  min-width: 0;
19
19
  overflow-x: hidden;
20
20
  overflow-y: ${t=>t.$isV3===!0?"hidden":"auto"};
21
- `;function yi({panelType:t,scheduleId:n,onClose:S,onCloseAfterDecision:g}){return k.jsx(Ei,{children:k.jsx(Ai,{children:vi(t,n,S,g)})})}function vi(t,n,S,g){switch(t){case"one_time_accrual":return k.jsx(pi,{isRenderedInPanel:!0,accrualIdOverride:n,onPanelNavigateBack:S});case"accrued_expenses":return k.jsx(mi,{isRenderedInPanel:!0,scheduleDetailIdOverride:n,onPanelNavigateBack:S,onPanelCloseAfterDecision:g});case"fixed_assets":return k.jsx(ui,{isRenderedInPanel:!0,scheduleDetailIdOverride:n,onPanelNavigateBack:S,onPanelCloseAfterDecision:g});case"prepaid_expenses":return k.jsx(di,{isRenderedInPanel:!0,scheduleDetailIdOverride:n,scheduleTypeOverride:"prepaid_expenses",onPanelNavigateBack:S,onPanelCloseAfterDecision:g})}}const Ei=Pe.div`
21
+ `;function yi({panelType:t,scheduleId:n,onClose:S,onCloseAfterDecision:g}){return k.jsx(Ei,{children:k.jsx(Ai,{children:vi(t,n,S,g)})})}function vi(t,n,S,g){switch(t){case"one_time_accrual":return k.jsx(pi,{isRenderedInPanel:!0,accrualIdOverride:n,onPanelNavigateBack:S});case"accrued_expenses":return k.jsx(mi,{isRenderedInPanel:!0,scheduleDetailIdOverride:n,onPanelNavigateBack:S,onPanelCloseAfterDecision:g});case"fixed_assets":return k.jsx(ui,{isRenderedInPanel:!0,scheduleDetailIdOverride:n,onPanelNavigateBack:S,onPanelCloseAfterDecision:g});case"prepaid_expenses":return k.jsx(di,{isRenderedInPanel:!0,scheduleDetailIdOverride:n,scheduleTypeOverride:"prepaid_expenses",onPanelNavigateBack:S,onPanelCloseAfterDecision:g})}}const Ei=be.div`
22
22
  display: flex;
23
23
  flex-direction: column;
24
24
  height: 100%;
25
- `,Ai=Pe.div`
25
+ `,Ai=be.div`
26
26
  flex: 1;
27
27
  min-height: 0;
28
28
  display: flex;
@@ -31,7 +31,7 @@ import{j as k}from"./liveblocks-gNIoHksP.js";import{u as ge,h as nt,g as Te,j as
31
31
  min-width: 0;
32
32
  overflow-x: hidden;
33
33
  overflow-y: auto;
34
- `,xi=/^schedule\/(prepaid_expenses|fixed_assets|accrued_expenses|one_time_accrual)\/([^/?]+)$/,wi=Wa({displayNamePrefix:"withScheduleSidePanel",usePanelSetup:function(t){const n=(function(C=!0){const f=nt(),m=Te(),z=ge(),w=Be(),I=Ha({childPathPattern:xi,enabled:C}),p=I.matchGroups[0],b=Ka(p)?p:void 0,_=I.matchGroups[1]!=null&&I.matchGroups[1]!==""?I.matchGroups[1]:void 0,G=I.isOpen&&b!=null&&_!=null,N=w.tenantEmailDomain??m.pathname.split("/").find(Boolean)??"",q=s.useRef({isOpen:G,scheduleId:_});q.current={isOpen:G,scheduleId:_};const h=s.useCallback(((e,a,c)=>{c!=null&&(a==="prepaid_expenses"||a==="fixed_assets")&&z(Oa({selectedJEScheduleKey:c})),!I.isMobile&&C?q.current.isOpen&&q.current.scheduleId===e?I.closePanel():I.navigateToChild(`schedule/${a}/${e}`,{replace:q.current.isOpen}):f(va(a,e,N),{state:{message:"expenseAutomation",origin:"je_schedules"}})}),[z,f,I.isMobile,I.navigateToChild,I.closePanel,C,N]),L=s.useCallback((()=>{if(b==null||_==null)return;const e=ee(m.state?.pathnameStackToGoBack,m.pathname);f(va(b,_,N),{state:{pathnameStackToGoBack:e,message:"expenseAutomation",origin:"je_schedules"}})}),[f,b,_,N,m.pathname,m.state]);return{closePanel:I.closePanel,isOpen:G,maximize:L,openPanel:h,panelType:G?b:void 0,scheduleId:G?_:void 0}})(t),S=s.useRef(null),[g,d]=s.useState(null),i=s.useMemo((()=>({registerPanelDirtyGuard:C=>{S.current=C}})),[]),r=s.useCallback((C=>{S.current?.isDirty()===!0?d((()=>C)):C()}),[]),A=s.useCallback((()=>{r(n.closePanel)}),[r,n.closePanel]),l=s.useCallback((()=>{r(n.maximize)}),[r,n.maximize]),v=s.useCallback(((C,f,m)=>{r((()=>n.openPanel(C,f,m)))}),[r,n.openPanel]),x=s.useMemo((()=>{if(g!=null)return{onCancel:()=>d(null),onDiscard:()=>{S.current=null,d(null),g()}}}),[g]),P=s.useMemo((()=>{if(n.isOpen&&n.panelType!=null&&n.scheduleId!=null)return k.jsx(Mc.Provider,{value:i,children:k.jsx(yi,{panelType:n.panelType,scheduleId:n.scheduleId,onClose:A,onCloseAfterDecision:()=>{S.current=null,n.closePanel()}},`${n.panelType}:${n.scheduleId}`)})}),[n.isOpen,n.panelType,n.scheduleId,n.closePanel,A,i]);return{injectedProps:s.useMemo((()=>({closeSchedulePanel:A,isSchedulePanelOpen:n.isOpen,openSchedulePanel:v,schedulePanelContent:P,schedulePendingDiscardConfirmation:x})),[A,v,P,x,n.isOpen]),selectedItemId:n.scheduleId,sidePanel:{closePanel:A,maximize:l}}}});function Ri({companyId:t,closeCustomerRequestDrawer:n,addCustomerRequest:S,resetCustomerRequest:g}){const d=st.getSignedInUser();if(d==null)throw Error("Can't access Customer Request page without signing in...");const i=F((r=>fs(r,t,d)));return s.useEffect((()=>{g()}),[]),k.jsx(k.Fragment,{children:i.fetchState==="In-Progress"||i.companyMonthEndReportTemplatesData.fetchState==="In-Progress"?k.jsx(Na,{fetchState:"In-Progress"}):k.jsx(Oc,{onCloseClick:n,addCustomerRequest:S,snippets:i.companyMonthEndReportTemplatesData,bulletPoints:i.zeniRequestsData??[]})})}const Di={schedules:"Review Schedules",actual_matching:"Actual Matching",existing_schedules:"Existing Schedules"},Fi=()=>{const t=F((x=>Oe(x))),n=Te(),{currentSelectedViewFetchState:S,currentSelectedView:g,selectedPeriod:d}=t,i=et(g),r=et(S.fetchState),A=t.jeSchedules.uiState.selectedPageTab??"schedules",l=et(A),v=s.useCallback((x=>{const P=n.state?.referrer;g==="transaction_categorization"&&(t.selectedTransactionCategorizationTab==="review"?W.trackTransactionsReviewPage(d.month,d.year,t.transactionView.totalCountByTab.review,0,x,P??null):W.trackTransactionsAutoCategorisedPage(d.month,d.year,t.transactionView.totalCountByTab.autoCategorized,0,x,P??null)),g==="missing_receipts"&&W.trackMissingReceiptsPage(d.month,d.year,x,t.missingReceipts.transactions.length,P??null),g==="je_schedules"&&W.trackMonthCloseScheduleListPage(d.month,d.year,x,t.jeSchedules.pendingReviewSchedules.length,t.jeSchedules.failedPostings.length,(C=>{const f={accruedCount:0,fixedAssetsCount:0,oneTimeAccrualCount:0,prepaidCount:0};return C.forEach((m=>{if(Is(m))f.oneTimeAccrualCount+=1;else switch(ks(m)){case"prepaid_expenses":f.prepaidCount+=1;break;case"fixed_assets":f.fixedAssetsCount+=1;break;case"accrued_expenses":f.accruedCount+=1}})),f})(t.jeSchedules.pendingReviewSchedules),Di[A],P??null),g==="flux_analysis"&&W.trackFluxAnalysisPage(d.month,d.year,x,_i(t.fluxAnalysis),P??null),g==="month_end_insights"&&t.auditSummary?.auditScorePercentage!=null&&W.trackInsightsEmailPage(d.month,d.year,x,"draft",t.auditSummary.auditScorePercentage,null,P??null)}),[d,t,A]);return s.useEffect((()=>{(r!==S.fetchState||g!==i||g==="je_schedules"&&l!=null&&A!==l)&&S.fetchState==="Completed"&&v(!1)}),[g,S.fetchState,i,A,l]),v},_i=t=>t.sections.generalExpense.vendors.length+t.sections.reimbursement.vendors.length,{common:{strings:{hyphen:Mi,comma:xa,space:Oi}},dateFormat:Qa}=Wc.getLocalizedStrings(),wa=Ec,Ui=Yn((function(t,n){const{uncategorizedAccounts:S,vendorSearchAutoCompleteData:g,monthEndInsightsCustomerRequestData:d,monthEndInsightsPreviewMode:i,companyId:r,isMissingReceiptsBulkUploadEnabled:A,isTransactionActivityEnabled:l,newScheduleActiveType:v}=n,x=st.getSignedInUser(),P=t.tenantState.currentTenantId,C={userId:x?.userId??"",sessionId:x?.zeniSessionId??"",tenantId:P??""},f=Oe(t),{selectedTransactionCategorizationTab:m}=f,{searchTransactionsResults:z,searchTransactionsFetchState:w}=Ns(t),I=v==="prepaid_expenses"?"prepaid_expenses":"fixed_assets",{accountListNestedAccountHierarchy:p,classListNestedAccountHierarchy:b,allDepreciationAccountListNestedAccountHierarchy:_,newScheduleLocalData:G,saveStatus:N}=qs(t,I);return{expenseAutomationViewSelector:f,accountListNestedAccountHierarchy:p,allDepreciationAccountListNestedAccountHierarchy:_,baseTransactionSearchFetchState:w,baseTransactionSearchResults:z,classListNestedAccountHierarchy:b,newScheduleLocalData:G,initialSelectedBaseTransaction:G.selectedBaseTransactionId!=null?Js(t.transactionState,Ys(G.selectedBaseTransactionId)):void 0,newAccrualAccountsView:Hs(t),newScheduleSaveStatus:N,bulkUploadSelector:A===!0?f.missingReceipts.bulkUpload:void 0,vendorSearchAutoCompleteData:g,authParams:C,receiptUploadEndpoint:`${Ue.accountMicroServiceBaseUrl}`,transactionAttachmentsEndpoint:`${ba}/transaction_attachments`,bulkUploadEndpoint:A===!0?`${Ue.communicationAgentMicroServiceBaseUrl}/1.0/receipts/bulk-upload`:void 0,isDisabled:!1,currentTab:m,selectedTransactionGroup:f.transactionView.selectedTransactionGroup,monthEndInsightsCustomerRequestData:d,monthEndInsightsPreviewMode:i,allThreadsSectionOpen:!1,enableMonthEndInsightsZeniGPTFeature:!1,loggedInUser:x,uncategorizedAccounts:S,companyId:r,isTransactionActivityEnabled:l,receiptsEmail:Ks(t.tenantState,P),downloadParams:{authParams:C,jeScheduleEndPoint:`${ba}/jeScheduleReports`,timezone:Ws(),companyName:ke(t).companyName}}}),(function(t,n){const{themeState:S,isAccountingClassesEnabled:g,isCOTEnabled:d,isMissingReceiptsBulkUploadEnabled:i,location:r,vendorSearchAutoCompleteData:A,expenseAutomationViewSelector:l,currentTenant:v,newScheduleActiveType:x,uncategorizedAccounts:P,navigate:C,onClickCustomerRequest:f,handleEditClick:m,closeSchedulePanel:z,isSchedulePanelOpen:w,openSchedulePanel:I,setActivityLogTransactionId:p}=n,{selectedPeriod:b,currentSelectedView:_,reconciliation:{selectedAccountId:G}}=l,{accountSettingsView:N}=l.jeSchedules,q=Ua(b),h=at(q.start),L=at(q.end);return{onZeniLogoClick:()=>{S.toggle()},onUploadReceiptAttachment:e=>{W.trackMissingReceiptAttached(b.month,b.year),t(pc(e))},onUploadTransactionReceipt:(e,a,c,u,T,E)=>{t(Ia(e,a,{fetchState:"In-Progress"}));const D=()=>t(Ia(e,a,{fetchState:"Error"}));Xc(`${Ue.accountMicroServiceBaseUrl}/1.0/transactions/${a}/attachments`,E,a,c,u,T).then((M=>{M!=null?t(mc(e,M)):D()})).catch(D)},onMissingReceiptsRowClick:(e,a)=>{if(n.openTransactionPanel)return void n.openTransactionPanel(e,a);const c=ee(r.state?.pathnameStackToGoBack,r.pathname);C(`../../transaction/${a}/${e}`,{state:{pathnameStackToGoBack:c,message:"expenseAutomation",origin:"missing_receipts"}})},onUploadReceiptComplete:(e,a)=>{t(uc(e,a)),v!=null&&t(Me({tenantId:v.tenantId,period:a,refreshViewInBackground:!0}))},onUploadReceiptFetchStatus:(e,a,c,u)=>{t(dc(e,{fetchState:a,error:c})),c!=null&&t(Pt({messageSection:"missing_receipts_attachment",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"__message__",variableValue:u!=null?Oi+Mi+u+xa:xa}]}))},onUpdateJESchedulesUIState:e=>{const a=l.jeSchedules.uiState,c=e.selectedPageTab!=null&&e.selectedPageTab!==a.selectedPageTab,u=e.selectedJETypeFilter!==void 0&&e.selectedJETypeFilter!==a.selectedJETypeFilter;c&&n.closeMatchSidePanel?.(),w===!0&&(c||u)&&z?.(),e.createdGroupCollapsed!=null?t(oc()):e.pendingGroupCollapsed!=null?t(cc()):e.failedGroupCollapsed!=null?t(ic()):e.selectedJETypeFilter!==void 0?t(lc(e.selectedJETypeFilter)):t(rc(e))},onUpdateMissingReceiptsUIState:e=>{t(sc(e))},onFetchMissingReceiptsList:()=>{L!=null&&h!=null&&t(ja({start:h,end:L},{amount:75,currencyCode:"USD",currencySymbol:"$"},!0,!1))},...i===!0?{onBulkUploadFiles:e=>{t(vc(e))},onBulkUploadProgress:e=>{t(yc(e))},onBulkUploadSuccess:e=>{t(bc({batchId:e}))},onBulkUploadUploadedFileCount:e=>{t(Pc(e))},onConfirmBulkUploadMatch:(e,a,c,u,T)=>{t(Tc(e,a,c,u,T))},onBulkUploadConfirmMatchAcknowledged:()=>{t(kc())},onSetBulkUploadResultsTab:e=>{t(Ic(e))},onSetBulkUploadCompletedSubTab:e=>{t(fc(e))},onSetBulkUploadSortConfig:(e,a)=>{t(ka({sortKey:e,sortOrder:a}))},onClearBulkUpload:()=>{t(Cc())},onSearchTransactionsForManualMatch:(e,a)=>{t(wa(e,a??void 0))},onLoadMoreManualSearch:()=>{const{manualSearch:e}=l.missingReceipts.bulkUpload;e.nextPageToken!=null&&e.searchQuery!==""&&t(wa(e.searchQuery,e.nextPageToken))},onFetchCompletedTransactions:(e,a)=>{t(gc(e,a))},onClearBulkUploadBatchDetailsForScopeChange:()=>{t(Sc())},onFetchBulkUploadBatches:e=>{t(Ba(e))},onFetchMoreBatchDetails:()=>{t(hc())},onResetBulkUploadSort:()=>{t(ka({sortKey:void 0,sortOrder:void 0}))}}:{},onClearMissingReceiptsTabNavigation:()=>{t(nc())},onSearchTextChanged:e=>{const a=l.currentSelectedView,c=l.selectedTransactionCategorizationTab;a==="transaction_categorization"&&(t(ft({selectedTab:c,uiState:{searchString:e}})),L!=null&&h!=null&&t(Se(c,{start:h,end:L},!0,!1,e,void 0,!1,!0)))},onFiltersChange:e=>{const a=l.selectedTransactionCategorizationTab;t(ac({filters:e,selectedTab:a}))},onRefresh:()=>{n.trackExpenseAutomationTabAnalytics(!0),t(tc())},onClose:()=>{_==="reconciliation"&&G!=null&&t(fa({selectedAccountId:void 0})),C("../")},onBack:()=>{_==="reconciliation"&&G!=null&&t(fa({selectedAccountId:void 0}))},onSaveReconciliation:e=>{t(ec(e))},onSaveReconciliationReview:e=>{t(Zo(e))},onUpdateStep:e=>{const{selectedPeriod:a}=l,c=ee(r.state?.pathnameStackToGoBack,r.pathname);C(`../${e}/${a.month}-${a.year}`,{state:{pathnameStackToGoBack:c,referrer:l.currentSelectedView}}),t(Va(e))},handleLogOutClick:()=>{const e=ee(r.state?.pathnameStackToGoBack,r.pathname);C("/signout",{replace:!0,state:{pathnameStackToGoBack:e,message:"logout"}})},onJeAccountSettingsChange:e=>{const{vendorsAccountSection:a}=e,{prepaidExpensesAccount:c,fixedAssetsAccount:u,accruedExpensesAccount:T}=a,E=It(N.prepaidExpensesAccountList,c.selectedOptions),D=It(N.fixedAssetsAccountList,u.selectedOptions),M=It(N.accruedExpensesAccountList,T.selectedOptions),J={selectedPrepaidExpensesAccountIds:E.map((Y=>Y.accountId)),selectedFixedAssetsAccountIds:D.map((Y=>Y.accountId)),selectedAccruedExpensesAccountIds:M.map((Y=>Y.accountId))};t(Xo({data:J}))},onSaveJeAccountSettingsClick:()=>{t(Qo())},onJESchedulesFormDataChange(e,a){const{jeScheduleID:c,accumulatedDepreciationCategory:u,scheduleClass:T,scheduleExpenseCategory:E,vendor:D}=a,{allAccountList:M,allClassList:J,allDepreciationAccountList:Y}=l.jeSchedules,oe=A.entityAutoCompleteView.vendor.length>0?A.entityAutoCompleteView.vendor.find((K=>K.id===D?.selectedOption)):void 0,ae={id:oe?.zeniId??D?.selectedOption??"",name:oe?.name??D?.defaultOptions.find((K=>K.value===D?.selectedOption))?.label??"",logo:oe?.logo},be=E?.selectedOption!=null?M.find((K=>K.qboId===E.selectedOption)):void 0,ye=T?.selectedOption!=null?J.find((K=>K.classId===T.selectedOption)):void 0,ve=u?.selectedOption!=null?Y.find((K=>K.qboId===u.selectedOption)):void 0;t(Ko({scheduledJournalEntryID:e,localData:{jeScheduleID:c,scheduledJournalEntryID:e,updatedCategoryId:be?.accountId,updatedClassId:ye?.classId,updatedAccumulatedDepreciationCategoryID:ve?.accountId,updatedVendor:{id:ae.id,name:ae.name}}}))},onRevertJeSchedule(e,a,c,u,T){t(Wo(e,a,c,u,T))},ignoreRecommendedJeSchedule(e,a,c,u){t(Ho(e,a,c,u))},vendorSearchAutoCompleteActions:{onAutoCompleteInputChange:(e,a)=>{e.trim().length>=2?t(pa({searchString:e,entityType:a,searchOrigin:"common"})):e.trim().length===0&&t(Ke("common"))},onCancelAutoComplete:()=>{t(Ke("common"))}},onPostJESchedule(e,a){t(Yo({scheduledJournalEntryID:e,jeScheduleTransactionKey:a}))},clearJeScheduleLocalData(){t(Jo())},onViewTransaction(e){if(n.tenantEmailDomain==null)return;const a=gi(e,n.tenantEmailDomain),c=ee(n.location.state?.pathnameStackToGoBack,`${n.location.pathname}${n.location.search}`);n.navigate(a,{state:{pathnameStackToGoBack:c,message:"expenseAutomation",origin:"je_schedules"}})},onSearchBaseTransaction(e){t(qo({query:e,scheduleType:x==="prepaid_expenses"?"prepaid_expenses":"fixed_assets"}))},onNewScheduleFormChange(e,a){const c=vt(e)==="prepaid_expenses"?"prepaid_expenses":"fixed_assets";t(Ca({scheduleType:c,localData:a}))},onOpenMatchNewModal(){t(No())},onIgnoreMatchSuggestion(e,a,c){t(Go(e,a,c))},onCloseMatchNewModal(){t(Lo())},onClearMatchNewModal(){t($o())},onSearchMatchTransactions(e,a){t(zo(e,a))},onSearchMatchAccruals(e,a){t(jo(e,a))},onMatchAndReverse(e){t(Vo(e.transactionId,e.transactionIntegrationId,e.transactionType,e.lineIds,e.transactionSyncToken,e.accrualIds,!0))},onUpdateActualMatchingUIState(e){t(Bo(e))},onUndoReversal(e,a){t(Uo(e,a))},onSaveSchedule(e,a){const c=e==="prepaid_expenses"?"prepaid_expenses":"fixed_assets",{allAccountList:u,allDepreciationAccountList:T}=l.jeSchedules,E=a.selectedAccount!=null?u.find((M=>M.qboId===a.selectedAccount)):void 0,D=a.selectedAccumulatedDepreciationCategory!=null?T.find((M=>M.qboId===a.selectedAccumulatedDepreciationCategory)):void 0;t(Ca({scheduleType:c,localData:{...a,selectedAccount:E?.accountId,selectedAccumulatedDepreciationCategory:D?.accountId}})),t(Oo({scheduleType:c}))},onCreateAccruedSchedule(e){const a="accrued_expenses";t(Ro()),t(Do()),t(Fo({scheduleType:a,localData:e,selectedJeScheduleDetailId:void 0})),t(_o({scheduleType:a})),t(Mo(a,void 0))},onCreateOneTimeAccrual(e){t(wo(e))},handleJeScheduleClick:(e,a,c)=>{if((function(T,E){return E!=="accrued_expenses"})(0,c)&&t(Oa({selectedJEScheduleKey:a})),I!=null&&Ka(c))return void I(e,c,a);const u=ee(r.state?.pathnameStackToGoBack,r.pathname);C(`../../vendors/schedules/${c}/details/${e}`,{state:{pathnameStackToGoBack:u,message:"expenseAutomation",origin:"je_schedules"}})},onOneTimeAccrualFeedback:(e,a,c,u)=>{t(a!=="revert"?xo(e,c,u):Ao(e,c,u))},onOneTimeAccrualClick:e=>{if(I!=null)return void I(e,"one_time_accrual");const a=ee(r.state?.pathnameStackToGoBack,r.pathname);C(`../../vendors/schedules/one_time_accrual/details/${e}`,{state:{pathnameStackToGoBack:a,message:"expenseAutomation",origin:"je_schedules"}})},onOpenMatch:e=>{n.openMatchPanel?.(e)},onOpenBill(e){if(n.tenantEmailDomain==null)return;const a=ii(e,n.tenantEmailDomain,n.location);n.navigate(a.pathname,{state:a.state})},improveMonthEndInsightsUsingZeniGPTClick:e=>{v!=null&&t(Eo(e,v.companyId,v.tenantId))},onClickCustomerRequest:f,setActivityLogTransactionId:p,onCloseAllThreadsSection:()=>{},onCloseFileAttachmentSnackBar:()=>{t(vo())},onOpenFileAttachmentSnackBar:()=>{t(Pt({messageSection:"cockpit_month_end_email_attachment_upload",messageText:"failed",type:"error",showStatusIcon:!0}))},onRemoveFileAttachment:e=>{t(yo(e))},onUpdateFileAttachment:e=>{t(bo({files:e}))},previewMonthEndReport:(e,a,c,u,T)=>{v!=null&&t(ga(e,v.companyId,a,!0,c,u,{agentInsightEdits:T,tenantId:v.tenantId}))},saveMonthEndReport:(e,a,c,u,T)=>{v!=null&&t(ga(e,v.companyId,a,!1,c,u,{agentInsightEdits:T,tenantId:v.tenantId}))},onEditMonthEndInsightsClick:m,sendMonthEndReport:e=>{const a=r.state?.referrer,{selectedPeriod:c,auditSummary:u}=l;v!=null&&u?.auditScorePercentage!=null&&(t(To(v.companyId,e,v.tenantId)),W.trackInsightsEmailPage(c.month,c.year,!1,"draft",u.auditScorePercentage,Po().format(Qa.analytics.MMMDDCommaYYYYformat),a??null))},onTransactionCategorizationRowClick:(e,a)=>{const c=l.transactionView.uiState.searchString??"",u=l.transactionView.transactions,T=u.findIndex((M=>M.id===e)),E=c.length>0?{resultPosition:T>=0?T+1:void 0,resultsCount:u.length,searchTerm:c}:void 0;if(n.openTransactionPanel)return void n.openTransactionPanel(e,a,E);const D=ee(r.state?.pathnameStackToGoBack,r.pathname);C(`../../transaction/${a}/${e}`,{state:{pathnameStackToGoBack:D,message:"expenseAutomation",origin:"transaction_categorization",searchContext:E}})},setLocalDataForCategoryAndClass:(e,a,c,u,T,E,D,M,J,Y,oe,ae)=>{t(ko(e,a,c,u,P,T,E,D,M,J,Y,oe,ae))},onCancelAutoComplete:()=>{t(Ke("common"))},updateExpenseAutomationReconListScrollPosition:e=>{t(ha({scrollPosition:e}))},onUpdateTab:e=>{n.closeSidePanel?.(),L!=null&&h!=null&&(t(Se(e,{start:h,end:L},!1,!1)),t(Io(e)))},onUpdateTransactionCategorizationCompletedSubTab:e=>{n.closeSidePanel?.(),L!=null&&h!=null&&(t(fo(e)),t(Se("autoCategorized",{start:h,end:L},!1,!1)))},onTransactionGroupChange:e=>{n.closeSidePanel?.(),L!=null&&h!=null&&(t(Co(e)),t(Se(n.expenseAutomationViewSelector.selectedTransactionCategorizationTab,{start:h,end:L},!1,!1)))},onUpdateTransactionCategorizationUIState:(e,a)=>{t(ft({selectedTab:e,uiState:a})),L!=null&&h!=null&&t(Se(e,{start:h,end:L},!1,!1,a.searchString,null,!0))},onUpdateScrollYOffSetTransactionCategorizationUIState:(e,a)=>{t(ft({selectedTab:e,uiState:a}))},onFetchTransactionCategorizationList:(e,a,c,u,T,E)=>{L!=null&&h!=null&&t(Se(e,{start:h,end:L},!0,c,a,u,T,E))},resetTransactionCategorizationLocalData:(e,a,c,u,T,E,D)=>{t(go(e,a,c,u,D??null,T,E,!1)),si(t,a.map(String))},updateSelectedVendorForTransaction:(e,a,c,u,T)=>{t(Sa({selectedTab:e,transactionId:a,lineId:c,selectedTransaction:u,uncategorizedAccounts:P,updatedVendor:T,isAccountingClassesEnabled:g}))},onSaveUpdateTransactionCategorization:(e,a,c)=>{const u=r.state?.referrer;e==="autoCategorized"?W.trackTransactionsAutoCategorisedPage(b.month,b.year,l.transactionView.totalCountByTab.autoCategorized,a.length,!1,u??null):W.trackTransactionsReviewPage(b.month,b.year,l.transactionView.totalCountByTab.review,a.length,!1,u??null),t(So(e,a,c)),ni(a.map(String))},onUpdateSelectedCheckboxTransactionIds:(e,a)=>{t(ho({selectedTab:e,transactionIds:a}))},onFetchRecommendationsForEntityCategorizationWithCustomer:(e,a,c,u,T,E)=>{const{transactionId:D,transaction:M,lineIds:J}=a;E!=null&&t(mo({transactionId:D,customerUpdates:E})),t(po({selectedTab:u,transactionId:D.id,lineId:J[0],selectedTransaction:M,uncategorizedAccounts:P,updatedCustomer:E,selectedEntity:T,isAccountingClassesEnabled:g})),T!=null&&t(yt({entity:T,amount:e,transactionDetails:a,flowType:"categorization",selectedTab:u,isFetchCOT:d}))},onFetchRecommendationsForEntityCategorization:(e,a,c,u,T,E)=>{const{transactionId:D,transaction:M,lineIds:J}=a;E!=null&&(t(lo({transactionId:D,vendorUpdates:{name:E.name,id:E.id?E.id:void 0}})),t(ro({vendorId:E.id?E.id:void 0,localData:{vendorName:E.name,vendorId:E.id?E.id:void 0}}))),E?.id?(t(Sa({selectedTab:u,transactionId:D.id,lineId:J[0],selectedTransaction:M,uncategorizedAccounts:P,updatedVendor:E,selectedEntity:T,isAccountingClassesEnabled:g})),T!=null&&t(yt({entity:T,amount:e,transactionDetails:a,flowType:"categorization",selectedTab:u,isFetchCOT:d}))):t(uo({selectedTab:u,transactionId:D.id,lineId:J[0]}))},fetchFluxViewOnScroll:(e,a)=>{t(Ze(e,!0,!1,a,!1,!0))},onFetchFluxViewList:()=>{t(Ze(b,!0,!1,null,!1,!1))},markAsReview:(e,a,c,u)=>{W.trackFluxAnalysisReviewed(c.month,c.year,u??!1,e),t(io(a,e,c,u??!1))},onUpdateFluxAnalysisUIState:e=>{t(co(e))},updateOperatingExpensesIdsForReview:e=>{t(oo({operatingExpenseIds:e,selectedPeriod:b}))},redirectToVendorDetailPage:e=>{if(n.tenantEmailDomain!=null){const a=Si(e.id,e.qboId,n.tenantEmailDomain),c=ee(n.location.state?.pathnameStackToGoBack,n.location.pathname);n.navigate(a,{state:{pathnameStackToGoBack:c,message:"expenseAutomation",referrer:"Vendor List",origin:"flux_analysis"}})}},updateSectionIdsForReview:e=>{t(so({sectionId:e,selectedPeriod:b}))},onFetchReimbursementView:(e,a,c)=>{t(Ze(e,!0,!1,a,!0,c))},onReviewClicked:e=>{t(ue(b,e))},setOpenDrawerClicked:e=>{t(tt({selectedDrawerAccountId:e}))},onFetchLinkTokenClick:(e,a)=>{t(Fa("expense_automation_reconcile",e,a))},onEstablishConnectionClick:(e,a)=>{const c=v?.companyId;c!=null&&(t(_a(e,c,"expense_automation_reconcile",void 0,"link_account_no_microdeposit",a)),t(Ma({accountId:a,connectionInProgress:!0})))},onAddStatementClick:e=>{t(tt({selectedDrawerAccountId:e})),t(Qe({accountId:e,selectedPeriod:b,localData:{accountSource:"bank_statement"}})),t(Xe({statementUploadChosen:!0}))},onReloadReconciliationListPage:()=>{t(ue(b,void 0,!0,!1))},onUpdateReconcileTabLocalData:e=>{t(no({selectedTransactionIds:e}))},onReconTabColumnSortConfigChanged:(e,a)=>{t(ao({sortKey:e,sortOrder:a}))},onReconReviewTabColumnSortConfigChanged:(e,a)=>{t(to({sortKey:e,sortOrder:a}))},onReconTabUpdate:e=>{n.closeSidePanel?.(),t(eo({selectedTab:e}))},updateReconReviewTabLocalData:(e,a,c)=>{const u=e.vendor?.id;c&&u!=null&&t(Xs(u)),t(Zs({data:e,transactionId:a}))},onReconMatchedTransactionClick:e=>{if(n.openTransactionPanel)return void n.openTransactionPanel(e,bt("bill"));const a=ee(r.state?.pathnameStackToGoBack,r.pathname);C(`../../transaction/bill/${e}`,{state:{pathnameStackToGoBack:a,message:"expenseAutomation",origin:"reconciliation"}})},onReloadPage:()=>{window.location.reload()},onBackClick:()=>{C(-1)},onReconListPageScroll:e=>{t(ha({scrollPosition:e}))},onVendorAutoCompleteInputChange:e=>{e.trim().length>=2?t(pa({searchString:e,searchOrigin:"common"})):e.trim().length===0&&t(Ke("common"))},onReconNodeCollapseToggled:(e,a)=>{t(Qs({nodeId:e,collapsed:a}))},updateSectionCollapseStatus:()=>{},onExcludeAccountFromReconciliation:e=>{t(Ra({accountId:e}))},onIncludeAccountIntoReconciliation:e=>{t(Da({accountId:e}))}}}),((t,n,S)=>{const{isMissingReceiptsBulkUploadEnabled:g,...d}=S;return(function(i,r,A){return{...i,...r,...A,onUploadTransactionReceipt:(l,v,x,P,C)=>{r.onUploadTransactionReceipt(l,v,x,P,C,i.authParams)}}})(t,n,d)}))(Kc(Qc)),kt="newScheduleMode",Tt="newScheduleType",Bi=wi(ri((function(t){const n=t.displayName??t.name??"Component",S=$a.memo(t),g=d=>{const i=ge(),r=(function(){const I=ge(),p=F((b=>Oe(b).reconciliation.selectedDrawerAccountId));return{isOpen:p!=null,selectedAccountId:p,openPanel:s.useCallback((b=>{I(tt({selectedDrawerAccountId:b}))}),[I]),closePanel:s.useCallback((()=>{I(tt({selectedDrawerAccountId:void 0}))}),[I])}})(),A=F((I=>Oe(I).reconciliation)),l=F((I=>ke(I))),v=s.useCallback(((I,p)=>{i(Fa("expense_automation_reconcile",I,p))}),[i]),x=s.useCallback(((I,p)=>{const b=l?.companyId;b!=null&&(i(_a(I,b,"expense_automation_reconcile",void 0,"link_account_no_microdeposit",p)),i(Ma({accountId:p,connectionInProgress:!0})))}),[i,l?.companyId]),P=s.useMemo((()=>{if(r.isOpen&&r.selectedAccountId!=null)return k.jsx(bi,{reconciliation:A,selectedDrawerAccountId:r.selectedAccountId,onClose:r.closePanel,onFetchLinkTokenClick:v,onEstablishConnectionClick:x})}),[r.isOpen,r.selectedAccountId,r.closePanel,A,v,x]),C=s.useMemo((()=>({reconPanelContent:P,reconSidePanelIsOpen:r.isOpen,closeReconSidePanel:r.closePanel})),[P,r.isOpen,r.closePanel]),{useFeatureGate:f}=Ve(),{isFeatureEnabled:m}=f(H.isReconV3Enabled),z=s.useContext(Pa),w=s.useMemo((()=>r.isOpen?m===!0?{selectedItemId:r.selectedAccountId}:{closePanel:r.closePanel,selectedItemId:r.selectedAccountId}:z),[r.isOpen,r.closePanel,r.selectedAccountId,z,m]);return k.jsx(Pa.Provider,{value:w,children:k.jsx(S,{...d,...C})})};return g.displayName=`withReconSidePanel(${n})`,g})(Pi((({closeMatchSidePanel:t,closeReconSidePanel:n,closeSidePanel:S,matchPanelContent:g,isMatchPanelOpen:d,matchPanelMatchId:i,openMatchPanel:r,openTransactionPanel:A,panelContent:l,reconPanelContent:v,reconSidePanelIsOpen:x,isSchedulePanelOpen:P,closeSchedulePanel:C,openSchedulePanel:f,schedulePanelContent:m,schedulePendingDiscardConfirmation:z,sidePanelIsFullView:w,sidePanelIsOpen:I})=>{const{isAiCfoOpen:p,setIsAiCfoOpen:b}=Uc(),_=Bc(),{isOpen:G}=Vc(),N=nt(),q=Te(),h=ge(),{isAiCfoAccessEnabled:L,onAskAiCfoClick:e}=qa({mobileExploreReferrer:"Transaction categorization"}),a=s.useCallback((()=>{d===!0&&t?.(),I===!0&&w!==!0&&S?.()}),[t,S,d,w,I]),c=F(Es);s.useEffect((()=>{c!=null&&(i===c&&a(),h(As()))}),[c,a,h,i]);const u=F(xs);s.useEffect((()=>{u!=null&&(i===u&&a(),h(ws()))}),[u,a,h,i]);const{areTenantIdsInSync:T}=La(),E=Fi(),D=jc(),[M,J]=s.useState(!1),[Y,oe]=Jn(),ae=s.useCallback((o=>{oe((R=>{const $=new URLSearchParams(R);return o==null?($.delete(kt),$.delete(Tt),$):($.set(kt,o.scheduleDetailsMode),$.set(Tt,o.scheduleType),$)}),{replace:!0})}),[oe]),[be,ye]=s.useState(void 0),ve=s.useCallback(((o,R,$)=>{const j=vt(o);ye(j),ae({scheduleDetailsMode:R,scheduleType:o}),h(da({scheduleType:j==="prepaid_expenses"?"prepaid_expenses":"fixed_assets",shouldResetEnteredData:$}))}),[h,ae]),K=s.useMemo((()=>{const o=Y.get(kt),R=Y.get(Tt);return o!=null&&R!=null?{scheduleDetailsMode:o,scheduleType:R}:void 0}),[Y]),ot=s.useCallback((o=>{ae(o),o!=null&&h(da({scheduleType:vt(o.scheduleType)==="prepaid_expenses"?"prepaid_expenses":"fixed_assets",shouldResetEnteredData:!0}))}),[h,ae]),Ee=F((o=>ra(o))),B=F((o=>ke(o))),[ct,Ae]=s.useState(!1),[je,y]=s.useState(!1),[Z,ne]=s.useState([]),[Q,ce]=s.useState(null),ie=s.useCallback((()=>{ce(null)}),[]),Et=Q?.contentType==="activity"?Q.detail.transactionId:void 0,it=s.useCallback((o=>{o!=null?(p&&b(!1),_(),a(),ce({contentType:"activity",detail:{transactionId:o}})):ce((R=>R?.contentType==="activity"?null:R))}),[a,p,_,b]),Xa=s.useCallback((o=>{p&&b(!1),_(),a(),ce({contentType:"transfer",detail:o})}),[a,p,_,b]),Za=s.useCallback((()=>{_(),ie(),a(),e()}),[a,ie,e,_]),At=s.useRef(p);s.useEffect((()=>{p===!0&&At.current===!1&&(_(),ie(),a()),At.current=p}),[a,ie,p,_]);const xt=s.useRef(G);s.useEffect((()=>{G===!0&&xt.current===!1&&(p&&b(!1),ie(),d===!0&&t?.(),I===!0&&w!==!0&&S?.()),xt.current=G}),[ie,t,S,G,p,d,b,w,I]);const ze=I===!0&&w!==!0||d===!0,wt=s.useRef(ze);s.useEffect((()=>{ze&&!wt.current&&(p&&b(!1),_(),ie()),wt.current=ze}),[ie,p,ze,_,b]);const[Rt,en]=s.useState(!1),Dt=s.useRef(!1),{selectedTab:tn}=Be(),{tenantEmailDomain:lt}=Be(),[rt,Ft]=s.useState(q.state?.message==="comingFromTransactionDetail"),_t=q.state?.message==="comingFromOverview",an=zc(),dt=st.getSignedInUser(),{useFeatureGate:le}=Ve(),{isFeatureEnabled:Mt}=le(H.isRealtimeInsightsFeatureEnabled),{isFeatureEnabled:xe}=le(H.isMissingReceiptsBulkUploadEnabled),{isFeatureEnabled:ut}=le(H.isTransactionActivityEnabled),{isFeatureEnabled:me}=le(H.isAccrualEnabled),{isFeatureEnabled:Ot}=le(H.isCreateTransferEntryFromExpenseEnabled),{isFeatureEnabled:nn}=le(H.isProjectsTransactionsEnabled),{isFeatureEnabled:sn}=le(H.isReconV3Enabled),on=s.useCallback((o=>{const R=bt(o.transactionType??(o.view==="reconciliation"?"bill":"expense")),$=ee(q.state?.pathnameStackToGoBack,q.pathname),j=new URLSearchParams({view:"full"});o.threadId!=null&&j.set("thread_id",o.threadId),o.entityType!=null&&j.set("entity_type",o.entityType),N(`/${lt}/transaction/${encodeURIComponent(R)}/${o.transactionId??o.entityId}?${j.toString()}`,{state:{pathnameStackToGoBack:$,message:"expenseAutomation"}})}),[N,lt,q.state,q.pathname]),cn=F((o=>Rs(o,"common"))),V=F((o=>Oe(o))),{categoryOptions:ln,paymentAccountNames:rn}=F((o=>Ds(o.accountState))),dn=F((o=>Fs(o.classState))),{monthEndCloseChecksView:X,currentSelectedView:O,selectedPeriod:U,selectedTransactionCategorizationTab:mt,currentSelectedViewBackgroundRefreshFetchState:un,currentSelectedViewFetchState:re,jeSchedules:pt,reconciliation:Ut}=V;Zc(O==="transaction_categorization");const mn=V.transactionView.saveStatus.fetchState,$e=V.transactionView.transactions,Bt=s.useRef($e);Bt.current=$e;const Vt=F((o=>o.expenseAutomationTransactionsViewState?.transactionCategorizationView)),jt=F((o=>o.expenseAutomationTransactionsViewState?.selectedTransactionCategorizationTab)),zt=s.useRef(Vt);zt.current=Vt;const $t=s.useRef(jt);$t.current=jt;const Le=F((o=>{const R=o.expenseAutomationTransactionsViewState?.selectedTransactionCategorizationTab;return R!=null?o.expenseAutomationTransactionsViewState?.transactionCategorizationView?.[R]?.filters:void 0})),Lt=s.useRef("");s.useEffect((()=>{if(O!=="transaction_categorization")return;const o=V.transactionView.uiState.searchString??"";if(re.fetchState!=="Completed"||o.length===0||o===Lt.current)return;Lt.current=o;const R=Le!=null?$c(Le):0,$=Le?.categories.filter((j=>j.values.length>0&&String(j.values[0]??"").trim()!=="")).map((j=>`${j.field}:${j.values.join(",")}`))??[];W.trackAiCloseTransactionSearch({filtersApplied:$,hasResults:$e.length>0,isFiltered:R>0,resultsCount:$e.length,searchTerm:o,searchType:"free_text"})}),[O,re.fetchState,V.transactionView.uiState.searchString,V.transactionView.transactions,Le]);const de=ei(mn,(()=>{const o=[],R=$t.current,$=zt.current,j=$!=null&&R!=null?$[R]:void 0;if(j?.transactionReviewLocalDataById!=null)for(const fe of Object.values(j.transactionReviewLocalDataById)){const te=fe?.transactionReviewLocalData?.lineItemById;if(te!=null)for(const ht of Object.values(te)){const _e=ht?.account;_e?.accountId!=null&&o.push(_e.accountId)}}const Ce=Bt.current;for(const fe of Ce)for(const te of fe.lines??[])"account"in te&&te.account?.accountId!=null&&o.push(te.account.accountId);return o}));s.useEffect((()=>{O==="transaction_categorization"&&I!==!0||it(void 0)}),[O,it,I]),s.useEffect((()=>{x===!0&&n?.()}),[O,Ut.selectedAccountId]);const pn=V.transactionView.selectedTransactionCategorizationCompletedSubTab,hn=V.transactionView.selectedTransactionGroup,Ge=`${mt}|${pn}|${hn}`,Ne=s.useRef(null),Gt=s.useRef(null);s.useEffect((()=>{Ne.current!==null?Ne.current!==Ge&&(Ne.current=Ge,O==="transaction_categorization"&&ie()):Ne.current=Ge}),[ie,O,Ge]);const Sn=F((o=>Et==null?void 0:_s(o.transactionState,Et))),pe=Sn?.qboId,Nt=F((o=>pe==null?void 0:Ms(o,pe)));s.useEffect((()=>{pe!=null&&h(Os(pe))}),[h,pe]);const{createTransferEntryStatus:qt,creditCardTransferAccountsList:Jt,transferAccounts:Yt}=V.transactionView,Ht=s.useCallback((o=>ti(h,o)),[h]),Wt=s.useMemo((()=>O!=="transaction_categorization"||Q==null?null:Q.contentType==="activity"?ut===!0?k.jsx(Lc,{activityLogView:Nt,qboId:pe,onClose:()=>ce(null),selectedTransactionId:Q.detail.transactionId,isQuickViewCardStyle:!0},String(Q.detail.transactionId)):null:Q.contentType==="transfer"?k.jsx(Gc,{createTransferEntryStatus:qt,creditCardTransferAccountsList:Jt,transaction:Q.detail,transferAccounts:Yt,onClose:()=>ce(null),onCreateTransfer:Ht,isQuickViewCardStyle:!0},String(Q.detail.transactionId)):null),[O,Q,ut,Nt,pe,qt,Jt,Yt,Ht]),gn=Wt!=null,{selectedAccountId:we}=Ut,Kt=et(pt.accountSettingsView.saveState.fetchState),Cn=F((o=>Us(o.accountState,o.accountListState,"accountList"))),fn=F((o=>Bs(o))),Re=Ya(tn)??O,In=F((o=>o.entityAutoCompleteState.autoCompleteText.common));if(Ga({isDataReady:re.fetchState==="Completed"}),dt==null)throw Error("Can't access expense automation screen without signing in...");const Qt=Ua(U),De=at(Qt.start),Fe=at(Qt.end);if(De==null||Fe==null)throw Error(`Invalid start - ${De} and end - ${Fe} period from given ${U}`);const kn=s.useCallback((()=>{Ae(!1)}),[]),Tn=s.useCallback((()=>{y(!0)}),[]),Pn=s.useCallback((o=>{ne(o),y(!1)}),[]),bn=s.useCallback((()=>{ne([])}),[]),qe=V.missingReceipts.bulkUpload.phase,Xt=V.missingReceipts.bulkUpload.currentBatchId;s.useEffect((()=>{xe===!0&&O==="missing_receipts"&&qe==="matching"&&Xt!=null&&h(Ba({cacheOverride:!0}))}),[xe,O,qe,Xt,h]);const Zt=dt?.userId,yn=U.month,vn=U.year,ea=B?.tenantId;s.useEffect((()=>{O==="missing_receipts"&&xe!==!1&&qe==="idle"&&Zt!=null&&ea!=null&&h(Vs())}),[O,xe,qe,Zt,ea,yn,vn,h]),s.useEffect((()=>{Ee.newVendorState?.vendorDetailLocalData?.vendorName!=null?J(!0):J(!1)}),[Ee.newVendorState?.vendorDetailLocalData?.vendorName]),s.useEffect((()=>{Re!=null&&O!==Re&&h(Va(Re))}),[Re]),s.useEffect((()=>{Rt===!1&&re.fetchState==="Completed"&&T&&(en(!0),h(ua(!1,!1,me===!0)))}),[Rt,re,T,me]),s.useEffect((()=>{const o={month:U.month,year:U.year},R=Gt.current;Gt.current=o,R===null||R.month===o.month&&R.year===o.year||!_t&&T&&(h(ua(!1,!1,me===!0)),h(ue(U,we,!1,!1)))}),[U.month,U.year,T,me]);const Je=s.useCallback(((o=!1,R=!1)=>{const $={start:De,end:Fe};switch(O){case"transaction_categorization":h(Se(mt,$,o,!rt,void 0,void 0,R)),Ft(!1);break;case"flux_analysis":h(Ze(U,o,R,null));break;case"month_end_insights":if(R===!1){const j=new Date(U.year,U.month,0),Ce=zs(j.toDateString()).format(Qa.analytics.YYYYDashMMDashDDFormat);h($s(!0,B.companyId,B.tenantId,Ce)),h(Ls(B.companyId,B.tenantId))}break;case"je_schedules":h(js($,R,me===!0));break;case"missing_receipts":h(ja($,{amount:75,currencyCode:"USD",currencySymbol:"$"},o,R));break;default:h(ue(U,we,o,R))}}),[O,De,Fe,B.companyId,B.tenantId,mt,U,we,rt,Ft,me]),En=s.useCallback((()=>{Je(!0,!0)}),[Je]);s.useEffect((()=>{O===Re&&re.fetchState==="Not-Started"&&T&&Je(!0)}),[re,De,Fe,B.companyId,B.tenantId,T]),s.useEffect((()=>{_t||rt||Dt.current||un.fetchState==="In-Progress"||re.fetchState!=="Completed"||(Dt.current=!0,Je(!0,!0))}),[]),s.useEffect((()=>{X.fetchState!=="In-Progress"&&X.fetchState!=="Completed"&&X.fetchState!=="Error"&&B?.tenantId!=null&&h(Me({tenantId:B.tenantId,period:U,refreshViewInBackground:!1}))}),[X.fetchState,B?.tenantId]),s.useEffect((()=>{X.fetchState!=="Completed"||!T||(X.monthEndCloseChecks?.monthEndCloseCheckList.some((o=>o.id==="reconciliation"))??!1)&&V.reconciliation.fetchStatus.fetchState==="Not-Started"&&h(ue(U,void 0,!1,!1))}),[X.fetchState,T,U.month,U.year,V.reconciliation.fetchStatus.fetchState,h]),s.useEffect((()=>{V.monthEndInsights?.previewMonthEndReportStatus?.fetchState==="Completed"?Ae(!0):Ae(!1)}),[V.monthEndInsights?.previewMonthEndReportStatus?.fetchState]),s.useEffect((()=>{V.monthEndInsights?.sendMonthEndReportStatus?.fetchState==="Completed"&&T&&(h(Me({tenantId:B.tenantId,period:U,refreshViewInBackground:!0})),h(Gs({companyId:B.companyId})),N("../"))}),[V.monthEndInsights?.sendMonthEndReportStatus?.fetchState,B.tenantId,U,B.companyId,T]),s.useEffect((()=>{const o=setInterval((()=>{X.fetchState!=="In-Progress"&&X.fetchState==="Completed"&&h(Me({tenantId:B.tenantId,period:U,refreshViewInBackground:!0}))}),3e5);return()=>clearInterval(o)}),[X.fetchState,B.tenantId,U,h]),s.useEffect((()=>{const o=setInterval((()=>{O==="reconciliation"&&we==null&&V.reconciliation.fetchStatus.fetchState==="Completed"&&V.reconciliation.refreshStatus.fetchState!=="In-Progress"&&h(ue(U,void 0,!0,!0))}),3e5);return()=>clearInterval(o)}),[O,h,V.reconciliation.fetchStatus.fetchState,V.reconciliation.refreshStatus.fetchState,ue,we,U]);const An=ya(),{isFeatureEnabled:xn}=le(H.isRecommendationFeedbackEnabled),ta=Nc(),{onRecommendationSelection:aa,popup:wn}=ai({isEnabled:xn}),Rn=s.useMemo((()=>({...ta,onRecommendationSelection:aa})),[ta,aa]);s.useEffect((()=>{const o=(X.monthEndCloseChecks?.monthEndCloseCheckList.find((R=>R.id==="month_end_insights"))?.isDisabled??!1)&&!Mt;O!=="month_end_insights"||!o&&X.monthEndCloseChecks?.reportEmailSentDate==null||N("../")}),[O,X.monthEndCloseChecks]);const Dn=x===!0?v:l,Fn=x===!0||I===!0,_n=x===!0?n:S,Mn=x!==!0&&w;s.useEffect((()=>{Kt==="In-Progress"&&pt.accountSettingsView.saveState.fetchState==="Completed"&&h(ma())}),[Kt,pt.accountSettingsView.saveState.fetchState,ma]);const{transactionId:na,onSaveVendor:On,onSaveSuccess:Un,onCancel:Bn,vendorViewDetails:Vn}=(({expenseAutomationViewSelector:o,closeDrawerHandler:R,currentSelectedView:$})=>{const j=ge();let Ce,fe,te;const ht=ya(),_e=o.transactionView;let sa=()=>{};const{transactions:jn,selectedTransactionId:Ie,selectedTransactionLineId:Ye,transactionLocalData:zn}=_e;if($==="transaction_categorization"){const St=zn.find((he=>he.transactionId===Ie)),se=jn.find((he=>he.id===Ie)),oa=Ye!=null?St?.transactionReviewLocalData?.lineItemById[Ye]:void 0,ca=oa?.account;fe=oa?.class?.classId,Ce=["Uncategorized Income","Uncategorized Expense"].includes(ca?.accountName??"")?void 0:ca?.accountId;const Ln=hi(Ie,se?.typeOfTransaction);se!=null&&Ln&&(te={id:Ie,type:bt(se.typeOfTransaction)}),sa=()=>{if(Ie!=null&&Ye!=null&&se!=null){const he=_e.transactionLocalData.find((He=>He.transactionId===Ie))?.transactionReviewLocalData;if(he!=null&&se.lines!=null&&se.lines.length>0){const He=he.lineItemById[Ye];let gt=he.selectedEntity;if(vs(se)||(gt=He.selectedEntityLine),gt!=null){const Gn=gt,Nn={transactionId:{id:se.id,type:se.type},transaction:se,lineIds:se.lines.map((qn=>qn.id))??[]};j(yt({entity:Gn,amount:He.amount.amount,transactionDetails:Nn,flowType:"categorization",selectedTab:o.selectedTransactionCategorizationTab,isFetchCOT:ht}))}}}}}const $n=F((St=>ra(St,void 0,Ce,fe)));return{transactionId:te,onSaveVendor:()=>{j(ys(te,void 0,!1,!0))},onSaveSuccess:sa,onCancel:()=>{te!=null&&j(Ts({transactionId:te})),j(Ps()),j(bs()),R()},vendorViewDetails:$n}})({expenseAutomationViewSelector:V,closeDrawerHandler:()=>{J(!1)},currentSelectedView:O});return an?.loggedInUserRoleMap==null?X.fetchState==="Error"?k.jsx(qc,{onGoHome:()=>N("../",{replace:!0}),onReload:()=>window.location.reload()}):k.jsx(Na,{fetchState:"In-Progress"}):k.jsxs(k.Fragment,{children:[k.jsx(Ci,{isOpen:je,drawerLeftMargin:new Jc(0,0,300,650),onClose:()=>{y(!1)},children:k.jsx(Vi,{onClick:o=>o.stopPropagation(),children:k.jsx(Ri,{companyId:B.companyId,closeCustomerRequestDrawer:()=>y(!1),addCustomerRequest:Pn,resetCustomerRequest:bn})})}),na!=null&&M&&k.jsx(oi,{isOpen:M,transactionId:na,onSaveVendor:On,onSaveSuccess:Un,onCancel:Bn,vendorViewDetails:Vn}),k.jsx(Yc,{toolkit:Rn,children:k.jsx(Ui,{events:[],eventCallback:(o,R,$)=>{},navigate:N,location:q,themeState:D,categoryOptions:ln,classesForFilters:dn,accountsForFilters:rn,vendorSearchAutoCompleteData:{autoCompleteText:In,entityAutoCompleteView:cn},expenseAutomationViewSelector:V,isMissingReceiptsBulkUploadEnabled:xe,monthEndInsightsPreviewMode:ct,monthEndInsightsCustomerRequestData:Z,isRealtimeInsightsFeatureEnabled:Mt,isCreateTransferEntryFromExpenseEnabled:Ot,isAccountingClassesEnabled:fn,isProjectsTransactionsEnabled:nn,isCOTEnabled:An,currentTenant:B,companyId:B.companyId,signedInUser:dt,isTransactionActivityEnabled:ut,isRightPanelOpen:gn,rightSidePanel:Wt,onOpenTransferRightPanel:Ot===!0?Xa:void 0,uncategorizedAccounts:Cn,newScheduleActiveType:be,isAccrualEnabled:me,newScheduleSelection:K,onNewScheduleSelectionChange:ot,onScheduleTypeChange:ve,onNewScheduleSaved:En,onClickCustomerRequest:Tn,handleEditClick:kn,tenantEmailDomain:lt,trackExpenseAutomationTabAnalytics:E,setActivityLogTransactionId:it,closeMatchSidePanel:t,closeSidePanel:_n,openTransactionPanel:A,closeSchedulePanel:C,openSchedulePanel:f,openMatchPanel:r,sidePanelIsOpen:Fn,sidePanelIsFullView:Mn,panelContent:Dn,isAiCfoAccessEnabled:L,onAskAiCfoClick:Za,isReconV3Enabled:sn,onExpenseAutomationCommentingThreadClick:on,sidePanelListPercent:x===!0?66:void 0,isMatchPanelOpen:d,isSchedulePanelOpen:P,matchPanelContent:g,schedulePanelContent:m,schedulePendingDiscardConfirmation:z})}),wn,de.showPopup&&de.popupType!=null&&k.jsx(Hc,{popupType:de.popupType,currencySymbol:de.currencySymbol,accountId:de.popupAccountId??"",accountName:de.popupAccountName??"",onSubmit:de.handleSubmit,onDismiss:de.handleDismiss})]})}))))),Vi=Pe(Ac)`
34
+ `,xi=/^schedule\/(prepaid_expenses|fixed_assets|accrued_expenses|one_time_accrual)\/([^/?]+)$/,wi=Wa({displayNamePrefix:"withScheduleSidePanel",usePanelSetup:function(t){const n=(function(C=!0){const f=nt(),m=Te(),z=ge(),w=Be(),I=Ha({childPathPattern:xi,enabled:C}),p=I.matchGroups[0],P=Xa(p)?p:void 0,_=I.matchGroups[1]!=null&&I.matchGroups[1]!==""?I.matchGroups[1]:void 0,G=I.isOpen&&P!=null&&_!=null,q=w.tenantEmailDomain??m.pathname.split("/").find(Boolean)??"",N=s.useRef({isOpen:G,scheduleId:_});N.current={isOpen:G,scheduleId:_};const h=s.useCallback(((e,a,c)=>{c!=null&&(a==="prepaid_expenses"||a==="fixed_assets")&&z(Oa({selectedJEScheduleKey:c})),!I.isMobile&&C?N.current.isOpen&&N.current.scheduleId===e?I.closePanel():I.navigateToChild(`schedule/${a}/${e}`,{replace:N.current.isOpen}):f(va(a,e,q),{state:{message:"expenseAutomation",origin:"je_schedules"}})}),[z,f,I.isMobile,I.navigateToChild,I.closePanel,C,q]),$=s.useCallback((()=>{if(P==null||_==null)return;const e=ee(m.state?.pathnameStackToGoBack,m.pathname);f(va(P,_,q),{state:{pathnameStackToGoBack:e,message:"expenseAutomation",origin:"je_schedules"}})}),[f,P,_,q,m.pathname,m.state]);return{closePanel:I.closePanel,isOpen:G,maximize:$,openPanel:h,panelType:G?P:void 0,scheduleId:G?_:void 0}})(t),S=s.useRef(null),[g,d]=s.useState(null),i=s.useMemo((()=>({registerPanelDirtyGuard:C=>{S.current=C}})),[]),r=s.useCallback((C=>{S.current?.isDirty()===!0?d((()=>C)):C()}),[]),A=s.useCallback((()=>{r(n.closePanel)}),[r,n.closePanel]),l=s.useCallback((()=>{r(n.maximize)}),[r,n.maximize]),v=s.useCallback(((C,f,m)=>{r((()=>n.openPanel(C,f,m)))}),[r,n.openPanel]),x=s.useMemo((()=>{if(g!=null)return{onCancel:()=>d(null),onDiscard:()=>{S.current=null,d(null),g()}}}),[g]),b=s.useMemo((()=>{if(n.isOpen&&n.panelType!=null&&n.scheduleId!=null)return k.jsx(Mc.Provider,{value:i,children:k.jsx(yi,{panelType:n.panelType,scheduleId:n.scheduleId,onClose:A,onCloseAfterDecision:()=>{S.current=null,n.closePanel()}},`${n.panelType}:${n.scheduleId}`)})}),[n.isOpen,n.panelType,n.scheduleId,n.closePanel,A,i]);return{injectedProps:s.useMemo((()=>({closeSchedulePanel:A,isSchedulePanelOpen:n.isOpen,openSchedulePanel:v,schedulePanelContent:b,schedulePendingDiscardConfirmation:x})),[A,v,b,x,n.isOpen]),selectedItemId:n.scheduleId,sidePanel:{closePanel:A,maximize:l}}}});function Ri({companyId:t,closeCustomerRequestDrawer:n,addCustomerRequest:S,resetCustomerRequest:g}){const d=st.getSignedInUser();if(d==null)throw Error("Can't access Customer Request page without signing in...");const i=F((r=>fs(r,t,d)));return s.useEffect((()=>{g()}),[]),k.jsx(k.Fragment,{children:i.fetchState==="In-Progress"||i.companyMonthEndReportTemplatesData.fetchState==="In-Progress"?k.jsx(qa,{fetchState:"In-Progress"}):k.jsx(Oc,{onCloseClick:n,addCustomerRequest:S,snippets:i.companyMonthEndReportTemplatesData,bulletPoints:i.zeniRequestsData??[]})})}const Di={schedules:"Review Schedules",actual_matching:"Actual Matching",existing_schedules:"Existing Schedules"},Fi=()=>{const t=F((x=>Oe(x))),n=Te(),{currentSelectedViewFetchState:S,currentSelectedView:g,selectedPeriod:d}=t,i=et(g),r=et(S.fetchState),A=t.jeSchedules.uiState.selectedPageTab??"schedules",l=et(A),v=s.useCallback((x=>{const b=n.state?.referrer;g==="transaction_categorization"&&(t.selectedTransactionCategorizationTab==="review"?W.trackTransactionsReviewPage(d.month,d.year,t.transactionView.totalCountByTab.review,0,x,b??null):W.trackTransactionsAutoCategorisedPage(d.month,d.year,t.transactionView.totalCountByTab.autoCategorized,0,x,b??null)),g==="missing_receipts"&&W.trackMissingReceiptsPage(d.month,d.year,x,t.missingReceipts.transactions.length,b??null),g==="je_schedules"&&W.trackMonthCloseScheduleListPage(d.month,d.year,x,t.jeSchedules.pendingReviewSchedules.length,t.jeSchedules.failedPostings.length,(C=>{const f={accruedCount:0,fixedAssetsCount:0,oneTimeAccrualCount:0,prepaidCount:0};return C.forEach((m=>{if(Is(m))f.oneTimeAccrualCount+=1;else switch(ks(m)){case"prepaid_expenses":f.prepaidCount+=1;break;case"fixed_assets":f.fixedAssetsCount+=1;break;case"accrued_expenses":f.accruedCount+=1}})),f})(t.jeSchedules.pendingReviewSchedules),Di[A],b??null),g==="flux_analysis"&&W.trackFluxAnalysisPage(d.month,d.year,x,_i(t.fluxAnalysis),b??null),g==="month_end_insights"&&t.auditSummary?.auditScorePercentage!=null&&W.trackInsightsEmailPage(d.month,d.year,x,"draft",t.auditSummary.auditScorePercentage,null,b??null)}),[d,t,A]);return s.useEffect((()=>{(r!==S.fetchState||g!==i||g==="je_schedules"&&l!=null&&A!==l)&&S.fetchState==="Completed"&&v(!1)}),[g,S.fetchState,i,A,l]),v},_i=t=>t.sections.generalExpense.vendors.length+t.sections.reimbursement.vendors.length,{common:{strings:{hyphen:Mi,comma:xa,space:Oi}},dateFormat:Ka}=Wc.getLocalizedStrings(),wa=Ec,Ui=Yn((function(t,n){const{uncategorizedAccounts:S,vendorSearchAutoCompleteData:g,monthEndInsightsCustomerRequestData:d,monthEndInsightsPreviewMode:i,companyId:r,isMissingReceiptsBulkUploadEnabled:A,isTransactionActivityEnabled:l,newScheduleActiveType:v}=n,x=st.getSignedInUser(),b=t.tenantState.currentTenantId,C={userId:x?.userId??"",sessionId:x?.zeniSessionId??"",tenantId:b??""},f=Oe(t),{selectedTransactionCategorizationTab:m}=f,{searchTransactionsResults:z,searchTransactionsFetchState:w}=qs(t),I=v==="prepaid_expenses"?"prepaid_expenses":"fixed_assets",{accountListNestedAccountHierarchy:p,classListNestedAccountHierarchy:P,allDepreciationAccountListNestedAccountHierarchy:_,newScheduleLocalData:G,saveStatus:q}=Ns(t,I);return{expenseAutomationViewSelector:f,accountListNestedAccountHierarchy:p,allDepreciationAccountListNestedAccountHierarchy:_,baseTransactionSearchFetchState:w,baseTransactionSearchResults:z,classListNestedAccountHierarchy:P,newScheduleLocalData:G,initialSelectedBaseTransaction:G.selectedBaseTransactionId!=null?Js(t.transactionState,Ys(G.selectedBaseTransactionId)):void 0,newAccrualAccountsView:Hs(t),newScheduleSaveStatus:q,bulkUploadSelector:A===!0?f.missingReceipts.bulkUpload:void 0,vendorSearchAutoCompleteData:g,authParams:C,receiptUploadEndpoint:`${Ue.accountMicroServiceBaseUrl}`,transactionAttachmentsEndpoint:`${Pa}/transaction_attachments`,bulkUploadEndpoint:A===!0?`${Ue.communicationAgentMicroServiceBaseUrl}/1.0/receipts/bulk-upload`:void 0,isDisabled:!1,currentTab:m,selectedTransactionGroup:f.transactionView.selectedTransactionGroup,monthEndInsightsCustomerRequestData:d,monthEndInsightsPreviewMode:i,allThreadsSectionOpen:!1,enableMonthEndInsightsZeniGPTFeature:!1,loggedInUser:x,uncategorizedAccounts:S,companyId:r,isTransactionActivityEnabled:l,receiptsEmail:Xs(t.tenantState,b),downloadParams:{authParams:C,jeScheduleEndPoint:`${Pa}/jeScheduleReports`,timezone:Ws(),companyName:ke(t).companyName}}}),(function(t,n){const{themeState:S,isAccountingClassesEnabled:g,isCOTEnabled:d,isMissingReceiptsBulkUploadEnabled:i,location:r,vendorSearchAutoCompleteData:A,expenseAutomationViewSelector:l,currentTenant:v,newScheduleActiveType:x,uncategorizedAccounts:b,navigate:C,onClickCustomerRequest:f,handleEditClick:m,closeSchedulePanel:z,isSchedulePanelOpen:w,openSchedulePanel:I,setActivityLogTransactionId:p}=n,{selectedPeriod:P,currentSelectedView:_,reconciliation:{selectedAccountId:G}}=l,{accountSettingsView:q}=l.jeSchedules,N=Ua(P),h=at(N.start),$=at(N.end);return{onZeniLogoClick:()=>{S.toggle()},onUploadReceiptAttachment:e=>{W.trackMissingReceiptAttached(P.month,P.year),t(pc(e))},onUploadTransactionReceipt:(e,a,c,u,T,E)=>{t(Ia(e,a,{fetchState:"In-Progress"}));const D=()=>t(Ia(e,a,{fetchState:"Error"}));Qc(`${Ue.accountMicroServiceBaseUrl}/1.0/transactions/${a}/attachments`,E,a,c,u,T).then((M=>{M!=null?t(mc(e,M)):D()})).catch(D)},onMissingReceiptsRowClick:(e,a)=>{if(n.openTransactionPanel)return void n.openTransactionPanel(e,a);const c=ee(r.state?.pathnameStackToGoBack,r.pathname);C(`../../transaction/${a}/${e}`,{state:{pathnameStackToGoBack:c,message:"expenseAutomation",origin:"missing_receipts"}})},onUploadReceiptComplete:(e,a)=>{t(uc(e,a)),v!=null&&t(Me({tenantId:v.tenantId,period:a,refreshViewInBackground:!0}))},onUploadReceiptFetchStatus:(e,a,c,u)=>{t(dc(e,{fetchState:a,error:c})),c!=null&&t(bt({messageSection:"missing_receipts_attachment",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"__message__",variableValue:u!=null?Oi+Mi+u+xa:xa}]}))},onUpdateJESchedulesUIState:e=>{const a=l.jeSchedules.uiState,c=e.selectedPageTab!=null&&e.selectedPageTab!==a.selectedPageTab,u=e.selectedJETypeFilter!==void 0&&e.selectedJETypeFilter!==a.selectedJETypeFilter;c&&n.closeMatchSidePanel?.(),w===!0&&(c||u)&&z?.(),e.createdGroupCollapsed!=null?t(oc()):e.pendingGroupCollapsed!=null?t(cc()):e.failedGroupCollapsed!=null?t(ic()):e.selectedJETypeFilter!==void 0?t(lc(e.selectedJETypeFilter)):t(rc(e))},onUpdateMissingReceiptsUIState:e=>{t(sc(e))},onFetchMissingReceiptsList:()=>{$!=null&&h!=null&&t(ja({start:h,end:$},{amount:75,currencyCode:"USD",currencySymbol:"$"},!0,!1))},...i===!0?{onBulkUploadFiles:e=>{t(vc(e))},onBulkUploadProgress:e=>{t(yc(e))},onBulkUploadSuccess:e=>{t(Pc({batchId:e}))},onBulkUploadUploadedFileCount:e=>{t(bc(e))},onConfirmBulkUploadMatch:(e,a,c,u,T)=>{t(Tc(e,a,c,u,T))},onBulkUploadConfirmMatchAcknowledged:()=>{t(kc())},onSetBulkUploadResultsTab:e=>{t(Ic(e))},onSetBulkUploadCompletedSubTab:e=>{t(fc(e))},onSetBulkUploadSortConfig:(e,a)=>{t(ka({sortKey:e,sortOrder:a}))},onClearBulkUpload:()=>{t(Cc())},onSearchTransactionsForManualMatch:(e,a)=>{t(wa(e,a??void 0))},onLoadMoreManualSearch:()=>{const{manualSearch:e}=l.missingReceipts.bulkUpload;e.nextPageToken!=null&&e.searchQuery!==""&&t(wa(e.searchQuery,e.nextPageToken))},onFetchCompletedTransactions:(e,a)=>{t(gc(e,a))},onClearBulkUploadBatchDetailsForScopeChange:()=>{t(Sc())},onFetchBulkUploadBatches:e=>{t(Ba(e))},onFetchMoreBatchDetails:()=>{t(hc())},onResetBulkUploadSort:()=>{t(ka({sortKey:void 0,sortOrder:void 0}))}}:{},onClearMissingReceiptsTabNavigation:()=>{t(nc())},onSearchTextChanged:e=>{const a=l.currentSelectedView,c=l.selectedTransactionCategorizationTab;a==="transaction_categorization"&&(t(ft({selectedTab:c,uiState:{searchString:e}})),$!=null&&h!=null&&t(Se(c,{start:h,end:$},!0,!1,e,void 0,!1,!0)))},onFiltersChange:e=>{const a=l.selectedTransactionCategorizationTab;t(ac({filters:e,selectedTab:a}))},onRefresh:()=>{n.trackExpenseAutomationTabAnalytics(!0),t(tc())},onClose:()=>{_==="reconciliation"&&G!=null&&t(fa({selectedAccountId:void 0})),C("../")},onBack:()=>{_==="reconciliation"&&G!=null&&t(fa({selectedAccountId:void 0}))},onSaveReconciliation:e=>{t(ec(e))},onSaveReconciliationReview:e=>{t(Zo(e))},onUpdateStep:e=>{const{selectedPeriod:a}=l,c=ee(r.state?.pathnameStackToGoBack,r.pathname);C(`../${e}/${a.month}-${a.year}`,{state:{pathnameStackToGoBack:c,referrer:l.currentSelectedView}}),t(Va(e))},handleLogOutClick:()=>{const e=ee(r.state?.pathnameStackToGoBack,r.pathname);C("/signout",{replace:!0,state:{pathnameStackToGoBack:e,message:"logout"}})},onJeAccountSettingsChange:e=>{const{vendorsAccountSection:a}=e,{prepaidExpensesAccount:c,fixedAssetsAccount:u,accruedExpensesAccount:T}=a,E=It(q.prepaidExpensesAccountList,c.selectedOptions),D=It(q.fixedAssetsAccountList,u.selectedOptions),M=It(q.accruedExpensesAccountList,T.selectedOptions),J={selectedPrepaidExpensesAccountIds:E.map((Y=>Y.accountId)),selectedFixedAssetsAccountIds:D.map((Y=>Y.accountId)),selectedAccruedExpensesAccountIds:M.map((Y=>Y.accountId))};t(Qo({data:J}))},onSaveJeAccountSettingsClick:()=>{t(Ko())},onJESchedulesFormDataChange(e,a){const{jeScheduleID:c,accumulatedDepreciationCategory:u,scheduleClass:T,scheduleExpenseCategory:E,vendor:D}=a,{allAccountList:M,allClassList:J,allDepreciationAccountList:Y}=l.jeSchedules,oe=A.entityAutoCompleteView.vendor.length>0?A.entityAutoCompleteView.vendor.find((X=>X.id===D?.selectedOption)):void 0,ae={id:oe?.zeniId??D?.selectedOption??"",name:oe?.name??D?.defaultOptions.find((X=>X.value===D?.selectedOption))?.label??"",logo:oe?.logo},Pe=E?.selectedOption!=null?M.find((X=>X.qboId===E.selectedOption)):void 0,ye=T?.selectedOption!=null?J.find((X=>X.classId===T.selectedOption)):void 0,ve=u?.selectedOption!=null?Y.find((X=>X.qboId===u.selectedOption)):void 0;t(Xo({scheduledJournalEntryID:e,localData:{jeScheduleID:c,scheduledJournalEntryID:e,updatedCategoryId:Pe?.accountId,updatedClassId:ye?.classId,updatedAccumulatedDepreciationCategoryID:ve?.accountId,updatedVendor:{id:ae.id,name:ae.name}}}))},onRevertJeSchedule(e,a,c,u,T){t(Wo(e,a,c,u,T))},ignoreRecommendedJeSchedule(e,a,c,u){t(Ho(e,a,c,u))},vendorSearchAutoCompleteActions:{onAutoCompleteInputChange:(e,a)=>{e.trim().length>=2?t(pa({searchString:e,entityType:a,searchOrigin:"common"})):e.trim().length===0&&t(Xe("common"))},onCancelAutoComplete:()=>{t(Xe("common"))}},onPostJESchedule(e,a){t(Yo({scheduledJournalEntryID:e,jeScheduleTransactionKey:a}))},clearJeScheduleLocalData(){t(Jo())},onViewTransaction(e){if(n.tenantEmailDomain==null)return;const a=gi(e,n.tenantEmailDomain),c=ee(n.location.state?.pathnameStackToGoBack,`${n.location.pathname}${n.location.search}`);n.navigate(a,{state:{pathnameStackToGoBack:c,message:"expenseAutomation",origin:"je_schedules"}})},onSearchBaseTransaction(e){t(No({query:e,scheduleType:x==="prepaid_expenses"?"prepaid_expenses":"fixed_assets"}))},onNewScheduleFormChange(e,a){const c=vt(e)==="prepaid_expenses"?"prepaid_expenses":"fixed_assets";t(Ca({scheduleType:c,localData:a}))},onOpenMatchNewModal(){t(qo())},onIgnoreMatchSuggestion(e,a,c){t(Go(e,a,c))},onCloseMatchNewModal(){t($o())},onClearMatchNewModal(){t(Lo())},onSearchMatchTransactions(e,a){t(zo(e,a))},onSearchMatchAccruals(e,a){t(jo(e,a))},onMatchAndReverse(e){t(Vo(e.transactionId,e.transactionIntegrationId,e.transactionType,e.lineIds,e.transactionSyncToken,e.accrualIds,!0))},onUpdateActualMatchingUIState(e){t(Bo(e))},onUndoReversal(e,a){t(Uo(e,a))},onSaveSchedule(e,a){const c=e==="prepaid_expenses"?"prepaid_expenses":"fixed_assets",{allAccountList:u,allDepreciationAccountList:T}=l.jeSchedules,E=a.selectedAccount!=null?u.find((M=>M.qboId===a.selectedAccount)):void 0,D=a.selectedAccumulatedDepreciationCategory!=null?T.find((M=>M.qboId===a.selectedAccumulatedDepreciationCategory)):void 0;t(Ca({scheduleType:c,localData:{...a,selectedAccount:E?.accountId,selectedAccumulatedDepreciationCategory:D?.accountId}})),t(Oo({scheduleType:c}))},onCreateAccruedSchedule(e){const a="accrued_expenses";t(Ro()),t(Do()),t(Fo({scheduleType:a,localData:e,selectedJeScheduleDetailId:void 0})),t(_o({scheduleType:a})),t(Mo(a,void 0))},onCreateOneTimeAccrual(e){t(wo(e))},handleJeScheduleClick:(e,a,c)=>{if((function(T,E){return E!=="accrued_expenses"})(0,c)&&t(Oa({selectedJEScheduleKey:a})),I!=null&&Xa(c))return void I(e,c,a);const u=ee(r.state?.pathnameStackToGoBack,r.pathname);C(`../../vendors/schedules/${c}/details/${e}`,{state:{pathnameStackToGoBack:u,message:"expenseAutomation",origin:"je_schedules"}})},onOneTimeAccrualFeedback:(e,a,c,u)=>{t(a!=="revert"?xo(e,c,u):Ao(e,c,u))},onOneTimeAccrualClick:e=>{if(I!=null)return void I(e,"one_time_accrual");const a=ee(r.state?.pathnameStackToGoBack,r.pathname);C(`../../vendors/schedules/one_time_accrual/details/${e}`,{state:{pathnameStackToGoBack:a,message:"expenseAutomation",origin:"je_schedules"}})},onOpenMatch:e=>{n.openMatchPanel?.(e)},onOpenBill(e){if(n.tenantEmailDomain==null)return;const a=ii(e,n.tenantEmailDomain,n.location);n.navigate(a.pathname,{state:a.state})},improveMonthEndInsightsUsingZeniGPTClick:e=>{v!=null&&t(Eo(e,v.companyId,v.tenantId))},onClickCustomerRequest:f,setActivityLogTransactionId:p,onCloseAllThreadsSection:()=>{},onCloseFileAttachmentSnackBar:()=>{t(vo())},onOpenFileAttachmentSnackBar:()=>{t(bt({messageSection:"cockpit_month_end_email_attachment_upload",messageText:"failed",type:"error",showStatusIcon:!0}))},onRemoveFileAttachment:e=>{t(yo(e))},onUpdateFileAttachment:e=>{t(Po({files:e}))},previewMonthEndReport:(e,a,c,u,T)=>{v!=null&&t(ga(e,v.companyId,a,!0,c,u,{agentInsightEdits:T,tenantId:v.tenantId}))},saveMonthEndReport:(e,a,c,u,T)=>{v!=null&&t(ga(e,v.companyId,a,!1,c,u,{agentInsightEdits:T,tenantId:v.tenantId}))},onEditMonthEndInsightsClick:m,sendMonthEndReport:e=>{const a=r.state?.referrer,{selectedPeriod:c,auditSummary:u}=l;v!=null&&u?.auditScorePercentage!=null&&(t(To(v.companyId,e,v.tenantId)),W.trackInsightsEmailPage(c.month,c.year,!1,"draft",u.auditScorePercentage,bo().format(Ka.analytics.MMMDDCommaYYYYformat),a??null))},onTransactionCategorizationRowClick:(e,a)=>{const c=l.transactionView.uiState.searchString??"",u=l.transactionView.transactions,T=u.findIndex((M=>M.id===e)),E=c.length>0?{resultPosition:T>=0?T+1:void 0,resultsCount:u.length,searchTerm:c}:void 0;if(n.openTransactionPanel)return void n.openTransactionPanel(e,a,E);const D=ee(r.state?.pathnameStackToGoBack,r.pathname);C(`../../transaction/${a}/${e}`,{state:{pathnameStackToGoBack:D,message:"expenseAutomation",origin:"transaction_categorization",searchContext:E}})},setLocalDataForCategoryAndClass:(e,a,c,u,T,E,D,M,J,Y,oe,ae)=>{t(ko(e,a,c,u,b,T,E,D,M,J,Y,oe,ae))},onCancelAutoComplete:()=>{t(Xe("common"))},updateExpenseAutomationReconListScrollPosition:e=>{t(ha({scrollPosition:e}))},onUpdateTab:e=>{n.closeSidePanel?.(),$!=null&&h!=null&&(t(Se(e,{start:h,end:$},!1,!1)),t(Io(e)))},onUpdateTransactionCategorizationCompletedSubTab:e=>{n.closeSidePanel?.(),$!=null&&h!=null&&(t(fo(e)),t(Se("autoCategorized",{start:h,end:$},!1,!1)))},onTransactionGroupChange:e=>{n.closeSidePanel?.(),$!=null&&h!=null&&(t(Co(e)),t(Se(n.expenseAutomationViewSelector.selectedTransactionCategorizationTab,{start:h,end:$},!1,!1)))},onUpdateTransactionCategorizationUIState:(e,a)=>{t(ft({selectedTab:e,uiState:a})),$!=null&&h!=null&&t(Se(e,{start:h,end:$},!1,!1,a.searchString,null,!0))},onUpdateScrollYOffSetTransactionCategorizationUIState:(e,a)=>{t(ft({selectedTab:e,uiState:a}))},onFetchTransactionCategorizationList:(e,a,c,u,T,E)=>{$!=null&&h!=null&&t(Se(e,{start:h,end:$},!0,c,a,u,T,E))},resetTransactionCategorizationLocalData:(e,a,c,u,T,E,D)=>{t(go(e,a,c,u,D??null,T,E,!1)),si(t,a.map(String))},updateSelectedVendorForTransaction:(e,a,c,u,T)=>{t(Sa({selectedTab:e,transactionId:a,lineId:c,selectedTransaction:u,uncategorizedAccounts:b,updatedVendor:T,isAccountingClassesEnabled:g}))},onSaveUpdateTransactionCategorization:(e,a,c)=>{const u=r.state?.referrer;e==="autoCategorized"?W.trackTransactionsAutoCategorisedPage(P.month,P.year,l.transactionView.totalCountByTab.autoCategorized,a.length,!1,u??null):W.trackTransactionsReviewPage(P.month,P.year,l.transactionView.totalCountByTab.review,a.length,!1,u??null),t(So(e,a,c)),ni(a.map(String))},onUpdateSelectedCheckboxTransactionIds:(e,a)=>{t(ho({selectedTab:e,transactionIds:a}))},onFetchRecommendationsForEntityCategorizationWithCustomer:(e,a,c,u,T,E)=>{const{transactionId:D,transaction:M,lineIds:J}=a;E!=null&&t(mo({transactionId:D,customerUpdates:E})),t(po({selectedTab:u,transactionId:D.id,lineId:J[0],selectedTransaction:M,uncategorizedAccounts:b,updatedCustomer:E,selectedEntity:T,isAccountingClassesEnabled:g})),T!=null&&t(yt({entity:T,amount:e,transactionDetails:a,flowType:"categorization",selectedTab:u,isFetchCOT:d}))},onFetchRecommendationsForEntityCategorization:(e,a,c,u,T,E)=>{const{transactionId:D,transaction:M,lineIds:J}=a;E!=null&&(t(lo({transactionId:D,vendorUpdates:{name:E.name,id:E.id?E.id:void 0}})),t(ro({vendorId:E.id?E.id:void 0,localData:{vendorName:E.name,vendorId:E.id?E.id:void 0}}))),E?.id?(t(Sa({selectedTab:u,transactionId:D.id,lineId:J[0],selectedTransaction:M,uncategorizedAccounts:b,updatedVendor:E,selectedEntity:T,isAccountingClassesEnabled:g})),T!=null&&t(yt({entity:T,amount:e,transactionDetails:a,flowType:"categorization",selectedTab:u,isFetchCOT:d}))):t(uo({selectedTab:u,transactionId:D.id,lineId:J[0]}))},fetchFluxViewOnScroll:(e,a)=>{t(Ze(e,!0,!1,a,!1,!0))},onFetchFluxViewList:()=>{t(Ze(P,!0,!1,null,!1,!1))},markAsReview:(e,a,c,u)=>{W.trackFluxAnalysisReviewed(c.month,c.year,u??!1,e),t(io(a,e,c,u??!1))},onUpdateFluxAnalysisUIState:e=>{t(co(e))},updateOperatingExpensesIdsForReview:e=>{t(oo({operatingExpenseIds:e,selectedPeriod:P}))},redirectToVendorDetailPage:e=>{if(n.tenantEmailDomain!=null){const a=Si(e.id,e.qboId,n.tenantEmailDomain),c=ee(n.location.state?.pathnameStackToGoBack,n.location.pathname);n.navigate(a,{state:{pathnameStackToGoBack:c,message:"expenseAutomation",referrer:"Vendor List",origin:"flux_analysis"}})}},updateSectionIdsForReview:e=>{t(so({sectionId:e,selectedPeriod:P}))},onFetchReimbursementView:(e,a,c)=>{t(Ze(e,!0,!1,a,!0,c))},onReviewClicked:e=>{t(ue(P,e))},setOpenDrawerClicked:e=>{t(tt({selectedDrawerAccountId:e}))},onFetchLinkTokenClick:(e,a)=>{t(Fa("expense_automation_reconcile",e,a))},onEstablishConnectionClick:(e,a)=>{const c=v?.companyId;c!=null&&(t(_a(e,c,"expense_automation_reconcile",void 0,"link_account_no_microdeposit",a)),t(Ma({accountId:a,connectionInProgress:!0})))},onAddStatementClick:e=>{t(tt({selectedDrawerAccountId:e})),t(Ke({accountId:e,selectedPeriod:P,localData:{accountSource:"bank_statement"}})),t(Qe({statementUploadChosen:!0}))},onReloadReconciliationListPage:()=>{t(ue(P,void 0,!0,!1))},onUpdateReconcileTabLocalData:e=>{t(no({selectedTransactionIds:e}))},onReconTabColumnSortConfigChanged:(e,a)=>{t(ao({sortKey:e,sortOrder:a}))},onReconReviewTabColumnSortConfigChanged:(e,a)=>{t(to({sortKey:e,sortOrder:a}))},onReconTabUpdate:e=>{n.closeSidePanel?.(),t(eo({selectedTab:e}))},updateReconReviewTabLocalData:(e,a,c)=>{const u=e.vendor?.id;c&&u!=null&&t(Qs(u)),t(Zs({data:e,transactionId:a}))},onReconMatchedTransactionClick:e=>{if(n.openTransactionPanel)return void n.openTransactionPanel(e,Pt("bill"));const a=ee(r.state?.pathnameStackToGoBack,r.pathname);C(`../../transaction/bill/${e}`,{state:{pathnameStackToGoBack:a,message:"expenseAutomation",origin:"reconciliation"}})},onReloadPage:()=>{window.location.reload()},onBackClick:()=>{C(-1)},onReconListPageScroll:e=>{t(ha({scrollPosition:e}))},onVendorAutoCompleteInputChange:e=>{e.trim().length>=2?t(pa({searchString:e,searchOrigin:"common"})):e.trim().length===0&&t(Xe("common"))},onReconNodeCollapseToggled:(e,a)=>{t(Ks({nodeId:e,collapsed:a}))},updateSectionCollapseStatus:()=>{},onExcludeAccountFromReconciliation:e=>{t(Ra({accountId:e}))},onIncludeAccountIntoReconciliation:e=>{t(Da({accountId:e}))}}}),((t,n,S)=>{const{isMissingReceiptsBulkUploadEnabled:g,...d}=S;return(function(i,r,A){return{...i,...r,...A,onUploadTransactionReceipt:(l,v,x,b,C)=>{r.onUploadTransactionReceipt(l,v,x,b,C,i.authParams)}}})(t,n,d)}))(Xc(Kc)),kt="newScheduleMode",Tt="newScheduleType",Bi=wi(ri((function(t){const n=t.displayName??t.name??"Component",S=La.memo(t),g=d=>{const i=ge(),r=(function(){const I=ge(),p=F((P=>Oe(P).reconciliation.selectedDrawerAccountId));return{isOpen:p!=null,selectedAccountId:p,openPanel:s.useCallback((P=>{I(tt({selectedDrawerAccountId:P}))}),[I]),closePanel:s.useCallback((()=>{I(tt({selectedDrawerAccountId:void 0}))}),[I])}})(),A=F((I=>Oe(I).reconciliation)),l=F((I=>ke(I))),v=s.useCallback(((I,p)=>{i(Fa("expense_automation_reconcile",I,p))}),[i]),x=s.useCallback(((I,p)=>{const P=l?.companyId;P!=null&&(i(_a(I,P,"expense_automation_reconcile",void 0,"link_account_no_microdeposit",p)),i(Ma({accountId:p,connectionInProgress:!0})))}),[i,l?.companyId]),b=s.useMemo((()=>{if(r.isOpen&&r.selectedAccountId!=null)return k.jsx(Pi,{reconciliation:A,selectedDrawerAccountId:r.selectedAccountId,onClose:r.closePanel,onFetchLinkTokenClick:v,onEstablishConnectionClick:x})}),[r.isOpen,r.selectedAccountId,r.closePanel,A,v,x]),C=s.useMemo((()=>({reconPanelContent:b,reconSidePanelIsOpen:r.isOpen,closeReconSidePanel:r.closePanel})),[b,r.isOpen,r.closePanel]),{useFeatureGate:f}=Ve(),{isFeatureEnabled:m}=f(H.isReconV3Enabled),z=s.useContext(ba),w=s.useMemo((()=>r.isOpen?m===!0?{selectedItemId:r.selectedAccountId}:{closePanel:r.closePanel,selectedItemId:r.selectedAccountId}:z),[r.isOpen,r.closePanel,r.selectedAccountId,z,m]);return k.jsx(ba.Provider,{value:w,children:k.jsx(S,{...d,...C})})};return g.displayName=`withReconSidePanel(${n})`,g})(bi((({closeMatchSidePanel:t,closeReconSidePanel:n,closeSidePanel:S,matchPanelContent:g,isMatchPanelOpen:d,matchPanelMatchId:i,openMatchPanel:r,openTransactionPanel:A,panelContent:l,reconPanelContent:v,reconSidePanelIsOpen:x,isSchedulePanelOpen:b,closeSchedulePanel:C,openSchedulePanel:f,schedulePanelContent:m,schedulePendingDiscardConfirmation:z,sidePanelIsFullView:w,sidePanelIsOpen:I})=>{const{isAiCfoOpen:p,setIsAiCfoOpen:P}=Uc(),_=Bc(),{isOpen:G}=Vc(),q=nt(),N=Te(),h=ge(),{isAiCfoAccessEnabled:$,onAskAiCfoClick:e}=Na({mobileExploreReferrer:"Transaction categorization"}),a=s.useCallback((()=>{d===!0&&t?.(),I===!0&&w!==!0&&S?.()}),[t,S,d,w,I]),c=F(Es);s.useEffect((()=>{c!=null&&(i===c&&a(),h(As()))}),[c,a,h,i]);const u=F(xs);s.useEffect((()=>{u!=null&&(i===u&&a(),h(ws()))}),[u,a,h,i]);const{areTenantIdsInSync:T}=$a(),E=Fi(),D=jc(),[M,J]=s.useState(!1),[Y,oe]=Jn(),ae=s.useCallback((o=>{oe((R=>{const L=new URLSearchParams(R);return o==null?(L.delete(kt),L.delete(Tt),L):(L.set(kt,o.scheduleDetailsMode),L.set(Tt,o.scheduleType),L)}),{replace:!0})}),[oe]),[Pe,ye]=s.useState(void 0),ve=s.useCallback(((o,R,L)=>{const j=vt(o);ye(j),ae({scheduleDetailsMode:R,scheduleType:o}),h(da({scheduleType:j==="prepaid_expenses"?"prepaid_expenses":"fixed_assets",shouldResetEnteredData:L}))}),[h,ae]),X=s.useMemo((()=>{const o=Y.get(kt),R=Y.get(Tt);return o!=null&&R!=null?{scheduleDetailsMode:o,scheduleType:R}:void 0}),[Y]),ot=s.useCallback((o=>{ae(o),o!=null&&h(da({scheduleType:vt(o.scheduleType)==="prepaid_expenses"?"prepaid_expenses":"fixed_assets",shouldResetEnteredData:!0}))}),[h,ae]),Ee=F((o=>ra(o))),B=F((o=>ke(o))),[ct,Ae]=s.useState(!1),[je,y]=s.useState(!1),[Z,ne]=s.useState([]),[K,ce]=s.useState(null),ie=s.useCallback((()=>{ce(null)}),[]),Et=K?.contentType==="activity"?K.detail.transactionId:void 0,it=s.useCallback((o=>{o!=null?(p&&P(!1),_(),a(),ce({contentType:"activity",detail:{transactionId:o}})):ce((R=>R?.contentType==="activity"?null:R))}),[a,p,_,P]),Qa=s.useCallback((o=>{p&&P(!1),_(),a(),ce({contentType:"transfer",detail:o})}),[a,p,_,P]),Za=s.useCallback((()=>{_(),ie(),a(),e()}),[a,ie,e,_]),At=s.useRef(p);s.useEffect((()=>{p===!0&&At.current===!1&&(_(),ie(),a()),At.current=p}),[a,ie,p,_]);const xt=s.useRef(G);s.useEffect((()=>{G===!0&&xt.current===!1&&(p&&P(!1),ie(),d===!0&&t?.(),I===!0&&w!==!0&&S?.()),xt.current=G}),[ie,t,S,G,p,d,P,w,I]);const ze=I===!0&&w!==!0||d===!0,wt=s.useRef(ze);s.useEffect((()=>{ze&&!wt.current&&(p&&P(!1),_(),ie()),wt.current=ze}),[ie,p,ze,_,P]);const[Rt,en]=s.useState(!1),Dt=s.useRef(!1),{selectedTab:tn}=Be(),{tenantEmailDomain:lt}=Be(),[rt,Ft]=s.useState(N.state?.message==="comingFromTransactionDetail"),_t=N.state?.message==="comingFromOverview",an=zc(),dt=st.getSignedInUser(),{useFeatureGate:le}=Ve(),{isFeatureEnabled:Mt}=le(H.isRealtimeInsightsFeatureEnabled),{isFeatureEnabled:xe}=le(H.isMissingReceiptsBulkUploadEnabled),{isFeatureEnabled:ut}=le(H.isTransactionActivityEnabled),{isFeatureEnabled:me}=le(H.isAccrualEnabled),{isFeatureEnabled:Ot}=le(H.isCreateTransferEntryFromExpenseEnabled),{isFeatureEnabled:nn}=le(H.isProjectsTransactionsEnabled),{isFeatureEnabled:sn}=le(H.isReconV3Enabled),on=s.useCallback((o=>{const R=Pt(o.transactionType??(o.view==="reconciliation"?"bill":"expense")),L=ee(N.state?.pathnameStackToGoBack,N.pathname),j=new URLSearchParams({view:"full"});o.threadId!=null&&j.set("thread_id",o.threadId),o.entityType!=null&&j.set("entity_type",o.entityType),q(`/${lt}/transaction/${encodeURIComponent(R)}/${o.transactionId??o.entityId}?${j.toString()}`,{state:{pathnameStackToGoBack:L,message:"expenseAutomation"}})}),[q,lt,N.state,N.pathname]),cn=F((o=>Rs(o,"common"))),V=F((o=>Oe(o))),{categoryOptions:ln,paymentAccountNames:rn}=F((o=>Ds(o.accountState))),dn=F((o=>Fs(o.classState))),{monthEndCloseChecksView:Q,currentSelectedView:O,selectedPeriod:U,selectedTransactionCategorizationTab:mt,currentSelectedViewBackgroundRefreshFetchState:un,currentSelectedViewFetchState:re,jeSchedules:pt,reconciliation:Ut}=V;Zc(O==="transaction_categorization");const mn=V.transactionView.saveStatus.fetchState,Le=V.transactionView.transactions,Bt=s.useRef(Le);Bt.current=Le;const Vt=F((o=>o.expenseAutomationTransactionsViewState?.transactionCategorizationView)),jt=F((o=>o.expenseAutomationTransactionsViewState?.selectedTransactionCategorizationTab)),zt=s.useRef(Vt);zt.current=Vt;const Lt=s.useRef(jt);Lt.current=jt;const $e=F((o=>{const R=o.expenseAutomationTransactionsViewState?.selectedTransactionCategorizationTab;return R!=null?o.expenseAutomationTransactionsViewState?.transactionCategorizationView?.[R]?.filters:void 0})),$t=s.useRef("");s.useEffect((()=>{if(O!=="transaction_categorization")return;const o=V.transactionView.uiState.searchString??"";if(re.fetchState!=="Completed"||o.length===0||o===$t.current)return;$t.current=o;const R=$e!=null?Lc($e):0,L=$e?.categories.filter((j=>j.values.length>0&&String(j.values[0]??"").trim()!=="")).map((j=>`${j.field}:${j.values.join(",")}`))??[];W.trackAiCloseTransactionSearch({filtersApplied:L,hasResults:Le.length>0,isFiltered:R>0,resultsCount:Le.length,searchTerm:o,searchType:"free_text"})}),[O,re.fetchState,V.transactionView.uiState.searchString,V.transactionView.transactions,$e]);const de=ei(mn,(()=>{const o=[],R=Lt.current,L=zt.current,j=L!=null&&R!=null?L[R]:void 0;if(j?.transactionReviewLocalDataById!=null)for(const fe of Object.values(j.transactionReviewLocalDataById)){const te=fe?.transactionReviewLocalData?.lineItemById;if(te!=null)for(const ht of Object.values(te)){const _e=ht?.account;_e?.accountId!=null&&o.push(_e.accountId)}}const Ce=Bt.current;for(const fe of Ce)for(const te of fe.lines??[])"account"in te&&te.account?.accountId!=null&&o.push(te.account.accountId);return o}));s.useEffect((()=>{O==="transaction_categorization"&&I!==!0||it(void 0)}),[O,it,I]),s.useEffect((()=>{x===!0&&n?.()}),[O,Ut.selectedAccountId]);const pn=V.transactionView.selectedTransactionCategorizationCompletedSubTab,hn=V.transactionView.selectedTransactionGroup,Ge=`${mt}|${pn}|${hn}`,qe=s.useRef(null),Gt=s.useRef(null);s.useEffect((()=>{qe.current!==null?qe.current!==Ge&&(qe.current=Ge,O==="transaction_categorization"&&ie()):qe.current=Ge}),[ie,O,Ge]);const Sn=F((o=>Et==null?void 0:_s(o.transactionState,Et))),pe=Sn?.qboId,qt=F((o=>pe==null?void 0:Ms(o,pe)));s.useEffect((()=>{pe!=null&&h(Os(pe))}),[h,pe]);const{createTransferEntryStatus:Nt,creditCardTransferAccountsList:Jt,transferAccounts:Yt}=V.transactionView,Ht=s.useCallback((o=>ti(h,o)),[h]),Wt=s.useMemo((()=>O!=="transaction_categorization"||K==null?null:K.contentType==="activity"?ut===!0?k.jsx($c,{activityLogView:qt,qboId:pe,onClose:()=>ce(null),selectedTransactionId:K.detail.transactionId,isQuickViewCardStyle:!0},String(K.detail.transactionId)):null:K.contentType==="transfer"?k.jsx(Gc,{createTransferEntryStatus:Nt,creditCardTransferAccountsList:Jt,transaction:K.detail,transferAccounts:Yt,onClose:()=>ce(null),onCreateTransfer:Ht,isQuickViewCardStyle:!0},String(K.detail.transactionId)):null),[O,K,ut,qt,pe,Nt,Jt,Yt,Ht]),gn=Wt!=null,{selectedAccountId:we}=Ut,Xt=et(pt.accountSettingsView.saveState.fetchState),Cn=F((o=>Us(o.accountState,o.accountListState,"accountList"))),fn=F((o=>Bs(o))),Re=Ya(tn)??O,In=F((o=>o.entityAutoCompleteState.autoCompleteText.common));if(Ga({isDataReady:re.fetchState==="Completed"}),dt==null)throw Error("Can't access expense automation screen without signing in...");const Kt=Ua(U),De=at(Kt.start),Fe=at(Kt.end);if(De==null||Fe==null)throw Error(`Invalid start - ${De} and end - ${Fe} period from given ${U}`);const kn=s.useCallback((()=>{Ae(!1)}),[]),Tn=s.useCallback((()=>{y(!0)}),[]),bn=s.useCallback((o=>{ne(o),y(!1)}),[]),Pn=s.useCallback((()=>{ne([])}),[]),Ne=V.missingReceipts.bulkUpload.phase,Qt=V.missingReceipts.bulkUpload.currentBatchId;s.useEffect((()=>{xe===!0&&O==="missing_receipts"&&Ne==="matching"&&Qt!=null&&h(Ba({cacheOverride:!0}))}),[xe,O,Ne,Qt,h]);const Zt=dt?.userId,yn=U.month,vn=U.year,ea=B?.tenantId;s.useEffect((()=>{O==="missing_receipts"&&xe!==!1&&Ne==="idle"&&Zt!=null&&ea!=null&&h(Vs())}),[O,xe,Ne,Zt,ea,yn,vn,h]),s.useEffect((()=>{Ee.newVendorState?.vendorDetailLocalData?.vendorName!=null?J(!0):J(!1)}),[Ee.newVendorState?.vendorDetailLocalData?.vendorName]),s.useEffect((()=>{Re!=null&&O!==Re&&h(Va(Re))}),[Re]),s.useEffect((()=>{Rt===!1&&re.fetchState==="Completed"&&T&&(en(!0),h(ua(!1,!1,me===!0)))}),[Rt,re,T,me]),s.useEffect((()=>{const o={month:U.month,year:U.year},R=Gt.current;Gt.current=o,R===null||R.month===o.month&&R.year===o.year||!_t&&T&&(h(ua(!1,!1,me===!0)),h(ue(U,we,!1,!1)))}),[U.month,U.year,T,me]);const Je=s.useCallback(((o=!1,R=!1)=>{const L={start:De,end:Fe};switch(O){case"transaction_categorization":h(Se(mt,L,o,!rt,void 0,void 0,R)),Ft(!1);break;case"flux_analysis":h(Ze(U,o,R,null));break;case"month_end_insights":if(R===!1){const j=new Date(U.year,U.month,0),Ce=zs(j.toDateString()).format(Ka.analytics.YYYYDashMMDashDDFormat);h(Ls(!0,B.companyId,B.tenantId,Ce)),h($s(B.companyId,B.tenantId))}break;case"je_schedules":h(js(L,R,me===!0));break;case"missing_receipts":h(ja(L,{amount:75,currencyCode:"USD",currencySymbol:"$"},o,R));break;default:h(ue(U,we,o,R))}}),[O,De,Fe,B.companyId,B.tenantId,mt,U,we,rt,Ft,me]),En=s.useCallback((()=>{Je(!0,!0)}),[Je]);s.useEffect((()=>{O===Re&&re.fetchState==="Not-Started"&&T&&Je(!0)}),[re,De,Fe,B.companyId,B.tenantId,T]),s.useEffect((()=>{_t||rt||Dt.current||un.fetchState==="In-Progress"||re.fetchState!=="Completed"||(Dt.current=!0,Je(!0,!0))}),[]),s.useEffect((()=>{Q.fetchState!=="In-Progress"&&Q.fetchState!=="Completed"&&Q.fetchState!=="Error"&&B?.tenantId!=null&&h(Me({tenantId:B.tenantId,period:U,refreshViewInBackground:!1}))}),[Q.fetchState,B?.tenantId]),s.useEffect((()=>{Q.fetchState!=="Completed"||!T||(Q.monthEndCloseChecks?.monthEndCloseCheckList.some((o=>o.id==="reconciliation"))??!1)&&V.reconciliation.fetchStatus.fetchState==="Not-Started"&&h(ue(U,void 0,!1,!1))}),[Q.fetchState,T,U.month,U.year,V.reconciliation.fetchStatus.fetchState,h]),s.useEffect((()=>{V.monthEndInsights?.previewMonthEndReportStatus?.fetchState==="Completed"?Ae(!0):Ae(!1)}),[V.monthEndInsights?.previewMonthEndReportStatus?.fetchState]),s.useEffect((()=>{V.monthEndInsights?.sendMonthEndReportStatus?.fetchState==="Completed"&&T&&(h(Me({tenantId:B.tenantId,period:U,refreshViewInBackground:!0})),h(Gs({companyId:B.companyId})),q("../"))}),[V.monthEndInsights?.sendMonthEndReportStatus?.fetchState,B.tenantId,U,B.companyId,T]),s.useEffect((()=>{const o=setInterval((()=>{Q.fetchState!=="In-Progress"&&Q.fetchState==="Completed"&&h(Me({tenantId:B.tenantId,period:U,refreshViewInBackground:!0}))}),3e5);return()=>clearInterval(o)}),[Q.fetchState,B.tenantId,U,h]),s.useEffect((()=>{const o=setInterval((()=>{O==="reconciliation"&&we==null&&V.reconciliation.fetchStatus.fetchState==="Completed"&&V.reconciliation.refreshStatus.fetchState!=="In-Progress"&&h(ue(U,void 0,!0,!0))}),3e5);return()=>clearInterval(o)}),[O,h,V.reconciliation.fetchStatus.fetchState,V.reconciliation.refreshStatus.fetchState,ue,we,U]);const An=ya(),{isFeatureEnabled:xn}=le(H.isRecommendationFeedbackEnabled),ta=qc(),{onRecommendationSelection:aa,popup:wn}=ai({isEnabled:xn}),Rn=s.useMemo((()=>({...ta,onRecommendationSelection:aa})),[ta,aa]);s.useEffect((()=>{const o=(Q.monthEndCloseChecks?.monthEndCloseCheckList.find((R=>R.id==="month_end_insights"))?.isDisabled??!1)&&!Mt;O!=="month_end_insights"||!o&&Q.monthEndCloseChecks?.reportEmailSentDate==null||q("../")}),[O,Q.monthEndCloseChecks]);const Dn=x===!0?v:l,Fn=x===!0||I===!0,_n=x===!0?n:S,Mn=x!==!0&&w;s.useEffect((()=>{Xt==="In-Progress"&&pt.accountSettingsView.saveState.fetchState==="Completed"&&h(ma())}),[Xt,pt.accountSettingsView.saveState.fetchState,ma]);const{transactionId:na,onSaveVendor:On,onSaveSuccess:Un,onCancel:Bn,vendorViewDetails:Vn}=(({expenseAutomationViewSelector:o,closeDrawerHandler:R,currentSelectedView:L})=>{const j=ge();let Ce,fe,te;const ht=ya(),_e=o.transactionView;let sa=()=>{};const{transactions:jn,selectedTransactionId:Ie,selectedTransactionLineId:Ye,transactionLocalData:zn}=_e;if(L==="transaction_categorization"){const St=zn.find((he=>he.transactionId===Ie)),se=jn.find((he=>he.id===Ie)),oa=Ye!=null?St?.transactionReviewLocalData?.lineItemById[Ye]:void 0,ca=oa?.account;fe=oa?.class?.classId,Ce=["Uncategorized Income","Uncategorized Expense"].includes(ca?.accountName??"")?void 0:ca?.accountId;const $n=hi(Ie,se?.typeOfTransaction);se!=null&&$n&&(te={id:Ie,type:Pt(se.typeOfTransaction)}),sa=()=>{if(Ie!=null&&Ye!=null&&se!=null){const he=_e.transactionLocalData.find((He=>He.transactionId===Ie))?.transactionReviewLocalData;if(he!=null&&se.lines!=null&&se.lines.length>0){const He=he.lineItemById[Ye];let gt=he.selectedEntity;if(vs(se)||(gt=He.selectedEntityLine),gt!=null){const Gn=gt,qn={transactionId:{id:se.id,type:se.type},transaction:se,lineIds:se.lines.map((Nn=>Nn.id))??[]};j(yt({entity:Gn,amount:He.amount.amount,transactionDetails:qn,flowType:"categorization",selectedTab:o.selectedTransactionCategorizationTab,isFetchCOT:ht}))}}}}}const Ln=F((St=>ra(St,void 0,Ce,fe)));return{transactionId:te,onSaveVendor:()=>{j(ys(te,void 0,!1,!0))},onSaveSuccess:sa,onCancel:()=>{te!=null&&j(Ts({transactionId:te})),j(bs()),j(Ps()),R()},vendorViewDetails:Ln}})({expenseAutomationViewSelector:V,closeDrawerHandler:()=>{J(!1)},currentSelectedView:O});return an?.loggedInUserRoleMap==null?Q.fetchState==="Error"?k.jsx(Nc,{onGoHome:()=>q("../",{replace:!0}),onReload:()=>window.location.reload()}):k.jsx(qa,{fetchState:"In-Progress"}):k.jsxs(k.Fragment,{children:[k.jsx(Ci,{isOpen:je,drawerLeftMargin:new Jc(0,0,300,650),onClose:()=>{y(!1)},children:k.jsx(Vi,{onClick:o=>o.stopPropagation(),children:k.jsx(Ri,{companyId:B.companyId,closeCustomerRequestDrawer:()=>y(!1),addCustomerRequest:bn,resetCustomerRequest:Pn})})}),na!=null&&M&&k.jsx(oi,{isOpen:M,transactionId:na,onSaveVendor:On,onSaveSuccess:Un,onCancel:Bn,vendorViewDetails:Vn}),k.jsx(Yc,{toolkit:Rn,children:k.jsx(Ui,{events:[],eventCallback:(o,R,L)=>{},navigate:q,location:N,themeState:D,categoryOptions:ln,classesForFilters:dn,accountsForFilters:rn,vendorSearchAutoCompleteData:{autoCompleteText:In,entityAutoCompleteView:cn},expenseAutomationViewSelector:V,isMissingReceiptsBulkUploadEnabled:xe,monthEndInsightsPreviewMode:ct,monthEndInsightsCustomerRequestData:Z,isRealtimeInsightsFeatureEnabled:Mt,isCreateTransferEntryFromExpenseEnabled:Ot,isAccountingClassesEnabled:fn,isProjectsTransactionsEnabled:nn,isCOTEnabled:An,currentTenant:B,companyId:B.companyId,signedInUser:dt,isTransactionActivityEnabled:ut,isRightPanelOpen:gn,rightSidePanel:Wt,onOpenTransferRightPanel:Ot===!0?Qa:void 0,uncategorizedAccounts:Cn,newScheduleActiveType:Pe,isAccrualEnabled:me,newScheduleSelection:X,onNewScheduleSelectionChange:ot,onScheduleTypeChange:ve,onNewScheduleSaved:En,onClickCustomerRequest:Tn,handleEditClick:kn,tenantEmailDomain:lt,trackExpenseAutomationTabAnalytics:E,setActivityLogTransactionId:it,closeMatchSidePanel:t,closeSidePanel:_n,openTransactionPanel:A,closeSchedulePanel:C,openSchedulePanel:f,openMatchPanel:r,sidePanelIsOpen:Fn,sidePanelIsFullView:Mn,panelContent:Dn,isAiCfoAccessEnabled:$,onAskAiCfoClick:Za,isReconV3Enabled:sn,onExpenseAutomationCommentingThreadClick:on,sidePanelListPercent:x===!0?66:void 0,isMatchPanelOpen:d,isSchedulePanelOpen:b,matchPanelContent:g,schedulePanelContent:m,schedulePendingDiscardConfirmation:z})}),wn,de.showPopup&&de.popupType!=null&&k.jsx(Hc,{popupType:de.popupType,currencySymbol:de.currencySymbol,accountId:de.popupAccountId??"",accountName:de.popupAccountName??"",onSubmit:de.handleSubmit,onDismiss:de.handleDismiss})]})}))))),Vi=be(Ac)`
35
35
  display: flex;
36
36
  min-height: 100%;
37
37
  flex-direction: column;
@@ -0,0 +1 @@
1
+ import{j as s}from"./liveblocks-CQOAuUNI.js";import{a as r}from"./sentry-pp_6zWNc.js";import{aw as f,ax as c,r as l,a4 as p}from"./index-B1xlAtau.js";import"./mui-XiTT8YBC.js";import m from"./NotFoundScreen-DnqoRCYC.js";import{h as b,g as u}from"./core-D07hD3KT.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new a.Error().stack;e&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[e]="aafc30b9-341c-40aa-86a1-bb77a9af613d",a._sentryDebugIdIdentifier="sentry-dbid-aafc30b9-341c-40aa-86a1-bb77a9af613d")}catch{}})();const _=()=>{const a=b(),e=u(),t=r.useCallback((()=>{window.open("https://www.zeni.ai/demo/request","_blank")}),[]),i=r.useCallback((()=>{(()=>{const n=p(e.state?.pathnameStackToGoBack),d=n.poppedPathname??k();a(d,{state:{pathnameStackToGoBack:n.newStack}})})()}),[]),o=f(e.pathname);return o!=null?s.jsx(c,{menuItem:l(o),onDemoClick:t,onGoBack:i}):s.jsx(m,{})},k=(a=2)=>{let e="../";for(let t=0;t<a;t++)e=`${e}../`;return e};export{_ as F};
@@ -0,0 +1 @@
1
+ import{a as r}from"./sentry-pp_6zWNc.js";import{u as f,h as l,g as m}from"./core-D07hD3KT.js";import{h$ as p,UL as g,UM as _}from"./zeni-epic-state-B3TABHgO.js";import{u as b,L as h,z as y}from"./index-B1xlAtau.js";import"./liveblocks-CQOAuUNI.js";import"./recharts-CgYqsGTH.js";import"./mui-XiTT8YBC.js";import"./analytics-DlzSqyvZ.js";import"./plaid-BG3pJamN.js";import"./dnd-B-KpYfWT.js";import"./stripe-cKAAJElX.js";import"./lottie-BIKpYE12.js";import"./lexical-NIxvAmS2.js";import"./pdf-Dli3mGO_.js";import"./utils-CrOdvv6w.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]="0fdf3891-5c7e-4a9e-b5ea-d15ebfeee038",e._sentryDebugIdIdentifier="sentry-dbid-0fdf3891-5c7e-4a9e-b5ea-d15ebfeee038")}catch{}})();function $(){const e=f(),n=l(),o=m(),{setLoading:i,clearAllLoading:c}=b(),s=r.useRef(!1);return r.useLayoutEffect((()=>{i(h.CONNECTION_AUTH)}),[i]),r.useEffect((()=>{if(s.current)return;s.current=!0;const a=new URLSearchParams(o.search).get("code"),d=sessionStorage.getItem("hubspot_oauth_pending");if(sessionStorage.removeItem("hubspot_oauth_pending"),a!=null&&d!=null){const t=JSON.parse(d);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}))}c();const u=y.getActiveTenantForUser();n(u?.tenantEmailDomain!=null?`/${u.tenantEmailDomain}/settings/integrations`:"/",{replace:!0})}),[]),null}export{$ as default};
@@ -1 +1 @@
1
- import{n as s}from"./liveblocks-gNIoHksP.js";import{j as c}from"./core-_cqItzd_.js";import{fI as f}from"./zeni-epic-state-ClqSlu6d.js";import"./sentry-BzzHvh63.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
+ import{n as s}from"./liveblocks-CQOAuUNI.js";import{j as c}from"./core-D07hD3KT.js";import{fI as f}from"./zeni-epic-state-B3TABHgO.js";import"./sentry-pp_6zWNc.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};
@@ -0,0 +1,2 @@
1
+ import{j as c}from"./liveblocks-CQOAuUNI.js";import{a as r}from"./sentry-pp_6zWNc.js";import{u as L,h as _,i as $,j as k,t as J,l as O,s as q,g as Y,N as V,n as oe,o as x}from"./core-D07hD3KT.js";import{a8 as Xn,k as g,aq as R,U as d,cc as Zn,cd as et,ce as nt,cf as tt,cg as it,ch as ot,ci as at,cj as ct,ck as st,cl as rt,cm as dt,cn as lt,p as X,co as ut,cp as gt,z as W,ae as se,cq as vt,cr as mt,cs as pt,ct as St,cu as ft,cv as It,cw as ht,cx as Ct,cy as kt,cz as Et,W as yt,ai as rn,cA as bt,cB as xt,cC as At,cD as Dt,cE as jt,cF as Lt,cG as _t,cH as Pt,cI as wt,cJ as $t,cK as Ft,t as He,j as _e,cL as Rt,cM as Tt,cN as Ot,cO as Mt,cP as Nt,cQ as Ut,cR as Bt}from"./index-B1xlAtau.js";import"./mui-XiTT8YBC.js";import{A as K}from"./AddressScreen-DAE2XqXc.js";import M from"./NotFoundScreen-DnqoRCYC.js";import{Z$ as Vt,_0 as Ht,vv as qe,_1 as G,v_ as re,_2 as Pe,_3 as de,wB as be,wI as qt,wM as dn,_4 as we,wF as Qt,ye as Qe,vZ as ze,_5 as ln,wX as xe,_6 as le,w$ as zt,_7 as Kt,_8 as un,x2 as gn,z9 as Gt,_9 as Se,_a as Ke,_b as vn,vX as Wt,_c as Jt,vP as Yt,_d as Xt,yr as Zt,_e as mn,yA as Ge,_f as ei,yx as ni,_g as $e,gk as Fe,_h as te,_i as ie,xh as ti,w3 as We,w8 as pn,w6 as ii,w0 as oi,xa as ai,wa as ci,xj as si,_j as Ae,xs as Sn,xq as fe,xo as ue,xn as ri,_k as fn,yG as Je,_l as di,vY as In,_m as Re,fI as Ie,wj as De,wg as je,wt as hn,ws as Te,wd as li,wm as Cn,wv as ae,VM as kn,v$ as Oe,wq as ui,wr as gi,wp as vi,_n as mi,x0 as pi,wY as En,_o as yn,vJ as Ye,_p as Si,vF as fi,_q as Ii,yM as hi,yQ as Q,yL as Ci,xU as he,_r as ki,_s as bn,yZ as Xe,_t as Ei,yW as yi,_u as xn,xX as bi,xY as H,x$ as xi,_v as An,y9 as Ee,_w as Ai,xi as Dn,Ui as jn,_x as Di,yj as ji,_y as Ln,_z as Li,_A as _i,_B as Pi,zO as wi,_C as $i,_D as _n,z4 as Pn,_E as wn,zM as ye,_F as Fi,zJ as Ri,_G as Ti,_H as Oi,_I as Mi,_J as Ni,_K as Ui,_L as Ze,_M as Bi,ei as Vi,zS as Hi,_N as Me,xC as qi,xx as Qi,_O as ge,xN as $n,xF as ve,xE as zi,xI as Fn,_P as Ki,xD as Gi,_Q as Rn,za as Tn,zB as en,zw as Wi,_R as Ji,zb as Yi,_S as Xi,zC as Zi,zG as eo,_T as Ne,wD as On,zn as no,wE as to,_U as io,_V as Mn,c9 as oo,mv as ao,mw as co,_W as nn,wC as me,go as so,mC as ro,zt as Nn,A2 as lo,zq as Un,v1 as uo,uR as go,hV as vo,UL as tn,UM as mo,Go as Bn,z$ as po,hN as So,zY as fo,_X as Io,_Y as ho,A8 as Co,A7 as ko,_Z as Eo,__ as Vn,A5 as yo,_$ as bo,$0 as xo,yn as Ao,$1 as Do}from"./zeni-epic-state-B3TABHgO.js";import{M as jo}from"./MobileAppDrawer-8BZVS4o3.js";import{q as pe}from"./QBOConnectionScreen-Dnjt4r9I.js";import"./recharts-CgYqsGTH.js";import"./analytics-DlzSqyvZ.js";import"./plaid-BG3pJamN.js";import"./dnd-B-KpYfWT.js";import"./stripe-cKAAJElX.js";import"./lottie-BIKpYE12.js";import"./lexical-NIxvAmS2.js";import"./pdf-Dli3mGO_.js";import"./utils-CrOdvv6w.js";import"./InboxNotificationsProvider-CH-l5W7V.js";import"./useTaskManagerAccess-Y5qsn5_D.js";import"./empty-DRbThjIF.js";import"./pdf-lib-D9XJLVoD.js";import"./index-D5s14gxd.js";import"./url-TK5h7pVR.js";import"./index-z9Fh-4S1.js";import"./decodeURIComponentSafe-D3MFRtCF.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]="3323183a-ec2e-4284-880c-cf2f2e8b91b4",t._sentryDebugIdIdentifier="sentry-dbid-3323183a-ec2e-4284-880c-cf2f2e8b91b4")}catch{}})();const w=({event:t,isReady:e=!0})=>e?c.jsx(Xn,{analytics:g,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function Lo(){const t=L(),e=_(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),{fetchState:m,hasMore:p,items:f,nextCursor:I,auditLogEntityRouteOptions:E,auditLogListSortFieldOptions:h}=k(Vt),y=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),D=`/${n??""}/invoicing`,b=r.useCallback(((F,U)=>{const T=Ht(D,F,U,E);T!=null&&(g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{entity:F,entityId:U,fromScreen:"audit_log",toScreen:F}),e(T))}),[E,e,D]);r.useEffect((()=>{const F=setTimeout((()=>u(a)),300);return()=>clearTimeout(F)}),[a]),r.useEffect((()=>{i&&t(qe({filters:y,keepExistingListItems:!1,sort:v}))}),[i,y,v,t]);const A=m==="Not-Started"||m==="In-Progress"&&f.length===0,C=m==="In-Progress"&&f.length>0,j=m==="Completed";return N(m)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingAuditLogPage,isReady:j}),c.jsx(Zn,{auditLogEntityRouteOptions:E,auditLogListSortFieldOptions:h,entries:f,hasMore:p,isLoading:A,isLoadingMore:C,searchValue:a,sortState:l,onEntityLinkClick:b,onLoadMore:()=>{p&&I!=null&&t(qe({cursor:I,filters:y,keepExistingListItems:!0,sort:v}))},onSearchChange:o,onSortChange:S})]})}function Ce(t,e=!1){const n=L(),i=k((s=>G(s).productNextCursor!=null)),a=k((s=>G(s).productNextCursor)),o=k((s=>G(s).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&o!=="Not-Started"||n(re({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&o!=="In-Progress"&&i&&a!=null&&n(re({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,o,i,a])}function Z(t,e,n,i){const[a,o]=r.useState(0),[s,u]=r.useState(!1),l=r.useRef(t);return r.useEffect((()=>{const S=l.current==="In-Progress";l.current=t,t==="Completed"&&S&&n!=null&&(u(!0),i(n))}),[t,n,i]),r.useEffect((()=>{s&&!e&&(u(!1),o((S=>S+1)))}),[s,e]),a}const _o=new Set(["plan"]),Po=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(d.Event.invoicingCatalogItemLifecycleAction,{action:a,fromScreen:"catalog_item_detail",itemId:i}),t(Qt({action:a,id:i})))}:void 0,onEditChange:a=>{i!==""&&t(we({id:i,localData:a}))},onSaveEdit:()=>{g.trackInvoicingActionClick(d.Event.invoicingCatalogItemEdited,{itemId:i}),t(dn({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&t(qt({action:o,id:a,parentItemId:i}))}}}))(et);function wo(){const t=L(),e=_(),{item_id:n,tenantEmailDomain:i}=$(),[a]=J(),{areTenantIdsInSync:o}=R(),s=(u=a.get("kind"))!=null&&_o.has(u)?u:"plan";var u;const l=k((y=>Pe(y,n))),{pageFetchState:S}=l,v=S.fetchState;r.useEffect((()=>(t(de({id:n})),()=>{t(de({id:n}))})),[t,n]),r.useEffect((()=>{o&&t(be({id:n,kind:s}))}),[o,n,s,t]);const m=r.useCallback((y=>t(be({cacheOverride:!0,id:y,kind:s}))),[t,s]),p=Z(l.fetchState,l.isFormLoading,n,m),f=v==="Completed"&&!l.isFormLoading;Ce(o,!0);const[I,E]=r.useState(f?n:void 0);r.useEffect((()=>{n!=null&&f&&E(n)}),[n,f]);const h=I!==n&&(v==="Not-Started"||v==="In-Progress"||l.isFormLoading);return N(v)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCatalogItemDetailPage,isReady:f}),c.jsx(Po,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:s,isLoading:h,view:l},p)]})}const $o=new Set(["addon","charge","plan"]),Fo=new Set(["plan"]),Ro=O((function(t,e){const n=Pe(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,pricingModelValues:n.pricingModelValues,prorationValues:n.prorationValues,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,tierTypeValues:n.tierTypeValues}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.isEdit?"edit":"create",{itemId:a}=e,o=a!=null?`${n}/catalog/${encodeURIComponent(a)}`:`${n}/catalog`;return{onBack:()=>e.navigate(o),onCancel:()=>{g.trackInvoicingActionClick(d.Event.invoicingCatalogItemFormCancelled),t(de({id:a})),e.navigate(`${n}/catalog`)},onChange:s=>{t(we({id:a,localData:s}))},onSubmit:()=>{g.trackInvoicingActionClick(d.Event.invoicingCatalogItemSaved,{mode:i}),t(dn({id:a}))}}}))(nt);function To(){const t=L(),e=_(),{item_id:n,tenantEmailDomain:i}=$(),[a]=J(),{areTenantIdsInSync:o}=R(),s=n!=null,u=a.get("type"),l=u!=null&&$o.has(u)?u:void 0,S=(v=a.get("kind"))!=null&&Fo.has(v)?v:"plan";var v;const m=k((p=>Pe(p,n)));return Ce(o,!0),r.useEffect((()=>{o&&t(be({id:n,kind:S}))}),[o,n,S,t]),r.useEffect((()=>{s||l==null||m.localData.catalogType===l||t(we({localData:{...m.localData,catalogType:l}}))}),[s,l,m.localData?.catalogType,t]),r.useEffect((()=>{if(m.fetchState==="Completed"){const p=m.savedItemId??n,f=p!=null?`/${i}/invoicing/catalog/${encodeURIComponent(p)}`:`/${i}/invoicing/catalog`;e(f),t(de({id:n}))}}),[m.fetchState,m.savedItemId,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCatalogItemFormPage}),c.jsx(Ro,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:s,itemId:n})]})}const Oo={addons:"addon",all:"item",charges:"charge",plans:"plan"},Mo=O((function(t,e){const n=G(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(d.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const s=Oo[e.activeTab];g.trackInvoicingActionClick(d.Event.invoicingAddCatalogItemClicked,{itemType:s}),e.navigate(`${n}/catalog/new?type=${s}`)},onItemClick:(s,u)=>{g.trackInvoicingActionClick(d.Event.invoicingCatalogItemRowClicked,{itemId:u}),e.navigate(`${n}/catalog/${encodeURIComponent(u)}`)},onLoadMore:()=>{if(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"catalog",tab:e.activeTab}),a)return e.planNextCursor!=null&&t(ze({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&t(re({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));o!=null&&t(i?ze({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):re({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(tt);function No(){const t=L(),e=_(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState("plans"),[l,S]=r.useState(""),[v,m]=r.useState(null),p=r.useMemo((()=>v!=null?{dir:v.direction,field:v.columnKey}:void 0),[v]),f=l.trim()!==""?l.trim():void 0,I=r.useMemo((()=>({search:f,type:"plan"})),[f]),E=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),h=k((j=>G(j))),y=h.planFilters.search,D=h.planSort,b=h.planNextCursor,A=h.productNextCursor,C=h.fetchState==="Completed";return r.useEffect((()=>{const j=setTimeout((()=>S(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t(Qe({cacheOverride:!1,planFilters:I,productFilters:E,planSort:p,productSort:p}))}),[i,t,I,E,p]),r.useEffect((()=>{i&&(f!==y||p?.field!==D?.field||p?.dir!==D?.dir)&&t(Qe({cacheOverride:!0,planFilters:I,productFilters:E,planSort:p,productSort:p}))}),[y,D,i,t,I,E,f,p]),N(h.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCatalogPage,isReady:C}),c.jsx(Mo,{navigate:e,tenantEmailDomain:n,activeTab:s,searchValue:a,sortState:v,planFilters:I,productFilters:E,sort:p,planNextCursor:b,productNextCursor:A,onSearchChange:o,onTabChange:u,onSortChange:m})]})}const Uo=O((function(t,e){const n=ln(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,periodUnitOptions:n.periodUnitOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,a=i!=null?"edit":"create",o=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>e.navigate(o),onCancel:()=>{g.trackInvoicingActionClick(d.Event.invoicingCouponFormCancelled),t(le({id:i})),e.navigate(`${n}/discounts`)},onChange:s=>{t(Kt({id:i,localData:s}))},onSubmit:()=>{g.trackInvoicingActionClick(d.Event.invoicingCouponSaved,{mode:a}),t(zt({id:i}))}}}))(it);function Bo(){const t=L(),e=_(),{coupon_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=R(),{fetchState:o,savedCouponId:s}=k((u=>ln(u,n)));return r.useEffect((()=>{a&&t(xe({id:n}))}),[a,n,t]),r.useEffect((()=>{if(o==="Completed"){const u=s??n,l=u!=null?`/${i}/invoicing/discounts/${encodeURIComponent(u)}`:`/${i}/invoicing/discounts`;e(l),t(le({id:n}))}}),[o,s,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCouponFormPage}),c.jsx(Uo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Vo=O((function(t){const e=un(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(d.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:a=>{e(vn(a))},onSubmit:()=>{const a=Jt(t.localData);g.trackInvoicingActionClick(d.Event.invoicingInvoiceCreated,{customerId:a.customer_id,lineItemCount:a.line_items?.length}),e(Yt(a))}}}))(at);function Ho(){const t=L(),e=_(),{tenantEmailDomain:n}=$(),[i]=J(),{areTenantIdsInSync:a}=R(),o=i.get("customerId"),s=k((b=>un(b))),u=s.fetchState,l=s.localData,S=s.savedInvoiceId,v=k(gn),m=k((b=>Gt(b))),p=k(Se),f=m.fetchState==="Not-Started"||m.fetchState==="In-Progress"&&v==null,I=p.fetchState==="Not-Started"||p.fetchState==="In-Progress"&&p.customers.length===0,E=f||I,h=m.fetchState==="Completed"&&p.fetchState==="Completed";r.useEffect((()=>(t(Ke()),()=>{t(Ke())})),[t]);const y=r.useRef(!1);r.useEffect((()=>{y.current||o==null||o===""||l.customerId!==""||(y.current=!0,t(vn({...l,customerId:o})))}),[o,l,t]),r.useEffect((()=>{a&&t(Wt({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=S!=null?`/${n}/invoicing/invoices/${encodeURIComponent(S)}`:`/${n}/invoicing/invoices`;e(A)}}),[u,S,e,n]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCreateInvoicePage,isReady:h}),E?c.jsx(ot,{}):c.jsx(Vo,{navigate:e,tenantEmailDomain:n})]})}const qo=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(d.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(ct);function Qo(){const t=L(),e=_(),{credit_note_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=R(),o=k((u=>Xt(u,n??""))),s=o.fetchState==="Completed";return r.useEffect((()=>{a&&n!=null&&t(Zt({id:n}))}),[a,n,t]),N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCreditDetailPage,isReady:s}),c.jsx(qo,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:o})]})}const zo=O((function(t){const e=mn(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(d.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"credits",status:e.activeStatus}),t(ni({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(st);function Ko(){const t=L(),e=_(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,creditNoteListFetchState:h}=k((D=>{const b=mn(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,creditNoteListFetchState:b.fetchState}}),q),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(Ge({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Ge({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:d.Event.invoicingCreditsListPage,isReady:y}),c.jsx(zo,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:l,filters:m,sort:v,nextCursor:E,onSearchChange:o,onStatusChange:D=>t(ei(D)),onSortChange:S})]})}const Hn=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},Go=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(Ae({id:i,localData:a}))},onCreateInvoice:()=>{g.trackInvoicingActionClick(d.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onCreatePromotionalCredits:()=>{g.trackInvoicingActionClick(d.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customer_detail"}),e.onCreatePromotionalCredits()},onNewSubscription:()=>{g.trackInvoicingActionClick(d.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`)},onDiscardEdit:()=>{t(fe(ue)),t(ri({id:i}))},onOpenAddress:()=>{const a=Hn(e.tenantEmailDomain??"",ue,i),o=X(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:a=>{g.trackInvoicingActionClick(d.Event.invoicingCustomerEdited,{customerId:i}),t(Ae({id:i,localData:a})),t(Sn({id:i}))},onFetchPaymentLinkEmailPreview:a=>t(si({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,s)=>{g.trackInvoicingActionClick(d.Event.invoicingPaymentLinkSent,{customerId:i,fromScreen:"customer_detail"}),t(ci({body:s,customerId:i,email:a,subject:o}))},onSubscriptionClick:a=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)}}}))(lt);function Wo(){const t=L(),e=_(),n=Y(),{customer_id:i,tenantEmailDomain:a}=$(),{areTenantIdsInSync:o}=R(),s=k((T=>$e(T,i))),u=s.pageFetchState.fetchState,l=u==="Completed"&&!s.isFormLoading,[S,v]=r.useState(!1),[m,p]=r.useState(!1),[f,I]=r.useState(l?i:void 0);r.useEffect((()=>{i!=null&&l&&I(i)}),[i,l]);const E=f===i,{plaidTokenFetchState:h,promotionalCreditSubmitState:y}=s,{paymentMethodSaveState:D,setupIntentFetchState:b,stripeConnected:A}=s.record,C=r.useRef(s.record.sendLinkState.fetchState);r.useEffect((()=>{const T=s.record.sendLinkState.fetchState;C.current!=="Error"&&T==="Error"&&t(Fe({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),C.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(te()),t(ie()),()=>{t(te()),t(ie())})),[t]),r.useEffect((()=>{n.state?.openPromotionalCreditsDialog===!0&&(p(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{o&&i!=null&&t(ti({id:i}))}),[o,i,t]),r.useEffect((()=>{o&&i!=null&&A&&t(We({customerId:i}))}),[o,i,t,A]);const F=r.useCallback((T=>t(pn({id:T}))),[t]),U=Z(s.fetchState,s.isFormLoading,i,F);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCustomerDetailPage,isReady:l}),c.jsx(Go,{customerId:i??"",editView:s,hasLoadedRecord:E,location:n,navigate:e,tenantEmailDomain:a,onAddPaymentMethod:()=>{g.trackInvoicingActionClick(d.Event.invoicingPaymentMethodAddClicked,{customerId:i??"",fromScreen:"customer_detail"}),t(te()),i!=null&&A&&t(We({customerId:i})),v(!0)},onCreatePromotionalCredits:()=>{t(ie()),p(!0)}},U),c.jsx(rt,{errorMessage:j,isCreatingSetupIntent:b.fetchState==="In-Progress",isSaving:D.fetchState==="In-Progress",open:S,plaidLinkToken:s.record.plaidLinkToken,saveSucceeded:D.fetchState==="Completed",setupIntent:s.record.setupIntent,stripeConnected:A,onChooseCard:()=>{i!=null&&t(oi({customerId:i}))},onClose:()=>{v(!1),t(te())},onSavePaymentMethod:T=>{i!=null&&(g.trackInvoicingActionClick(d.Event.invoicingPaymentMethodSaved,{customerId:i,fromScreen:"customer_detail"}),t(ii({customerId:i,data:T})))}}),c.jsx(dt,{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:()=>{p(!1),t(ie())},onSubmit:({amount:T,description:ne})=>{i!=null&&(g.trackInvoicingActionClick(d.Event.invoicingPromotionalCreditsAdded,{amount:T,customerId:i,fromScreen:"customer_detail"}),t(ai({amount:T,customerId:i,currencyCode:s.record.invoicingCustomer?.preferredCurrencyCode,description:ne})))}})]})}const Jo=O((function(t,e){const n=$e(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}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,a=i!=null?"edit":"create",o=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>e.navigate(o),onCancel:()=>{g.trackInvoicingActionClick(d.Event.invoicingCustomerFormCancelled),t(fn({id:i})),t(fe(ue)),e.navigate(`${n}/customers`)},onChange:s=>{t(Ae({id:i,localData:s}))},onOpenAddress:()=>{g.trackInvoicingActionClick(d.Event.invoicingAddressOpened,{entity:"customer",fromScreen:"customer_form"});const s=Hn(e.tenantEmailDomain??"",ue,i),u=X(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(s,{state:{pathnameStackToGoBack:u}})},onSubmit:()=>{g.trackInvoicingActionClick(d.Event.invoicingCustomerSaved,{mode:a}),t(Sn({id:i}))}}}))(ut);function Yo(){const t=L(),e=_(),n=Y(),{customer_id:i,tenantEmailDomain:a}=$(),{areTenantIdsInSync:o}=R(),{fetchState:s,savedCustomerId:u}=k((l=>$e(l,i)));return r.useEffect((()=>{o&&i!=null&&t(pn({id:i}))}),[o,i,t]),r.useEffect((()=>{if(s==="Completed"){const l=u??i,S=l!=null?`/${a}/invoicing/customers/${encodeURIComponent(l)}`:`/${a}/invoicing/customers`;e(S),t(fn({id:i}))}}),[s,u,i,t,e,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCustomerFormPage}),c.jsx(Jo,{customerId:i,location:n,navigate:e,tenantEmailDomain:a})]})}const Xo=O((function(t){const e=Se(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(d.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,a)=>{switch(a){case"createInvoice":g.trackInvoicingActionClick(d.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":g.trackInvoicingActionClick(d.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":g.trackInvoicingActionClick(d.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"customers",status:e.activeStatus}),t(In({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(gt);function Zo(){const t=L(),e=_(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,customerListFetchState:h}=k((D=>{const b=Se(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,customerListFetchState:b.fetchState}}),q),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[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:d.Event.invoicingCustomersListPage,isReady:y}),c.jsx(Xo,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:l,filters:m,sort:v,nextCursor:E,onSearchChange:o,onStatusChange:D=>t(di(D)),onSortChange:S})]})}const Le=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),ea=O((function(t,e){const{authParams:n,csvDownloadUrl:i,filters:a,sessionId:o,view:s}=e,u=o==null?void 0:s.diagnosticsBySession[o],l=u?.fetch.fetchState??"Not-Started";return{authParams:n,csvDownloadUrl:i,diagnostics:u?.items??[],errorMessage:l==="Error"?u?.fetch.error?.message:void 0,expired:u?.expired??!1,filters:a,hasMore:u?.nextCursor!=null,isLoading:l==="Not-Started"||l==="In-Progress",isLoadingMore:l==="In-Progress"&&(u?.items.length??0)>0,session:Le(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],l=Le(s,a),S=s.actionStateByKind.retry?.fetchState==="In-Progress",v=s.actionStateByKind.rollback?.fetchState==="In-Progress",m=l?.status==="done"&&l.rollback_available_until!=null&&new Date(l.rollback_available_until).getTime()>Date.now()&&!v;return{onBack:()=>i(`/${o}/invoicing/data_import`),onDownloadCsv:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"download_csv",fromScreen:"data_import_detail",sessionId:a})},onDownloadError:()=>{t(Fe({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{a!=null&&u?.nextCursor!=null&&t(je({...n,cursor:u.nextCursor,sessionId:a}))},onRetry:l?.status!=="failed"||S?void 0:()=>{a!=null&&(g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_detail",sessionId:a}),t(Te(a)))},onRollback:m?()=>{a!=null&&(g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"rollback",fromScreen:"data_import_detail",sessionId:a}),t(hn(a)))}:void 0}}))(vt);function na(){const t=L(),e=_(),{sessionId:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=R(),[o,s]=r.useState({}),u=k(Re),l=k(Ie),S=r.useMemo((()=>{const E=W.getSignedInUser();return{userId:E?.userId??"",sessionId:E?.zeniSessionId??"",tenantId:l.tenantId}}),[l.tenantId]),v=Le(u,n),m=n==null?void 0:u.diagnosticsBySession[n];r.useEffect((()=>{a&&n!=null&&t(De(n))}),[a,t,n]),r.useEffect((()=>{if(!a||n==null)return;const E=setTimeout((()=>{t(je({...o,sessionId:n}))}),300);return()=>clearTimeout(E)}),[a,t,o,n]);const p=v?.status==="scanning"||v?.status==="importing";r.useEffect((()=>{if(!a||n==null||!p)return;const E=setInterval((()=>{t(De(n)),t(je({...o,sessionId:n}))}),3e3);return()=>clearInterval(E)}),[a,t,o,p,n]);const f=r.useMemo((()=>{if(n==null)return"";const E=new URLSearchParams;o.moduleId!=null&&E.set("module_id",o.moduleId),o.level!=null&&E.set("level",o.level),o.outcome!=null&&E.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&E.set("search",o.search.trim());const h=E.toString();return`${se?.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:d.Event.invoicingDataImportDetailPage,isReady:v!=null&&I!=="Not-Started"}),c.jsx(ea,{authParams:S,csvDownloadUrl:f,filters:o,navigate:e,sessionId:n,tenantEmailDomain:i,view:u,onFiltersChange:s})]})}const qn=t=>`invoicing_active_migration:${t}`,ce=(t,e)=>{if(t!=null&&t!=="")try{const n=qn(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},ta=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(ae(s)),ce(i,s),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),a(o)},onNewImport:()=>{g.trackInvoicingActionClick(d.Event.invoicingNewImportClicked),a()},onRetrySession:o=>{g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),t(Te(o)),a(o)},onRollbackSession:o=>{g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),t(hn(o))},onViewSession:o=>{g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),n(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(mt);function ia(){const t=L(),e=_(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=R(),a=k(Re);r.useEffect((()=>{i&&(t(li()),t(Cn()))}),[i,t]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingDataImportHubPage,isReady:o}),c.jsx(ta,{navigate:e,tenantEmailDomain:n,view:a})]})}const oa=O((function(t,e){const{activeId:n,authParams:i,integrationsView:a,settings:o,templatesDownloadUrl:s,view:u}=e,{actionStateByKind:l,sessionDetail:S,sessions:v}=u,m=a.externalConnections?.revenue?.find((f=>f.connectionName==="chargebee")),p=n!=null?S[n]:void 0;return{authParams:i,templatesDownloadUrl:s,chargebeeConnected:o?.chargebee_connected===!0||(m?.isValid??!1),chargebeeConnectorAvailable:m!=null,chargebeeSite:o?.chargebee_site,connectError:l.connect?.error?.message,connecting:l.connect?.fetchState==="In-Progress",retrying:l.retry?.fetchState==="In-Progress",session:p??v.find((f=>f.id===n)),starting:l.start?.fetchState==="In-Progress",uploading:l.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:a}=e;return{onBack:e.onBack,onDownloadError:()=>{t(Fe({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onDownloadTemplates:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportTemplatesDownloaded)},onFetchFromChargebee:()=>{g.trackInvoicingActionClick(d.Event.invoicingChargebeeConnectClicked),t(vi())},onGoToIntegrations:()=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"settings_integrations"}),i(`/${a}/invoicing/settings`)},onGoToOverview:()=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"overview"}),i(`/${a}/invoicing/overview`)},onRetry:()=>{n!=null&&(g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_migrate",sessionId:n}),t(Te(n)))},onSaveLater:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportStarted),n!=null&&t(gi(n))},onUpload:o=>{g.trackInvoicingActionClick(d.Event.invoicingImportFileUploaded),t(ui({files:o}))},onViewDetails:n==null?void 0:()=>i(`/${a}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(pt);function aa(){const t=L(),e=_(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=R(),a=k(gn),o=k(Ie),s=r.useMemo((()=>{const h=W.getSignedInUser();return{userId:h?.userId??"",sessionId:h?.zeniSessionId??"",tenantId:o.tenantId}}),[o.tenantId]),u=`${se?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/templates`,l=o.companyId??W.getSignedInUserTenant(n??"")?.companyId,S=k((h=>kn(h,l))),v=k(Re),{activeMigrationSessionId:m}=v,p=m??void 0,f=p!=null?v.sessionDetail[p]??v.sessions.find((h=>h.id===p)):void 0;r.useEffect((()=>{i&&(t(Oe()),t(Cn()))}),[i,t]),r.useEffect((()=>{if(m!=null)return;const h=(y=>{if(y==null||y==="")return null;try{return sessionStorage.getItem(qn(y))}catch{return null}})(n);h!=null&&t(ae(h))}),[m,t,n]),r.useEffect((()=>{ce(n,m)}),[m,n]);const I=f?.status,E=I==="scanning"||I==="importing";return r.useEffect((()=>{if(!i||p==null||!E)return;const h=setInterval((()=>{t(De(p))}),3e3);return()=>clearInterval(h)}),[i,p,E,t]),r.useEffect((()=>{I==="done"&&(t(ae(null)),ce(n,null))}),[t,I,n]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingDataImportMigratePage}),c.jsx(oa,{activeId:p,authParams:s,integrationsView:S,navigate:e,settings:a,templatesDownloadUrl:u,tenantEmailDomain:n,view:v,onBack:()=>{t(ae(null)),ce(n,null),e(`/${n}/invoicing/data_import`)}})]})}const ca=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(d.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discount_detail",status:e.editView.coupon?.status}),t(En({action:a,id:i}))},onSaveEdit:a=>{g.trackInvoicingActionClick(d.Event.invoicingCouponEdited,{couponId:i}),t(pi({data:a,id:i}))}}}))(St);function sa(){const t=L(),e=_(),{coupon_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=R(),o=k((I=>mi(I,n))),s=o.actionState.fetchState==="In-Progress",u=o.pageFetchState.fetchState,l=u==="Completed",[S,v]=r.useState(l?n:void 0);r.useEffect((()=>{n!=null&&l&&v(n)}),[n,l]);const m=S===n;r.useEffect((()=>(t(le({id:n})),()=>{t(le({id:n}))})),[n,t]),r.useEffect((()=>{a&&t(xe({id:n}))}),[a,n,t]);const p=r.useCallback((I=>t(xe({cacheOverride:!0,id:I}))),[t]),f=Z(o.fetchState,o.isFormLoading,n,p);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingDiscountDetailPage,isReady:l}),c.jsx(ca,{hasLoadedRecord:m,couponId:n??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:s,navigate:e,tenantEmailDomain:i},f)]})}const ra=O((function(t){const e=yn(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(d.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{g.trackInvoicingActionClick(d.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,a)=>{g.trackInvoicingActionClick(d.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discounts_list"}),t(En({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"discounts",status:e.activeStatus}),t(fi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(ft);function da(){const t=L(),e=_(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,couponListFetchState:h,runningDiscountActionId:y}=k((b=>{const A=yn(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,couponListFetchState:A.fetchState,runningDiscountActionId:A.runningActionId??null}}),q),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(Ye({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Ye({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:d.Event.invoicingDiscountsListPage,isReady:D}),c.jsx(ra,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:l,filters:m,sort:v,nextCursor:E,runningDiscountActionId:y,onSearchChange:o,onStatusChange:b=>t(Si(b)),onSortChange:S})]})}const la=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"}}),(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(d.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:u,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(u)}`)},onCancel:a?()=>{g.trackInvoicingActionClick(d.Event.invoicingDunningAction,{...s,action:"cancel",fromScreen:"dunning_detail"}),t(Q({action:"cancel",id:i}))}:void 0,onResolve:a?()=>{g.trackInvoicingActionClick(d.Event.invoicingDunningAction,{...s,action:"resolve",fromScreen:"dunning_detail"}),t(Q({action:"resolve",id:i}))}:void 0,onResume:a?()=>{g.trackInvoicingActionClick(d.Event.invoicingDunningAction,{...s,action:"resume",fromScreen:"dunning_detail"}),t(Q({action:"resume",id:i}))}:void 0,onRetry:a?()=>{g.trackInvoicingActionClick(d.Event.invoicingDunningAction,{...s,action:"retry",fromScreen:"dunning_detail"}),t(Q({action:"retry",id:i}))}:void 0}}))(ht);function ua(){const t=L(),e=_(),{case_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=R(),o=k((C=>Ii(C,n??""))),s=o.fetchState==="Completed",u=o.dunningCase?.invoiceID,[l,S]=r.useState("idle"),[v,m]=r.useState(!1),[p,f]=r.useState(),[I,E]=r.useState(!1),h=r.useCallback((()=>{S("idle"),m(!1),f(void 0),E(!1)}),[]),y=r.useCallback((()=>{if(n==null)return;t(hi({id:n})),S("idle"),m(!1);const C=o.emailPreview.preview;f(C==null?void 0:{body:C.body,cc:C.cc,subject:C.subject,to:C.to}),E(!0)}),[n,t,o.emailPreview.preview]),D=r.useCallback((C=>{n!=null&&l!=="pending"&&(m(!1),S("pending"),g.trackInvoicingActionClick(d.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(Q({action:"send-email",body:C,id:n})))}),[n,t,l,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(Ci({id:n}))}),[a,n,t]),r.useEffect((()=>{a&&u!=null&&t(he({invoiceId:u}))}),[a,u,t]),r.useEffect((()=>{S("idle"),m(!1),f(void 0),E(!1)}),[n]),r.useEffect((()=>{a||(S("idle"),m(!1),f(void 0),E(!1))}),[a]),r.useEffect((()=>{I&&p==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,p,I]),r.useEffect((()=>{l==="pending"&&(o.actionState.fetchState!=="In-Progress"?v&&o.actionState.fetchState==="Completed"?(n!=null&&t(ki({id:n})),h()):v&&o.actionState.fetchState==="Error"&&S("failed"):m(!0))}),[n,h,t,l,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:d.Event.invoicingDunningDetailPage,isReady:s}),c.jsx(la,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:o,dunningAttempts:A,onSendEmail:y}),c.jsx(It,{initialDraft:p,isPreviewLoading:o.emailPreview.fetchState==="Not-Started"||o.emailPreview.fetchState==="In-Progress",isSending:l==="pending",onClose:h,onSend:D,open:I,preview:b,previewErrorMessage:o.emailPreview.fetchState==="Error"?o.emailPreview.error?.message:void 0,sendErrorMessage:l==="failed"?o.actionState.error?.message:void 0})]})}const ga=O((function(t){const e=bn(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,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(d.Event.invoicingDunningCaseRowClicked,i(a)),e.navigate(`${n}/dunning/${encodeURIComponent(a)}`)},onRowAction:(a,o)=>{o!=="retry"&&o!=="resume"&&o!=="resolve"&&o!=="cancel"||(g.trackInvoicingActionClick(d.Event.invoicingDunningAction,{...i(a),action:o}),t(Q({action:o,id:a})))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"dunning",status:e.activeStatus}),t(yi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Ct);function va(){const t=L(),e=_(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,dunningCaseListFetchState:h,dunningCases:y}=k((b=>{const A=bn(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,dunningCaseListFetchState:A.fetchState,dunningCases:A.dunningCases}}),q),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[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:d.Event.invoicingDunningListPage,isReady:D}),c.jsx(ga,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:l,filters:m,sort:v,dunningCases:y,nextCursor:E,onSearchChange:o,onStatusChange:b=>t(Ei(b)),onSortChange:S})]})}const ma=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(d.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(s)}`)},onIssueCreditNote:()=>{g.trackInvoicingActionClick(d.Event.invoicingIssueCreditNoteClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{g.trackInvoicingActionClick(d.Event.invoicingRecordPaymentClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{g.trackInvoicingActionClick(d.Event.invoicingInvoiceRegenerated,{...o,fromScreen:"invoice_detail"}),t(H({action:"regenerate",invoiceId:i}))},onSaveEdit:s=>{g.trackInvoicingActionClick(d.Event.invoicingInvoiceEdited,{...o,fromScreen:"invoice_detail"}),t(xi({data:{due_date:s.due_date!==""?s.due_date:void 0,notes:s.notes.trim()!==""?s.notes.split(`
2
+ `).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(d.Event.invoicingInvoiceReminderSent,{...o,fromScreen:"invoice_detail"}),t(H({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:s=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:s,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(s)}`)},onVoid:s=>{g.trackInvoicingActionClick(d.Event.invoicingInvoiceVoided,{...o,fromScreen:"invoice_detail"}),t(H({action:"void",invoiceId:i,body:s}))}}}))(kt);function pa(){const t=L(),e=_(),{invoice_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=R(),o=k((f=>xn(f,n??""))),s=o.pageFetchState.fetchState,u=s==="Completed",[l,S]=r.useState(u?n:void 0);r.useEffect((()=>{n!=null&&u&&S(n)}),[n,u]);const v=l===n;r.useEffect((()=>{a&&n!=null&&t(bi({invoiceId:n}))}),[a,n,t]);const m=r.useCallback((f=>t(he({invoiceId:f}))),[t]),p=Z(o.actionState.fetchState,o.fetchState==="In-Progress",n,m);return N(s)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingInvoiceDetailPage,isReady:u}),c.jsx(ma,{invoiceId:n??"",hasLoadedRecord:v,navigate:e,tenantEmailDomain:i,view:o},p)]})}const Sa=O((function(t){const e=An(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(d.Event.invoicingCreateInvoiceClicked),e.navigate(`${n}/invoices/create`)},onImportCsv:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportCsvClicked,{entity:"invoices"}),e.navigate(`${n}/data_import`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(d.Event.invoicingInvoiceRowClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onRowAction:(a,o)=>{switch(o){case"recordPayment":g.trackInvoicingActionClick(d.Event.invoicingRecordPaymentClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}/record-payment`);break;case"issueCreditNote":g.trackInvoicingActionClick(d.Event.invoicingIssueCreditNoteClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}/issue-credit-note`);break;case"sendReminder":g.trackInvoicingActionClick(d.Event.invoicingInvoiceReminderSent,i(a)),t(H({action:"send-reminder",invoiceId:a}));break;case"regenerate":g.trackInvoicingActionClick(d.Event.invoicingInvoiceRegenerated,i(a)),t(H({action:"regenerate",invoiceId:a}));break;case"void":g.trackInvoicingActionClick(d.Event.invoicingInvoiceVoided,i(a)),t(H({action:"void",invoiceId:a}))}},onVoidInvoice:(a,o)=>{g.trackInvoicingActionClick(d.Event.invoicingInvoiceVoided,i(a)),t(H({action:"void",invoiceId:a,body:o}))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"invoices",status:e.activeStatus}),t(Dn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Et);function fa(){const t=L(),e=_(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,invoiceListFetchState:h,voidingInvoiceId:y,invoices:D}=k((A=>{const C=An(A);return{activeStatus:C.activeTab,appliedSearch:C.filters.search,appliedSort:A.invoicingInvoiceListState.sort,nextCursor:C.nextCursor,invoiceListFetchState:C.fetchState,voidingInvoiceId:C.runningActionId,invoices:C.invoices}}),q),b=h==="Completed";return r.useEffect((()=>{const A=setTimeout((()=>u(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&t(Ee({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Ee({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:d.Event.invoicingInvoicesListPage,isReady:b}),c.jsx(Sa,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:l,filters:m,sort:v,invoices:D,nextCursor:E,voidingInvoiceId:y,onSearchChange:o,onStatusChange:A=>{t(Ai(A)),t(Ee({cacheOverride:!1,filters:m,sort:v}))},onSortChange:S})]})}function on(){const t=L(),e=_(),{tenantEmailDomain:n}=$(),i=yt(),a=rn(),[o,s]=r.useState(!1),{acceptTermsState:u,status:l}=k(jn),S=Di(i?.loggedInUserRoleMap),v=`/${n}/invoicing`,m=p=>{s(p)};return l==="completed"?c.jsx(V,{to:`${v}/overview`,replace:!0}):l==="settings"&&S?c.jsx(V,{to:`${v}/settings`,replace:!0}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingPromoPage}),c.jsx(jo,{isAppContentDrawerOpen:o,handleDrawerToggle:m}),c.jsx(bt,{analytics:g,isAccepting:u.fetchState==="In-Progress",isReadOnlyUser:!S,meetingUrl:a("invoicing_promo"),onAcceptClick:()=>{g.trackInvoicingActionClick(d.Event.invoicingTermsAccepted),t(ji())},onBackClick:()=>{e(`/${n}`)},onClickMenuIcon:()=>{m(!0)}})]})}const Ia=O((function(t,e){const n=Ln(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($i({localData:a}))},onSubmit:()=>{g.trackInvoicingActionClick(d.Event.invoicingCreditNoteIssued,{invoiceId:e.invoiceId}),t(wi())}}}))(xt);function ha(){const t=L(),e=_(),{invoice_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=R(),{fetchState:o,invoice:s,isPageReady:u,issuedCreditNoteId:l,submitState:S}=k((f=>Ln(f,n??""))),v=`/${i}/invoicing`,m=r.useRef(null);r.useEffect((()=>{t(Li()),m.current=null}),[t,n]),r.useEffect((()=>{a&&n!=null&&t(he({invoiceId:n}))}),[a,t,n]),r.useEffect((()=>{s!=null&&n!=null&&o==="Completed"&&m.current!==n&&(m.current=n,t(_i({localData:Pi(s)})))}),[t,o,s,n]);const p=r.useRef(S.fetchState);return r.useEffect((()=>{const f=p.current;p.current=S.fetchState,f!=="Completed"&&S.fetchState==="Completed"&&l!=null&&e(`${v}/credits/${encodeURIComponent(l)}`)}),[l,e,S.fetchState,v]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingIssueCreditNotePage,isReady:u}),c.jsx(Ia,{invoiceId:n??"",navigate:e,tenantEmailDomain:i})]})}const Ca=O((function(t){return{invoicingOverview:_n(t)}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onRefresh:()=>{g.trackInvoicingActionClick(d.Event.invoicingOverviewRefreshed),t(Pn(e.selectedPeriod,!0))},onSubscriptionClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingSubscriptionTileClicked,{subscriptionId:i}),e.navigate(`${n}/subscriptions/${i}`)},onViewInvoices:()=>{g.trackInvoicingActionClick(d.Event.invoicingViewInvoicesClicked),e.navigate(`${n}/invoices`)},onViewPayments:()=>{g.trackInvoicingActionClick(d.Event.invoicingViewPaymentsClicked),e.navigate(`${n}/payments`)}}}))(At);function ka(){const t=L(),e=_(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=R(),[a]=r.useState((()=>{const s=new Date;return{month:s.getMonth()+1,year:s.getFullYear()}})),o=k((s=>_n(s).fetchState))==="Completed";return r.useEffect((()=>{i&&t(Pn(a))}),[i,t,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingOverviewPage,isReady:o}),c.jsx(Ca,{navigate:e,selectedPeriod:a,tenantEmailDomain:n})]})}const Ea=O((function(t){const e=wn(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(d.Event.invoicingImportCsvClicked,{entity:"payments"}),e.navigate(`${n}/data_import`)},onTransactionClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingPaymentRowClicked,{transactionId:i}),e.navigate(`${n}/payments/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"payments",tab:e.activeType}),t(Ri({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Dt);function ya(){const t=L(),e=_(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeType:p,appliedSearch:f,appliedSort:I,nextCursor:E,transactionListFetchState:h,transactions:y}=k((j=>{const F=wn(j);return{activeType:F.activeTab,appliedSearch:F.filters.search,appliedSort:F.sort,nextCursor:F.nextCursor,transactionListFetchState:F.fetchState,transactions:F.transactions}}),q),D=h==="Completed",b=`/${n}/invoicing`,A=r.useCallback((j=>{const F=y.find((T=>T.id===j)),U=F?.linkedInvoices?.[0]?.invoiceID??F?.invoiceID;U!=null&&(g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"payments_list",invoiceId:U,toScreen:"invoice"}),e(`${b}/invoices/${encodeURIComponent(U)}`))}),[e,b,y]),C=r.useCallback((j=>{const F=y.find((U=>U.id===j))?.customerID;F!=null&&(g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{customerId:F,fromScreen:"payments_list",toScreen:"customer"}),e(`${b}/customers/${encodeURIComponent(F)}`))}),[e,b,y]);return r.useEffect((()=>{const j=setTimeout((()=>u(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t(ye({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(ye({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:d.Event.invoicingPaymentsListPage,isReady:D}),c.jsx(Ea,{navigate:e,tenantEmailDomain:n,activeType:p,searchValue:a,sortState:l,filters:m,sort:v,nextCursor:E,onSearchChange:o,onTypeChange:j=>{t(Fi(j)),t(ye({cacheOverride:!1,filters:m,sort:v}))},onSortChange:S,onViewTransactionCustomer:C,onViewTransactionInvoice:A})]})}const ba=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 an(){const t=L(),e=_(),{invoice_id:n,tenantEmailDomain:i}=$(),{areTenantIdsInSync:a}=R(),o=n!=null&&n!=="",s=k(Se),u=k((C=>Ti(C))),l=k(Oi),S=k((C=>xn(C,n??""))),v=S.invoice,m=`/${i}/invoicing`,p=r.useRef(null),f=r.useRef("");r.useEffect((()=>{t(Mi()),p.current=null,f.current=""}),[t,n]),r.useEffect((()=>{a&&t(o&&n!=null?he({invoiceId:n}):In({filters:{},keepExistingListItems:!1}))}),[a,t,n,o]),r.useEffect((()=>{o&&v!=null&&n!=null&&S.fetchState==="Completed"&&p.current!==n&&(p.current=n,t(Ni({contextInvoiceId:n,localData:Ui(v)})))}),[t,v,n,S.fetchState,o]),r.useEffect((()=>{if(o)return;const C=u.localData.customerId;C!==""&&C!==f.current&&(f.current=C,t(Dn({filters:{customerId:C},keepExistingListItems:!1})),u.localData.invoiceToLink!==""&&t(Ze({localData:{...u.localData,customerId:C,invoiceToLink:""}})))}),[t,u.localData,o]);const I=r.useRef(l.fetchState);r.useEffect((()=>{const C=I.current;if(I.current=l.fetchState,C!=="Completed"&&l.fetchState==="Completed"){if(l.recordedInvoiceId!=null)return void e(`${m}/invoices/${encodeURIComponent(l.recordedInvoiceId)}`);e(`${m}/payments`)}}),[e,l.fetchState,l.recordedInvoiceId,m]);const E=r.useMemo((()=>s.customers.map((C=>({id:C.id,name:ba(C)})))),[s.customers]),h=k((C=>Bi(C,u.localData.customerId))),y=r.useMemo((()=>h.map((C=>{return{amountDue:(j=C.amountDue,F=Vi.currencySymbol,_t("0,0.00",j,F)),amountDueValue:C.amountDue,id:C.id,label:C.invoiceNumber};var j,F}))),[h]),D=r.useMemo((()=>{if(!o||v==null)return;const C=v.currencyCode??"USD",j=v.amountDue?.amount??0;return{amountDue:jt("0,0.00",v.amountDue),amountDueValue:j,currencyCode:C,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||S.fetchState==="Completed"&&u.localData.invoiceToLink!=="";return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingRecordPaymentPage,isReady:A}),c.jsx(Lt,{customers:E,fieldHelp:u.fieldHelp,errorMessage:l.fetchState==="Error"?l.error?.message??"Failed to record payment. Please try again.":void 0,gatewayOptions:u.gatewayOptions,invoiceContext:D,invoiceOptions:y,isSubmitting:l.fetchState==="In-Progress",localData:u.localData,mode:o?"invoice":"customer",paymentMethodOptions:u.paymentMethodOptions,onBack:()=>{e(b)},onCancel:()=>{g.trackInvoicingActionClick(d.Event.invoicingRecordPaymentCancelled),e(b)},onChange:C=>{t(Ze({localData:C}))},onSubmit:()=>{g.trackInvoicingActionClick(d.Event.invoicingPaymentRecorded,{customerId:u.localData.customerId,invoiceId:o?n:u.localData.invoiceToLink,paymentMethod:u.localData.paymentMethod}),t(Hi(o?n??void 0:void 0))}})]})}const Qn=(t,e,n)=>{const i=`/${t}/invoicing/subscriptions/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},xa=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,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:l}=e.editView;g.trackInvoicingActionClick(d.Event.invoicingSubscriptionLifecycleAction,{action:s,amount:l?.mrr?.amount,customerId:l?.customerID,fromScreen:"subscription_detail",status:l?.status,subscriptionId:i}),t(Fn({action:s,id:i,body:u}))};return{onBack:()=>e.navigate(`${n}/subscriptions`),onChange:s=>{t(ge({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(d.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${n}/customers/${encodeURIComponent(s)}`,"_blank","noopener,noreferrer")},onDiscardEdit:()=>{t(fe(ve)),t(zi({id:i}))},onOpenAddress:()=>{const s=Qn(e.tenantEmailDomain??"",ve,i),u=X(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(s,{state:{pathnameStackToGoBack:u}})},onViewInvoices:()=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"subscription_detail",subscriptionId:i,toScreen:"invoices"}),e.navigate(`${n}/invoices`)},onSaveEdit:s=>{g.trackInvoicingActionClick(d.Event.invoicingSubscriptionEdited,{subscriptionId:i}),t(ge({id:i,localData:s})),t($n({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}}))(Pt);function Aa(){const t=L(),e=_(),n=Y(),{subscription_id:i,tenantEmailDomain:a}=$(),{areTenantIdsInSync:o}=R(),s=k((y=>Me(y,i))),{subscriptionCommercialEditAllowedFromStatuses:u,subscriptionLifecycleActionOptions:l,subscriptionMetadataEditAllowedFromStatuses:S}=s,v=s.pageFetchState.fetchState,m=v==="Completed"&&!s.isFormLoading,[p,f]=r.useState(m?i:void 0);r.useEffect((()=>{i!=null&&m&&f(i)}),[i,m]);const I=p===i;Ce(o),r.useEffect((()=>{o&&i!=null&&t(qi({id:i}))}),[o,i,t]);const E=r.useCallback((y=>t(Qi({id:y}))),[t]),h=Z(s.fetchState,s.isFormLoading,i,E);return N(v)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingSubscriptionDetailPage,isReady:m}),c.jsx(xa,{hasLoadedRecord:I,commercialEditAllowedFromStatuses:u,editView:s,lifecycleActionOptions:l,location:n,metadataEditAllowedFromStatuses:S,navigate:e,subscriptionId:i??"",tenantEmailDomain:a},h)]})}const Da=O((function(t,e){const n=Me(t,e.subscriptionId);return{fieldHelp:n.fieldHelp,addons:n.addons,charges:n.charges,coupons:n.coupons,customers:n.customers,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,shippingAddressLabel:n.shippingAddressLabel}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,a=i!=null?"edit":"create";return{onCancel:()=>{g.trackInvoicingActionClick(d.Event.invoicingSubscriptionFormCancelled),t(Rn({id:i})),t(fe(ve)),i==null?e.navigate(`${n}/subscriptions`):e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)},onChange:o=>{t(ge({id:i,localData:o}))},onOpenAddress:()=>{g.trackInvoicingActionClick(d.Event.invoicingAddressOpened,{entity:"subscription",fromScreen:"subscription_form"});const o=Qn(e.tenantEmailDomain??"",ve,i),s=X(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(o,{state:{pathnameStackToGoBack:s}})},onSubmit:()=>{g.trackInvoicingActionClick(d.Event.invoicingSubscriptionSaved,{mode:a}),t($n({id:i}))}}}))(wt);function ja(){const t=L(),e=_(),n=Y(),{subscription_id:i,tenantEmailDomain:a}=$(),[o]=J(),{areTenantIdsInSync:s}=R(),u=o.get("customerId"),{fetchState:l,savedSubscriptionId:S}=k((p=>Ki(p,i))),v=k((p=>Me(p,i).localData));Ce(s),r.useEffect((()=>{s&&t(Gi({subscriptionId:i}))}),[s,i,t]);const m=r.useRef(!1);return r.useEffect((()=>{m.current||i!=null||u==null||u===""||v.customerId!==""||(m.current=!0,t(ge({id:i,localData:{...v,customerId:u}})))}),[u,i,v,t]),r.useEffect((()=>{if(l==="Completed"){const p=S??i,f=p!=null?`/${a}/invoicing/subscriptions/${encodeURIComponent(p)}`:`/${a}/invoicing/subscriptions`;e(f),t(Rn({id:i}))}}),[l,S,i,t,e,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingSubscriptionFormPage}),c.jsx(Da,{location:n,navigate:e,subscriptionId:i,tenantEmailDomain:a})]})}const La=O((function(t){const e=Tn(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((l=>l.id===a));g.trackInvoicingActionClick(d.Event.invoicingSubscriptionLifecycleAction,{action:o,amount:u?.mrr?.amount,customerId:u?.customerID,fromScreen:"subscriptions_list",status:u?.status,subscriptionId:a}),t(Fn({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(d.Event.invoicingAddSubscriptionClicked),e.navigate(`${n}/subscriptions/new`)},onImportCsv:()=>{g.trackInvoicingActionClick(d.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(d.Event.invoicingSubscriptionRowClicked,{subscriptionId:a}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onViewSubscriptionInvoices:()=>{e.navigate(`${n}/invoices`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"subscriptions",status:e.activeStatus}),t(Yi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))($t);function _a(){const t=L(),e=_(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,subscriptionListFetchState:h,runningActionSubscriptionId:y,subscriptions:D}=k((C=>{const j=Tn(C);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:j.sort,nextCursor:j.nextCursor,subscriptionListFetchState:j.fetchState,runningActionSubscriptionId:j.runningActionId??null,subscriptions:j.subscriptions}}),q),b=h==="Completed";r.useEffect((()=>{const C=setTimeout((()=>u(a)),300);return()=>clearTimeout(C)}),[a]),r.useEffect((()=>{i&&t(en({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(en({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]);const A=r.useRef(y);return r.useEffect((()=>{const C=A.current!=null&&y==null;A.current=y,C&&i&&t(Wi())}),[y,i,t]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingSubscriptionsListPage,isReady:b}),c.jsx(La,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:l,filters:m,sort:v,nextCursor:E,runningActionSubscriptionId:y,subscriptions:D,onSearchChange:o,onStatusChange:C=>t(Ji(C)),onSortChange:S})]})}const Pa=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(d.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"transaction_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(a)}`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onSubscriptionClick:a=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onCapture:i!==""?()=>{g.trackInvoicingActionClick(d.Event.invoicingTransactionCaptured,{transactionId:i}),t(eo({action:"capture",id:i}))}:void 0}}))(Ft);function wa(){const t=L(),e=_(),{tenantEmailDomain:n,transaction_id:i}=$(),{areTenantIdsInSync:a}=R(),o=k((u=>Xi(u,i??""))),s=o.fetchState==="Completed";return r.useEffect((()=>{a&&i!=null&&t(Zi({id:i}))}),[a,i,t]),N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingTransactionDetailPage,isReady:s}),c.jsx(Pa,{navigate:e,tenantEmailDomain:n,transactionId:i??"",readView:o})]})}function zn(t={}){const{enabled:e=!0,fetchSyncHealth:n=!1,loadAccountingPickers:i=!1,reuseCached:a=!1}=t,o=L(),{areTenantIdsInSync:s}=R(),u=k(Ne),l=u.connection?.connected===!0,S=u.connectionFetchState.fetchState;return r.useEffect((()=>{e&&s&&(a&&S!=="Not-Started"||o(On()),n&&o(no()))}),[s,o,e,n,a]),r.useEffect((()=>{e&&s&&l&&i&&o(to())}),[s,o,e,l,i]),{isQboConnected:l,qboView:u}}const $a={branding:"invoicing_branding_save",dunning:"invoicing_dunning_settings_save",quickbooks:"invoicing_qbo_settings_save"};function ee(t){const e=L(),{areTenantIdsInSync:n}=R(),{tenantEmailDomain:i}=$(),{fetchState:a,fieldHelp:o,logoFile:s,saveState:u,settings:l,stripeConnectState:S}=k(io),{configError:v,configFetchState:m,dunningScheduleActionOptions:p,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:I,qboSyncStatusOptions:E}=k(Mn),h=k(Ne);zn({enabled:t==="quickbooks",fetchSyncHealth:!0,loadAccountingPickers:!0});const y=k(Ie),D=t==="dunning"||t==="quickbooks",b=y.companyId??W.getSignedInUserTenant(i??"")?.companyId,A=k((P=>kn(P,b))),C=oo(y.userRole??[]),j=y.tenantId??"",F=W.getSignedInUser(),U={userId:F?.userId??"",sessionId:F?.zeniSessionId??"",tenantId:j},T=s?.fileId,ne=k((P=>T!=null&&T!==""?ao(P,T):void 0)),Ue=k((P=>T!=null&&T!==""?co(P,T):void 0)),Kn=T!=null&&T!==""&&ne!=null?{[T]:ne}:{},Gn=T!=null&&T!==""&&Ue!=null?{[T]:Ue}:{};r.useEffect((()=>(e(nn()),()=>{e(nn())})),[e]),r.useEffect((()=>{n&&(a!=="Not-Started"&&a!=="Error"||e(Oe()))}),[n,e,a]),r.useEffect((()=>{n&&D&&m==="Not-Started"&&e(me())}),[n,e,m,D]),r.useEffect((()=>{if(!n)return;const P=F?.userId;P!=null&&P!==""&&j!==""&&He.shouldFetchActiveTenant(j)&&(He.markActiveTenantFetchStarted(j),e(so(P,j,F?.zeniSessionId)))}),[n,e,F?.userId,F?.zeniSessionId,j]);const Wn=p.length>0||f.length>0,Jn=a==="Not-Started"||a==="In-Progress"&&l==null||D&&!Wn&&(m==="Not-Started"||m==="In-Progress"),Yn=a==="Completed"&&(!D||m==="Completed"),Be=A.externalConnections?.revenue?.find((P=>P.connectionName==="chargebee"))?.connectionId,ke=se?.invoicingMicroServiceBaseUrl,Ve=ke!=null&&ke.length>0?`${ke}/1.0/webhooks/stripe`:"",z={deleteConnectionError:A.externalConnections?.deleteConnectionError?.message,deleteConnectionState:A.externalConnections?.deleteConnectionState??"Not-Started",integrationsView:A,isAdmin:C,isStripeBusy:S.fetchState==="In-Progress",onConnectStripe:P=>{g.trackInvoicingActionClick(d.Event.invoicingStripeConnectClicked,{fromScreen:t??"hub"}),e(fo(P))},onDisconnect:(P,B)=>{j!==""&&(g.trackInvoicingActionClick(d.Event.invoicingIntegrationDisconnected,{entity:B,entityId:P,fromScreen:t??"hub"}),e(So(j,P,tn(B))))},onDisconnectStripe:()=>{g.trackInvoicingActionClick(d.Event.invoicingStripeDisconnected,{fromScreen:t??"hub"}),e(po())},onReconnectQBO:()=>{g.trackInvoicingActionClick(d.Event.invoicingQboAction,{action:"reconnect",fromScreen:t??"hub"});const P=y.tenantEmailDomain??i??"";pe.init("/connection/auth",P),pe.handleClick()},onRefreshQBO:()=>{A.integrations.refreshQBO.fetchState!=="In-Progress"&&(g.trackInvoicingActionClick(d.Event.invoicingQboAction,{action:"refresh",fromScreen:t??"hub"}),e(Bn()))},onSaveChargeBeeCredentials:(P,B)=>{Be!=null&&j!==""&&(g.trackInvoicingActionClick(d.Event.invoicingChargebeeCredentialsSaved,{fromScreen:t??"hub"}),e(vo(j,Be,tn("revenue"),mo("chargebee"),{api_key:P,site:B})))},saveChargeBeeError:A.externalConnections?.saveAPIKeyConnectionError?.message,saveChargeBeeState:A.externalConnections?.saveAPIKeyConnectionState??"Not-Started",settings:l,stripeError:S.fetchState==="Error"?S.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Ve};return{authParams:U,deleteFileStatusById:Kn,fieldHelp:o,dunningScheduleActionOptions:p,filesEndPoint:se?.fileMicroServiceBaseUrl??"",integrationsSectionProps:z,isInvoicingPageReady:Yn,isLoading:Jn,isSaving:u.fetchState==="In-Progress",isStripeBusy:S.fetchState==="In-Progress",logoFile:s,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:I,qboSyncStatusOptions:E,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:l,stripeError:S.fetchState==="Error"?S.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Ve,updateFileStatusById:Gn,onConnectStripe:z.onConnectStripe,onDeleteFile:P=>{g.trackInvoicingActionClick(d.Event.invoicingLogoRemoved,{fromScreen:t??"hub"}),e(go(P,j))},onDisconnectStripe:z.onDisconnectStripe,onEditFileName:(P,B)=>{g.trackInvoicingActionClick(d.Event.invoicingLogoRenamed,{fromScreen:t??"hub"}),e(uo(P,B.split(".")[0],j))},onReconnectQBO:z.onReconnectQBO,onRefreshQBO:z.onRefreshQBO,onRetryQboSyncTask:P=>{g.trackInvoicingActionClick(d.Event.invoicingQboAction,{action:"retry_task",entityId:P,fromScreen:t??"hub"}),e(Un(P))},onSave:P=>{g.trackInvoicingActionClick(d.Event.invoicingSettingsSaved,{fieldsChanged:Object.keys(P).filter((B=>JSON.stringify(P[B])!==JSON.stringify(l?.[B]))),tab:t??"hub"}),e(lo({settings:P,snackbarSection:$a[t??""]}))},onStartQboBackfill:P=>{g.trackInvoicingActionClick(d.Event.invoicingQboAction,{action:"backfill",fromScreen:t??"hub"}),e(Nn(P))},updateFilesEntity:P=>{g.trackInvoicingActionClick(d.Event.invoicingLogoUploaded,{fromScreen:t??"hub"}),e(ro({files:P}))}}}function cn({appContent:t}){const e=_(),n=Y(),i=L(),{tenantEmailDomain:a}=$(),o=ee("branding"),s=k((l=>Io(l)));r.useEffect((()=>{s.saveState.fetchState==="Completed"&&i(ho())}),[s.saveState.fetchState,i]);const u=_e(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:d.Event.invoicingBrandingSettingsPage,isReady:o.isInvoicingPageReady}),c.jsx(Rt,{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:l=>{i(Eo({localData:l}))},onDeleteFile:o.onDeleteFile,onEditFileName:o.onEditFileName,onOpenAddress:()=>{g.trackInvoicingActionClick(d.Event.invoicingAddressOpened,{entity:"branding",fromScreen:"settings_branding"});const l=`/${a}/invoicing/settings/branding/${ko}/`,S=X(n.state?.pathnameStackToGoBack,n.pathname);e(l,{state:{pathnameStackToGoBack:S}})},onSubmit:()=>{g.trackInvoicingActionClick(d.Event.invoicingSettingsSaved,{tab:"branding"}),i(Co())},updateFilesEntity:o.updateFilesEntity})]})}function Fa(){const t=_(),e=ee("dunning");return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingDunningSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(Tt,{dunningScheduleActionOptions:e.dunningScheduleActionOptions,isLoading:e.isLoading,isSaving:e.isSaving,saveErrorMessage:e.saveErrorMessage,settings:e.settings,onBackClick:()=>t(".."),onSave:e.onSave})]})}function Ra(){const t=_(),e=ee("integrations");return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingIntegrationsSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(Ot,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>t("../quickbooks"),onOpenPaymentDestination:()=>t("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>t("..")})]})}function Ta(){const t=_(),e=ee("payment-destination");return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingPaymentDestinationSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(Mt,{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 Oa=["autoCreateItems","closedPeriodVoidAsCreditMemo","customerMatching","isSyncEnabled","syncStartDate","trackingCategoriesEnabled"],Ma=O((function(t){const e=Vn(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,saveErrorMessage:e.saveState.fetchState==="Error"?e.saveState.error?.message:void 0,syncHealth:e.syncHealth,syncStatusOptions:e.syncStatusOptions}}),(function(t){return{onChange:e=>{t(xo({localData:e}))},onReset:()=>{g.trackInvoicingActionClick(d.Event.invoicingSettingsReset,{tab:"quickbooks"}),t(bo())},onRetryTask:e=>{g.trackInvoicingActionClick(d.Event.invoicingQboAction,{action:"retry_task",entityId:e,fromScreen:"settings_qbo"}),t(Un(e))},onStartBackfill:e=>{g.trackInvoicingActionClick(d.Event.invoicingQboAction,{action:"backfill",fromScreen:"settings_qbo"}),t(Nn(e))}}}))(Nt);function Na(){const t=L(),e=_(),{tenantEmailDomain:n}=$(),i=k(Ie),{configFetchState:a,localData:o,savedLocalData:s,saveState:u,settingsFetchState:l}=k(Vn),S=r.useMemo((()=>{return m=o,p=s,[...[...new Set([...Object.keys(m.accountIdByMappingCode),...Object.keys(p.accountIdByMappingCode)])].some((f=>(m.accountIdByMappingCode[f]??"")!==(p.accountIdByMappingCode[f]??"")))?["account_mappings"]:[],...Oa.filter((f=>m[f]!==p[f]))];var m,p}),[o,s]),v=_e(u.fetchState);return r.useEffect((()=>{v==="In-Progress"&&u.fetchState==="Completed"&&e("..")}),[e,v,u.fetchState]),r.useEffect((()=>{l!=="Not-Started"&&l!=="Error"||t(Oe())}),[t,l]),r.useEffect((()=>{a==="Not-Started"&&t(me())}),[a,t]),zn({fetchSyncHealth:!0,loadAccountingPickers:!0}),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingQboSettingsPage}),c.jsx(Ma,{onBackClick:()=>e(".."),onReconnect:()=>{g.trackInvoicingActionClick(d.Event.invoicingQboAction,{action:"reconnect",fromScreen:"settings_qbo"}),pe.init("/connection/auth",i.tenantEmailDomain??n??""),pe.handleClick()},onRefresh:()=>{g.trackInvoicingActionClick(d.Event.invoicingQboAction,{action:"refresh",fromScreen:"settings_qbo"}),t(Bn())},onSave:()=>{g.trackInvoicingActionClick(d.Event.invoicingSettingsSaved,{fieldsChanged:S,tab:"quickbooks"}),t(yo())}})]})}const Ua={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function Ba(){const t=rn(),e=L(),n=_(),[i,a]=J(),o=ee(),{canEnableInvoicing:s,isEnablingInvoicing:u,isInvoicingEnabled:l,isQboConfigured:S,isStripeConnected:v}=k(Mn),m=i.get("tab");return r.useEffect((()=>{if(m==null)return;const p=Ua[m];a({},{replace:!0}),p!=null&&n(p,{replace:!0})}),[m,n,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),c.jsx(Ut,{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:S,isStripePaymentsReady:v,onEnableInvoicingClick:l?void 0:()=>{g.trackInvoicingActionClick(d.Event.invoicingEnableClicked),e(Ao())}})]})}function sn(){return c.jsxs(oe,{children:[c.jsx(x,{index:!0,element:c.jsx(Ba,{})}),c.jsx(x,{path:"payment-destination",element:c.jsx(Ta,{})}),c.jsx(x,{path:"branding",element:c.jsx(cn,{})}),c.jsx(x,{path:"branding/:addressType",element:c.jsx(cn,{appContent:c.jsx(K,{isSubPage:!0,hideAddressBackButton:!0})})}),c.jsx(x,{path:"integrations",element:c.jsx(Ra,{})}),c.jsx(x,{path:"dunning",element:c.jsx(Fa,{})}),c.jsx(x,{path:"quickbooks",element:c.jsx(Na,{})}),c.jsx(x,{path:"*",element:c.jsx(V,{to:"..",replace:!0})})]})}function pc(){const t=L(),e=_(),{tenantEmailDomain:n}=$(),{areTenantIdsInSync:i}=R(),{enableState:a,fetchState:o,status:s}=k(jn),u=_e(a.fetchState),l=`/${n}/invoicing`,S=r.useRef(!1),v=k((m=>Ne(m).connectionFetchState.fetchState));return r.useEffect((()=>{i&&(o!=="Not-Started"?o!=="Error"||S.current||(S.current=!0,t(me({cacheOverride:!1}))):t(me({cacheOverride:!1})))}),[i,t,o]),r.useEffect((()=>{i&&v==="Not-Started"&&t(On())}),[i,t,v]),r.useEffect((()=>{u==="In-Progress"&&a.fetchState==="Completed"&&(e(`${l}/catalog`),t(Do()))}),[u,a.fetchState,l,t,e]),s==null&&o!=="Error"?c.jsx(Bt,{fetchState:"In-Progress"}):s==="not_started"?c.jsxs(oe,{children:[c.jsx(x,{path:"promo",element:c.jsx(on,{})}),c.jsx(x,{path:"*",element:c.jsx(V,{to:`${l}/promo`,replace:!0})})]}):s==="settings"?c.jsxs(oe,{children:[c.jsx(x,{path:"promo",element:c.jsx(on,{})}),c.jsx(x,{path:"settings/*",element:c.jsx(sn,{})}),c.jsx(x,{path:"*",element:c.jsx(V,{to:`${l}/settings`,replace:!0})})]}):c.jsxs(oe,{children:[c.jsx(x,{path:"/",element:c.jsx(V,{to:"overview",replace:!0})}),c.jsx(x,{path:"overview",element:c.jsx(ka,{})}),c.jsx(x,{path:"promo",element:c.jsx(V,{to:`${l}/overview`,replace:!0})}),c.jsx(x,{path:"customers",element:c.jsx(Zo,{})}),c.jsx(x,{path:"customers/new",element:c.jsx(Yo,{})}),c.jsx(x,{path:"customers/new/:addressType",element:c.jsx(K,{})}),c.jsx(x,{path:"customers/:customer_id",element:c.jsx(Wo,{})}),c.jsx(x,{path:"customers/:customer_id/:addressType",element:c.jsx(K,{})}),c.jsx(x,{path:"subscriptions",element:c.jsx(_a,{})}),c.jsx(x,{path:"subscriptions/new",element:c.jsx(ja,{})}),c.jsx(x,{path:"subscriptions/new/:addressType",element:c.jsx(K,{})}),c.jsx(x,{path:"subscriptions/:subscription_id",element:c.jsx(Aa,{})}),c.jsx(x,{path:"subscriptions/:subscription_id/:addressType",element:c.jsx(K,{})}),c.jsx(x,{path:"invoices",element:c.jsx(fa,{})}),c.jsx(x,{path:"invoices/create",element:c.jsx(Ho,{})}),c.jsx(x,{path:"invoices/:invoice_id",element:c.jsx(pa,{})}),c.jsx(x,{path:"invoices/:invoice_id/record-payment",element:c.jsx(an,{})}),c.jsx(x,{path:"invoices/:invoice_id/issue-credit-note",element:c.jsx(ha,{})}),c.jsx(x,{path:"payments",element:c.jsx(ya,{})}),c.jsx(x,{path:"payments/record",element:c.jsx(an,{})}),c.jsx(x,{path:"payments/:transaction_id",element:c.jsx(wa,{})}),c.jsx(x,{path:"credits",element:c.jsx(Ko,{})}),c.jsx(x,{path:"credits/:credit_note_id",element:c.jsx(Qo,{})}),c.jsx(x,{path:"discounts",element:c.jsx(da,{})}),c.jsx(x,{path:"discounts/new",element:c.jsx(Bo,{})}),c.jsx(x,{path:"discounts/:coupon_id",element:c.jsx(sa,{})}),c.jsx(x,{path:"dunning",element:c.jsx(va,{})}),c.jsx(x,{path:"dunning/:case_id",element:c.jsx(ua,{})}),c.jsx(x,{path:"catalog",element:c.jsx(No,{})}),c.jsx(x,{path:"catalog/new",element:c.jsx(To,{})}),c.jsx(x,{path:"catalog/:item_id",element:c.jsx(wo,{})}),c.jsx(x,{path:"settings/*",element:c.jsx(sn,{})}),c.jsx(x,{path:"audit_log",element:c.jsx(Lo,{})}),c.jsx(x,{path:"data_import",element:c.jsx(ia,{})}),c.jsx(x,{path:"data_import/migrate",element:c.jsx(aa,{})}),c.jsx(x,{path:"data_import/:sessionId",element:c.jsx(na,{})}),c.jsx(x,{path:"*",element:c.jsx(M,{})})]})}export{pc as default};