@zeniai/web-app-ui 5.3.26-qa → 5.3.27-qa

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (150) hide show
  1. package/dist/assets/AccountMappingScreen-BQfmEpLX.js +9 -0
  2. package/dist/assets/AddressRoutes-CdpLMjIu.js +1 -0
  3. package/dist/assets/AddressScreen-CT-cfyaM.js +9 -0
  4. package/dist/assets/AiCfoScreen-DqiQxXnW.js +22 -0
  5. package/dist/assets/AppDrawer-MNEp__cO.js +10 -0
  6. package/dist/assets/{BillPayApprovalRoutes-BWcKljpL.js → BillPayApprovalRoutes-DNrNWIlc.js} +1 -1
  7. package/dist/assets/{BillPayRoutes-DxfZSGDE.js → BillPayRoutes-DnJ45sAp.js} +18 -18
  8. package/dist/assets/{BusinessVerificationPageScreen-BnngOdPs.js → BusinessVerificationPageScreen-BE7jNtnW.js} +2 -2
  9. package/dist/assets/{CardsAiCfoScreen-C9jErKn4.js → CardsAiCfoScreen-6Ka5bg_s.js} +1 -1
  10. package/dist/assets/{ChargeCardRoutes-CpllRZ3I.js → ChargeCardRoutes-DCXweRlN.js} +8 -8
  11. package/dist/assets/CompanyPassportScreen-9PIPrJD8.js +1 -0
  12. package/dist/assets/ConnectionAuthScreen-D7Id8Qyv.js +11 -0
  13. package/dist/assets/CustomerOnboardingAuthScreen-BKppasz4.js +1 -0
  14. package/dist/assets/{CustomerOnboardingRoutes-C4NalCKf.js → CustomerOnboardingRoutes-D0fsx_NF.js} +5 -5
  15. package/dist/assets/{DashboardRoutes-BYYgNdD2.js → DashboardRoutes-FqOIwMdn.js} +4 -4
  16. package/dist/assets/{DefaultTenantHome-C6nJD7za.js → DefaultTenantHome-BCa4fCFu.js} +1 -1
  17. package/dist/assets/DomesticWireDetailScreen-DYRE--Tw.js +18 -0
  18. package/dist/assets/DrawerScreen-Ch4vO2_l.js +1 -0
  19. package/dist/assets/EntityDetailRoutes-D1iT3MPR.js +1 -0
  20. package/dist/assets/{ExpenseAutomationRoutes-8pbTDpsO.js → ExpenseAutomationRoutes-OE_lY51d.js} +4 -4
  21. package/dist/assets/FeaturePreviewScreen-qqDSfjtg.js +1 -0
  22. package/dist/assets/HubSpotOAuthCallbackScreen-BJdTOO-n.js +1 -0
  23. package/dist/assets/{InboxNotificationsProvider-yp4VlF4V.js → InboxNotificationsProvider-CzhxlkVm.js} +1 -1
  24. package/dist/assets/{InvoicingRoutes-D5cSux-9.js → InvoicingRoutes-B3AeTlOl.js} +2 -2
  25. package/dist/assets/{MagicLinkRoutes-rwao6E2u.js → MagicLinkRoutes-BAk-aNDD.js} +10 -10
  26. package/dist/assets/MagicLinkSignInScreen-CzSGTOjZ.js +12 -0
  27. package/dist/assets/MobileAppDrawer-BWD9smko.js +1 -0
  28. package/dist/assets/NotFoundScreen-VUm8cLbz.js +1 -0
  29. package/dist/assets/NotificationRoutes-D0AL5w0Z.js +1 -0
  30. package/dist/assets/OAuthConsentScreen-DeyebXNT.js +1 -0
  31. package/dist/assets/PandLWithForecastRoutes-DzBBzW7r.js +1 -0
  32. package/dist/assets/{PaymentLinkScreen-CxAwIeqN.js → PaymentLinkScreen-Cwn7LxRK.js} +5 -5
  33. package/dist/assets/PeopleRoutes-DvGZoebQ.js +22 -0
  34. package/dist/assets/PerformanceRoutes-9A-lBxuM.js +1 -0
  35. package/dist/assets/{Preview-BxM5wosg.js → Preview-D-cOupgE.js} +1 -1
  36. package/dist/assets/{QBOConnectionScreen-CIODRsNA.js → QBOConnectionScreen-C9YRg79s.js} +22 -22
  37. package/dist/assets/ReimbursementApprovalRoutes-GiFApWFb.js +1 -0
  38. package/dist/assets/ReimbursementApprovalRuleDetailScreen-0HTyN3lV.js +1 -0
  39. package/dist/assets/ReimbursementRoutes-DflRsfsu.js +68 -0
  40. package/dist/assets/ReportsRoutes-B-F2r3lp.js +1 -0
  41. package/dist/assets/RewardsRoutes-CSaZHc7K.js +1 -0
  42. package/dist/assets/ScreenRoutes-C1JhTMiC.js +2 -0
  43. package/dist/assets/{SettingsRoutes-Dv5UDyEV.js → SettingsRoutes-DBQFuX0Q.js} +7 -7
  44. package/dist/assets/{SetupPagesScreen-CvaReXCR.js → SetupPagesScreen-BsaJHNfF.js} +5 -5
  45. package/dist/assets/SignInScreen-BmuYyGgl.js +1 -0
  46. package/dist/assets/SignOutScreen-2DfdubEs.js +9 -0
  47. package/dist/assets/TaskListScreen-CmZ7R7x9.js +9 -0
  48. package/dist/assets/TaskRoutes-wZ3nPlAw.js +9 -0
  49. package/dist/assets/TransactionDetailRoutes-DvkfSP-r.js +1 -0
  50. package/dist/assets/TransactionDetailScreen-BsrX2MVn.js +5 -0
  51. package/dist/assets/{TransactionListRoutes-ChfbF5Yn.js → TransactionListRoutes-Coxf-yFa.js} +1 -1
  52. package/dist/assets/{TreasuryRoutes-OIkwuzMV.js → TreasuryRoutes-DkhMbXQx.js} +5 -5
  53. package/dist/assets/{VendorsRoutes-BUXB41aT.js → VendorsRoutes-C6LVkVPB.js} +27 -27
  54. package/dist/assets/{WiseConfirmationScreen-D9W1pM9c.js → WiseConfirmationScreen-IQZ_ZF6P.js} +2 -2
  55. package/dist/assets/{ZeniAccountRoutes-DD4g7Ugu.js → ZeniAccountRoutes-CW0lRnK0.js} +10 -10
  56. package/dist/assets/ZeniAccountStatementScreen-BQTVbJHb.js +9 -0
  57. package/dist/assets/{accountMappingHelper-C4yUO_tP.js → accountMappingHelper-CabpVb3J.js} +1 -1
  58. package/dist/assets/{analytics-p9dV2gEo.js → analytics-CsVp7bfq.js} +1 -1
  59. package/dist/assets/{analyticsHelper-Cq4tYGNc.js → analyticsHelper-DA7cdp8W.js} +1 -1
  60. package/dist/assets/{core-35eDsgGP.js → core-DFhvjgE1.js} +1 -1
  61. package/dist/assets/{decodeURIComponentSafe-DhnAz_92.js → decodeURIComponentSafe-Bq1r0pP9.js} +1 -1
  62. package/dist/assets/{dnd-Dm1d6mZC.js → dnd-CR945ANw.js} +1 -1
  63. package/dist/assets/{empty-BDPRkuRZ.js → empty-BUo7eNC4.js} +1 -1
  64. package/dist/assets/{empty-DpY1OPz6.js → empty-DtCztbrx.js} +1 -1
  65. package/dist/assets/{emptyVideoElement-C6tD2_Is.js → emptyVideoElement-BHUR8Iif.js} +1 -1
  66. package/dist/assets/epic-CXAAQW1t.js +2 -0
  67. package/dist/assets/{expenseAutomationHelper-XBf0IYWB.js → expenseAutomationHelper-BDz030nC.js} +1 -1
  68. package/dist/assets/getLocaleForTenant-mARGfLdD.js +1 -0
  69. package/dist/assets/{index-DqXFykf0.js → index-BBYtI_9U.js} +1 -1
  70. package/dist/assets/{index-B3U6gyEe.js → index-BaZwiGCV.js} +1 -1
  71. package/dist/assets/{index-D-ldiYpS.js → index-BjpjXshH.js} +1 -1
  72. package/dist/assets/{index-DHtuXNZa.js → index-BuEv25D3.js} +1 -1
  73. package/dist/assets/{index-D-oz9cOM.js → index-BvtiyGfj.js} +1 -1
  74. package/dist/assets/{index-CJI7GB_s.js → index-CFhckac5.js} +1 -1
  75. package/dist/assets/{index-BBhWSYD8.js → index-Cp-pyxoH.js} +28540 -27684
  76. package/dist/assets/{index-g5u7iWai.js → index-DiQe_6d7.js} +2 -2
  77. package/dist/assets/{lexical-DQ4lSvQh.js → lexical-CCIwPSwQ.js} +1 -1
  78. package/dist/assets/{liveblocks-D0hIH2N0.js → liveblocks-BY1qt3Nf.js} +1 -1
  79. package/dist/assets/{lottie-TJOzQ6Cz.js → lottie-DgdF8254.js} +1 -1
  80. package/dist/assets/{mui-CY_LMiAy.js → mui-DesXezzU.js} +1 -1
  81. package/dist/assets/{pathToGoBack-n4Mx0taW.js → pathToGoBack-9ah_vxgB.js} +1 -1
  82. package/dist/assets/{pdf-DElOA9Iz.js → pdf-BVKoD2Fp.js} +4 -4
  83. package/dist/assets/{pdf-lib-D54M6RaZ.js → pdf-lib-B25n7och.js} +1 -1
  84. package/dist/assets/{plaid-CoaHurGj.js → plaid---yWAm21.js} +1 -1
  85. package/dist/assets/{pusher-BBz5Zhu2.js → pusher-D7k49qkv.js} +1 -1
  86. package/dist/assets/{react-psgyYffq.js → react-B5sZlhmO.js} +1 -1
  87. package/dist/assets/{react-DRB89Tf-.js → react-CNwSpjM6.js} +1 -1
  88. package/dist/assets/{react-Cn6RRlX0.js → react-Cwl8BPa_.js} +1 -1
  89. package/dist/assets/{react-CFjwLJT9.js → react-Dmj3hcZb.js} +1 -1
  90. package/dist/assets/{react-CcppuOI-.js → react-DyW_yLGE.js} +1 -1
  91. package/dist/assets/{react-DlGIFhE7.js → react-KT_bO9_E.js} +1 -1
  92. package/dist/assets/{recharts-B8j-bW95.js → recharts-Co89o1ZO.js} +1 -1
  93. package/dist/assets/routePaths-CdJe6JYT.js +1 -0
  94. package/dist/assets/{sentry-DhqS_W-k.js → sentry-xWYlrqHr.js} +1 -1
  95. package/dist/assets/{url-BniS_9P1.js → url-B6D8gSqv.js} +1 -1
  96. package/dist/assets/{url-BlblTlRS.js → url-BQb6aJ6P.js} +1 -1
  97. package/dist/assets/useAiCfoDashboardSuggestedQuestionsChips-Q3fykDPb.js +1 -0
  98. package/dist/assets/useAskAiCfoHostNavButtonProps-DqIFV4k1.js +1 -0
  99. package/dist/assets/useChargeCardPusherEvents-D6tT2l3B.js +1 -0
  100. package/dist/assets/{useDeviceId-Cd5EU_Dl.js → useDeviceId-BklKiHEX.js} +1 -1
  101. package/dist/assets/useEmailConnectResultRefresh-BZTHF4dB.js +1 -0
  102. package/dist/assets/useInitialThreadRequest-C8H1eKN2.js +1 -0
  103. package/dist/assets/{useTaskManagerAccess-DRrr5b-Z.js → useTaskManagerAccess-D4rOKbOu.js} +1 -1
  104. package/dist/assets/{utils-CgQOqOwX.js → utils-18zApAFM.js} +1 -1
  105. package/dist/assets/{withTransactionSidePanel-Cyf8gB6i.js → withTransactionSidePanel-B0GHQzqo.js} +4 -4
  106. package/dist/assets/{zeni-epic-state-BRRtwAQl.js → zeni-epic-state-DxmmAR38.js} +6 -6
  107. package/dist/index.html +1 -1
  108. package/package.json +3 -3
  109. package/dist/assets/AccountMappingScreen-vvnlkgXd.js +0 -9
  110. package/dist/assets/AddressRoutes-CqGLkDqt.js +0 -1
  111. package/dist/assets/AddressScreen-anqh6to9.js +0 -9
  112. package/dist/assets/AiCfoScreen-ZhNzgLev.js +0 -22
  113. package/dist/assets/AppDrawer-DMcZyfYw.js +0 -10
  114. package/dist/assets/CompanyPassportScreen-BQcZnLc-.js +0 -1
  115. package/dist/assets/ConnectionAuthScreen-D3Mf7qK3.js +0 -11
  116. package/dist/assets/CustomerOnboardingAuthScreen-C0sBjs60.js +0 -1
  117. package/dist/assets/DomesticWireDetailScreen-Df9Zx-eI.js +0 -18
  118. package/dist/assets/DrawerScreen-B_ZAZq-c.js +0 -1
  119. package/dist/assets/EntityDetailRoutes-BPJmlwG-.js +0 -1
  120. package/dist/assets/FeaturePreviewScreen-BhcrS0dM.js +0 -1
  121. package/dist/assets/HubSpotOAuthCallbackScreen-DY9bdeeM.js +0 -1
  122. package/dist/assets/MagicLinkSignInScreen-e8SmU6Yc.js +0 -12
  123. package/dist/assets/MobileAppDrawer-C9wi8312.js +0 -1
  124. package/dist/assets/NotFoundScreen-B6L1cY3I.js +0 -1
  125. package/dist/assets/NotificationRoutes-HbqGfq1a.js +0 -1
  126. package/dist/assets/OAuthConsentScreen-CwgWaIOt.js +0 -1
  127. package/dist/assets/PandLWithForecastRoutes-nx90MfxG.js +0 -1
  128. package/dist/assets/PeopleRoutes-4LCfOWjr.js +0 -22
  129. package/dist/assets/PerformanceRoutes-EfI4IfLY.js +0 -1
  130. package/dist/assets/ReimbursementApprovalRoutes-DfUkgvoL.js +0 -1
  131. package/dist/assets/ReimbursementApprovalRuleDetailScreen-HPs-AWde.js +0 -1
  132. package/dist/assets/ReimbursementRoutes-DvUFtazN.js +0 -68
  133. package/dist/assets/ReportsRoutes-CFpVRFNe.js +0 -1
  134. package/dist/assets/RewardsRoutes-CS-_8unl.js +0 -1
  135. package/dist/assets/ScreenRoutes-B_vqHZtF.js +0 -2
  136. package/dist/assets/SignInScreen-Cis2Hrqo.js +0 -1
  137. package/dist/assets/SignOutScreen-CgiJ4aJR.js +0 -9
  138. package/dist/assets/TaskListScreen-DsFWTjuD.js +0 -9
  139. package/dist/assets/TaskRoutes-BDVAqm9e.js +0 -9
  140. package/dist/assets/TransactionDetailRoutes-BDvPcX4f.js +0 -1
  141. package/dist/assets/TransactionDetailScreen-Bgc2K53s.js +0 -5
  142. package/dist/assets/ZeniAccountStatementScreen-BlteVo42.js +0 -9
  143. package/dist/assets/epic-BLC2ItWM.js +0 -2
  144. package/dist/assets/getLocaleForTenant-C0JZQLGG.js +0 -1
  145. package/dist/assets/routePaths-BgYQMm9p.js +0 -1
  146. package/dist/assets/useAiCfoDashboardSuggestedQuestionsChips-Dw4vBi90.js +0 -1
  147. package/dist/assets/useAskAiCfoHostNavButtonProps-DGTLHvUD.js +0 -1
  148. package/dist/assets/useChargeCardPusherEvents-COwRMcoJ.js +0 -1
  149. package/dist/assets/useEmailConnectResultRefresh-D_zBEeqz.js +0 -1
  150. package/dist/assets/useInitialThreadRequest-UvGRmRxR.js +0 -1
