@zeniai/web-app-ui 5.3.93-qa → 5.3.94-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 (152) hide show
  1. package/dist/assets/AccountMappingScreen-DaAsvWlG.js +9 -0
  2. package/dist/assets/{ActualMatchingMatchDetailScreen-BuAecBJl.js → ActualMatchingMatchDetailScreen-DsOtbvkM.js} +1 -1
  3. package/dist/assets/AddressRoutes-DYRqLyFY.js +1 -0
  4. package/dist/assets/AddressScreen-C0JLhAcE.js +9 -0
  5. package/dist/assets/{AiCfoScreen-PdexPkiB.js → AiCfoScreen-BUHwXAf6.js} +2 -2
  6. package/dist/assets/{AppDrawer-D_pZzlzK.js → AppDrawer-vbC-QV57.js} +2 -2
  7. package/dist/assets/{BillPayApprovalRoutes-B0zQnc3l.js → BillPayApprovalRoutes-DzF0eyUE.js} +1 -1
  8. package/dist/assets/{BillPayRoutes-VIWjug-6.js → BillPayRoutes-Bi056p3z.js} +34 -34
  9. package/dist/assets/BusinessVerificationPageScreen-D1nbOYUs.js +9 -0
  10. package/dist/assets/{CardsAiCfoScreen-DmJ2Dapk.js → CardsAiCfoScreen-CfZl8Gyx.js} +2 -2
  11. package/dist/assets/{ChargeCardRoutes-Dffv4bgE.js → ChargeCardRoutes-S3N8oI1a.js} +7 -7
  12. package/dist/assets/{CompanyPassportScreen-CAlxZp4n.js → CompanyPassportScreen-Cb0WDItw.js} +1 -1
  13. package/dist/assets/ConnectionAuthScreen-DscrSY_4.js +11 -0
  14. package/dist/assets/CustomerOnboardingAuthScreen-DZSTKSts.js +1 -0
  15. package/dist/assets/{CustomerOnboardingRoutes-D8rEuaY_.js → CustomerOnboardingRoutes-Q5YqE-pG.js} +3 -3
  16. package/dist/assets/{DashboardRoutes-f7LYLg2v.js → DashboardRoutes-CHLUwZtv.js} +3 -3
  17. package/dist/assets/{DefaultTenantHome-C2oJ4Z_A.js → DefaultTenantHome-BSW3FKbq.js} +1 -1
  18. package/dist/assets/DomesticWireDetailScreen-BqNLFPCz.js +18 -0
  19. package/dist/assets/DrawerScreen-CjvLDWWa.js +1 -0
  20. package/dist/assets/EntityDetailRoutes-CiuhVFP6.js +1 -0
  21. package/dist/assets/ExpenseAutomationRoutes-yHkHWhCB.js +38 -0
  22. package/dist/assets/FeaturePreviewScreen-t6-81tB3.js +1 -0
  23. package/dist/assets/HubSpotOAuthCallbackScreen-6v8VBEj0.js +1 -0
  24. package/dist/assets/{InboxNotificationsProvider-BYzYM_cO.js → InboxNotificationsProvider--Aami2sh.js} +1 -1
  25. package/dist/assets/InvoicingRoutes-DYvbJYG6.js +3 -0
  26. package/dist/assets/{MagicLinkRoutes-BXcgUoFN.js → MagicLinkRoutes-C2OazRqD.js} +8 -8
  27. package/dist/assets/MagicLinkSignInScreen-Cn6GsNEp.js +12 -0
  28. package/dist/assets/MobileAppDrawer-CPwvCIYa.js +1 -0
  29. package/dist/assets/NotFoundScreen-BR0tBeJN.js +1 -0
  30. package/dist/assets/NotificationRoutes-aekj_lXX.js +1 -0
  31. package/dist/assets/OAuthConsentScreen-xUzU6tqX.js +1 -0
  32. package/dist/assets/PandLWithForecastRoutes-DbBbI4iD.js +1 -0
  33. package/dist/assets/{PaymentLinkScreen-DzxyNsJc.js → PaymentLinkScreen-wDbMp6EU.js} +9 -9
  34. package/dist/assets/PeopleRoutes-DLFd4iV8.js +22 -0
  35. package/dist/assets/PerformanceRoutes-DgAZpNgm.js +1 -0
  36. package/dist/assets/{Preview-Cu-MUKgE.js → Preview-9JjGFG_v.js} +1 -1
  37. package/dist/assets/{QBOConnectionScreen-pIPlV1os.js → QBOConnectionScreen-Dn2zy1VD.js} +1 -1
  38. package/dist/assets/ReimbursementApprovalRoutes-y4qFEQsq.js +1 -0
  39. package/dist/assets/{ReimbursementApprovalRuleDetailScreen-DlhNa5Zp.js → ReimbursementApprovalRuleDetailScreen-D0_gOHEu.js} +1 -1
  40. package/dist/assets/{ReimbursementRoutes-D6Z9PeOq.js → ReimbursementRoutes-BnId3F39.js} +10 -10
  41. package/dist/assets/{ReportsRoutes-DpEZmBno.js → ReportsRoutes-DbeoJpVK.js} +1 -1
  42. package/dist/assets/RewardsRoutes-CbVAxJ_Q.js +1 -0
  43. package/dist/assets/{ScheduleDetailsPrepaidExpensesScreen-C56nxOtH.js → ScheduleDetailsPrepaidExpensesScreen-ISVWQj5Q.js} +5 -5
  44. package/dist/assets/ScreenRoutes-BxsiowEM.js +2 -0
  45. package/dist/assets/{SettingsRoutes-BQaHGrfu.js → SettingsRoutes-tCVJI0Fg.js} +6 -6
  46. package/dist/assets/{SetupPagesScreen-JaDZPyBb.js → SetupPagesScreen-fiQdFdcd.js} +5 -5
  47. package/dist/assets/SignInScreen-DiXsocpm.js +1 -0
  48. package/dist/assets/SignOutScreen-BiwH5m6t.js +9 -0
  49. package/dist/assets/TaskListScreen-BgIlrtZe.js +9 -0
  50. package/dist/assets/TaskRoutes-BNd4w4Bb.js +9 -0
  51. package/dist/assets/TransactionDetailRoutes-BYsmhufD.js +1 -0
  52. package/dist/assets/TransactionDetailScreen-BkV8Yidz.js +5 -0
  53. package/dist/assets/{TransactionListRoutes-BMNG-mCk.js → TransactionListRoutes-Dy1QqSzY.js} +1 -1
  54. package/dist/assets/TreasuryRoutes-Caywh1RR.js +37 -0
  55. package/dist/assets/{VendorsRoutes-CuJ6l3u7.js → VendorsRoutes-g-EHYY2y.js} +19 -19
  56. package/dist/assets/WiseConfirmationScreen-C46GF-q1.js +12 -0
  57. package/dist/assets/{ZeniAccountRoutes-DCqzbBao.js → ZeniAccountRoutes-B6_vZk4u.js} +11 -11
  58. package/dist/assets/ZeniAccountStatementScreen-BjT0Ja6v.js +9 -0
  59. package/dist/assets/{accountMappingHelper-CrsNnhds.js → accountMappingHelper-jzkx0QiS.js} +1 -1
  60. package/dist/assets/{analytics-Bx-fDzHK.js → analytics-BE49_JfE.js} +1 -1
  61. package/dist/assets/{analyticsHelper-gIdO7Mdz.js → analyticsHelper-DZVn8KPX.js} +1 -1
  62. package/dist/assets/{core-B4xcCWwD.js → core-R1zvmcG1.js} +1 -1
  63. package/dist/assets/{decodeURIComponentSafe-Cemfdm8F.js → decodeURIComponentSafe-D4d600vS.js} +1 -1
  64. package/dist/assets/{dnd-DAPYv1yt.js → dnd-LSyMQh_7.js} +1 -1
  65. package/dist/assets/{empty-BZYLRXJG.js → empty-BfAyW5rR.js} +1 -1
  66. package/dist/assets/{empty-De1pe7cM.js → empty-CtFP9XJw.js} +1 -1
  67. package/dist/assets/{emptyVideoElement-BeM7zNIg.js → emptyVideoElement-DYu9DRPv.js} +1 -1
  68. package/dist/assets/epic-DI5821Fd.js +2 -0
  69. package/dist/assets/expenseAutomationHelper-BlCRyV8f.js +1 -0
  70. package/dist/assets/getLocaleForTenant-DZAPKjbH.js +1 -0
  71. package/dist/assets/{index-4oajNfRK.js → index-ARkELHLC.js} +1 -1
  72. package/dist/assets/{index-yQhQQ1oc.js → index-B-tyZK_L.js} +2 -2
  73. package/dist/assets/{index-Bd0_NsrR.js → index-CooR7eTi.js} +1 -1
  74. package/dist/assets/{index-Dhmnq53Y.js → index-Cvus_VBr.js} +16596 -16159
  75. package/dist/assets/{index-DA_RWywU.js → index-D7BxdwHb.js} +1 -1
  76. package/dist/assets/{index-CDDSCoA2.js → index-DhHwwWlj.js} +1 -1
  77. package/dist/assets/{index-BmVAOx0d.js → index-IzH6rGRi.js} +1 -1
  78. package/dist/assets/{index-BRgafJlj.js → index-LeoAhFsn.js} +1 -1
  79. package/dist/assets/{lexical-Ct1kS2bH.js → lexical-BG-nDmQN.js} +1 -1
  80. package/dist/assets/{liveblocks-CFpJ3lBt.js → liveblocks-DOdRxZ-H.js} +1 -1
  81. package/dist/assets/{lottie-DJ3FaWjT.js → lottie-Z_NAxrmn.js} +1 -1
  82. package/dist/assets/{mui-B8AhwxrZ.js → mui-ZKvbmPSP.js} +1 -1
  83. package/dist/assets/{pathToGoBack-Bf-EUmYS.js → pathToGoBack-DioXT2-t.js} +1 -1
  84. package/dist/assets/{pdf-BJPlJ9jJ.js → pdf-_w1KRTSP.js} +4 -4
  85. package/dist/assets/{pdf-lib-DHIhGaxw.js → pdf-lib-Ctu1umZQ.js} +1 -1
  86. package/dist/assets/{plaid-DygABMyK.js → plaid-tDbexfSh.js} +1 -1
  87. package/dist/assets/{pusher-CvM5lN-w.js → pusher-9ZSIvZ4p.js} +1 -1
  88. package/dist/assets/{react-jh-NMtWH.js → react-BwaH8vjo.js} +1 -1
  89. package/dist/assets/{react-CEuXmahb.js → react-CNq4EJHI.js} +1 -1
  90. package/dist/assets/{react-D_ZzsTWD.js → react-DLfHBjuE.js} +1 -1
  91. package/dist/assets/{react-BFfN-39Q.js → react-DofVj9Pu.js} +1 -1
  92. package/dist/assets/{react-b9RyyXpT.js → react-V1QPqCMR.js} +1 -1
  93. package/dist/assets/{react-B4HMf5As.js → react-dAAwh8YD.js} +1 -1
  94. package/dist/assets/{recharts-D65Mp-4O.js → recharts-UmMlzZlF.js} +1 -1
  95. package/dist/assets/{routePaths-u4VdP_Vd.js → routePaths-ME1g30cL.js} +1 -1
  96. package/dist/assets/{sentry-DXRU_0Gm.js → sentry-DvoFEQx8.js} +1 -1
  97. package/dist/assets/{stripSplatSuffix-DxveybUa.js → stripSplatSuffix-BaAbZcaB.js} +1 -1
  98. package/dist/assets/{url-Bq1xmidF.js → url-C4ptnP9R.js} +1 -1
  99. package/dist/assets/{url-CRJKll1O.js → url-CxALZHMf.js} +1 -1
  100. package/dist/assets/useActualMatchingMatchDetail-CuSDY9wd.js +1 -0
  101. package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-AC_haZph.js → useAiCfoDashboardSuggestedQuestionsChips-B-4Cv_Hc.js} +1 -1
  102. package/dist/assets/useAskAiCfoHostNavButtonProps-D5Ew-Qzm.js +1 -0
  103. package/dist/assets/{useChargeCardPusherEvents-HIkJLjrd.js → useChargeCardPusherEvents-Cd0ovQSz.js} +1 -1
  104. package/dist/assets/{useDeviceId-CP6WbFos.js → useDeviceId-DiDVtEd4.js} +1 -1
  105. package/dist/assets/useEmailConnectResultRefresh-neeIEIrq.js +1 -0
  106. package/dist/assets/{useInitialThreadRequest-BZhBhiT0.js → useInitialThreadRequest-mCNzqzEf.js} +1 -1
  107. package/dist/assets/{useTaskManagerAccess-CXACI9oH.js → useTaskManagerAccess-CcPTnvTg.js} +1 -1
  108. package/dist/assets/{useTaskManagerPusherEvents-CCoo7hJZ.js → useTaskManagerPusherEvents-D1CY3bdf.js} +1 -1
  109. package/dist/assets/{utils-C2swztfg.js → utils-D06mHID-.js} +1 -1
  110. package/dist/assets/{withTransactionSidePanel-DeGcwtOM.js → withTransactionSidePanel-LlSL3tvn.js} +3 -3
  111. package/dist/assets/{zeni-epic-state-z7dEhSaI.js → zeni-epic-state-Mdu-dKQU.js} +7 -7
  112. package/dist/index.html +1 -1
  113. package/package.json +4 -4
  114. package/dist/assets/AccountMappingScreen-BX_TgCEW.js +0 -9
  115. package/dist/assets/AddressRoutes-CCVcXi3e.js +0 -1
  116. package/dist/assets/AddressScreen-CmK0Z1Gk.js +0 -9
  117. package/dist/assets/BusinessVerificationPageScreen-B6MsK8ZB.js +0 -9
  118. package/dist/assets/ConnectionAuthScreen-BKfqdMMN.js +0 -11
  119. package/dist/assets/CustomerOnboardingAuthScreen-BKlbrqkD.js +0 -1
  120. package/dist/assets/DomesticWireDetailScreen-AW4yjv1_.js +0 -18
  121. package/dist/assets/DrawerScreen-BxDe6c9S.js +0 -1
  122. package/dist/assets/EntityDetailRoutes-ePVPk-FN.js +0 -1
  123. package/dist/assets/ExpenseAutomationRoutes-Ctfh4LIP.js +0 -38
  124. package/dist/assets/FeaturePreviewScreen-cSXIJHvM.js +0 -1
  125. package/dist/assets/HubSpotOAuthCallbackScreen-Coekh8J7.js +0 -1
  126. package/dist/assets/InvoicingRoutes-CFnnpzb-.js +0 -3
  127. package/dist/assets/MagicLinkSignInScreen-Cgc6upj0.js +0 -12
  128. package/dist/assets/MobileAppDrawer-PknNExj-.js +0 -1
  129. package/dist/assets/NotFoundScreen-BA5GK6fZ.js +0 -1
  130. package/dist/assets/NotificationRoutes-BYdtJyhh.js +0 -1
  131. package/dist/assets/OAuthConsentScreen-Dsn5YLy4.js +0 -1
  132. package/dist/assets/PandLWithForecastRoutes-Bfj4W6hW.js +0 -1
  133. package/dist/assets/PeopleRoutes-Ca7RDuty.js +0 -22
  134. package/dist/assets/PerformanceRoutes-CtdCEpTT.js +0 -1
  135. package/dist/assets/ReimbursementApprovalRoutes-AZUxWb79.js +0 -1
  136. package/dist/assets/RewardsRoutes-CGv84UVK.js +0 -1
  137. package/dist/assets/ScreenRoutes-Dq8tSKSA.js +0 -2
  138. package/dist/assets/SignInScreen-BPiC2SXK.js +0 -1
  139. package/dist/assets/SignOutScreen-DrmKOkUx.js +0 -9
  140. package/dist/assets/TaskListScreen-lNco8GQG.js +0 -9
  141. package/dist/assets/TaskRoutes-hQtI-0Ne.js +0 -9
  142. package/dist/assets/TransactionDetailRoutes-C3MxiiB1.js +0 -1
  143. package/dist/assets/TransactionDetailScreen-BaZRBpiD.js +0 -5
  144. package/dist/assets/TreasuryRoutes-CTieXhH2.js +0 -37
  145. package/dist/assets/WiseConfirmationScreen-B49tOG90.js +0 -12
  146. package/dist/assets/ZeniAccountStatementScreen-D7kxRmlf.js +0 -9
  147. package/dist/assets/epic-cOk9fI5o.js +0 -2
  148. package/dist/assets/expenseAutomationHelper-DT7JkXm4.js +0 -1
  149. package/dist/assets/getLocaleForTenant-DTiA1xl1.js +0 -1
  150. package/dist/assets/useActualMatchingMatchDetail-BPxS7o9O.js +0 -1
  151. package/dist/assets/useAskAiCfoHostNavButtonProps-DOhr7Jea.js +0 -1
  152. package/dist/assets/useEmailConnectResultRefresh-C8XZBLif.js +0 -1