@@ -1,2 +1,2 @@
1
- import{j as s}from"./liveblocks-D0hIH2N0.js";import{a as r}from"./sentry-DhqS_W-k.js";import{u as P,h as L,i as w,j as E,t as z,l as T,s as H,g as W,N as B,n as ie,o as x}from"./core-35eDsgGP.js";import{a6 as ln,k as p,ao as F,S as g,c9 as dn,ca as un,cb as gn,cc as mn,cd as vn,ce as pn,cf as fn,cg as Sn,ch as hn,ci as Cn,cj as In,ck as En,cl as kn,cm as yn,p as J,cn as xn,co as bn,ac as se,cp as jn,cq as Dn,z as he,cr as Pn,cs as Ln,ct as An,cu as $n,cv as wn,cw as Fn,cx as Rn,cy as Tn,U as On,ag as ft,cz as _n,cA as Mn,cB as Nn,cC as Un,cD as Bn,cE as Vn,cF as Hn,cG as Zn,cH as qn,t as Ye,j as St,cI as Yn,cJ as Kn,cK as Qn,cL as Gn,cM as zn,cN as Wn,cO as Jn}from"./index-BBhWSYD8.js";import"./mui-CY_LMiAy.js";import{A as Y}from"./AddressScreen-anqh6to9.js";import N from"./NotFoundScreen-B6L1cY3I.js";import{YI as Xn,YJ as ei,uv as Ke,YK as De,YL as K,vz as Qe,vG as ti,vL as ht,YM as Pe,YN as Ct,vD as It,YO as Le,vB as Et,yg as ni,vC as ii,YP as Q,uY as ce,vv as oi,x7 as Ge,uX as Ce,YQ as ai,YR as kt,vS as si,YS as G,vZ as ci,YT as ri,YU as yt,YV as xt,y2 as li,YW as ue,YX as ze,YY as bt,uV as di,YZ as ui,uP as gi,Y_ as mi,xk as vi,Y$ as jt,xt as We,Z0 as pi,xq as fi,Z1 as Ae,gd as Si,Z2 as te,Z3 as ne,wc as hi,v1 as Je,Z4 as $e,v6 as Dt,v4 as Ci,u_ as Ii,w5 as Ei,v8 as ki,we as yi,Z5 as Ie,wm as Pt,wk as Ee,F6 as we,xz as Xe,Z6 as xi,uW as Fe,Z7 as Re,vh as ke,ve as ye,vr as Lt,vq as Te,vb as bi,vk as At,vt as oe,fB as Oe,Uv as $t,uZ as _e,vo as ji,vp as Di,vn as Pi,Z8 as Li,vV as et,v_ as Ai,vW as wt,Z9 as Ft,uJ as tt,Za as $i,uF as Rt,Zb as wi,xF as Fi,xJ as Z,xE as Ri,wN as Me,Zc as Ti,Zd as Tt,xS as nt,Ze as Oi,xP as _i,Zf as Ot,wQ as Mi,wR as V,wU as Ni,Zg as _t,x2 as ve,Zh as Ui,wd as Mt,T3 as Nt,Zi as Bi,xc as Vi,Zj as Ut,Zk as Hi,Zl as Zi,Zm as qi,yH as Yi,Zn as Ki,Zo as Bt,xZ as Vt,Zp as Ht,yF as pe,Zq as Qi,yC as Gi,Zr as zi,Zs as Wi,Zt as Ji,Zu as Xi,Zv as eo,Zw as it,Zx as to,yL as no,Zy as Ne,ww as ot,Zz as Ue,ZA as re,wG as Zt,wB as qt,wz as xe,ZB as io,wr as oo,y3 as Yt,yu as at,yp as ao,ZC as so,y4 as co,ZD as ro,yv as lo,yz as uo,ZE as go,ZF as Kt,c7 as mo,m6 as vo,m7 as po,ZG as st,vA as le,gh as fo,tX as So,md as ho,ym as Qt,yX as Co,yj as Gt,u1 as Io,yU as ct,tR as Eo,yR as rt,hP as ko,Tv as lt,Tw as yo,Fi as zt,hH as xo,ZH as bo,Uk as jo,ZI as Do,z1 as fe,z2 as Po,ZJ as Lo,ZK as Wt,y_ as Ao,ZL as $o,ZM as wo,xg as Fo,ZN as Ro}from"./zeni-epic-state-BRRtwAQl.js";import{M as To}from"./MobileAppDrawer-C9wi8312.js";import{q as de}from"./QBOConnectionScreen-CIODRsNA.js";import"./recharts-B8j-bW95.js";import"./analytics-p9dV2gEo.js";import"./plaid-CoaHurGj.js";import"./dnd-Dm1d6mZC.js";import"./stripe-cKAAJElX.js";import"./lottie-TJOzQ6Cz.js";import"./lexical-DQ4lSvQh.js";import"./pdf-DElOA9Iz.js";import"./utils-CgQOqOwX.js";import"./InboxNotificationsProvider-yp4VlF4V.js";import"./useTaskManagerAccess-DRrr5b-Z.js";import"./empty-BDPRkuRZ.js";import"./pdf-lib-D54M6RaZ.js";import"./index-D-ldiYpS.js";import"./url-BlblTlRS.js";import"./index-B3U6gyEe.js";import"./decodeURIComponentSafe-DhnAz_92.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new n.Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="719194b2-d41e-406a-9f93-28fbb714f3d7",n._sentryDebugIdIdentifier="sentry-dbid-719194b2-d41e-406a-9f93-28fbb714f3d7")}catch{}})();const $=({event:n,isReady:e=!0})=>e?s.jsx(ln,{analytics:p,onLoad:t=>t.trackPageLoaded(n)}):null;function U(...n){return n.some((e=>e==="Error"))}function Oo(){const n=P(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),{fetchState:m,hasMore:S,items:f,nextCursor:I,auditLogEntityRouteOptions:j,auditLogListSortFieldOptions:y}=E(Xn),k=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),b=`/${t??""}/invoicing`,C=r.useCallback(((O,R)=>{const M=ei(b,O,R,j);M!=null&&(p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{entity:O,entityId:R,fromScreen:"audit_log"}),e(M))}),[j,e,b]);r.useEffect((()=>{const O=setTimeout((()=>d(o)),300);return()=>clearTimeout(O)}),[o]),r.useEffect((()=>{i&&n(Ke({filters:k,keepExistingListItems:!1,sort:u}))}),[i,k,u,n]);const D=m==="Not-Started"||m==="In-Progress"&&f.length===0,h=m==="In-Progress"&&f.length>0,_=m==="Completed";return U(m)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingAuditLogPage,isReady:_}),s.jsx(dn,{auditLogEntityRouteOptions:j,auditLogListSortFieldOptions:y,entries:f,hasMore:S,isLoading:D,isLoadingMore:h,searchValue:o,sortState:l,onEntityLinkClick:C,onLoadMore:()=>{S&&I!=null&&n(Ke({cursor:I,filters:k,keepExistingListItems:!0,sort:u}))},onSearchChange:a,onSortChange:v})]})}const _o=new Set(["plan"]),Jt=[],Mo=Ct((n=>n.length>0?n:Jt),mn),No=Ct((n=>n.length>0?n:Jt),gn),Uo=T((function(n,e){const{view:t}=e;return{groupedAccountOptions:Mo(t.qboAccountHierarchy),groupedClassOptions:No(t.qboClassHierarchy),catalogItemLifecycleActionOptions:t.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:t.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:t.catalogTierTypeOptionsByPricingModel,periodUnitOptions:t.periodUnitOptions,trialEndActionOptions:t.trialEndActionOptions,trialUnitOptions:t.trialUnitOptions,typeOptions:t.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:t.actionState.fetchState==="In-Progress",isSaving:t.fetchState==="In-Progress",itemId:e.itemId,localData:t.localData,plan:t.plan}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${t}/catalog`),onLifecycleAction:i!==""?o=>{i!==""&&n(It({action:o,id:i}))}:void 0,onEditChange:o=>{i!==""&&n(Pe({id:i,localData:o}))},onSaveEdit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemEdited,{itemId:i}),n(ht({id:i}))},onSubFamilyLifecycleAction:(o,a)=>{i!==""&&n(ti({action:a,id:o,parentItemId:i}))}}}))(un);function Bo(){const n=P(),e=L(),{item_id:t,tenantEmailDomain:i}=w(),[o]=z(),{areTenantIdsInSync:a}=F(),c=(d=o.get("kind"))!=null&&_o.has(d)?d:"plan";var d;const l=E((k=>De(k,t))),{pageFetchState:v}=l,u=v.fetchState;r.useEffect((()=>(n(K()),()=>{n(K())})),[n]),r.useEffect((()=>{a&&n(Qe({id:t,kind:c}))}),[a,t,c,n]);const[m,S]=r.useState(0);r.useEffect((()=>{l.fetchState==="Completed"&&(n(K()),n(Qe({cacheOverride:!0,id:t,kind:c})),S((k=>k+1)))}),[l.fetchState,n,t,c]);const f=u==="Completed",[I,j]=r.useState(f?t:void 0);r.useEffect((()=>{t!=null&&f&&j(t)}),[t,f]);const y=I!==t&&(u==="Not-Started"||u==="In-Progress");return U(u)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCatalogItemDetailPage,isReady:f}),s.jsx(Uo,{navigate:e,tenantEmailDomain:i,itemId:t??"",kind:c,isLoading:y,view:l},m)]})}function Be(n={}){const{enabled:e=!0,fetchSyncHealth:t=!1,loadAccountingPickers:i=!1,reuseCached:o=!1}=n,a=P(),{areTenantIdsInSync:c}=F(),d=E(Le),l=d.connection?.connected===!0,v=d.connectionFetchState.fetchState;return r.useEffect((()=>{e&&c&&(o&&v!=="Not-Started"||a(Et()),t&&a(ni()))}),[c,a,e,t,o]),r.useEffect((()=>{e&&c&&l&&i&&a(ii())}),[c,a,e,l,i]),{isQboConnected:l,qboView:d}}function Ve(n,e=!1){const t=P(),i=E((c=>Q(c).productNextCursor!=null)),o=E((c=>Q(c).productNextCursor)),a=E((c=>Q(c).productFetchState.fetchState));r.useEffect((()=>{n&&(e&&a!=="Not-Started"||t(ce({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[n,t,e]),r.useEffect((()=>{n&&a!=="In-Progress"&&i&&o!=null&&t(ce({cursor:o,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[n,t,a,i,o])}const Vo=new Set(["addon","charge","plan"]),Ho=new Set(["plan"]),Zo=T((function(n,e){const t=De(n,e.itemId);return{fieldHelp:t.fieldHelp,isQboPickerDataLoading:t.isQboPickerDataLoading,qboClassHierarchy:t.qboClassHierarchy,qboAccountHierarchy:t.qboAccountHierarchy,applicabilityValues:t.applicabilityValues,periodUnitOptions:t.periodUnitOptions,trialEndActionOptions:t.trialEndActionOptions,trialUnitOptions:t.trialUnitOptions,typeOptions:t.typeOptions,applicableItemOptions:t.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save catalog item.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode,pricingModelValues:t.pricingModelValues,prorationValues:t.prorationValues,tierTypeOptionsByPricingModel:t.catalogTierTypeOptionsByPricingModel,tierTypeValues:t.tierTypeValues}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,i=e.isEdit?"edit":"create",{itemId:o}=e,a=o!=null?`${t}/catalog/${encodeURIComponent(o)}`:`${t}/catalog`;return{onBack:()=>e.navigate(a),onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemFormCancelled),n(K()),e.navigate(`${t}/catalog`)},onChange:c=>{n(Pe({id:o,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemSaved,{mode:i}),n(ht({id:o}))}}}))(vn);function qo(){const n=P(),e=L(),{item_id:t,tenantEmailDomain:i}=w(),[o]=z(),{areTenantIdsInSync:a}=F(),c=t!=null,d=o.get("type"),l=d!=null&&Vo.has(d)?d:void 0,v=(u=o.get("kind"))!=null&&Ho.has(u)?u:"plan";var u;const m=E((S=>De(S,t)));return Ve(a,!0),Be({loadAccountingPickers:!0,reuseCached:!0}),r.useEffect((()=>{a&&t!=null&&n(oi({id:t,kind:v}))}),[a,t,v,n]),r.useEffect((()=>{c||l==null||m.localData.catalogType===l||n(Pe({localData:{...m.localData,catalogType:l}}))}),[c,l,m.localData?.catalogType,n]),r.useEffect((()=>{if(m.fetchState==="Completed"){const S=m.savedItemId??t,f=S!=null?`/${i}/invoicing/catalog/${encodeURIComponent(S)}`:`/${i}/invoicing/catalog`;e(f),n(K())}}),[m.fetchState,m.savedItemId,t,n,e,i]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCatalogItemFormPage}),s.jsx(Zo,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:c,itemId:t})]})}const Yo={addons:"addon",all:"item",charges:"charge",plans:"plan"},Ko=T((function(n,e){const t=Q(n),i=e.activeTab==="plans",o=e.activeTab==="all",a=i?t.plans:o?[...t.plans,...t.products]:t.products,c=i||o&&t.fetchState==="In-Progress"?t.fetchState:t.productFetchState.fetchState;return{catalogItemLifecycleActionOptions:t.catalogItemLifecycleActionOptions,counts:t.count,countsLoading:t.countsFetchState.fetchState==="Not-Started"||t.countsFetchState.fetchState==="In-Progress",hasMore:i?t.planNextCursor!=null:o&&t.planNextCursor!=null||t.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&a.length===0,isLoadingMore:c==="In-Progress"&&a.length>0,plans:t.plans,productColumns:t.productColumns,products:t.products}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",o=e.activeTab==="all",a=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:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${t}/data_import`)},onAddItem:()=>{const c=Yo[e.activeTab];p.trackInvoicingActionClick(g.Event.invoicingAddCatalogItemClicked,{itemType:c}),e.navigate(`${t}/catalog/new?type=${c}`)},onItemClick:(c,d)=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemRowClicked,{itemId:d}),e.navigate(`${t}/catalog/${encodeURIComponent(d)}`)},onCatalogItemLifecycleAction:(c,d)=>{n(It({action:ai(d),id:c}))},onLoadMore:()=>{if(o)return e.planNextCursor!=null&&n(Ce({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&n(ce({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));a!=null&&n(i?Ce({cursor:a,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):ce({cursor:a,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(pn);function Qo(){const n=P(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o,a]=r.useState(""),[c,d]=r.useState("plans"),[l,v]=r.useState(""),[u,m]=r.useState(null),S=r.useMemo((()=>u!=null?{dir:u.direction,field:u.columnKey}:void 0),[u]),f=l.trim()!==""?l.trim():void 0,I=r.useMemo((()=>({search:f,type:"plan"})),[f]),j=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),y=E((O=>Q(O))),k=y.planFilters.search,b=y.planSort,C=y.planNextCursor,D=y.productNextCursor,h=y.fetchState==="Completed",_=y.runningActionId??null;return r.useEffect((()=>{const O=setTimeout((()=>v(o)),300);return()=>clearTimeout(O)}),[o]),r.useEffect((()=>{i&&n(Ge({cacheOverride:!1,planFilters:I,productFilters:j,planSort:S,productSort:S}))}),[i,n,I,j,S]),r.useEffect((()=>{i&&(f!==k||S?.field!==b?.field||S?.dir!==b?.dir)&&n(Ge({cacheOverride:!0,planFilters:I,productFilters:j,planSort:S,productSort:S}))}),[k,b,i,n,I,j,f,S]),U(y.fetchState)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCatalogPage,isReady:h}),s.jsx(Ko,{navigate:e,tenantEmailDomain:t,activeTab:c,searchValue:o,sortState:u,planFilters:I,productFilters:j,sort:S,planNextCursor:C,productNextCursor:D,runningCatalogItemActionId:_,onSearchChange:a,onTabChange:d,onSortChange:m})]})}const Go=T((function(n,e){const t=kt(n,e.couponId);return{fieldHelp:t.fieldHelp,applyOnOptions:t.applyOnOptions,discountTypeOptions:t.discountTypeOptions,durationTypeOptions:t.durationTypeOptions,errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save coupon.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode,periodUnitOptions:t.periodUnitOptions}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,o=i!=null?"edit":"create",a=i!=null?`${t}/discounts/${encodeURIComponent(i)}`:`${t}/discounts`;return{onBack:()=>e.navigate(a),onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCouponFormCancelled),n(G()),e.navigate(`${t}/discounts`)},onChange:c=>{n(ri({id:i,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCouponSaved,{mode:o}),n(ci({id:i}))}}}))(fn);function zo(){const n=P(),e=L(),{coupon_id:t,tenantEmailDomain:i}=w(),{areTenantIdsInSync:o}=F(),{fetchState:a,savedCouponId:c}=E((d=>kt(d,t)));return r.useEffect((()=>{o&&t!=null&&n(si({id:t}))}),[o,t,n]),r.useEffect((()=>{if(a==="Completed"){const d=c??t,l=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(l),n(G())}}),[a,c,t,n,e,i]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCouponFormPage}),s.jsx(Go,{couponId:t,navigate:e,tenantEmailDomain:i})]})}const Wo=T((function(n){const e=yt(n);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(n){return{dispatch:n}}),(function(n,{dispatch:e},t){const i=`/${t.tenantEmailDomain}/invoicing`;return{...n,onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreateInvoiceCancelled),t.navigate(`${i}/invoices`)},onChange:o=>{e(bt(o))},onSubmit:()=>{const o=ui(n.localData);p.trackInvoicingActionClick(g.Event.invoicingInvoiceCreated,{customerId:o.customer_id,lineItemCount:o.line_items?.length}),e(gi(o))}}}))(hn);function Jo(){const n=P(),e=L(),{tenantEmailDomain:t}=w(),[i]=z(),{areTenantIdsInSync:o}=F(),a=i.get("customerId"),c=E((C=>yt(C))),d=c.fetchState,l=c.localData,v=c.savedInvoiceId,u=E(xt),m=E((C=>li(C))),S=E(ue),f=m.fetchState==="Not-Started"||m.fetchState==="In-Progress"&&u==null,I=S.fetchState==="Not-Started"||S.fetchState==="In-Progress"&&S.customers.length===0,j=f||I,y=m.fetchState==="Completed"&&S.fetchState==="Completed";r.useEffect((()=>(n(ze()),()=>{n(ze())})),[n]);const k=r.useRef(!1);r.useEffect((()=>{k.current||a==null||a===""||l.customerId!==""||(k.current=!0,n(bt({...l,customerId:a})))}),[a,l,n]),r.useEffect((()=>{o&&n(di({cacheOverride:!1}))}),[o,n]);const b=r.useRef(d);return r.useEffect((()=>{const C=b.current;if(b.current=d,C!=="Completed"&&d==="Completed"){const D=v!=null?`/${t}/invoicing/invoices/${encodeURIComponent(v)}`:`/${t}/invoicing/invoices`;e(D)}}),[d,v,e,t]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCreateInvoicePage,isReady:y}),j?s.jsx(Sn,{}):s.jsx(Wo,{navigate:e,tenantEmailDomain:t})]})}const Xo=T((function(n,e){const{detailView:t}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:t.creditNote,creditNoteId:e.creditNoteId,isLoading:t.fetchState==="Not-Started"||t.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${t}/credits`),onCustomerClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${t}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(i)}`)}}}))(Cn);function ea(){const n=P(),e=L(),{credit_note_id:t,tenantEmailDomain:i}=w(),{areTenantIdsInSync:o}=F(),a=E((d=>mi(d,t??""))),c=a.fetchState==="Completed";return r.useEffect((()=>{o&&t!=null&&n(vi({id:t}))}),[o,t,n]),U(a.fetchState)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCreditDetailPage,isReady:c}),s.jsx(Xo,{navigate:e,tenantEmailDomain:i,creditNoteId:t??"",detailView:a})]})}const ta=T((function(n){const e=jt(n),{fetchState:t}=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:t==="Not-Started"||t==="In-Progress"&&e.creditNotes.length===0,isLoadingMore:t==="In-Progress"&&e.creditNotes.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${t}/data_import`)},onCreditNoteClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${t}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&n(fi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(In);function na(){const n=P(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:j,creditNoteListFetchState:y}=E((b=>{const C=jt(b);return{activeStatus:C.activeTab,appliedSearch:C.filters.search,appliedSort:C.sort,nextCursor:C.nextCursor,creditNoteListFetchState:C.fetchState}}),H),k=y==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&n(We({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==I?.field||u?.dir!==I?.dir)&&n(We({cacheOverride:!0,filters:m,sort:u}))}),[i,n,m,u,f,I]),U(y)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCreditsListPage,isReady:k}),s.jsx(ta,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onStatusChange:b=>n(pi(b)),onSortChange:v})]})}const Xt=(n,e,t)=>{const i=`/${n}/invoicing/customers/`;return t!=null?`${i}${encodeURIComponent(t)}/${e}/`:`${i}new/${e}/`},ia=T((function(n,e){const{editView:t,hasLoadedRecord:i}=e;return{fieldHelp:t.fieldHelp,billingAddressLabel:t.billingAddressLabel,customerTypeOptions:t.customerTypeOptions,netTermDayOptions:t.netTermDayOptions,taxabilityOptions:t.taxabilityOptions,customer:t.record.invoicingCustomer,invoices:t.record.invoices.slice(0,5),isLoading:!i&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),hasPaymentLinkEmailPreviewFailed:t.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:t.emailPreviewFetchState.fetchState==="In-Progress",isSaving:t.fetchState==="In-Progress",paymentLinkEmailPreview:t.emailPreview,isSendingPaymentLink:t.record.sendLinkState.fetchState==="In-Progress",localData:t.localData,paymentMethods:t.record.paymentMethods,sendPaymentLinkErrorMessage:t.record.sendLinkState.fetchState==="Error"?t.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:t.record.sendLinkState.fetchState==="Completed"?t.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:t.record.sendLinkState.fetchState==="Completed"?t.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:t.record.stripeConnected}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${t}/customers`),onChange:o=>{n(Ie({id:i,localData:o}))},onCreateInvoice:()=>e.navigate(`${t}/invoices/create`),onInvoiceClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(o)}`)},onCreatePromotionalCredits:()=>e.onCreatePromotionalCredits(),onNewSubscription:()=>e.navigate(`${t}/subscriptions/new`),onOpenAddress:()=>{const o=Xt(e.tenantEmailDomain??"",Ee,i),a=J(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(o,{state:{pathnameStackToGoBack:a}})},onOpenPaymentSettings:()=>e.navigate(`${t}/settings/payment-destination`),onSaveEdit:o=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerEdited,{customerId:i}),n(Ie({id:i,localData:o})),n(Pt({id:i}))},onFetchPaymentLinkEmailPreview:o=>n(yi({cacheOverride:o,customerId:i})),onSendPaymentLink:(o,a,c)=>n(ki({body:c,customerId:i,email:o,subject:a})),onSubscriptionClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:o,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(o)}`)}}}))(yn);function oa(){const n=P(),e=L(),t=W(),{customer_id:i,tenantEmailDomain:o}=w(),{areTenantIdsInSync:a}=F(),c=E((M=>Ae(M,i))),d=c.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(!1),[m,S]=r.useState(!1),[f,I]=r.useState(c.record.fetchState==="Completed"?i:void 0);r.useEffect((()=>{i!=null&&c.record.fetchState==="Completed"&&I(i)}),[i,c.record.fetchState]);const j=f===i,{plaidTokenFetchState:y,promotionalCreditSubmitState:k}=c,{paymentMethodSaveState:b,setupIntentFetchState:C,stripeConnected:D}=c.record,h=r.useRef(c.record.sendLinkState.fetchState);r.useEffect((()=>{const M=c.record.sendLinkState.fetchState;h.current!=="Error"&&M==="Error"&&n(Si({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),h.current=M}),[n,c.record.sendLinkState.fetchState]);const _=C.fetchState==="Error"?C.error?.message??"Failed to start card setup.":b.fetchState==="Error"?b.error?.message??"Failed to save payment method.":y.fetchState==="Error"?y.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(n(te()),n(ne()),()=>{n(te()),n(ne())})),[n]),r.useEffect((()=>{t.state?.openPromotionalCreditsDialog===!0&&(S(!0),e(t.pathname,{replace:!0,state:null}))}),[t.pathname,t.state,e]),r.useEffect((()=>{a&&i!=null&&n(hi({id:i}))}),[a,i,n]),r.useEffect((()=>{a&&i!=null&&D&&n(Je({customerId:i}))}),[a,i,n,D]);const[O,R]=r.useState(0);return r.useEffect((()=>{c.fetchState==="Completed"&&(n($e()),i!=null&&n(Dt({id:i})),R((M=>M+1)))}),[c.fetchState,n,i]),U(d)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCustomerDetailPage,isReady:l}),s.jsx(ia,{customerId:i??"",editView:c,hasLoadedRecord:j,location:t,navigate:e,tenantEmailDomain:o,onAddPaymentMethod:()=>{n(te()),i!=null&&D&&n(Je({customerId:i})),u(!0)},onCreatePromotionalCredits:()=>{n(ne()),S(!0)}},O),s.jsx(En,{errorMessage:_,isCreatingSetupIntent:C.fetchState==="In-Progress",isSaving:b.fetchState==="In-Progress",open:v,plaidLinkToken:c.record.plaidLinkToken,saveSucceeded:b.fetchState==="Completed",setupIntent:c.record.setupIntent,stripeConnected:D,onChooseCard:()=>{i!=null&&n(Ii({customerId:i}))},onClose:()=>{u(!1),n(te())},onSavePaymentMethod:M=>{i!=null&&n(Ci({customerId:i,data:M}))}}),s.jsx(kn,{currentBalance:c.record.invoicingCustomer?.promotionalCredits,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:k.fetchState==="Error"?k.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:k.fetchState==="In-Progress",open:m,submitSucceeded:k.fetchState==="Completed",onClose:()=>{S(!1),n(ne())},onSubmit:({amount:M,description:ee})=>{i!=null&&n(Ei({amount:M,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:ee}))}})]})}const aa=T((function(n,e){const t=Ae(n,e.customerId);return{fieldHelp:t.fieldHelp,billingAddressLabel:t.billingAddressLabel,customerTypeOptions:t.customerTypeOptions,netTermDayOptions:t.netTermDayOptions,taxabilityOptions:t.taxabilityOptions,errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save customer.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,o=i!=null?"edit":"create",a=i!=null?`${t}/customers/${encodeURIComponent(i)}`:`${t}/customers`;return{onBack:()=>e.navigate(a),onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerFormCancelled),n($e()),n(we(Ee)),e.navigate(`${t}/customers`)},onChange:c=>{n(Ie({id:i,localData:c}))},onOpenAddress:()=>{const c=Xt(e.tenantEmailDomain??"",Ee,i),d=J(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerSaved,{mode:o}),n(Pt({id:i}))}}}))(xn);function sa(){const n=P(),e=L(),t=W(),{customer_id:i,tenantEmailDomain:o}=w(),{areTenantIdsInSync:a}=F(),{fetchState:c,savedCustomerId:d}=E((l=>Ae(l,i)));return r.useEffect((()=>{a&&i!=null&&n(Dt({id:i}))}),[a,i,n]),r.useEffect((()=>{if(c==="Completed"){const l=d??i,v=l!=null?`/${o}/invoicing/customers/${encodeURIComponent(l)}`:`/${o}/invoicing/customers`;e(v),n($e())}}),[c,d,i,n,e,o]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCustomerFormPage}),s.jsx(aa,{customerId:i,location:t,navigate:e,tenantEmailDomain:o})]})}const ca=T((function(n){const e=ue(n),{fetchState:t}=e;return{addressesById:n.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:t==="Not-Started"||t==="In-Progress"&&e.customers.length===0,isLoadingMore:t==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{p.trackInvoicingActionClick(g.Event.invoicingAddCustomerClicked),e.navigate(`${t}/customers/new`)},onCustomerClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${t}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${t}/data_import`)},onRowAction:(i,o)=>{switch(o){case"createInvoice":e.navigate(`${t}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":e.navigate(`${t}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":e.navigate(`${t}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&n(Fe({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(bn);function ra(){const n=P(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:j,customerListFetchState:y}=E((b=>{const C=ue(b);return{activeStatus:C.activeTab,appliedSearch:C.filters.search,appliedSort:C.sort,nextCursor:C.nextCursor,customerListFetchState:C.fetchState}}),H),k=y==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&n(Xe({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==I?.field||u?.dir!==I?.dir)&&n(Xe({cacheOverride:!0,filters:m,sort:u}))}),[i,n,m,u,f,I]),U(y)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCustomersListPage,isReady:k}),s.jsx(ca,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onStatusChange:b=>n(xi(b)),onSortChange:v})]})}const be=(n,e)=>e==null?void 0:n.sessionDetail[e]??n.sessions.find((t=>t.id===e)),la=T((function(n,e){const{filters:t,sessionId:i,view:o}=e,a=i==null?void 0:o.diagnosticsBySession[i],c=a?.fetch.fetchState??"Not-Started";return{diagnostics:a?.items??[],errorMessage:c==="Error"?a?.fetch.error?.message:void 0,expired:a?.expired??!1,filters:t,hasMore:a?.nextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress",isLoadingMore:c==="In-Progress"&&(a?.items.length??0)>0,session:be(o,i)}}),(function(n,e){const{downloadUrl:t,filters:i,navigate:o,sessionId:a,tenantEmailDomain:c,view:d}=e,l=a==null?void 0:d.diagnosticsBySession[a],v=be(d,a),u=d.actionStateByKind.retry?.fetchState==="In-Progress",m=d.actionStateByKind.rollback?.fetchState==="In-Progress",S=v?.status==="done"&&v.rollback_available_until!=null&&new Date(v.rollback_available_until).getTime()>Date.now()&&!m;return{onBack:()=>o(`/${c}/invoicing/data_import`),onDownloadCsv:()=>{t!=null&&window.open(t,"_blank","noopener")},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{a!=null&&l?.nextCursor!=null&&n(ye({...i,cursor:l.nextCursor,sessionId:a}))},onRetry:v?.status!=="failed"||u?void 0:()=>{a!=null&&n(Te(a))},onRollback:S?()=>{a!=null&&n(Lt(a))}:void 0}}))(jn);function da(){const n=P(),e=L(),{sessionId:t,tenantEmailDomain:i}=w(),{areTenantIdsInSync:o}=F(),[a,c]=r.useState({}),d=E(Re),l=be(d,t),v=t==null?void 0:d.diagnosticsBySession[t];r.useEffect((()=>{o&&t!=null&&n(ke(t))}),[o,n,t]),r.useEffect((()=>{if(!o||t==null)return;const f=setTimeout((()=>{n(ye({...a,sessionId:t}))}),300);return()=>clearTimeout(f)}),[o,n,a,t]);const u=l?.status==="scanning"||l?.status==="importing";r.useEffect((()=>{if(!o||t==null||!u)return;const f=setInterval((()=>{n(ke(t)),n(ye({...a,sessionId:t}))}),3e3);return()=>clearInterval(f)}),[o,n,a,u,t]);const m=r.useMemo((()=>{if(t==null)return;const f=new URLSearchParams;a.moduleId!=null&&f.set("module_id",a.moduleId),a.level!=null&&f.set("level",a.level),a.outcome!=null&&f.set("outcome",a.outcome),a.search!=null&&a.search.trim()!==""&&f.set("search",a.search.trim());const I=f.toString();return`${se?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(t)}/issues.csv${I===""?"":`?${I}`}`}),[a,t]),S=v?.fetch.fetchState??"Not-Started";return U(S)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingDataImportHubPage,isReady:l!=null&&S!=="Not-Started"}),s.jsx(la,{downloadUrl:m,filters:a,navigate:e,sessionId:t,tenantEmailDomain:i,view:d,onFiltersChange:c})]})}const en=n=>`invoicing_active_migration:${n}`,ae=(n,e)=>{if(n!=null&&n!=="")try{const t=en(n);e==null?sessionStorage.removeItem(t):sessionStorage.setItem(t,e)}catch{}},ua=T((function(n,e){const{sessions:t,sessionsFetch:i,statusFetch:o,statusRows:a}=e.view;return{isLoading:!(o.fetchState!=="Not-Started"&&o.fetchState!=="In-Progress"||a.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:t,statusRows:a}}),(function(n,e){const{navigate:t,tenantEmailDomain:i}=e,o=a=>{const c=a??null;n(oe(c)),ae(i,c),t(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"continue",sessionId:a}),o(a)},onNewImport:()=>{p.trackInvoicingActionClick(g.Event.invoicingNewImportClicked),o()},onRetrySession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"retry",sessionId:a}),n(Te(a)),o(a)},onRollbackSession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"rollback",sessionId:a}),n(Lt(a))},onViewSession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"view_details",sessionId:a}),t(`/${i}/invoicing/data_import/${encodeURIComponent(a)}`)}}}))(Dn);function ga(){const n=P(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),o=E(Re);r.useEffect((()=>{i&&(n(bi()),n(At()))}),[i,n]);const a=o.statusFetch.fetchState==="Completed"&&o.sessionsFetch.fetchState==="Completed";return s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingDataImportHubPage,isReady:a}),s.jsx(ua,{navigate:e,tenantEmailDomain:t,view:o})]})}const ma=T((function(n,e){const{activeId:t,integrationsView:i,settings:o,view:a}=e,{actionStateByKind:c,sessionDetail:d,sessions:l}=a,v=i.externalConnections?.revenue?.find((m=>m.connectionName==="chargebee")),u=t!=null?d[t]:void 0;return{chargebeeConnected:o?.chargebee_connected===!0||(v?.isValid??!1),chargebeeConnectorAvailable:v!=null,chargebeeSite:o?.chargebee_site,connectError:c.connect?.error?.message,connecting:c.connect?.fetchState==="In-Progress",retrying:c.retry?.fetchState==="In-Progress",session:u??l.find((m=>m.id===t)),starting:c.start?.fetchState==="In-Progress",uploading:c.upload?.fetchState==="In-Progress"}}),(function(n,e){const{activeId:t,navigate:i,tenantEmailDomain:o}=e;return{onBack:e.onBack,onDownloadTemplates:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportTemplatesDownloaded);const a=se?.invoicingMicroServiceBaseUrl,c=a!=null&&a.length>0?a:"";window.open(`${c}/1.0/data-import/templates`,"_blank","noopener")},onFetchFromChargebee:()=>{p.trackInvoicingActionClick(g.Event.invoicingChargebeeConnectClicked),n(Pi())},onGoToIntegrations:()=>{i(`/${o}/invoicing/settings`)},onGoToOverview:()=>i(`/${o}/invoicing/overview`),onRetry:()=>{t!=null&&n(Te(t))},onSaveLater:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportStarted),t!=null&&n(Di(t))},onUpload:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportFileUploaded),n(ji({files:a}))},onViewDetails:t==null?void 0:()=>i(`/${o}/invoicing/data_import/${encodeURIComponent(t)}`)}}))(Pn);function va(){const n=P(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),o=E(xt),a=E(Oe).companyId??he.getSignedInUserTenant(t??"")?.companyId,c=E((f=>$t(f,a))),d=E(Re),{activeMigrationSessionId:l}=d,v=l??void 0,u=v!=null?d.sessionDetail[v]??d.sessions.find((f=>f.id===v)):void 0;r.useEffect((()=>{i&&(n(_e()),n(At()))}),[i,n]),r.useEffect((()=>{if(l!=null)return;const f=(I=>{if(I==null||I==="")return null;try{return sessionStorage.getItem(en(I))}catch{return null}})(t);f!=null&&n(oe(f))}),[l,n,t]),r.useEffect((()=>{ae(t,l)}),[l,t]);const m=u?.status,S=m==="scanning"||m==="importing";return r.useEffect((()=>{if(!i||v==null||!S)return;const f=setInterval((()=>{n(ke(v))}),3e3);return()=>clearInterval(f)}),[i,v,S,n]),r.useEffect((()=>{m==="done"&&(n(oe(null)),ae(t,null))}),[n,m,t]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingDataImportMigratePage}),s.jsx(ma,{activeId:v,integrationsView:c,navigate:e,settings:o,tenantEmailDomain:t,view:d,onBack:()=>{n(oe(null)),ae(t,null),e(`/${t}/invoicing/data_import`)}})]})}const pa=T((function(n,e){const{editView:t}=e;return{fieldHelp:t.fieldHelp,coupon:t.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,isLoading:!e.hasLoadedRecord&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:t.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${t}/discounts`),onLifecycleAction:o=>{n(wt({action:o,id:i}))},onSaveEdit:o=>{p.trackInvoicingActionClick(g.Event.invoicingCouponEdited,{couponId:i}),n(Ai({data:o,id:i}))}}}))(Ln);function fa(){const n=P(),e=L(),{coupon_id:t,tenantEmailDomain:i}=w(),{areTenantIdsInSync:o}=F(),a=E((I=>Li(I,t))),c=a.actionState.fetchState==="In-Progress",d=a.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(l?t:void 0);r.useEffect((()=>{t!=null&&l&&u(t)}),[t,l]);const m=v===t;r.useEffect((()=>(n(G()),()=>{n(G())})),[n]),r.useEffect((()=>{o&&n(et({id:t}))}),[o,t,n]);const[S,f]=r.useState(0);return r.useEffect((()=>{a.fetchState==="Completed"&&(n(G()),n(et({cacheOverride:!0,id:t})),f((I=>I+1)))}),[a.fetchState,n,t]),U(d)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingDiscountDetailPage,isReady:l}),s.jsx(pa,{hasLoadedRecord:m,couponId:t??"",discountLifecycleActionOptions:a.discountLifecycleActionOptions,editView:a,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},S)]})}const Sa=T((function(n){const e=Ft(n),{fetchState:t}=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:t==="Not-Started"||t==="In-Progress"&&e.coupons.length===0,isLoadingMore:t==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${t}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreateCouponClicked),e.navigate(`${t}/discounts/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${t}/data_import`)},onDiscountLifecycleAction:(i,o)=>{n(wt({action:o,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&n(Rt({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(An);function ha(){const n=P(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:j,couponListFetchState:y,runningDiscountActionId:k}=E((C=>{const D=Ft(C);return{activeStatus:D.activeTab,appliedSearch:D.filters.search,appliedSort:D.sort,nextCursor:D.nextCursor,couponListFetchState:D.fetchState,runningDiscountActionId:D.runningActionId??null}}),H),b=y==="Completed";return r.useEffect((()=>{const C=setTimeout((()=>d(o)),300);return()=>clearTimeout(C)}),[o]),r.useEffect((()=>{i&&n(tt({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==I?.field||u?.dir!==I?.dir)&&n(tt({cacheOverride:!0,filters:m,sort:u}))}),[i,n,m,u,f,I]),U(y)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingDiscountsListPage,isReady:b}),s.jsx(Sa,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,runningDiscountActionId:k,onSearchChange:a,onStatusChange:C=>n($i(C)),onSortChange:v})]})}const Ca=T((function(n,e){const{readView:t}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:t.dunningCase,isLoading:t.fetchState==="Not-Started"||t.fetchState==="In-Progress",isRunningAction:t.actionState.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,o=i!=="";return{onBack:()=>e.navigate(`${t}/dunning`),onInvoiceClick:a=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(a)}`)},onCancel:o?()=>n(Z({action:"cancel",id:i})):void 0,onResolve:o?()=>{p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"resolve",caseId:i}),n(Z({action:"resolve",id:i}))}:void 0,onResume:o?()=>{p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"resume",caseId:i}),n(Z({action:"resume",id:i}))}:void 0,onRetry:o?()=>{p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"retry",caseId:i}),n(Z({action:"retry",id:i}))}:void 0}}))(wn);function Ia(){const n=P(),e=L(),{case_id:t,tenantEmailDomain:i}=w(),{areTenantIdsInSync:o}=F(),a=E((h=>wi(h,t??""))),c=a.fetchState==="Completed",d=a.dunningCase?.invoiceID,[l,v]=r.useState("idle"),[u,m]=r.useState(!1),[S,f]=r.useState(),[I,j]=r.useState(!1),y=r.useCallback((()=>{v("idle"),m(!1),f(void 0),j(!1)}),[]),k=r.useCallback((()=>{if(t==null)return;n(Fi({id:t})),v("idle"),m(!1);const h=a.emailPreview.preview;f(h==null?void 0:{body:h.body,cc:h.cc,subject:h.subject,to:h.to}),j(!0)}),[t,n,a.emailPreview.preview]),b=r.useCallback((h=>{t!=null&&l!=="pending"&&(m(!1),v("pending"),p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"send-email",caseId:t}),n(Z({action:"send-email",body:h,id:t})))}),[t,n,l]),C=r.useMemo((()=>a.emailPreview.preview==null?void 0:{bodyToken:a.emailPreview.preview.bodyToken,renderedHtmlTemplate:a.emailPreview.preview.renderedHtmlTemplate,subjectToken:a.emailPreview.preview.subjectToken}),[a.emailPreview.preview]);r.useEffect((()=>{o&&t!=null&&n(Ri({id:t}))}),[o,t,n]),r.useEffect((()=>{o&&d!=null&&n(Me({invoiceId:d}))}),[o,d,n]),r.useEffect((()=>{v("idle"),m(!1),f(void 0),j(!1)}),[t]),r.useEffect((()=>{o||(v("idle"),m(!1),f(void 0),j(!1))}),[o]),r.useEffect((()=>{I&&S==null&&a.emailPreview.preview!=null&&f({body:a.emailPreview.preview.body,cc:a.emailPreview.preview.cc,subject:a.emailPreview.preview.subject,to:a.emailPreview.preview.to})}),[a.emailPreview.preview,S,I]),r.useEffect((()=>{l==="pending"&&(a.actionState.fetchState!=="In-Progress"?u&&a.actionState.fetchState==="Completed"?(t!=null&&n(Ti({id:t})),y()):u&&a.actionState.fetchState==="Error"&&v("failed"):m(!0))}),[t,y,n,l,u,a.actionState.fetchState]);const D=d!=null&&a.linkedInvoice?.id===d?a.linkedInvoice.dunningAttempts:void 0;return U(a.fetchState)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingDunningDetailPage,isReady:c}),s.jsx(Ca,{navigate:e,tenantEmailDomain:i,caseId:t??"",readView:a,dunningAttempts:D,onSendEmail:k}),s.jsx($n,{initialDraft:S,isPreviewLoading:a.emailPreview.fetchState==="Not-Started"||a.emailPreview.fetchState==="In-Progress",isSending:l==="pending",onClose:y,onSend:b,open:I,preview:C,previewErrorMessage:a.emailPreview.fetchState==="Error"?a.emailPreview.error?.message:void 0,sendErrorMessage:l==="failed"?a.actionState.error?.message:void 0})]})}const Ea=T((function(n){const e=Tt(n),{fetchState:t}=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:t==="Not-Started"||t==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:t==="In-Progress"&&e.dunningCases.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${t}/data_import`),onDunningCaseClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingDunningCaseRowClicked,{caseId:i}),e.navigate(`${t}/dunning/${encodeURIComponent(i)}`)},onRowAction:(i,o)=>{o!=="retry"&&o!=="resume"&&o!=="resolve"&&o!=="cancel"||n(Z({action:o,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&n(_i({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Fn);function ka(){const n=P(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:j,dunningCaseListFetchState:y}=E((b=>{const C=Tt(b);return{activeStatus:C.activeTab,appliedSearch:C.filters.search,appliedSort:C.sort,nextCursor:C.nextCursor,dunningCaseListFetchState:C.fetchState}}),H),k=y==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&n(nt({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==I?.field||u?.dir!==I?.dir)&&n(nt({cacheOverride:!0,filters:m,sort:u}))}),[i,n,m,u,f,I]),U(y)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingDunningListPage,isReady:k}),s.jsx(Ea,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onStatusChange:b=>n(Oi(b)),onSortChange:v})]})}const ya=T((function(n,e){const{view:t}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:t.billingAddress,invoice:t.invoice,invoiceId:e.invoiceId,shippingAddress:t.shippingAddress,isLoading:!e.hasLoadedRecord&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),isSaving:t.actionState.fetchState==="In-Progress",isVoiding:t.actionState.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e;return{onBack:()=>e.navigate(`${t}/invoices`),onCustomerClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:o,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${t}/customers/${encodeURIComponent(o)}`)},onIssueCreditNote:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreditNoteIssued,{invoiceId:i}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{p.trackInvoicingActionClick(g.Event.invoicingRecordPaymentClicked,{fromScreen:"invoice_detail",invoiceId:i}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceRegenerated,{invoiceId:i}),n(V({action:"regenerate",invoiceId:i}))},onSaveEdit:o=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceEdited,{invoiceId:i}),n(Ni({data:{due_date:o.due_date!==""?o.due_date:void 0,notes:o.notes.trim()!==""?o.notes.split(`
2
- `).map((a=>a.trim())).filter((a=>a!=="")).map((a=>({note:a}))):void 0,po_number:o.po_number!==""?o.po_number:null},invoiceId:i}))},onSendReminder:()=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceReminderSent,{invoiceId:i}),n(V({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:o,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(o)}`)},onVoid:o=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceVoided,{invoiceId:i}),n(V({action:"void",invoiceId:i,body:o}))}}}))(Rn);function xa(){const n=P(),e=L(),{invoice_id:t,tenantEmailDomain:i}=w(),{areTenantIdsInSync:o}=F(),a=E((m=>Ot(m,t??""))),c=a.pageFetchState.fetchState,d=c==="Completed",[l,v]=r.useState(d?t:void 0);r.useEffect((()=>{t!=null&&d&&v(t)}),[t,d]);const u=l===t;return r.useEffect((()=>{o&&t!=null&&n(Mi({invoiceId:t}))}),[o,t,n]),U(c)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingInvoiceDetailPage,isReady:d}),s.jsx(ya,{invoiceId:t??"",hasLoadedRecord:u,navigate:e,tenantEmailDomain:i,view:a})]})}const ba=T((function(n){const e=_t(n),{fetchState:t}=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:t==="Not-Started"||t==="In-Progress"&&e.invoices.length===0,isLoadingMore:t==="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(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onCreateInvoice:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreateInvoiceClicked),e.navigate(`${t}/invoices/create`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"invoices"}),e.navigate(`${t}/data_import`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceRowClicked,{invoiceId:i}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}`)},onRowAction:(i,o)=>{switch(o){case"recordPayment":e.navigate(`${t}/invoices/${encodeURIComponent(i)}/record-payment`);break;case"issueCreditNote":e.navigate(`${t}/invoices/${encodeURIComponent(i)}/issue-credit-note`);break;case"sendReminder":n(V({action:"send-reminder",invoiceId:i}));break;case"regenerate":n(V({action:"regenerate",invoiceId:i}));break;case"void":n(V({action:"void",invoiceId:i}))}},onVoidInvoice:(i,o)=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceVoided,{invoiceId:i}),n(V({action:"void",invoiceId:i,body:o}))},onLoadMore:()=>{e.nextCursor!=null&&n(Mt({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Tn);function ja(){const n=P(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:j,invoiceListFetchState:y,voidingInvoiceId:k}=E((C=>{const D=_t(C);return{activeStatus:D.activeTab,appliedSearch:D.filters.search,appliedSort:C.invoicingInvoiceListState.sort,nextCursor:D.nextCursor,invoiceListFetchState:D.fetchState,voidingInvoiceId:D.runningActionId}}),H),b=y==="Completed";return r.useEffect((()=>{const C=setTimeout((()=>d(o)),300);return()=>clearTimeout(C)}),[o]),r.useEffect((()=>{i&&n(ve({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==I?.field||u?.dir!==I?.dir)&&n(ve({cacheOverride:!0,filters:m,sort:u}))}),[i,n,m,u,f,I]),U(y)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingInvoicesListPage,isReady:b}),s.jsx(ba,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,voidingInvoiceId:k,onSearchChange:a,onStatusChange:C=>{n(Ui(C)),n(ve({cacheOverride:!1,filters:m,sort:u}))},onSortChange:v})]})}function dt(){const n=P(),e=L(),{tenantEmailDomain:t}=w(),i=On(),o=ft(),[a,c]=r.useState(!1),{acceptTermsState:d,status:l}=E(Nt),v=Bi(i?.loggedInUserRoleMap),u=`/${t}/invoicing`,m=S=>{c(S)};return l==="completed"?s.jsx(B,{to:`${u}/overview`,replace:!0}):l==="settings"&&v?s.jsx(B,{to:`${u}/settings`,replace:!0}):s.jsxs(s.Fragment,{children:[s.jsx(To,{isAppContentDrawerOpen:a,handleDrawerToggle:m}),s.jsx(_n,{analytics:p,isAccepting:d.fetchState==="In-Progress",isReadOnlyUser:!v,meetingUrl:o("invoicing_promo"),onAcceptClick:()=>{n(Vi())},onBackClick:()=>{e(`/${t}`)},onClickMenuIcon:()=>{m(!0)}})]})}const Da=T((function(n,e){const t=Ut(n,e.invoiceId),{invoice:i,localData:o,reasonCodeOptions:a,submitState:c,typeOptions:d}=t;return{fieldHelp:t.fieldHelp,amountDue:i?.amountDue,currencyCode:i?.currencyCode??"USD",customerName:i?.customerName??"",errorMessage:c.fetchState==="Error"?c.error?.message??"Failed to issue credit note. Please try again.":void 0,invoiceNumber:i?.invoiceNumber??e.invoiceId,isSubmitting:c.fetchState==="In-Progress",localData:o,reasonCodeOptions:a,typeOptions:d}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing/invoices/${encodeURIComponent(e.invoiceId)}`,i=()=>e.navigate(t);return{onBack:i,onCancel:i,onChange:o=>{n(Ki({localData:o}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreditNoteIssued,{invoiceId:e.invoiceId}),n(Yi())}}}))(Mn);function Pa(){const n=P(),e=L(),{invoice_id:t,tenantEmailDomain:i}=w(),{areTenantIdsInSync:o}=F(),{fetchState:a,invoice:c,isPageReady:d,issuedCreditNoteId:l,submitState:v}=E((f=>Ut(f,t??""))),u=`/${i}/invoicing`,m=r.useRef(null);r.useEffect((()=>{n(Hi()),m.current=null}),[n,t]),r.useEffect((()=>{o&&t!=null&&n(Me({invoiceId:t}))}),[o,n,t]),r.useEffect((()=>{c!=null&&t!=null&&a==="Completed"&&m.current!==t&&(m.current=t,n(Zi({localData:qi(c)})))}),[n,a,c,t]);const S=r.useRef(v.fetchState);return r.useEffect((()=>{const f=S.current;S.current=v.fetchState,f!=="Completed"&&v.fetchState==="Completed"&&l!=null&&e(`${u}/credits/${encodeURIComponent(l)}`)}),[l,e,v.fetchState,u]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingInvoiceDetailPage,isReady:d}),s.jsx(Da,{invoiceId:t??"",navigate:e,tenantEmailDomain:i})]})}const La=T((function(n){return{invoicingOverview:Bt(n)}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{onRefresh:()=>{n(Vt(e.selectedPeriod,!0))},onSubscriptionClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionTileClicked,{subscriptionId:i}),e.navigate(`${t}/subscriptions/${i}`)},onViewInvoices:()=>{p.trackInvoicingActionClick(g.Event.invoicingViewInvoicesClicked),e.navigate(`${t}/invoices`)},onViewPayments:()=>{p.trackInvoicingActionClick(g.Event.invoicingViewPaymentsClicked),e.navigate(`${t}/payments`)}}}))(Nn);function Aa(){const n=P(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o]=r.useState((()=>{const c=new Date;return{month:c.getMonth()+1,year:c.getFullYear()}})),a=E((c=>Bt(c).fetchState))==="Completed";return r.useEffect((()=>{i&&n(Vt(o))}),[i,n,o]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingOverviewPage,isReady:a}),s.jsx(La,{navigate:e,selectedPeriod:o,tenantEmailDomain:t})]})}const $a=T((function(n){const e=Ht(n),{fetchState:t}=e;return{columns:e.columns,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.transactions.length===0,isLoadingMore:t==="In-Progress"&&e.transactions.length>0,tabIds:e.tabIds,transactions:e.transactions}}),(function(n,e){const t=`/${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:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"payments"}),e.navigate(`${t}/data_import`)},onTransactionClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingPaymentRowClicked,{transactionId:i}),e.navigate(`${t}/payments/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&n(Gi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Un);function wa(){const n=P(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeType:S,appliedSearch:f,appliedSort:I,nextCursor:j,transactionListFetchState:y,transactions:k}=E((_=>{const O=Ht(_);return{activeType:O.activeTab,appliedSearch:O.filters.search,appliedSort:O.sort,nextCursor:O.nextCursor,transactionListFetchState:O.fetchState,transactions:O.transactions}}),H),b=y==="Completed",C=`/${t}/invoicing`,D=r.useCallback((_=>{const O=k.find((M=>M.id===_)),R=O?.linkedInvoices?.[0]?.invoiceID??O?.invoiceID;R!=null&&(p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"payments_list",invoiceId:R,toScreen:"invoice"}),e(`${C}/invoices/${encodeURIComponent(R)}`))}),[e,C,k]),h=r.useCallback((_=>{const O=k.find((R=>R.id===_))?.customerID;O!=null&&(p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:O,fromScreen:"payments_list",toScreen:"customer"}),e(`${C}/customers/${encodeURIComponent(O)}`))}),[e,C,k]);return r.useEffect((()=>{const _=setTimeout((()=>d(o)),300);return()=>clearTimeout(_)}),[o]),r.useEffect((()=>{i&&n(pe({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==I?.field||u?.dir!==I?.dir)&&n(pe({cacheOverride:!0,filters:m,sort:u}))}),[i,n,m,u,f,I]),U(y)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingPaymentsListPage,isReady:b}),s.jsx($a,{navigate:e,tenantEmailDomain:t,activeType:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onTypeChange:_=>{n(Qi(_)),n(pe({cacheOverride:!1,filters:m,sort:u}))},onSortChange:v,onViewTransactionCustomer:h,onViewTransactionInvoice:D})]})}const Fa=n=>{const e=[n.firstName,n.lastName].filter((t=>t!=null&&t.trim()!=="")).join(" ").trim();return(n.company!=null&&n.company.trim()!==""?n.company.trim():"")||e||(n.email!=null&&n.email.trim()!==""?n.email.trim():"")||n.id},ut=(n,e)=>new Intl.NumberFormat("en-US",{currency:e,style:"currency"}).format(n);function gt(){const n=P(),e=L(),{invoice_id:t,tenantEmailDomain:i}=w(),{areTenantIdsInSync:o}=F(),a=t!=null&&t!=="",c=E(ue),d=E((h=>zi(h))),l=E(Wi),v=E((h=>Ot(h,t??""))),u=v.invoice,m=`/${i}/invoicing`,S=r.useRef(null),f=r.useRef("");r.useEffect((()=>{n(Ji()),S.current=null,f.current=""}),[n,t]),r.useEffect((()=>{o&&n(a&&t!=null?Me({invoiceId:t}):Fe({filters:{},keepExistingListItems:!1}))}),[o,n,t,a]),r.useEffect((()=>{a&&u!=null&&t!=null&&v.fetchState==="Completed"&&S.current!==t&&(S.current=t,n(Xi({contextInvoiceId:t,localData:eo(u)})))}),[n,u,t,v.fetchState,a]),r.useEffect((()=>{if(a)return;const h=d.localData.customerId;h!==""&&h!==f.current&&(f.current=h,n(Mt({filters:{customerId:h},keepExistingListItems:!1})),d.localData.invoiceToLink!==""&&n(it({localData:{...d.localData,customerId:h,invoiceToLink:""}})))}),[n,d.localData,a]);const I=r.useRef(l.fetchState);r.useEffect((()=>{const h=I.current;if(I.current=l.fetchState,h!=="Completed"&&l.fetchState==="Completed"){if(l.recordedInvoiceId!=null)return void e(`${m}/invoices/${encodeURIComponent(l.recordedInvoiceId)}`);e(`${m}/payments`)}}),[e,l.fetchState,l.recordedInvoiceId,m]);const j=r.useMemo((()=>c.customers.map((h=>({id:h.id,name:Fa(h)})))),[c.customers]),y=E((h=>to(h,d.localData.customerId))),k=r.useMemo((()=>y.map((h=>({amountDue:ut(h.amountDue,"USD"),amountDueValue:h.amountDue,id:h.id,label:h.invoiceNumber})))),[y]),b=r.useMemo((()=>{if(!a||u==null)return;const h=u.currencyCode??"USD",_=u.amountDue?.amount??0;return{amountDue:ut(_,h),amountDueValue:_,currencyCode:h,customerName:u.customerName??u.customerID,invoiceId:u.id,invoiceNumber:u.invoiceNumber??u.id}}),[u,a]),C=a?`${m}/invoices/${encodeURIComponent(t??"")}`:`${m}/payments`,D=!a||v.fetchState==="Completed"&&d.localData.invoiceToLink!=="";return s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingRecordPaymentPage,isReady:D}),s.jsx(Bn,{customers:j,fieldHelp:d.fieldHelp,errorMessage:l.fetchState==="Error"?l.error?.message??"Failed to record payment. Please try again.":void 0,gatewayOptions:d.gatewayOptions,invoiceContext:b,invoiceOptions:k,isSubmitting:l.fetchState==="In-Progress",localData:d.localData,mode:a?"invoice":"customer",paymentMethodOptions:d.paymentMethodOptions,onBack:()=>{e(C)},onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingRecordPaymentCancelled),e(C)},onChange:h=>{n(it({localData:h}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingPaymentRecorded,{customerId:d.localData.customerId,invoiceId:a?t:d.localData.invoiceToLink,paymentMethod:d.localData.paymentMethod}),n(no(a?t??void 0:void 0))}})]})}const tn=(n,e,t)=>{const i=`/${n}/invoicing/subscriptions/`;return t!=null?`${i}${encodeURIComponent(t)}/${e}/`:`${i}new/${e}/`},Ra=(n,e)=>{if(n==null)return;const t=new Intl.NumberFormat("en-US",{currency:n.currencyCode??"USD",maximumFractionDigits:0,style:"currency"}).format(n.amount);return e!=null?`${t}/${e}`:t},nn=(n,e,t)=>{const i=[n,Ra(e,t)].filter((o=>o!=null&&o!=="")).join(" · ");return i!==""?i:void 0},mt=n=>n.priceCode!=null&&n.priceCode.trim()!=="",Ta=n=>({billingCycles:n.billingCycles,billingPeriod:n.period,billingPeriodUnit:n.periodUnit,label:n.name??n.id,subtitle:nn(n.productCode,n.price,n.periodUnit),value:n.priceCode}),Oa=n=>({label:n.name??n.couponCode??n.id,value:n.couponCode??n.id}),_a=T((function(n,e){const{editView:t}=e,i=t.subscription,o=i?.status,a=o!=null&&e.commercialEditAllowedFromStatuses.includes(o);return{cancelReasonCodeOptions:t.cancelReasonCodeOptions,fieldHelp:t.fieldHelp,addons:t.products.filter((c=>c.itemType==="addon")).filter(mt).map((c=>({label:c.name??c.id,subtitle:nn(c.productCode,c.price,c.periodUnit),value:c.priceCode}))),canEditCommercial:a,coupons:t.coupons.map(Oa),isLoading:!e.hasLoadedRecord&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),isRunningAction:t.actionState.fetchState==="In-Progress",isSaving:t.fetchState==="In-Progress",lifecycleActionOptions:e.lifecycleActionOptions,localData:t.localData,plans:t.plans.filter(mt).map(Ta),shippingAddressLabel:t.shippingAddressLabel,subscription:i}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,o=i!=="",a=(c,d)=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionLifecycleAction,{action:c,subscriptionId:i}),n(qt({action:c,id:i,body:d}))};return{onBack:()=>e.navigate(`${t}/subscriptions`),onChange:c=>{n(re({id:i,localData:c}))},onChangeTermEnd:o?c=>{const d=c?.trim()??"";d!==""&&a("change_term_end",{term_ends_at:d})}:void 0,onCustomerClick:c=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:c,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${t}/customers/${encodeURIComponent(c)}`,"_blank","noopener,noreferrer")},onOpenAddress:()=>{const c=tn(e.tenantEmailDomain??"",xe,i),d=J(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onViewInvoices:()=>e.navigate(`${t}/invoices`),onSaveEdit:c=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionEdited,{subscriptionId:i}),n(re({id:i,localData:c})),n(Zt({id:i}))},onCancelSubscription:o?c=>{a("cancel",{cancel_reason_code:c.cancelReasonCode,end_of_term:!1,...c.cancelReason!=null&&c.cancelReason.trim()!==""?{cancel_reason:c.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:o?(c,d)=>{c!=="pause"?a(c):a(c,d!=null&&d.trim()!==""?{resume_date:d.trim()}:void 0)}:void 0}}))(Vn);function Ma(){const n=P(),e=L(),t=W(),{subscription_id:i,tenantEmailDomain:o}=w(),{areTenantIdsInSync:a}=F(),c=E((k=>Ne(k,i))),{subscriptionCommercialEditAllowedFromStatuses:d,subscriptionLifecycleActionOptions:l,subscriptionMetadataEditAllowedFromStatuses:v}=c,u=c.pageFetchState.fetchState,m=u==="Completed",[S,f]=r.useState(m?i:void 0);r.useEffect((()=>{i!=null&&m&&f(i)}),[i,m]);const I=S===i;Ve(a),r.useEffect((()=>{a&&i!=null&&n(ot({id:i}))}),[a,i,n]);const[j,y]=r.useState(0);return r.useEffect((()=>{c.fetchState==="Completed"&&(n(Ue()),n(ot({cacheOverride:!0,id:i})),y((k=>k+1)))}),[c.fetchState,n,i]),U(u)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingSubscriptionDetailPage,isReady:m}),s.jsx(_a,{hasLoadedRecord:I,commercialEditAllowedFromStatuses:d,editView:c,lifecycleActionOptions:l,location:t,metadataEditAllowedFromStatuses:v,navigate:e,subscriptionId:i??"",tenantEmailDomain:o},j)]})}const Na=n=>{const e=[n.firstName,n.lastName].filter((t=>t!=null&&t.trim()!=="")).join(" ").trim();return(n.company!=null&&n.company.trim()!==""?n.company.trim():"")||e||(n.email!=null&&n.email.trim()!==""?n.email.trim():"")||n.id},Ua=(n,e)=>{if(n==null)return;const t=new Intl.NumberFormat("en-US",{currency:n.currencyCode??"USD",maximumFractionDigits:0,style:"currency"}).format(n.amount);return e!=null?`${t}/${e}`:t},je=(n,e,t)=>{const i=[n,Ua(e,t)].filter((o=>o!=null&&o!=="")).join(" · ");return i!==""?i:void 0},Ba=n=>({label:Na(n),value:n.id}),Se=n=>n.priceCode!=null&&n.priceCode.trim()!=="",Va=n=>({billingCycles:n.billingCycles,billingPeriod:n.period,billingPeriodUnit:n.periodUnit,label:n.name??n.id,subtitle:je(n.productCode,n.price,n.periodUnit),trialPeriod:n.trialPeriod,trialPeriodUnit:n.trialPeriodUnit,value:n.priceCode}),Ha=n=>({label:n.name??n.couponCode??n.id,value:n.couponCode??n.id}),Za=T((function(n,e){const t=Ne(n,e.subscriptionId);return{fieldHelp:t.fieldHelp,addons:t.products.filter((i=>i.itemType==="addon")).filter(Se).map((i=>({label:i.name??i.id,subtitle:je(i.productCode,i.price,i.periodUnit),value:i.priceCode}))),charges:t.products.filter((i=>i.itemType==="charge")).filter(Se).map((i=>({label:i.name??i.id,subtitle:je(i.productCode,i.price,void 0),value:i.priceCode}))),coupons:t.coupons.map(Ha),customers:t.customers.map(Ba),errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save subscription.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode,plans:t.plans.filter(Se).map(Va),shippingAddressLabel:t.shippingAddressLabel}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,o=i!=null?"edit":"create";return{onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionFormCancelled),n(Ue()),n(we(xe)),i==null?e.navigate(`${t}/subscriptions`):e.navigate(`${t}/subscriptions/${encodeURIComponent(i)}`)},onChange:a=>{n(re({id:i,localData:a}))},onOpenAddress:()=>{const a=tn(e.tenantEmailDomain??"",xe,i),c=J(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:c}})},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionSaved,{mode:o}),n(Zt({id:i}))}}}))(Hn);function qa(){const n=P(),e=L(),t=W(),{subscription_id:i,tenantEmailDomain:o}=w(),[a]=z(),{areTenantIdsInSync:c}=F(),d=a.get("customerId"),{fetchState:l,savedSubscriptionId:v}=E((S=>io(S,i))),u=E((S=>Ne(S,i).localData));Ve(c),r.useEffect((()=>{c&&(n(Fe({filters:{},keepExistingListItems:!1})),n(Ce({filters:{type:"plan"},keepExistingListItems:!1})),n(Rt({filters:{},keepExistingListItems:!1})),i!=null&&n(oo({id:i})))}),[c,i,n]);const m=r.useRef(!1);return r.useEffect((()=>{m.current||i!=null||d==null||d===""||u.customerId!==""||(m.current=!0,n(re({id:i,localData:{...u,customerId:d}})))}),[d,i,u,n]),r.useEffect((()=>{if(l==="Completed"){const S=v??i,f=S!=null?`/${o}/invoicing/subscriptions/${encodeURIComponent(S)}`:`/${o}/invoicing/subscriptions`;e(f),n(Ue())}}),[l,v,i,n,e,o]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingSubscriptionFormPage}),s.jsx(Za,{location:t,navigate:e,subscriptionId:i,tenantEmailDomain:o})]})}const Ya=T((function(n){const e=Yt(n),{fetchState:t}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.subscriptions.length===0,isLoadingMore:t==="In-Progress"&&e.subscriptions.length>0,cancelReasonCodeOptions:e.cancelReasonCodeOptions,lifecycleActionOptions:e.subscriptionLifecycleActionOptions,subscriptions:e.subscriptions,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,i=(o,a,c)=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionLifecycleAction,{action:a,subscriptionId:o}),n(qt({action:a,id:o,body:c}))};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onAddSubscription:()=>{p.trackInvoicingActionClick(g.Event.invoicingAddSubscriptionClicked),e.navigate(`${t}/subscriptions/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"subscriptions"}),e.navigate(`${t}/data_import`)},onChangeTermEnd:(o,a)=>{const c=a?.trim()??"";c!==""&&i(o,"change_term_end",{term_ends_at:c})},onSubscriptionAction:(o,a,c)=>{a!=="pause"?i(o,a):i(o,a,c!=null&&c.trim()!==""?{resume_date:c.trim()}:void 0)},onCancelSubscription:(o,a)=>{i(o,"cancel",{cancel_reason_code:a.cancelReasonCode,end_of_term:!1,...a.cancelReason!=null&&a.cancelReason.trim()!==""?{cancel_reason:a.cancelReason.trim()}:{}})},onSubscriptionClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionRowClicked,{subscriptionId:o}),e.navigate(`${t}/subscriptions/${encodeURIComponent(o)}`)},onViewSubscriptionInvoices:()=>{e.navigate(`${t}/invoices`)},onLoadMore:()=>{e.nextCursor!=null&&n(co({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Zn);function Ka(){const n=P(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:j,subscriptionListFetchState:y,runningActionSubscriptionId:k}=E((D=>{const h=Yt(D);return{activeStatus:h.activeTab,appliedSearch:h.filters.search,appliedSort:h.sort,nextCursor:h.nextCursor,subscriptionListFetchState:h.fetchState,runningActionSubscriptionId:h.runningActionId??null}}),H),b=y==="Completed";r.useEffect((()=>{const D=setTimeout((()=>d(o)),300);return()=>clearTimeout(D)}),[o]),r.useEffect((()=>{i&&n(at({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==I?.field||u?.dir!==I?.dir)&&n(at({cacheOverride:!0,filters:m,sort:u}))}),[i,n,m,u,f,I]);const C=r.useRef(k);return r.useEffect((()=>{const D=C.current!=null&&k==null;C.current=k,D&&i&&n(ao())}),[k,i,n]),U(y)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingSubscriptionsListPage,isReady:b}),s.jsx(Ya,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,runningActionSubscriptionId:k,onSearchChange:a,onStatusChange:D=>n(so(D)),onSortChange:v})]})}const Qa=T((function(n,e){const{readView:t}=e;return{isLoading:t.fetchState==="Not-Started"||t.fetchState==="In-Progress",isRunningAction:t.actionState.fetchState==="In-Progress",transaction:t.transaction,transactionId:e.transactionId}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{transactionId:i}=e;return{onBack:()=>e.navigate(`${t}/payments`),onCustomerClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:o,fromScreen:"transaction_detail",toScreen:"customer"}),e.navigate(`${t}/customers/${encodeURIComponent(o)}`)},onInvoiceClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(o)}`)},onSubscriptionClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",subscriptionId:o,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(o)}`)},onCapture:i!==""?()=>{p.trackInvoicingActionClick(g.Event.invoicingTransactionCaptured,{transactionId:i}),n(uo({action:"capture",id:i}))}:void 0}}))(qn);function Ga(){const n=P(),e=L(),{tenantEmailDomain:t,transaction_id:i}=w(),{areTenantIdsInSync:o}=F(),a=E((d=>ro(d,i??""))),c=a.fetchState==="Completed";return r.useEffect((()=>{o&&i!=null&&n(lo({id:i}))}),[o,i,n]),U(a.fetchState)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingTransactionDetailPage,isReady:c}),s.jsx(Qa,{navigate:e,tenantEmailDomain:t,transactionId:i??"",readView:a})]})}const za={branding:"invoicing_branding_save",dunning:"invoicing_dunning_settings_save",quickbooks:"invoicing_qbo_settings_save"};function X(n){const e=P(),{areTenantIdsInSync:t}=F(),{tenantEmailDomain:i}=w(),{fetchState:o,fieldHelp:a,saveState:c,settings:d,stripeConnectState:l}=E(go),{configError:v,configFetchState:u,dunningScheduleActionOptions:m,qboAccountMappingKindOptions:S,qboCustomerMatchingOptions:f,qboSyncStatusOptions:I}=E(Kt),j=E(Le);Be({enabled:n==="quickbooks",fetchSyncHealth:!0,loadAccountingPickers:!0});const y=E(Oe),k=n==="dunning"||n==="quickbooks",b=y.companyId??he.getSignedInUserTenant(i??"")?.companyId,C=E((A=>$t(A,b))),D=mo(y.userRole??[]),h=y.tenantId??"",_=he.getSignedInUser(),O={userId:_?.userId??"",sessionId:_?.zeniSessionId??"",tenantId:h},R=d?.logo_file_id,M=E((A=>R!=null&&R!==""?A.fileState.fileByFileId[R]:void 0)),ee=E((A=>R!=null&&R!==""?vo(A,R):void 0)),He=E((A=>R!=null&&R!==""?po(A,R):void 0)),on=R!=null&&R!==""&&ee!=null?{[R]:ee}:{},an=R!=null&&R!==""&&He!=null?{[R]:He}:{};r.useEffect((()=>(e(st()),()=>{e(st())})),[e]),r.useEffect((()=>{t&&(o!=="Not-Started"&&o!=="Error"||e(_e()))}),[t,e,o]),r.useEffect((()=>{t&&k&&u==="Not-Started"&&e(le())}),[t,e,u,k]),r.useEffect((()=>{if(!t)return;const A=_?.userId;A!=null&&A!==""&&h!==""&&Ye.shouldFetchActiveTenant(h)&&(Ye.markActiveTenantFetchStarted(h),e(fo(A,h,_?.zeniSessionId)))}),[t,e,_?.userId,_?.zeniSessionId,h]),r.useEffect((()=>{t&&R!=null&&R!==""&&h!==""&&M==null&&e(So(R,h))}),[t,e,M,R,h]);const sn=m.length>0||S.length>0,cn=o==="Not-Started"||o==="In-Progress"&&d==null||k&&!sn&&(u==="Not-Started"||u==="In-Progress"),rn=o==="Completed"&&(!k||u==="Completed"),Ze=C.externalConnections?.revenue?.find((A=>A.connectionName==="chargebee"))?.connectionId,ge=se?.invoicingMicroServiceBaseUrl,qe=ge!=null&&ge.length>0?`${ge}/1.0/webhooks/stripe`:"",me={deleteConnectionError:C.externalConnections?.deleteConnectionError?.message,deleteConnectionState:C.externalConnections?.deleteConnectionState??"Not-Started",integrationsView:C,isAdmin:D,isStripeBusy:l.fetchState==="In-Progress",onConnectStripe:A=>e(rt(A)),onDisconnect:(A,q)=>{h!==""&&e(xo(h,A,lt(q)))},onDisconnectStripe:()=>e(ct()),onReconnectQBO:()=>{const A=y.tenantEmailDomain??i??"";de.init("/connection/auth",A),de.handleClick()},onRefreshQBO:()=>{C.integrations.refreshQBO.fetchState!=="In-Progress"&&e(zt())},onSaveChargeBeeCredentials:(A,q)=>{Ze!=null&&h!==""&&e(ko(h,Ze,lt("revenue"),yo("chargebee"),{api_key:A,site:q}))},saveChargeBeeError:C.externalConnections?.saveAPIKeyConnectionError?.message,saveChargeBeeState:C.externalConnections?.saveAPIKeyConnectionState??"Not-Started",settings:d,stripeError:l.fetchState==="Error"?l.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:qe};return{authParams:O,deleteFileStatusById:on,fieldHelp:a,dunningScheduleActionOptions:m,filesEndPoint:se?.fileMicroServiceBaseUrl??"",integrationsSectionProps:me,isInvoicingPageReady:rn,isLoading:cn,isSaving:c.fetchState==="In-Progress",isStripeBusy:l.fetchState==="In-Progress",logoFile:M,qboAccountMappingKindOptions:S,qboCustomerMatchingOptions:f,qboSyncStatusOptions:I,qboView:j,saveErrorMessage:c.fetchState==="Error"?c.error?.message??"Failed to save settings.":k&&u==="Error"?v?.message??"Failed to load invoicing configuration.":void 0,settings:d,stripeError:l.fetchState==="Error"?l.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:qe,updateFileStatusById:an,onConnectStripe:A=>e(rt(A)),onDeleteFile:A=>e(Eo(A)),onDisconnectStripe:()=>e(ct()),onEditFileName:(A,q)=>e(Io(A,q)),onReconnectQBO:me.onReconnectQBO,onRefreshQBO:me.onRefreshQBO,onRetryQboSyncTask:A=>e(Gt(A)),onSave:A=>{p.trackInvoicingActionClick(g.Event.invoicingSettingsSaved,{tab:n??"hub"}),e(Co({settings:A,snackbarSection:za[n??""]}))},onStartQboBackfill:A=>e(Qt(A)),updateFilesEntity:A=>{p.trackInvoicingActionClick(g.Event.invoicingLogoUploaded),e(ho({files:A}))}}}function vt({appContent:n}){const e=L(),t=W(),i=P(),{tenantEmailDomain:o}=w(),a=X("branding"),c=E((v=>bo(v))),d=E((v=>jo(fe,v)?.addressToCreate));r.useEffect((()=>{c.saveState.fetchState==="Completed"&&(i(Do()),i(we(fe)))}),[c.saveState.fetchState,i]);const l=St(c.saveState.fetchState);return r.useEffect((()=>{l==="In-Progress"&&c.saveState.fetchState==="Completed"&&e("..")}),[l,c.saveState.fetchState,e]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingSettingsPage,isReady:a.isInvoicingPageReady}),s.jsx(Yn,{address:d,fieldHelp:c.fieldHelp,addressLabel:c.addressLabel,appContent:n,authParams:a.authParams,dateFormatOptions:c.dateFormatOptions,deleteFileStatusById:a.deleteFileStatusById,filesEndPoint:a.filesEndPoint,isLoading:a.isLoading,isSaving:a.isSaving,localData:c.localData,saveErrorMessage:a.saveErrorMessage,settings:a.settings,updateFileStatusById:a.updateFileStatusById,onBackClick:()=>e(".."),onChange:v=>{i(Lo({localData:v}))},onDeleteFile:a.onDeleteFile,onEditFileName:a.onEditFileName,onOpenAddress:()=>{const v=`/${o}/invoicing/settings/branding/${fe}/`,u=J(t.state?.pathnameStackToGoBack,t.pathname);e(v,{state:{pathnameStackToGoBack:u}})},onSubmit:()=>i(Po()),updateFilesEntity:a.updateFilesEntity})]})}function Wa(){const n=L(),e=X("dunning");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Kn,{dunningScheduleActionOptions:e.dunningScheduleActionOptions,isLoading:e.isLoading,isSaving:e.isSaving,saveErrorMessage:e.saveErrorMessage,settings:e.settings,onBackClick:()=>n(".."),onSave:e.onSave})]})}function Ja(){const n=L(),e=X("integrations");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Qn,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>n("../quickbooks"),onOpenPaymentDestination:()=>n("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>n("..")})]})}function Xa(){const n=L(),e=X("payment-destination");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Gn,{fieldHelp:e.fieldHelp,isLoading:e.isLoading,isStripeBusy:e.isStripeBusy,saveErrorMessage:e.saveErrorMessage,settings:e.settings,stripeError:e.stripeError,stripeWebhookUrl:e.stripeWebhookUrl,onBackClick:()=>n(".."),onConnectStripe:e.onConnectStripe})]})}const es=T((function(n){const e=Wt(n);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(n){return{onChange:e=>{n(wo({localData:e}))},onReset:()=>{n($o())},onRetryTask:e=>{n(Gt(e))},onSave:()=>{p.trackInvoicingActionClick(g.Event.invoicingSettingsSaved,{tab:"quickbooks"}),n(Ao())},onStartBackfill:e=>{n(Qt(e))}}}))(zn);function ts(){const n=P(),e=L(),{tenantEmailDomain:t}=w(),i=E(Oe),{configFetchState:o,settingsFetchState:a}=E(Wt);return r.useEffect((()=>{a!=="Not-Started"&&a!=="Error"||n(_e())}),[n,a]),r.useEffect((()=>{o==="Not-Started"&&n(le())}),[o,n]),Be({fetchSyncHealth:!0,loadAccountingPickers:!0}),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingSettingsPage}),s.jsx(es,{onBackClick:()=>e(".."),onReconnect:()=>{de.init("/connection/auth",i.tenantEmailDomain??t??""),de.handleClick()},onRefresh:()=>n(zt())})]})}const ns={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function is(){const n=ft(),e=P(),t=L(),[i,o]=z(),a=X(),{canEnableInvoicing:c,isEnablingInvoicing:d,isInvoicingEnabled:l,isQboConfigured:v,isStripeConnected:u}=E(Kt),m=i.get("tab");return r.useEffect((()=>{if(m==null)return;const S=ns[m];o({},{replace:!0}),S!=null&&t(S,{replace:!0})}),[m,t,o]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingSettingsPage,isReady:a.isInvoicingPageReady}),s.jsx(Wn,{analytics:p,integrationsSectionProps:{...a.integrationsSectionProps,onConfigureQBO:()=>t("quickbooks"),onOpenPaymentDestination:()=>t("payment-destination")},isEnablingInvoicing:d,isLoading:a.isLoading,meetingUrl:n("invoicing_settings"),settings:a.settings,onBrandingClick:()=>t("branding"),onDunningClick:()=>t("dunning"),canEnableInvoicing:c,isQboConfigured:v,isStripePaymentsReady:u,onEnableInvoicingClick:l?void 0:()=>{e(Fo())}})]})}function pt(){return s.jsxs(ie,{children:[s.jsx(x,{index:!0,element:s.jsx(is,{})}),s.jsx(x,{path:"payment-destination",element:s.jsx(Xa,{})}),s.jsx(x,{path:"branding",element:s.jsx(vt,{})}),s.jsx(x,{path:"branding/:addressType",element:s.jsx(vt,{appContent:s.jsx(Y,{isSubPage:!0,hideAddressBackButton:!0})})}),s.jsx(x,{path:"integrations",element:s.jsx(Ja,{})}),s.jsx(x,{path:"dunning",element:s.jsx(Wa,{})}),s.jsx(x,{path:"quickbooks",element:s.jsx(ts,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:"..",replace:!0})})]})}function $s(){const n=P(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),{enableState:o,fetchState:a,status:c}=E(Nt),d=St(o.fetchState),l=`/${t}/invoicing`,v=r.useRef(!1),u=E((m=>Le(m).connectionFetchState.fetchState));return r.useEffect((()=>{i&&(a!=="Not-Started"?a!=="Error"||v.current||(v.current=!0,n(le({cacheOverride:!1}))):n(le({cacheOverride:!1})))}),[i,n,a]),r.useEffect((()=>{i&&u==="Not-Started"&&n(Et())}),[i,n,u]),r.useEffect((()=>{d==="In-Progress"&&o.fetchState==="Completed"&&(e(`${l}/catalog`),n(Ro()))}),[d,o.fetchState,l,n,e]),c==null&&a!=="Error"?s.jsx(Jn,{}):c==="not_started"?s.jsxs(ie,{children:[s.jsx(x,{path:"promo",element:s.jsx(dt,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:`${l}/promo`,replace:!0})})]}):c==="settings"?s.jsxs(ie,{children:[s.jsx(x,{path:"promo",element:s.jsx(dt,{})}),s.jsx(x,{path:"settings/*",element:s.jsx(pt,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:`${l}/settings`,replace:!0})})]}):s.jsxs(ie,{children:[s.jsx(x,{path:"/",element:s.jsx(B,{to:"overview",replace:!0})}),s.jsx(x,{path:"overview",element:s.jsx(Aa,{})}),s.jsx(x,{path:"promo",element:s.jsx(B,{to:`${l}/overview`,replace:!0})}),s.jsx(x,{path:"customers",element:s.jsx(ra,{})}),s.jsx(x,{path:"customers/new",element:s.jsx(sa,{})}),s.jsx(x,{path:"customers/new/:addressType",element:s.jsx(Y,{})}),s.jsx(x,{path:"customers/:customer_id",element:s.jsx(oa,{})}),s.jsx(x,{path:"customers/:customer_id/:addressType",element:s.jsx(Y,{})}),s.jsx(x,{path:"subscriptions",element:s.jsx(Ka,{})}),s.jsx(x,{path:"subscriptions/new",element:s.jsx(qa,{})}),s.jsx(x,{path:"subscriptions/new/:addressType",element:s.jsx(Y,{})}),s.jsx(x,{path:"subscriptions/:subscription_id",element:s.jsx(Ma,{})}),s.jsx(x,{path:"subscriptions/:subscription_id/:addressType",element:s.jsx(Y,{})}),s.jsx(x,{path:"invoices",element:s.jsx(ja,{})}),s.jsx(x,{path:"invoices/create",element:s.jsx(Jo,{})}),s.jsx(x,{path:"invoices/:invoice_id",element:s.jsx(xa,{})}),s.jsx(x,{path:"invoices/:invoice_id/record-payment",element:s.jsx(gt,{})}),s.jsx(x,{path:"invoices/:invoice_id/issue-credit-note",element:s.jsx(Pa,{})}),s.jsx(x,{path:"payments",element:s.jsx(wa,{})}),s.jsx(x,{path:"payments/record",element:s.jsx(gt,{})}),s.jsx(x,{path:"payments/:transaction_id",element:s.jsx(Ga,{})}),s.jsx(x,{path:"credits",element:s.jsx(na,{})}),s.jsx(x,{path:"credits/:credit_note_id",element:s.jsx(ea,{})}),s.jsx(x,{path:"discounts",element:s.jsx(ha,{})}),s.jsx(x,{path:"discounts/new",element:s.jsx(zo,{})}),s.jsx(x,{path:"discounts/:coupon_id",element:s.jsx(fa,{})}),s.jsx(x,{path:"dunning",element:s.jsx(ka,{})}),s.jsx(x,{path:"dunning/:case_id",element:s.jsx(Ia,{})}),s.jsx(x,{path:"catalog",element:s.jsx(Qo,{})}),s.jsx(x,{path:"catalog/new",element:s.jsx(qo,{})}),s.jsx(x,{path:"catalog/:item_id",element:s.jsx(Bo,{})}),s.jsx(x,{path:"settings/*",element:s.jsx(pt,{})}),s.jsx(x,{path:"audit_log",element:s.jsx(Oo,{})}),s.jsx(x,{path:"data_import",element:s.jsx(ga,{})}),s.jsx(x,{path:"data_import/migrate",element:s.jsx(va,{})}),s.jsx(x,{path:"data_import/:sessionId",element:s.jsx(da,{})}),s.jsx(x,{path:"*",element:s.jsx(N,{})})]})}export{$s as default};
1
+ import{j as s}from"./liveblocks-BY1qt3Nf.js";import{a as r}from"./sentry-xWYlrqHr.js";import{u as D,h as L,i as w,j as E,t as W,l as T,s as Z,g as J,N as B,n as ie,o as x}from"./core-DFhvjgE1.js";import{a8 as ln,k as p,aq as F,U as g,cb as dn,cc as un,cd as gn,ce as mn,cf as vn,cg as pn,ch as fn,ci as Sn,cj as hn,ck as Cn,cl as In,cm as En,cn as kn,co as yn,p as X,cp as xn,cq as bn,ae as se,cr as jn,cs as Pn,z as he,ct as Dn,cu as Ln,cv as An,cw as $n,cx as wn,cy as Fn,cz as Rn,cA as Tn,V as On,ai as ft,cB as _n,cC as Mn,cD as Nn,cE as Un,cF as Bn,cG as Vn,cH as Zn,cI as Hn,cJ as qn,t as Ke,j as St,cK as Kn,cL as Qn,cM as Gn,cN as zn,cO as Wn,cP as Jn,cQ as Xn}from"./index-Cp-pyxoH.js";import"./mui-DesXezzU.js";import{A as K}from"./AddressScreen-CT-cfyaM.js";import N from"./NotFoundScreen-VUm8cLbz.js";import{Z0 as Yn,Z1 as ei,uM as Qe,Z2 as Pe,Z3 as Q,vQ as Ge,vX as ti,w0 as ht,Z4 as De,Z5 as Ct,vU as It,Z6 as Le,vS as Et,yw as ni,vT as ii,Z7 as G,vd as ce,vM as oi,xn as ze,vc as Ce,Z8 as ai,Z9 as kt,w7 as si,Za as z,we as ci,Zb as ri,Zc as yt,Zd as xt,yi as li,Ze as ue,Zf as We,Zg as bt,va as di,Zh as ui,v4 as gi,Zi as mi,xA as vi,Zj as jt,xJ as Je,Zk as pi,xG as fi,Zl as Ae,gd as Si,Zm as te,Zn as ne,wt as hi,vi as Xe,Zo as $e,vn as Pt,vl as Ci,vf as Ii,wm as Ei,vp as ki,wv as yi,Zp as Ie,wC as Dt,wA as Ee,Fm as we,xP as Ye,Zq as xi,vb as Fe,Zr as Re,vy as ke,vv as ye,vI as Lt,vH as Te,vs as bi,vB as At,vK as oe,fB as Oe,UP as $t,ve as _e,vF as ji,vG as Pi,vE as Di,Zs as Li,wa as et,wf as Ai,wb as wt,Zt as Ft,u_ as tt,Zu as $i,uW as Rt,Zv as wi,xV as Fi,xZ as H,xU as Ri,x1 as Me,Zw as Ti,Zx as Tt,y6 as nt,Zy as Oi,y3 as _i,Zz as Ot,x4 as Mi,x5 as V,x8 as Ni,ZA as _t,xi as ve,ZB as Ui,wu as Mt,Tm as Nt,ZC as Bi,xs as Vi,ZD as Ut,ZE as Zi,ZF as Hi,ZG as qi,yX as Ki,ZH as Qi,ZI as Bt,yd as Vt,ZJ as Zt,yV as pe,ZK as Gi,yS as zi,ZL as Wi,ZM as Ji,ZN as Xi,ZO as Yi,ZP as eo,ZQ as it,ZR as to,y$ as no,ZS as Ne,wM as ot,ZT as Ue,ZU as re,wW as Ht,wR as qt,wP as xe,ZV as io,wH as oo,yj as Kt,yK as at,yF as ao,ZW as so,yk as co,ZX as ro,yL as lo,yP as uo,ZY as go,ZZ as Qt,c7 as mo,mo as vo,mp as po,Z_ as st,vR as le,gh as fo,uc as So,mv as ho,yC as Gt,zb as Co,yz as zt,ui as Io,z8 as ct,u6 as Eo,z5 as rt,hP as ko,TP as lt,TQ as yo,Fy as Wt,hH as xo,Z$ as bo,UE as jo,_0 as Po,zh as fe,zi as Do,_1 as Lo,_2 as Jt,ze as Ao,_3 as $o,_4 as wo,xw as Fo,_5 as Ro}from"./zeni-epic-state-DxmmAR38.js";import{M as To}from"./MobileAppDrawer-BWD9smko.js";import{q as de}from"./QBOConnectionScreen-C9YRg79s.js";import"./recharts-Co89o1ZO.js";import"./analytics-CsVp7bfq.js";import"./plaid---yWAm21.js";import"./dnd-CR945ANw.js";import"./stripe-cKAAJElX.js";import"./lottie-DgdF8254.js";import"./lexical-CCIwPSwQ.js";import"./pdf-BVKoD2Fp.js";import"./utils-18zApAFM.js";import"./InboxNotificationsProvider-CzhxlkVm.js";import"./useTaskManagerAccess-D4rOKbOu.js";import"./empty-BUo7eNC4.js";import"./pdf-lib-B25n7och.js";import"./index-BjpjXshH.js";import"./url-BQb6aJ6P.js";import"./index-BaZwiGCV.js";import"./decodeURIComponentSafe-Bq1r0pP9.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new n.Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="e80ff18b-6b4c-40c4-bde3-d51583202348",n._sentryDebugIdIdentifier="sentry-dbid-e80ff18b-6b4c-40c4-bde3-d51583202348")}catch{}})();const $=({event:n,isReady:e=!0})=>e?s.jsx(ln,{analytics:p,onLoad:t=>t.trackPageLoaded(n)}):null;function U(...n){return n.some((e=>e==="Error"))}function Oo(){const n=D(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),{fetchState:m,hasMore:S,items:f,nextCursor:I,auditLogEntityRouteOptions:j,auditLogListSortFieldOptions:y}=E(Yn),k=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),b=`/${t??""}/invoicing`,C=r.useCallback(((O,R)=>{const M=ei(b,O,R,j);M!=null&&(p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{entity:O,entityId:R,fromScreen:"audit_log"}),e(M))}),[j,e,b]);r.useEffect((()=>{const O=setTimeout((()=>d(o)),300);return()=>clearTimeout(O)}),[o]),r.useEffect((()=>{i&&n(Qe({filters:k,keepExistingListItems:!1,sort:u}))}),[i,k,u,n]);const P=m==="Not-Started"||m==="In-Progress"&&f.length===0,h=m==="In-Progress"&&f.length>0,_=m==="Completed";return U(m)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingAuditLogPage,isReady:_}),s.jsx(dn,{auditLogEntityRouteOptions:j,auditLogListSortFieldOptions:y,entries:f,hasMore:S,isLoading:P,isLoadingMore:h,searchValue:o,sortState:l,onEntityLinkClick:C,onLoadMore:()=>{S&&I!=null&&n(Qe({cursor:I,filters:k,keepExistingListItems:!0,sort:u}))},onSearchChange:a,onSortChange:v})]})}const _o=new Set(["plan"]),Xt=[],Mo=Ct((n=>n.length>0?n:Xt),mn),No=Ct((n=>n.length>0?n:Xt),gn),Uo=T((function(n,e){const{view:t}=e;return{groupedAccountOptions:Mo(t.qboAccountHierarchy),groupedClassOptions:No(t.qboClassHierarchy),catalogItemLifecycleActionOptions:t.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:t.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:t.catalogTierTypeOptionsByPricingModel,periodUnitOptions:t.periodUnitOptions,trialEndActionOptions:t.trialEndActionOptions,trialUnitOptions:t.trialUnitOptions,typeOptions:t.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:t.actionState.fetchState==="In-Progress",isSaving:t.fetchState==="In-Progress",itemId:e.itemId,localData:t.localData,plan:t.plan}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${t}/catalog`),onLifecycleAction:i!==""?o=>{i!==""&&n(It({action:o,id:i}))}:void 0,onEditChange:o=>{i!==""&&n(De({id:i,localData:o}))},onSaveEdit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemEdited,{itemId:i}),n(ht({id:i}))},onSubFamilyLifecycleAction:(o,a)=>{i!==""&&n(ti({action:a,id:o,parentItemId:i}))}}}))(un);function Bo(){const n=D(),e=L(),{item_id:t,tenantEmailDomain:i}=w(),[o]=W(),{areTenantIdsInSync:a}=F(),c=(d=o.get("kind"))!=null&&_o.has(d)?d:"plan";var d;const l=E((k=>Pe(k,t))),{pageFetchState:v}=l,u=v.fetchState;r.useEffect((()=>(n(Q()),()=>{n(Q())})),[n]),r.useEffect((()=>{a&&n(Ge({id:t,kind:c}))}),[a,t,c,n]);const[m,S]=r.useState(0);r.useEffect((()=>{l.fetchState==="Completed"&&(n(Q()),n(Ge({cacheOverride:!0,id:t,kind:c})),S((k=>k+1)))}),[l.fetchState,n,t,c]);const f=u==="Completed",[I,j]=r.useState(f?t:void 0);r.useEffect((()=>{t!=null&&f&&j(t)}),[t,f]);const y=I!==t&&(u==="Not-Started"||u==="In-Progress");return U(u)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCatalogItemDetailPage,isReady:f}),s.jsx(Uo,{navigate:e,tenantEmailDomain:i,itemId:t??"",kind:c,isLoading:y,view:l},m)]})}function Be(n={}){const{enabled:e=!0,fetchSyncHealth:t=!1,loadAccountingPickers:i=!1,reuseCached:o=!1}=n,a=D(),{areTenantIdsInSync:c}=F(),d=E(Le),l=d.connection?.connected===!0,v=d.connectionFetchState.fetchState;return r.useEffect((()=>{e&&c&&(o&&v!=="Not-Started"||a(Et()),t&&a(ni()))}),[c,a,e,t,o]),r.useEffect((()=>{e&&c&&l&&i&&a(ii())}),[c,a,e,l,i]),{isQboConnected:l,qboView:d}}function Ve(n,e=!1){const t=D(),i=E((c=>G(c).productNextCursor!=null)),o=E((c=>G(c).productNextCursor)),a=E((c=>G(c).productFetchState.fetchState));r.useEffect((()=>{n&&(e&&a!=="Not-Started"||t(ce({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[n,t,e]),r.useEffect((()=>{n&&a!=="In-Progress"&&i&&o!=null&&t(ce({cursor:o,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[n,t,a,i,o])}const Vo=new Set(["addon","charge","plan"]),Zo=new Set(["plan"]),Ho=T((function(n,e){const t=Pe(n,e.itemId);return{fieldHelp:t.fieldHelp,isQboPickerDataLoading:t.isQboPickerDataLoading,qboClassHierarchy:t.qboClassHierarchy,qboAccountHierarchy:t.qboAccountHierarchy,applicabilityValues:t.applicabilityValues,periodUnitOptions:t.periodUnitOptions,trialEndActionOptions:t.trialEndActionOptions,trialUnitOptions:t.trialUnitOptions,typeOptions:t.typeOptions,applicableItemOptions:t.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save catalog item.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode,pricingModelValues:t.pricingModelValues,prorationValues:t.prorationValues,tierTypeOptionsByPricingModel:t.catalogTierTypeOptionsByPricingModel,tierTypeValues:t.tierTypeValues}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,i=e.isEdit?"edit":"create",{itemId:o}=e,a=o!=null?`${t}/catalog/${encodeURIComponent(o)}`:`${t}/catalog`;return{onBack:()=>e.navigate(a),onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemFormCancelled),n(Q()),e.navigate(`${t}/catalog`)},onChange:c=>{n(De({id:o,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemSaved,{mode:i}),n(ht({id:o}))}}}))(vn);function qo(){const n=D(),e=L(),{item_id:t,tenantEmailDomain:i}=w(),[o]=W(),{areTenantIdsInSync:a}=F(),c=t!=null,d=o.get("type"),l=d!=null&&Vo.has(d)?d:void 0,v=(u=o.get("kind"))!=null&&Zo.has(u)?u:"plan";var u;const m=E((S=>Pe(S,t)));return Ve(a,!0),Be({loadAccountingPickers:!0,reuseCached:!0}),r.useEffect((()=>{a&&t!=null&&n(oi({id:t,kind:v}))}),[a,t,v,n]),r.useEffect((()=>{c||l==null||m.localData.catalogType===l||n(De({localData:{...m.localData,catalogType:l}}))}),[c,l,m.localData?.catalogType,n]),r.useEffect((()=>{if(m.fetchState==="Completed"){const S=m.savedItemId??t,f=S!=null?`/${i}/invoicing/catalog/${encodeURIComponent(S)}`:`/${i}/invoicing/catalog`;e(f),n(Q())}}),[m.fetchState,m.savedItemId,t,n,e,i]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCatalogItemFormPage}),s.jsx(Ho,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:c,itemId:t})]})}const Ko={addons:"addon",all:"item",charges:"charge",plans:"plan"},Qo=T((function(n,e){const t=G(n),i=e.activeTab==="plans",o=e.activeTab==="all",a=i?t.plans:o?[...t.plans,...t.products]:t.products,c=i||o&&t.fetchState==="In-Progress"?t.fetchState:t.productFetchState.fetchState;return{catalogItemLifecycleActionOptions:t.catalogItemLifecycleActionOptions,counts:t.count,countsLoading:t.countsFetchState.fetchState==="Not-Started"||t.countsFetchState.fetchState==="In-Progress",hasMore:i?t.planNextCursor!=null:o&&t.planNextCursor!=null||t.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&a.length===0,isLoadingMore:c==="In-Progress"&&a.length>0,plans:t.plans,productColumns:t.productColumns,products:t.products}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",o=e.activeTab==="all",a=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:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${t}/data_import`)},onAddItem:()=>{const c=Ko[e.activeTab];p.trackInvoicingActionClick(g.Event.invoicingAddCatalogItemClicked,{itemType:c}),e.navigate(`${t}/catalog/new?type=${c}`)},onItemClick:(c,d)=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemRowClicked,{itemId:d}),e.navigate(`${t}/catalog/${encodeURIComponent(d)}`)},onCatalogItemLifecycleAction:(c,d)=>{n(It({action:ai(d),id:c}))},onLoadMore:()=>{if(o)return e.planNextCursor!=null&&n(Ce({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&n(ce({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));a!=null&&n(i?Ce({cursor:a,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):ce({cursor:a,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(pn);function Go(){const n=D(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o,a]=r.useState(""),[c,d]=r.useState("plans"),[l,v]=r.useState(""),[u,m]=r.useState(null),S=r.useMemo((()=>u!=null?{dir:u.direction,field:u.columnKey}:void 0),[u]),f=l.trim()!==""?l.trim():void 0,I=r.useMemo((()=>({search:f,type:"plan"})),[f]),j=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),y=E((O=>G(O))),k=y.planFilters.search,b=y.planSort,C=y.planNextCursor,P=y.productNextCursor,h=y.fetchState==="Completed",_=y.runningActionId??null;return r.useEffect((()=>{const O=setTimeout((()=>v(o)),300);return()=>clearTimeout(O)}),[o]),r.useEffect((()=>{i&&n(ze({cacheOverride:!1,planFilters:I,productFilters:j,planSort:S,productSort:S}))}),[i,n,I,j,S]),r.useEffect((()=>{i&&(f!==k||S?.field!==b?.field||S?.dir!==b?.dir)&&n(ze({cacheOverride:!0,planFilters:I,productFilters:j,planSort:S,productSort:S}))}),[k,b,i,n,I,j,f,S]),U(y.fetchState)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCatalogPage,isReady:h}),s.jsx(Qo,{navigate:e,tenantEmailDomain:t,activeTab:c,searchValue:o,sortState:u,planFilters:I,productFilters:j,sort:S,planNextCursor:C,productNextCursor:P,runningCatalogItemActionId:_,onSearchChange:a,onTabChange:d,onSortChange:m})]})}const zo=T((function(n,e){const t=kt(n,e.couponId);return{fieldHelp:t.fieldHelp,applyOnOptions:t.applyOnOptions,discountTypeOptions:t.discountTypeOptions,durationTypeOptions:t.durationTypeOptions,errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save coupon.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode,periodUnitOptions:t.periodUnitOptions}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,o=i!=null?"edit":"create",a=i!=null?`${t}/discounts/${encodeURIComponent(i)}`:`${t}/discounts`;return{onBack:()=>e.navigate(a),onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCouponFormCancelled),n(z()),e.navigate(`${t}/discounts`)},onChange:c=>{n(ri({id:i,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCouponSaved,{mode:o}),n(ci({id:i}))}}}))(fn);function Wo(){const n=D(),e=L(),{coupon_id:t,tenantEmailDomain:i}=w(),{areTenantIdsInSync:o}=F(),{fetchState:a,savedCouponId:c}=E((d=>kt(d,t)));return r.useEffect((()=>{o&&t!=null&&n(si({id:t}))}),[o,t,n]),r.useEffect((()=>{if(a==="Completed"){const d=c??t,l=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(l),n(z())}}),[a,c,t,n,e,i]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCouponFormPage}),s.jsx(zo,{couponId:t,navigate:e,tenantEmailDomain:i})]})}const Jo=T((function(n){const e=yt(n);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(n){return{dispatch:n}}),(function(n,{dispatch:e},t){const i=`/${t.tenantEmailDomain}/invoicing`;return{...n,onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreateInvoiceCancelled),t.navigate(`${i}/invoices`)},onChange:o=>{e(bt(o))},onSubmit:()=>{const o=ui(n.localData);p.trackInvoicingActionClick(g.Event.invoicingInvoiceCreated,{customerId:o.customer_id,lineItemCount:o.line_items?.length}),e(gi(o))}}}))(hn);function Xo(){const n=D(),e=L(),{tenantEmailDomain:t}=w(),[i]=W(),{areTenantIdsInSync:o}=F(),a=i.get("customerId"),c=E((C=>yt(C))),d=c.fetchState,l=c.localData,v=c.savedInvoiceId,u=E(xt),m=E((C=>li(C))),S=E(ue),f=m.fetchState==="Not-Started"||m.fetchState==="In-Progress"&&u==null,I=S.fetchState==="Not-Started"||S.fetchState==="In-Progress"&&S.customers.length===0,j=f||I,y=m.fetchState==="Completed"&&S.fetchState==="Completed";r.useEffect((()=>(n(We()),()=>{n(We())})),[n]);const k=r.useRef(!1);r.useEffect((()=>{k.current||a==null||a===""||l.customerId!==""||(k.current=!0,n(bt({...l,customerId:a})))}),[a,l,n]),r.useEffect((()=>{o&&n(di({cacheOverride:!1}))}),[o,n]);const b=r.useRef(d);return r.useEffect((()=>{const C=b.current;if(b.current=d,C!=="Completed"&&d==="Completed"){const P=v!=null?`/${t}/invoicing/invoices/${encodeURIComponent(v)}`:`/${t}/invoicing/invoices`;e(P)}}),[d,v,e,t]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCreateInvoicePage,isReady:y}),j?s.jsx(Sn,{}):s.jsx(Jo,{navigate:e,tenantEmailDomain:t})]})}const Yo=T((function(n,e){const{detailView:t}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:t.creditNote,creditNoteId:e.creditNoteId,isLoading:t.fetchState==="Not-Started"||t.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${t}/credits`),onCustomerClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${t}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(i)}`)}}}))(Cn);function ea(){const n=D(),e=L(),{credit_note_id:t,tenantEmailDomain:i}=w(),{areTenantIdsInSync:o}=F(),a=E((d=>mi(d,t??""))),c=a.fetchState==="Completed";return r.useEffect((()=>{o&&t!=null&&n(vi({id:t}))}),[o,t,n]),U(a.fetchState)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCreditDetailPage,isReady:c}),s.jsx(Yo,{navigate:e,tenantEmailDomain:i,creditNoteId:t??"",detailView:a})]})}const ta=T((function(n){const e=jt(n),{fetchState:t}=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:t==="Not-Started"||t==="In-Progress"&&e.creditNotes.length===0,isLoadingMore:t==="In-Progress"&&e.creditNotes.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${t}/data_import`)},onCreditNoteClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${t}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&n(fi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(In);function na(){const n=D(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:j,creditNoteListFetchState:y}=E((b=>{const C=jt(b);return{activeStatus:C.activeTab,appliedSearch:C.filters.search,appliedSort:C.sort,nextCursor:C.nextCursor,creditNoteListFetchState:C.fetchState}}),Z),k=y==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&n(Je({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==I?.field||u?.dir!==I?.dir)&&n(Je({cacheOverride:!0,filters:m,sort:u}))}),[i,n,m,u,f,I]),U(y)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCreditsListPage,isReady:k}),s.jsx(ta,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onStatusChange:b=>n(pi(b)),onSortChange:v})]})}const Yt=(n,e,t)=>{const i=`/${n}/invoicing/customers/`;return t!=null?`${i}${encodeURIComponent(t)}/${e}/`:`${i}new/${e}/`},ia=T((function(n,e){const{editView:t,hasLoadedRecord:i}=e;return{fieldHelp:t.fieldHelp,billingAddressLabel:t.billingAddressLabel,customerTypeOptions:t.customerTypeOptions,netTermDayOptions:t.netTermDayOptions,taxabilityOptions:t.taxabilityOptions,customer:t.record.invoicingCustomer,invoices:t.record.invoices.slice(0,5),isLoading:!i&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),hasPaymentLinkEmailPreviewFailed:t.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:t.emailPreviewFetchState.fetchState==="In-Progress",isSaving:t.fetchState==="In-Progress",paymentLinkEmailPreview:t.emailPreview,isSendingPaymentLink:t.record.sendLinkState.fetchState==="In-Progress",localData:t.localData,paymentMethods:t.record.paymentMethods,sendPaymentLinkErrorMessage:t.record.sendLinkState.fetchState==="Error"?t.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:t.record.sendLinkState.fetchState==="Completed"?t.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:t.record.sendLinkState.fetchState==="Completed"?t.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:t.record.stripeConnected}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${t}/customers`),onChange:o=>{n(Ie({id:i,localData:o}))},onCreateInvoice:()=>e.navigate(`${t}/invoices/create`),onInvoiceClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(o)}`)},onCreatePromotionalCredits:()=>e.onCreatePromotionalCredits(),onNewSubscription:()=>e.navigate(`${t}/subscriptions/new`),onOpenAddress:()=>{const o=Yt(e.tenantEmailDomain??"",Ee,i),a=X(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(o,{state:{pathnameStackToGoBack:a}})},onOpenPaymentSettings:()=>e.navigate(`${t}/settings/payment-destination`),onSaveEdit:o=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerEdited,{customerId:i}),n(Ie({id:i,localData:o})),n(Dt({id:i}))},onFetchPaymentLinkEmailPreview:o=>n(yi({cacheOverride:o,customerId:i})),onSendPaymentLink:(o,a,c)=>n(ki({body:c,customerId:i,email:o,subject:a})),onSubscriptionClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:o,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(o)}`)}}}))(yn);function oa(){const n=D(),e=L(),t=J(),{customer_id:i,tenantEmailDomain:o}=w(),{areTenantIdsInSync:a}=F(),c=E((M=>Ae(M,i))),d=c.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(!1),[m,S]=r.useState(!1),[f,I]=r.useState(c.record.fetchState==="Completed"?i:void 0);r.useEffect((()=>{i!=null&&c.record.fetchState==="Completed"&&I(i)}),[i,c.record.fetchState]);const j=f===i,{plaidTokenFetchState:y,promotionalCreditSubmitState:k}=c,{paymentMethodSaveState:b,setupIntentFetchState:C,stripeConnected:P}=c.record,h=r.useRef(c.record.sendLinkState.fetchState);r.useEffect((()=>{const M=c.record.sendLinkState.fetchState;h.current!=="Error"&&M==="Error"&&n(Si({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),h.current=M}),[n,c.record.sendLinkState.fetchState]);const _=C.fetchState==="Error"?C.error?.message??"Failed to start card setup.":b.fetchState==="Error"?b.error?.message??"Failed to save payment method.":y.fetchState==="Error"?y.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(n(te()),n(ne()),()=>{n(te()),n(ne())})),[n]),r.useEffect((()=>{t.state?.openPromotionalCreditsDialog===!0&&(S(!0),e(t.pathname,{replace:!0,state:null}))}),[t.pathname,t.state,e]),r.useEffect((()=>{a&&i!=null&&n(hi({id:i}))}),[a,i,n]),r.useEffect((()=>{a&&i!=null&&P&&n(Xe({customerId:i}))}),[a,i,n,P]);const[O,R]=r.useState(0);return r.useEffect((()=>{c.fetchState==="Completed"&&(n($e()),i!=null&&n(Pt({id:i})),R((M=>M+1)))}),[c.fetchState,n,i]),U(d)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCustomerDetailPage,isReady:l}),s.jsx(ia,{customerId:i??"",editView:c,hasLoadedRecord:j,location:t,navigate:e,tenantEmailDomain:o,onAddPaymentMethod:()=>{n(te()),i!=null&&P&&n(Xe({customerId:i})),u(!0)},onCreatePromotionalCredits:()=>{n(ne()),S(!0)}},O),s.jsx(En,{errorMessage:_,isCreatingSetupIntent:C.fetchState==="In-Progress",isSaving:b.fetchState==="In-Progress",open:v,plaidLinkToken:c.record.plaidLinkToken,saveSucceeded:b.fetchState==="Completed",setupIntent:c.record.setupIntent,stripeConnected:P,onChooseCard:()=>{i!=null&&n(Ii({customerId:i}))},onClose:()=>{u(!1),n(te())},onSavePaymentMethod:M=>{i!=null&&n(Ci({customerId:i,data:M}))}}),s.jsx(kn,{currentBalance:c.record.invoicingCustomer?.promotionalCredits,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:k.fetchState==="Error"?k.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:k.fetchState==="In-Progress",open:m,submitSucceeded:k.fetchState==="Completed",onClose:()=>{S(!1),n(ne())},onSubmit:({amount:M,description:ee})=>{i!=null&&n(Ei({amount:M,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:ee}))}})]})}const aa=T((function(n,e){const t=Ae(n,e.customerId);return{fieldHelp:t.fieldHelp,billingAddressLabel:t.billingAddressLabel,customerTypeOptions:t.customerTypeOptions,netTermDayOptions:t.netTermDayOptions,taxabilityOptions:t.taxabilityOptions,errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save customer.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,o=i!=null?"edit":"create",a=i!=null?`${t}/customers/${encodeURIComponent(i)}`:`${t}/customers`;return{onBack:()=>e.navigate(a),onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerFormCancelled),n($e()),n(we(Ee)),e.navigate(`${t}/customers`)},onChange:c=>{n(Ie({id:i,localData:c}))},onOpenAddress:()=>{const c=Yt(e.tenantEmailDomain??"",Ee,i),d=X(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerSaved,{mode:o}),n(Dt({id:i}))}}}))(xn);function sa(){const n=D(),e=L(),t=J(),{customer_id:i,tenantEmailDomain:o}=w(),{areTenantIdsInSync:a}=F(),{fetchState:c,savedCustomerId:d}=E((l=>Ae(l,i)));return r.useEffect((()=>{a&&i!=null&&n(Pt({id:i}))}),[a,i,n]),r.useEffect((()=>{if(c==="Completed"){const l=d??i,v=l!=null?`/${o}/invoicing/customers/${encodeURIComponent(l)}`:`/${o}/invoicing/customers`;e(v),n($e())}}),[c,d,i,n,e,o]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCustomerFormPage}),s.jsx(aa,{customerId:i,location:t,navigate:e,tenantEmailDomain:o})]})}const ca=T((function(n){const e=ue(n),{fetchState:t}=e;return{addressesById:n.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:t==="Not-Started"||t==="In-Progress"&&e.customers.length===0,isLoadingMore:t==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{p.trackInvoicingActionClick(g.Event.invoicingAddCustomerClicked),e.navigate(`${t}/customers/new`)},onCustomerClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${t}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${t}/data_import`)},onRowAction:(i,o)=>{switch(o){case"createInvoice":e.navigate(`${t}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":e.navigate(`${t}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":e.navigate(`${t}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&n(Fe({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(bn);function ra(){const n=D(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:j,customerListFetchState:y}=E((b=>{const C=ue(b);return{activeStatus:C.activeTab,appliedSearch:C.filters.search,appliedSort:C.sort,nextCursor:C.nextCursor,customerListFetchState:C.fetchState}}),Z),k=y==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&n(Ye({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==I?.field||u?.dir!==I?.dir)&&n(Ye({cacheOverride:!0,filters:m,sort:u}))}),[i,n,m,u,f,I]),U(y)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingCustomersListPage,isReady:k}),s.jsx(ca,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onStatusChange:b=>n(xi(b)),onSortChange:v})]})}const be=(n,e)=>e==null?void 0:n.sessionDetail[e]??n.sessions.find((t=>t.id===e)),la=T((function(n,e){const{filters:t,sessionId:i,view:o}=e,a=i==null?void 0:o.diagnosticsBySession[i],c=a?.fetch.fetchState??"Not-Started";return{diagnostics:a?.items??[],errorMessage:c==="Error"?a?.fetch.error?.message:void 0,expired:a?.expired??!1,filters:t,hasMore:a?.nextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress",isLoadingMore:c==="In-Progress"&&(a?.items.length??0)>0,session:be(o,i)}}),(function(n,e){const{downloadUrl:t,filters:i,navigate:o,sessionId:a,tenantEmailDomain:c,view:d}=e,l=a==null?void 0:d.diagnosticsBySession[a],v=be(d,a),u=d.actionStateByKind.retry?.fetchState==="In-Progress",m=d.actionStateByKind.rollback?.fetchState==="In-Progress",S=v?.status==="done"&&v.rollback_available_until!=null&&new Date(v.rollback_available_until).getTime()>Date.now()&&!m;return{onBack:()=>o(`/${c}/invoicing/data_import`),onDownloadCsv:()=>{t!=null&&window.open(t,"_blank","noopener")},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{a!=null&&l?.nextCursor!=null&&n(ye({...i,cursor:l.nextCursor,sessionId:a}))},onRetry:v?.status!=="failed"||u?void 0:()=>{a!=null&&n(Te(a))},onRollback:S?()=>{a!=null&&n(Lt(a))}:void 0}}))(jn);function da(){const n=D(),e=L(),{sessionId:t,tenantEmailDomain:i}=w(),{areTenantIdsInSync:o}=F(),[a,c]=r.useState({}),d=E(Re),l=be(d,t),v=t==null?void 0:d.diagnosticsBySession[t];r.useEffect((()=>{o&&t!=null&&n(ke(t))}),[o,n,t]),r.useEffect((()=>{if(!o||t==null)return;const f=setTimeout((()=>{n(ye({...a,sessionId:t}))}),300);return()=>clearTimeout(f)}),[o,n,a,t]);const u=l?.status==="scanning"||l?.status==="importing";r.useEffect((()=>{if(!o||t==null||!u)return;const f=setInterval((()=>{n(ke(t)),n(ye({...a,sessionId:t}))}),3e3);return()=>clearInterval(f)}),[o,n,a,u,t]);const m=r.useMemo((()=>{if(t==null)return;const f=new URLSearchParams;a.moduleId!=null&&f.set("module_id",a.moduleId),a.level!=null&&f.set("level",a.level),a.outcome!=null&&f.set("outcome",a.outcome),a.search!=null&&a.search.trim()!==""&&f.set("search",a.search.trim());const I=f.toString();return`${se?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(t)}/issues.csv${I===""?"":`?${I}`}`}),[a,t]),S=v?.fetch.fetchState??"Not-Started";return U(S)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingDataImportHubPage,isReady:l!=null&&S!=="Not-Started"}),s.jsx(la,{downloadUrl:m,filters:a,navigate:e,sessionId:t,tenantEmailDomain:i,view:d,onFiltersChange:c})]})}const en=n=>`invoicing_active_migration:${n}`,ae=(n,e)=>{if(n!=null&&n!=="")try{const t=en(n);e==null?sessionStorage.removeItem(t):sessionStorage.setItem(t,e)}catch{}},ua=T((function(n,e){const{sessions:t,sessionsFetch:i,statusFetch:o,statusRows:a}=e.view;return{isLoading:!(o.fetchState!=="Not-Started"&&o.fetchState!=="In-Progress"||a.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:t,statusRows:a}}),(function(n,e){const{navigate:t,tenantEmailDomain:i}=e,o=a=>{const c=a??null;n(oe(c)),ae(i,c),t(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"continue",sessionId:a}),o(a)},onNewImport:()=>{p.trackInvoicingActionClick(g.Event.invoicingNewImportClicked),o()},onRetrySession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"retry",sessionId:a}),n(Te(a)),o(a)},onRollbackSession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"rollback",sessionId:a}),n(Lt(a))},onViewSession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"view_details",sessionId:a}),t(`/${i}/invoicing/data_import/${encodeURIComponent(a)}`)}}}))(Pn);function ga(){const n=D(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),o=E(Re);r.useEffect((()=>{i&&(n(bi()),n(At()))}),[i,n]);const a=o.statusFetch.fetchState==="Completed"&&o.sessionsFetch.fetchState==="Completed";return s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingDataImportHubPage,isReady:a}),s.jsx(ua,{navigate:e,tenantEmailDomain:t,view:o})]})}const ma=T((function(n,e){const{activeId:t,integrationsView:i,settings:o,view:a}=e,{actionStateByKind:c,sessionDetail:d,sessions:l}=a,v=i.externalConnections?.revenue?.find((m=>m.connectionName==="chargebee")),u=t!=null?d[t]:void 0;return{chargebeeConnected:o?.chargebee_connected===!0||(v?.isValid??!1),chargebeeConnectorAvailable:v!=null,chargebeeSite:o?.chargebee_site,connectError:c.connect?.error?.message,connecting:c.connect?.fetchState==="In-Progress",retrying:c.retry?.fetchState==="In-Progress",session:u??l.find((m=>m.id===t)),starting:c.start?.fetchState==="In-Progress",uploading:c.upload?.fetchState==="In-Progress"}}),(function(n,e){const{activeId:t,navigate:i,tenantEmailDomain:o}=e;return{onBack:e.onBack,onDownloadTemplates:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportTemplatesDownloaded);const a=se?.invoicingMicroServiceBaseUrl,c=a!=null&&a.length>0?a:"";window.open(`${c}/1.0/data-import/templates`,"_blank","noopener")},onFetchFromChargebee:()=>{p.trackInvoicingActionClick(g.Event.invoicingChargebeeConnectClicked),n(Di())},onGoToIntegrations:()=>{i(`/${o}/invoicing/settings`)},onGoToOverview:()=>i(`/${o}/invoicing/overview`),onRetry:()=>{t!=null&&n(Te(t))},onSaveLater:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportStarted),t!=null&&n(Pi(t))},onUpload:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportFileUploaded),n(ji({files:a}))},onViewDetails:t==null?void 0:()=>i(`/${o}/invoicing/data_import/${encodeURIComponent(t)}`)}}))(Dn);function va(){const n=D(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),o=E(xt),a=E(Oe).companyId??he.getSignedInUserTenant(t??"")?.companyId,c=E((f=>$t(f,a))),d=E(Re),{activeMigrationSessionId:l}=d,v=l??void 0,u=v!=null?d.sessionDetail[v]??d.sessions.find((f=>f.id===v)):void 0;r.useEffect((()=>{i&&(n(_e()),n(At()))}),[i,n]),r.useEffect((()=>{if(l!=null)return;const f=(I=>{if(I==null||I==="")return null;try{return sessionStorage.getItem(en(I))}catch{return null}})(t);f!=null&&n(oe(f))}),[l,n,t]),r.useEffect((()=>{ae(t,l)}),[l,t]);const m=u?.status,S=m==="scanning"||m==="importing";return r.useEffect((()=>{if(!i||v==null||!S)return;const f=setInterval((()=>{n(ke(v))}),3e3);return()=>clearInterval(f)}),[i,v,S,n]),r.useEffect((()=>{m==="done"&&(n(oe(null)),ae(t,null))}),[n,m,t]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingDataImportMigratePage}),s.jsx(ma,{activeId:v,integrationsView:c,navigate:e,settings:o,tenantEmailDomain:t,view:d,onBack:()=>{n(oe(null)),ae(t,null),e(`/${t}/invoicing/data_import`)}})]})}const pa=T((function(n,e){const{editView:t}=e;return{fieldHelp:t.fieldHelp,coupon:t.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,isLoading:!e.hasLoadedRecord&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:t.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${t}/discounts`),onLifecycleAction:o=>{n(wt({action:o,id:i}))},onSaveEdit:o=>{p.trackInvoicingActionClick(g.Event.invoicingCouponEdited,{couponId:i}),n(Ai({data:o,id:i}))}}}))(Ln);function fa(){const n=D(),e=L(),{coupon_id:t,tenantEmailDomain:i}=w(),{areTenantIdsInSync:o}=F(),a=E((I=>Li(I,t))),c=a.actionState.fetchState==="In-Progress",d=a.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(l?t:void 0);r.useEffect((()=>{t!=null&&l&&u(t)}),[t,l]);const m=v===t;r.useEffect((()=>(n(z()),()=>{n(z())})),[n]),r.useEffect((()=>{o&&n(et({id:t}))}),[o,t,n]);const[S,f]=r.useState(0);return r.useEffect((()=>{a.fetchState==="Completed"&&(n(z()),n(et({cacheOverride:!0,id:t})),f((I=>I+1)))}),[a.fetchState,n,t]),U(d)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingDiscountDetailPage,isReady:l}),s.jsx(pa,{hasLoadedRecord:m,couponId:t??"",discountLifecycleActionOptions:a.discountLifecycleActionOptions,editView:a,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},S)]})}const Sa=T((function(n){const e=Ft(n),{fetchState:t}=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:t==="Not-Started"||t==="In-Progress"&&e.coupons.length===0,isLoadingMore:t==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${t}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreateCouponClicked),e.navigate(`${t}/discounts/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${t}/data_import`)},onDiscountLifecycleAction:(i,o)=>{n(wt({action:o,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&n(Rt({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(An);function ha(){const n=D(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:j,couponListFetchState:y,runningDiscountActionId:k}=E((C=>{const P=Ft(C);return{activeStatus:P.activeTab,appliedSearch:P.filters.search,appliedSort:P.sort,nextCursor:P.nextCursor,couponListFetchState:P.fetchState,runningDiscountActionId:P.runningActionId??null}}),Z),b=y==="Completed";return r.useEffect((()=>{const C=setTimeout((()=>d(o)),300);return()=>clearTimeout(C)}),[o]),r.useEffect((()=>{i&&n(tt({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==I?.field||u?.dir!==I?.dir)&&n(tt({cacheOverride:!0,filters:m,sort:u}))}),[i,n,m,u,f,I]),U(y)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingDiscountsListPage,isReady:b}),s.jsx(Sa,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,runningDiscountActionId:k,onSearchChange:a,onStatusChange:C=>n($i(C)),onSortChange:v})]})}const Ca=T((function(n,e){const{readView:t}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:t.dunningCase,isLoading:t.fetchState==="Not-Started"||t.fetchState==="In-Progress",isRunningAction:t.actionState.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,o=i!=="";return{onBack:()=>e.navigate(`${t}/dunning`),onInvoiceClick:a=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(a)}`)},onCancel:o?()=>n(H({action:"cancel",id:i})):void 0,onResolve:o?()=>{p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"resolve",caseId:i}),n(H({action:"resolve",id:i}))}:void 0,onResume:o?()=>{p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"resume",caseId:i}),n(H({action:"resume",id:i}))}:void 0,onRetry:o?()=>{p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"retry",caseId:i}),n(H({action:"retry",id:i}))}:void 0}}))(wn);function Ia(){const n=D(),e=L(),{case_id:t,tenantEmailDomain:i}=w(),{areTenantIdsInSync:o}=F(),a=E((h=>wi(h,t??""))),c=a.fetchState==="Completed",d=a.dunningCase?.invoiceID,[l,v]=r.useState("idle"),[u,m]=r.useState(!1),[S,f]=r.useState(),[I,j]=r.useState(!1),y=r.useCallback((()=>{v("idle"),m(!1),f(void 0),j(!1)}),[]),k=r.useCallback((()=>{if(t==null)return;n(Fi({id:t})),v("idle"),m(!1);const h=a.emailPreview.preview;f(h==null?void 0:{body:h.body,cc:h.cc,subject:h.subject,to:h.to}),j(!0)}),[t,n,a.emailPreview.preview]),b=r.useCallback((h=>{t!=null&&l!=="pending"&&(m(!1),v("pending"),p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"send-email",caseId:t}),n(H({action:"send-email",body:h,id:t})))}),[t,n,l]),C=r.useMemo((()=>a.emailPreview.preview==null?void 0:{bodyToken:a.emailPreview.preview.bodyToken,renderedHtmlTemplate:a.emailPreview.preview.renderedHtmlTemplate,subjectToken:a.emailPreview.preview.subjectToken}),[a.emailPreview.preview]);r.useEffect((()=>{o&&t!=null&&n(Ri({id:t}))}),[o,t,n]),r.useEffect((()=>{o&&d!=null&&n(Me({invoiceId:d}))}),[o,d,n]),r.useEffect((()=>{v("idle"),m(!1),f(void 0),j(!1)}),[t]),r.useEffect((()=>{o||(v("idle"),m(!1),f(void 0),j(!1))}),[o]),r.useEffect((()=>{I&&S==null&&a.emailPreview.preview!=null&&f({body:a.emailPreview.preview.body,cc:a.emailPreview.preview.cc,subject:a.emailPreview.preview.subject,to:a.emailPreview.preview.to})}),[a.emailPreview.preview,S,I]),r.useEffect((()=>{l==="pending"&&(a.actionState.fetchState!=="In-Progress"?u&&a.actionState.fetchState==="Completed"?(t!=null&&n(Ti({id:t})),y()):u&&a.actionState.fetchState==="Error"&&v("failed"):m(!0))}),[t,y,n,l,u,a.actionState.fetchState]);const P=d!=null&&a.linkedInvoice?.id===d?a.linkedInvoice.dunningAttempts:void 0;return U(a.fetchState)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingDunningDetailPage,isReady:c}),s.jsx(Ca,{navigate:e,tenantEmailDomain:i,caseId:t??"",readView:a,dunningAttempts:P,onSendEmail:k}),s.jsx($n,{initialDraft:S,isPreviewLoading:a.emailPreview.fetchState==="Not-Started"||a.emailPreview.fetchState==="In-Progress",isSending:l==="pending",onClose:y,onSend:b,open:I,preview:C,previewErrorMessage:a.emailPreview.fetchState==="Error"?a.emailPreview.error?.message:void 0,sendErrorMessage:l==="failed"?a.actionState.error?.message:void 0})]})}const Ea=T((function(n){const e=Tt(n),{fetchState:t}=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:t==="Not-Started"||t==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:t==="In-Progress"&&e.dunningCases.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${t}/data_import`),onDunningCaseClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingDunningCaseRowClicked,{caseId:i}),e.navigate(`${t}/dunning/${encodeURIComponent(i)}`)},onRowAction:(i,o)=>{o!=="retry"&&o!=="resume"&&o!=="resolve"&&o!=="cancel"||n(H({action:o,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&n(_i({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Fn);function ka(){const n=D(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:j,dunningCaseListFetchState:y}=E((b=>{const C=Tt(b);return{activeStatus:C.activeTab,appliedSearch:C.filters.search,appliedSort:C.sort,nextCursor:C.nextCursor,dunningCaseListFetchState:C.fetchState}}),Z),k=y==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&n(nt({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==I?.field||u?.dir!==I?.dir)&&n(nt({cacheOverride:!0,filters:m,sort:u}))}),[i,n,m,u,f,I]),U(y)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingDunningListPage,isReady:k}),s.jsx(Ea,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onStatusChange:b=>n(Oi(b)),onSortChange:v})]})}const ya=T((function(n,e){const{view:t}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:t.billingAddress,invoice:t.invoice,invoiceId:e.invoiceId,shippingAddress:t.shippingAddress,isLoading:!e.hasLoadedRecord&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),isSaving:t.actionState.fetchState==="In-Progress",isVoiding:t.actionState.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e;return{onBack:()=>e.navigate(`${t}/invoices`),onCustomerClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:o,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${t}/customers/${encodeURIComponent(o)}`)},onIssueCreditNote:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreditNoteIssued,{invoiceId:i}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{p.trackInvoicingActionClick(g.Event.invoicingRecordPaymentClicked,{fromScreen:"invoice_detail",invoiceId:i}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceRegenerated,{invoiceId:i}),n(V({action:"regenerate",invoiceId:i}))},onSaveEdit:o=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceEdited,{invoiceId:i}),n(Ni({data:{due_date:o.due_date!==""?o.due_date:void 0,notes:o.notes.trim()!==""?o.notes.split(`
2
+ `).map((a=>a.trim())).filter((a=>a!=="")).map((a=>({note:a}))):void 0,po_number:o.po_number!==""?o.po_number:null},invoiceId:i}))},onSendReminder:()=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceReminderSent,{invoiceId:i}),n(V({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:o,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(o)}`)},onVoid:o=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceVoided,{invoiceId:i}),n(V({action:"void",invoiceId:i,body:o}))}}}))(Rn);function xa(){const n=D(),e=L(),{invoice_id:t,tenantEmailDomain:i}=w(),{areTenantIdsInSync:o}=F(),a=E((m=>Ot(m,t??""))),c=a.pageFetchState.fetchState,d=c==="Completed",[l,v]=r.useState(d?t:void 0);r.useEffect((()=>{t!=null&&d&&v(t)}),[t,d]);const u=l===t;return r.useEffect((()=>{o&&t!=null&&n(Mi({invoiceId:t}))}),[o,t,n]),U(c)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingInvoiceDetailPage,isReady:d}),s.jsx(ya,{invoiceId:t??"",hasLoadedRecord:u,navigate:e,tenantEmailDomain:i,view:a})]})}const ba=T((function(n){const e=_t(n),{fetchState:t}=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:t==="Not-Started"||t==="In-Progress"&&e.invoices.length===0,isLoadingMore:t==="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(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onCreateInvoice:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreateInvoiceClicked),e.navigate(`${t}/invoices/create`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"invoices"}),e.navigate(`${t}/data_import`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceRowClicked,{invoiceId:i}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}`)},onRowAction:(i,o)=>{switch(o){case"recordPayment":e.navigate(`${t}/invoices/${encodeURIComponent(i)}/record-payment`);break;case"issueCreditNote":e.navigate(`${t}/invoices/${encodeURIComponent(i)}/issue-credit-note`);break;case"sendReminder":n(V({action:"send-reminder",invoiceId:i}));break;case"regenerate":n(V({action:"regenerate",invoiceId:i}));break;case"void":n(V({action:"void",invoiceId:i}))}},onVoidInvoice:(i,o)=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceVoided,{invoiceId:i}),n(V({action:"void",invoiceId:i,body:o}))},onLoadMore:()=>{e.nextCursor!=null&&n(Mt({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Tn);function ja(){const n=D(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:j,invoiceListFetchState:y,voidingInvoiceId:k}=E((C=>{const P=_t(C);return{activeStatus:P.activeTab,appliedSearch:P.filters.search,appliedSort:C.invoicingInvoiceListState.sort,nextCursor:P.nextCursor,invoiceListFetchState:P.fetchState,voidingInvoiceId:P.runningActionId}}),Z),b=y==="Completed";return r.useEffect((()=>{const C=setTimeout((()=>d(o)),300);return()=>clearTimeout(C)}),[o]),r.useEffect((()=>{i&&n(ve({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==I?.field||u?.dir!==I?.dir)&&n(ve({cacheOverride:!0,filters:m,sort:u}))}),[i,n,m,u,f,I]),U(y)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingInvoicesListPage,isReady:b}),s.jsx(ba,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,voidingInvoiceId:k,onSearchChange:a,onStatusChange:C=>{n(Ui(C)),n(ve({cacheOverride:!1,filters:m,sort:u}))},onSortChange:v})]})}function dt(){const n=D(),e=L(),{tenantEmailDomain:t}=w(),i=On(),o=ft(),[a,c]=r.useState(!1),{acceptTermsState:d,status:l}=E(Nt),v=Bi(i?.loggedInUserRoleMap),u=`/${t}/invoicing`,m=S=>{c(S)};return l==="completed"?s.jsx(B,{to:`${u}/overview`,replace:!0}):l==="settings"&&v?s.jsx(B,{to:`${u}/settings`,replace:!0}):s.jsxs(s.Fragment,{children:[s.jsx(To,{isAppContentDrawerOpen:a,handleDrawerToggle:m}),s.jsx(_n,{analytics:p,isAccepting:d.fetchState==="In-Progress",isReadOnlyUser:!v,meetingUrl:o("invoicing_promo"),onAcceptClick:()=>{n(Vi())},onBackClick:()=>{e(`/${t}`)},onClickMenuIcon:()=>{m(!0)}})]})}const Pa=T((function(n,e){const t=Ut(n,e.invoiceId),{invoice:i,localData:o,reasonCodeOptions:a,submitState:c,typeOptions:d}=t;return{fieldHelp:t.fieldHelp,amountDue:i?.amountDue,currencyCode:i?.currencyCode??"USD",customerName:i?.customerName??"",errorMessage:c.fetchState==="Error"?c.error?.message??"Failed to issue credit note. Please try again.":void 0,invoiceNumber:i?.invoiceNumber??e.invoiceId,isSubmitting:c.fetchState==="In-Progress",localData:o,reasonCodeOptions:a,typeOptions:d}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing/invoices/${encodeURIComponent(e.invoiceId)}`,i=()=>e.navigate(t);return{onBack:i,onCancel:i,onChange:o=>{n(Qi({localData:o}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreditNoteIssued,{invoiceId:e.invoiceId}),n(Ki())}}}))(Mn);function Da(){const n=D(),e=L(),{invoice_id:t,tenantEmailDomain:i}=w(),{areTenantIdsInSync:o}=F(),{fetchState:a,invoice:c,isPageReady:d,issuedCreditNoteId:l,submitState:v}=E((f=>Ut(f,t??""))),u=`/${i}/invoicing`,m=r.useRef(null);r.useEffect((()=>{n(Zi()),m.current=null}),[n,t]),r.useEffect((()=>{o&&t!=null&&n(Me({invoiceId:t}))}),[o,n,t]),r.useEffect((()=>{c!=null&&t!=null&&a==="Completed"&&m.current!==t&&(m.current=t,n(Hi({localData:qi(c)})))}),[n,a,c,t]);const S=r.useRef(v.fetchState);return r.useEffect((()=>{const f=S.current;S.current=v.fetchState,f!=="Completed"&&v.fetchState==="Completed"&&l!=null&&e(`${u}/credits/${encodeURIComponent(l)}`)}),[l,e,v.fetchState,u]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingInvoiceDetailPage,isReady:d}),s.jsx(Pa,{invoiceId:t??"",navigate:e,tenantEmailDomain:i})]})}const La=T((function(n){return{invoicingOverview:Bt(n)}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{onRefresh:()=>{n(Vt(e.selectedPeriod,!0))},onSubscriptionClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionTileClicked,{subscriptionId:i}),e.navigate(`${t}/subscriptions/${i}`)},onViewInvoices:()=>{p.trackInvoicingActionClick(g.Event.invoicingViewInvoicesClicked),e.navigate(`${t}/invoices`)},onViewPayments:()=>{p.trackInvoicingActionClick(g.Event.invoicingViewPaymentsClicked),e.navigate(`${t}/payments`)}}}))(Nn);function Aa(){const n=D(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o]=r.useState((()=>{const c=new Date;return{month:c.getMonth()+1,year:c.getFullYear()}})),a=E((c=>Bt(c).fetchState))==="Completed";return r.useEffect((()=>{i&&n(Vt(o))}),[i,n,o]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingOverviewPage,isReady:a}),s.jsx(La,{navigate:e,selectedPeriod:o,tenantEmailDomain:t})]})}const $a=T((function(n){const e=Zt(n),{fetchState:t}=e;return{columns:e.columns,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.transactions.length===0,isLoadingMore:t==="In-Progress"&&e.transactions.length>0,tabIds:e.tabIds,transactions:e.transactions}}),(function(n,e){const t=`/${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:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"payments"}),e.navigate(`${t}/data_import`)},onTransactionClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingPaymentRowClicked,{transactionId:i}),e.navigate(`${t}/payments/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&n(zi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Un);function wa(){const n=D(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeType:S,appliedSearch:f,appliedSort:I,nextCursor:j,transactionListFetchState:y,transactions:k}=E((_=>{const O=Zt(_);return{activeType:O.activeTab,appliedSearch:O.filters.search,appliedSort:O.sort,nextCursor:O.nextCursor,transactionListFetchState:O.fetchState,transactions:O.transactions}}),Z),b=y==="Completed",C=`/${t}/invoicing`,P=r.useCallback((_=>{const O=k.find((M=>M.id===_)),R=O?.linkedInvoices?.[0]?.invoiceID??O?.invoiceID;R!=null&&(p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"payments_list",invoiceId:R,toScreen:"invoice"}),e(`${C}/invoices/${encodeURIComponent(R)}`))}),[e,C,k]),h=r.useCallback((_=>{const O=k.find((R=>R.id===_))?.customerID;O!=null&&(p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:O,fromScreen:"payments_list",toScreen:"customer"}),e(`${C}/customers/${encodeURIComponent(O)}`))}),[e,C,k]);return r.useEffect((()=>{const _=setTimeout((()=>d(o)),300);return()=>clearTimeout(_)}),[o]),r.useEffect((()=>{i&&n(pe({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==I?.field||u?.dir!==I?.dir)&&n(pe({cacheOverride:!0,filters:m,sort:u}))}),[i,n,m,u,f,I]),U(y)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingPaymentsListPage,isReady:b}),s.jsx($a,{navigate:e,tenantEmailDomain:t,activeType:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onTypeChange:_=>{n(Gi(_)),n(pe({cacheOverride:!1,filters:m,sort:u}))},onSortChange:v,onViewTransactionCustomer:h,onViewTransactionInvoice:P})]})}const Fa=n=>{const e=[n.firstName,n.lastName].filter((t=>t!=null&&t.trim()!=="")).join(" ").trim();return(n.company!=null&&n.company.trim()!==""?n.company.trim():"")||e||(n.email!=null&&n.email.trim()!==""?n.email.trim():"")||n.id},ut=(n,e)=>new Intl.NumberFormat("en-US",{currency:e,style:"currency"}).format(n);function gt(){const n=D(),e=L(),{invoice_id:t,tenantEmailDomain:i}=w(),{areTenantIdsInSync:o}=F(),a=t!=null&&t!=="",c=E(ue),d=E((h=>Wi(h))),l=E(Ji),v=E((h=>Ot(h,t??""))),u=v.invoice,m=`/${i}/invoicing`,S=r.useRef(null),f=r.useRef("");r.useEffect((()=>{n(Xi()),S.current=null,f.current=""}),[n,t]),r.useEffect((()=>{o&&n(a&&t!=null?Me({invoiceId:t}):Fe({filters:{},keepExistingListItems:!1}))}),[o,n,t,a]),r.useEffect((()=>{a&&u!=null&&t!=null&&v.fetchState==="Completed"&&S.current!==t&&(S.current=t,n(Yi({contextInvoiceId:t,localData:eo(u)})))}),[n,u,t,v.fetchState,a]),r.useEffect((()=>{if(a)return;const h=d.localData.customerId;h!==""&&h!==f.current&&(f.current=h,n(Mt({filters:{customerId:h},keepExistingListItems:!1})),d.localData.invoiceToLink!==""&&n(it({localData:{...d.localData,customerId:h,invoiceToLink:""}})))}),[n,d.localData,a]);const I=r.useRef(l.fetchState);r.useEffect((()=>{const h=I.current;if(I.current=l.fetchState,h!=="Completed"&&l.fetchState==="Completed"){if(l.recordedInvoiceId!=null)return void e(`${m}/invoices/${encodeURIComponent(l.recordedInvoiceId)}`);e(`${m}/payments`)}}),[e,l.fetchState,l.recordedInvoiceId,m]);const j=r.useMemo((()=>c.customers.map((h=>({id:h.id,name:Fa(h)})))),[c.customers]),y=E((h=>to(h,d.localData.customerId))),k=r.useMemo((()=>y.map((h=>({amountDue:ut(h.amountDue,"USD"),amountDueValue:h.amountDue,id:h.id,label:h.invoiceNumber})))),[y]),b=r.useMemo((()=>{if(!a||u==null)return;const h=u.currencyCode??"USD",_=u.amountDue?.amount??0;return{amountDue:ut(_,h),amountDueValue:_,currencyCode:h,customerName:u.customerName??u.customerID,invoiceId:u.id,invoiceNumber:u.invoiceNumber??u.id}}),[u,a]),C=a?`${m}/invoices/${encodeURIComponent(t??"")}`:`${m}/payments`,P=!a||v.fetchState==="Completed"&&d.localData.invoiceToLink!=="";return s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingRecordPaymentPage,isReady:P}),s.jsx(Bn,{customers:j,fieldHelp:d.fieldHelp,errorMessage:l.fetchState==="Error"?l.error?.message??"Failed to record payment. Please try again.":void 0,gatewayOptions:d.gatewayOptions,invoiceContext:b,invoiceOptions:k,isSubmitting:l.fetchState==="In-Progress",localData:d.localData,mode:a?"invoice":"customer",paymentMethodOptions:d.paymentMethodOptions,onBack:()=>{e(C)},onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingRecordPaymentCancelled),e(C)},onChange:h=>{n(it({localData:h}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingPaymentRecorded,{customerId:d.localData.customerId,invoiceId:a?t:d.localData.invoiceToLink,paymentMethod:d.localData.paymentMethod}),n(no(a?t??void 0:void 0))}})]})}const tn=(n,e,t)=>{const i=`/${n}/invoicing/subscriptions/`;return t!=null?`${i}${encodeURIComponent(t)}/${e}/`:`${i}new/${e}/`},Ra=(n,e)=>{if(n==null)return;const t=new Intl.NumberFormat("en-US",{currency:n.currencyCode??"USD",maximumFractionDigits:0,style:"currency"}).format(n.amount);return e!=null?`${t}/${e}`:t},nn=(n,e,t)=>{const i=[n,Ra(e,t)].filter((o=>o!=null&&o!=="")).join(" · ");return i!==""?i:void 0},mt=n=>n.priceCode!=null&&n.priceCode.trim()!=="",Ta=n=>({billingCycles:n.billingCycles,billingPeriod:n.period,billingPeriodUnit:n.periodUnit,label:n.name??n.id,subtitle:nn(n.productCode,n.price,n.periodUnit),value:n.priceCode}),Oa=n=>({label:n.name??n.couponCode??n.id,value:n.couponCode??n.id}),_a=T((function(n,e){const{editView:t}=e,i=t.subscription,o=i?.status,a=o!=null&&e.commercialEditAllowedFromStatuses.includes(o);return{cancelReasonCodeOptions:t.cancelReasonCodeOptions,fieldHelp:t.fieldHelp,addons:t.products.filter((c=>c.itemType==="addon")).filter(mt).map((c=>({label:c.name??c.id,subtitle:nn(c.productCode,c.price,c.periodUnit),value:c.priceCode}))),canEditCommercial:a,coupons:t.coupons.map(Oa),isLoading:!e.hasLoadedRecord&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),isRunningAction:t.actionState.fetchState==="In-Progress",isSaving:t.fetchState==="In-Progress",lifecycleActionOptions:e.lifecycleActionOptions,localData:t.localData,plans:t.plans.filter(mt).map(Ta),shippingAddressLabel:t.shippingAddressLabel,subscription:i}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,o=i!=="",a=(c,d)=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionLifecycleAction,{action:c,subscriptionId:i}),n(qt({action:c,id:i,body:d}))};return{onBack:()=>e.navigate(`${t}/subscriptions`),onChange:c=>{n(re({id:i,localData:c}))},onChangeTermEnd:o?c=>{const d=c?.trim()??"";d!==""&&a("change_term_end",{term_ends_at:d})}:void 0,onCustomerClick:c=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:c,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${t}/customers/${encodeURIComponent(c)}`,"_blank","noopener,noreferrer")},onOpenAddress:()=>{const c=tn(e.tenantEmailDomain??"",xe,i),d=X(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onViewInvoices:()=>e.navigate(`${t}/invoices`),onSaveEdit:c=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionEdited,{subscriptionId:i}),n(re({id:i,localData:c})),n(Ht({id:i}))},onCancelSubscription:o?c=>{a("cancel",{cancel_reason_code:c.cancelReasonCode,end_of_term:!1,...c.cancelReason!=null&&c.cancelReason.trim()!==""?{cancel_reason:c.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:o?(c,d)=>{c!=="pause"?a(c):a(c,d!=null&&d.trim()!==""?{resume_date:d.trim()}:void 0)}:void 0}}))(Vn);function Ma(){const n=D(),e=L(),t=J(),{subscription_id:i,tenantEmailDomain:o}=w(),{areTenantIdsInSync:a}=F(),c=E((k=>Ne(k,i))),{subscriptionCommercialEditAllowedFromStatuses:d,subscriptionLifecycleActionOptions:l,subscriptionMetadataEditAllowedFromStatuses:v}=c,u=c.pageFetchState.fetchState,m=u==="Completed",[S,f]=r.useState(m?i:void 0);r.useEffect((()=>{i!=null&&m&&f(i)}),[i,m]);const I=S===i;Ve(a),r.useEffect((()=>{a&&i!=null&&n(ot({id:i}))}),[a,i,n]);const[j,y]=r.useState(0);return r.useEffect((()=>{c.fetchState==="Completed"&&(n(Ue()),n(ot({cacheOverride:!0,id:i})),y((k=>k+1)))}),[c.fetchState,n,i]),U(u)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingSubscriptionDetailPage,isReady:m}),s.jsx(_a,{hasLoadedRecord:I,commercialEditAllowedFromStatuses:d,editView:c,lifecycleActionOptions:l,location:t,metadataEditAllowedFromStatuses:v,navigate:e,subscriptionId:i??"",tenantEmailDomain:o},j)]})}const Na=n=>{const e=[n.firstName,n.lastName].filter((t=>t!=null&&t.trim()!=="")).join(" ").trim();return(n.company!=null&&n.company.trim()!==""?n.company.trim():"")||e||(n.email!=null&&n.email.trim()!==""?n.email.trim():"")||n.id},Ua=(n,e)=>{if(n==null)return;const t=new Intl.NumberFormat("en-US",{currency:n.currencyCode??"USD",maximumFractionDigits:0,style:"currency"}).format(n.amount);return e!=null?`${t}/${e}`:t},je=(n,e,t)=>{const i=[n,Ua(e,t)].filter((o=>o!=null&&o!=="")).join(" · ");return i!==""?i:void 0},Ba=n=>({label:Na(n),value:n.id}),Se=n=>n.priceCode!=null&&n.priceCode.trim()!=="",Va=n=>({billingCycles:n.billingCycles,billingPeriod:n.period,billingPeriodUnit:n.periodUnit,label:n.name??n.id,subtitle:je(n.productCode,n.price,n.periodUnit),trialPeriod:n.trialPeriod,trialPeriodUnit:n.trialPeriodUnit,value:n.priceCode}),Za=n=>({label:n.name??n.couponCode??n.id,value:n.couponCode??n.id}),Ha=T((function(n,e){const t=Ne(n,e.subscriptionId);return{fieldHelp:t.fieldHelp,addons:t.products.filter((i=>i.itemType==="addon")).filter(Se).map((i=>({label:i.name??i.id,subtitle:je(i.productCode,i.price,i.periodUnit),value:i.priceCode}))),charges:t.products.filter((i=>i.itemType==="charge")).filter(Se).map((i=>({label:i.name??i.id,subtitle:je(i.productCode,i.price,void 0),value:i.priceCode}))),coupons:t.coupons.map(Za),customers:t.customers.map(Ba),errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save subscription.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode,plans:t.plans.filter(Se).map(Va),shippingAddressLabel:t.shippingAddressLabel}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,o=i!=null?"edit":"create";return{onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionFormCancelled),n(Ue()),n(we(xe)),i==null?e.navigate(`${t}/subscriptions`):e.navigate(`${t}/subscriptions/${encodeURIComponent(i)}`)},onChange:a=>{n(re({id:i,localData:a}))},onOpenAddress:()=>{const a=tn(e.tenantEmailDomain??"",xe,i),c=X(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:c}})},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionSaved,{mode:o}),n(Ht({id:i}))}}}))(Zn);function qa(){const n=D(),e=L(),t=J(),{subscription_id:i,tenantEmailDomain:o}=w(),[a]=W(),{areTenantIdsInSync:c}=F(),d=a.get("customerId"),{fetchState:l,savedSubscriptionId:v}=E((S=>io(S,i))),u=E((S=>Ne(S,i).localData));Ve(c),r.useEffect((()=>{c&&(n(Fe({filters:{},keepExistingListItems:!1})),n(Ce({filters:{type:"plan"},keepExistingListItems:!1})),n(Rt({filters:{},keepExistingListItems:!1})),i!=null&&n(oo({id:i})))}),[c,i,n]);const m=r.useRef(!1);return r.useEffect((()=>{m.current||i!=null||d==null||d===""||u.customerId!==""||(m.current=!0,n(re({id:i,localData:{...u,customerId:d}})))}),[d,i,u,n]),r.useEffect((()=>{if(l==="Completed"){const S=v??i,f=S!=null?`/${o}/invoicing/subscriptions/${encodeURIComponent(S)}`:`/${o}/invoicing/subscriptions`;e(f),n(Ue())}}),[l,v,i,n,e,o]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingSubscriptionFormPage}),s.jsx(Ha,{location:t,navigate:e,subscriptionId:i,tenantEmailDomain:o})]})}const Ka=T((function(n){const e=Kt(n),{fetchState:t}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.subscriptions.length===0,isLoadingMore:t==="In-Progress"&&e.subscriptions.length>0,cancelReasonCodeOptions:e.cancelReasonCodeOptions,lifecycleActionOptions:e.subscriptionLifecycleActionOptions,subscriptions:e.subscriptions,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,i=(o,a,c)=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionLifecycleAction,{action:a,subscriptionId:o}),n(qt({action:a,id:o,body:c}))};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onAddSubscription:()=>{p.trackInvoicingActionClick(g.Event.invoicingAddSubscriptionClicked),e.navigate(`${t}/subscriptions/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"subscriptions"}),e.navigate(`${t}/data_import`)},onChangeTermEnd:(o,a)=>{const c=a?.trim()??"";c!==""&&i(o,"change_term_end",{term_ends_at:c})},onSubscriptionAction:(o,a,c)=>{a!=="pause"?i(o,a):i(o,a,c!=null&&c.trim()!==""?{resume_date:c.trim()}:void 0)},onCancelSubscription:(o,a)=>{i(o,"cancel",{cancel_reason_code:a.cancelReasonCode,end_of_term:!1,...a.cancelReason!=null&&a.cancelReason.trim()!==""?{cancel_reason:a.cancelReason.trim()}:{}})},onSubscriptionClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionRowClicked,{subscriptionId:o}),e.navigate(`${t}/subscriptions/${encodeURIComponent(o)}`)},onViewSubscriptionInvoices:()=>{e.navigate(`${t}/invoices`)},onLoadMore:()=>{e.nextCursor!=null&&n(co({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Hn);function Qa(){const n=D(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:I,nextCursor:j,subscriptionListFetchState:y,runningActionSubscriptionId:k}=E((P=>{const h=Kt(P);return{activeStatus:h.activeTab,appliedSearch:h.filters.search,appliedSort:h.sort,nextCursor:h.nextCursor,subscriptionListFetchState:h.fetchState,runningActionSubscriptionId:h.runningActionId??null}}),Z),b=y==="Completed";r.useEffect((()=>{const P=setTimeout((()=>d(o)),300);return()=>clearTimeout(P)}),[o]),r.useEffect((()=>{i&&n(at({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==I?.field||u?.dir!==I?.dir)&&n(at({cacheOverride:!0,filters:m,sort:u}))}),[i,n,m,u,f,I]);const C=r.useRef(k);return r.useEffect((()=>{const P=C.current!=null&&k==null;C.current=k,P&&i&&n(ao())}),[k,i,n]),U(y)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingSubscriptionsListPage,isReady:b}),s.jsx(Ka,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,runningActionSubscriptionId:k,onSearchChange:a,onStatusChange:P=>n(so(P)),onSortChange:v})]})}const Ga=T((function(n,e){const{readView:t}=e;return{isLoading:t.fetchState==="Not-Started"||t.fetchState==="In-Progress",isRunningAction:t.actionState.fetchState==="In-Progress",transaction:t.transaction,transactionId:e.transactionId}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{transactionId:i}=e;return{onBack:()=>e.navigate(`${t}/payments`),onCustomerClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:o,fromScreen:"transaction_detail",toScreen:"customer"}),e.navigate(`${t}/customers/${encodeURIComponent(o)}`)},onInvoiceClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(o)}`)},onSubscriptionClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",subscriptionId:o,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(o)}`)},onCapture:i!==""?()=>{p.trackInvoicingActionClick(g.Event.invoicingTransactionCaptured,{transactionId:i}),n(uo({action:"capture",id:i}))}:void 0}}))(qn);function za(){const n=D(),e=L(),{tenantEmailDomain:t,transaction_id:i}=w(),{areTenantIdsInSync:o}=F(),a=E((d=>ro(d,i??""))),c=a.fetchState==="Completed";return r.useEffect((()=>{o&&i!=null&&n(lo({id:i}))}),[o,i,n]),U(a.fetchState)?s.jsx(N,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingTransactionDetailPage,isReady:c}),s.jsx(Ga,{navigate:e,tenantEmailDomain:t,transactionId:i??"",readView:a})]})}const Wa={branding:"invoicing_branding_save",dunning:"invoicing_dunning_settings_save",quickbooks:"invoicing_qbo_settings_save"};function Y(n){const e=D(),{areTenantIdsInSync:t}=F(),{tenantEmailDomain:i}=w(),{fetchState:o,fieldHelp:a,saveState:c,settings:d,stripeConnectState:l}=E(go),{configError:v,configFetchState:u,dunningScheduleActionOptions:m,qboAccountMappingKindOptions:S,qboCustomerMatchingOptions:f,qboSyncStatusOptions:I}=E(Qt),j=E(Le);Be({enabled:n==="quickbooks",fetchSyncHealth:!0,loadAccountingPickers:!0});const y=E(Oe),k=n==="dunning"||n==="quickbooks",b=y.companyId??he.getSignedInUserTenant(i??"")?.companyId,C=E((A=>$t(A,b))),P=mo(y.userRole??[]),h=y.tenantId??"",_=he.getSignedInUser(),O={userId:_?.userId??"",sessionId:_?.zeniSessionId??"",tenantId:h},R=d?.logo_file_id,M=E((A=>R!=null&&R!==""?A.fileState.fileByFileId[R]:void 0)),ee=E((A=>R!=null&&R!==""?vo(A,R):void 0)),Ze=E((A=>R!=null&&R!==""?po(A,R):void 0)),on=R!=null&&R!==""&&ee!=null?{[R]:ee}:{},an=R!=null&&R!==""&&Ze!=null?{[R]:Ze}:{};r.useEffect((()=>(e(st()),()=>{e(st())})),[e]),r.useEffect((()=>{t&&(o!=="Not-Started"&&o!=="Error"||e(_e()))}),[t,e,o]),r.useEffect((()=>{t&&k&&u==="Not-Started"&&e(le())}),[t,e,u,k]),r.useEffect((()=>{if(!t)return;const A=_?.userId;A!=null&&A!==""&&h!==""&&Ke.shouldFetchActiveTenant(h)&&(Ke.markActiveTenantFetchStarted(h),e(fo(A,h,_?.zeniSessionId)))}),[t,e,_?.userId,_?.zeniSessionId,h]),r.useEffect((()=>{t&&R!=null&&R!==""&&h!==""&&M==null&&e(So(R,h))}),[t,e,M,R,h]);const sn=m.length>0||S.length>0,cn=o==="Not-Started"||o==="In-Progress"&&d==null||k&&!sn&&(u==="Not-Started"||u==="In-Progress"),rn=o==="Completed"&&(!k||u==="Completed"),He=C.externalConnections?.revenue?.find((A=>A.connectionName==="chargebee"))?.connectionId,ge=se?.invoicingMicroServiceBaseUrl,qe=ge!=null&&ge.length>0?`${ge}/1.0/webhooks/stripe`:"",me={deleteConnectionError:C.externalConnections?.deleteConnectionError?.message,deleteConnectionState:C.externalConnections?.deleteConnectionState??"Not-Started",integrationsView:C,isAdmin:P,isStripeBusy:l.fetchState==="In-Progress",onConnectStripe:A=>e(rt(A)),onDisconnect:(A,q)=>{h!==""&&e(xo(h,A,lt(q)))},onDisconnectStripe:()=>e(ct()),onReconnectQBO:()=>{const A=y.tenantEmailDomain??i??"";de.init("/connection/auth",A),de.handleClick()},onRefreshQBO:()=>{C.integrations.refreshQBO.fetchState!=="In-Progress"&&e(Wt())},onSaveChargeBeeCredentials:(A,q)=>{He!=null&&h!==""&&e(ko(h,He,lt("revenue"),yo("chargebee"),{api_key:A,site:q}))},saveChargeBeeError:C.externalConnections?.saveAPIKeyConnectionError?.message,saveChargeBeeState:C.externalConnections?.saveAPIKeyConnectionState??"Not-Started",settings:d,stripeError:l.fetchState==="Error"?l.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:qe};return{authParams:O,deleteFileStatusById:on,fieldHelp:a,dunningScheduleActionOptions:m,filesEndPoint:se?.fileMicroServiceBaseUrl??"",integrationsSectionProps:me,isInvoicingPageReady:rn,isLoading:cn,isSaving:c.fetchState==="In-Progress",isStripeBusy:l.fetchState==="In-Progress",logoFile:M,qboAccountMappingKindOptions:S,qboCustomerMatchingOptions:f,qboSyncStatusOptions:I,qboView:j,saveErrorMessage:c.fetchState==="Error"?c.error?.message??"Failed to save settings.":k&&u==="Error"?v?.message??"Failed to load invoicing configuration.":void 0,settings:d,stripeError:l.fetchState==="Error"?l.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:qe,updateFileStatusById:an,onConnectStripe:A=>e(rt(A)),onDeleteFile:A=>e(Eo(A)),onDisconnectStripe:()=>e(ct()),onEditFileName:(A,q)=>e(Io(A,q)),onReconnectQBO:me.onReconnectQBO,onRefreshQBO:me.onRefreshQBO,onRetryQboSyncTask:A=>e(zt(A)),onSave:A=>{p.trackInvoicingActionClick(g.Event.invoicingSettingsSaved,{tab:n??"hub"}),e(Co({settings:A,snackbarSection:Wa[n??""]}))},onStartQboBackfill:A=>e(Gt(A)),updateFilesEntity:A=>{p.trackInvoicingActionClick(g.Event.invoicingLogoUploaded),e(ho({files:A}))}}}function vt({appContent:n}){const e=L(),t=J(),i=D(),{tenantEmailDomain:o}=w(),a=Y("branding"),c=E((v=>bo(v))),d=E((v=>jo(fe,v)?.addressToCreate));r.useEffect((()=>{c.saveState.fetchState==="Completed"&&(i(Po()),i(we(fe)))}),[c.saveState.fetchState,i]);const l=St(c.saveState.fetchState);return r.useEffect((()=>{l==="In-Progress"&&c.saveState.fetchState==="Completed"&&e("..")}),[l,c.saveState.fetchState,e]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingSettingsPage,isReady:a.isInvoicingPageReady}),s.jsx(Kn,{address:d,fieldHelp:c.fieldHelp,addressLabel:c.addressLabel,appContent:n,authParams:a.authParams,dateFormatOptions:c.dateFormatOptions,deleteFileStatusById:a.deleteFileStatusById,filesEndPoint:a.filesEndPoint,isLoading:a.isLoading,isSaving:a.isSaving,localData:c.localData,saveErrorMessage:a.saveErrorMessage,settings:a.settings,updateFileStatusById:a.updateFileStatusById,onBackClick:()=>e(".."),onChange:v=>{i(Lo({localData:v}))},onDeleteFile:a.onDeleteFile,onEditFileName:a.onEditFileName,onOpenAddress:()=>{const v=`/${o}/invoicing/settings/branding/${fe}/`,u=X(t.state?.pathnameStackToGoBack,t.pathname);e(v,{state:{pathnameStackToGoBack:u}})},onSubmit:()=>i(Do()),updateFilesEntity:a.updateFilesEntity})]})}function Ja(){const n=L(),e=Y("dunning");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Qn,{dunningScheduleActionOptions:e.dunningScheduleActionOptions,isLoading:e.isLoading,isSaving:e.isSaving,saveErrorMessage:e.saveErrorMessage,settings:e.settings,onBackClick:()=>n(".."),onSave:e.onSave})]})}function Xa(){const n=L(),e=Y("integrations");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Gn,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>n("../quickbooks"),onOpenPaymentDestination:()=>n("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>n("..")})]})}function Ya(){const n=L(),e=Y("payment-destination");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(zn,{fieldHelp:e.fieldHelp,isLoading:e.isLoading,isStripeBusy:e.isStripeBusy,saveErrorMessage:e.saveErrorMessage,settings:e.settings,stripeError:e.stripeError,stripeWebhookUrl:e.stripeWebhookUrl,onBackClick:()=>n(".."),onConnectStripe:e.onConnectStripe})]})}const es=T((function(n){const e=Jt(n);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(n){return{onChange:e=>{n(wo({localData:e}))},onReset:()=>{n($o())},onRetryTask:e=>{n(zt(e))},onSave:()=>{p.trackInvoicingActionClick(g.Event.invoicingSettingsSaved,{tab:"quickbooks"}),n(Ao())},onStartBackfill:e=>{n(Gt(e))}}}))(Wn);function ts(){const n=D(),e=L(),{tenantEmailDomain:t}=w(),i=E(Oe),{configFetchState:o,settingsFetchState:a}=E(Jt);return r.useEffect((()=>{a!=="Not-Started"&&a!=="Error"||n(_e())}),[n,a]),r.useEffect((()=>{o==="Not-Started"&&n(le())}),[o,n]),Be({fetchSyncHealth:!0,loadAccountingPickers:!0}),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingSettingsPage}),s.jsx(es,{onBackClick:()=>e(".."),onReconnect:()=>{de.init("/connection/auth",i.tenantEmailDomain??t??""),de.handleClick()},onRefresh:()=>n(Wt())})]})}const ns={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function is(){const n=ft(),e=D(),t=L(),[i,o]=W(),a=Y(),{canEnableInvoicing:c,isEnablingInvoicing:d,isInvoicingEnabled:l,isQboConfigured:v,isStripeConnected:u}=E(Qt),m=i.get("tab");return r.useEffect((()=>{if(m==null)return;const S=ns[m];o({},{replace:!0}),S!=null&&t(S,{replace:!0})}),[m,t,o]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:g.Event.invoicingSettingsPage,isReady:a.isInvoicingPageReady}),s.jsx(Jn,{analytics:p,integrationsSectionProps:{...a.integrationsSectionProps,onConfigureQBO:()=>t("quickbooks"),onOpenPaymentDestination:()=>t("payment-destination")},isEnablingInvoicing:d,isLoading:a.isLoading,meetingUrl:n("invoicing_settings"),settings:a.settings,onBrandingClick:()=>t("branding"),onDunningClick:()=>t("dunning"),canEnableInvoicing:c,isQboConfigured:v,isStripePaymentsReady:u,onEnableInvoicingClick:l?void 0:()=>{e(Fo())}})]})}function pt(){return s.jsxs(ie,{children:[s.jsx(x,{index:!0,element:s.jsx(is,{})}),s.jsx(x,{path:"payment-destination",element:s.jsx(Ya,{})}),s.jsx(x,{path:"branding",element:s.jsx(vt,{})}),s.jsx(x,{path:"branding/:addressType",element:s.jsx(vt,{appContent:s.jsx(K,{isSubPage:!0,hideAddressBackButton:!0})})}),s.jsx(x,{path:"integrations",element:s.jsx(Xa,{})}),s.jsx(x,{path:"dunning",element:s.jsx(Ja,{})}),s.jsx(x,{path:"quickbooks",element:s.jsx(ts,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:"..",replace:!0})})]})}function $s(){const n=D(),e=L(),{tenantEmailDomain:t}=w(),{areTenantIdsInSync:i}=F(),{enableState:o,fetchState:a,status:c}=E(Nt),d=St(o.fetchState),l=`/${t}/invoicing`,v=r.useRef(!1),u=E((m=>Le(m).connectionFetchState.fetchState));return r.useEffect((()=>{i&&(a!=="Not-Started"?a!=="Error"||v.current||(v.current=!0,n(le({cacheOverride:!1}))):n(le({cacheOverride:!1})))}),[i,n,a]),r.useEffect((()=>{i&&u==="Not-Started"&&n(Et())}),[i,n,u]),r.useEffect((()=>{d==="In-Progress"&&o.fetchState==="Completed"&&(e(`${l}/catalog`),n(Ro()))}),[d,o.fetchState,l,n,e]),c==null&&a!=="Error"?s.jsx(Xn,{}):c==="not_started"?s.jsxs(ie,{children:[s.jsx(x,{path:"promo",element:s.jsx(dt,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:`${l}/promo`,replace:!0})})]}):c==="settings"?s.jsxs(ie,{children:[s.jsx(x,{path:"promo",element:s.jsx(dt,{})}),s.jsx(x,{path:"settings/*",element:s.jsx(pt,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:`${l}/settings`,replace:!0})})]}):s.jsxs(ie,{children:[s.jsx(x,{path:"/",element:s.jsx(B,{to:"overview",replace:!0})}),s.jsx(x,{path:"overview",element:s.jsx(Aa,{})}),s.jsx(x,{path:"promo",element:s.jsx(B,{to:`${l}/overview`,replace:!0})}),s.jsx(x,{path:"customers",element:s.jsx(ra,{})}),s.jsx(x,{path:"customers/new",element:s.jsx(sa,{})}),s.jsx(x,{path:"customers/new/:addressType",element:s.jsx(K,{})}),s.jsx(x,{path:"customers/:customer_id",element:s.jsx(oa,{})}),s.jsx(x,{path:"customers/:customer_id/:addressType",element:s.jsx(K,{})}),s.jsx(x,{path:"subscriptions",element:s.jsx(Qa,{})}),s.jsx(x,{path:"subscriptions/new",element:s.jsx(qa,{})}),s.jsx(x,{path:"subscriptions/new/:addressType",element:s.jsx(K,{})}),s.jsx(x,{path:"subscriptions/:subscription_id",element:s.jsx(Ma,{})}),s.jsx(x,{path:"subscriptions/:subscription_id/:addressType",element:s.jsx(K,{})}),s.jsx(x,{path:"invoices",element:s.jsx(ja,{})}),s.jsx(x,{path:"invoices/create",element:s.jsx(Xo,{})}),s.jsx(x,{path:"invoices/:invoice_id",element:s.jsx(xa,{})}),s.jsx(x,{path:"invoices/:invoice_id/record-payment",element:s.jsx(gt,{})}),s.jsx(x,{path:"invoices/:invoice_id/issue-credit-note",element:s.jsx(Da,{})}),s.jsx(x,{path:"payments",element:s.jsx(wa,{})}),s.jsx(x,{path:"payments/record",element:s.jsx(gt,{})}),s.jsx(x,{path:"payments/:transaction_id",element:s.jsx(za,{})}),s.jsx(x,{path:"credits",element:s.jsx(na,{})}),s.jsx(x,{path:"credits/:credit_note_id",element:s.jsx(ea,{})}),s.jsx(x,{path:"discounts",element:s.jsx(ha,{})}),s.jsx(x,{path:"discounts/new",element:s.jsx(Wo,{})}),s.jsx(x,{path:"discounts/:coupon_id",element:s.jsx(fa,{})}),s.jsx(x,{path:"dunning",element:s.jsx(ka,{})}),s.jsx(x,{path:"dunning/:case_id",element:s.jsx(Ia,{})}),s.jsx(x,{path:"catalog",element:s.jsx(Go,{})}),s.jsx(x,{path:"catalog/new",element:s.jsx(qo,{})}),s.jsx(x,{path:"catalog/:item_id",element:s.jsx(Bo,{})}),s.jsx(x,{path:"settings/*",element:s.jsx(pt,{})}),s.jsx(x,{path:"audit_log",element:s.jsx(Oo,{})}),s.jsx(x,{path:"data_import",element:s.jsx(ga,{})}),s.jsx(x,{path:"data_import/migrate",element:s.jsx(va,{})}),s.jsx(x,{path:"data_import/:sessionId",element:s.jsx(da,{})}),s.jsx(x,{path:"*",element:s.jsx(N,{})})]})}export{$s as default};
@@ -1,4 +1,4 @@
1
- import{j as a}from"./liveblocks-D0hIH2N0.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-35eDsgGP.js";import{To as k,Tp as v,Tq as F,Iw as D,Ii as G,Tr as B,Ts as oe,Tt as ie,Im as se,ge as j,It as le,Iq as re}from"./zeni-epic-state-BRRtwAQl.js";import{$ as x,J as r,a0 as de,k as I,X as M,a1 as ce,a2 as me,a3 as pe,p as V,I as ue,d as he,a4 as ge,c as xe,E as fe,g as we,a5 as be,a6 as Se,Z as ye,a7 as ke,a8 as ve,a9 as Ie,aa as je}from"./index-BBhWSYD8.js";import{n as m}from"./mui-CY_LMiAy.js";import f from"./NotFoundScreen-B6L1cY3I.js";import{a as $}from"./sentry-DhqS_W-k.js";import"./recharts-B8j-bW95.js";import"./analytics-p9dV2gEo.js";import"./plaid-CoaHurGj.js";import"./dnd-Dm1d6mZC.js";import"./stripe-cKAAJElX.js";import"./lottie-TJOzQ6Cz.js";import"./lexical-DQ4lSvQh.js";import"./pdf-DElOA9Iz.js";import"./utils-CgQOqOwX.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]="016e604d-869b-4b82-a07c-3316ed6157fe",e._sentryDebugIdIdentifier="sentry-dbid-016e604d-869b-4b82-a07c-3316ed6157fe")}catch{}})();const $e=m.div`
1
+ import{j as a}from"./liveblocks-BY1qt3Nf.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-DFhvjgE1.js";import{TI as k,TJ as v,TK as F,IM as D,Iy as M,TL as B,TM as oe,TN as ie,IC as se,ge as j,IJ as le,IG as re}from"./zeni-epic-state-DxmmAR38.js";import{a1 as x,N as r,a2 as de,k as I,Z as G,a3 as ce,a4 as me,a5 as pe,p as K,c as ue,y as he,a6 as ge,M as xe,E as fe,f as be,a7 as we,a8 as Se,$ as ye,a9 as ke,aa as ve,ab as Ie,ac as je}from"./index-Cp-pyxoH.js";import{n as m}from"./mui-DesXezzU.js";import f from"./NotFoundScreen-VUm8cLbz.js";import{a as $}from"./sentry-xWYlrqHr.js";import"./recharts-Co89o1ZO.js";import"./analytics-CsVp7bfq.js";import"./plaid---yWAm21.js";import"./dnd-CR945ANw.js";import"./stripe-cKAAJElX.js";import"./lottie-DgdF8254.js";import"./lexical-CCIwPSwQ.js";import"./pdf-BVKoD2Fp.js";import"./utils-18zApAFM.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]="7804991b-ee68-402a-8140-81bbf6d7e211",e._sentryDebugIdIdentifier="sentry-dbid-7804991b-ee68-402a-8140-81bbf6d7e211")}catch{}})();const $e=m.div`
2
2
  display: flex;
3
3
  height: 100%;
4
4
  width: 100%;
@@ -7,7 +7,7 @@ import{j as a}from"./liveblocks-D0hIH2N0.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(G(i))},onSaveHandler:i=>{I.trackBillPayMagicLinkSubmitBankAccountDetails(o),e(D(i,"standard",n,o))},onACHDetailsUpdated:i=>{const{bankAccountSection:l}=i;e(F({data:l}))}}}))(de);function T(){const e=x(),{vendorId:t,billId:n}=S();return t==null||n==null?a.jsx(f,{}):a.jsx(a.Fragment,{children:a.jsx($e,{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(M(i))},onSaveHandler:i=>{I.trackBillPayMagicLinkSubmitBankAccountDetails(o),e(D(i,"standard",n,o))},onACHDetailsUpdated:i=>{const{bankAccountSection:l}=i;e(F({data:l}))}}}))(de);function T(){const e=x(),{vendorId:t,billId:n}=S();return t==null||n==null?a.jsx(f,{}):a.jsx(a.Fragment,{children:a.jsx($e,{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%;
@@ -16,7 +16,7 @@ import{j as a}from"./liveblocks-D0hIH2N0.js";import{i as S,l as g,h as C,g as y,
16
16
  align-items: center;
17
17
  background-color: ${e=>e.theme.colors.grey4};
18
18
  box-shadow: ${e=>`0px 2px ${r.sp1} ${e.theme.colors.dropShadowNormal}`};
19
- `,Be=g((function(e,t){const{isSubPage:n}=t;return{addressToEdit:B(e),googleAPIKey:M.googleMapsAPIKey,isSubPage:n}}),(function(e,t){const{navigate:n,location:o}=t,i=()=>{const l=me(o.state?.pathnameStackToGoBack),s=l.poppedPathname??Pe();n(s,{state:{pathnameStackToGoBack:l.newStack}})};return{onSubmitHandler:l=>{const s=ze(l);e(oe({addressToCreate:s})),i()},onCancel:()=>{i()}}}))(ce);function Ae({isSubPage:e}){const t=C(),n=y(),o=x();return a.jsx(a.Fragment,{children:a.jsx(De,{windowSize:o,children:a.jsx(Be,{location:n,navigate:t,isSubPage:e===!0,googleAPIKey:M.googleMapsAPIKey})})})}const Pe=(e=2)=>{let t="../";for(let n=0;n<e;n++)t=`${t}../`;return t},ze=e=>({street:[e.street.addressString,e.suite,e.secondaryInfo],city:e.city,state:e.state,country:e.country.selectedOption??"",countryCode:e.countryCode,postalCode:e.postalCode,latitude:e.street.addressValue?.locationLat,longitude:e.street.addressValue?.locationLng}),Le=m.div`
19
+ `,Be=g((function(e,t){const{isSubPage:n}=t;return{addressToEdit:B(e),googleAPIKey:G.googleMapsAPIKey,isSubPage:n}}),(function(e,t){const{navigate:n,location:o}=t,i=()=>{const l=me(o.state?.pathnameStackToGoBack),s=l.poppedPathname??Pe();n(s,{state:{pathnameStackToGoBack:l.newStack}})};return{onSubmitHandler:l=>{const s=Ne(l);e(oe({addressToCreate:s})),i()},onCancel:()=>{i()}}}))(ce);function Ae({isSubPage:e}){const t=C(),n=y(),o=x();return a.jsx(a.Fragment,{children:a.jsx(De,{windowSize:o,children:a.jsx(Be,{location:n,navigate:t,isSubPage:e===!0,googleAPIKey:G.googleMapsAPIKey})})})}const Pe=(e=2)=>{let t="../";for(let n=0;n<e;n++)t=`${t}../`;return t},Ne=e=>({street:[e.street.addressString,e.suite,e.secondaryInfo],city:e.city,state:e.state,country:e.country.selectedOption??"",countryCode:e.countryCode,postalCode:e.postalCode,latitude:e.street.addressValue?.locationLat,longitude:e.street.addressValue?.locationLng}),ze=m.div`
20
20
  display: flex;
21
21
  height: 100%;
22
22
  width: 100%;
@@ -25,7 +25,7 @@ import{j as a}from"./liveblocks-D0hIH2N0.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(G(s))},onSaveHandler:s=>{I.trackBillPayMagicLinkSubmitBankAccountDetails(l),e(D(s,"us-domestic",i,l))},onWireDetailsUpdated:s=>{const{bankAccountSection:d}=s;e(F({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 Te=m.div`
28
+ `,Le=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(M(s))},onSaveHandler:s=>{I.trackBillPayMagicLinkSubmitBankAccountDetails(l),e(D(s,"us-domestic",i,l))},onWireDetailsUpdated:s=>{const{bankAccountSection:d}=s;e(F({data:d}))},onAddressClick:()=>{const s=o.pathname.replace("us-domestic","address"),d=K(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(ze,{windowSize:n,children:a.jsx(Le,{location:t,navigate:e,vendorId:o,billId:i})})})}const Te=m.div`
29
29
  display: flex;
30
30
  height: 100%;
31
31
  width: 100%;
@@ -34,7 +34,7 @@ import{j as a}from"./liveblocks-D0hIH2N0.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
- `,Fe=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=>{I.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 Ge(){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(Te,{windowSize:n,children:a.jsx(Fe,{location:t,navigate:e,vendorId:o,billId:i,isLocalCurrencyEnabled:s})})}const Me={containerWidth:new Ie(100,58)},Ve=m(ke)`
37
+ `,Fe=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=>{I.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=K(o.state?.pathnameStackToGoBack,o.pathname);n(s,{state:{pathnameStackToGoBack:d}})}}}))(ge);function Me(){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(Te,{windowSize:n,children:a.jsx(Fe,{location:t,navigate:e,vendorId:o,billId:i,isLocalCurrencyEnabled:s})})}const Ge={containerWidth:new Ie(100,58)},Ke=m(ke)`
38
38
  width: ${r.sp4};
39
39
  height: ${r.sp4};
40
40
  margin-bottom: ${r.sp3};
@@ -43,22 +43,22 @@ import{j as a}from"./liveblocks-D0hIH2N0.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
- `,_e=m.div`
46
+ `,Ve=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
- `,He=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;
57
- width: ${e=>`${Me.containerWidth.value(e.windowSize)}%`};
57
+ width: ${e=>`${Ge.containerWidth.value(e.windowSize)}%`};
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
- `,Ke=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-D0hIH2N0.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
- `,We=g((function(e,t){return{file:t.file,type:t.type}}))(ve);function h({appContent:e}){const t=ee(),n=y(),{tenantEmailDomain:o,vendorId:i,billId:l}=S(),[s]=ae(),d=s.get("token"),_=n.pathname.includes("address"),w=x(),H=xe(),A=fe(),b=we(),K=()=>{H.toggle()},W=E((u=>k(u))),U=E((u=>v(u))),{authParams:q,fetchState:c,billAttachment:J,billFetchState:P,companyName:X,currencySymbol:Z,amount:O}=W,{tenantId:z,userId:L,sessionId:N}=q,{fetchState:Q,internationalBankAccountCreateStatus:R}=U;return $.useEffect((()=>{j()}),[]),$.useEffect((()=>{b&&c==="Not-Started"&&i!=null&&o!=null&&d!=null&&t(le(i,o,d))}),[b,c,i,o,d,t]),$.useEffect((()=>{b&&c==="Completed"&&(j(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"?(j(),a.jsx(te,{to:"../../../../../../../bank/account/save/success",replace:!0,relative:"path"})):c==="In-Progress"?a.jsx(be,{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(Se,{analytics:I,onLoad:u=>(Y=>Y.trackBillPayMagicLinkPageLoad(o??"",i??"",X,l??"",Ue(n.pathname),Z,O))(u)}),a.jsxs(_e,{windowSize:w,children:[w!=="small"?a.jsx(Ve,{onClick:K}):null,a.jsx(Ke,{windowSize:w,isAddressPage:_,children:P==="In-Progress"?a.jsx(ye,{size:"ExtraLarge",start:!0}):a.jsx(We,{file:J,type:"bill"})}),a.jsx(He,{windowSize:w,children:e})]})]})}const Ue=e=>`${e.split("/").at(-2)}_${e.split("/").at(-1)}`;function qe(){return a.jsx(je,{})}function da(){return a.jsxs(ne,{children:[a.jsx(p,{path:"bank/account/save/success",element:a.jsx(qe,{})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/ach/standard",element:a.jsx(h,{appContent:a.jsx(T,{})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/ach/same-day",element:a.jsx(h,{appContent:a.jsx(T,{})})}),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(Ge,{})})}),a.jsx(p,{path:"*",element:a.jsx(f,{})})]})}export{da as default};
72
+ `,We=g((function(e,t){return{file:t.file,type:t.type}}))(ve);function h({appContent:e}){const t=ee(),n=y(),{tenantEmailDomain:o,vendorId:i,billId:l}=S(),[s]=ae(),d=s.get("token"),V=n.pathname.includes("address"),b=x(),_=xe(),A=fe(),w=be(),H=()=>{_.toggle()},W=E((u=>k(u))),J=E((u=>v(u))),{authParams:U,fetchState:c,billAttachment:q,billFetchState:P,companyName:O,currencySymbol:Q,amount:Z}=W,{tenantId:N,userId:z,sessionId:L}=U,{fetchState:R,internationalBankAccountCreateStatus:X}=J;return $.useEffect((()=>{j()}),[]),$.useEffect((()=>{w&&c==="Not-Started"&&i!=null&&o!=null&&d!=null&&t(le(i,o,d))}),[w,c,i,o,d,t]),$.useEffect((()=>{w&&c==="Completed"&&(j(z,L,N),l!=null&&t(re(l)))}),[c,w,z,L,N,l,t]),c==="Error"?a.jsx(f,{}):R==="Completed"||X.fetchState==="Completed"?(j(),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(Se,{analytics:I,onLoad:u=>(Y=>Y.trackBillPayMagicLinkPageLoad(o??"",i??"",O,l??"",Je(n.pathname),Q,Z))(u)}),a.jsxs(Ve,{windowSize:b,children:[b!=="small"?a.jsx(Ke,{onClick:H}):null,a.jsx(He,{windowSize:b,isAddressPage:V,children:P==="In-Progress"?a.jsx(ye,{size:"ExtraLarge",start:!0}):a.jsx(We,{file:q,type:"bill"})}),a.jsx(_e,{windowSize:b,children:e})]})]})}const Je=e=>`${e.split("/").at(-2)}_${e.split("/").at(-1)}`;function Ue(){return a.jsx(je,{})}function da(){return a.jsxs(ne,{children:[a.jsx(p,{path:"bank/account/save/success",element:a.jsx(Ue,{})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/ach/standard",element:a.jsx(h,{appContent:a.jsx(T,{})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/ach/same-day",element:a.jsx(h,{appContent:a.jsx(T,{})})}),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(Me,{})})}),a.jsx(p,{path:"*",element:a.jsx(f,{})})]})}export{da as default};
@@ -0,0 +1,12 @@
1
+ import{j as g}from"./liveblocks-BY1qt3Nf.js";import{a as u}from"./sentry-xWYlrqHr.js";import{u as O,g as _,h as w,t as A,j as l,N as L}from"./core-DFhvjgE1.js";import{z as r,E as M,G as P,T as V,k as N,U as G,_ as R,$,X as B}from"./index-Cp-pyxoH.js";import{fB as W,Tb as X,TE as q,Tv as H,ge as J,gg as K,TA as Q,gR as Y,df as Z,TF as ee,TG as te}from"./zeni-epic-state-DxmmAR38.js";import{n as ne}from"./mui-DesXezzU.js";import{u as se}from"./useDeviceId-BklKiHEX.js";import{f as ae}from"./analyticsHelper-DA7cdp8W.js";import{t as ie}from"./getLocaleForTenant-mARGfLdD.js";import"./recharts-Co89o1ZO.js";import"./analytics-CsVp7bfq.js";import"./plaid---yWAm21.js";import"./dnd-CR945ANw.js";import"./stripe-cKAAJElX.js";import"./lottie-DgdF8254.js";import"./lexical-CCIwPSwQ.js";import"./pdf-BVKoD2Fp.js";import"./utils-18zApAFM.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]="16031b3e-ce32-4484-891c-6c924a086300",t._sentryDebugIdIdentifier="sentry-dbid-16031b3e-ce32-4484-891c-6c924a086300")}catch{}})();const C=(t,a)=>t!=null&&t.length>0&&a==="magic_links";function Ce(){const t=O(),a=_(),f=w(),[y]=A(),n=y.get("token"),p=y.get("stytch_token_type"),m=r.getMagicLinkCodeVerifier(),i=se(),{otpChallenge:d,twoFAPhoneNumber:E,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=>W(e))),k=l((e=>X(e))),D=r.getSignedInUser(),T=M().mode;u.useEffect((()=>{s?.zeniSessionId==null&&n!=null&&C(n,p)&&i!=null&&m!=null&&(r.saveMagicLinkTriggered(n),t(q(n,i,m)))}),[n,p,t,i,m,s?.zeniSessionId]),u.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(H(k.tenantsInOrder),s.zeniSessionId),J(s.userId,s.zeniSessionId,o.tenantId),t(K(o.tenantId)),r.saveActiveTenantDomainForUser(o.tenantEmailDomain),t(Q("Completed")),P.updateAppLocaleID(ie(o)),ae(s,o,T,void 0,k.tenantsInOrder),Y().then((()=>{const e=B();e!=null&&V(e)})),setTimeout((()=>{N.trackLogin(G.Event.loginSuccess,"email",Z(o.productSettings))}),2e3))}),[I,S,b,s,o,k,T,a.state,t]);const F=u.useCallback((()=>{f("/signin/auth")}),[f]),U=u.useCallback((()=>{i!=null&&d!=null&&c!=null&&t(ee(i,c,d))}),[i,d,t,c]),j=u.useCallback((e=>{i!=null&&n!=null&&c!=null&&d!=null&&t(te(e,i,c,d))}),[i,n,t,c,d]);if(h==="Completed"&&d!=null)return g.jsx(R,{phoneNumber:E,verifyOtpFetchState:x.fetchState,resendVerifyDeviceOTPFetchState:z,onResendOtp:U,onVerifyOtp:j,onCancelVerifyDevice:F});if(I==="In-Progress"&&S==="Completed"&&s?.zeniSessionId!=null&&o!=null||D!=null){const e=a.state?.origin??"/";return g.jsx(L,{to:e,state:{...a.state,origin:""}})}if(!C(n,p)||m==null||h==="Error"){const e=a.state?.origin??"/",v=n!=null&&r.getLastUsedMagicLinkToken()===n;return g.jsx(L,{to:e,state:{...a.state,origin:"",magicLinkAlreadyUsed:v,magicLinkExpired:!v&&(r.isMagicLinkTriggered(n??"")||h==="Error"&&s?.zeniSessionId==null)}})}return g.jsx(oe,{"data-testid":"smooth-loader",children:g.jsx($,{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{Ce as default};