@@ -0,0 +1 @@
1
+ import{j as s}from"./liveblocks-DOdRxZ-H.js";import{a as c}from"./sentry-DvoFEQx8.js";import{h as q,u as A,g as G,i as N,j as d,N as W,l as X,n as F,o as O}from"./core-R1zvmcG1.js";import{Xw as _,fI as M,WN as R,n3 as Y,SN as k,XB as $,Xq as z,m3 as V,SO as P,WS as H,WT as J,Xs as K,Xr as L}from"./zeni-epic-state-Mdu-dKQU.js";import{b6 as Q,l as U,a2 as Z,p as tt}from"./index-Cvus_VBr.js";import"./mui-ZKvbmPSP.js";import{d as I}from"./decodeURIComponentSafe-D4d600vS.js";import{w as et}from"./withTransactionSidePanel-LlSL3tvn.js";import{f as at,c as nt}from"./routePaths-ME1g30cL.js";import"./recharts-UmMlzZlF.js";import"./analytics-BE49_JfE.js";import"./plaid-tDbexfSh.js";import"./dnd-LSyMQh_7.js";import"./stripe-cKAAJElX.js";import"./lottie-Z_NAxrmn.js";import"./lexical-BG-nDmQN.js";import"./pdf-_w1KRTSP.js";import"./utils-D06mHID-.js";import"./useAskAiCfoHostNavButtonProps-D5Ew-Qzm.js";import"./TransactionDetailScreen-BkV8Yidz.js";import"./useInitialThreadRequest-mCNzqzEf.js";import"./expenseAutomationHelper-BlCRyV8f.js";import"./stripSplatSuffix-BaAbZcaB.js";(function(){try{var a=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new a.Error().stack;t&&(a._sentryDebugIds=a._sentryDebugIds||{},a._sentryDebugIds[t]="a6866467-5cf7-4cd2-8cf2-4241e73c8538",a._sentryDebugIdIdentifier="sentry-dbid-a6866467-5cf7-4cd2-8cf2-4241e73c8538")}catch{}})();const ot=X((function(a,t){const e=t.entity,o=$(a,t.entity,"EntityDetail");return{selectedEntity:e,autoCompleteData:{autoCompleteText:e.name,entityAutoCompleteView:z(a,"common")},trendWithTransactionsReport:o,analytics:U,isAccountingClassesEnabled:V(a)}}),(function(a,t){return{onTransactionItemClick:e=>{if(t.openTransactionPanel)return void t.openTransactionPanel(e.id,e.type);const o=`${nt(e,t.tenantEmailDomain)}`,l=tt(t.location.state?.pathnameStackToGoBack,t.location.pathname);t.navigate(o,{state:{pathnameStackToGoBack:l}})},autoCompleteActions:{onAutoCompleteInputChange:e=>{e.trim().length>=2?a(K({searchString:e,searchOrigin:"common"})):e.trim().length===0&&a(L("common"))},onAutoCompleteEntity:e=>{const o=at(e,t.tenantEmailDomain);a(H()),a(J()),t.resetTrendIsFetchedStates(),t.navigate(o,{replace:!0,state:{pathnameStackToGoBack:t.location.state?.pathnameStackToGoBack}})},onCancelAutoComplete:()=>{const e=Z(t.location.state?.pathnameStackToGoBack),o=e.poppedPathname??C();t.navigate(o,{state:{pathnameStackToGoBack:e.newStack}})}},onTrendSelectedPeriodChange:e=>{if(t.closeSidePanel?.(),e==null)t.defaultTransactionTimePeriod!=null&&a(P(t.entity,"EntityDetail",{timeframe:"quarter",timePeriod:t.defaultTransactionTimePeriod}));else{const o=e.currentTimePeriod==null?e.addTimePeriod:{startDate:e.addTimePeriod.startDate,endDate:e.currentTimePeriod.endDate};a(k(t.entity,"EntityDetail",{timeframe:e.timeframe,timePeriod:e.addTimePeriod})),a(P(t.entity,"EntityDetail",{timeframe:e.timeframe,timePeriod:o}))}}}}))(Q),it=et((function({entityType:a,...t}){const e=q(),o=A(),l=G(),[m,T]=c.useState(!1),[h,D]=c.useState(!1),{tenantEmailDomain:b,entityIdEncoded:w,entityNameEncoded:x}=N(),r=I(w??""),p=I(x??""),f=rt(r,p),j=[r,p].filter((n=>n!=null)),i={name:p,id:r,type:a,zeniId:r,qboId:r},g=d((n=>_(n.customerIncomeState,n.vendorExpenseState,n.trendState,i,"quarter"))),v=d((n=>M(n).company?.companyInfo.firstMonthOfFY??1)),u=d((n=>R(n.trendWithTransactionsState,i,"EntityDetail")));c.useEffect((()=>{m===!1&&f===!0&&(T(!0),o(Y(i)))}),[m,f,i]);const S=d((n=>n.trendState.fetchState)),E=u?.selectedPeriod?.timePeriod??g,B=(function(n,y){return n!=null&&y!=null?{startDate:n.startDate,endDate:y?.endDate}:y})(u?.selectedPeriod?.timePeriod,g);return c.useEffect((()=>{m===!0&&h===!1&&S==="Completed"&&(D(!0),E!=null&&o(k(i,"EntityDetail",{timeframe:u?.selectedPeriod?.timeframe??"quarter",timePeriod:E})))}),[m,h,S]),f?s.jsx(ot,{firstMonthOfFY:v,tenantEmailDomain:b,location:l,navigate:e,entity:i,defaultTransactionTimePeriod:B,resetTrendIsFetchedStates:()=>{T(!1),D(!1)},...t}):s.jsx(W,{to:C(j.length)})})),rt=(a,t)=>t!=null&&t.length>0&&a!=null&&a.length>0,C=(a=2)=>{let t="../";for(let e=0;e<a;e++)t=`${t}../`;return t};function vt({entityType:a}){return s.jsx(F,{children:s.jsx(O,{path:"/:entityIdEncoded/:entityNameEncoded/*",element:s.jsx(it,{entityType:a})})})}export{vt as EntityDetailRoutes,vt as default};
@@ -0,0 +1,38 @@
1
+ import{j as T}from"./liveblocks-DOdRxZ-H.js";import{u as Se,h as _e,g as fe,j as O,i as Te,t as qn,l as io,n as lo,o as Ge,N as ro}from"./core-R1zvmcG1.js";import{fI as ye,a1F as Jn,q4 as De,UN as xt,Aq as uo,a1G as mo,a1H as po,a1I as ho,a1J as yt,a1K as it,gk as Rt,a1L as In,eH as So,g3 as fo,a1M as Cn,a1N as lt,qX as go,uY as Io,gW as Co,gU as ko,a1O as bo,r8 as To,rh as yo,qf as Po,qt as Yn,gT as re,gV as vo,a1P as Eo,qP as Wn,ri as Ao,qq as xo,ql as Ro,v2 as wo,gS as Fe,a1Q as ut,CA as Hn,N3 as Kn,a1R as Xn,F_ as Qn,a1S as Do,e$ as Fo,f1 as _o,sZ as wt,Xx as kn,Xz as Mo,m6 as Oo,XA as Uo,md as Bo,dm as Vo,DT as Dt,a1T as jo,a1U as $o,a1V as zo,a1W as Lo,fp as Ft,sN as bn,Xq as Go,a1X as No,a1Y as qo,mf as Jo,a1Z as Yo,RO as Wo,me as Ho,m3 as Ko,qI as Zn,rn as mt,tA as ea,tW as Xo,UD as ta,rm as Tn,rp as na,rr as Qo,bF as Zo,nC as es,nz as ts,rq as rt,ro as be,a1_ as ns,rI as yn,a1$ as as,a20 as os,sR as ss,sS as cs,Xm as is,Ws as ls,a17 as rs,a21 as ds,Xs as Pn,Xr as ct,a22 as vn,mu as us,a23 as ms,a24 as ps,a25 as hs,a26 as Ss,qD as fs,a27 as gs,a28 as Is,a29 as Cs,ry as ks,mh as bs,m8 as Ts,a2a as ys,mg as En,XK as Ps,a2b as vs,a2c as Es,uz as As,ua as xs,u9 as Pt,a2d as Rs,a2e as ws,a2f as Ds,a2g as Fs,nN as _s,br as aa,nI as An,nu as Ms,a2h as Os,h3 as Us,nF as Bs,s$ as Vs,t1 as js,sK as $s,Wv as zs,Ww as Ls,Fs as Gs,Fr as Ns,FI as qs,a2i as xn,sQ as Js,sl as Ys,a2j as Ws,s1 as Hs,s6 as Ks,sh as Xs,s4 as Qs,a2k as Zs,rZ as ec,sg as tc,sW as nc,a2l as ac,t7 as oc,sE as sc,td as cc,sJ as ic,rJ as lc,a2m as rc,q$ as dc,qz as uc,qG as Rn,rt as mc,a2n as pc,a2o as hc,a2p as Sc,a2q as fc,a2r as gc,a2s as Ic,a2t as Cc,th as kc,a2u as bc,a2v as Tc,a2w as wn,uK as yc,u1 as Pc,tS as Dn,tQ as vc,a2x as Ec,tF as Ac,tk as xc,tT as Rc,a2y as wc,a2z as Dc,tq as Fc,a2A as _c,tl as Mc,tp as Oc,tn as Uc,tZ as Bc,a2B as Vc,q8 as Fn,a2C as jc,E3 as _n,cz as $c}from"./zeni-epic-state-Mdu-dKQU.js";import Ut from"./NotFoundScreen-BR0tBeJN.js";import{a as o,R as oa}from"./sentry-DvoFEQx8.js";import{n as Me,S as zc}from"./mui-ZKvbmPSP.js";import{Y as qe,$ as X,l as ee,p as Z,ao as sa,aq as ca,dM as Lc,dN as Gc,z as Je,dO as _t,dP as Nc,dQ as qc,ac as Ne,dR as Jc,dS as Mn,b8 as On,dT as Yc,a5 as ia,dU as Wc,j as dt,a as Hc,dV as Kc,dW as Xc,k as Qc,V as Zc,dX as ei,dY as ti,dZ as ni,b2 as ai,bq as oi,a9 as si,b3 as ci,b4 as ii,G as la,w as li,d_ as ri,at as Mt,d$ as di,a2 as ui,e0 as mi}from"./index-Cvus_VBr.js";import{u as Bt}from"./useAskAiCfoHostNavButtonProps-D5Ew-Qzm.js";import{g as Un,b as pi,c as hi,h as Si,a as fi,i as gi,r as Ii,C as Ci}from"./TransactionDetailScreen-BkV8Yidz.js";import{u as ki,a as bi}from"./useActualMatchingMatchDetail-CuSDY9wd.js";import{d as Ti}from"./decodeURIComponentSafe-D4d600vS.js";import{m as Vt,a as ra,b as da,i as Ot}from"./expenseAutomationHelper-BlCRyV8f.js";import{u as ua,a as ma,w as yi}from"./withTransactionSidePanel-LlSL3tvn.js";import{b as Pi,S as vi,a as Ei,J as Ai}from"./ScheduleDetailsPrepaidExpensesScreen-ISVWQj5Q.js";import{s as Bn,i as pa,h as xi,v as Ri,c as wi}from"./routePaths-ME1g30cL.js";import{a as vt}from"./accountMappingHelper-jzkx0QiS.js";import{D as Di}from"./DrawerScreen-CjvLDWWa.js";import"./recharts-UmMlzZlF.js";import"./analytics-BE49_JfE.js";import"./plaid-tDbexfSh.js";import"./dnd-LSyMQh_7.js";import"./stripe-cKAAJElX.js";import"./lottie-Z_NAxrmn.js";import"./lexical-BG-nDmQN.js";import"./pdf-_w1KRTSP.js";import"./utils-D06mHID-.js";import"./useInitialThreadRequest-mCNzqzEf.js";import"./stripSplatSuffix-BaAbZcaB.js";import"./pathToGoBack-DioXT2-t.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new t.Error().stack;a&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[a]="0f9fb863-9375-4861-bfe7-69ab51125333",t._sentryDebugIdIdentifier="sentry-dbid-0f9fb863-9375-4861-bfe7-69ab51125333")}catch{}})();const Fi=()=>{const t=Se(),a=_e(),S=fe(),I=O((u=>ye(u))),{useFeatureGate:d}=qe(),{isFeatureEnabled:i}=d(X.isRealtimeInsightsFeatureEnabled),{isFeatureEnabled:l}=d(X.aiAuditScorePercentage),x=O((u=>u.expenseAutomationViewState.selectedPeriodByTenantId)),r=O((u=>Jn(u,I.tenantId))),{isAiCfoAccessEnabled:v,onAskAiCfoClick:R}=Bt({mobileExploreReferrer:"Month-End Close Overview"}),C=o.useCallback(((u,y,p=!1)=>{t(De({tenantId:y,period:{month:u.month,year:u.year},refreshViewInBackground:p}))}),[]),h=o.useCallback((u=>{const y=S.state?.referrer;r.monthEndCloseChecks?.auditSummary!=null&&ee.trackMonthCloseAuditPage(u.month,u.year,r.monthEndCloseChecks.reportEmailSentDate!=null?"closed":"in-review",r.monthEndCloseChecks.auditSummary.auditScorePercentage,!1,y??null),t(xt(I.tenantId,u))}),[I.tenantId,r.monthEndCloseChecks?.auditSummary,r.monthEndCloseChecks?.reportEmailSentDate]),g=x[I.tenantId],D=o.useCallback((()=>{const u=S.state?.referrer;r.monthEndCloseChecks?.auditSummary!=null&&ee.trackMonthCloseAuditPage(g.month,g.year,r.monthEndCloseChecks.reportEmailSentDate!=null?"closed":"in-review",r.monthEndCloseChecks.auditSummary.auditScorePercentage,!0,u??null),C(g,I.tenantId,!0)}),[C,g,I.tenantId,r.monthEndCloseChecks?.auditSummary,r.monthEndCloseChecks?.reportEmailSentDate]),B=Z(S.state?.pathnameStackToGoBack,S.pathname),V=o.useCallback((()=>{if(r.monthEndCloseChecks!=null&&g!=null){const u=r.monthEndCloseChecks.monthEndCloseCheckList.find((y=>y.progress<100));if(u!=null)return void a(`./${u.id}/${g.month}-${g.year}`,{state:{pathnameStackToGoBack:B,message:"comingFromOverview"}});a(`./month_end_insights/${g.month}-${g.year}`,{state:{pathnameStackToGoBack:B,message:"comingFromOverview"}})}}),[r.monthEndCloseChecks,g]),{areTenantIdsInSync:b}=sa();return ca({isDataReady:r.fetchState==="Completed"}),o.useEffect((()=>{g!=null&&r.fetchState!=="In-Progress"&&r.fetchState!=="Completed"&&b&&C(g,I.tenantId)}),[C,g,r.fetchState,I.tenantId,b]),o.useEffect((()=>{g!=null&&r.monthClosePerformanceTrendFetchStatus.fetchState!=="In-Progress"&&r.monthClosePerformanceTrendFetchStatus.fetchState!=="Completed"&&b&&t(uo(g))}),[g,r.monthClosePerformanceTrendFetchStatus.fetchState,b]),o.useEffect((()=>{const u=setInterval((()=>{r.fetchState!=="In-Progress"&&r.fetchState==="Completed"&&D()}),3e5);return()=>clearInterval(u)}),[r.fetchState]),o.useEffect((()=>{if(r.fetchState==="Completed"&&r.monthEndCloseChecks?.auditSummary!=null){const u=S.state?.referrer;ee.trackMonthCloseAuditPage(r.selectedPeriod.month,r.selectedPeriod.year,r.monthEndCloseChecks.reportEmailSentDate!=null?"closed":"in-review",r.monthEndCloseChecks.auditSummary.auditScorePercentage,!1,u??null)}}),[r.fetchState,r.selectedPeriod,r.monthEndCloseChecks?.auditSummary,r.monthEndCloseChecks?.reportEmailSentDate]),T.jsx(_i,{children:T.jsx(Lc,{monthEndCloseChecksView:r,isRealtimeInsightsFeatureEnabled:i,onMonthEndCheckClick:u=>{a(`./${u}/${g.month}-${g.year}`,{state:{pathnameStackToGoBack:B,message:"comingFromOverview",referrer:"Expense Automation - Overview"}})},onPeriodChange:h,handleReviewButtonClick:V,onBackClick:()=>{a("../../dashboard")},onReload:D,isAiCfoAccessEnabled:v,onAskAiCfoClick:R,aiAuditScorePercentageEnabled:l})})},_i=Me.div`
2
+ display: flex;
3
+ height: 100vh;
4
+ width: 100%;
5
+ flex: 1 1 auto;
6
+ flex-direction: column;
7
+ background-color: ${t=>t.theme.colors.grey4};
8
+ `;function Mi({isFullView:t,matchId:a,onClose:S}){const{match:I,detailFetchState:d,handleOpenBill:i,handleApproveAndReverse:l,handleIgnoreMatchSuggestion:x,handleRefresh:r,handleUndoReversal:v,lastMatchResults:R,lastUndoResults:C,refreshStatus:h,ignoreStatus:g,matchAndReverseStatus:D,undoReversalStatus:B}=ki(a);return T.jsx(Gc,{match:I,detailFetchState:d.fetchState,isRenderedInPanel:!t,isApproveInFlight:D.fetchState==="In-Progress",isIgnoreInFlight:g.fetchState==="In-Progress",isUndoInFlight:B.fetchState==="In-Progress",refreshStatus:h.fetchState,onNavigateBack:S,onOpenBill:i,onApproveAndReverse:l,onIgnoreMatchSuggestion:x,onRefresh:r,onUndoReversal:v,lastMatchResults:R,lastUndoResults:C})}const Oi=/^match\/([^/?]+)$/,Ui=ma({displayNamePrefix:"withActualMatchingSidePanel",usePanelSetup:function(t){const{useFeatureGate:a}=qe(),{isFeatureEnabled:S}=a(X.isTransactionDetailSplitViewEnabled),{isFeatureEnabled:I}=a(X.isAccrualEnabled),d=(function(l=!0){const x=_e(),r=fe(),v=Te(),R=Vt(v),C=ua({childPathPattern:Oi,enabled:l,listPath:R}),h=C.matchGroups[0]!=null&&C.matchGroups[0]!==""?Ti(C.matchGroups[0]):void 0,g=v.tenantEmailDomain??r.pathname.split("/").find(Boolean)??"",D=o.useRef({isOpen:C.isOpen,matchId:h});D.current={isOpen:C.isOpen,matchId:h};const B=o.useCallback((u=>{!C.isMobile&&l?D.current.isOpen&&D.current.matchId===u?C.closePanel():C.navigateToChild(`match/${encodeURIComponent(u)}`,{replace:D.current.isOpen}):x(`/${g}/expense-automation/actual-matching/${encodeURIComponent(u)}`)}),[x,C.isMobile,C.navigateToChild,C.closePanel,l,g]),V=o.useCallback((()=>{if(h==null)return;const u=Z(r.state?.pathnameStackToGoBack,`${r.pathname}${r.search}`);x(`/${g}/expense-automation/actual-matching/${encodeURIComponent(h)}`,{state:{pathnameStackToGoBack:u}})}),[r.pathname,r.search,r.state,h,x,g]),b=C.isOpen&&h!=null;return{closePanel:C.closePanel,isOpen:b,maximize:V,matchId:l&&b?h:void 0,openPanel:B}})(t&&I===!0&&S===!0),i=o.useMemo((()=>{if(d.isOpen&&d.matchId!=null)return T.jsx(Mi,{isFullView:!1,matchId:d.matchId,onClose:d.closePanel},d.matchId)}),[d.closePanel,d.isOpen,d.matchId]);return{injectedProps:o.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=oa.memo((({reconciliation:t,selectedDrawerAccountId:a,onClose:S,onFetchLinkTokenClick:I,onEstablishConnectionClick:d})=>{const i=Se(),l=_e(),x=fe(),{tenantEmailDomain:r,selectedTab:v,selectedPeriod:R}=Te(),{useFeatureGate:C}=qe(),{isFeatureEnabled:h}=C(X.isReconV3Enabled),{isFeatureEnabled:g}=C(X.isReconciliationCombinedStatementEnabled),{isFeatureEnabled:D}=C(X.isReconReportEnabled),B=Je.getSignedInUser(),V=O((w=>ye(w))),b=o.useMemo((()=>({userId:B?.userId??"",sessionId:B?.zeniSessionId??"",tenantId:V?.tenantId??""})),[B?.userId,B?.zeniSessionId,V?.tenantId]),{accountReconciliationsByAccountID:u,excludedAccountIDs:y,monthYearPeriod:p,statementUploadChosen:E}=t,_=u[a],j=o.useMemo((()=>mo(u,a)),[u,a]),f=o.useMemo((()=>po(u)),[u]),U=o.useMemo((()=>ho(u,a)),[u,a]),e=o.useRef(!1),n=o.useCallback((w=>{e.current=w,Mn(a,w)}),[a]),c=o.useCallback((w=>{i(yt({accountId:a,selectedPeriod:p,dismissedToBackground:!0,backgroundCompletedSteps:w.completedSteps,startedAtMs:w.startedAtMs,totalDurationSeconds:w.totalDurationSeconds})),w.accountMappings!=null&&i(it({accountId:a,selectedPeriod:p,localData:{combinedStatementAccountMappings:w.accountMappings}})),_!=null&&requestAnimationFrame((()=>{e.current||i(Rt({messageSection:"statement_parsing_in_progress",messageText:"success",type:"info",showStatusIcon:!0,variables:[{variableName:"_account_name_",variableValue:_t(_)}]}))}))}),[i,p,_,a]),m=o.useCallback((()=>{i(yt({accountId:a,selectedPeriod:p,dismissedToBackground:!1}))}),[i,a,p]),k=o.useCallback((w=>{i(In({accountId:a,selectedPeriod:p,backgroundCompletedSteps:w}))}),[i,p,a]),P=o.useCallback((()=>{i(In({accountId:a,selectedPeriod:p,backgroundCompletedSteps:0})),i(yt({accountId:a,selectedPeriod:p,dismissedToBackground:!1}))}),[i,p,a]);o.useEffect((()=>()=>{Mn(null,!1)}),[]);const F=_?.parsedStatementData?.statementUpload?.statementMeta?.statementUploadId??_?.accountReconEntity.statementMetaData?.statementUploadId,z=_?.statementDateConflict?.previousReconciliationInfo?.reconciledByUserId,H=O((w=>z!=null&&z!==""?So(fo(w.userState,z)):"")),K=o.useCallback((()=>{i(Cn({accountId:a,selectedPeriod:p}))}),[i,a,p]),oe=o.useCallback((()=>{i(Cn({accountId:a,selectedPeriod:p})),i(lt({statementUploadChosen:!0}))}),[i,a,p]),te=(w,Q)=>{i(wo(w,Q.split(".")[0]))},ue=(w,Q)=>{if(Q===!0){const ae=_?.combinedStatementGroupId??_?.parsedStatementData?.statementUpload?.statementMeta?.combinedStatementGroupId??_?.parsedStatementData?.statementUpload?.combinedStatementDetails?.combinedStatementGroupId;if(ae!=null&&ae!=="")return void i(xo({accountId:a,selectedPeriod:p,combinedStatementGroupId:ae,fileId:w}))}F!=null&&i(Ro({accountId:a,selectedPeriod:p,fileId:w,statementUploadId:F}))},A=()=>{i(lt({statementUploadChosen:!1}))},$=w=>{i(Ao({accountId:a,selectedPeriod:p,payload:w,statementAccountScope:g===!0?_?.localData?.statementAccountScope??"single_account":"single_account"}))},L=o.useCallback(((w,Q,ae)=>{i(go({accountId:w,selectedPeriod:Q,statementUploadId:ae}))}),[i]),ge=o.useCallback(((w,Q,ae,ve,Ee)=>{Ee!=null&&Ee!==""&&i(Io(Ee)),i(ve==null||ve===""?ko({accountId:w,selectedPeriod:Q,statementUploadId:ae}):Co({accountId:w,selectedPeriod:Q,statementUploadId:ae,combinedStatementGroupId:ve}))}),[i]),Ye=o.useCallback(((w,Q)=>{Q!==""&&i(bo({accountId:a,selectedPeriod:p,statementUpdateLocalData:w,statementUploadId:Q}))}),[i,a,p]),q=o.useCallback((()=>{F!=null&&i(_?.localData?.statementAccountScope!=="multi_account"?yo({accountId:a,selectedPeriod:p,statementUploadId:F}):To({accountId:a,selectedPeriod:p,statementUploadId:F}))}),[i,_?.localData?.statementAccountScope,a,p,F]),pt=o.useCallback((w=>{F!=null&&i(Po({accountId:a,selectedPeriod:p,statementUploadId:F,accountMappings:w}))}),[i,p,a,F]),Oe=o.useCallback((()=>{i(lt({statementUploadChosen:!0}))}),[i]),We=w=>{i(it({accountId:a,selectedPeriod:p,localData:{accountSource:w}}))},Pe=w=>{i(it({accountId:a,selectedPeriod:p,localData:{statementAccountScope:w}}))},He=o.useCallback((()=>{i(Yn({accountId:a}))}),[i,a]),Ke=o.useCallback((w=>{i(re(p,w,!0)),S()}),[i,p,S]),se=o.useCallback((w=>{if(r==null||v==null||R==null)return;const Q=Z(x.state?.pathnameStackToGoBack,x.pathname);S();const ae=ra({tenantEmailDomain:r,selectedTab:v,accountId:w,period:R});ae!=null&&l(ae,{state:{pathnameStackToGoBack:Q}})}),[x.pathname,x.state,l,S,R,v,r]),me=o.useCallback((()=>{i(vo({accountId:a,selectedPeriod:p,statementProcessingFailed:!1})),i(Eo({accountId:a,selectedPeriod:p}))}),[i,a,p]),ce=o.useCallback((()=>{i(Wn({accountId:a}))}),[i,a]),Ue=y.includes(a)?t.excludedAccountReconciliationByAccountID[a]:void 0;if(Ue!=null)return T.jsx(Vn,{children:T.jsx(jn,{$isV3:h===!0,children:T.jsx(Nc,{excludedAccountReconciliation:Ue,includeAccountFetch:t.includeAccountFetchState,isReconV3Enabled:h,onDismissClick:S,onIncludeIntoReconciliation:ce})})});if(_!=null){const w=h===!0?T.jsx(qc,{excludeAccountFetch:t.excludeAccountFetchState,accountReconciliation:_,monthYearPeriod:p,onDismissClick:S,plaidConnectionDetails:t.plaidConnectionDetails,onFetchLinkTokenClick:I,onEstablishConnectionClick:d,onEditFileName:te,onDeleteFile:ue,onSelectSourceType:We,onSelectStatementAccountScope:Pe,isReconciliationCombinedStatementEnabled:g===!0,ledgerAccounts:j,statementOverrideWarningAccountIds:U,unavailableLedgerAccountIds:f,onConfirmStatementMapping:pt,filesEndPoint:Ne.fileMicroServiceBaseUrl,authParams:b,openFilePicker:E,onStatementUploadSuccess:$,onUploadWindowOpenedOnce:A,onExcludeFromReconciliation:He,onRetryParsing:L,onFetchStatementParseInfo:ge,onReviewClicked:Ke,onViewReportClicked:D===!0?se:void 0,statementProcessingFailed:_.statementProcessingFailed,statementProcessingDismissedToBackground:_.statementProcessingDismissedToBackground,onDismissStatementProcessingFailed:me,onContinueInBackground:c,onClearStatementProcessingDismissedToBackground:m,onResetStatementProcessingProgress:P,onStatementProcessingProgressChange:k,onStatementFlowVisibilityChange:n,onReuploadStatement:Oe,onStatementFormDataChange:Ye,onStatementConfirmSave:q,reconciledByName:H,onDismissDateConflict:K,onReuploadAfterDateConflict:oe,isReconV3Enabled:h}):T.jsx(Jc,{excludeAccountFetch:t.excludeAccountFetchState,accountReconciliation:_,monthYearPeriod:p,onDismissClick:S,plaidConnectionDetails:t.plaidConnectionDetails,onFetchLinkTokenClick:I,onEstablishConnectionClick:d,onEditFileName:te,onDeleteFile:ue,onSelectSourceType:We,filesEndPoint:Ne.fileMicroServiceBaseUrl,authParams:b,openFilePicker:E,onStatementUploadSuccess:$,onUploadWindowOpenedOnce:A,onExcludeFromReconciliation:He});return T.jsx(Vn,{children:T.jsx(jn,{$isV3:h===!0,children:w})})}return null})),Vn=Me.div`
9
+ display: flex;
10
+ flex-direction: column;
11
+ height: 100%;
12
+ `,jn=Me.div`
13
+ flex: 1;
14
+ min-height: 0;
15
+ display: flex;
16
+ flex-direction: column;
17
+ box-sizing: border-box;
18
+ min-width: 0;
19
+ overflow-x: hidden;
20
+ overflow-y: ${t=>t.$isV3===!0?"hidden":"auto"};
21
+ `;function Vi({panelType:t,scheduleId:a,onClose:S,onCloseAfterDecision:I}){return T.jsx($i,{children:T.jsx(zi,{children:ji(t,a,S,I)})})}function ji(t,a,S,I){switch(t){case"one_time_accrual":return T.jsx(Ai,{isRenderedInPanel:!0,accrualIdOverride:a,onPanelNavigateBack:S});case"accrued_expenses":return T.jsx(Ei,{isRenderedInPanel:!0,scheduleDetailIdOverride:a,onPanelNavigateBack:S,onPanelCloseAfterDecision:I});case"fixed_assets":return T.jsx(vi,{isRenderedInPanel:!0,scheduleDetailIdOverride:a,onPanelNavigateBack:S,onPanelCloseAfterDecision:I});case"prepaid_expenses":return T.jsx(Pi,{isRenderedInPanel:!0,scheduleDetailIdOverride:a,scheduleTypeOverride:"prepaid_expenses",onPanelNavigateBack:S,onPanelCloseAfterDecision:I})}}const $i=Me.div`
22
+ display: flex;
23
+ flex-direction: column;
24
+ height: 100%;
25
+ `,zi=Me.div`
26
+ flex: 1;
27
+ min-height: 0;
28
+ display: flex;
29
+ flex-direction: column;
30
+ box-sizing: border-box;
31
+ min-width: 0;
32
+ overflow-x: hidden;
33
+ overflow-y: auto;
34
+ `,Li=/^schedule\/(prepaid_expenses|fixed_assets|accrued_expenses|one_time_accrual)\/([^/?]+)$/,Gi=ma({displayNamePrefix:"withScheduleSidePanel",usePanelSetup:function(t){const a=(function(h=!0){const g=_e(),D=fe(),B=Se(),V=Te(),b=ua({childPathPattern:Li,enabled:h}),u=b.matchGroups[0],y=pa(u)?u:void 0,p=b.matchGroups[1]!=null&&b.matchGroups[1]!==""?b.matchGroups[1]:void 0,E=b.isOpen&&y!=null&&p!=null,_=V.tenantEmailDomain??D.pathname.split("/").find(Boolean)??"",j=o.useRef({isOpen:E,scheduleId:p});j.current={isOpen:E,scheduleId:p};const f=o.useCallback(((e,n,c)=>{c!=null&&(n==="prepaid_expenses"||n==="fixed_assets")&&B(Qn({selectedJEScheduleKey:c})),!b.isMobile&&h?j.current.isOpen&&j.current.scheduleId===e?b.closePanel():b.navigateToChild(`schedule/${n}/${e}`,{replace:j.current.isOpen}):g(Bn(n,e,_),{state:{message:"expenseAutomation",origin:"je_schedules"}})}),[B,g,b.isMobile,b.navigateToChild,b.closePanel,h,_]),U=o.useCallback((()=>{if(y==null||p==null)return;const e=Z(D.state?.pathnameStackToGoBack,D.pathname);g(Bn(y,p,_),{state:{pathnameStackToGoBack:e,message:"expenseAutomation",origin:"je_schedules"}})}),[g,y,p,_,D.pathname,D.state]);return{closePanel:b.closePanel,isOpen:E,maximize:U,openPanel:f,panelType:E?y:void 0,scheduleId:E?p:void 0}})(t),S=o.useRef(null),[I,d]=o.useState(null),i=o.useMemo((()=>({registerPanelDirtyGuard:h=>{S.current=h}})),[]),l=o.useCallback((h=>{S.current?.isDirty()===!0?d((()=>h)):h()}),[]),x=o.useCallback((()=>{l(a.closePanel)}),[l,a.closePanel]),r=o.useCallback((()=>{l(a.maximize)}),[l,a.maximize]),v=o.useCallback(((h,g,D)=>{l((()=>a.openPanel(h,g,D)))}),[l,a.openPanel]),R=o.useMemo((()=>{if(I!=null)return{onCancel:()=>d(null),onDiscard:()=>{S.current=null,d(null),I()}}}),[I]),C=o.useMemo((()=>{if(a.isOpen&&a.panelType!=null&&a.scheduleId!=null)return T.jsx(Yc.Provider,{value:i,children:T.jsx(Vi,{panelType:a.panelType,scheduleId:a.scheduleId,onClose:x,onCloseAfterDecision:()=>{S.current=null,a.closePanel()}},`${a.panelType}:${a.scheduleId}`)})}),[a.isOpen,a.panelType,a.scheduleId,a.closePanel,x,i]);return{injectedProps:o.useMemo((()=>({closeSchedulePanel:x,isSchedulePanelOpen:a.isOpen,openSchedulePanel:v,schedulePanelContent:C,schedulePendingDiscardConfirmation:R})),[x,v,C,R,a.isOpen]),selectedItemId:a.scheduleId,sidePanel:{closePanel:x,maximize:r}}}});function Ni({companyId:t,closeCustomerRequestDrawer:a,addCustomerRequest:S,resetCustomerRequest:I}){const d=Je.getSignedInUser();if(d==null)throw Error("Can't access Customer Request page without signing in...");const i=O((l=>Do(l,t,d)));return o.useEffect((()=>{I()}),[]),T.jsx(T.Fragment,{children:i.fetchState==="In-Progress"||i.companyMonthEndReportTemplatesData.fetchState==="In-Progress"?T.jsx(ia,{fetchState:"In-Progress"}):T.jsx(Wc,{onCloseClick:a,addCustomerRequest:S,snippets:i.companyMonthEndReportTemplatesData,bulletPoints:i.zeniRequestsData??[]})})}const qi={schedules:"Review Schedules",actual_matching:"Actual Matching",existing_schedules:"Existing Schedules"},Ji=()=>{const t=O((R=>Fe(R))),a=fe(),{currentSelectedViewFetchState:S,currentSelectedView:I,selectedPeriod:d}=t,i=dt(I),l=dt(S.fetchState),x=t.jeSchedules.uiState.selectedPageTab??"schedules",r=dt(x),v=o.useCallback((R=>{const C=a.state?.referrer;I==="transaction_categorization"&&(t.selectedTransactionCategorizationTab==="review"?ee.trackTransactionsReviewPage(d.month,d.year,t.transactionView.totalCountByTab.review,0,R,C??null):ee.trackTransactionsAutoCategorisedPage(d.month,d.year,t.transactionView.totalCountByTab.autoCategorized,0,R,C??null)),I==="missing_receipts"&&ee.trackMissingReceiptsPage(d.month,d.year,R,t.missingReceipts.transactions.length,C??null),I==="je_schedules"&&ee.trackMonthCloseScheduleListPage(d.month,d.year,R,t.jeSchedules.pendingReviewSchedules.length,t.jeSchedules.failedPostings.length,(h=>{const g={accruedCount:0,fixedAssetsCount:0,oneTimeAccrualCount:0,prepaidCount:0};return h.forEach((D=>{if(Fo(D))g.oneTimeAccrualCount+=1;else switch(_o(D)){case"prepaid_expenses":g.prepaidCount+=1;break;case"fixed_assets":g.fixedAssetsCount+=1;break;case"accrued_expenses":g.accruedCount+=1}})),g})(t.jeSchedules.pendingReviewSchedules),qi[x],C??null),I==="flux_analysis"&&ee.trackFluxAnalysisPage(d.month,d.year,R,Yi(t.fluxAnalysis),C??null),I==="month_end_insights"&&t.auditSummary?.auditScorePercentage!=null&&ee.trackInsightsEmailPage(d.month,d.year,R,"draft",t.auditSummary.auditScorePercentage,null,C??null)}),[d,t,x]);return o.useEffect((()=>{(l!==S.fetchState||I!==i||I==="je_schedules"&&r!=null&&x!==r)&&S.fetchState==="Completed"&&v(!1)}),[I,S.fetchState,i,x,r]),v},Yi=t=>t.sections.generalExpense.vendors.length+t.sections.reimbursement.vendors.length,{common:{strings:{hyphen:Wi,comma:$n,space:Hi}},dateFormat:ha}=la.getLocalizedStrings(),zn=Bc,Ki=io((function(t,a){const{uncategorizedAccounts:S,vendorSearchAutoCompleteData:I,monthEndInsightsCustomerRequestData:d,monthEndInsightsPreviewMode:i,companyId:l,isMissingReceiptsBulkUploadEnabled:x,isTransactionActivityEnabled:r,newScheduleActiveType:v}=a,R=Je.getSignedInUser(),C=t.tenantState.currentTenantId,h={userId:R?.userId??"",sessionId:R?.zeniSessionId??"",tenantId:C??""},g=Fe(t),{selectedTransactionCategorizationTab:D}=g,{searchTransactionsResults:B,searchTransactionsFetchState:V}=as(t),b=v==="prepaid_expenses"?"prepaid_expenses":"fixed_assets",{accountListNestedAccountHierarchy:u,classListNestedAccountHierarchy:y,allDepreciationAccountListNestedAccountHierarchy:p,newScheduleLocalData:E,saveStatus:_}=os(t,b);return{expenseAutomationViewSelector:g,accountListNestedAccountHierarchy:u,allDepreciationAccountListNestedAccountHierarchy:p,baseTransactionSearchFetchState:V,baseTransactionSearchResults:B,classListNestedAccountHierarchy:y,newScheduleLocalData:E,initialSelectedBaseTransaction:E.selectedBaseTransactionId!=null?ss(t.transactionState,cs(E.selectedBaseTransactionId)):void 0,newAccrualAccountsView:is(t),newScheduleSaveStatus:_,bulkUploadSelector:x===!0?g.missingReceipts.bulkUpload:void 0,vendorSearchAutoCompleteData:I,authParams:h,receiptUploadEndpoint:`${Ne.accountMicroServiceBaseUrl}`,transactionAttachmentsEndpoint:`${Mt}/transaction_attachments`,bulkUploadEndpoint:x===!0?`${Ne.communicationAgentMicroServiceBaseUrl}/1.0/receipts/bulk-upload`:void 0,isDisabled:!1,currentTab:D,selectedTransactionGroup:g.transactionView.selectedTransactionGroup,monthEndInsightsCustomerRequestData:d,monthEndInsightsPreviewMode:i,allThreadsSectionOpen:!1,enableMonthEndInsightsZeniGPTFeature:!1,loggedInUser:R,uncategorizedAccounts:S,companyId:l,isTransactionActivityEnabled:r,receiptsEmail:rs(t.tenantState,C),downloadParams:{authParams:h,jeScheduleEndPoint:`${Mt}/jeScheduleReports`,timezone:ls(),companyName:ye(t).companyName}}}),(function(t,a){const{themeState:S,isAccountingClassesEnabled:I,isCOTEnabled:d,isMissingReceiptsBulkUploadEnabled:i,location:l,vendorSearchAutoCompleteData:x,expenseAutomationViewSelector:r,currentTenant:v,newScheduleActiveType:R,uncategorizedAccounts:C,navigate:h,onClickCustomerRequest:g,handleEditClick:D,closeSchedulePanel:B,isSchedulePanelOpen:V,openSchedulePanel:b,setActivityLogTransactionId:u}=a,{selectedPeriod:y,currentSelectedView:p,reconciliation:{selectedAccountId:E}}=r,{accountSettingsView:_}=r.jeSchedules,j=Zn(y),f=mt(j.start),U=mt(j.end);return{onZeniLogoClick:()=>{S.toggle()},onUploadReceiptAttachment:e=>{ee.trackMissingReceiptAttached(y.month,y.year),t(Pc(e))},onUploadTransactionReceipt:(e,n,c,m,k,P)=>{t(wn(e,n,{fetchState:"In-Progress"}));const F=()=>t(wn(e,n,{fetchState:"Error"}));di(`${Ne.accountMicroServiceBaseUrl}/1.0/transactions/${n}/attachments`,P,n,c,m,k).then((z=>{z!=null?t(yc(e,z)):F()})).catch(F)},onMissingReceiptsRowClick:(e,n)=>{if(a.openTransactionPanel)return void a.openTransactionPanel(e,n);const c=Z(l.state?.pathnameStackToGoBack,l.pathname);h(`../../transaction/${n}/${e}`,{state:{pathnameStackToGoBack:c,message:"expenseAutomation",origin:"missing_receipts"}})},onUploadReceiptComplete:(e,n)=>{t(Tc(e,n)),v!=null&&t(De({tenantId:v.tenantId,period:n,refreshViewInBackground:!0}))},onUploadReceiptFetchStatus:(e,n,c,m)=>{t(bc(e,{fetchState:n,error:c})),c!=null&&t(Rt({messageSection:"missing_receipts_attachment",messageText:"failed",type:"error",showStatusIcon:!0,variables:[{variableName:"__message__",variableValue:m!=null?Hi+Wi+m+$n:$n}]}))},onUpdateJESchedulesUIState:e=>{const n=r.jeSchedules.uiState,c=e.selectedPageTab!=null&&e.selectedPageTab!==n.selectedPageTab,m=e.selectedJETypeFilter!==void 0&&e.selectedJETypeFilter!==n.selectedJETypeFilter;c&&a.closeMatchSidePanel?.(),V===!0&&(c||m)&&B?.(),e.createdGroupCollapsed!=null?t(fc()):e.pendingGroupCollapsed!=null?t(gc()):e.failedGroupCollapsed!=null?t(Ic()):e.selectedJETypeFilter!==void 0?t(Cc(e.selectedJETypeFilter)):t(kc(e))},onUpdateMissingReceiptsUIState:e=>{t(Sc(e))},onFetchMissingReceiptsList:()=>{U!=null&&f!=null&&t(na({start:f,end:U},{amount:75,currencyCode:"USD",currencySymbol:"$"},!0,!1))},...i===!0?{onBulkUploadFiles:e=>{t(Uc(e))},onBulkUploadProgress:e=>{t(Oc(e))},onBulkUploadSuccess:e=>{t(Mc({batchId:e}))},onBulkUploadUploadedFileCount:e=>{t(_c(e))},onConfirmBulkUploadMatch:(e,n,c,m,k)=>{t(Fc(e,n,c,m,k))},onBulkUploadConfirmMatchAcknowledged:()=>{t(Dc())},onSetBulkUploadResultsTab:e=>{t(wc(e))},onSetBulkUploadCompletedSubTab:e=>{t(Rc(e))},onSetBulkUploadSortConfig:(e,n)=>{t(Dn({sortKey:e,sortOrder:n}))},onClearBulkUpload:()=>{t(xc())},onSearchTransactionsForManualMatch:(e,n)=>{t(zn(e,n??void 0))},onLoadMoreManualSearch:()=>{const{manualSearch:e}=r.missingReceipts.bulkUpload;e.nextPageToken!=null&&e.searchQuery!==""&&t(zn(e.searchQuery,e.nextPageToken))},onFetchCompletedTransactions:(e,n)=>{t(Ac(e,n))},onClearBulkUploadBatchDetailsForScopeChange:()=>{t(Ec())},onFetchBulkUploadBatches:e=>{t(ea(e))},onFetchMoreBatchDetails:()=>{t(vc())},onResetBulkUploadSort:()=>{t(Dn({sortKey:void 0,sortOrder:void 0}))}}:{},onClearMissingReceiptsTabNavigation:()=>{t(hc())},onSearchTextChanged:e=>{const n=r.currentSelectedView,c=r.selectedTransactionCategorizationTab;n==="transaction_categorization"&&(t(Pt({selectedTab:c,uiState:{searchString:e}})),U!=null&&f!=null&&t(be(c,{start:f,end:U},!0,!1,e,void 0,!1,!0)))},onFiltersChange:e=>{const n=r.selectedTransactionCategorizationTab;t(pc({filters:e,selectedTab:n}))},onRefresh:()=>{a.trackExpenseAutomationTabAnalytics(!0),t(mc())},onClose:()=>{p==="reconciliation"&&E!=null&&t(Rn({selectedAccountId:void 0})),h("../")},onBack:()=>{p==="reconciliation"&&E!=null&&t(Rn({selectedAccountId:void 0}))},onSaveReconciliation:e=>{t(uc(e))},onSaveReconciliationReview:e=>{t(dc(e))},onUpdateStep:e=>{const{selectedPeriod:n}=r,c=Z(l.state?.pathnameStackToGoBack,l.pathname);h(`../${e}/${n.month}-${n.year}`,{state:{pathnameStackToGoBack:c,referrer:r.currentSelectedView}}),t(ta(e))},handleLogOutClick:()=>{const e=Z(l.state?.pathnameStackToGoBack,l.pathname);h("/signout",{replace:!0,state:{pathnameStackToGoBack:e,message:"logout"}})},onJeAccountSettingsChange:e=>{const{vendorsAccountSection:n}=e,{prepaidExpensesAccount:c,fixedAssetsAccount:m,accruedExpensesAccount:k}=n,P=vt(_.prepaidExpensesAccountList,c.selectedOptions),F=vt(_.fixedAssetsAccountList,m.selectedOptions),z=vt(_.accruedExpensesAccountList,k.selectedOptions),H={selectedPrepaidExpensesAccountIds:P.map((K=>K.accountId)),selectedFixedAssetsAccountIds:F.map((K=>K.accountId)),selectedAccruedExpensesAccountIds:z.map((K=>K.accountId))};t(rc({data:H}))},onSaveJeAccountSettingsClick:()=>{t(lc())},onJESchedulesFormDataChange(e,n){const{jeScheduleID:c,accumulatedDepreciationCategory:m,scheduleClass:k,scheduleExpenseCategory:P,vendor:F}=n,{allAccountList:z,allClassList:H,allDepreciationAccountList:K}=r.jeSchedules,oe=x.entityAutoCompleteView.vendor.length>0?x.entityAutoCompleteView.vendor.find((L=>L.id===F?.selectedOption)):void 0,te={id:oe?.zeniId??F?.selectedOption??"",name:oe?.name??F?.defaultOptions.find((L=>L.value===F?.selectedOption))?.label??"",logo:oe?.logo},ue=P?.selectedOption!=null?z.find((L=>L.qboId===P.selectedOption)):void 0,A=k?.selectedOption!=null?H.find((L=>L.classId===k.selectedOption)):void 0,$=m?.selectedOption!=null?K.find((L=>L.qboId===m.selectedOption)):void 0;t(ic({scheduledJournalEntryID:e,localData:{jeScheduleID:c,scheduledJournalEntryID:e,updatedCategoryId:ue?.accountId,updatedClassId:A?.classId,updatedAccumulatedDepreciationCategoryID:$?.accountId,updatedVendor:{id:te.id,name:te.name}}}))},onRevertJeSchedule(e,n,c,m,k){t(cc(e,n,c,m,k))},ignoreRecommendedJeSchedule(e,n,c,m){t(sc(e,n,c,m))},vendorSearchAutoCompleteActions:{onAutoCompleteInputChange:(e,n)=>{e.trim().length>=2?t(Pn({searchString:e,entityType:n,searchOrigin:"common"})):e.trim().length===0&&t(ct("common"))},onCancelAutoComplete:()=>{t(ct("common"))}},onPostJESchedule(e,n){t(oc({scheduledJournalEntryID:e,jeScheduleTransactionKey:n}))},clearJeScheduleLocalData(){t(ac())},onViewTransaction(e){if(a.tenantEmailDomain==null)return;const n=wi(e,a.tenantEmailDomain),c=Z(a.location.state?.pathnameStackToGoBack,`${a.location.pathname}${a.location.search}`);a.navigate(n,{state:{pathnameStackToGoBack:c,message:"expenseAutomation",origin:"je_schedules"}})},onSearchBaseTransaction(e){t(nc({query:e,scheduleType:R==="prepaid_expenses"?"prepaid_expenses":"fixed_assets"}))},onNewScheduleFormChange(e,n){const c=Ft(e)==="prepaid_expenses"?"prepaid_expenses":"fixed_assets";t(xn({scheduleType:c,localData:n}))},onOpenMatchNewModal(){t(tc())},onIgnoreMatchSuggestion(e,n,c){t(ec(e,n,c))},onCloseMatchNewModal(){t(Zs())},onClearMatchNewModal(){t(Qs())},onSearchMatchTransactions(e,n){t(Xs(e,n))},onSearchMatchAccruals(e,n){t(Ks(e,n))},onMatchAndReverse(e){t(Hs(e.transactionId,e.transactionIntegrationId,e.transactionType,e.lineIds,e.transactionSyncToken,e.accrualIds,!0))},onUpdateActualMatchingUIState(e){t(Ws(e))},onUndoReversal(e,n){t(Ys(e,n))},onSaveSchedule(e,n){const c=e==="prepaid_expenses"?"prepaid_expenses":"fixed_assets",{allAccountList:m,allDepreciationAccountList:k}=r.jeSchedules,P=n.selectedAccount!=null?m.find((z=>z.qboId===n.selectedAccount)):void 0,F=n.selectedAccumulatedDepreciationCategory!=null?k.find((z=>z.qboId===n.selectedAccumulatedDepreciationCategory)):void 0;t(xn({scheduleType:c,localData:{...n,selectedAccount:P?.accountId,selectedAccumulatedDepreciationCategory:F?.accountId}})),t(Js({scheduleType:c}))},onCreateAccruedSchedule(e){const n="accrued_expenses";t(zs()),t(Ls()),t(Gs({scheduleType:n,localData:e,selectedJeScheduleDetailId:void 0})),t(Ns({scheduleType:n})),t(qs(n,void 0))},onCreateOneTimeAccrual(e){t($s(e))},handleJeScheduleClick:(e,n,c)=>{if((function(k,P){return P!=="accrued_expenses"})(0,c)&&t(Qn({selectedJEScheduleKey:n})),b!=null&&pa(c))return void b(e,c,n);const m=Z(l.state?.pathnameStackToGoBack,l.pathname);h(`../../vendors/schedules/${c}/details/${e}`,{state:{pathnameStackToGoBack:m,message:"expenseAutomation",origin:"je_schedules"}})},onOneTimeAccrualFeedback:(e,n,c,m)=>{t(n!=="revert"?js(e,c,m):Vs(e,c,m))},onOneTimeAccrualClick:e=>{if(b!=null)return void b(e,"one_time_accrual");const n=Z(l.state?.pathnameStackToGoBack,l.pathname);h(`../../vendors/schedules/one_time_accrual/details/${e}`,{state:{pathnameStackToGoBack:n,message:"expenseAutomation",origin:"je_schedules"}})},onOpenMatch:e=>{a.openMatchPanel?.(e)},onOpenBill(e){if(a.tenantEmailDomain==null)return;const n=bi(e,a.tenantEmailDomain,a.location);a.navigate(n.pathname,{state:n.state})},improveMonthEndInsightsUsingZeniGPTClick:e=>{v!=null&&t(Bs(e,v.companyId,v.tenantId))},onClickCustomerRequest:g,setActivityLogTransactionId:u,onCloseAllThreadsSection:()=>{},onCloseFileAttachmentSnackBar:()=>{t(Us())},onOpenFileAttachmentSnackBar:()=>{t(Rt({messageSection:"cockpit_month_end_email_attachment_upload",messageText:"failed",type:"error",showStatusIcon:!0}))},onRemoveFileAttachment:e=>{t(Os(e))},onUpdateFileAttachment:e=>{t(Ms({files:e}))},previewMonthEndReport:(e,n,c,m,k)=>{v!=null&&t(An(e,v.companyId,n,!0,c,m,{agentInsightEdits:k,tenantId:v.tenantId}))},saveMonthEndReport:(e,n,c,m,k)=>{v!=null&&t(An(e,v.companyId,n,!1,c,m,{agentInsightEdits:k,tenantId:v.tenantId}))},onEditMonthEndInsightsClick:D,sendMonthEndReport:e=>{const n=l.state?.referrer,{selectedPeriod:c,auditSummary:m}=r;v!=null&&m?.auditScorePercentage!=null&&(t(_s(v.companyId,e,v.tenantId)),ee.trackInsightsEmailPage(c.month,c.year,!1,"draft",m.auditScorePercentage,aa().format(ha.analytics.MMMDDCommaYYYYformat),n??null))},onTransactionCategorizationRowClick:(e,n)=>{const c=r.transactionView.uiState.searchString??"",m=r.transactionView.transactions,k=m.findIndex((z=>z.id===e)),P=c.length>0?{resultPosition:k>=0?k+1:void 0,resultsCount:m.length,searchTerm:c}:void 0;if(a.openTransactionPanel)return void a.openTransactionPanel(e,n,P);const F=Z(l.state?.pathnameStackToGoBack,l.pathname);h(`../../transaction/${n}/${e}`,{state:{pathnameStackToGoBack:F,message:"expenseAutomation",origin:"transaction_categorization",searchContext:P}})},setLocalDataForCategoryAndClass:(e,n,c,m,k,P,F,z,H,K,oe,te)=>{t(Fs(e,n,c,m,C,k,P,F,z,H,K,oe,te))},onCancelAutoComplete:()=>{t(ct("common"))},updateExpenseAutomationReconListScrollPosition:e=>{t(vn({scrollPosition:e}))},onUpdateTab:e=>{a.closeSidePanel?.(),U!=null&&f!=null&&(t(be(e,{start:f,end:U},!1,!1)),t(Ds(e)))},onUpdateTransactionCategorizationCompletedSubTab:e=>{a.closeSidePanel?.(),U!=null&&f!=null&&(t(ws(e)),t(be("autoCategorized",{start:f,end:U},!1,!1)))},onTransactionGroupChange:e=>{a.closeSidePanel?.(),U!=null&&f!=null&&(t(Rs(e)),t(be(a.expenseAutomationViewSelector.selectedTransactionCategorizationTab,{start:f,end:U},!1,!1)))},onUpdateTransactionCategorizationUIState:(e,n)=>{t(Pt({selectedTab:e,uiState:n})),U!=null&&f!=null&&t(be(e,{start:f,end:U},!1,!1,n.searchString,null,!0))},onUpdateScrollYOffSetTransactionCategorizationUIState:(e,n)=>{t(Pt({selectedTab:e,uiState:n}))},onFetchTransactionCategorizationList:(e,n,c,m,k,P)=>{U!=null&&f!=null&&t(be(e,{start:f,end:U},!0,c,n,m,k,P))},resetTransactionCategorizationLocalData:(e,n,c,m,k,P,F)=>{t(xs(e,n,c,m,F??null,k,P,!1)),Ii(t,n.map(String))},updateSelectedVendorForTransaction:(e,n,c,m,k)=>{t(En({selectedTab:e,transactionId:n,lineId:c,selectedTransaction:m,uncategorizedAccounts:C,updatedVendor:k,isAccountingClassesEnabled:I}))},onSaveUpdateTransactionCategorization:(e,n,c)=>{const m=l.state?.referrer;e==="autoCategorized"?ee.trackTransactionsAutoCategorisedPage(y.month,y.year,r.transactionView.totalCountByTab.autoCategorized,n.length,!1,m??null):ee.trackTransactionsReviewPage(y.month,y.year,r.transactionView.totalCountByTab.review,n.length,!1,m??null),t(As(e,n,c)),gi(n.map(String))},onUpdateSelectedCheckboxTransactionIds:(e,n)=>{t(Es({selectedTab:e,transactionIds:n}))},onFetchRecommendationsForEntityCategorizationWithCustomer:(e,n,c,m,k,P)=>{const{transactionId:F,transaction:z,lineIds:H}=n;P!=null&&t(Ps({transactionId:F,customerUpdates:P})),t(vs({selectedTab:m,transactionId:F.id,lineId:H[0],selectedTransaction:z,uncategorizedAccounts:C,updatedCustomer:P,selectedEntity:k,isAccountingClassesEnabled:I})),k!=null&&t(Dt({entity:k,amount:e,transactionDetails:n,flowType:"categorization",selectedTab:m,isFetchCOT:d}))},onFetchRecommendationsForEntityCategorization:(e,n,c,m,k,P)=>{const{transactionId:F,transaction:z,lineIds:H}=n;P!=null&&(t(bs({transactionId:F,vendorUpdates:{name:P.name,id:P.id?P.id:void 0}})),t(Ts({vendorId:P.id?P.id:void 0,localData:{vendorName:P.name,vendorId:P.id?P.id:void 0}}))),P?.id?(t(En({selectedTab:m,transactionId:F.id,lineId:H[0],selectedTransaction:z,uncategorizedAccounts:C,updatedVendor:P,selectedEntity:k,isAccountingClassesEnabled:I})),k!=null&&t(Dt({entity:k,amount:e,transactionDetails:n,flowType:"categorization",selectedTab:m,isFetchCOT:d}))):t(ys({selectedTab:m,transactionId:F.id,lineId:H[0]}))},fetchFluxViewOnScroll:(e,n)=>{t(rt(e,!0,!1,n,!1,!0))},onFetchFluxViewList:()=>{t(rt(y,!0,!1,null,!1,!1))},markAsReview:(e,n,c,m)=>{ee.trackFluxAnalysisReviewed(c.month,c.year,m??!1,e),t(ks(n,e,c,m??!1))},onUpdateFluxAnalysisUIState:e=>{t(Cs(e))},updateOperatingExpensesIdsForReview:e=>{t(Is({operatingExpenseIds:e,selectedPeriod:y}))},redirectToVendorDetailPage:e=>{if(a.tenantEmailDomain!=null){const n=Ri(e.id,e.qboId,a.tenantEmailDomain),c=Z(a.location.state?.pathnameStackToGoBack,a.location.pathname);a.navigate(n,{state:{pathnameStackToGoBack:c,message:"expenseAutomation",referrer:"Vendor List",origin:"flux_analysis"}})}},updateSectionIdsForReview:e=>{t(gs({sectionId:e,selectedPeriod:y}))},onFetchReimbursementView:(e,n,c)=>{t(rt(e,!0,!1,n,!0,c))},onReviewClicked:e=>{t(re(y,e))},onViewReportClicked:e=>{const n=a.tenantEmailDomain,c=p,m=`${y.month}-${y.year}`;if(n==null||c==null)return;const k=Z(l.state?.pathnameStackToGoBack,l.pathname),P=ra({tenantEmailDomain:n,selectedTab:c,accountId:e,period:m});P!=null&&h(P,{state:{pathnameStackToGoBack:k}})},setOpenDrawerClicked:e=>{t(ut({selectedDrawerAccountId:e}))},onFetchLinkTokenClick:(e,n)=>{t(Hn("expense_automation_reconcile",e,n))},onEstablishConnectionClick:(e,n)=>{const c=v?.companyId;c!=null&&(t(Kn(e,c,"expense_automation_reconcile",void 0,"link_account_no_microdeposit",n)),t(Xn({accountId:n,connectionInProgress:!0})))},onAddStatementClick:e=>{t(ut({selectedDrawerAccountId:e})),t(it({accountId:e,selectedPeriod:y,localData:{accountSource:"bank_statement"}})),t(lt({statementUploadChosen:!0}))},onReloadReconciliationListPage:()=>{t(re(y,void 0,!0,!1))},onUpdateReconcileTabLocalData:e=>{t(fs({selectedTransactionIds:e}))},onReconTabColumnSortConfigChanged:(e,n)=>{t(Ss({sortKey:e,sortOrder:n}))},onReconReviewTabColumnSortConfigChanged:(e,n)=>{t(hs({sortKey:e,sortOrder:n}))},onReconTabUpdate:e=>{a.closeSidePanel?.(),t(ps({selectedTab:e}))},updateReconReviewTabLocalData:(e,n,c)=>{const m=e.vendor?.id;c&&m!=null&&t(us(m)),t(ms({data:e,transactionId:n}))},onReconMatchedTransactionClick:e=>{if(a.openTransactionPanel)return void a.openTransactionPanel(e,wt("bill"));const n=Z(l.state?.pathnameStackToGoBack,l.pathname);h(`../../transaction/bill/${e}`,{state:{pathnameStackToGoBack:n,message:"expenseAutomation",origin:"reconciliation"}})},onReloadPage:()=>{window.location.reload()},onBackClick:()=>{h(-1)},onReconListPageScroll:e=>{t(vn({scrollPosition:e}))},onVendorAutoCompleteInputChange:e=>{e.trim().length>=2?t(Pn({searchString:e,searchOrigin:"common"})):e.trim().length===0&&t(ct("common"))},onReconNodeCollapseToggled:(e,n)=>{t(ds({nodeId:e,collapsed:n}))},updateSectionCollapseStatus:()=>{},onExcludeAccountFromReconciliation:e=>{t(Yn({accountId:e}))},onIncludeAccountIntoReconciliation:e=>{t(Wn({accountId:e}))}}}),((t,a,S)=>{const{isMissingReceiptsBulkUploadEnabled:I,...d}=S;return(function(i,l,x){return{...i,...l,...x,onUploadTransactionReceipt:(r,v,R,C,h)=>{l.onUploadTransactionReceipt(r,v,R,C,h,i.authParams)}}})(t,a,d)}))(li(ri)),Et="newScheduleMode",At="newScheduleType",Xi=Gi(yi((function(t){const a=t.displayName??t.name??"Component",S=oa.memo(t),I=d=>{const i=Se(),l=(function(){const b=Se(),u=O((y=>Fe(y).reconciliation.selectedDrawerAccountId));return{isOpen:u!=null,selectedAccountId:u,openPanel:o.useCallback((y=>{b(ut({selectedDrawerAccountId:y}))}),[b]),closePanel:o.useCallback((()=>{b(ut({selectedDrawerAccountId:void 0}))}),[b])}})(),x=O((b=>Fe(b).reconciliation)),r=O((b=>ye(b))),v=o.useCallback(((b,u)=>{i(Hn("expense_automation_reconcile",b,u))}),[i]),R=o.useCallback(((b,u)=>{const y=r?.companyId;y!=null&&(i(Kn(b,y,"expense_automation_reconcile",void 0,"link_account_no_microdeposit",u)),i(Xn({accountId:u,connectionInProgress:!0})))}),[i,r?.companyId]),C=o.useMemo((()=>{if(l.isOpen&&l.selectedAccountId!=null)return T.jsx(Bi,{reconciliation:x,selectedDrawerAccountId:l.selectedAccountId,onClose:l.closePanel,onFetchLinkTokenClick:v,onEstablishConnectionClick:R})}),[l.isOpen,l.selectedAccountId,l.closePanel,x,v,R]),h=o.useMemo((()=>({reconPanelContent:C,reconSidePanelIsOpen:l.isOpen,closeReconSidePanel:l.closePanel})),[C,l.isOpen,l.closePanel]),{useFeatureGate:g}=qe(),{isFeatureEnabled:D}=g(X.isReconV3Enabled),B=o.useContext(On),V=o.useMemo((()=>l.isOpen?D===!0?{selectedItemId:l.selectedAccountId}:{closePanel:l.closePanel,selectedItemId:l.selectedAccountId}:B),[l.isOpen,l.closePanel,l.selectedAccountId,B,D]);return T.jsx(On.Provider,{value:V,children:T.jsx(S,{...d,...h})})};return I.displayName=`withReconSidePanel(${a})`,I})(Ui((({closeMatchSidePanel:t,closeReconSidePanel:a,closeSidePanel:S,matchPanelContent:I,isMatchPanelOpen:d,matchPanelMatchId:i,openMatchPanel:l,openTransactionPanel:x,panelContent:r,reconPanelContent:v,reconSidePanelIsOpen:R,isSchedulePanelOpen:C,closeSchedulePanel:h,openSchedulePanel:g,schedulePanelContent:D,schedulePendingDiscardConfirmation:B,sidePanelIsFullView:V,sidePanelIsOpen:b})=>{const{isAiCfoOpen:u,setIsAiCfoOpen:y}=Hc(),p=Kc(),{isOpen:E}=Xc(),_=_e(),j=fe(),f=Se(),{isAiCfoAccessEnabled:U,onAskAiCfoClick:e}=Bt({mobileExploreReferrer:"Transaction categorization"}),n=o.useCallback((()=>{d===!0&&t?.(),b===!0&&V!==!0&&S?.()}),[t,S,d,V,b]),c=O(jo);o.useEffect((()=>{c!=null&&(i===c&&n(),f($o()))}),[c,n,f,i]);const m=O(zo);o.useEffect((()=>{m!=null&&(i===m&&n(),f(Lo()))}),[m,n,f,i]);const{areTenantIdsInSync:k}=sa(),P=Ji(),F=Qc(),[z,H]=o.useState(!1),[K,oe]=qn(),te=o.useCallback((s=>{oe((M=>{const W=new URLSearchParams(M);return s==null?(W.delete(Et),W.delete(At),W):(W.set(Et,s.scheduleDetailsMode),W.set(At,s.scheduleType),W)}),{replace:!0})}),[oe]),[ue,A]=o.useState(void 0),$=o.useCallback(((s,M,W)=>{const Y=Ft(s);A(Y),te({scheduleDetailsMode:M,scheduleType:s}),f(bn({scheduleType:Y==="prepaid_expenses"?"prepaid_expenses":"fixed_assets",shouldResetEnteredData:W}))}),[f,te]),L=o.useMemo((()=>{const s=K.get(Et),M=K.get(At);return s!=null&&M!=null?{scheduleDetailsMode:s,scheduleType:M}:void 0}),[K]),ge=o.useCallback((s=>{te(s),s!=null&&f(bn({scheduleType:Ft(s.scheduleType)==="prepaid_expenses"?"prepaid_expenses":"fixed_assets",shouldResetEnteredData:!0}))}),[f,te]),Ye=O((s=>kn(s))),q=O((s=>ye(s))),[pt,Oe]=o.useState(!1),[We,Pe]=o.useState(!1),[He,Ke]=o.useState([]),[se,me]=o.useState(null),ce=o.useCallback((()=>{me(null)}),[]),Ue=se?.contentType==="activity"?se.detail.transactionId:void 0,w=o.useCallback((s=>{s!=null?(u&&y(!1),p(),n(),me({contentType:"activity",detail:{transactionId:s}})):me((M=>M?.contentType==="activity"?null:M))}),[n,u,p,y]),Q=o.useCallback((s=>{u&&y(!1),p(),n(),me({contentType:"transfer",detail:s})}),[n,u,p,y]),ae=o.useCallback((()=>{p(),ce(),n(),e()}),[n,ce,e,p]),ve=o.useRef(u);o.useEffect((()=>{u===!0&&ve.current===!1&&(p(),ce(),n()),ve.current=u}),[n,ce,u,p]);const Ee=o.useRef(E);o.useEffect((()=>{E===!0&&Ee.current===!1&&(u&&y(!1),ce(),d===!0&&t?.(),b===!0&&V!==!0&&S?.()),Ee.current=E}),[ce,t,S,E,u,d,y,V,b]);const Xe=b===!0&&V!==!0||d===!0,jt=o.useRef(Xe);o.useEffect((()=>{Xe&&!jt.current&&(u&&y(!1),p(),ce()),jt.current=Xe}),[ce,u,Xe,p,y]);const[$t,Sa]=o.useState(!1),zt=o.useRef(!1),{selectedTab:fa}=Te(),{tenantEmailDomain:ht}=Te(),[St,Lt]=o.useState(j.state?.message==="comingFromTransactionDetail"),Gt=j.state?.message==="comingFromOverview",ga=Zc(),ft=Je.getSignedInUser(),{useFeatureGate:de}=qe(),{isFeatureEnabled:Nt}=de(X.isRealtimeInsightsFeatureEnabled),{isFeatureEnabled:Be}=de(X.isMissingReceiptsBulkUploadEnabled),{isFeatureEnabled:gt}=de(X.isTransactionActivityEnabled),{isFeatureEnabled:Ie}=de(X.isAccrualEnabled),{isFeatureEnabled:qt}=de(X.isCreateTransferEntryFromExpenseEnabled),{isFeatureEnabled:Ia}=de(X.isProjectsTransactionsEnabled),{isFeatureEnabled:Ca}=de(X.isReconV3Enabled),{isFeatureEnabled:ka}=de(X.isReconReportEnabled),ba=o.useCallback((s=>{const M=wt(s.transactionType??(s.view==="reconciliation"?"bill":"expense")),W=Z(j.state?.pathnameStackToGoBack,j.pathname),Y=new URLSearchParams({view:"full"});s.threadId!=null&&Y.set("thread_id",s.threadId),s.entityType!=null&&Y.set("entity_type",s.entityType),_(`/${ht}/transaction/${encodeURIComponent(M)}/${s.transactionId??s.entityId}?${Y.toString()}`,{state:{pathnameStackToGoBack:W,message:"expenseAutomation"}})}),[_,ht,j.state,j.pathname]),Ta=O((s=>Go(s,"common"))),J=O((s=>Fe(s))),{categoryOptions:ya,paymentAccountNames:Pa}=O((s=>No(s.accountState))),va=O((s=>qo(s.classState))),{monthEndCloseChecksView:ne,currentSelectedView:G,selectedPeriod:N,selectedTransactionCategorizationTab:It,currentSelectedViewBackgroundRefreshFetchState:Ea,currentSelectedViewFetchState:pe,jeSchedules:Ct,reconciliation:Jt}=J;pi(G==="transaction_categorization");const Aa=J.transactionView.saveStatus.fetchState,Qe=J.transactionView.transactions,Yt=o.useRef(Qe);Yt.current=Qe;const Wt=O((s=>s.expenseAutomationTransactionsViewState?.transactionCategorizationView)),Ht=O((s=>s.expenseAutomationTransactionsViewState?.selectedTransactionCategorizationTab)),Kt=o.useRef(Wt);Kt.current=Wt;const Xt=o.useRef(Ht);Xt.current=Ht;const Ze=O((s=>{const M=s.expenseAutomationTransactionsViewState?.selectedTransactionCategorizationTab;return M!=null?s.expenseAutomationTransactionsViewState?.transactionCategorizationView?.[M]?.filters:void 0})),Qt=o.useRef("");o.useEffect((()=>{if(G!=="transaction_categorization")return;const s=J.transactionView.uiState.searchString??"";if(pe.fetchState!=="Completed"||s.length===0||s===Qt.current)return;Qt.current=s;const M=Ze!=null?ei(Ze):0,W=Ze?.categories.filter((Y=>Y.values.length>0&&String(Y.values[0]??"").trim()!=="")).map((Y=>`${Y.field}:${Y.values.join(",")}`))??[];ee.trackAiCloseTransactionSearch({filtersApplied:W,hasResults:Qe.length>0,isFiltered:M>0,resultsCount:Qe.length,searchTerm:s,searchType:"free_text"})}),[G,pe.fetchState,J.transactionView.uiState.searchString,J.transactionView.transactions,Ze]);const he=hi(Aa,(()=>{const s=[],M=Xt.current,W=Kt.current,Y=W!=null&&M!=null?W[M]:void 0;if(Y?.transactionReviewLocalDataById!=null)for(const xe of Object.values(Y.transactionReviewLocalDataById)){const ie=xe?.transactionReviewLocalData?.lineItemById;if(ie!=null)for(const kt of Object.values(ie)){const Le=kt?.account;Le?.accountId!=null&&s.push(Le.accountId)}}const Ae=Yt.current;for(const xe of Ae)for(const ie of xe.lines??[])"account"in ie&&ie.account?.accountId!=null&&s.push(ie.account.accountId);return s}));o.useEffect((()=>{G==="transaction_categorization"&&b!==!0||w(void 0)}),[G,w,b]),o.useEffect((()=>{R===!0&&a?.()}),[G,Jt.selectedAccountId]);const xa=J.transactionView.selectedTransactionCategorizationCompletedSubTab,Ra=J.transactionView.selectedTransactionGroup,et=`${It}|${xa}|${Ra}`,tt=o.useRef(null),Zt=o.useRef(null);o.useEffect((()=>{tt.current!==null?tt.current!==et&&(tt.current=et,G==="transaction_categorization"&&ce()):tt.current=et}),[ce,G,et]);const wa=O((s=>Ue==null?void 0:Jo(s.transactionState,Ue))),Ce=wa?.qboId,en=O((s=>Ce==null?void 0:Yo(s,Ce)));o.useEffect((()=>{Ce!=null&&f(Wo(Ce))}),[f,Ce]);const{createTransferEntryStatus:tn,creditCardTransferAccountsList:nn,transferAccounts:an}=J.transactionView,on=o.useCallback((s=>Si(f,s)),[f]),sn=o.useMemo((()=>G!=="transaction_categorization"||se==null?null:se.contentType==="activity"?gt===!0?T.jsx(ti,{activityLogView:en,qboId:Ce,onClose:()=>me(null),selectedTransactionId:se.detail.transactionId,isQuickViewCardStyle:!0},String(se.detail.transactionId)):null:se.contentType==="transfer"?T.jsx(ni,{createTransferEntryStatus:tn,creditCardTransferAccountsList:nn,transaction:se.detail,transferAccounts:an,onClose:()=>me(null),onCreateTransfer:on,isQuickViewCardStyle:!0},String(se.detail.transactionId)):null),[G,se,gt,en,Ce,tn,nn,an,on]),Da=sn!=null,{selectedAccountId:Ve}=Jt,cn=dt(Ct.accountSettingsView.saveState.fetchState),Fa=O((s=>Ho(s.accountState,s.accountListState,"accountList"))),_a=O((s=>Ko(s))),je=da(fa)??G,Ma=O((s=>s.entityAutoCompleteState.autoCompleteText.common));if(ca({isDataReady:pe.fetchState==="Completed"}),ft==null)throw Error("Can't access expense automation screen without signing in...");const ln=Zn(N),$e=mt(ln.start),ze=mt(ln.end);if($e==null||ze==null)throw Error(`Invalid start - ${$e} and end - ${ze} period from given ${N}`);const Oa=o.useCallback((()=>{Oe(!1)}),[]),Ua=o.useCallback((()=>{Pe(!0)}),[]),Ba=o.useCallback((s=>{Ke(s),Pe(!1)}),[]),Va=o.useCallback((()=>{Ke([])}),[]),nt=J.missingReceipts.bulkUpload.phase,rn=J.missingReceipts.bulkUpload.currentBatchId;o.useEffect((()=>{Be===!0&&G==="missing_receipts"&&nt==="matching"&&rn!=null&&f(ea({cacheOverride:!0}))}),[Be,G,nt,rn,f]);const dn=ft?.userId,ja=N.month,$a=N.year,un=q?.tenantId;o.useEffect((()=>{G==="missing_receipts"&&Be!==!1&&nt==="idle"&&dn!=null&&un!=null&&f(Xo())}),[G,Be,nt,dn,un,ja,$a,f]),o.useEffect((()=>{Ye.newVendorState?.vendorDetailLocalData?.vendorName!=null?H(!0):H(!1)}),[Ye.newVendorState?.vendorDetailLocalData?.vendorName]),o.useEffect((()=>{je!=null&&G!==je&&f(ta(je))}),[je]),o.useEffect((()=>{$t===!1&&pe.fetchState==="Completed"&&k&&(Sa(!0),f(Tn(!1,!1,Ie===!0)))}),[$t,pe,k,Ie]),o.useEffect((()=>{const s={month:N.month,year:N.year},M=Zt.current;Zt.current=s,M===null||M.month===s.month&&M.year===s.year||!Gt&&k&&(f(Tn(!1,!1,Ie===!0)),f(re(N,Ve,!1,!1)))}),[N.month,N.year,k,Ie]);const at=o.useCallback(((s=!1,M=!1)=>{const W={start:$e,end:ze};switch(G){case"transaction_categorization":f(be(It,W,s,!St,void 0,void 0,M)),Lt(!1);break;case"flux_analysis":f(rt(N,s,M,null));break;case"month_end_insights":if(M===!1){const Y=new Date(N.year,N.month,0),Ae=Zo(Y.toDateString()).format(ha.analytics.YYYYDashMMDashDDFormat);f(es(!0,q.companyId,q.tenantId,Ae)),f(ts(q.companyId,q.tenantId))}break;case"je_schedules":f(Qo(W,M,Ie===!0));break;case"missing_receipts":f(na(W,{amount:75,currencyCode:"USD",currencySymbol:"$"},s,M));break;default:f(re(N,Ve,s,M))}}),[G,$e,ze,q.companyId,q.tenantId,It,N,Ve,St,Lt,Ie]),za=o.useCallback((()=>{at(!0,!0)}),[at]);o.useEffect((()=>{G===je&&pe.fetchState==="Not-Started"&&k&&at(!0)}),[pe,$e,ze,q.companyId,q.tenantId,k]),o.useEffect((()=>{Gt||St||zt.current||Ea.fetchState==="In-Progress"||pe.fetchState!=="Completed"||(zt.current=!0,at(!0,!0))}),[]),o.useEffect((()=>{ne.fetchState!=="In-Progress"&&ne.fetchState!=="Completed"&&ne.fetchState!=="Error"&&q?.tenantId!=null&&f(De({tenantId:q.tenantId,period:N,refreshViewInBackground:!1}))}),[ne.fetchState,q?.tenantId]),o.useEffect((()=>{ne.fetchState!=="Completed"||!k||(ne.monthEndCloseChecks?.monthEndCloseCheckList.some((s=>s.id==="reconciliation"))??!1)&&J.reconciliation.fetchStatus.fetchState==="Not-Started"&&f(re(N,void 0,!1,!1))}),[ne.fetchState,k,N.month,N.year,J.reconciliation.fetchStatus.fetchState,f]),o.useEffect((()=>{J.monthEndInsights?.previewMonthEndReportStatus?.fetchState==="Completed"?Oe(!0):Oe(!1)}),[J.monthEndInsights?.previewMonthEndReportStatus?.fetchState]),o.useEffect((()=>{J.monthEndInsights?.sendMonthEndReportStatus?.fetchState==="Completed"&&k&&(f(De({tenantId:q.tenantId,period:N,refreshViewInBackground:!0})),f(ns({companyId:q.companyId})),_("../"))}),[J.monthEndInsights?.sendMonthEndReportStatus?.fetchState,q.tenantId,N,q.companyId,k]),o.useEffect((()=>{const s=setInterval((()=>{ne.fetchState!=="In-Progress"&&ne.fetchState==="Completed"&&f(De({tenantId:q.tenantId,period:N,refreshViewInBackground:!0}))}),3e5);return()=>clearInterval(s)}),[ne.fetchState,q.tenantId,N,f]),o.useEffect((()=>{const s=setInterval((()=>{G==="reconciliation"&&Ve==null&&J.reconciliation.fetchStatus.fetchState==="Completed"&&J.reconciliation.refreshStatus.fetchState!=="In-Progress"&&f(re(N,void 0,!0,!0))}),3e5);return()=>clearInterval(s)}),[G,f,J.reconciliation.fetchStatus.fetchState,J.reconciliation.refreshStatus.fetchState,re,Ve,N]);const La=Un(),{isFeatureEnabled:Ga}=de(X.isRecommendationFeedbackEnabled),mn=ai(),{onRecommendationSelection:pn,popup:Na}=fi({isEnabled:Ga}),qa=o.useMemo((()=>({...mn,onRecommendationSelection:pn})),[mn,pn]);o.useEffect((()=>{const s=(ne.monthEndCloseChecks?.monthEndCloseCheckList.find((M=>M.id==="month_end_insights"))?.isDisabled??!1)&&!Nt;G!=="month_end_insights"||!s&&ne.monthEndCloseChecks?.reportEmailSentDate==null||_("../")}),[G,ne.monthEndCloseChecks]);const Ja=R===!0?v:r,Ya=R===!0||b===!0,Wa=R===!0?a:S,Ha=R!==!0&&V;o.useEffect((()=>{cn==="In-Progress"&&Ct.accountSettingsView.saveState.fetchState==="Completed"&&f(yn())}),[cn,Ct.accountSettingsView.saveState.fetchState,yn]);const{transactionId:hn,onSaveVendor:Ka,onSaveSuccess:Xa,onCancel:Qa,vendorViewDetails:Za}=(({expenseAutomationViewSelector:s,closeDrawerHandler:M,currentSelectedView:W})=>{const Y=Se();let Ae,xe,ie;const kt=Un(),Le=s.transactionView;let Sn=()=>{};const{transactions:eo,selectedTransactionId:Re,selectedTransactionLineId:ot,transactionLocalData:to}=Le;if(W==="transaction_categorization"){const bt=to.find((ke=>ke.transactionId===Re)),le=eo.find((ke=>ke.id===Re)),fn=ot!=null?bt?.transactionReviewLocalData?.lineItemById[ot]:void 0,gn=fn?.account;xe=fn?.class?.classId,Ae=["Uncategorized Income","Uncategorized Expense"].includes(gn?.accountName??"")?void 0:gn?.accountId;const ao=xi(Re,le?.typeOfTransaction);le!=null&&ao&&(ie={id:Re,type:wt(le.typeOfTransaction)}),Sn=()=>{if(Re!=null&&ot!=null&&le!=null){const ke=Le.transactionLocalData.find((st=>st.transactionId===Re))?.transactionReviewLocalData;if(ke!=null&&le.lines!=null&&le.lines.length>0){const st=ke.lineItemById[ot];let Tt=ke.selectedEntity;if(Vo(le)||(Tt=st.selectedEntityLine),Tt!=null){const oo=Tt,so={transactionId:{id:le.id,type:le.type},transaction:le,lineIds:le.lines.map((co=>co.id))??[]};Y(Dt({entity:oo,amount:st.amount.amount,transactionDetails:so,flowType:"categorization",selectedTab:s.selectedTransactionCategorizationTab,isFetchCOT:kt}))}}}}}const no=O((bt=>kn(bt,void 0,Ae,xe)));return{transactionId:ie,onSaveVendor:()=>{Y(Bo(ie,void 0,!1,!0))},onSaveSuccess:Sn,onCancel:()=>{ie!=null&&Y(Mo({transactionId:ie})),Y(Oo()),Y(Uo()),M()},vendorViewDetails:no}})({expenseAutomationViewSelector:J,closeDrawerHandler:()=>{H(!1)},currentSelectedView:G});return ga?.loggedInUserRoleMap==null?ne.fetchState==="Error"?T.jsx(oi,{onGoHome:()=>_("../",{replace:!0}),onReload:()=>window.location.reload()}):T.jsx(ia,{fetchState:"In-Progress"}):T.jsxs(T.Fragment,{children:[T.jsx(Di,{isOpen:We,drawerLeftMargin:new si(0,0,300,650),onClose:()=>{Pe(!1)},children:T.jsx(Qi,{onClick:s=>s.stopPropagation(),children:T.jsx(Ni,{companyId:q.companyId,closeCustomerRequestDrawer:()=>Pe(!1),addCustomerRequest:Ba,resetCustomerRequest:Va})})}),hn!=null&&z&&T.jsx(Ci,{isOpen:z,transactionId:hn,onSaveVendor:Ka,onSaveSuccess:Xa,onCancel:Qa,vendorViewDetails:Za}),T.jsx(ci,{toolkit:qa,children:T.jsx(Ki,{events:[],eventCallback:(s,M,W)=>{},navigate:_,location:j,themeState:F,categoryOptions:ya,classesForFilters:va,accountsForFilters:Pa,vendorSearchAutoCompleteData:{autoCompleteText:Ma,entityAutoCompleteView:Ta},expenseAutomationViewSelector:J,isMissingReceiptsBulkUploadEnabled:Be,monthEndInsightsPreviewMode:pt,monthEndInsightsCustomerRequestData:He,isRealtimeInsightsFeatureEnabled:Nt,isCreateTransferEntryFromExpenseEnabled:qt,isAccountingClassesEnabled:_a,isProjectsTransactionsEnabled:Ia,isCOTEnabled:La,currentTenant:q,companyId:q.companyId,signedInUser:ft,isTransactionActivityEnabled:gt,isRightPanelOpen:Da,rightSidePanel:sn,onOpenTransferRightPanel:qt===!0?Q:void 0,uncategorizedAccounts:Fa,newScheduleActiveType:ue,isAccrualEnabled:Ie,newScheduleSelection:L,onNewScheduleSelectionChange:ge,onScheduleTypeChange:$,onNewScheduleSaved:za,onClickCustomerRequest:Ua,handleEditClick:Oa,tenantEmailDomain:ht,trackExpenseAutomationTabAnalytics:P,setActivityLogTransactionId:w,closeMatchSidePanel:t,closeSidePanel:Wa,openTransactionPanel:x,closeSchedulePanel:h,openSchedulePanel:g,openMatchPanel:l,sidePanelIsOpen:Ya,sidePanelIsFullView:Ha,panelContent:Ja,isAiCfoAccessEnabled:U,onAskAiCfoClick:ae,isReconReportEnabled:ka===!0,isReconV3Enabled:Ca,onExpenseAutomationCommentingThreadClick:ba,sidePanelListPercent:R===!0?66:void 0,isMatchPanelOpen:d,isSchedulePanelOpen:C,matchPanelContent:I,schedulePanelContent:D,schedulePendingDiscardConfirmation:B})}),Na,he.showPopup&&he.popupType!=null&&T.jsx(ii,{popupType:he.popupType,currencySymbol:he.currencySymbol,accountId:he.popupAccountId??"",accountName:he.popupAccountName??"",onSubmit:he.handleSubmit,onDismiss:he.handleDismiss})]})}))))),Qi=Me(zc)`
35
+ display: flex;
36
+ min-height: 100%;
37
+ flex-direction: column;
38
+ `;async function Zi({authParams:t,endpoint:a,fileType:S,report:I}){const d=await fetch(a,{method:"POST",headers:{"Content-Type":"application/json","zeni-user-id":t.userId,"zeni-tenant-id":t.tenantId,"zeni-session-id":t.sessionId},body:JSON.stringify({report:I,file_type:S,locale_id:"en-US"})});if(!d.ok)throw new Error(`Reconciliation report download failed: ${d.statusText}`);const i=S==="pdf"?"Reconciliation_Report.pdf":"Reconciliation_Report.xlsx",l=(function(x,r){return x==null?r:/filename="?([^"]+)"?/i.exec(x)?.[1]??r})(d.headers.get("Content-Disposition"),i);(function(x,r){const v=new Blob([x]),R=URL.createObjectURL(v),C=document.createElement("a");C.href=R,C.download=r,document.body.appendChild(C),C.click(),document.body.removeChild(C),URL.revokeObjectURL(R)})(await d.arrayBuffer(),l)}const el=new Set(["reconciled","reconciled_on_qbo"]),{dateFormat:{analytics:{MMSlashDDSlashYYYYFormat:Ln}}}=la.getLocalizedStrings();function we(t){return`${t.month}-${t.year}`}function Gn(t){if(!Ot(t))return;const[a,S]=t.split("-"),I=Number(a),d=Number(S);return Number.isNaN(I)||Number.isNaN(d)?void 0:{month:$c(I),year:d}}function Nn(t){const a=aa().set("year",t.year).set("month",t.month-1).startOf("month"),S=a.endOf("month");return`${a.format(Ln)} – ${S.format(Ln)}`}function tl(){const{tenantEmailDomain:t,selectedTab:a}=Te(),[S,I]=qn(),d=_e(),i=fe(),l=Se(),x=Bt({mobileExploreReferrer:"reconciliation_report"}),[r,v]=o.useState("Not-Started"),[R,C]=o.useState(void 0),h=S.get("accountId")??void 0,g=S.get("period")??void 0,D=O((A=>ye(A))),B=O((A=>Fe(A))),V=O((A=>Jn(A,D.tenantId))),b=O((A=>Vc(A))),u=B.reconciliation.fetchStatus.fetchState,y=B.reconciliation.accountReconciliationsByAccountID,p=B.reconciliation.monthYearPeriod,E=o.useMemo((()=>g!=null?Gn(g):void 0),[g]),_=o.useMemo((()=>{const A=(V.monthEndCloseChecks?.historicMonthYear??[]).map((L=>({periodId:we(L),label:Nn(L)})));if(E==null)return A;const $=we(E);return A.some((L=>L.periodId===$))?A:[{periodId:$,label:Nn(E)},...A]}),[V.monthEndCloseChecks?.historicMonthYear,E]),j=E!=null&&p.month===E.month&&p.year===E.year,f=o.useMemo((()=>{const A=Object.values(y).filter((L=>{return ge=L.accountReconEntity.reconciliationStatus?.code,ge!=null&&el.has(ge);var ge})).map((L=>({accountId:L.accountReconEntity.account.accountId,label:_t(L)})));if(h==null||A.some((L=>L.accountId===h)))return A;const $=y[h];return[{accountId:h,label:$!=null?_t($):h},...A]}),[h,y]),U=o.useMemo((()=>{if(h!=null&&j===!0)return y[h]?.accountReconEntity.reconciliationId}),[h,y,j]),e=E!=null?Fn(E):void 0,n=e!=null&&b[e]!=null&&b[e].accountIDs.length>0,c=E!=null&&(j!==!0||u==="In-Progress"||n!==!0&&u!=="Completed"&&u!=="Error"),m=c!==!0&&j===!0&&U==null&&(h!=null||f.length===0),k=O((A=>U!=null?jc(A,U):void 0)),P=o.useCallback((A=>{const $=new URLSearchParams;A.accountId!=null&&A.accountId!==""&&$.set("accountId",A.accountId),Ot(A.period)&&$.set("period",A.period),I($,{replace:!0})}),[I]);o.useEffect((()=>{const A=E??p;D.tenantId!=null&&A!=null&&V.fetchState!=="In-Progress"&&V.fetchState!=="Completed"&&V.fetchState!=="Error"&&l(De({tenantId:D.tenantId,period:A,refreshViewInBackground:!1}))}),[D.tenantId,l,V.fetchState,E,p]),o.useEffect((()=>{E!=null&&j!==!0&&l(xt(D.tenantId,E))}),[D.tenantId,l,E,j]),o.useEffect((()=>{if(E==null||j!==!0||u==="In-Progress")return;const A=Fn(E),$=b[A];!($!=null&&$.accountIDs.length>0)&&l(re(E,void 0,!0,!1))}),[l,u,b,E,j]),o.useEffect((()=>{E!=null&&j===!0&&f.length!==0&&h==null&&P({accountId:f[0].accountId,period:we(E)})}),[h,f,E,P,j]),o.useEffect((()=>{U!=null&&l(_n(U))}),[l,U]);const F=o.useCallback((()=>{const A=ui(i.state?.pathnameStackToGoBack),$=g??(p!=null?we(p):void 0),L=Vt({tenantEmailDomain:t,selectedTab:a,selectedPeriod:$})??`/${t??""}/month_end_close_checks/review`;d(A.poppedPathname??L,{state:{pathnameStackToGoBack:A.newStack}})}),[i.state,d,g,p,a,t]),z=o.useCallback((()=>{U!=null&&l(_n(U,!0))}),[l,U]),H=o.useCallback((A=>{if(k?.report==null||R!=null)return;const $=Je.getSignedInUser();C(A),v("In-Progress"),Zi({endpoint:`${Mt}/reconciliation_report`,fileType:A,report:k.report,authParams:{userId:$?.userId??"",sessionId:$?.zeniSessionId??"",tenantId:D.tenantId}}).then((()=>{v("Completed")})).catch((()=>{v("Error")})).finally((()=>{C(void 0)}))}),[D.tenantId,R,k?.report]),K=o.useCallback((A=>{E!=null&&P({accountId:A,period:we(E)})}),[E,P]),oe=o.useCallback((A=>{const $=Gn(A);$!=null&&(l(xt(D.tenantId,$)),l(re($,void 0,!0,!1)),P({accountId:h,period:A}))}),[h,D.tenantId,l,P]);if(g==null||!Ot(g)||E==null)return T.jsx(Ut,{});const te=h??f[0]?.accountId??k?.report?.account.accountId??"",ue=c?"In-Progress":m===!0?"Completed":k?.fetchState??"Not-Started";return T.jsx(mi,{accountOptions:f,periodOptions:_,selectedAccountId:te,selectedPeriodId:we(E),fetchState:ue,isReportNotFound:m,report:k?.report,downloadingFileType:R,downloadState:r,onAccountChange:K,onPeriodChange:oe,onBackClick:F,onDownloadClick:H,onRetry:z,onAskAiCfoClick:x.isAiCfoAccessEnabled===!0?x.onAskAiCfoClick:void 0})}function nl(){const t=fe(),{selectedTab:a,tenantEmailDomain:S}=Te(),I=O((l=>ye(l))),d=O((l=>l.expenseAutomationViewState.selectedPeriodByTenantId[I.tenantId]));if(da(a)==null)return T.jsx(Ut,{});const i=Vt({tenantEmailDomain:S,selectedTab:a,selectedPeriod:d!=null?`${d.month}-${d.year}`:void 0});return i==null?null:T.jsx(ro,{to:i,replace:!0,state:t.state})}function Fl(){return T.jsxs(lo,{children:[T.jsx(Ge,{index:!0,element:T.jsx(Fi,{})}),T.jsx(Ge,{path:"/:selectedTab/report",element:T.jsx(tl,{})}),T.jsx(Ge,{path:"/:selectedTab/:selectedPeriod/*",element:T.jsx(Xi,{})}),T.jsx(Ge,{path:"/:selectedTab",element:T.jsx(nl,{})}),T.jsx(Ge,{path:"*",element:T.jsx(Ut,{})})]})}export{Fl as default};
@@ -0,0 +1 @@
1
+ import{j as s}from"./liveblocks-DOdRxZ-H.js";import{a as r}from"./sentry-DvoFEQx8.js";import{au as f,av as i,Z as l,a2 as p}from"./index-Cvus_VBr.js";import"./mui-ZKvbmPSP.js";import m from"./NotFoundScreen-BR0tBeJN.js";import{h as b,g as u}from"./core-R1zvmcG1.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new e.Error().stack;a&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[a]="c5cccb90-93ef-49b9-9d2f-d25df6a7e6b3",e._sentryDebugIdIdentifier="sentry-dbid-c5cccb90-93ef-49b9-9d2f-d25df6a7e6b3")}catch{}})();const _=()=>{const e=b(),a=u(),t=r.useCallback((()=>{window.open("https://www.zeni.ai/demo/request","_blank")}),[]),d=r.useCallback((()=>{(()=>{const n=p(a.state?.pathnameStackToGoBack),c=n.poppedPathname??k();e(c,{state:{pathnameStackToGoBack:n.newStack}})})()}),[]),o=f(a.pathname);return o!=null?s.jsx(i,{menuItem:l(o),onDemoClick:t,onGoBack:d}):s.jsx(m,{})},k=(e=2)=>{let a="../";for(let t=0;t<e;t++)a=`${a}../`;return a};export{_ as F};
@@ -0,0 +1 @@
1
+ import{a as i}from"./sentry-DvoFEQx8.js";import{u as l,h as f,g as m}from"./core-R1zvmcG1.js";import{i0 as p,V8 as g,V9 as _}from"./zeni-epic-state-Mdu-dKQU.js";import{u as b,L as h,z as y}from"./index-Cvus_VBr.js";import"./liveblocks-DOdRxZ-H.js";import"./recharts-UmMlzZlF.js";import"./mui-ZKvbmPSP.js";import"./analytics-BE49_JfE.js";import"./plaid-tDbexfSh.js";import"./dnd-LSyMQh_7.js";import"./stripe-cKAAJElX.js";import"./lottie-Z_NAxrmn.js";import"./lexical-BG-nDmQN.js";import"./pdf-_w1KRTSP.js";import"./utils-D06mHID-.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]="a48ab914-268c-45f4-8c38-e3b31f5837ea",e._sentryDebugIdIdentifier="sentry-dbid-a48ab914-268c-45f4-8c38-e3b31f5837ea")}catch{}})();function V(){const e=l(),n=f(),r=m(),{setLoading:o,clearAllLoading:d}=b(),a=i.useRef(!1);return i.useLayoutEffect((()=>{o(h.CONNECTION_AUTH)}),[o]),i.useEffect((()=>{if(a.current)return;a.current=!0;const s=new URLSearchParams(r.search).get("code"),c=sessionStorage.getItem("hubspot_oauth_pending");if(sessionStorage.removeItem("hubspot_oauth_pending"),s!=null&&c!=null){const t=JSON.parse(c);e(p(t.tenant_id,t.connection_id,g("revenue"),_("hubspot"),{authorization_code:s,client_id:t.client_id,client_secret:t.client_secret,redirect_uri:t.redirect_uri}))}d();const u=y.getActiveTenantForUser();n(u?.tenantEmailDomain!=null?`/${u.tenantEmailDomain}/settings/integrations`:"/",{replace:!0})}),[]),null}export{V as default};
@@ -1 +1 @@
1
- import{n as s}from"./liveblocks-CFpJ3lBt.js";import{j as c}from"./core-B4xcCWwD.js";import{fI as f}from"./zeni-epic-state-z7dEhSaI.js";import"./sentry-DXRU_0Gm.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-DOdRxZ-H.js";import{j as c}from"./core-R1zvmcG1.js";import{fI as f}from"./zeni-epic-state-Mdu-dKQU.js";import"./sentry-DvoFEQx8.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,3 @@
1
+ import{j as c}from"./liveblocks-DOdRxZ-H.js";import{a as r}from"./sentry-DvoFEQx8.js";import{u as L,h as P,i as w,j as E,t as ie,l as O,s as z,g as oe,N as H,n as ue,o as x}from"./core-R1zvmcG1.js";import{a6 as st,l as g,ao as F,K as l,ca as rt,cb as dt,cc as lt,cd as ut,ce as gt,cf as mt,cg as vt,ch as pt,ci as ft,cj as St,ck as It,cl as ht,p as ae,cm as Ct,cn as kt,z as ne,ac as ve,co as Et,cp as yt,cq as bt,cr as xt,cs as At,ct as Dt,cu as jt,cv as Lt,cw as Pt,cx as $t,V as _t,ag as pn,cy as wt,cz as Rt,cA as Ft,cB as Tt,cC as Ot,cD as Mt,cE as Nt,cF as Ut,cG as Bt,cH as Vt,cI as Ht,t as en,j as Ue,cJ as qt,cK as Qt,cL as zt,cM as Kt,cN as Gt,cO as Wt,cP as Jt}from"./index-Cvus_VBr.js";import"./mui-ZKvbmPSP.js";import{A as X}from"./AddressScreen-C0JLhAcE.js";import M from"./NotFoundScreen-BR0tBeJN.js";import{_o as Yt,_p as Xt,vw as nn,v as Zt,_q as Z,w7 as pe,_r as Be,_s as W,wK as $e,wR as ei,dX as fn,wV as Sn,_t as Ve,wO as ni,yu as tn,w6 as on,_u as In,_v as J,x4 as _e,x8 as ti,_w as ii,xi as oi,_x as hn,xb as Cn,z2 as ai,_y as he,_z as an,_A as kn,w2 as ci,_B as si,vW as ri,_C as di,yH as li,_D as En,yQ as be,_E as ui,yN as gi,_F as He,gk as qe,_G as de,_H as le,xq as mi,wc as cn,wh as yn,wf as vi,w9 as pi,xj as fi,wj as Si,xs as Ii,c_ as bn,_I as we,xB as xn,xz as Q,xx as G,xw as hi,_J as fe,yX as xe,_K as Ci,w4 as An,_L as Qe,fI as Ce,ws as Re,wp as Fe,wC as Dn,wB as ze,wm as ki,wv as jn,wE as ge,W9 as Ln,w8 as Ke,wz as Ei,wA as yi,wy as bi,_M as xi,x9 as Ai,x5 as Pn,_N as $n,vN as Ae,_O as Di,vG as ji,_P as Li,z1 as Pi,z6 as K,z0 as $i,y8 as ke,_Q as _i,_R as _n,zf as De,_S as wi,zc as Ri,_T as wn,yb as Fi,yc as q,yf as Ti,_U as Rn,yp as je,_V as Oi,xr as Fn,UH as Tn,_W as Mi,yz as Ni,_X as On,_Y as sn,_Z as Ui,__ as Bi,A2 as Vi,_$ as Hi,$0 as Mn,zm as Nn,$1 as Un,A0 as Le,$2 as qi,zZ as Qi,$3 as zi,$4 as Ki,$5 as Gi,$6 as Wi,$7 as Ji,$8 as rn,$9 as Yi,ei as Xi,A6 as Zi,$a as Ge,xL as eo,xG as no,d0 as Te,$b as ee,xP as Bn,xX as Vn,$c as We,xQ as te,y0 as to,y3 as Hn,$d as io,$e as Oe,x$ as oo,$f as qn,zR as Pe,zM as ao,$g as co,zr as so,$h as ro,zS as lo,zW as uo,$i as Je,wM as Qn,zD as go,wN as mo,$j as vo,$k as zn,c9 as po,mw as fo,mx as So,$l as dn,wL as Se,go as Io,mD as ho,zJ as Kn,Ai as Co,zG as Gn,v2 as ko,uS as Eo,hW as yo,V8 as ln,V9 as bo,GJ as Wn,Af as xo,hO as Ao,Ac as Do,$m as jo,$n as Lo,Ao as Po,An as $o,$o as _o,$p as Jn,Al as wo,$q as Ro,$r as Fo,yD as To,$s as Oo}from"./zeni-epic-state-Mdu-dKQU.js";import{M as Mo}from"./MobileAppDrawer-CPwvCIYa.js";import{q as Ie}from"./QBOConnectionScreen-Dn2zy1VD.js";import"./recharts-UmMlzZlF.js";import"./analytics-BE49_JfE.js";import"./plaid-tDbexfSh.js";import"./dnd-LSyMQh_7.js";import"./stripe-cKAAJElX.js";import"./lottie-Z_NAxrmn.js";import"./lexical-BG-nDmQN.js";import"./pdf-_w1KRTSP.js";import"./utils-D06mHID-.js";import"./InboxNotificationsProvider--Aami2sh.js";import"./useTaskManagerAccess-CcPTnvTg.js";import"./empty-CtFP9XJw.js";import"./pdf-lib-Ctu1umZQ.js";import"./index-DhHwwWlj.js";import"./url-CxALZHMf.js";import"./index-LeoAhFsn.js";import"./decodeURIComponentSafe-D4d600vS.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]="a212c258-7614-4211-a595-f1ce25e64bd6",t._sentryDebugIdIdentifier="sentry-dbid-a212c258-7614-4211-a595-f1ce25e64bd6")}catch{}})();const _=({event:t,isReady:e=!0})=>e?c.jsx(st,{analytics:g,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function No(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),{fetchState:m,hasMore:f,items:S,nextCursor:I,auditLogEntityRouteOptions:C,auditLogListSortFieldOptions:h}=E(Yt),y=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),D=`/${n??""}/invoicing`,b=r.useCallback(((R,U)=>{const T=Xt(D,R,U,C);T!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{entity:R,entityId:U,fromScreen:"audit_log",toScreen:R}),e(T))}),[C,e,D]);r.useEffect((()=>{const R=setTimeout((()=>u(a)),300);return()=>clearTimeout(R)}),[a]),r.useEffect((()=>{i&&t(nn({filters:y,keepExistingListItems:!1,sort:v}))}),[i,y,v,t]);const A=m==="Not-Started"||m==="In-Progress"&&S.length===0,k=m==="In-Progress"&&S.length>0,j=m==="Completed";return N(m)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingAuditLogPage,isReady:j}),c.jsx(rt,{auditLogEntityRouteOptions:C,auditLogListSortFieldOptions:h,entries:S,hasMore:f,isLoading:A,isLoadingMore:k,searchValue:a,sortState:d,onEntityLinkClick:b,onLoadMore:()=>{f&&I!=null&&t(nn({cursor:I,filters:y,keepExistingListItems:!0,sort:v}))},onSearchChange:o,onSortChange:p})]})}const Yn=["company","email","firstName","invoiceNotes","lastName","notes","phone","vatNumber"],Me=t=>typeof t=="string"||typeof t=="number"||typeof t=="boolean"?t:Array.isArray(t)?t.map(Me):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).map((([e,n])=>[e,Me(n)]))):null;function B(t,e,n=[]){const i=t,a=e,o=[...new Set([...Object.keys(i),...Object.keys(a??{})])].filter((u=>{if(a==null)return(d=i[u])!=null&&d!==""&&(Array.isArray(d)?d.length>0:typeof d!="object"||Object.keys(d).length>0);var d;return!(i[u]==null&&a[u]==null)&&!Zt(i[u],a[u])})).sort(),s=Object.fromEntries(o.filter((u=>!n.includes(u))).map((u=>[u,Me(i[u])])));return{fieldsChanged:o,formValues:s}}function Ee(t,e=!1){const n=L(),i=E((s=>Z(s).productNextCursor!=null)),a=E((s=>Z(s).productNextCursor)),o=E((s=>Z(s).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&o!=="Not-Started"||n(pe({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&o!=="In-Progress"&&i&&a!=null&&n(pe({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,o,i,a])}function ce(t,e,n,i){const[a,o]=r.useState(0),[s,u]=r.useState(!1),d=r.useRef(t);return r.useEffect((()=>{const p=d.current==="In-Progress";d.current=t,t==="Completed"&&p&&n!=null&&(u(!0),i(n))}),[t,n,i]),r.useEffect((()=>{s&&!e&&(u(!1),o((p=>p+1)))}),[s,e]),a}const Uo=new Set(["plan"]),Bo=O((function(t,e){const{view:n}=e;return{applicableItemOptions:n.applicableItemOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboClassHierarchy:n.qboClassHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:n.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",itemId:e.itemId,localData:n.localData,plan:n.plan}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${n}/catalog`),onLifecycleAction:i!==""?a=>{i!==""&&(g.trackInvoicingActionClick(l.Event.invoicingCatalogItemLifecycleAction,{action:a,fromScreen:"catalog_item_detail",itemId:i}),t(ni({action:a,id:i})))}:void 0,onEditChange:a=>{i!==""&&t(Ve({id:i,localData:a}))},onSaveEdit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemEdited,{itemId:i,mode:"edit",...B(e.view.localData,fn(e.view.plan))}),t(Sn({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&t(ei({action:o,id:a,parentItemId:i}))}}}))(dt);function Vo(){const t=L(),e=P(),{item_id:n,tenantEmailDomain:i}=w(),[a]=ie(),{areTenantIdsInSync:o}=F(),s=(u=a.get("kind"))!=null&&Uo.has(u)?u:"plan";var u;const d=E((y=>Be(y,n))),{pageFetchState:p}=d,v=p.fetchState;r.useEffect((()=>(t(W({id:n})),()=>{t(W({id:n}))})),[t,n]),r.useEffect((()=>{o&&t($e({id:n,kind:s}))}),[o,n,s,t]);const m=r.useCallback((y=>t($e({cacheOverride:!0,id:y,kind:s}))),[t,s]),f=ce(d.fetchState,d.isFormLoading,n,m),S=v==="Completed"&&!d.isFormLoading;Ee(o,!0);const[I,C]=r.useState(S?n:void 0);r.useEffect((()=>{n!=null&&S&&C(n)}),[n,S]);const h=I!==n&&(v==="Not-Started"||v==="In-Progress"||d.isFormLoading);return N(v)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingCatalogItemDetailPage,isReady:S}),c.jsx(Bo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:s,isLoading:h,view:d},f)]})}const Ho=new Set(["addon","charge","plan"]),qo=new Set(["plan"]),Qo=O((function(t,e){const n=Be(t,e.itemId);return{fieldHelp:n.fieldHelp,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,applicabilityValues:n.applicabilityValues,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,applicableItemOptions:n.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save catalog item.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedItem:n.plan,pricingModelValues:n.pricingModelValues,prorationValues:n.prorationValues,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,tierTypeValues:n.tierTypeValues}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e,a=i!=null?`${n}/catalog/${encodeURIComponent(i)}`:`${n}/catalog`;return{onBack:()=>{t(W({id:i})),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemFormCancelled),t(W({id:i})),e.navigate(`${n}/catalog`)},onChange:o=>{t(Ve({id:i,localData:o}))},onSubmit:()=>{t(Sn({id:i}))}}}),(function({savedItem:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemSaved,{itemId:i.itemId,mode:e.mode,...B(e.localData,t!=null?fn(t):void 0)}),n.onSubmit()}}}))(lt);function zo(){const t=L(),e=P(),{item_id:n,tenantEmailDomain:i}=w(),[a]=ie(),{areTenantIdsInSync:o}=F(),s=n!=null,u=a.get("type"),d=u!=null&&Ho.has(u)?u:void 0,p=(v=a.get("kind"))!=null&&qo.has(v)?v:"plan";var v;const m=E((S=>Be(S,n)));Ee(o,!0);const f=r.useRef();return r.useEffect((()=>(clearTimeout(f.current),()=>{f.current=setTimeout((()=>{t(W({id:n}))}),0)})),[n,t]),r.useEffect((()=>{o&&t($e({id:n,kind:p}))}),[o,n,p,t]),r.useEffect((()=>{s||d==null||m.localData.catalogType===d||t(Ve({localData:{...m.localData,catalogType:d}}))}),[s,d,m.localData?.catalogType,t]),r.useEffect((()=>{if(m.fetchState==="Completed"){const S=m.savedItemId??n,I=S!=null?`/${i}/invoicing/catalog/${encodeURIComponent(S)}`:`/${i}/invoicing/catalog`;e(I),t(W({id:n}))}}),[m.fetchState,m.savedItemId,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingCatalogItemFormPage}),c.jsx(Qo,{navigate:e,tenantEmailDomain:i,defaultType:d,isEdit:s,itemId:n})]})}const Ko={addons:"addon",all:"item",charges:"charge",plans:"plan"},Go=O((function(t,e){const n=Z(t),i=e.activeTab==="plans",a=e.activeTab==="all",o=i?n.plans:a?[...n.plans,...n.products]:n.products,s=i||a&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:a&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:s==="Not-Started"||s==="In-Progress"&&o.length===0,isLoadingMore:s==="In-Progress"&&o.length>0,planRows:n.planRows,productRows:n.productRows}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",a=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const s=Ko[e.activeTab];g.trackInvoicingActionClick(l.Event.invoicingAddCatalogItemClicked,{itemType:s}),e.navigate(`${n}/catalog/new?type=${s}`)},onItemClick:(s,u)=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemRowClicked,{itemId:u}),e.navigate(`${n}/catalog/${encodeURIComponent(u)}`)},onLoadMore:()=>{if(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"catalog",tab:e.activeTab}),a)return e.planNextCursor!=null&&t(on({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&t(pe({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));o!=null&&t(i?on({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):pe({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(ut);function Wo(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState("plans"),[d,p]=r.useState(""),[v,m]=r.useState(null),f=r.useMemo((()=>v!=null?{dir:v.direction,field:v.columnKey}:void 0),[v]),S=d.trim()!==""?d.trim():void 0,I=r.useMemo((()=>({search:S,type:"plan"})),[S]),C=r.useMemo((()=>({search:S,type:"addon|charge"})),[S]),h=E((j=>Z(j))),y=h.planFilters.search,D=h.planSort,b=h.planNextCursor,A=h.productNextCursor,k=h.fetchState==="Completed";return r.useEffect((()=>{const j=setTimeout((()=>p(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t(tn({cacheOverride:!1,planFilters:I,productFilters:C,planSort:f,productSort:f}))}),[i,t,I,C,f]),r.useEffect((()=>{i&&(S!==y||f?.field!==D?.field||f?.dir!==D?.dir)&&t(tn({cacheOverride:!0,planFilters:I,productFilters:C,planSort:f,productSort:f}))}),[y,D,i,t,I,C,S,f]),N(h.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingCatalogPage,isReady:k}),c.jsx(Go,{navigate:e,tenantEmailDomain:n,activeTab:s,searchValue:a,sortState:v,planFilters:I,productFilters:C,sort:f,planNextCursor:b,productNextCursor:A,onSearchChange:o,onTabChange:u,onSortChange:m})]})}const Jo=O((function(t,e){const n=In(t,e.couponId);return{fieldHelp:n.fieldHelp,applyOnOptions:n.applyOnOptions,discountTypeOptions:n.discountTypeOptions,durationTypeOptions:n.durationTypeOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save coupon.":void 0,isQboConnected:n.isQboConnected,isQboPickerDataLoading:n.isQboPickerDataLoading,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedCoupon:n.coupon,periodUnitOptions:n.periodUnitOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,a=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>{t(J({id:i})),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCouponFormCancelled),t(J({id:i})),e.navigate(`${n}/discounts`)},onChange:o=>{t(ii({id:i,localData:o}))},onSubmit:()=>{t(ti({id:i}))}}}),(function({savedCoupon:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCouponSaved,{couponId:i.couponId,mode:e.mode,...B(e.localData,t!=null?oi(t):void 0)}),n.onSubmit()}}}))(gt);function Yo(){const t=L(),e=P(),{coupon_id:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),{fetchState:o,savedCouponId:s}=E((d=>In(d,n))),u=r.useRef();return r.useEffect((()=>(clearTimeout(u.current),()=>{u.current=setTimeout((()=>{t(J({id:n}))}),0)})),[n,t]),r.useEffect((()=>{a&&t(_e({id:n}))}),[a,n,t]),r.useEffect((()=>{if(o==="Completed"){const d=s??n,p=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(p),t(J({id:n}))}}),[o,s,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingCouponFormPage}),c.jsx(Jo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Xo=O((function(t){const e=hn(t);return{fieldHelp:e.fieldHelp,customers:e.customers,planNames:e.planNames,errorMessage:e.fetchState==="Error"?e.error?.message??"Failed to create invoice. Please try again.":void 0,isSubmitting:e.fetchState==="In-Progress",localData:e.localData,settings:e.settings}}),(function(t){return{dispatch:t}}),(function(t,{dispatch:e},n){const i=`/${n.tenantEmailDomain}/invoicing`;return{...t,onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:a=>{e(kn(a))},onSubmit:()=>{const a=si(t.localData);g.trackInvoicingActionClick(l.Event.invoicingInvoiceCreated,{customerId:a.customer_id,lineItemCount:a.line_items?.length,mode:"create",...B(t.localData,void 0,["memo"])}),e(ri(a))}}}))(vt);function Zo(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),[i]=ie(),{areTenantIdsInSync:a}=F(),o=i.get("customerId"),s=E((b=>hn(b))),u=s.fetchState,d=s.localData,p=s.savedInvoiceId,v=E(Cn),m=E((b=>ai(b))),f=E(he),S=m.fetchState==="Not-Started"||m.fetchState==="In-Progress"&&v==null,I=f.fetchState==="Not-Started"||f.fetchState==="In-Progress"&&f.customers.length===0,C=S||I,h=m.fetchState==="Completed"&&f.fetchState==="Completed";r.useEffect((()=>(t(an()),()=>{t(an())})),[t]);const y=r.useRef(!1);r.useEffect((()=>{y.current||o==null||o===""||d.customerId!==""||(y.current=!0,t(kn({...d,customerId:o})))}),[o,d,t]),r.useEffect((()=>{a&&t(ci({cacheOverride:!1}))}),[a,t]);const D=r.useRef(u);return r.useEffect((()=>{const b=D.current;if(D.current=u,b!=="Completed"&&u==="Completed"){const A=p!=null?`/${n}/invoicing/invoices/${encodeURIComponent(p)}`:`/${n}/invoicing/invoices`;e(A)}}),[u,p,e,n]),c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingCreateInvoicePage,isReady:h}),C?c.jsx(mt,{}):c.jsx(Xo,{navigate:e,tenantEmailDomain:n})]})}const ea=O((function(t,e){const{detailView:n}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:n.creditNote,creditNoteId:e.creditNoteId,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${n}/credits`),onCustomerClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(pt);function na(){const t=L(),e=P(),{credit_note_id:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),o=E((u=>di(u,n??""))),s=o.fetchState==="Completed";return r.useEffect((()=>{a&&n!=null&&t(li({id:n}))}),[a,n,t]),N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingCreditDetailPage,isReady:s}),c.jsx(ea,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:o})]})}const ta=O((function(t){const e=En(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",creditNotes:e.creditNotes,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.creditNotes.length===0,isLoadingMore:n==="In-Progress"&&e.creditNotes.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"credits",status:e.activeStatus}),t(gi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(ft);function ia(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,appliedSort:I,nextCursor:C,creditNoteListFetchState:h}=E((D=>{const b=En(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,creditNoteListFetchState:b.fetchState}}),z),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(be({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(be({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingCreditsListPage,isReady:y}),c.jsx(ta,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,onSearchChange:o,onStatusChange:D=>{t(ui(D)),t(be({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const Xn=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},oa=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(we({id:i,localData:a}))},onCreateInvoice:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onCreatePromotionalCredits:()=>{g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customer_detail"}),e.onCreatePromotionalCredits()},onNewSubscription:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`)},onDiscardEdit:()=>{t(Q(G)),t(hi({id:i}))},onOpenAddress:()=>{const a=Xn(e.tenantEmailDomain??"",G,i),o=ae(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:a=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerEdited,{customerId:i,mode:"edit",...B(a,e.editView.record.invoicingCustomer!=null?bn(e.editView.record.invoicingCustomer):void 0,Yn)}),t(we({id:i,localData:a})),t(xn({id:i}))},onFetchPaymentLinkEmailPreview:a=>t(Ii({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,s)=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentLinkSent,{customerId:i,fromScreen:"customer_detail"}),t(Si({body:s,customerId:i,email:a,subject:o}))},onSubscriptionClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)}}}))(ht);function aa(){const t=L(),e=P(),n=oe(),{customer_id:i,tenantEmailDomain:a}=w(),{areTenantIdsInSync:o}=F(),s=E((T=>He(T,i))),u=s.pageFetchState.fetchState,d=u==="Completed"&&!s.isFormLoading,[p,v]=r.useState(!1),[m,f]=r.useState(!1),[S,I]=r.useState(d?i:void 0);r.useEffect((()=>{i!=null&&d&&I(i)}),[i,d]);const C=S===i,{plaidTokenFetchState:h,promotionalCreditSubmitState:y}=s,{paymentMethodSaveState:D,setupIntentFetchState:b,stripeConnected:A}=s.record,k=r.useRef(s.record.sendLinkState.fetchState);r.useEffect((()=>{const T=s.record.sendLinkState.fetchState;k.current!=="Error"&&T==="Error"&&t(qe({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),k.current=T}),[t,s.record.sendLinkState.fetchState]);const j=b.fetchState==="Error"?b.error?.message??"Failed to start card setup.":D.fetchState==="Error"?D.error?.message??"Failed to save payment method.":h.fetchState==="Error"?h.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(t(de()),t(le()),()=>{t(de()),t(le())})),[t]),r.useEffect((()=>{n.state?.openPromotionalCreditsDialog===!0&&(f(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{o&&i!=null&&t(mi({id:i}))}),[o,i,t]),r.useEffect((()=>{o&&i!=null&&A&&t(cn({customerId:i}))}),[o,i,t,A]);const R=r.useCallback((T=>t(yn({id:T}))),[t]),U=ce(s.fetchState,s.isFormLoading,i,R);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingCustomerDetailPage,isReady:d}),c.jsx(oa,{customerId:i??"",editView:s,hasLoadedRecord:C,location:n,navigate:e,tenantEmailDomain:a,onAddPaymentMethod:()=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentMethodAddClicked,{customerId:i??"",fromScreen:"customer_detail"}),t(de()),i!=null&&A&&t(cn({customerId:i})),v(!0)},onCreatePromotionalCredits:()=>{t(le()),f(!0)}},U),c.jsx(St,{errorMessage:j,isCreatingSetupIntent:b.fetchState==="In-Progress",isSaving:D.fetchState==="In-Progress",open:p,plaidLinkToken:s.record.plaidLinkToken,saveSucceeded:D.fetchState==="Completed",setupIntent:s.record.setupIntent,stripeConnected:A,onChooseCard:()=>{i!=null&&t(pi({customerId:i}))},onClose:()=>{v(!1),t(de())},onSavePaymentMethod:T=>{i!=null&&(g.trackInvoicingActionClick(l.Event.invoicingPaymentMethodSaved,{customerId:i,fromScreen:"customer_detail"}),t(vi({customerId:i,data:T})))}}),c.jsx(It,{currentBalance:s.record.invoicingCustomer?.promotionalCredits,currencyCode:s.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:y.fetchState==="Error"?y.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:y.fetchState==="In-Progress",open:m,submitSucceeded:y.fetchState==="Completed",onClose:()=>{f(!1),t(le())},onSubmit:({amount:T,description:re})=>{i!=null&&(g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsAdded,{amount:T,customerId:i,fromScreen:"customer_detail"}),t(fi({amount:T,customerId:i,currencyCode:s.record.invoicingCustomer?.preferredCurrencyCode,description:re})))}})]})}const ca=O((function(t,e){const n=He(t,e.customerId);return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save customer.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedCustomer:n.record.invoicingCustomer}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,a=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>{t(fe({id:i})),t(Q(G)),e.navigate(a)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerFormCancelled),t(fe({id:i})),t(Q(G)),e.navigate(`${n}/customers`)},onChange:o=>{t(we({id:i,localData:o}))},onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"customer",fromScreen:"customer_form"});const o=Xn(e.tenantEmailDomain??"",G,i),s=ae(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.keepDraftOnLeave(),e.navigate(o,{state:{pathnameStackToGoBack:s}})},onSubmit:()=>{t(xn({id:i}))}}}),(function({savedCustomer:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerSaved,{customerId:i.customerId,mode:e.mode,...B(e.localData,t!=null?bn(t):void 0,Yn)}),n.onSubmit()}}}))(Ct);function sa(){const t=L(),e=P(),n=oe(),{customer_id:i,tenantEmailDomain:a}=w(),{areTenantIdsInSync:o}=F(),{fetchState:s,savedCustomerId:u}=E((m=>He(m,i))),d=r.useRef(!1),p=r.useCallback((()=>{d.current=!0}),[]),v=r.useRef();return r.useEffect((()=>(clearTimeout(v.current),d.current=!1,()=>{d.current||(v.current=setTimeout((()=>{t(fe({id:i})),t(Q(G))}),0))})),[i,t]),r.useEffect((()=>{o&&i!=null&&t(yn({id:i}))}),[o,i,t]),r.useEffect((()=>{if(s==="Completed"){const m=u??i,f=m!=null?`/${a}/invoicing/customers/${encodeURIComponent(m)}`:`/${a}/invoicing/customers`;e(f),t(fe({id:i}))}}),[s,u,i,t,e,a]),c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingCustomerFormPage}),c.jsx(ca,{customerId:i,keepDraftOnLeave:p,location:n,navigate:e,tenantEmailDomain:a})]})}const ra=O((function(t){const e=he(t),{fetchState:n}=e;return{addressesById:t.addressState.addressesById,columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",customers:e.customers,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.customers.length===0,isLoadingMore:n==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,a)=>{switch(a){case"createInvoice":g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":g.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"customers",status:e.activeStatus}),t(An({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(kt);function da(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,appliedSort:I,nextCursor:C,customerListFetchState:h}=E((D=>{const b=he(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,customerListFetchState:b.fetchState}}),z),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(xe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(xe({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingCustomersListPage,isReady:y}),c.jsx(ra,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,onSearchChange:o,onStatusChange:D=>{t(Ci(D)),t(xe({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const Ne=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),la=O((function(t,e){const{authParams:n,csvDownloadUrl:i,filters:a,sessionId:o,view:s}=e,u=o==null?void 0:s.diagnosticsBySession[o],d=u?.fetch.fetchState??"Not-Started";return{authParams:n,csvDownloadUrl:i,diagnostics:u?.items??[],errorMessage:d==="Error"?u?.fetch.error?.message:void 0,expired:u?.expired??!1,filters:a,hasMore:u?.nextCursor!=null,isLoading:d==="Not-Started"||d==="In-Progress",isLoadingMore:d==="In-Progress"&&(u?.items.length??0)>0,session:Ne(s,o)}}),(function(t,e){const{filters:n,navigate:i,sessionId:a,tenantEmailDomain:o,view:s}=e,u=a==null?void 0:s.diagnosticsBySession[a],d=Ne(s,a),p=s.actionStateByKind.retry?.fetchState==="In-Progress",v=s.actionStateByKind.rollback?.fetchState==="In-Progress",m=d?.status==="done"&&d.rollback_available_until!=null&&new Date(d.rollback_available_until).getTime()>Date.now()&&!v;return{onBack:()=>i(`/${o}/invoicing/data_import`),onDownloadCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"download_csv",fromScreen:"data_import_detail",sessionId:a})},onDownloadError:()=>{t(qe({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{a!=null&&u?.nextCursor!=null&&t(Fe({...n,cursor:u.nextCursor,sessionId:a}))},onRetry:d?.status!=="failed"||p?void 0:()=>{a!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_detail",sessionId:a}),t(ze(a)))},onRollback:m?()=>{a!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"rollback",fromScreen:"data_import_detail",sessionId:a}),t(Dn(a)))}:void 0}}))(Et);function ua(){const t=L(),e=P(),{sessionId:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),[o,s]=r.useState({}),u=E(Qe),d=E(Ce),p=r.useMemo((()=>{const C=ne.getSignedInUser();return{userId:C?.userId??"",sessionId:C?.zeniSessionId??"",tenantId:d.tenantId}}),[d.tenantId]),v=Ne(u,n),m=n==null?void 0:u.diagnosticsBySession[n];r.useEffect((()=>{a&&n!=null&&t(Re(n))}),[a,t,n]),r.useEffect((()=>{if(!a||n==null)return;const C=setTimeout((()=>{t(Fe({...o,sessionId:n}))}),300);return()=>clearTimeout(C)}),[a,t,o,n]);const f=v?.status==="scanning"||v?.status==="importing";r.useEffect((()=>{if(!a||n==null||!f)return;const C=setInterval((()=>{t(Re(n)),t(Fe({...o,sessionId:n}))}),3e3);return()=>clearInterval(C)}),[a,t,o,f,n]);const S=r.useMemo((()=>{if(n==null)return"";const C=new URLSearchParams;o.moduleId!=null&&C.set("module_id",o.moduleId),o.level!=null&&C.set("level",o.level),o.outcome!=null&&C.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&C.set("search",o.search.trim());const h=C.toString();return`${ve?.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(_,{event:l.Event.invoicingDataImportDetailPage,isReady:v!=null&&I!=="Not-Started"}),c.jsx(la,{authParams:p,csvDownloadUrl:S,filters:o,navigate:e,sessionId:n,tenantEmailDomain:i,view:u,onFiltersChange:s})]})}const Zn=t=>`invoicing_active_migration:${t}`,me=(t,e)=>{if(t!=null&&t!=="")try{const n=Zn(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},ga=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(ge(s)),me(i,s),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),a(o)},onNewImport:()=>{g.trackInvoicingActionClick(l.Event.invoicingNewImportClicked),a()},onRetrySession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),t(ze(o)),a(o)},onRollbackSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),t(Dn(o))},onViewSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),n(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(yt);function ma(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),a=E(Qe);r.useEffect((()=>{i&&(t(ki()),t(jn()))}),[i,t]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingDataImportHubPage,isReady:o}),c.jsx(ga,{navigate:e,tenantEmailDomain:n,view:a})]})}const va=O((function(t,e){const{activeId:n,authParams:i,integrationsView:a,settings:o,templatesDownloadUrl:s,view:u}=e,{actionStateByKind:d,sessionDetail:p,sessions:v}=u,m=a.externalConnections?.revenue?.find((S=>S.connectionName==="chargebee")),f=n!=null?p[n]:void 0;return{authParams:i,templatesDownloadUrl:s,chargebeeConnected:o?.chargebee_connected===!0||(m?.isValid??!1),chargebeeConnectorAvailable:m!=null,chargebeeSite:o?.chargebee_site,connectError:d.connect?.error?.message,connecting:d.connect?.fetchState==="In-Progress",retrying:d.retry?.fetchState==="In-Progress",session:f??v.find((S=>S.id===n)),starting:d.start?.fetchState==="In-Progress",uploading:d.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:a}=e;return{onBack:e.onBack,onDownloadError:()=>{t(qe({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onDownloadTemplates:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportTemplatesDownloaded)},onFetchFromChargebee:()=>{g.trackInvoicingActionClick(l.Event.invoicingChargebeeConnectClicked),t(bi())},onGoToIntegrations:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"settings_integrations"}),i(`/${a}/invoicing/settings`)},onGoToOverview:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"overview"}),i(`/${a}/invoicing/overview`)},onRetry:()=>{n!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_migrate",sessionId:n}),t(ze(n)))},onSaveLater:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportStarted),n!=null&&t(yi(n))},onUpload:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportFileUploaded),t(Ei({files:o}))},onViewDetails:n==null?void 0:()=>i(`/${a}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(bt);function pa(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),a=E(Cn),o=E(Ce),s=r.useMemo((()=>{const h=ne.getSignedInUser();return{userId:h?.userId??"",sessionId:h?.zeniSessionId??"",tenantId:o.tenantId}}),[o.tenantId]),u=`${ve?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/templates`,d=o.companyId??ne.getSignedInUserTenant(n??"")?.companyId,p=E((h=>Ln(h,d))),v=E(Qe),{activeMigrationSessionId:m}=v,f=m??void 0,S=f!=null?v.sessionDetail[f]??v.sessions.find((h=>h.id===f)):void 0;r.useEffect((()=>{i&&(t(Ke()),t(jn()))}),[i,t]),r.useEffect((()=>{if(m!=null)return;const h=(y=>{if(y==null||y==="")return null;try{return sessionStorage.getItem(Zn(y))}catch{return null}})(n);h!=null&&t(ge(h))}),[m,t,n]),r.useEffect((()=>{me(n,m)}),[m,n]);const I=S?.status,C=I==="scanning"||I==="importing";return r.useEffect((()=>{if(!i||f==null||!C)return;const h=setInterval((()=>{t(Re(f))}),3e3);return()=>clearInterval(h)}),[i,f,C,t]),r.useEffect((()=>{I==="done"&&(t(ge(null)),me(n,null))}),[t,I,n]),c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingDataImportMigratePage}),c.jsx(va,{activeId:f,authParams:s,integrationsView:p,navigate:e,settings:a,templatesDownloadUrl:u,tenantEmailDomain:n,view:v,onBack:()=>{t(ge(null)),me(n,null),e(`/${n}/invoicing/data_import`)}})]})}const fa=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,discountsAccountName:n.discountsAccountName,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${n}/discounts`),onLifecycleAction:a=>{g.trackInvoicingActionClick(l.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discount_detail",status:e.editView.coupon?.status}),t(Pn({action:a,id:i}))},onSaveEdit:a=>{const{coupon:o}=e.editView;g.trackInvoicingActionClick(l.Event.invoicingCouponEdited,{couponId:i,mode:"edit",...B(a,{invoice_name:o?.invoiceName,invoice_notes:o?.invoiceNotes,max_redemptions:o?.maxRedemptions,name:o?.name},["invoice_notes"])}),t(Ai({data:a,id:i}))}}}))(xt);function Sa(){const t=L(),e=P(),{coupon_id:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),o=E((I=>xi(I,n))),s=o.actionState.fetchState==="In-Progress",u=o.pageFetchState.fetchState,d=u==="Completed",[p,v]=r.useState(d?n:void 0);r.useEffect((()=>{n!=null&&d&&v(n)}),[n,d]);const m=p===n;r.useEffect((()=>(t(J({id:n})),()=>{t(J({id:n}))})),[n,t]),r.useEffect((()=>{a&&t(_e({id:n}))}),[a,n,t]);const f=r.useCallback((I=>t(_e({cacheOverride:!0,id:I}))),[t]),S=ce(o.fetchState,o.isFormLoading,n,f);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingDiscountDetailPage,isReady:d}),c.jsx(fa,{hasLoadedRecord:m,couponId:n??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:s,navigate:e,tenantEmailDomain:i},S)]})}const Ia=O((function(t){const e=$n(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,discountLifecycleActionOptions:e.discountLifecycleActionOptions,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",coupons:e.coupons,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.coupons.length===0,isLoadingMore:n==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,a)=>{g.trackInvoicingActionClick(l.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discounts_list"}),t(Pn({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"discounts",status:e.activeStatus}),t(ji({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(At);function ha(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,appliedSort:I,nextCursor:C,couponListFetchState:h,runningDiscountActionId:y}=E((b=>{const A=$n(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,couponListFetchState:A.fetchState,runningDiscountActionId:A.runningActionId??null}}),z),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(Ae({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Ae({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingDiscountsListPage,isReady:D}),c.jsx(Ia,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,runningDiscountActionId:y,onSearchChange:o,onStatusChange:b=>{t(Di(b)),t(Ae({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const Ca=O((function(t,e){const{readView:n}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:n.dunningCase,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress",step:n.step}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,a=i!=="",{dunningCase:o}=e.readView,s={amount:o?.amount?.amount,caseId:i,customerId:o?.customerID,invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID};return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:u=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:u,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(u)}`)},onCancel:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"cancel",fromScreen:"dunning_detail"}),t(K({action:"cancel",id:i}))}:void 0,onResolve:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"resolve",fromScreen:"dunning_detail"}),t(K({action:"resolve",id:i}))}:void 0,onResume:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"resume",fromScreen:"dunning_detail"}),t(K({action:"resume",id:i}))}:void 0,onRetry:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"retry",fromScreen:"dunning_detail"}),t(K({action:"retry",id:i}))}:void 0}}))(jt);function ka(){const t=L(),e=P(),{case_id:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),o=E((k=>Li(k,n??""))),s=o.fetchState==="Completed",u=o.dunningCase?.invoiceID,[d,p]=r.useState("idle"),[v,m]=r.useState(!1),[f,S]=r.useState(),[I,C]=r.useState(!1),h=r.useCallback((()=>{p("idle"),m(!1),S(void 0),C(!1)}),[]),y=r.useCallback((()=>{if(n==null)return;t(Pi({id:n})),p("idle"),m(!1);const k=o.emailPreview.preview;S(k==null?void 0:{body:k.body,cc:k.cc,subject:k.subject,to:k.to}),C(!0)}),[n,t,o.emailPreview.preview]),D=r.useCallback((k=>{n!=null&&d!=="pending"&&(m(!1),p("pending"),g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{action:"send-email",amount:o.dunningCase?.amount?.amount,caseId:n,customerId:o.dunningCase?.customerID,fromScreen:"dunning_detail",invoiceId:o.dunningCase?.invoiceID,status:o.dunningCase?.status,subscriptionId:o.dunningCase?.subscriptionID}),t(K({action:"send-email",body:k,id:n})))}),[n,t,d,o.dunningCase]),b=r.useMemo((()=>o.emailPreview.preview==null?void 0:{bodyToken:o.emailPreview.preview.bodyToken,renderedHtmlTemplate:o.emailPreview.preview.renderedHtmlTemplate,subjectToken:o.emailPreview.preview.subjectToken}),[o.emailPreview.preview]);r.useEffect((()=>{a&&n!=null&&t($i({id:n}))}),[a,n,t]),r.useEffect((()=>{a&&u!=null&&t(ke({invoiceId:u}))}),[a,u,t]),r.useEffect((()=>{p("idle"),m(!1),S(void 0),C(!1)}),[n]),r.useEffect((()=>{a||(p("idle"),m(!1),S(void 0),C(!1))}),[a]),r.useEffect((()=>{I&&f==null&&o.emailPreview.preview!=null&&S({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,f,I]),r.useEffect((()=>{d==="pending"&&(o.actionState.fetchState!=="In-Progress"?v&&o.actionState.fetchState==="Completed"?(n!=null&&t(_i({id:n})),h()):v&&o.actionState.fetchState==="Error"&&p("failed"):m(!0))}),[n,h,t,d,v,o.actionState.fetchState]);const A=u!=null&&o.linkedInvoice?.id===u?o.linkedInvoice.dunningAttempts:void 0;return N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingDunningDetailPage,isReady:s}),c.jsx(Ca,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:o,dunningAttempts:A,onSendEmail:y}),c.jsx(Dt,{initialDraft:f,isPreviewLoading:o.emailPreview.fetchState==="Not-Started"||o.emailPreview.fetchState==="In-Progress",isSending:d==="pending",onClose:h,onSend:D,open:I,preview:b,previewErrorMessage:o.emailPreview.fetchState==="Error"?o.emailPreview.error?.message:void 0,sendErrorMessage:d==="failed"?o.actionState.error?.message:void 0})]})}const Ea=O((function(t){const e=_n(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:n==="In-Progress"&&e.dunningCases.length>0,stepById:e.stepById,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=a=>{const o=e.dunningCases.find((s=>s.id===a));return{amount:o?.amount?.amount,caseId:a,customerId:o?.customerID,fromScreen:"dunning_list",invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID}};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${n}/data_import`),onDunningCaseClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingDunningCaseRowClicked,i(a)),e.navigate(`${n}/dunning/${encodeURIComponent(a)}`)},onRowAction:(a,o)=>{o!=="retry"&&o!=="resume"&&o!=="resolve"&&o!=="cancel"||(g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...i(a),action:o}),t(K({action:o,id:a})))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"dunning",status:e.activeStatus}),t(Ri({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Lt);function ya(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,appliedSort:I,nextCursor:C,dunningCaseListFetchState:h,dunningCases:y}=E((b=>{const A=_n(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,dunningCaseListFetchState:A.fetchState,dunningCases:A.dunningCases}}),z),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(De({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(De({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingDunningListPage,isReady:D}),c.jsx(Ea,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:a,sortState:d,filters:m,sort:v,dunningCases:y,nextCursor:C,onSearchChange:o,onStatusChange:b=>{t(wi(b)),t(De({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const ba=O((function(t,e){const{view:n}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:n.billingAddress,invoice:n.invoice,invoiceId:e.invoiceId,shippingAddress:n.shippingAddress,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isSaving:n.actionState.fetchState==="In-Progress",isVoiding:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e,{invoice:a}=e.view,o={amount:a?.total?.amount,customerId:a?.customerID,invoiceId:i,status:a?.status};return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(s)}`)},onIssueCreditNote:()=>{g.trackInvoicingActionClick(l.Event.invoicingIssueCreditNoteClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{g.trackInvoicingActionClick(l.Event.invoicingRecordPaymentClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceRegenerated,{...o,fromScreen:"invoice_detail"}),t(q({action:"regenerate",invoiceId:i}))},onSaveEdit:s=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceEdited,{...o,fromScreen:"invoice_detail",mode:"edit",...B(s,{due_date:a?.dueDate?.format("YYYY-MM-DD")??"",notes:(a?.notes??[]).map((u=>u.note)).filter((u=>u!=null&&u!=="")).join(`
2
+ `),po_number:a?.poNumber??""},["notes"])}),t(Ti({data:{due_date:s.due_date!==""?s.due_date:void 0,notes:s.notes.trim()!==""?s.notes.split(`
3
+ `).map((u=>u.trim())).filter((u=>u!=="")).map((u=>({note:u}))):void 0,po_number:s.po_number!==""?s.po_number:null},invoiceId:i}))},onSendReminder:()=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceReminderSent,{...o,fromScreen:"invoice_detail"}),t(q({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:s,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(s)}`)},onVoid:s=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,{...o,fromScreen:"invoice_detail"}),t(q({action:"void",invoiceId:i,body:s}))}}}))(Pt);function xa(){const t=L(),e=P(),{invoice_id:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),o=E((S=>wn(S,n??""))),s=o.pageFetchState.fetchState,u=s==="Completed",[d,p]=r.useState(u?n:void 0);r.useEffect((()=>{n!=null&&u&&p(n)}),[n,u]);const v=d===n;r.useEffect((()=>{a&&n!=null&&t(Fi({invoiceId:n}))}),[a,n,t]);const m=r.useCallback((S=>t(ke({invoiceId:S}))),[t]),f=ce(o.actionState.fetchState,o.fetchState==="In-Progress",n,m);return N(s)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingInvoiceDetailPage,isReady:u}),c.jsx(ba,{invoiceId:n??"",hasLoadedRecord:v,navigate:e,tenantEmailDomain:i,view:o},f)]})}const Aa=O((function(t){const e=Rn(t),{fetchState:n}=e;return{counts:e.counts,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,invoices:e.invoices,statusOptions:e.statusOptions,isLoading:n==="Not-Started"||n==="In-Progress"&&e.invoices.length===0,isLoadingMore:n==="In-Progress"&&e.invoices.length>0,kpis:e.kpis,kpisLoading:e.kpisFetchState.fetchState==="Not-Started"||e.kpisFetchState.fetchState==="In-Progress"&&e.kpis==null,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=a=>{const o=e.invoices.find((s=>s.id===a));return{amount:o?.total?.amount,customerId:o?.customerID,fromScreen:"invoices_list",invoiceId:a,status:o?.status}};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onCreateInvoice:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked),e.navigate(`${n}/invoices/create`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"invoices"}),e.navigate(`${n}/data_import`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceRowClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onRowAction:(a,o)=>{switch(o){case"recordPayment":g.trackInvoicingActionClick(l.Event.invoicingRecordPaymentClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}/record-payment`);break;case"issueCreditNote":g.trackInvoicingActionClick(l.Event.invoicingIssueCreditNoteClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}/issue-credit-note`);break;case"sendReminder":g.trackInvoicingActionClick(l.Event.invoicingInvoiceReminderSent,i(a)),t(q({action:"send-reminder",invoiceId:a}));break;case"regenerate":g.trackInvoicingActionClick(l.Event.invoicingInvoiceRegenerated,i(a)),t(q({action:"regenerate",invoiceId:a}));break;case"void":g.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,i(a)),t(q({action:"void",invoiceId:a}))}},onVoidInvoice:(a,o)=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,i(a)),t(q({action:"void",invoiceId:a,body:o}))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"invoices",status:e.activeStatus}),t(Fn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))($t);function Da(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,appliedSort:I,nextCursor:C,invoiceListFetchState:h,voidingInvoiceId:y,invoices:D}=E((A=>{const k=Rn(A);return{activeStatus:k.activeTab,appliedSearch:k.filters.search,appliedSort:A.invoicingInvoiceListState.sort,nextCursor:k.nextCursor,invoiceListFetchState:k.fetchState,voidingInvoiceId:k.runningActionId,invoices:k.invoices}}),z),b=h==="Completed";return r.useEffect((()=>{const A=setTimeout((()=>u(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&t(je({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(je({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingInvoicesListPage,isReady:b}),c.jsx(Aa,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:a,sortState:d,filters:m,sort:v,invoices:D,nextCursor:C,voidingInvoiceId:y,onSearchChange:o,onStatusChange:A=>{t(Oi(A)),t(je({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}function un(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),i=_t(),a=pn(),[o,s]=r.useState(!1),{acceptTermsState:u,status:d}=E(Tn),p=Mi(i?.loggedInUserRoleMap),v=`/${n}/invoicing`,m=f=>{s(f)};return d==="completed"?c.jsx(H,{to:`${v}/overview`,replace:!0}):d==="settings"&&p?c.jsx(H,{to:`${v}/settings`,replace:!0}):c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingPromoPage}),c.jsx(Mo,{isAppContentDrawerOpen:o,handleDrawerToggle:m}),c.jsx(wt,{analytics:g,isAccepting:u.fetchState==="In-Progress",isReadOnlyUser:!p,meetingUrl:a("invoicing_promo"),onAcceptClick:()=>{g.trackInvoicingActionClick(l.Event.invoicingTermsAccepted),t(Ni())},onBackClick:()=>{e(`/${n}`)},onClickMenuIcon:()=>{m(!0)}})]})}const ja=O((function(t,e){const n=On(t,e.invoiceId),{invoice:i,localData:a,reasonCodeOptions:o,submitState:s,typeOptions:u}=n;return{fieldHelp:n.fieldHelp,amountDue:i?.amountDue,currencyCode:i?.currencyCode??"USD",customerName:i?.customerName??"",errorMessage:s.fetchState==="Error"?s.error?.message??"Failed to issue credit note. Please try again.":void 0,invoiceNumber:i?.invoiceNumber??e.invoiceId,isSubmitting:s.fetchState==="In-Progress",localData:a,reasonCodeOptions:o,typeOptions:u}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing/invoices/${encodeURIComponent(e.invoiceId)}`,i=()=>e.navigate(n);return{onBack:i,onCancel:i,onChange:a=>{t(Hi({localData:a}))},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreditNoteIssued,{invoiceId:e.invoiceId}),t(Vi())}}}))(Rt);function La(){const t=L(),e=P(),{invoice_id:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),{fetchState:o,invoice:s,isPageReady:u,issuedCreditNoteId:d,submitState:p}=E((S=>On(S,n??""))),v=`/${i}/invoicing`,m=r.useRef(null);r.useEffect((()=>(t(sn()),m.current=null,()=>{t(sn())})),[t,n]),r.useEffect((()=>{a&&n!=null&&t(ke({invoiceId:n}))}),[a,t,n]),r.useEffect((()=>{s!=null&&n!=null&&o==="Completed"&&m.current!==n&&(m.current=n,t(Ui({localData:Bi(s)})))}),[t,o,s,n]);const f=r.useRef(p.fetchState);return r.useEffect((()=>{const S=f.current;f.current=p.fetchState,S!=="Completed"&&p.fetchState==="Completed"&&d!=null&&e(`${v}/credits/${encodeURIComponent(d)}`)}),[d,e,p.fetchState,v]),c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingIssueCreditNotePage,isReady:u}),c.jsx(ja,{invoiceId:n??"",navigate:e,tenantEmailDomain:i})]})}const Pa=O((function(t){return{invoicingOverview:Mn(t)}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onRefresh:()=>{g.trackInvoicingActionClick(l.Event.invoicingOverviewRefreshed),t(Nn(e.selectedPeriod,!0))},onSubscriptionClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionTileClicked,{subscriptionId:i}),e.navigate(`${n}/subscriptions/${i}`)},onViewInvoices:()=>{g.trackInvoicingActionClick(l.Event.invoicingViewInvoicesClicked),e.navigate(`${n}/invoices`)},onViewPayments:()=>{g.trackInvoicingActionClick(l.Event.invoicingViewPaymentsClicked),e.navigate(`${n}/payments`)}}}))(Ft);function $a(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a]=r.useState((()=>{const s=new Date;return{month:s.getMonth()+1,year:s.getFullYear()}})),o=E((s=>Mn(s).fetchState))==="Completed";return r.useEffect((()=>{i&&t(Nn(a))}),[i,t,a]),c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingOverviewPage,isReady:o}),c.jsx(Pa,{navigate:e,selectedPeriod:a,tenantEmailDomain:n})]})}const _a=O((function(t){const e=Un(t),{fetchState:n}=e;return{columns:e.columns,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.transactions.length===0,isLoadingMore:n==="In-Progress"&&e.transactions.length>0,tabIds:e.tabIds,transactions:e.transactions}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeType:e.activeType,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTypeChange:e.onTypeChange,onViewTransactionCustomer:e.onViewTransactionCustomer,onViewTransactionInvoice:e.onViewTransactionInvoice,onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"payments"}),e.navigate(`${n}/data_import`)},onTransactionClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentRowClicked,{transactionId:i}),e.navigate(`${n}/payments/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"payments",tab:e.activeType}),t(Qi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Tt);function wa(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeType:f,appliedSearch:S,appliedSort:I,nextCursor:C,transactionListFetchState:h,transactions:y}=E((j=>{const R=Un(j);return{activeType:R.activeTab,appliedSearch:R.filters.search,appliedSort:R.sort,nextCursor:R.nextCursor,transactionListFetchState:R.fetchState,transactions:R.transactions}}),z),D=h==="Completed",b=`/${n}/invoicing`,A=r.useCallback((j=>{const R=y.find((T=>T.id===j)),U=R?.linkedInvoices?.[0]?.invoiceID??R?.invoiceID;U!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"payments_list",invoiceId:U,toScreen:"invoice"}),e(`${b}/invoices/${encodeURIComponent(U)}`))}),[e,b,y]),k=r.useCallback((j=>{const R=y.find((U=>U.id===j))?.customerID;R!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:R,fromScreen:"payments_list",toScreen:"customer"}),e(`${b}/customers/${encodeURIComponent(R)}`))}),[e,b,y]);return r.useEffect((()=>{const j=setTimeout((()=>u(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t(Le({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Le({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingPaymentsListPage,isReady:D}),c.jsx(_a,{navigate:e,tenantEmailDomain:n,activeType:f,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,onSearchChange:o,onTypeChange:j=>{t(qi(j)),t(Le({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p,onViewTransactionCustomer:k,onViewTransactionInvoice:A})]})}const Ra=t=>{const e=[t.firstName,t.lastName].filter((n=>n!=null&&n.trim()!=="")).join(" ").trim();return(t.company!=null&&t.company.trim()!==""?t.company.trim():"")||e||(t.email!=null&&t.email.trim()!==""?t.email.trim():"")||t.id};function gn(){const t=L(),e=P(),{invoice_id:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),o=n!=null&&n!=="",s=E(he),u=E((k=>zi(k))),d=E(Ki),p=E((k=>wn(k,n??""))),v=p.invoice,m=`/${i}/invoicing`,f=r.useRef(null),S=r.useRef("");r.useEffect((()=>{t(Gi()),f.current=null,S.current=""}),[t,n]),r.useEffect((()=>{a&&t(o&&n!=null?ke({invoiceId:n}):An({filters:{},keepExistingListItems:!1}))}),[a,t,n,o]),r.useEffect((()=>{o&&v!=null&&n!=null&&p.fetchState==="Completed"&&f.current!==n&&(f.current=n,t(Wi({contextInvoiceId:n,localData:Ji(v)})))}),[t,v,n,p.fetchState,o]),r.useEffect((()=>{if(o)return;const k=u.localData.customerId;k!==""&&k!==S.current&&(S.current=k,t(Fn({filters:{customerId:k},keepExistingListItems:!1})),u.localData.invoiceToLink!==""&&t(rn({localData:{...u.localData,customerId:k,invoiceToLink:""}})))}),[t,u.localData,o]);const I=r.useRef(d.fetchState);r.useEffect((()=>{const k=I.current;if(I.current=d.fetchState,k!=="Completed"&&d.fetchState==="Completed"){if(d.recordedInvoiceId!=null)return void e(`${m}/invoices/${encodeURIComponent(d.recordedInvoiceId)}`);e(`${m}/payments`)}}),[e,d.fetchState,d.recordedInvoiceId,m]);const C=r.useMemo((()=>s.customers.map((k=>({id:k.id,name:Ra(k)})))),[s.customers]),h=E((k=>Yi(k,u.localData.customerId))),y=r.useMemo((()=>h.map((k=>{return{amountDue:(j=k.amountDue,R=Xi.currencySymbol,Nt("0,0.00",j,R)),amountDueValue:k.amountDue,id:k.id,label:k.invoiceNumber};var j,R}))),[h]),D=r.useMemo((()=>{if(!o||v==null)return;const k=v.currencyCode??"USD",j=v.amountDue?.amount??0;return{amountDue:Ot("0,0.00",v.amountDue),amountDueValue:j,currencyCode:k,customerName:v.customerName??v.customerID,invoiceId:v.id,invoiceNumber:v.invoiceNumber??v.id}}),[v,o]),b=o?`${m}/invoices/${encodeURIComponent(n??"")}`:`${m}/payments`,A=!o||p.fetchState==="Completed"&&u.localData.invoiceToLink!=="";return c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingRecordPaymentPage,isReady:A}),c.jsx(Mt,{customers:C,fieldHelp:u.fieldHelp,errorMessage:d.fetchState==="Error"?d.error?.message??"Failed to record payment. Please try again.":void 0,gatewayOptions:u.gatewayOptions,invoiceContext:D,invoiceOptions:y,isSubmitting:d.fetchState==="In-Progress",localData:u.localData,mode:o?"invoice":"customer",paymentMethodOptions:u.paymentMethodOptions,onBack:()=>{e(b)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingRecordPaymentCancelled),e(b)},onChange:k=>{t(rn({localData:k}))},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentRecorded,{customerId:u.localData.customerId,invoiceId:o?n:u.localData.invoiceToLink,paymentMethod:u.localData.paymentMethod}),t(Zi(o?n??void 0:void 0))}})]})}const et=(t,e,n)=>{const i=`/${t}/invoicing/subscriptions/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},Fa=O((function(t,e){const{editView:n}=e,i=n.subscription,a=i?.status,o=a!=null&&e.commercialEditAllowedFromStatuses.includes(a);return{cancelReasonCodeOptions:n.cancelReasonCodeOptions,fieldHelp:n.fieldHelp,addons:n.addons,canEditCommercial:o,charges:n.charges,coupons:n.coupons,estimate:n.estimate,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),isRunningAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",lifecycleActionOptions:e.lifecycleActionOptions,localData:n.localData,plans:n.plans,shippingAddressLabel:n.shippingAddressLabel,hasUnsavedShippingAddress:n.hasUnsavedShippingAddress,subscription:i}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,a=i!=="",o=(s,u)=>{const{subscription:d}=e.editView;g.trackInvoicingActionClick(l.Event.invoicingSubscriptionLifecycleAction,{action:s,amount:d?.mrr?.amount,customerId:d?.customerID,fromScreen:"subscription_detail",status:d?.status,subscriptionId:i}),t(Hn({action:s,id:i,body:u}))};return{onBack:()=>e.navigate(`${n}/subscriptions`),onChange:s=>{t(ee({id:i,localData:s}))},onChangeTermEnd:a?s=>{const u=s?.trim()??"";u!==""&&o("change_term_end",{term_ends_at:u})}:void 0,onCustomerClick:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${n}/customers/${encodeURIComponent(s)}`,"_blank","noopener,noreferrer")},onDiscardEdit:()=>{t(Q(te)),t(to({id:i}))},onOpenAddress:()=>{const s=et(e.tenantEmailDomain??"",te,i),u=ae(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(s,{state:{pathnameStackToGoBack:u}})},onViewInvoices:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"subscription_detail",subscriptionId:i,toScreen:"invoices"}),e.navigate(`${n}/invoices`)},onCloseEstimate:()=>{t(We())},onRequestEstimate:s=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionEstimateCalculation,{mode:"edit",subscriptionId:i,...B(s,Te(e.editView.subscription))}),t(ee({id:i,localData:s})),t(Vn({id:i}))},onSaveEdit:s=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionEdited,{mode:"edit",subscriptionId:i,...B(s,Te(e.editView.subscription))}),t(ee({id:i,localData:s})),t(Bn({id:i}))},onCancelSubscription:a?s=>{o("cancel",{cancel_reason_code:s.cancelReasonCode,end_of_term:!1,...s.cancelReason!=null&&s.cancelReason.trim()!==""?{cancel_reason:s.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:a?(s,u)=>{s!=="pause"?o(s):o(s,u!=null&&u.trim()!==""?{resume_date:u.trim()}:void 0)}:void 0}}))(Ut);function Ta(){const t=L(),e=P(),n=oe(),{subscription_id:i,tenantEmailDomain:a}=w(),{areTenantIdsInSync:o}=F(),s=E((y=>Ge(y,i))),{subscriptionCommercialEditAllowedFromStatuses:u,subscriptionLifecycleActionOptions:d,subscriptionMetadataEditAllowedFromStatuses:p}=s,v=s.pageFetchState.fetchState,m=v==="Completed"&&!s.isFormLoading,[f,S]=r.useState(m?i:void 0);r.useEffect((()=>{i!=null&&m&&S(i)}),[i,m]);const I=f===i;Ee(o),r.useEffect((()=>{o&&i!=null&&t(eo({id:i}))}),[o,i,t]);const C=r.useCallback((y=>t(no({id:y}))),[t]),h=ce(s.fetchState,s.isFormLoading,i,C);return N(v)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingSubscriptionDetailPage,isReady:m}),c.jsx(Fa,{hasLoadedRecord:I,commercialEditAllowedFromStatuses:u,editView:s,lifecycleActionOptions:d,location:n,metadataEditAllowedFromStatuses:p,navigate:e,subscriptionId:i??"",tenantEmailDomain:a},h)]})}const Oa=O((function(t,e){const n=Ge(t,e.subscriptionId);return{fieldHelp:n.fieldHelp,addons:n.addons,charges:n.charges,coupons:n.coupons,customers:n.customers,estimate:n.estimate,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save subscription.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,plans:n.plans,savedSubscription:n.subscription,shippingAddressLabel:n.shippingAddressLabel}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e;return{onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionFormCancelled),t(Oe({id:i})),t(Q(te)),i==null?e.navigate(`${n}/subscriptions`):e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)},onChange:a=>{t(ee({id:i,localData:a}))},onCloseEstimate:()=>{t(We())},onRequestEstimate:()=>{t(Vn({id:i}))},onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"subscription",fromScreen:"subscription_form"});const a=et(e.tenantEmailDomain??"",te,i),o=ae(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.keepDraftOnLeave(),e.navigate(a,{state:{pathnameStackToGoBack:o}})},onSubmit:()=>{t(Bn({id:i}))}}}),(function({savedSubscription:t,...e},n,i){const a=()=>({mode:e.mode,subscriptionId:i.subscriptionId,...B(e.localData,t!=null?Te(t):void 0)});return{...i,...e,...n,onRequestEstimate:()=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionEstimateCalculation,a()),n.onRequestEstimate()},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionSaved,a()),n.onSubmit()}}}))(Bt);function Ma(){const t=L(),e=P(),n=oe(),{subscription_id:i,tenantEmailDomain:a}=w(),[o]=ie(),{areTenantIdsInSync:s}=F(),u=o.get("customerId"),{fetchState:d,savedSubscriptionId:p}=E((C=>io(C,i))),v=E((C=>Ge(C,i).localData));Ee(s);const m=r.useRef(!1),f=r.useCallback((()=>{m.current=!0}),[]),S=r.useRef();r.useEffect((()=>(clearTimeout(S.current),m.current=!1,()=>{m.current||(S.current=setTimeout((()=>{t(Oe({id:i})),t(Q(te)),t(We())}),0))})),[i,t]),r.useEffect((()=>{s&&t(oo({subscriptionId:i}))}),[s,i,t]);const I=r.useRef(!1);return r.useEffect((()=>{I.current||i!=null||u==null||u===""||v.customerId!==""||(I.current=!0,t(ee({id:i,localData:{...v,customerId:u}})))}),[u,i,v,t]),r.useEffect((()=>{if(d==="Completed"){const C=p??i,h=C!=null?`/${a}/invoicing/subscriptions/${encodeURIComponent(C)}`:`/${a}/invoicing/subscriptions`;e(h),t(Oe({id:i}))}}),[d,p,i,t,e,a]),c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingSubscriptionFormPage}),c.jsx(Oa,{keepDraftOnLeave:f,location:n,navigate:e,subscriptionId:i,tenantEmailDomain:a})]})}const Na=O((function(t){const e=qn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.subscriptions.length===0,isLoadingMore:n==="In-Progress"&&e.subscriptions.length>0,cancelReasonCodeOptions:e.cancelReasonCodeOptions,lifecycleActionOptions:e.subscriptionLifecycleActionOptions,subscriptions:e.subscriptions,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=(a,o,s)=>{const u=e.subscriptions.find((d=>d.id===a));g.trackInvoicingActionClick(l.Event.invoicingSubscriptionLifecycleAction,{action:o,amount:u?.mrr?.amount,customerId:u?.customerID,fromScreen:"subscriptions_list",status:u?.status,subscriptionId:a}),t(Hn({action:o,id:a,body:s}))};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onAddSubscription:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked),e.navigate(`${n}/subscriptions/new`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"subscriptions"}),e.navigate(`${n}/data_import`)},onChangeTermEnd:(a,o)=>{const s=o?.trim()??"";s!==""&&i(a,"change_term_end",{term_ends_at:s})},onSubscriptionAction:(a,o,s)=>{o!=="pause"?i(a,o):i(a,o,s!=null&&s.trim()!==""?{resume_date:s.trim()}:void 0)},onCancelSubscription:(a,o)=>{i(a,"cancel",{cancel_reason_code:o.cancelReasonCode,end_of_term:!1,...o.cancelReason!=null&&o.cancelReason.trim()!==""?{cancel_reason:o.cancelReason.trim()}:{}})},onSubscriptionClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionRowClicked,{subscriptionId:a}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onViewSubscriptionInvoices:()=>{e.navigate(`${n}/invoices`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"subscriptions",status:e.activeStatus}),t(so({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Vt);function Ua(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,p]=r.useState(null),v=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:f,appliedSearch:S,appliedSort:I,nextCursor:C,subscriptionListFetchState:h,runningActionSubscriptionId:y,subscriptions:D}=E((k=>{const j=qn(k);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:j.sort,nextCursor:j.nextCursor,subscriptionListFetchState:j.fetchState,runningActionSubscriptionId:j.runningActionId??null,subscriptions:j.subscriptions}}),z),b=h==="Completed";r.useEffect((()=>{const k=setTimeout((()=>u(a)),300);return()=>clearTimeout(k)}),[a]),r.useEffect((()=>{i&&t(Pe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==S||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Pe({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,S,I]);const A=r.useRef(y);return r.useEffect((()=>{const k=A.current!=null&&y==null;A.current=y,k&&i&&t(ao())}),[y,i,t]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingSubscriptionsListPage,isReady:b}),c.jsx(Na,{navigate:e,tenantEmailDomain:n,activeStatus:f,searchValue:a,sortState:d,filters:m,sort:v,nextCursor:C,runningActionSubscriptionId:y,subscriptions:D,onSearchChange:o,onStatusChange:k=>{t(co(k)),t(Pe({cacheOverride:!1,filters:m,sort:v}))},onSortChange:p})]})}const Ba=O((function(t,e){const{readView:n}=e;return{isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress",transaction:n.transaction,transactionId:e.transactionId}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{transactionId:i}=e;return{onBack:()=>e.navigate(`${n}/payments`),onCustomerClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"transaction_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(a)}`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onSubscriptionClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onCapture:i!==""?()=>{g.trackInvoicingActionClick(l.Event.invoicingTransactionCaptured,{transactionId:i}),t(uo({action:"capture",id:i}))}:void 0}}))(Ht);function Va(){const t=L(),e=P(),{tenantEmailDomain:n,transaction_id:i}=w(),{areTenantIdsInSync:a}=F(),o=E((u=>ro(u,i??""))),s=o.fetchState==="Completed";return r.useEffect((()=>{a&&i!=null&&t(lo({id:i}))}),[a,i,t]),N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingTransactionDetailPage,isReady:s}),c.jsx(Ba,{navigate:e,tenantEmailDomain:n,transactionId:i??"",readView:o})]})}function nt(t={}){const{enabled:e=!0,fetchSyncHealth:n=!1,loadAccountingPickers:i=!1,reuseCached:a=!1}=t,o=L(),{areTenantIdsInSync:s}=F(),u=E(Je),d=u.connection?.connected===!0,p=u.connectionFetchState.fetchState;return r.useEffect((()=>{e&&s&&(a&&p!=="Not-Started"||o(Qn()),n&&o(go()))}),[s,o,e,n,a]),r.useEffect((()=>{e&&s&&d&&i&&o(mo())}),[s,o,e,d,i]),{isQboConnected:d,qboView:u}}const Ha={branding:"invoicing_branding_save",dunning:"invoicing_dunning_settings_save",quickbooks:"invoicing_qbo_settings_save"};function se(t){const e=L(),{areTenantIdsInSync:n}=F(),{tenantEmailDomain:i}=w(),{fetchState:a,fieldHelp:o,logoFile:s,saveState:u,settings:d,stripeConnectState:p}=E(vo),{configError:v,configFetchState:m,dunningScheduleActionOptions:f,qboAccountMappingKindOptions:S,qboCustomerMatchingOptions:I,qboSyncStatusOptions:C}=E(zn),h=E(Je);nt({enabled:t==="quickbooks",fetchSyncHealth:!0,loadAccountingPickers:!0});const y=E(Ce),D=t==="dunning"||t==="quickbooks",b=y.companyId??ne.getSignedInUserTenant(i??"")?.companyId,A=E(($=>Ln($,b))),k=po(y.userRole??[]),j=y.tenantId??"",R=ne.getSignedInUser(),U={userId:R?.userId??"",sessionId:R?.zeniSessionId??"",tenantId:j},T=s?.fileId,re=E(($=>T!=null&&T!==""?fo($,T):void 0)),Ye=E(($=>T!=null&&T!==""?So($,T):void 0)),tt=T!=null&&T!==""&&re!=null?{[T]:re}:{},it=T!=null&&T!==""&&Ye!=null?{[T]:Ye}:{};r.useEffect((()=>(e(dn()),()=>{e(dn())})),[e]),r.useEffect((()=>{n&&(a!=="Not-Started"&&a!=="Error"||e(Ke()))}),[n,e,a]),r.useEffect((()=>{n&&D&&m==="Not-Started"&&e(Se())}),[n,e,m,D]),r.useEffect((()=>{if(!n)return;const $=R?.userId;$!=null&&$!==""&&j!==""&&en.shouldFetchActiveTenant(j)&&(en.markActiveTenantFetchStarted(j),e(Io($,j,R?.zeniSessionId)))}),[n,e,R?.userId,R?.zeniSessionId,j]);const ot=f.length>0||S.length>0,at=a==="Not-Started"||a==="In-Progress"&&d==null||D&&!ot&&(m==="Not-Started"||m==="In-Progress"),ct=a==="Completed"&&(!D||m==="Completed"),Xe=A.externalConnections?.revenue?.find(($=>$.connectionName==="chargebee"))?.connectionId,ye=ve?.invoicingMicroServiceBaseUrl,Ze=ye!=null&&ye.length>0?`${ye}/1.0/webhooks/stripe`:"",Y={deleteConnectionError:A.externalConnections?.deleteConnectionError?.message,deleteConnectionState:A.externalConnections?.deleteConnectionState??"Not-Started",integrationsView:A,isAdmin:k,isStripeBusy:p.fetchState==="In-Progress",onConnectStripe:$=>{g.trackInvoicingActionClick(l.Event.invoicingStripeConnectClicked,{fromScreen:t??"hub"}),e(Do($))},onDisconnect:($,V)=>{j!==""&&(g.trackInvoicingActionClick(l.Event.invoicingIntegrationDisconnected,{entity:V,entityId:$,fromScreen:t??"hub"}),e(Ao(j,$,ln(V))))},onDisconnectStripe:()=>{g.trackInvoicingActionClick(l.Event.invoicingStripeDisconnected,{fromScreen:t??"hub"}),e(xo())},onReconnectQBO:()=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"reconnect",fromScreen:t??"hub"});const $=y.tenantEmailDomain??i??"";Ie.init("/connection/auth",$),Ie.handleClick()},onRefreshQBO:()=>{A.integrations.refreshQBO.fetchState!=="In-Progress"&&(g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"refresh",fromScreen:t??"hub"}),e(Wn()))},onSaveChargeBeeCredentials:($,V)=>{Xe!=null&&j!==""&&(g.trackInvoicingActionClick(l.Event.invoicingChargebeeCredentialsSaved,{fromScreen:t??"hub"}),e(yo(j,Xe,ln("revenue"),bo("chargebee"),{api_key:$,site:V})))},saveChargeBeeError:A.externalConnections?.saveAPIKeyConnectionError?.message,saveChargeBeeState:A.externalConnections?.saveAPIKeyConnectionState??"Not-Started",settings:d,stripeError:p.fetchState==="Error"?p.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Ze};return{authParams:U,deleteFileStatusById:tt,fieldHelp:o,dunningScheduleActionOptions:f,filesEndPoint:ve?.fileMicroServiceBaseUrl??"",integrationsSectionProps:Y,isInvoicingPageReady:ct,isLoading:at,isSaving:u.fetchState==="In-Progress",isStripeBusy:p.fetchState==="In-Progress",logoFile:s,qboAccountMappingKindOptions:S,qboCustomerMatchingOptions:I,qboSyncStatusOptions:C,qboView:h,saveErrorMessage:u.fetchState==="Error"?u.error?.message??"Failed to save settings.":D&&m==="Error"?v?.message??"Failed to load invoicing configuration.":void 0,settings:d,stripeError:p.fetchState==="Error"?p.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Ze,updateFileStatusById:it,onConnectStripe:Y.onConnectStripe,onDeleteFile:$=>{g.trackInvoicingActionClick(l.Event.invoicingLogoRemoved,{fromScreen:t??"hub"}),e(Eo($,j))},onDisconnectStripe:Y.onDisconnectStripe,onEditFileName:($,V)=>{g.trackInvoicingActionClick(l.Event.invoicingLogoRenamed,{fromScreen:t??"hub"}),e(ko($,V.split(".")[0],j))},onReconnectQBO:Y.onReconnectQBO,onRefreshQBO:Y.onRefreshQBO,onRetryQboSyncTask:$=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"retry_task",entityId:$,fromScreen:t??"hub"}),e(Gn($))},onSave:$=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{fieldsChanged:Object.keys($).filter((V=>JSON.stringify($[V])!==JSON.stringify(d?.[V]))),tab:t??"hub"}),e(Co({settings:$,snackbarSection:Ha[t??""]}))},onStartQboBackfill:$=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"backfill",fromScreen:t??"hub"}),e(Kn($))},updateFilesEntity:$=>{g.trackInvoicingActionClick(l.Event.invoicingLogoUploaded,{fromScreen:t??"hub"}),e(ho({files:$}))}}}function mn({appContent:t}){const e=P(),n=oe(),i=L(),{tenantEmailDomain:a}=w(),o=se("branding"),s=E((d=>jo(d)));r.useEffect((()=>{s.saveState.fetchState==="Completed"&&i(Lo())}),[s.saveState.fetchState,i]);const u=Ue(s.saveState.fetchState);return r.useEffect((()=>{u==="In-Progress"&&s.saveState.fetchState==="Completed"&&e("..")}),[u,s.saveState.fetchState,e]),c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingBrandingSettingsPage,isReady:o.isInvoicingPageReady}),c.jsx(qt,{address:s.address,fieldHelp:s.fieldHelp,addressLabel:s.addressLabel,appContent:t,authParams:o.authParams,dateFormatOptions:s.dateFormatOptions,deleteFileStatusById:o.deleteFileStatusById,filesEndPoint:o.filesEndPoint,isLoading:o.isLoading,isSaving:o.isSaving,localData:s.localData,logoFile:o.logoFile,saveErrorMessage:o.saveErrorMessage,settings:o.settings,updateFileStatusById:o.updateFileStatusById,onBackClick:()=>e(".."),onChange:d=>{i(_o({localData:d}))},onDeleteFile:o.onDeleteFile,onEditFileName:o.onEditFileName,onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"branding",fromScreen:"settings_branding"});const d=`/${a}/invoicing/settings/branding/${$o}/`,p=ae(n.state?.pathnameStackToGoBack,n.pathname);e(d,{state:{pathnameStackToGoBack:p}})},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{tab:"branding"}),i(Po())},updateFilesEntity:o.updateFilesEntity})]})}function qa(){const t=P(),e=se("dunning");return c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingDunningSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(Qt,{dunningScheduleActionOptions:e.dunningScheduleActionOptions,isLoading:e.isLoading,isSaving:e.isSaving,saveErrorMessage:e.saveErrorMessage,settings:e.settings,onBackClick:()=>t(".."),onSave:e.onSave})]})}function Qa(){const t=P(),e=se("integrations");return c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingIntegrationsSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(zt,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>t("../quickbooks"),onOpenPaymentDestination:()=>t("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>t("..")})]})}function za(){const t=P(),e=se("payment-destination");return c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingPaymentDestinationSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(Kt,{fieldHelp:e.fieldHelp,isLoading:e.isLoading,isStripeBusy:e.isStripeBusy,saveErrorMessage:e.saveErrorMessage,settings:e.settings,stripeError:e.stripeError,stripeWebhookUrl:e.stripeWebhookUrl,onBackClick:()=>t(".."),onConnectStripe:e.onConnectStripe})]})}const Ka=["autoCreateItems","closedPeriodVoidAsCreditMemo","customerMatching","isSyncEnabled","syncStartDate","trackingCategoriesEnabled"],Ga=O((function(t){const e=Jn(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(Fo({localData:e}))},onReset:()=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsReset,{tab:"quickbooks"}),t(Ro())},onRetryTask:e=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"retry_task",entityId:e,fromScreen:"settings_qbo"}),t(Gn(e))},onStartBackfill:e=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"backfill",fromScreen:"settings_qbo"}),t(Kn(e))}}}))(Gt);function Wa(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),i=E(Ce),{configFetchState:a,localData:o,savedLocalData:s,saveState:u,settingsFetchState:d}=E(Jn),p=r.useMemo((()=>{return m=o,f=s,[...[...new Set([...Object.keys(m.accountIdByMappingCode),...Object.keys(f.accountIdByMappingCode)])].some((S=>(m.accountIdByMappingCode[S]??"")!==(f.accountIdByMappingCode[S]??"")))?["account_mappings"]:[],...Ka.filter((S=>m[S]!==f[S]))];var m,f}),[o,s]),v=Ue(u.fetchState);return r.useEffect((()=>{v==="In-Progress"&&u.fetchState==="Completed"&&e("..")}),[e,v,u.fetchState]),r.useEffect((()=>{d!=="Not-Started"&&d!=="Error"||t(Ke())}),[t,d]),r.useEffect((()=>{a==="Not-Started"&&t(Se())}),[a,t]),nt({fetchSyncHealth:!0,loadAccountingPickers:!0}),c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingQboSettingsPage}),c.jsx(Ga,{onBackClick:()=>e(".."),onReconnect:()=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"reconnect",fromScreen:"settings_qbo"}),Ie.init("/connection/auth",i.tenantEmailDomain??n??""),Ie.handleClick()},onRefresh:()=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"refresh",fromScreen:"settings_qbo"}),t(Wn())},onSave:()=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{fieldsChanged:p,tab:"quickbooks"}),t(wo())}})]})}const Ja={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function Ya(){const t=pn(),e=L(),n=P(),[i,a]=ie(),o=se(),{canEnableInvoicing:s,isEnablingInvoicing:u,isInvoicingEnabled:d,isQboConfigured:p,isStripeConnected:v}=E(zn),m=i.get("tab");return r.useEffect((()=>{if(m==null)return;const f=Ja[m];a({},{replace:!0}),f!=null&&n(f,{replace:!0})}),[m,n,a]),c.jsxs(c.Fragment,{children:[c.jsx(_,{event:l.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),c.jsx(Wt,{analytics:g,integrationsSectionProps:{...o.integrationsSectionProps,onConfigureQBO:()=>n("quickbooks"),onOpenPaymentDestination:()=>n("payment-destination")},isEnablingInvoicing:u,isLoading:o.isLoading,meetingUrl:t("invoicing_settings"),settings:o.settings,onBrandingClick:()=>n("branding"),onDunningClick:()=>n("dunning"),canEnableInvoicing:s,isQboConfigured:p,isStripePaymentsReady:v,onEnableInvoicingClick:d?void 0:()=>{g.trackInvoicingActionClick(l.Event.invoicingEnableClicked),e(To())}})]})}function vn(){return c.jsxs(ue,{children:[c.jsx(x,{index:!0,element:c.jsx(Ya,{})}),c.jsx(x,{path:"payment-destination",element:c.jsx(za,{})}),c.jsx(x,{path:"branding",element:c.jsx(mn,{})}),c.jsx(x,{path:"branding/:addressType",element:c.jsx(mn,{appContent:c.jsx(X,{isSubPage:!0,hideAddressBackButton:!0})})}),c.jsx(x,{path:"integrations",element:c.jsx(Qa,{})}),c.jsx(x,{path:"dunning",element:c.jsx(qa,{})}),c.jsx(x,{path:"quickbooks",element:c.jsx(Wa,{})}),c.jsx(x,{path:"*",element:c.jsx(H,{to:"..",replace:!0})})]})}function xc(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),{enableState:a,fetchState:o,status:s}=E(Tn),u=Ue(a.fetchState),d=`/${n}/invoicing`,p=r.useRef(!1),v=E((m=>Je(m).connectionFetchState.fetchState));return r.useEffect((()=>{i&&(o!=="Not-Started"?o!=="Error"||p.current||(p.current=!0,t(Se({cacheOverride:!1}))):t(Se({cacheOverride:!1})))}),[i,t,o]),r.useEffect((()=>{i&&v==="Not-Started"&&t(Qn())}),[i,t,v]),r.useEffect((()=>{u==="In-Progress"&&a.fetchState==="Completed"&&(e(`${d}/catalog`),t(Oo()))}),[u,a.fetchState,d,t,e]),s==null&&o!=="Error"?c.jsx(Jt,{fetchState:"In-Progress"}):s==="not_started"?c.jsxs(ue,{children:[c.jsx(x,{path:"promo",element:c.jsx(un,{})}),c.jsx(x,{path:"*",element:c.jsx(H,{to:`${d}/promo`,replace:!0})})]}):s==="settings"?c.jsxs(ue,{children:[c.jsx(x,{path:"promo",element:c.jsx(un,{})}),c.jsx(x,{path:"settings/*",element:c.jsx(vn,{})}),c.jsx(x,{path:"*",element:c.jsx(H,{to:`${d}/settings`,replace:!0})})]}):c.jsxs(ue,{children:[c.jsx(x,{path:"/",element:c.jsx(H,{to:"overview",replace:!0})}),c.jsx(x,{path:"overview",element:c.jsx($a,{})}),c.jsx(x,{path:"promo",element:c.jsx(H,{to:`${d}/overview`,replace:!0})}),c.jsx(x,{path:"customers",element:c.jsx(da,{})}),c.jsx(x,{path:"customers/new",element:c.jsx(sa,{})}),c.jsx(x,{path:"customers/new/:addressType",element:c.jsx(X,{})}),c.jsx(x,{path:"customers/:customer_id",element:c.jsx(aa,{})}),c.jsx(x,{path:"customers/:customer_id/:addressType",element:c.jsx(X,{})}),c.jsx(x,{path:"subscriptions",element:c.jsx(Ua,{})}),c.jsx(x,{path:"subscriptions/new",element:c.jsx(Ma,{})}),c.jsx(x,{path:"subscriptions/new/:addressType",element:c.jsx(X,{})}),c.jsx(x,{path:"subscriptions/:subscription_id",element:c.jsx(Ta,{})}),c.jsx(x,{path:"subscriptions/:subscription_id/:addressType",element:c.jsx(X,{})}),c.jsx(x,{path:"invoices",element:c.jsx(Da,{})}),c.jsx(x,{path:"invoices/create",element:c.jsx(Zo,{})}),c.jsx(x,{path:"invoices/:invoice_id",element:c.jsx(xa,{})}),c.jsx(x,{path:"invoices/:invoice_id/record-payment",element:c.jsx(gn,{})}),c.jsx(x,{path:"invoices/:invoice_id/issue-credit-note",element:c.jsx(La,{})}),c.jsx(x,{path:"payments",element:c.jsx(wa,{})}),c.jsx(x,{path:"payments/record",element:c.jsx(gn,{})}),c.jsx(x,{path:"payments/:transaction_id",element:c.jsx(Va,{})}),c.jsx(x,{path:"credits",element:c.jsx(ia,{})}),c.jsx(x,{path:"credits/:credit_note_id",element:c.jsx(na,{})}),c.jsx(x,{path:"discounts",element:c.jsx(ha,{})}),c.jsx(x,{path:"discounts/new",element:c.jsx(Yo,{})}),c.jsx(x,{path:"discounts/:coupon_id",element:c.jsx(Sa,{})}),c.jsx(x,{path:"dunning",element:c.jsx(ya,{})}),c.jsx(x,{path:"dunning/:case_id",element:c.jsx(ka,{})}),c.jsx(x,{path:"catalog",element:c.jsx(Wo,{})}),c.jsx(x,{path:"catalog/new",element:c.jsx(zo,{})}),c.jsx(x,{path:"catalog/:item_id",element:c.jsx(Vo,{})}),c.jsx(x,{path:"settings/*",element:c.jsx(vn,{})}),c.jsx(x,{path:"audit_log",element:c.jsx(No,{})}),c.jsx(x,{path:"data_import",element:c.jsx(ma,{})}),c.jsx(x,{path:"data_import/migrate",element:c.jsx(pa,{})}),c.jsx(x,{path:"data_import/:sessionId",element:c.jsx(ua,{})}),c.jsx(x,{path:"*",element:c.jsx(M,{})})]})}export{xc as default};
@@ -1,4 +1,4 @@
1
- import{j as a}from"./liveblocks-CFpJ3lBt.js";import{i as S,l as g,h as C,g as y,u as ee,t as ae,j as E,N as te,n as ne,o as p}from"./core-B4xcCWwD.js";import{UV as k,UW as v,UX as T,JS as D,JE as U,UY as B,UZ as oe,U_ as ie,JI as se,gl as $,JP as le,JM as re}from"./zeni-epic-state-z7dEhSaI.js";import{$ as x,I as r,a0 as de,k as j,V as M,a1 as ce,a2 as me,a3 as pe,p as V,W as ue,c as he,a4 as ge,Z as xe,f as fe,a5 as we,a6 as be,Y as Se,a7 as ye,a8 as ke,a9 as ve,aa as je}from"./index-Dhmnq53Y.js";import{n as m,u as $e}from"./mui-B8AhwxrZ.js";import f from"./NotFoundScreen-BA5GK6fZ.js";import{a as I}from"./sentry-DXRU_0Gm.js";import"./recharts-D65Mp-4O.js";import"./analytics-Bx-fDzHK.js";import"./plaid-DygABMyK.js";import"./dnd-DAPYv1yt.js";import"./stripe-cKAAJElX.js";import"./lottie-DJ3FaWjT.js";import"./lexical-Ct1kS2bH.js";import"./pdf-BJPlJ9jJ.js";import"./utils-C2swztfg.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="36a0b232-93c9-4109-94a9-ad289151d027",e._sentryDebugIdIdentifier="sentry-dbid-36a0b232-93c9-4109-94a9-ad289151d027")}catch{}})();const Ie=m.div`
1
+ import{j as a}from"./liveblocks-DOdRxZ-H.js";import{i as S,l as g,h as C,g as y,u as ee,t as ae,j as E,N as te,n as ne,o as p}from"./core-R1zvmcG1.js";import{V1 as k,V2 as v,V3 as T,J_ as D,JM as V,V4 as B,V5 as oe,V6 as ie,JQ as se,gl as $,JX as le,JU as re}from"./zeni-epic-state-Mdu-dKQU.js";import{_ as x,E as r,a0 as de,l as j,Q as M,a1 as ce,a2 as me,a3 as pe,p as G,Y as ue,$ as he,a4 as ge,k as xe,f as fe,a5 as we,a6 as be,T as Se,a7 as ye,a8 as ke,a9 as ve,aa as je}from"./index-Cvus_VBr.js";import{n as m,u as $e}from"./mui-ZKvbmPSP.js";import f from"./NotFoundScreen-BR0tBeJN.js";import{a as I}from"./sentry-DvoFEQx8.js";import"./recharts-UmMlzZlF.js";import"./analytics-BE49_JfE.js";import"./plaid-tDbexfSh.js";import"./dnd-LSyMQh_7.js";import"./stripe-cKAAJElX.js";import"./lottie-Z_NAxrmn.js";import"./lexical-BG-nDmQN.js";import"./pdf-_w1KRTSP.js";import"./utils-D06mHID-.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="394d0276-54e5-41b9-ae92-4fa8234a0454",e._sentryDebugIdIdentifier="sentry-dbid-394d0276-54e5-41b9-ae92-4fa8234a0454")}catch{}})();const Ie=m.div`
2
2
  display: flex;
3
3
  height: 100%;
4
4
  width: 100%;
@@ -7,7 +7,7 @@ import{j as a}from"./liveblocks-CFpJ3lBt.js";import{i as S,l as g,h as C,g as y,
7
7
  align-items: center;
8
8
  background-color: ${e=>e.theme.colors.grey4};
9
9
  box-shadow: ${e=>`0px 2px ${r.sp1} ${e.theme.colors.dropShadowNormal}`};
10
- `,Ce=g((function(e){const t=k(e),n=v(e),{companyName:o}=t;return{companyName:o,isDisabled:t.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,magicLinkViewState:t}}),(function(e,t){const{vendorId:n,billId:o}=t;return{onFetchBankName:i=>{e(U(i))},onSaveHandler:i=>{j.trackBillPayMagicLinkSubmitBankAccountDetails(o),e(D(i,"standard",n,o))},onACHDetailsUpdated:i=>{const{bankAccountSection:l}=i;e(T({data:l}))}}}))(de);function F(){const e=x(),{vendorId:t,billId:n}=S();return t==null||n==null?a.jsx(f,{}):a.jsx(a.Fragment,{children:a.jsx(Ie,{windowSize:e,children:a.jsx(Ce,{vendorId:t,billId:n})})})}const De=m.div`
10
+ `,Ce=g((function(e){const t=k(e),n=v(e),{companyName:o}=t;return{companyName:o,isDisabled:t.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,magicLinkViewState:t}}),(function(e,t){const{vendorId:n,billId:o}=t;return{onFetchBankName:i=>{e(V(i))},onSaveHandler:i=>{j.trackBillPayMagicLinkSubmitBankAccountDetails(o),e(D(i,"standard",n,o))},onACHDetailsUpdated:i=>{const{bankAccountSection:l}=i;e(T({data:l}))}}}))(de);function F(){const e=x(),{vendorId:t,billId:n}=S();return t==null||n==null?a.jsx(f,{}):a.jsx(a.Fragment,{children:a.jsx(Ie,{windowSize:e,children:a.jsx(Ce,{vendorId:t,billId:n})})})}const De=m.div`
11
11
  display: flex;
12
12
  height: 100vh;
13
13
  width: 100%;
@@ -25,7 +25,7 @@ import{j as a}from"./liveblocks-CFpJ3lBt.js";import{i as S,l as g,h as C,g as y,
25
25
  align-items: center;
26
26
  background-color: ${e=>e.theme.colors.grey4};
27
27
  box-shadow: ${e=>`0px 2px ${r.sp1} ${e.theme.colors.dropShadowNormal}`};
28
- `,Ne=g((function(e){const t=k(e),n=v(e),o=B(e),{companyName:i}=t;return{companyName:i,isDisabled:t.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,mailingAddressDetails:o,magicLinkViewState:t}}),(function(e,t){const{navigate:n,location:o,vendorId:i,billId:l}=t;return{onFetchBankName:s=>{e(U(s))},onSaveHandler:s=>{j.trackBillPayMagicLinkSubmitBankAccountDetails(l),e(D(s,"us-domestic",i,l))},onWireDetailsUpdated:s=>{const{bankAccountSection:d}=s;e(T({data:d}))},onAddressClick:()=>{const s=o.pathname.replace("us-domestic","address"),d=V(o.state?.pathnameStackToGoBack,o.pathname);n(s,{state:{pathnameStackToGoBack:d}})}}}))(pe);function Ee(){const e=C(),t=y(),n=x(),{vendorId:o,billId:i}=S();return o==null||i==null?a.jsx(f,{}):a.jsx(a.Fragment,{children:a.jsx(Le,{windowSize:n,children:a.jsx(Ne,{location:t,navigate:e,vendorId:o,billId:i})})})}const Fe=m.div`
28
+ `,Ne=g((function(e){const t=k(e),n=v(e),o=B(e),{companyName:i}=t;return{companyName:i,isDisabled:t.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,mailingAddressDetails:o,magicLinkViewState:t}}),(function(e,t){const{navigate:n,location:o,vendorId:i,billId:l}=t;return{onFetchBankName:s=>{e(V(s))},onSaveHandler:s=>{j.trackBillPayMagicLinkSubmitBankAccountDetails(l),e(D(s,"us-domestic",i,l))},onWireDetailsUpdated:s=>{const{bankAccountSection:d}=s;e(T({data:d}))},onAddressClick:()=>{const s=o.pathname.replace("us-domestic","address"),d=G(o.state?.pathnameStackToGoBack,o.pathname);n(s,{state:{pathnameStackToGoBack:d}})}}}))(pe);function Ee(){const e=C(),t=y(),n=x(),{vendorId:o,billId:i}=S();return o==null||i==null?a.jsx(f,{}):a.jsx(a.Fragment,{children:a.jsx(Le,{windowSize:n,children:a.jsx(Ne,{location:t,navigate:e,vendorId:o,billId:i})})})}const Fe=m.div`
29
29
  display: flex;
30
30
  height: 100%;
31
31
  width: 100%;
@@ -34,7 +34,7 @@ import{j as a}from"./liveblocks-CFpJ3lBt.js";import{i as S,l as g,h as C,g as y,
34
34
  align-items: center;
35
35
  background-color: ${e=>e.theme.colors.grey4};
36
36
  box-shadow: ${e=>`0px 2px ${r.sp1} ${e.theme.colors.dropShadowNormal}`};
37
- `,Te=g((function(e){const t=k(e),n=v(e),o=B(e),{companyName:i}=t;return{companyName:i,isDisabled:t.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,mailingAddressDetails:o,magicLinkViewState:t}}),(function(e,t){const{navigate:n,location:o,vendorId:i,billId:l}=t;return{onFetchBankNameBySwift:s=>{e(se(s))},onSaveHandler:s=>{j.trackBillPayMagicLinkSubmitBankAccountDetails(l),e(D(s,"international",i,l,t.isLocalCurrencyEnabled))},onBankDetailsUpdated:s=>{const{internationalWireSwiftAccountSection:d}=s;e(ie({data:d}))},onAddressClick:()=>{const s=o.pathname.replace("international","address"),d=V(o.state?.pathnameStackToGoBack,o.pathname);n(s,{state:{pathnameStackToGoBack:d}})}}}))(ge);function Ue(){const e=C(),t=y(),n=x(),{vendorId:o,billId:i}=S(),{useFeatureGate:l}=ue(),{isFeatureEnabled:s}=l(he.isBillPayLocalCurrencyFeatureEnabled);return o==null||i==null?a.jsx(f,{}):a.jsx(Fe,{windowSize:n,children:a.jsx(Te,{location:t,navigate:e,vendorId:o,billId:i,isLocalCurrencyEnabled:s})})}const Me={containerWidth:new ve(100,58)},Ve=m(ye)`
37
+ `,Te=g((function(e){const t=k(e),n=v(e),o=B(e),{companyName:i}=t;return{companyName:i,isDisabled:t.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,mailingAddressDetails:o,magicLinkViewState:t}}),(function(e,t){const{navigate:n,location:o,vendorId:i,billId:l}=t;return{onFetchBankNameBySwift:s=>{e(se(s))},onSaveHandler:s=>{j.trackBillPayMagicLinkSubmitBankAccountDetails(l),e(D(s,"international",i,l,t.isLocalCurrencyEnabled))},onBankDetailsUpdated:s=>{const{internationalWireSwiftAccountSection:d}=s;e(ie({data:d}))},onAddressClick:()=>{const s=o.pathname.replace("international","address"),d=G(o.state?.pathnameStackToGoBack,o.pathname);n(s,{state:{pathnameStackToGoBack:d}})}}}))(ge);function Ve(){const e=C(),t=y(),n=x(),{vendorId:o,billId:i}=S(),{useFeatureGate:l}=ue(),{isFeatureEnabled:s}=l(he.isBillPayLocalCurrencyFeatureEnabled);return o==null||i==null?a.jsx(f,{}):a.jsx(Fe,{windowSize:n,children:a.jsx(Te,{location:t,navigate:e,vendorId:o,billId:i,isLocalCurrencyEnabled:s})})}const Me={containerWidth:new ve(100,58)},Ge=m(ye)`
38
38
  width: ${r.sp4};
39
39
  height: ${r.sp4};
40
40
  margin-bottom: ${r.sp3};
@@ -43,14 +43,14 @@ import{j as a}from"./liveblocks-CFpJ3lBt.js";import{i as S,l as g,h as C,g as y,
43
43
  cursor: pointer;
44
44
  position: absolute;
45
45
  color: ${e=>e.theme.colors.brandColorJade};
46
- `,Ge=m.div`
46
+ `,Je=m.div`
47
47
  display: flex;
48
48
  height: 100vh;
49
49
  flex-direction: ${e=>e.windowSize==="small"?"column":"row"};
50
50
  width: 100vw;
51
51
  overflow-y: scroll;
52
52
  background-color: ${e=>e.theme.colors.grey4};
53
- `,Je=m.div`
53
+ `,_e=m.div`
54
54
  display: flex;
55
55
  flex-direction: ${e=>e.windowSize==="small"?"column":"row"};
56
56
  flex-direction: column;
@@ -58,7 +58,7 @@ import{j as a}from"./liveblocks-CFpJ3lBt.js";import{i as S,l as g,h as C,g as y,
58
58
  ${e=>e.windowSize!=="small"?"overflow: auto;":""}
59
59
  box-shadow: ${e=>`0px 2px ${r.sp1} ${e.theme.colors.dropShadowNormal}`};
60
60
  padding-top: ${e=>e.windowSize!=="small"?r.sp2:"0px"};
61
- `,We=m.div`
61
+ `,He=m.div`
62
62
  display: flex;
63
63
  flex-direction: column;
64
64
  align-items: center;
@@ -69,4 +69,4 @@ import{j as a}from"./liveblocks-CFpJ3lBt.js";import{i as S,l as g,h as C,g as y,
69
69
  width: ${e=>e.windowSize=="small"?"auto":"42%"};
70
70
  background-color: ${e=>e.windowSize==="small"?e.theme.colors.grey4:e.theme.colors.background};
71
71
  margin-top: ${e=>e.windowSize==="small"?e.isAddressPage?"0px":"186px":"unset"};
72
- `,_e=g((function(e,t){return{file:t.file,type:t.type}}))(ke);function h({appContent:e}){const t=ee(),n=y(),{tenantEmailDomain:o,vendorId:i,billId:l}=S(),[s]=ae(),d=s.get("token"),G=n.pathname.includes("address"),w=x(),J=xe(),A=$e(),b=fe(),W=()=>{J.toggle()},_=E((u=>k(u))),H=E((u=>v(u))),{authParams:K,fetchState:c,billAttachment:O,billFetchState:P,companyName:X,currencySymbol:Y,amount:Z}=_,{tenantId:z,userId:L,sessionId:N}=K,{fetchState:q,internationalBankAccountCreateStatus:Q}=H;return I.useEffect((()=>{$()}),[]),I.useEffect((()=>{b&&c==="Not-Started"&&i!=null&&o!=null&&d!=null&&t(le(i,o,d))}),[b,c,i,o,d,t]),I.useEffect((()=>{b&&c==="Completed"&&($(L,N,z),l!=null&&t(re(l)))}),[c,b,L,N,z,l,t]),c==="Error"?a.jsx(f,{}):q==="Completed"||Q.fetchState==="Completed"?($(),a.jsx(te,{to:"../../../../../../../bank/account/save/success",replace:!0,relative:"path"})):c==="In-Progress"?a.jsx(we,{fetchState:c,style:{height:"100vh",backgroundColor:A.colors.grey5,boxShadow:`0px 2px ${r.sp1} ${A.colors.dropShadowNormal}`}}):a.jsxs(a.Fragment,{children:[c==="Completed"&&P==="Completed"&&a.jsx(be,{analytics:j,onLoad:u=>(R=>R.trackBillPayMagicLinkPageLoad(o??"",i??"",X,l??"",He(n.pathname),Y,Z))(u)}),a.jsxs(Ge,{windowSize:w,children:[w!=="small"?a.jsx(Ve,{onClick:W}):null,a.jsx(We,{windowSize:w,isAddressPage:G,children:P==="In-Progress"?a.jsx(Se,{size:"ExtraLarge",start:!0}):a.jsx(_e,{file:O,type:"bill"})}),a.jsx(Je,{windowSize:w,children:e})]})]})}const He=e=>`${e.split("/").at(-2)}_${e.split("/").at(-1)}`;function Ke(){return a.jsx(je,{})}function da(){return a.jsxs(ne,{children:[a.jsx(p,{path:"bank/account/save/success",element:a.jsx(Ke,{})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/ach/standard",element:a.jsx(h,{appContent:a.jsx(F,{})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/ach/same-day",element:a.jsx(h,{appContent:a.jsx(F,{})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/address",element:a.jsx(h,{appContent:a.jsx(Ae,{isSubPage:!0})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/us-domestic",element:a.jsx(h,{appContent:a.jsx(Ee,{})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/international",element:a.jsx(h,{appContent:a.jsx(Ue,{})})}),a.jsx(p,{path:"*",element:a.jsx(f,{})})]})}export{da as default};
72
+ `,Ke=g((function(e,t){return{file:t.file,type:t.type}}))(ke);function h({appContent:e}){const t=ee(),n=y(),{tenantEmailDomain:o,vendorId:i,billId:l}=S(),[s]=ae(),d=s.get("token"),J=n.pathname.includes("address"),w=x(),_=xe(),A=$e(),b=fe(),H=()=>{_.toggle()},K=E((u=>k(u))),U=E((u=>v(u))),{authParams:W,fetchState:c,billAttachment:O,billFetchState:P,companyName:Q,currencySymbol:X,amount:Y}=K,{tenantId:z,userId:L,sessionId:N}=W,{fetchState:q,internationalBankAccountCreateStatus:R}=U;return I.useEffect((()=>{$()}),[]),I.useEffect((()=>{b&&c==="Not-Started"&&i!=null&&o!=null&&d!=null&&t(le(i,o,d))}),[b,c,i,o,d,t]),I.useEffect((()=>{b&&c==="Completed"&&($(L,N,z),l!=null&&t(re(l)))}),[c,b,L,N,z,l,t]),c==="Error"?a.jsx(f,{}):q==="Completed"||R.fetchState==="Completed"?($(),a.jsx(te,{to:"../../../../../../../bank/account/save/success",replace:!0,relative:"path"})):c==="In-Progress"?a.jsx(we,{fetchState:c,style:{height:"100vh",backgroundColor:A.colors.grey5,boxShadow:`0px 2px ${r.sp1} ${A.colors.dropShadowNormal}`}}):a.jsxs(a.Fragment,{children:[c==="Completed"&&P==="Completed"&&a.jsx(be,{analytics:j,onLoad:u=>(Z=>Z.trackBillPayMagicLinkPageLoad(o??"",i??"",Q,l??"",Ue(n.pathname),X,Y))(u)}),a.jsxs(Je,{windowSize:w,children:[w!=="small"?a.jsx(Ge,{onClick:H}):null,a.jsx(He,{windowSize:w,isAddressPage:J,children:P==="In-Progress"?a.jsx(Se,{size:"ExtraLarge",start:!0}):a.jsx(Ke,{file:O,type:"bill"})}),a.jsx(_e,{windowSize:w,children:e})]})]})}const Ue=e=>`${e.split("/").at(-2)}_${e.split("/").at(-1)}`;function We(){return a.jsx(je,{})}function da(){return a.jsxs(ne,{children:[a.jsx(p,{path:"bank/account/save/success",element:a.jsx(We,{})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/ach/standard",element:a.jsx(h,{appContent:a.jsx(F,{})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/ach/same-day",element:a.jsx(h,{appContent:a.jsx(F,{})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/address",element:a.jsx(h,{appContent:a.jsx(Ae,{isSubPage:!0})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/us-domestic",element:a.jsx(h,{appContent:a.jsx(Ee,{})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/international",element:a.jsx(h,{appContent:a.jsx(Ve,{})})}),a.jsx(p,{path:"*",element:a.jsx(f,{})})]})}export{da as default};
@@ -0,0 +1,12 @@
1
+ import{j as u}from"./liveblocks-DOdRxZ-H.js";import{a as g}from"./sentry-DvoFEQx8.js";import{u as O,g as _,h as w,t as V,j as l,N as U}from"./core-R1zvmcG1.js";import{z as r,G as M,J as P,l as A,K as N,S as $,T as G,N as J}from"./index-Cvus_VBr.js";import{fI as K,Uw as Q,UZ as R,UQ as W,gl as Y,gn as Z,UV as q,gY as B,dk as H,U_ as X,U$ as ee}from"./zeni-epic-state-Mdu-dKQU.js";import{u as te,n as ne}from"./mui-ZKvbmPSP.js";import{u as se}from"./useDeviceId-DiDVtEd4.js";import{f as ae}from"./analyticsHelper-DZVn8KPX.js";import{t as ie}from"./getLocaleForTenant-DZAPKjbH.js";import"./recharts-UmMlzZlF.js";import"./analytics-BE49_JfE.js";import"./plaid-tDbexfSh.js";import"./dnd-LSyMQh_7.js";import"./stripe-cKAAJElX.js";import"./lottie-Z_NAxrmn.js";import"./lexical-BG-nDmQN.js";import"./pdf-_w1KRTSP.js";import"./utils-D06mHID-.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new t.Error().stack;a&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[a]="8d913351-5620-42b1-afcf-1c64cea3c7ad",t._sentryDebugIdIdentifier="sentry-dbid-8d913351-5620-42b1-afcf-1c64cea3c7ad")}catch{}})();const T=(t,a)=>t!=null&&t.length>0&&a==="magic_links";function Te(){const t=O(),a=_(),m=w(),[y]=V(),n=y.get("token"),p=y.get("stytch_token_type"),f=r.getMagicLinkCodeVerifier(),i=se(),{otpChallenge:d,twoFAPhoneNumber:C,magicLinkEmail:c,verifyDeviceFetchState:x,resendVerifyDeviceOTPFetchState:z}=l((e=>e.tenantState)),S=l((e=>e.tenantState.fetchState)),b=l((e=>e.tenantState.activeTenantFetchState.fetchState)),I=l((e=>e.tenantState.signInState)),h=l((e=>e.tenantState.magicLinkSignInFetchState.fetchState)),s=l((e=>e.tenantState.loggedInUser)),o=l((e=>K(e))),k=l((e=>Q(e))),D=r.getSignedInUser(),v=te().mode;g.useEffect((()=>{s?.zeniSessionId==null&&n!=null&&T(n,p)&&i!=null&&f!=null&&(r.saveMagicLinkTriggered(n),t(R(n,i,f)))}),[n,p,t,i,f,s?.zeniSessionId]),g.useEffect((()=>{I!=="In-Progress"||S!=="Completed"&&b!=="Completed"||s?.zeniSessionId==null||o==null||(n!=null&&r.saveLastUsedMagicLinkToken(n),r.saveSignedInUserWithSession(s,s.zeniSessionId),r.saveSignedInUserTenants(W(k.tenantsInOrder),s.zeniSessionId),Y(s.userId,s.zeniSessionId,o.tenantId),t(Z(o.tenantId)),r.saveActiveTenantDomainForUser(o.tenantEmailDomain),t(q("Completed")),M.updateAppLocaleID(ie(o)),ae(s,o,v,void 0,k.tenantsInOrder),B().then((()=>{const e=J();e!=null&&P(e)})),setTimeout((()=>{A.trackLogin(N.Event.loginSuccess,"email",H(o.productSettings))}),2e3))}),[I,S,b,s,o,k,v,a.state,t]);const E=g.useCallback((()=>{m("/signin/auth")}),[m]),j=g.useCallback((()=>{i!=null&&d!=null&&c!=null&&t(X(i,c,d))}),[i,d,t,c]),F=g.useCallback((e=>{i!=null&&n!=null&&c!=null&&d!=null&&t(ee(e,i,c,d))}),[i,n,t,c,d]);if(h==="Completed"&&d!=null)return u.jsx($,{phoneNumber:C,verifyOtpFetchState:x.fetchState,resendVerifyDeviceOTPFetchState:z,onResendOtp:j,onVerifyOtp:F,onCancelVerifyDevice:E});if(I==="In-Progress"&&S==="Completed"&&s?.zeniSessionId!=null&&o!=null||D!=null){const e=a.state?.origin??"/";return u.jsx(U,{to:e,state:{...a.state,origin:""}})}if(!T(n,p)||f==null||h==="Error"){const e=a.state?.origin??"/",L=n!=null&&r.getLastUsedMagicLinkToken()===n;return u.jsx(U,{to:e,state:{...a.state,origin:"",magicLinkAlreadyUsed:L,magicLinkExpired:!L&&(r.isMagicLinkTriggered(n??"")||h==="Error"&&s?.zeniSessionId==null)}})}return u.jsx(oe,{"data-testid":"smooth-loader",children:u.jsx(G,{size:"ExtraLarge",start:!0})})}const oe=ne.div`
2
+ position: fixed;
3
+ top: 0;
4
+ left: 0;
5
+ right: 0;
6
+ bottom: 0;
7
+ display: flex;
8
+ align-items: center;
9
+ justify-content: center;
10
+ z-index: 9999;
11
+ background-color: ${t=>t.theme.colors.background};
12
+ `;export{Te as default};