@zeniai/web-app-ui 5.3.92-qa → 5.3.93-dev

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/dist/assets/{AccountMappingScreen-DzaKUFSm.js → AccountMappingScreen-BTR8uKQK.js} +2 -2
  2. package/dist/assets/{ActualMatchingMatchDetailScreen-BjfIrL3i.js → ActualMatchingMatchDetailScreen-DpaCOnCM.js} +1 -1
  3. package/dist/assets/AddressRoutes-GFLqbgTr.js +1 -0
  4. package/dist/assets/AddressScreen-DWZzKMEw.js +9 -0
  5. package/dist/assets/AiCfoScreen-Dd__YIWm.js +22 -0
  6. package/dist/assets/{AppDrawer-Cs7TZZXA.js → AppDrawer-D2Tl26uq.js} +1 -1
  7. package/dist/assets/{BillPayApprovalRoutes-QOJ-pIsv.js → BillPayApprovalRoutes-DV_p_SQ2.js} +1 -1
  8. package/dist/assets/{BillPayRoutes-Ds5ptY4o.js → BillPayRoutes-sNvDS-kN.js} +6 -6
  9. package/dist/assets/{BusinessVerificationPageScreen-mTzkg86O.js → BusinessVerificationPageScreen-CVijkaE8.js} +2 -2
  10. package/dist/assets/{CardsAiCfoScreen-BFglNhAZ.js → CardsAiCfoScreen-DO_HCVwI.js} +1 -1
  11. package/dist/assets/{ChargeCardRoutes-CQB-2ARh.js → ChargeCardRoutes-mt2g3Jg0.js} +1 -1
  12. package/dist/assets/CompanyPassportScreen-_f68duti.js +1 -0
  13. package/dist/assets/{ConnectionAuthScreen-Cv5k_T0m.js → ConnectionAuthScreen-oPVi82Cx.js} +2 -2
  14. package/dist/assets/CustomerOnboardingAuthScreen-C3FMpb4J.js +1 -0
  15. package/dist/assets/{CustomerOnboardingRoutes-D81_0duE.js → CustomerOnboardingRoutes-BLRE7IK-.js} +3 -3
  16. package/dist/assets/{DashboardRoutes-DQp1_htT.js → DashboardRoutes-mQvE4jJ0.js} +3 -3
  17. package/dist/assets/{DefaultTenantHome-DCvwRsZt.js → DefaultTenantHome-Dh5bAcpG.js} +1 -1
  18. package/dist/assets/DomesticWireDetailScreen-pkS3AD2d.js +18 -0
  19. package/dist/assets/{DrawerScreen-B2norkbn.js → DrawerScreen-DI4gxsFO.js} +1 -1
  20. package/dist/assets/EntityDetailRoutes-BH8_jvsw.js +1 -0
  21. package/dist/assets/{ExpenseAutomationRoutes-B6EAqro0.js → ExpenseAutomationRoutes-_6qCRlW0.js} +7 -7
  22. package/dist/assets/FeaturePreviewScreen-kue3YUvW.js +1 -0
  23. package/dist/assets/{HubSpotOAuthCallbackScreen-DaHtgtF9.js → HubSpotOAuthCallbackScreen-D64pI0iU.js} +1 -1
  24. package/dist/assets/{InboxNotificationsProvider-BS3jevbV.js → InboxNotificationsProvider-DrljtAmN.js} +1 -1
  25. package/dist/assets/{InvoicingRoutes-DkMix0rR.js → InvoicingRoutes-D6QJ-LnU.js} +1 -1
  26. package/dist/assets/{MagicLinkRoutes-D3v-8lNS.js → MagicLinkRoutes-DFwRCGOM.js} +20 -20
  27. package/dist/assets/MagicLinkSignInScreen-DaNmJtKR.js +12 -0
  28. package/dist/assets/MobileAppDrawer-D9iwyW6E.js +1 -0
  29. package/dist/assets/NotFoundScreen-DHpPkJUq.js +1 -0
  30. package/dist/assets/{NotificationRoutes-a5A0iN2X.js → NotificationRoutes-CNN0JO68.js} +1 -1
  31. package/dist/assets/{OAuthConsentScreen-D63uGlri.js → OAuthConsentScreen-CMQBCmUq.js} +1 -1
  32. package/dist/assets/{PandLWithForecastRoutes-w3e32aok.js → PandLWithForecastRoutes-BhMRDGc1.js} +1 -1
  33. package/dist/assets/{PaymentLinkScreen-1-nPsVVw.js → PaymentLinkScreen-DstzeuhJ.js} +9 -9
  34. package/dist/assets/{PeopleRoutes-CKIH3u6r.js → PeopleRoutes-6Eq28etR.js} +9 -9
  35. package/dist/assets/{PerformanceRoutes-BWuyjaEy.js → PerformanceRoutes-DkxGB8dS.js} +1 -1
  36. package/dist/assets/{Preview-BKLzLytN.js → Preview-Dfugi26f.js} +1 -1
  37. package/dist/assets/{QBOConnectionScreen-bFEzMEIk.js → QBOConnectionScreen-DNwlxY3R.js} +1 -1
  38. package/dist/assets/ReimbursementApprovalRoutes-CzKIB6lB.js +1 -0
  39. package/dist/assets/{ReimbursementApprovalRuleDetailScreen-B64E_E-d.js → ReimbursementApprovalRuleDetailScreen-C0oxxTC0.js} +1 -1
  40. package/dist/assets/{ReimbursementRoutes-BvuoOPQd.js → ReimbursementRoutes-C2uBm8Jr.js} +7 -7
  41. package/dist/assets/{ReportsRoutes-DoO3hdWb.js → ReportsRoutes-CmRsRF1m.js} +1 -1
  42. package/dist/assets/RewardsRoutes-cYws_8FH.js +1 -0
  43. package/dist/assets/{ScheduleDetailsPrepaidExpensesScreen-D6W5dMVV.js → ScheduleDetailsPrepaidExpensesScreen-DKDzHrf0.js} +5 -5
  44. package/dist/assets/ScreenRoutes-Cd2fvUao.js +2 -0
  45. package/dist/assets/{SettingsRoutes-CvCbpSrb.js → SettingsRoutes-DBJKrFxG.js} +6 -6
  46. package/dist/assets/{SetupPagesScreen-CJavjOcL.js → SetupPagesScreen-C70xRnVo.js} +1 -1
  47. package/dist/assets/SignInScreen-DB64sQry.js +1 -0
  48. package/dist/assets/SignOutScreen-RkBhfYpP.js +9 -0
  49. package/dist/assets/TaskListScreen-DW7e6ef_.js +9 -0
  50. package/dist/assets/{TaskRoutes-BiKmO-hs.js → TaskRoutes-BRKcMi_T.js} +2 -2
  51. package/dist/assets/TransactionDetailRoutes-BFBaFYFk.js +1 -0
  52. package/dist/assets/{TransactionDetailScreen-Bqs4Kci_.js → TransactionDetailScreen-DPKP2gGJ.js} +2 -2
  53. package/dist/assets/{TransactionListRoutes-D8Sek6_m.js → TransactionListRoutes-CDs1-rA6.js} +1 -1
  54. package/dist/assets/{TreasuryRoutes-CwbBMAQd.js → TreasuryRoutes-BbsVM2lE.js} +1 -1
  55. package/dist/assets/{VendorsRoutes-DsSf7vck.js → VendorsRoutes-B18gUSfI.js} +1 -1
  56. package/dist/assets/{WiseConfirmationScreen-CCeT1ONM.js → WiseConfirmationScreen-CMKnfyei.js} +1 -1
  57. package/dist/assets/{ZeniAccountRoutes-B45B2_r8.js → ZeniAccountRoutes-CWU7HNHh.js} +9 -9
  58. package/dist/assets/{ZeniAccountStatementScreen-CJwspdGU.js → ZeniAccountStatementScreen-BcWZ9nqz.js} +1 -1
  59. package/dist/assets/{accountMappingHelper-Bfnz2zpL.js → accountMappingHelper-PEq3iFwb.js} +1 -1
  60. package/dist/assets/{analytics-Cf42-eLX.js → analytics-wUVBNE2n.js} +1 -1
  61. package/dist/assets/{analyticsHelper-CSArgrxe.js → analyticsHelper-C8wUoU5C.js} +1 -1
  62. package/dist/assets/{core-BqvURhsI.js → core-DtSa7_zJ.js} +1 -1
  63. package/dist/assets/{decodeURIComponentSafe-B1hZa76R.js → decodeURIComponentSafe-CxfS79yY.js} +1 -1
  64. package/dist/assets/{dnd-_c-IyjNm.js → dnd-BRHUZ8LO.js} +1 -1
  65. package/dist/assets/{empty-LUvrL5FY.js → empty--RCTsu0x.js} +1 -1
  66. package/dist/assets/{empty-BKR4GGax.js → empty-TXY6nS9o.js} +1 -1
  67. package/dist/assets/{emptyVideoElement-BJ035AVv.js → emptyVideoElement-jsNpgByF.js} +1 -1
  68. package/dist/assets/{epic-DrlhLZYQ.js → epic-NcSj2eco.js} +1 -1
  69. package/dist/assets/{expenseAutomationHelper-DowMWMz9.js → expenseAutomationHelper-BUiYzGxA.js} +1 -1
  70. package/dist/assets/{getLocaleForTenant-Djy8DXCn.js → getLocaleForTenant-D03DEBIE.js} +1 -1
  71. package/dist/assets/{index-ZhvTTZJ8.js → index-BfiunY7r.js} +1 -1
  72. package/dist/assets/{index-BGV6srOZ.js → index-Bfr7Ew4h.js} +1 -1
  73. package/dist/assets/{index-CGxso4kb.js → index-BgQKS1TL.js} +1 -1
  74. package/dist/assets/{index-BxbV4xNq.js → index-CABDWa_r.js} +2 -2
  75. package/dist/assets/{index-tkcziiFe.js → index-CJhgQFRI.js} +13423 -13425
  76. package/dist/assets/{index-30fNmyq6.js → index-CeI_n1Jv.js} +1 -1
  77. package/dist/assets/{index-Bolx2cRY.js → index-Cz1UMaoE.js} +1 -1
  78. package/dist/assets/{index--c44Imtf.js → index-DxlUZLeR.js} +1 -1
  79. package/dist/assets/{lexical-DOFKMtgG.js → lexical-CV0PpHfb.js} +1 -1
  80. package/dist/assets/{liveblocks-DALtO6SV.js → liveblocks-CZZ7TQJf.js} +1 -1
  81. package/dist/assets/{lottie-Cl-fmeYA.js → lottie-_8fQYf62.js} +1 -1
  82. package/dist/assets/{mui-DSj4M999.js → mui-hHF2bYsV.js} +1 -1
  83. package/dist/assets/{pathToGoBack-wPZAGkF4.js → pathToGoBack-sBV6PqT4.js} +1 -1
  84. package/dist/assets/{pdf-CFPsQLlu.js → pdf-DcTPEGUQ.js} +3 -3
  85. package/dist/assets/{pdf-lib-CIxi_5DP.js → pdf-lib-DvlP1tZv.js} +1 -1
  86. package/dist/assets/{plaid-D9ebNRn2.js → plaid-l93gkere.js} +1 -1
  87. package/dist/assets/{pusher-5CwADSV9.js → pusher-Chl1DxG2.js} +1 -1
  88. package/dist/assets/{react-qChTbEdN.js → react-B6u5wAGC.js} +1 -1
  89. package/dist/assets/{react-BRdMEoki.js → react-BPJWvFAw.js} +1 -1
  90. package/dist/assets/{react-Dq2mldFo.js → react-BXuuk3m7.js} +1 -1
  91. package/dist/assets/{react-CGWQVVRQ.js → react-Ct10qt1E.js} +1 -1
  92. package/dist/assets/{react-Cq8Ib3UV.js → react-DvOc8dL3.js} +1 -1
  93. package/dist/assets/{react-Dy48Rpd-.js → react-UkV3Bwgo.js} +1 -1
  94. package/dist/assets/{recharts-BMVG1gQz.js → recharts-DHYb1iJa.js} +1 -1
  95. package/dist/assets/{routePaths-BjzJG6XW.js → routePaths-66PPW-xS.js} +1 -1
  96. package/dist/assets/{sentry-CWf72ffv.js → sentry-7oL5NFUY.js} +1 -1
  97. package/dist/assets/{stripSplatSuffix-DXHVmpGI.js → stripSplatSuffix-Cj4hZLSk.js} +1 -1
  98. package/dist/assets/{url-B8MZkCoD.js → url-AXfPza2U.js} +1 -1
  99. package/dist/assets/{url-DHtqGfZ7.js → url-yW-1Hcty.js} +1 -1
  100. package/dist/assets/{useActualMatchingMatchDetail-Qibc6TG4.js → useActualMatchingMatchDetail-Bv7_wq27.js} +1 -1
  101. package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-NdMsbltO.js → useAiCfoDashboardSuggestedQuestionsChips-B0543FEo.js} +1 -1
  102. package/dist/assets/useAskAiCfoHostNavButtonProps-C0sjuZuZ.js +1 -0
  103. package/dist/assets/{useChargeCardPusherEvents-CJQSDbRy.js → useChargeCardPusherEvents-DLwmfLZC.js} +1 -1
  104. package/dist/assets/{useDeviceId-rWDIGh8Q.js → useDeviceId-DpOlnzI_.js} +1 -1
  105. package/dist/assets/{useEmailConnectResultRefresh-vD6sM0GC.js → useEmailConnectResultRefresh-DWBnl6oa.js} +1 -1
  106. package/dist/assets/{useInitialThreadRequest-DpcFEC8O.js → useInitialThreadRequest-Cf6qZ2C0.js} +1 -1
  107. package/dist/assets/useTaskManagerAccess-zRd8th0q.js +1 -0
  108. package/dist/assets/{useTaskManagerPusherEvents-C0Cn-LDD.js → useTaskManagerPusherEvents-CtTv0DPD.js} +1 -1
  109. package/dist/assets/{utils-1PeqdCv6.js → utils-D3PNq8pk.js} +1 -1
  110. package/dist/assets/{withTransactionSidePanel-tQ0C9myG.js → withTransactionSidePanel-DVXJCqK3.js} +1 -1
  111. package/dist/assets/{zeni-epic-state-_CRDfrCw.js → zeni-epic-state-DIQk-W8f.js} +3 -3
  112. package/dist/index.html +1 -1
  113. package/package.json +2 -2
  114. package/dist/assets/AddressRoutes-BV7Rst9R.js +0 -1
  115. package/dist/assets/AddressScreen-CZzU7Yh0.js +0 -9
  116. package/dist/assets/AiCfoScreen-BFZAUa9A.js +0 -22
  117. package/dist/assets/CompanyPassportScreen-CSQ3VkCy.js +0 -1
  118. package/dist/assets/CustomerOnboardingAuthScreen-Bf69aRbu.js +0 -1
  119. package/dist/assets/DomesticWireDetailScreen-BR5XWG_Y.js +0 -18
  120. package/dist/assets/EntityDetailRoutes-CIllCXHp.js +0 -1
  121. package/dist/assets/FeaturePreviewScreen-tcOuJ_S6.js +0 -1
  122. package/dist/assets/MagicLinkSignInScreen-DRQ7g0CK.js +0 -12
  123. package/dist/assets/MobileAppDrawer-_PNTdcvf.js +0 -1
  124. package/dist/assets/NotFoundScreen-CM2NXlhe.js +0 -1
  125. package/dist/assets/ReimbursementApprovalRoutes-u28kfRZl.js +0 -1
  126. package/dist/assets/RewardsRoutes-DXJLwvZU.js +0 -1
  127. package/dist/assets/ScreenRoutes-BqRhONQ5.js +0 -2
  128. package/dist/assets/SignInScreen-D8kGqFET.js +0 -1
  129. package/dist/assets/SignOutScreen-WRT_UIqE.js +0 -9
  130. package/dist/assets/TaskListScreen-DBI4QvUz.js +0 -9
  131. package/dist/assets/TransactionDetailRoutes-ixw2MpuC.js +0 -1
  132. package/dist/assets/useAskAiCfoHostNavButtonProps-BtUsWnxf.js +0 -1
  133. package/dist/assets/useTaskManagerAccess-BtX9AiFh.js +0 -1
@@ -1,3 +1,3 @@
1
- import{j as c}from"./liveblocks-DALtO6SV.js";import{a as r}from"./sentry-CWf72ffv.js";import{u as L,h as P,i as w,j as k,t as Z,l as T,s as Q,g as X,N as H,n as ce,o as x}from"./core-BqvURhsI.js";import{a6 as ct,j as g,ao as F,N as l,ca as st,cb as rt,cc as dt,cd as lt,ce as ut,cf as gt,cg as mt,ch as vt,ci as pt,cj as St,ck as ft,cl as It,p as ee,cm as ht,cn as Ct,z as J,ac as de,co as kt,cp as Et,cq as yt,cr as bt,cs as xt,ct as At,cu as Dt,cv as jt,cw as Lt,cx as Pt,V as _t,ag as un,cy as $t,cz as wt,cA as Rt,cB as Ft,cC as Ot,cD as Tt,cE as Mt,cF as Nt,cG as Ut,cH as Bt,cI as Vt,t as Je,h as Me,cJ as Ht,cK as qt,cL as Qt,cM as zt,cN as Kt,cO as Gt,cP as Wt}from"./index-tkcziiFe.js";import"./mui-DSj4M999.js";import{A as G}from"./AddressScreen-CZzU7Yh0.js";import M from"./NotFoundScreen-CM2NXlhe.js";import{_g as Yt,_h as Jt,vw as Ze,v as Zt,_i as W,w6 as le,_j as Ne,_k as ue,wJ as Pe,wQ as Xt,dX as gn,wU as mn,_l as Ue,wN as ei,yr as Xe,w5 as en,_m as vn,x3 as _e,_n as ge,x7 as ni,_o as ti,xh as ii,_p as pn,xa as Sn,y$ as oi,_q as fe,_r as nn,_s as fn,w2 as ai,_t as ci,vW as si,_u as ri,yE as di,_v as In,yN as ye,_w as li,yK as ui,_x as Be,gk as Ve,_y as oe,_z as ae,xp as gi,wb as tn,wg as hn,we as mi,w8 as vi,xi as pi,wi as Si,xr as fi,c_ as Cn,_A as $e,xA as kn,xy as Ie,xw as me,xv as Ii,_B as En,yU as be,_C as hi,w4 as yn,_D as He,fI as he,wr as we,wo as Re,wB as bn,wA as qe,wl as Ci,wu as xn,wD as se,W1 as An,w7 as Qe,wy as ki,wz as Ei,wx as yi,_E as bi,x8 as xi,x4 as Dn,_F as jn,vN as xe,_G as Ai,vG as Di,_H as ji,y_ as Li,z3 as z,yZ as Pi,y5 as Ce,_I as _i,_J as Ln,zc as Ae,_K as $i,z9 as wi,_L as Pn,y8 as Ri,y9 as q,yc as Fi,_M as _n,ym as De,_N as Oi,xq as $n,Uz as wn,_O as Ti,yw as Mi,_P as Rn,_Q as Ni,_R as Ui,_S as Bi,z$ as Vi,_T as Hi,_U as Fn,zj as On,_V as Tn,zZ as je,_W as qi,zW as Qi,_X as zi,_Y as Ki,_Z as Gi,__ as Wi,_$ as Yi,$0 as on,$1 as Ji,ei as Zi,A3 as Xi,$2 as ze,xK as eo,xF as no,d0 as Fe,$3 as Y,xO as Mn,xU as Nn,$4 as Un,xP as ve,xZ as to,y0 as Bn,$5 as io,xY as oo,$6 as Vn,$7 as Hn,zO as Le,zJ as ao,$8 as co,zo as so,$9 as ro,zP as lo,zT as uo,$a as Ke,wL as qn,zA as go,wM as mo,$b as vo,$c as Qn,c9 as po,mw as So,mx as fo,$d as an,wK as pe,go as Io,mD as ho,zG as zn,Af as Co,zD as Kn,v2 as ko,uS as Eo,hW as yo,V0 as cn,V1 as bo,GB as Gn,Ac as xo,hO as Ao,A9 as Do,$e as jo,$f as Lo,Al as Po,Ak as _o,$g as $o,$h as Wn,Ai as wo,$i as Ro,$j as Fo,yA as Oo,$k as To}from"./zeni-epic-state-_CRDfrCw.js";import{M as Mo}from"./MobileAppDrawer-_PNTdcvf.js";import{q as Se}from"./QBOConnectionScreen-bFEzMEIk.js";import"./recharts-BMVG1gQz.js";import"./analytics-Cf42-eLX.js";import"./plaid-D9ebNRn2.js";import"./dnd-_c-IyjNm.js";import"./stripe-cKAAJElX.js";import"./lottie-Cl-fmeYA.js";import"./lexical-DOFKMtgG.js";import"./pdf-CFPsQLlu.js";import"./utils-1PeqdCv6.js";import"./InboxNotificationsProvider-BS3jevbV.js";import"./useTaskManagerAccess-BtX9AiFh.js";import"./empty-LUvrL5FY.js";import"./pdf-lib-CIxi_5DP.js";import"./index--c44Imtf.js";import"./url-DHtqGfZ7.js";import"./index-Bolx2cRY.js";import"./decodeURIComponentSafe-B1hZa76R.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="13129495-891a-410e-9c2f-7c0914051e61",t._sentryDebugIdIdentifier="sentry-dbid-13129495-891a-410e-9c2f-7c0914051e61")}catch{}})();const $=({event:t,isReady:e=!0})=>e?c.jsx(ct,{analytics:g,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function No(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,S]=r.useState(null),m=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),{fetchState:v,hasMore:p,items:f,nextCursor:I,auditLogEntityRouteOptions:E,auditLogListSortFieldOptions:h}=k(Yt),y=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),D=`/${n??""}/invoicing`,b=r.useCallback(((R,U)=>{const O=Jt(D,R,U,E);O!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{entity:R,entityId:U,fromScreen:"audit_log",toScreen:R}),e(O))}),[E,e,D]);r.useEffect((()=>{const R=setTimeout((()=>u(a)),300);return()=>clearTimeout(R)}),[a]),r.useEffect((()=>{i&&t(Ze({filters:y,keepExistingListItems:!1,sort:m}))}),[i,y,m,t]);const A=v==="Not-Started"||v==="In-Progress"&&f.length===0,C=v==="In-Progress"&&f.length>0,j=v==="Completed";return N(v)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingAuditLogPage,isReady:j}),c.jsx(st,{auditLogEntityRouteOptions:E,auditLogListSortFieldOptions:h,entries:f,hasMore:p,isLoading:A,isLoadingMore:C,searchValue:a,sortState:d,onEntityLinkClick:b,onLoadMore:()=>{p&&I!=null&&t(Ze({cursor:I,filters:y,keepExistingListItems:!0,sort:m}))},onSearchChange:o,onSortChange:S})]})}const Yn=["company","email","firstName","invoiceNotes","lastName","notes","phone","vatNumber"],Oe=t=>typeof t=="string"||typeof t=="number"||typeof t=="boolean"?t:Array.isArray(t)?t.map(Oe):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).map((([e,n])=>[e,Oe(n)]))):null;function B(t,e,n=[]){const i=t,a=e,o=[...new Set([...Object.keys(i),...Object.keys(a??{})])].filter((u=>{if(a==null)return(d=i[u])!=null&&d!==""&&(Array.isArray(d)?d.length>0:typeof d!="object"||Object.keys(d).length>0);var d;return!(i[u]==null&&a[u]==null)&&!Zt(i[u],a[u])})).sort(),s=Object.fromEntries(o.filter((u=>!n.includes(u))).map((u=>[u,Oe(i[u])])));return{fieldsChanged:o,formValues:s}}function ke(t,e=!1){const n=L(),i=k((s=>W(s).productNextCursor!=null)),a=k((s=>W(s).productNextCursor)),o=k((s=>W(s).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&o!=="Not-Started"||n(le({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&o!=="In-Progress"&&i&&a!=null&&n(le({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,o,i,a])}function ne(t,e,n,i){const[a,o]=r.useState(0),[s,u]=r.useState(!1),d=r.useRef(t);return r.useEffect((()=>{const S=d.current==="In-Progress";d.current=t,t==="Completed"&&S&&n!=null&&(u(!0),i(n))}),[t,n,i]),r.useEffect((()=>{s&&!e&&(u(!1),o((S=>S+1)))}),[s,e]),a}const Uo=new Set(["plan"]),Bo=T((function(t,e){const{view:n}=e;return{applicableItemOptions:n.applicableItemOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboClassHierarchy:n.qboClassHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:n.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",itemId:e.itemId,localData:n.localData,plan:n.plan}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${n}/catalog`),onLifecycleAction:i!==""?a=>{i!==""&&(g.trackInvoicingActionClick(l.Event.invoicingCatalogItemLifecycleAction,{action:a,fromScreen:"catalog_item_detail",itemId:i}),t(ei({action:a,id:i})))}:void 0,onEditChange:a=>{i!==""&&t(Ue({id:i,localData:a}))},onSaveEdit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemEdited,{itemId:i,mode:"edit",...B(e.view.localData,gn(e.view.plan))}),t(mn({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&t(Xt({action:o,id:a,parentItemId:i}))}}}))(rt);function Vo(){const t=L(),e=P(),{item_id:n,tenantEmailDomain:i}=w(),[a]=Z(),{areTenantIdsInSync:o}=F(),s=(u=a.get("kind"))!=null&&Uo.has(u)?u:"plan";var u;const d=k((y=>Ne(y,n))),{pageFetchState:S}=d,m=S.fetchState;r.useEffect((()=>(t(ue({id:n})),()=>{t(ue({id:n}))})),[t,n]),r.useEffect((()=>{o&&t(Pe({id:n,kind:s}))}),[o,n,s,t]);const v=r.useCallback((y=>t(Pe({cacheOverride:!0,id:y,kind:s}))),[t,s]),p=ne(d.fetchState,d.isFormLoading,n,v),f=m==="Completed"&&!d.isFormLoading;ke(o,!0);const[I,E]=r.useState(f?n:void 0);r.useEffect((()=>{n!=null&&f&&E(n)}),[n,f]);const h=I!==n&&(m==="Not-Started"||m==="In-Progress"||d.isFormLoading);return N(m)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCatalogItemDetailPage,isReady:f}),c.jsx(Bo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:s,isLoading:h,view:d},p)]})}const Ho=new Set(["addon","charge","plan"]),qo=new Set(["plan"]),Qo=T((function(t,e){const n=Ne(t,e.itemId);return{fieldHelp:n.fieldHelp,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,applicabilityValues:n.applicabilityValues,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,applicableItemOptions:n.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save catalog item.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedItem:n.plan,pricingModelValues:n.pricingModelValues,prorationValues:n.prorationValues,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,tierTypeValues:n.tierTypeValues}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e,a=i!=null?`${n}/catalog/${encodeURIComponent(i)}`:`${n}/catalog`;return{onBack:()=>e.navigate(a),onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemFormCancelled),t(ue({id:i})),e.navigate(`${n}/catalog`)},onChange:o=>{t(Ue({id:i,localData:o}))},onSubmit:()=>{t(mn({id:i}))}}}),(function({savedItem:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemSaved,{itemId:i.itemId,mode:e.mode,...B(e.localData,t!=null?gn(t):void 0)}),n.onSubmit()}}}))(dt);function zo(){const t=L(),e=P(),{item_id:n,tenantEmailDomain:i}=w(),[a]=Z(),{areTenantIdsInSync:o}=F(),s=n!=null,u=a.get("type"),d=u!=null&&Ho.has(u)?u:void 0,S=(m=a.get("kind"))!=null&&qo.has(m)?m:"plan";var m;const v=k((p=>Ne(p,n)));return ke(o,!0),r.useEffect((()=>{o&&t(Pe({id:n,kind:S}))}),[o,n,S,t]),r.useEffect((()=>{s||d==null||v.localData.catalogType===d||t(Ue({localData:{...v.localData,catalogType:d}}))}),[s,d,v.localData?.catalogType,t]),r.useEffect((()=>{if(v.fetchState==="Completed"){const p=v.savedItemId??n,f=p!=null?`/${i}/invoicing/catalog/${encodeURIComponent(p)}`:`/${i}/invoicing/catalog`;e(f),t(ue({id:n}))}}),[v.fetchState,v.savedItemId,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCatalogItemFormPage}),c.jsx(Qo,{navigate:e,tenantEmailDomain:i,defaultType:d,isEdit:s,itemId:n})]})}const Ko={addons:"addon",all:"item",charges:"charge",plans:"plan"},Go=T((function(t,e){const n=W(t),i=e.activeTab==="plans",a=e.activeTab==="all",o=i?n.plans:a?[...n.plans,...n.products]:n.products,s=i||a&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:a&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:s==="Not-Started"||s==="In-Progress"&&o.length===0,isLoadingMore:s==="In-Progress"&&o.length>0,planRows:n.planRows,productRows:n.productRows}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",a=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const s=Ko[e.activeTab];g.trackInvoicingActionClick(l.Event.invoicingAddCatalogItemClicked,{itemType:s}),e.navigate(`${n}/catalog/new?type=${s}`)},onItemClick:(s,u)=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemRowClicked,{itemId:u}),e.navigate(`${n}/catalog/${encodeURIComponent(u)}`)},onLoadMore:()=>{if(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"catalog",tab:e.activeTab}),a)return e.planNextCursor!=null&&t(en({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&t(le({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));o!=null&&t(i?en({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):le({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(lt);function Wo(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState("plans"),[d,S]=r.useState(""),[m,v]=r.useState(null),p=r.useMemo((()=>m!=null?{dir:m.direction,field:m.columnKey}:void 0),[m]),f=d.trim()!==""?d.trim():void 0,I=r.useMemo((()=>({search:f,type:"plan"})),[f]),E=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),h=k((j=>W(j))),y=h.planFilters.search,D=h.planSort,b=h.planNextCursor,A=h.productNextCursor,C=h.fetchState==="Completed";return r.useEffect((()=>{const j=setTimeout((()=>S(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t(Xe({cacheOverride:!1,planFilters:I,productFilters:E,planSort:p,productSort:p}))}),[i,t,I,E,p]),r.useEffect((()=>{i&&(f!==y||p?.field!==D?.field||p?.dir!==D?.dir)&&t(Xe({cacheOverride:!0,planFilters:I,productFilters:E,planSort:p,productSort:p}))}),[y,D,i,t,I,E,f,p]),N(h.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCatalogPage,isReady:C}),c.jsx(Go,{navigate:e,tenantEmailDomain:n,activeTab:s,searchValue:a,sortState:m,planFilters:I,productFilters:E,sort:p,planNextCursor:b,productNextCursor:A,onSearchChange:o,onTabChange:u,onSortChange:v})]})}const Yo=T((function(t,e){const n=vn(t,e.couponId);return{fieldHelp:n.fieldHelp,applyOnOptions:n.applyOnOptions,discountTypeOptions:n.discountTypeOptions,durationTypeOptions:n.durationTypeOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save coupon.":void 0,isQboConnected:n.isQboConnected,isQboPickerDataLoading:n.isQboPickerDataLoading,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedCoupon:n.coupon,periodUnitOptions:n.periodUnitOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,a=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>e.navigate(a),onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCouponFormCancelled),t(ge({id:i})),e.navigate(`${n}/discounts`)},onChange:o=>{t(ti({id:i,localData:o}))},onSubmit:()=>{t(ni({id:i}))}}}),(function({savedCoupon:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCouponSaved,{couponId:i.couponId,mode:e.mode,...B(e.localData,t!=null?ii(t):void 0)}),n.onSubmit()}}}))(ut);function Jo(){const t=L(),e=P(),{coupon_id:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),{fetchState:o,savedCouponId:s}=k((u=>vn(u,n)));return r.useEffect((()=>{a&&t(_e({id:n}))}),[a,n,t]),r.useEffect((()=>{if(o==="Completed"){const u=s??n,d=u!=null?`/${i}/invoicing/discounts/${encodeURIComponent(u)}`:`/${i}/invoicing/discounts`;e(d),t(ge({id:n}))}}),[o,s,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCouponFormPage}),c.jsx(Yo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Zo=T((function(t){const e=pn(t);return{fieldHelp:e.fieldHelp,customers:e.customers,planNames:e.planNames,errorMessage:e.fetchState==="Error"?e.error?.message??"Failed to create invoice. Please try again.":void 0,isSubmitting:e.fetchState==="In-Progress",localData:e.localData,settings:e.settings}}),(function(t){return{dispatch:t}}),(function(t,{dispatch:e},n){const i=`/${n.tenantEmailDomain}/invoicing`;return{...t,onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:a=>{e(fn(a))},onSubmit:()=>{const a=ci(t.localData);g.trackInvoicingActionClick(l.Event.invoicingInvoiceCreated,{customerId:a.customer_id,lineItemCount:a.line_items?.length,mode:"create",...B(t.localData,void 0,["memo"])}),e(si(a))}}}))(mt);function Xo(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),[i]=Z(),{areTenantIdsInSync:a}=F(),o=i.get("customerId"),s=k((b=>pn(b))),u=s.fetchState,d=s.localData,S=s.savedInvoiceId,m=k(Sn),v=k((b=>oi(b))),p=k(fe),f=v.fetchState==="Not-Started"||v.fetchState==="In-Progress"&&m==null,I=p.fetchState==="Not-Started"||p.fetchState==="In-Progress"&&p.customers.length===0,E=f||I,h=v.fetchState==="Completed"&&p.fetchState==="Completed";r.useEffect((()=>(t(nn()),()=>{t(nn())})),[t]);const y=r.useRef(!1);r.useEffect((()=>{y.current||o==null||o===""||d.customerId!==""||(y.current=!0,t(fn({...d,customerId:o})))}),[o,d,t]),r.useEffect((()=>{a&&t(ai({cacheOverride:!1}))}),[a,t]);const D=r.useRef(u);return r.useEffect((()=>{const b=D.current;if(D.current=u,b!=="Completed"&&u==="Completed"){const A=S!=null?`/${n}/invoicing/invoices/${encodeURIComponent(S)}`:`/${n}/invoicing/invoices`;e(A)}}),[u,S,e,n]),c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCreateInvoicePage,isReady:h}),E?c.jsx(gt,{}):c.jsx(Zo,{navigate:e,tenantEmailDomain:n})]})}const ea=T((function(t,e){const{detailView:n}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:n.creditNote,creditNoteId:e.creditNoteId,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${n}/credits`),onCustomerClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(vt);function na(){const t=L(),e=P(),{credit_note_id:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),o=k((u=>ri(u,n??""))),s=o.fetchState==="Completed";return r.useEffect((()=>{a&&n!=null&&t(di({id:n}))}),[a,n,t]),N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCreditDetailPage,isReady:s}),c.jsx(ea,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:o})]})}const ta=T((function(t){const e=In(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",creditNotes:e.creditNotes,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.creditNotes.length===0,isLoadingMore:n==="In-Progress"&&e.creditNotes.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"credits",status:e.activeStatus}),t(ui({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(pt);function ia(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,S]=r.useState(null),m=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),v=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,creditNoteListFetchState:h}=k((D=>{const b=In(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,creditNoteListFetchState:b.fetchState}}),Q),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(ye({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(v.search!==f||m?.field!==I?.field||m?.dir!==I?.dir)&&t(ye({cacheOverride:!0,filters:v,sort:m}))}),[i,t,v,m,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCreditsListPage,isReady:y}),c.jsx(ta,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:d,filters:v,sort:m,nextCursor:E,onSearchChange:o,onStatusChange:D=>{t(li(D)),t(ye({cacheOverride:!1,filters:v,sort:m}))},onSortChange:S})]})}const Jn=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},oa=T((function(t,e){const{editView:n,hasLoadedRecord:i}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,hasUnsavedBillingAddress:n.hasUnsavedBillingAddress,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:!i&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),hasPaymentLinkEmailPreviewFailed:n.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:n.emailPreviewFetchState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",paymentLinkEmailPreview:n.emailPreview,isSendingPaymentLink:n.record.sendLinkState.fetchState==="In-Progress",localData:n.localData,paymentMethods:n.record.paymentMethods,sendPaymentLinkErrorMessage:n.record.sendLinkState.fetchState==="Error"?n.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:n.record.stripeConnected}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${n}/customers`),onChange:a=>{t($e({id:i,localData:a}))},onCreateInvoice:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onCreatePromotionalCredits:()=>{g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customer_detail"}),e.onCreatePromotionalCredits()},onNewSubscription:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`)},onDiscardEdit:()=>{t(Ie(me)),t(Ii({id:i}))},onOpenAddress:()=>{const a=Jn(e.tenantEmailDomain??"",me,i),o=ee(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:a=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerEdited,{customerId:i,mode:"edit",...B(a,e.editView.record.invoicingCustomer!=null?Cn(e.editView.record.invoicingCustomer):void 0,Yn)}),t($e({id:i,localData:a})),t(kn({id:i}))},onFetchPaymentLinkEmailPreview:a=>t(fi({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,s)=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentLinkSent,{customerId:i,fromScreen:"customer_detail"}),t(Si({body:s,customerId:i,email:a,subject:o}))},onSubscriptionClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)}}}))(It);function aa(){const t=L(),e=P(),n=X(),{customer_id:i,tenantEmailDomain:a}=w(),{areTenantIdsInSync:o}=F(),s=k((O=>Be(O,i))),u=s.pageFetchState.fetchState,d=u==="Completed"&&!s.isFormLoading,[S,m]=r.useState(!1),[v,p]=r.useState(!1),[f,I]=r.useState(d?i:void 0);r.useEffect((()=>{i!=null&&d&&I(i)}),[i,d]);const E=f===i,{plaidTokenFetchState:h,promotionalCreditSubmitState:y}=s,{paymentMethodSaveState:D,setupIntentFetchState:b,stripeConnected:A}=s.record,C=r.useRef(s.record.sendLinkState.fetchState);r.useEffect((()=>{const O=s.record.sendLinkState.fetchState;C.current!=="Error"&&O==="Error"&&t(Ve({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),C.current=O}),[t,s.record.sendLinkState.fetchState]);const j=b.fetchState==="Error"?b.error?.message??"Failed to start card setup.":D.fetchState==="Error"?D.error?.message??"Failed to save payment method.":h.fetchState==="Error"?h.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(t(oe()),t(ae()),()=>{t(oe()),t(ae())})),[t]),r.useEffect((()=>{n.state?.openPromotionalCreditsDialog===!0&&(p(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{o&&i!=null&&t(gi({id:i}))}),[o,i,t]),r.useEffect((()=>{o&&i!=null&&A&&t(tn({customerId:i}))}),[o,i,t,A]);const R=r.useCallback((O=>t(hn({id:O}))),[t]),U=ne(s.fetchState,s.isFormLoading,i,R);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCustomerDetailPage,isReady:d}),c.jsx(oa,{customerId:i??"",editView:s,hasLoadedRecord:E,location:n,navigate:e,tenantEmailDomain:a,onAddPaymentMethod:()=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentMethodAddClicked,{customerId:i??"",fromScreen:"customer_detail"}),t(oe()),i!=null&&A&&t(tn({customerId:i})),m(!0)},onCreatePromotionalCredits:()=>{t(ae()),p(!0)}},U),c.jsx(St,{errorMessage:j,isCreatingSetupIntent:b.fetchState==="In-Progress",isSaving:D.fetchState==="In-Progress",open:S,plaidLinkToken:s.record.plaidLinkToken,saveSucceeded:D.fetchState==="Completed",setupIntent:s.record.setupIntent,stripeConnected:A,onChooseCard:()=>{i!=null&&t(vi({customerId:i}))},onClose:()=>{m(!1),t(oe())},onSavePaymentMethod:O=>{i!=null&&(g.trackInvoicingActionClick(l.Event.invoicingPaymentMethodSaved,{customerId:i,fromScreen:"customer_detail"}),t(mi({customerId:i,data:O})))}}),c.jsx(ft,{currentBalance:s.record.invoicingCustomer?.promotionalCredits,currencyCode:s.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:y.fetchState==="Error"?y.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:y.fetchState==="In-Progress",open:v,submitSucceeded:y.fetchState==="Completed",onClose:()=>{p(!1),t(ae())},onSubmit:({amount:O,description:ie})=>{i!=null&&(g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsAdded,{amount:O,customerId:i,fromScreen:"customer_detail"}),t(pi({amount:O,customerId:i,currencyCode:s.record.invoicingCustomer?.preferredCurrencyCode,description:ie})))}})]})}const ca=T((function(t,e){const n=Be(t,e.customerId);return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save customer.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedCustomer:n.record.invoicingCustomer}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,a=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>e.navigate(a),onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerFormCancelled),t(En({id:i})),t(Ie(me)),e.navigate(`${n}/customers`)},onChange:o=>{t($e({id:i,localData:o}))},onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"customer",fromScreen:"customer_form"});const o=Jn(e.tenantEmailDomain??"",me,i),s=ee(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(o,{state:{pathnameStackToGoBack:s}})},onSubmit:()=>{t(kn({id:i}))}}}),(function({savedCustomer:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerSaved,{customerId:i.customerId,mode:e.mode,...B(e.localData,t!=null?Cn(t):void 0,Yn)}),n.onSubmit()}}}))(ht);function sa(){const t=L(),e=P(),n=X(),{customer_id:i,tenantEmailDomain:a}=w(),{areTenantIdsInSync:o}=F(),{fetchState:s,savedCustomerId:u}=k((d=>Be(d,i)));return r.useEffect((()=>{o&&i!=null&&t(hn({id:i}))}),[o,i,t]),r.useEffect((()=>{if(s==="Completed"){const d=u??i,S=d!=null?`/${a}/invoicing/customers/${encodeURIComponent(d)}`:`/${a}/invoicing/customers`;e(S),t(En({id:i}))}}),[s,u,i,t,e,a]),c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCustomerFormPage}),c.jsx(ca,{customerId:i,location:n,navigate:e,tenantEmailDomain:a})]})}const ra=T((function(t){const e=fe(t),{fetchState:n}=e;return{addressesById:t.addressState.addressesById,columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",customers:e.customers,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.customers.length===0,isLoadingMore:n==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,a)=>{switch(a){case"createInvoice":g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":g.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"customers",status:e.activeStatus}),t(yn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Ct);function da(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,S]=r.useState(null),m=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),v=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,customerListFetchState:h}=k((D=>{const b=fe(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,customerListFetchState:b.fetchState}}),Q),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(be({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(v.search!==f||m?.field!==I?.field||m?.dir!==I?.dir)&&t(be({cacheOverride:!0,filters:v,sort:m}))}),[i,t,v,m,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCustomersListPage,isReady:y}),c.jsx(ra,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:d,filters:v,sort:m,nextCursor:E,onSearchChange:o,onStatusChange:D=>{t(hi(D)),t(be({cacheOverride:!1,filters:v,sort:m}))},onSortChange:S})]})}const Te=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),la=T((function(t,e){const{authParams:n,csvDownloadUrl:i,filters:a,sessionId:o,view:s}=e,u=o==null?void 0:s.diagnosticsBySession[o],d=u?.fetch.fetchState??"Not-Started";return{authParams:n,csvDownloadUrl:i,diagnostics:u?.items??[],errorMessage:d==="Error"?u?.fetch.error?.message:void 0,expired:u?.expired??!1,filters:a,hasMore:u?.nextCursor!=null,isLoading:d==="Not-Started"||d==="In-Progress",isLoadingMore:d==="In-Progress"&&(u?.items.length??0)>0,session:Te(s,o)}}),(function(t,e){const{filters:n,navigate:i,sessionId:a,tenantEmailDomain:o,view:s}=e,u=a==null?void 0:s.diagnosticsBySession[a],d=Te(s,a),S=s.actionStateByKind.retry?.fetchState==="In-Progress",m=s.actionStateByKind.rollback?.fetchState==="In-Progress",v=d?.status==="done"&&d.rollback_available_until!=null&&new Date(d.rollback_available_until).getTime()>Date.now()&&!m;return{onBack:()=>i(`/${o}/invoicing/data_import`),onDownloadCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"download_csv",fromScreen:"data_import_detail",sessionId:a})},onDownloadError:()=>{t(Ve({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{a!=null&&u?.nextCursor!=null&&t(Re({...n,cursor:u.nextCursor,sessionId:a}))},onRetry:d?.status!=="failed"||S?void 0:()=>{a!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_detail",sessionId:a}),t(qe(a)))},onRollback:v?()=>{a!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"rollback",fromScreen:"data_import_detail",sessionId:a}),t(bn(a)))}:void 0}}))(kt);function ua(){const t=L(),e=P(),{sessionId:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),[o,s]=r.useState({}),u=k(He),d=k(he),S=r.useMemo((()=>{const E=J.getSignedInUser();return{userId:E?.userId??"",sessionId:E?.zeniSessionId??"",tenantId:d.tenantId}}),[d.tenantId]),m=Te(u,n),v=n==null?void 0:u.diagnosticsBySession[n];r.useEffect((()=>{a&&n!=null&&t(we(n))}),[a,t,n]),r.useEffect((()=>{if(!a||n==null)return;const E=setTimeout((()=>{t(Re({...o,sessionId:n}))}),300);return()=>clearTimeout(E)}),[a,t,o,n]);const p=m?.status==="scanning"||m?.status==="importing";r.useEffect((()=>{if(!a||n==null||!p)return;const E=setInterval((()=>{t(we(n)),t(Re({...o,sessionId:n}))}),3e3);return()=>clearInterval(E)}),[a,t,o,p,n]);const f=r.useMemo((()=>{if(n==null)return"";const E=new URLSearchParams;o.moduleId!=null&&E.set("module_id",o.moduleId),o.level!=null&&E.set("level",o.level),o.outcome!=null&&E.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&E.set("search",o.search.trim());const h=E.toString();return`${de?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${h===""?"":`?${h}`}`}),[o,n]),I=v?.fetch.fetchState??"Not-Started";return N(I)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingDataImportDetailPage,isReady:m!=null&&I!=="Not-Started"}),c.jsx(la,{authParams:S,csvDownloadUrl:f,filters:o,navigate:e,sessionId:n,tenantEmailDomain:i,view:u,onFiltersChange:s})]})}const Zn=t=>`invoicing_active_migration:${t}`,re=(t,e)=>{if(t!=null&&t!=="")try{const n=Zn(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},ga=T((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:a,statusRows:o}=e.view;return{isLoading:!(a.fetchState!=="Not-Started"&&a.fetchState!=="In-Progress"||o.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:o}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,a=o=>{const s=o??null;t(se(s)),re(i,s),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),a(o)},onNewImport:()=>{g.trackInvoicingActionClick(l.Event.invoicingNewImportClicked),a()},onRetrySession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),t(qe(o)),a(o)},onRollbackSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),t(bn(o))},onViewSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),n(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(Et);function ma(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),a=k(He);r.useEffect((()=>{i&&(t(Ci()),t(xn()))}),[i,t]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingDataImportHubPage,isReady:o}),c.jsx(ga,{navigate:e,tenantEmailDomain:n,view:a})]})}const va=T((function(t,e){const{activeId:n,authParams:i,integrationsView:a,settings:o,templatesDownloadUrl:s,view:u}=e,{actionStateByKind:d,sessionDetail:S,sessions:m}=u,v=a.externalConnections?.revenue?.find((f=>f.connectionName==="chargebee")),p=n!=null?S[n]:void 0;return{authParams:i,templatesDownloadUrl:s,chargebeeConnected:o?.chargebee_connected===!0||(v?.isValid??!1),chargebeeConnectorAvailable:v!=null,chargebeeSite:o?.chargebee_site,connectError:d.connect?.error?.message,connecting:d.connect?.fetchState==="In-Progress",retrying:d.retry?.fetchState==="In-Progress",session:p??m.find((f=>f.id===n)),starting:d.start?.fetchState==="In-Progress",uploading:d.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:a}=e;return{onBack:e.onBack,onDownloadError:()=>{t(Ve({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onDownloadTemplates:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportTemplatesDownloaded)},onFetchFromChargebee:()=>{g.trackInvoicingActionClick(l.Event.invoicingChargebeeConnectClicked),t(yi())},onGoToIntegrations:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"settings_integrations"}),i(`/${a}/invoicing/settings`)},onGoToOverview:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"overview"}),i(`/${a}/invoicing/overview`)},onRetry:()=>{n!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_migrate",sessionId:n}),t(qe(n)))},onSaveLater:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportStarted),n!=null&&t(Ei(n))},onUpload:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportFileUploaded),t(ki({files:o}))},onViewDetails:n==null?void 0:()=>i(`/${a}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(yt);function pa(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),a=k(Sn),o=k(he),s=r.useMemo((()=>{const h=J.getSignedInUser();return{userId:h?.userId??"",sessionId:h?.zeniSessionId??"",tenantId:o.tenantId}}),[o.tenantId]),u=`${de?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/templates`,d=o.companyId??J.getSignedInUserTenant(n??"")?.companyId,S=k((h=>An(h,d))),m=k(He),{activeMigrationSessionId:v}=m,p=v??void 0,f=p!=null?m.sessionDetail[p]??m.sessions.find((h=>h.id===p)):void 0;r.useEffect((()=>{i&&(t(Qe()),t(xn()))}),[i,t]),r.useEffect((()=>{if(v!=null)return;const h=(y=>{if(y==null||y==="")return null;try{return sessionStorage.getItem(Zn(y))}catch{return null}})(n);h!=null&&t(se(h))}),[v,t,n]),r.useEffect((()=>{re(n,v)}),[v,n]);const I=f?.status,E=I==="scanning"||I==="importing";return r.useEffect((()=>{if(!i||p==null||!E)return;const h=setInterval((()=>{t(we(p))}),3e3);return()=>clearInterval(h)}),[i,p,E,t]),r.useEffect((()=>{I==="done"&&(t(se(null)),re(n,null))}),[t,I,n]),c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingDataImportMigratePage}),c.jsx(va,{activeId:p,authParams:s,integrationsView:S,navigate:e,settings:a,templatesDownloadUrl:u,tenantEmailDomain:n,view:m,onBack:()=>{t(se(null)),re(n,null),e(`/${n}/invoicing/data_import`)}})]})}const Sa=T((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,discountsAccountName:n.discountsAccountName,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${n}/discounts`),onLifecycleAction:a=>{g.trackInvoicingActionClick(l.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discount_detail",status:e.editView.coupon?.status}),t(Dn({action:a,id:i}))},onSaveEdit:a=>{const{coupon:o}=e.editView;g.trackInvoicingActionClick(l.Event.invoicingCouponEdited,{couponId:i,mode:"edit",...B(a,{invoice_name:o?.invoiceName,invoice_notes:o?.invoiceNotes,max_redemptions:o?.maxRedemptions,name:o?.name},["invoice_notes"])}),t(xi({data:a,id:i}))}}}))(bt);function fa(){const t=L(),e=P(),{coupon_id:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),o=k((I=>bi(I,n))),s=o.actionState.fetchState==="In-Progress",u=o.pageFetchState.fetchState,d=u==="Completed",[S,m]=r.useState(d?n:void 0);r.useEffect((()=>{n!=null&&d&&m(n)}),[n,d]);const v=S===n;r.useEffect((()=>(t(ge({id:n})),()=>{t(ge({id:n}))})),[n,t]),r.useEffect((()=>{a&&t(_e({id:n}))}),[a,n,t]);const p=r.useCallback((I=>t(_e({cacheOverride:!0,id:I}))),[t]),f=ne(o.fetchState,o.isFormLoading,n,p);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingDiscountDetailPage,isReady:d}),c.jsx(Sa,{hasLoadedRecord:v,couponId:n??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:s,navigate:e,tenantEmailDomain:i},f)]})}const Ia=T((function(t){const e=jn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,discountLifecycleActionOptions:e.discountLifecycleActionOptions,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",coupons:e.coupons,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.coupons.length===0,isLoadingMore:n==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,a)=>{g.trackInvoicingActionClick(l.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discounts_list"}),t(Dn({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"discounts",status:e.activeStatus}),t(Di({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(xt);function ha(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,S]=r.useState(null),m=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),v=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,couponListFetchState:h,runningDiscountActionId:y}=k((b=>{const A=jn(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,couponListFetchState:A.fetchState,runningDiscountActionId:A.runningActionId??null}}),Q),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(xe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(v.search!==f||m?.field!==I?.field||m?.dir!==I?.dir)&&t(xe({cacheOverride:!0,filters:v,sort:m}))}),[i,t,v,m,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingDiscountsListPage,isReady:D}),c.jsx(Ia,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:d,filters:v,sort:m,nextCursor:E,runningDiscountActionId:y,onSearchChange:o,onStatusChange:b=>{t(Ai(b)),t(xe({cacheOverride:!1,filters:v,sort:m}))},onSortChange:S})]})}const Ca=T((function(t,e){const{readView:n}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:n.dunningCase,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress",step:n.step}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,a=i!=="",{dunningCase:o}=e.readView,s={amount:o?.amount?.amount,caseId:i,customerId:o?.customerID,invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID};return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:u=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:u,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(u)}`)},onCancel:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"cancel",fromScreen:"dunning_detail"}),t(z({action:"cancel",id:i}))}:void 0,onResolve:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"resolve",fromScreen:"dunning_detail"}),t(z({action:"resolve",id:i}))}:void 0,onResume:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"resume",fromScreen:"dunning_detail"}),t(z({action:"resume",id:i}))}:void 0,onRetry:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"retry",fromScreen:"dunning_detail"}),t(z({action:"retry",id:i}))}:void 0}}))(Dt);function ka(){const t=L(),e=P(),{case_id:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),o=k((C=>ji(C,n??""))),s=o.fetchState==="Completed",u=o.dunningCase?.invoiceID,[d,S]=r.useState("idle"),[m,v]=r.useState(!1),[p,f]=r.useState(),[I,E]=r.useState(!1),h=r.useCallback((()=>{S("idle"),v(!1),f(void 0),E(!1)}),[]),y=r.useCallback((()=>{if(n==null)return;t(Li({id:n})),S("idle"),v(!1);const C=o.emailPreview.preview;f(C==null?void 0:{body:C.body,cc:C.cc,subject:C.subject,to:C.to}),E(!0)}),[n,t,o.emailPreview.preview]),D=r.useCallback((C=>{n!=null&&d!=="pending"&&(v(!1),S("pending"),g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{action:"send-email",amount:o.dunningCase?.amount?.amount,caseId:n,customerId:o.dunningCase?.customerID,fromScreen:"dunning_detail",invoiceId:o.dunningCase?.invoiceID,status:o.dunningCase?.status,subscriptionId:o.dunningCase?.subscriptionID}),t(z({action:"send-email",body:C,id:n})))}),[n,t,d,o.dunningCase]),b=r.useMemo((()=>o.emailPreview.preview==null?void 0:{bodyToken:o.emailPreview.preview.bodyToken,renderedHtmlTemplate:o.emailPreview.preview.renderedHtmlTemplate,subjectToken:o.emailPreview.preview.subjectToken}),[o.emailPreview.preview]);r.useEffect((()=>{a&&n!=null&&t(Pi({id:n}))}),[a,n,t]),r.useEffect((()=>{a&&u!=null&&t(Ce({invoiceId:u}))}),[a,u,t]),r.useEffect((()=>{S("idle"),v(!1),f(void 0),E(!1)}),[n]),r.useEffect((()=>{a||(S("idle"),v(!1),f(void 0),E(!1))}),[a]),r.useEffect((()=>{I&&p==null&&o.emailPreview.preview!=null&&f({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,p,I]),r.useEffect((()=>{d==="pending"&&(o.actionState.fetchState!=="In-Progress"?m&&o.actionState.fetchState==="Completed"?(n!=null&&t(_i({id:n})),h()):m&&o.actionState.fetchState==="Error"&&S("failed"):v(!0))}),[n,h,t,d,m,o.actionState.fetchState]);const A=u!=null&&o.linkedInvoice?.id===u?o.linkedInvoice.dunningAttempts:void 0;return N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingDunningDetailPage,isReady:s}),c.jsx(Ca,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:o,dunningAttempts:A,onSendEmail:y}),c.jsx(At,{initialDraft:p,isPreviewLoading:o.emailPreview.fetchState==="Not-Started"||o.emailPreview.fetchState==="In-Progress",isSending:d==="pending",onClose:h,onSend:D,open:I,preview:b,previewErrorMessage:o.emailPreview.fetchState==="Error"?o.emailPreview.error?.message:void 0,sendErrorMessage:d==="failed"?o.actionState.error?.message:void 0})]})}const Ea=T((function(t){const e=Ln(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:n==="In-Progress"&&e.dunningCases.length>0,stepById:e.stepById,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=a=>{const o=e.dunningCases.find((s=>s.id===a));return{amount:o?.amount?.amount,caseId:a,customerId:o?.customerID,fromScreen:"dunning_list",invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID}};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${n}/data_import`),onDunningCaseClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingDunningCaseRowClicked,i(a)),e.navigate(`${n}/dunning/${encodeURIComponent(a)}`)},onRowAction:(a,o)=>{o!=="retry"&&o!=="resume"&&o!=="resolve"&&o!=="cancel"||(g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...i(a),action:o}),t(z({action:o,id:a})))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"dunning",status:e.activeStatus}),t(wi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(jt);function ya(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,S]=r.useState(null),m=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),v=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,dunningCaseListFetchState:h,dunningCases:y}=k((b=>{const A=Ln(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,dunningCaseListFetchState:A.fetchState,dunningCases:A.dunningCases}}),Q),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(Ae({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(v.search!==f||m?.field!==I?.field||m?.dir!==I?.dir)&&t(Ae({cacheOverride:!0,filters:v,sort:m}))}),[i,t,v,m,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingDunningListPage,isReady:D}),c.jsx(Ea,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:d,filters:v,sort:m,dunningCases:y,nextCursor:E,onSearchChange:o,onStatusChange:b=>{t($i(b)),t(Ae({cacheOverride:!1,filters:v,sort:m}))},onSortChange:S})]})}const ba=T((function(t,e){const{view:n}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:n.billingAddress,invoice:n.invoice,invoiceId:e.invoiceId,shippingAddress:n.shippingAddress,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isSaving:n.actionState.fetchState==="In-Progress",isVoiding:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e,{invoice:a}=e.view,o={amount:a?.total?.amount,customerId:a?.customerID,invoiceId:i,status:a?.status};return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(s)}`)},onIssueCreditNote:()=>{g.trackInvoicingActionClick(l.Event.invoicingIssueCreditNoteClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{g.trackInvoicingActionClick(l.Event.invoicingRecordPaymentClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceRegenerated,{...o,fromScreen:"invoice_detail"}),t(q({action:"regenerate",invoiceId:i}))},onSaveEdit:s=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceEdited,{...o,fromScreen:"invoice_detail",mode:"edit",...B(s,{due_date:a?.dueDate?.format("YYYY-MM-DD")??"",notes:(a?.notes??[]).map((u=>u.note)).filter((u=>u!=null&&u!=="")).join(`
1
+ import{j as c}from"./liveblocks-CZZ7TQJf.js";import{a as r}from"./sentry-7oL5NFUY.js";import{u as L,h as P,i as w,j as k,t as Z,l as T,s as Q,g as X,N as H,n as ce,o as x}from"./core-DtSa7_zJ.js";import{a6 as ct,k as g,ao as F,R as l,ca as st,cb as rt,cc as dt,cd as lt,ce as ut,cf as gt,cg as mt,ch as vt,ci as pt,cj as St,ck as ft,cl as It,p as ee,cm as ht,cn as Ct,z as J,ac as de,co as kt,cp as Et,cq as yt,cr as bt,cs as xt,ct as At,cu as Dt,cv as jt,cw as Lt,cx as Pt,M as _t,ag as un,cy as $t,cz as wt,cA as Rt,cB as Ft,cC as Ot,cD as Tt,cE as Mt,cF as Nt,cG as Ut,cH as Bt,cI as Vt,t as Je,j as Me,cJ as Ht,cK as qt,cL as Qt,cM as zt,cN as Kt,cO as Gt,cP as Wt}from"./index-CJhgQFRI.js";import"./mui-hHF2bYsV.js";import{A as G}from"./AddressScreen-DWZzKMEw.js";import M from"./NotFoundScreen-DHpPkJUq.js";import{_g as Yt,_h as Jt,vw as Ze,v as Zt,_i as W,w6 as le,_j as Ne,_k as ue,wJ as Pe,wQ as Xt,dX as gn,wU as mn,_l as Ue,wN as ei,yr as Xe,w5 as en,_m as vn,x3 as _e,_n as ge,x7 as ni,_o as ti,xh as ii,_p as pn,xa as Sn,y$ as oi,_q as fe,_r as nn,_s as fn,w2 as ai,_t as ci,vW as si,_u as ri,yE as di,_v as In,yN as ye,_w as li,yK as ui,_x as Be,gk as Ve,_y as oe,_z as ae,xp as gi,wb as tn,wg as hn,we as mi,w8 as vi,xi as pi,wi as Si,xr as fi,c_ as Cn,_A as $e,xA as kn,xy as Ie,xw as me,xv as Ii,_B as En,yU as be,_C as hi,w4 as yn,_D as He,fI as he,wr as we,wo as Re,wB as bn,wA as qe,wl as Ci,wu as xn,wD as se,W1 as An,w7 as Qe,wy as ki,wz as Ei,wx as yi,_E as bi,x8 as xi,x4 as Dn,_F as jn,vN as xe,_G as Ai,vG as Di,_H as ji,y_ as Li,z3 as z,yZ as Pi,y5 as Ce,_I as _i,_J as Ln,zc as Ae,_K as $i,z9 as wi,_L as Pn,y8 as Ri,y9 as q,yc as Fi,_M as _n,ym as De,_N as Oi,xq as $n,Uz as wn,_O as Ti,yw as Mi,_P as Rn,_Q as Ni,_R as Ui,_S as Bi,z$ as Vi,_T as Hi,_U as Fn,zj as On,_V as Tn,zZ as je,_W as qi,zW as Qi,_X as zi,_Y as Ki,_Z as Gi,__ as Wi,_$ as Yi,$0 as on,$1 as Ji,ei as Zi,A3 as Xi,$2 as ze,xK as eo,xF as no,d0 as Fe,$3 as Y,xO as Mn,xU as Nn,$4 as Un,xP as ve,xZ as to,y0 as Bn,$5 as io,xY as oo,$6 as Vn,$7 as Hn,zO as Le,zJ as ao,$8 as co,zo as so,$9 as ro,zP as lo,zT as uo,$a as Ke,wL as qn,zA as go,wM as mo,$b as vo,$c as Qn,c9 as po,mw as So,mx as fo,$d as an,wK as pe,go as Io,mD as ho,zG as zn,Af as Co,zD as Kn,v2 as ko,uS as Eo,hW as yo,V0 as cn,V1 as bo,GB as Gn,Ac as xo,hO as Ao,A9 as Do,$e as jo,$f as Lo,Al as Po,Ak as _o,$g as $o,$h as Wn,Ai as wo,$i as Ro,$j as Fo,yA as Oo,$k as To}from"./zeni-epic-state-DIQk-W8f.js";import{M as Mo}from"./MobileAppDrawer-D9iwyW6E.js";import{q as Se}from"./QBOConnectionScreen-DNwlxY3R.js";import"./recharts-DHYb1iJa.js";import"./analytics-wUVBNE2n.js";import"./plaid-l93gkere.js";import"./dnd-BRHUZ8LO.js";import"./stripe-cKAAJElX.js";import"./lottie-_8fQYf62.js";import"./lexical-CV0PpHfb.js";import"./pdf-DcTPEGUQ.js";import"./utils-D3PNq8pk.js";import"./InboxNotificationsProvider-DrljtAmN.js";import"./useTaskManagerAccess-zRd8th0q.js";import"./empty--RCTsu0x.js";import"./pdf-lib-DvlP1tZv.js";import"./index-DxlUZLeR.js";import"./url-yW-1Hcty.js";import"./index-Cz1UMaoE.js";import"./decodeURIComponentSafe-CxfS79yY.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="c3911b53-0387-4691-9e92-9159e56c82db",t._sentryDebugIdIdentifier="sentry-dbid-c3911b53-0387-4691-9e92-9159e56c82db")}catch{}})();const $=({event:t,isReady:e=!0})=>e?c.jsx(ct,{analytics:g,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function No(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,S]=r.useState(null),m=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),{fetchState:v,hasMore:p,items:f,nextCursor:I,auditLogEntityRouteOptions:E,auditLogListSortFieldOptions:h}=k(Yt),y=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),D=`/${n??""}/invoicing`,b=r.useCallback(((R,U)=>{const O=Jt(D,R,U,E);O!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{entity:R,entityId:U,fromScreen:"audit_log",toScreen:R}),e(O))}),[E,e,D]);r.useEffect((()=>{const R=setTimeout((()=>u(a)),300);return()=>clearTimeout(R)}),[a]),r.useEffect((()=>{i&&t(Ze({filters:y,keepExistingListItems:!1,sort:m}))}),[i,y,m,t]);const A=v==="Not-Started"||v==="In-Progress"&&f.length===0,C=v==="In-Progress"&&f.length>0,j=v==="Completed";return N(v)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingAuditLogPage,isReady:j}),c.jsx(st,{auditLogEntityRouteOptions:E,auditLogListSortFieldOptions:h,entries:f,hasMore:p,isLoading:A,isLoadingMore:C,searchValue:a,sortState:d,onEntityLinkClick:b,onLoadMore:()=>{p&&I!=null&&t(Ze({cursor:I,filters:y,keepExistingListItems:!0,sort:m}))},onSearchChange:o,onSortChange:S})]})}const Yn=["company","email","firstName","invoiceNotes","lastName","notes","phone","vatNumber"],Oe=t=>typeof t=="string"||typeof t=="number"||typeof t=="boolean"?t:Array.isArray(t)?t.map(Oe):t!=null&&typeof t=="object"?Object.fromEntries(Object.entries(t).map((([e,n])=>[e,Oe(n)]))):null;function B(t,e,n=[]){const i=t,a=e,o=[...new Set([...Object.keys(i),...Object.keys(a??{})])].filter((u=>{if(a==null)return(d=i[u])!=null&&d!==""&&(Array.isArray(d)?d.length>0:typeof d!="object"||Object.keys(d).length>0);var d;return!(i[u]==null&&a[u]==null)&&!Zt(i[u],a[u])})).sort(),s=Object.fromEntries(o.filter((u=>!n.includes(u))).map((u=>[u,Oe(i[u])])));return{fieldsChanged:o,formValues:s}}function ke(t,e=!1){const n=L(),i=k((s=>W(s).productNextCursor!=null)),a=k((s=>W(s).productNextCursor)),o=k((s=>W(s).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&o!=="Not-Started"||n(le({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&o!=="In-Progress"&&i&&a!=null&&n(le({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,o,i,a])}function ne(t,e,n,i){const[a,o]=r.useState(0),[s,u]=r.useState(!1),d=r.useRef(t);return r.useEffect((()=>{const S=d.current==="In-Progress";d.current=t,t==="Completed"&&S&&n!=null&&(u(!0),i(n))}),[t,n,i]),r.useEffect((()=>{s&&!e&&(u(!1),o((S=>S+1)))}),[s,e]),a}const Uo=new Set(["plan"]),Bo=T((function(t,e){const{view:n}=e;return{applicableItemOptions:n.applicableItemOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboClassHierarchy:n.qboClassHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:n.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",itemId:e.itemId,localData:n.localData,plan:n.plan}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${n}/catalog`),onLifecycleAction:i!==""?a=>{i!==""&&(g.trackInvoicingActionClick(l.Event.invoicingCatalogItemLifecycleAction,{action:a,fromScreen:"catalog_item_detail",itemId:i}),t(ei({action:a,id:i})))}:void 0,onEditChange:a=>{i!==""&&t(Ue({id:i,localData:a}))},onSaveEdit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemEdited,{itemId:i,mode:"edit",...B(e.view.localData,gn(e.view.plan))}),t(mn({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&t(Xt({action:o,id:a,parentItemId:i}))}}}))(rt);function Vo(){const t=L(),e=P(),{item_id:n,tenantEmailDomain:i}=w(),[a]=Z(),{areTenantIdsInSync:o}=F(),s=(u=a.get("kind"))!=null&&Uo.has(u)?u:"plan";var u;const d=k((y=>Ne(y,n))),{pageFetchState:S}=d,m=S.fetchState;r.useEffect((()=>(t(ue({id:n})),()=>{t(ue({id:n}))})),[t,n]),r.useEffect((()=>{o&&t(Pe({id:n,kind:s}))}),[o,n,s,t]);const v=r.useCallback((y=>t(Pe({cacheOverride:!0,id:y,kind:s}))),[t,s]),p=ne(d.fetchState,d.isFormLoading,n,v),f=m==="Completed"&&!d.isFormLoading;ke(o,!0);const[I,E]=r.useState(f?n:void 0);r.useEffect((()=>{n!=null&&f&&E(n)}),[n,f]);const h=I!==n&&(m==="Not-Started"||m==="In-Progress"||d.isFormLoading);return N(m)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCatalogItemDetailPage,isReady:f}),c.jsx(Bo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:s,isLoading:h,view:d},p)]})}const Ho=new Set(["addon","charge","plan"]),qo=new Set(["plan"]),Qo=T((function(t,e){const n=Ne(t,e.itemId);return{fieldHelp:n.fieldHelp,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,applicabilityValues:n.applicabilityValues,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,applicableItemOptions:n.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save catalog item.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedItem:n.plan,pricingModelValues:n.pricingModelValues,prorationValues:n.prorationValues,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,tierTypeValues:n.tierTypeValues}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e,a=i!=null?`${n}/catalog/${encodeURIComponent(i)}`:`${n}/catalog`;return{onBack:()=>e.navigate(a),onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemFormCancelled),t(ue({id:i})),e.navigate(`${n}/catalog`)},onChange:o=>{t(Ue({id:i,localData:o}))},onSubmit:()=>{t(mn({id:i}))}}}),(function({savedItem:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemSaved,{itemId:i.itemId,mode:e.mode,...B(e.localData,t!=null?gn(t):void 0)}),n.onSubmit()}}}))(dt);function zo(){const t=L(),e=P(),{item_id:n,tenantEmailDomain:i}=w(),[a]=Z(),{areTenantIdsInSync:o}=F(),s=n!=null,u=a.get("type"),d=u!=null&&Ho.has(u)?u:void 0,S=(m=a.get("kind"))!=null&&qo.has(m)?m:"plan";var m;const v=k((p=>Ne(p,n)));return ke(o,!0),r.useEffect((()=>{o&&t(Pe({id:n,kind:S}))}),[o,n,S,t]),r.useEffect((()=>{s||d==null||v.localData.catalogType===d||t(Ue({localData:{...v.localData,catalogType:d}}))}),[s,d,v.localData?.catalogType,t]),r.useEffect((()=>{if(v.fetchState==="Completed"){const p=v.savedItemId??n,f=p!=null?`/${i}/invoicing/catalog/${encodeURIComponent(p)}`:`/${i}/invoicing/catalog`;e(f),t(ue({id:n}))}}),[v.fetchState,v.savedItemId,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCatalogItemFormPage}),c.jsx(Qo,{navigate:e,tenantEmailDomain:i,defaultType:d,isEdit:s,itemId:n})]})}const Ko={addons:"addon",all:"item",charges:"charge",plans:"plan"},Go=T((function(t,e){const n=W(t),i=e.activeTab==="plans",a=e.activeTab==="all",o=i?n.plans:a?[...n.plans,...n.products]:n.products,s=i||a&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:a&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:s==="Not-Started"||s==="In-Progress"&&o.length===0,isLoadingMore:s==="In-Progress"&&o.length>0,planRows:n.planRows,productRows:n.productRows}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",a=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const s=Ko[e.activeTab];g.trackInvoicingActionClick(l.Event.invoicingAddCatalogItemClicked,{itemType:s}),e.navigate(`${n}/catalog/new?type=${s}`)},onItemClick:(s,u)=>{g.trackInvoicingActionClick(l.Event.invoicingCatalogItemRowClicked,{itemId:u}),e.navigate(`${n}/catalog/${encodeURIComponent(u)}`)},onLoadMore:()=>{if(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"catalog",tab:e.activeTab}),a)return e.planNextCursor!=null&&t(en({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&t(le({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));o!=null&&t(i?en({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):le({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(lt);function Wo(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState("plans"),[d,S]=r.useState(""),[m,v]=r.useState(null),p=r.useMemo((()=>m!=null?{dir:m.direction,field:m.columnKey}:void 0),[m]),f=d.trim()!==""?d.trim():void 0,I=r.useMemo((()=>({search:f,type:"plan"})),[f]),E=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),h=k((j=>W(j))),y=h.planFilters.search,D=h.planSort,b=h.planNextCursor,A=h.productNextCursor,C=h.fetchState==="Completed";return r.useEffect((()=>{const j=setTimeout((()=>S(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t(Xe({cacheOverride:!1,planFilters:I,productFilters:E,planSort:p,productSort:p}))}),[i,t,I,E,p]),r.useEffect((()=>{i&&(f!==y||p?.field!==D?.field||p?.dir!==D?.dir)&&t(Xe({cacheOverride:!0,planFilters:I,productFilters:E,planSort:p,productSort:p}))}),[y,D,i,t,I,E,f,p]),N(h.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCatalogPage,isReady:C}),c.jsx(Go,{navigate:e,tenantEmailDomain:n,activeTab:s,searchValue:a,sortState:m,planFilters:I,productFilters:E,sort:p,planNextCursor:b,productNextCursor:A,onSearchChange:o,onTabChange:u,onSortChange:v})]})}const Yo=T((function(t,e){const n=vn(t,e.couponId);return{fieldHelp:n.fieldHelp,applyOnOptions:n.applyOnOptions,discountTypeOptions:n.discountTypeOptions,durationTypeOptions:n.durationTypeOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save coupon.":void 0,isQboConnected:n.isQboConnected,isQboPickerDataLoading:n.isQboPickerDataLoading,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedCoupon:n.coupon,periodUnitOptions:n.periodUnitOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,a=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>e.navigate(a),onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCouponFormCancelled),t(ge({id:i})),e.navigate(`${n}/discounts`)},onChange:o=>{t(ti({id:i,localData:o}))},onSubmit:()=>{t(ni({id:i}))}}}),(function({savedCoupon:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCouponSaved,{couponId:i.couponId,mode:e.mode,...B(e.localData,t!=null?ii(t):void 0)}),n.onSubmit()}}}))(ut);function Jo(){const t=L(),e=P(),{coupon_id:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),{fetchState:o,savedCouponId:s}=k((u=>vn(u,n)));return r.useEffect((()=>{a&&t(_e({id:n}))}),[a,n,t]),r.useEffect((()=>{if(o==="Completed"){const u=s??n,d=u!=null?`/${i}/invoicing/discounts/${encodeURIComponent(u)}`:`/${i}/invoicing/discounts`;e(d),t(ge({id:n}))}}),[o,s,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCouponFormPage}),c.jsx(Yo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Zo=T((function(t){const e=pn(t);return{fieldHelp:e.fieldHelp,customers:e.customers,planNames:e.planNames,errorMessage:e.fetchState==="Error"?e.error?.message??"Failed to create invoice. Please try again.":void 0,isSubmitting:e.fetchState==="In-Progress",localData:e.localData,settings:e.settings}}),(function(t){return{dispatch:t}}),(function(t,{dispatch:e},n){const i=`/${n.tenantEmailDomain}/invoicing`;return{...t,onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:a=>{e(fn(a))},onSubmit:()=>{const a=ci(t.localData);g.trackInvoicingActionClick(l.Event.invoicingInvoiceCreated,{customerId:a.customer_id,lineItemCount:a.line_items?.length,mode:"create",...B(t.localData,void 0,["memo"])}),e(si(a))}}}))(mt);function Xo(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),[i]=Z(),{areTenantIdsInSync:a}=F(),o=i.get("customerId"),s=k((b=>pn(b))),u=s.fetchState,d=s.localData,S=s.savedInvoiceId,m=k(Sn),v=k((b=>oi(b))),p=k(fe),f=v.fetchState==="Not-Started"||v.fetchState==="In-Progress"&&m==null,I=p.fetchState==="Not-Started"||p.fetchState==="In-Progress"&&p.customers.length===0,E=f||I,h=v.fetchState==="Completed"&&p.fetchState==="Completed";r.useEffect((()=>(t(nn()),()=>{t(nn())})),[t]);const y=r.useRef(!1);r.useEffect((()=>{y.current||o==null||o===""||d.customerId!==""||(y.current=!0,t(fn({...d,customerId:o})))}),[o,d,t]),r.useEffect((()=>{a&&t(ai({cacheOverride:!1}))}),[a,t]);const D=r.useRef(u);return r.useEffect((()=>{const b=D.current;if(D.current=u,b!=="Completed"&&u==="Completed"){const A=S!=null?`/${n}/invoicing/invoices/${encodeURIComponent(S)}`:`/${n}/invoicing/invoices`;e(A)}}),[u,S,e,n]),c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCreateInvoicePage,isReady:h}),E?c.jsx(gt,{}):c.jsx(Zo,{navigate:e,tenantEmailDomain:n})]})}const ea=T((function(t,e){const{detailView:n}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:n.creditNote,creditNoteId:e.creditNoteId,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${n}/credits`),onCustomerClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(vt);function na(){const t=L(),e=P(),{credit_note_id:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),o=k((u=>ri(u,n??""))),s=o.fetchState==="Completed";return r.useEffect((()=>{a&&n!=null&&t(di({id:n}))}),[a,n,t]),N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCreditDetailPage,isReady:s}),c.jsx(ea,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:o})]})}const ta=T((function(t){const e=In(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",creditNotes:e.creditNotes,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.creditNotes.length===0,isLoadingMore:n==="In-Progress"&&e.creditNotes.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"credits",status:e.activeStatus}),t(ui({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(pt);function ia(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,S]=r.useState(null),m=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),v=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,creditNoteListFetchState:h}=k((D=>{const b=In(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,creditNoteListFetchState:b.fetchState}}),Q),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(ye({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(v.search!==f||m?.field!==I?.field||m?.dir!==I?.dir)&&t(ye({cacheOverride:!0,filters:v,sort:m}))}),[i,t,v,m,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCreditsListPage,isReady:y}),c.jsx(ta,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:d,filters:v,sort:m,nextCursor:E,onSearchChange:o,onStatusChange:D=>{t(li(D)),t(ye({cacheOverride:!1,filters:v,sort:m}))},onSortChange:S})]})}const Jn=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},oa=T((function(t,e){const{editView:n,hasLoadedRecord:i}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,hasUnsavedBillingAddress:n.hasUnsavedBillingAddress,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:!i&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),hasPaymentLinkEmailPreviewFailed:n.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:n.emailPreviewFetchState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",paymentLinkEmailPreview:n.emailPreview,isSendingPaymentLink:n.record.sendLinkState.fetchState==="In-Progress",localData:n.localData,paymentMethods:n.record.paymentMethods,sendPaymentLinkErrorMessage:n.record.sendLinkState.fetchState==="Error"?n.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:n.record.stripeConnected}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${n}/customers`),onChange:a=>{t($e({id:i,localData:a}))},onCreateInvoice:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onCreatePromotionalCredits:()=>{g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customer_detail"}),e.onCreatePromotionalCredits()},onNewSubscription:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`)},onDiscardEdit:()=>{t(Ie(me)),t(Ii({id:i}))},onOpenAddress:()=>{const a=Jn(e.tenantEmailDomain??"",me,i),o=ee(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:a=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerEdited,{customerId:i,mode:"edit",...B(a,e.editView.record.invoicingCustomer!=null?Cn(e.editView.record.invoicingCustomer):void 0,Yn)}),t($e({id:i,localData:a})),t(kn({id:i}))},onFetchPaymentLinkEmailPreview:a=>t(fi({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,s)=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentLinkSent,{customerId:i,fromScreen:"customer_detail"}),t(Si({body:s,customerId:i,email:a,subject:o}))},onSubscriptionClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)}}}))(It);function aa(){const t=L(),e=P(),n=X(),{customer_id:i,tenantEmailDomain:a}=w(),{areTenantIdsInSync:o}=F(),s=k((O=>Be(O,i))),u=s.pageFetchState.fetchState,d=u==="Completed"&&!s.isFormLoading,[S,m]=r.useState(!1),[v,p]=r.useState(!1),[f,I]=r.useState(d?i:void 0);r.useEffect((()=>{i!=null&&d&&I(i)}),[i,d]);const E=f===i,{plaidTokenFetchState:h,promotionalCreditSubmitState:y}=s,{paymentMethodSaveState:D,setupIntentFetchState:b,stripeConnected:A}=s.record,C=r.useRef(s.record.sendLinkState.fetchState);r.useEffect((()=>{const O=s.record.sendLinkState.fetchState;C.current!=="Error"&&O==="Error"&&t(Ve({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),C.current=O}),[t,s.record.sendLinkState.fetchState]);const j=b.fetchState==="Error"?b.error?.message??"Failed to start card setup.":D.fetchState==="Error"?D.error?.message??"Failed to save payment method.":h.fetchState==="Error"?h.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(t(oe()),t(ae()),()=>{t(oe()),t(ae())})),[t]),r.useEffect((()=>{n.state?.openPromotionalCreditsDialog===!0&&(p(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{o&&i!=null&&t(gi({id:i}))}),[o,i,t]),r.useEffect((()=>{o&&i!=null&&A&&t(tn({customerId:i}))}),[o,i,t,A]);const R=r.useCallback((O=>t(hn({id:O}))),[t]),U=ne(s.fetchState,s.isFormLoading,i,R);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCustomerDetailPage,isReady:d}),c.jsx(oa,{customerId:i??"",editView:s,hasLoadedRecord:E,location:n,navigate:e,tenantEmailDomain:a,onAddPaymentMethod:()=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentMethodAddClicked,{customerId:i??"",fromScreen:"customer_detail"}),t(oe()),i!=null&&A&&t(tn({customerId:i})),m(!0)},onCreatePromotionalCredits:()=>{t(ae()),p(!0)}},U),c.jsx(St,{errorMessage:j,isCreatingSetupIntent:b.fetchState==="In-Progress",isSaving:D.fetchState==="In-Progress",open:S,plaidLinkToken:s.record.plaidLinkToken,saveSucceeded:D.fetchState==="Completed",setupIntent:s.record.setupIntent,stripeConnected:A,onChooseCard:()=>{i!=null&&t(vi({customerId:i}))},onClose:()=>{m(!1),t(oe())},onSavePaymentMethod:O=>{i!=null&&(g.trackInvoicingActionClick(l.Event.invoicingPaymentMethodSaved,{customerId:i,fromScreen:"customer_detail"}),t(mi({customerId:i,data:O})))}}),c.jsx(ft,{currentBalance:s.record.invoicingCustomer?.promotionalCredits,currencyCode:s.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:y.fetchState==="Error"?y.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:y.fetchState==="In-Progress",open:v,submitSucceeded:y.fetchState==="Completed",onClose:()=>{p(!1),t(ae())},onSubmit:({amount:O,description:ie})=>{i!=null&&(g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsAdded,{amount:O,customerId:i,fromScreen:"customer_detail"}),t(pi({amount:O,customerId:i,currencyCode:s.record.invoicingCustomer?.preferredCurrencyCode,description:ie})))}})]})}const ca=T((function(t,e){const n=Be(t,e.customerId);return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save customer.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,savedCustomer:n.record.invoicingCustomer}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,a=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>e.navigate(a),onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerFormCancelled),t(En({id:i})),t(Ie(me)),e.navigate(`${n}/customers`)},onChange:o=>{t($e({id:i,localData:o}))},onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"customer",fromScreen:"customer_form"});const o=Jn(e.tenantEmailDomain??"",me,i),s=ee(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(o,{state:{pathnameStackToGoBack:s}})},onSubmit:()=>{t(kn({id:i}))}}}),(function({savedCustomer:t,...e},n,i){return{...i,...e,...n,onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerSaved,{customerId:i.customerId,mode:e.mode,...B(e.localData,t!=null?Cn(t):void 0,Yn)}),n.onSubmit()}}}))(ht);function sa(){const t=L(),e=P(),n=X(),{customer_id:i,tenantEmailDomain:a}=w(),{areTenantIdsInSync:o}=F(),{fetchState:s,savedCustomerId:u}=k((d=>Be(d,i)));return r.useEffect((()=>{o&&i!=null&&t(hn({id:i}))}),[o,i,t]),r.useEffect((()=>{if(s==="Completed"){const d=u??i,S=d!=null?`/${a}/invoicing/customers/${encodeURIComponent(d)}`:`/${a}/invoicing/customers`;e(S),t(En({id:i}))}}),[s,u,i,t,e,a]),c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCustomerFormPage}),c.jsx(ca,{customerId:i,location:n,navigate:e,tenantEmailDomain:a})]})}const ra=T((function(t){const e=fe(t),{fetchState:n}=e;return{addressesById:t.addressState.addressesById,columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",customers:e.customers,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.customers.length===0,isLoadingMore:n==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,a)=>{switch(a){case"createInvoice":g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":g.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":g.trackInvoicingActionClick(l.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"customers",status:e.activeStatus}),t(yn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Ct);function da(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,S]=r.useState(null),m=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),v=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,customerListFetchState:h}=k((D=>{const b=fe(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,customerListFetchState:b.fetchState}}),Q),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(be({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(v.search!==f||m?.field!==I?.field||m?.dir!==I?.dir)&&t(be({cacheOverride:!0,filters:v,sort:m}))}),[i,t,v,m,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingCustomersListPage,isReady:y}),c.jsx(ra,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:d,filters:v,sort:m,nextCursor:E,onSearchChange:o,onStatusChange:D=>{t(hi(D)),t(be({cacheOverride:!1,filters:v,sort:m}))},onSortChange:S})]})}const Te=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),la=T((function(t,e){const{authParams:n,csvDownloadUrl:i,filters:a,sessionId:o,view:s}=e,u=o==null?void 0:s.diagnosticsBySession[o],d=u?.fetch.fetchState??"Not-Started";return{authParams:n,csvDownloadUrl:i,diagnostics:u?.items??[],errorMessage:d==="Error"?u?.fetch.error?.message:void 0,expired:u?.expired??!1,filters:a,hasMore:u?.nextCursor!=null,isLoading:d==="Not-Started"||d==="In-Progress",isLoadingMore:d==="In-Progress"&&(u?.items.length??0)>0,session:Te(s,o)}}),(function(t,e){const{filters:n,navigate:i,sessionId:a,tenantEmailDomain:o,view:s}=e,u=a==null?void 0:s.diagnosticsBySession[a],d=Te(s,a),S=s.actionStateByKind.retry?.fetchState==="In-Progress",m=s.actionStateByKind.rollback?.fetchState==="In-Progress",v=d?.status==="done"&&d.rollback_available_until!=null&&new Date(d.rollback_available_until).getTime()>Date.now()&&!m;return{onBack:()=>i(`/${o}/invoicing/data_import`),onDownloadCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"download_csv",fromScreen:"data_import_detail",sessionId:a})},onDownloadError:()=>{t(Ve({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{a!=null&&u?.nextCursor!=null&&t(Re({...n,cursor:u.nextCursor,sessionId:a}))},onRetry:d?.status!=="failed"||S?void 0:()=>{a!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_detail",sessionId:a}),t(qe(a)))},onRollback:v?()=>{a!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"rollback",fromScreen:"data_import_detail",sessionId:a}),t(bn(a)))}:void 0}}))(kt);function ua(){const t=L(),e=P(),{sessionId:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),[o,s]=r.useState({}),u=k(He),d=k(he),S=r.useMemo((()=>{const E=J.getSignedInUser();return{userId:E?.userId??"",sessionId:E?.zeniSessionId??"",tenantId:d.tenantId}}),[d.tenantId]),m=Te(u,n),v=n==null?void 0:u.diagnosticsBySession[n];r.useEffect((()=>{a&&n!=null&&t(we(n))}),[a,t,n]),r.useEffect((()=>{if(!a||n==null)return;const E=setTimeout((()=>{t(Re({...o,sessionId:n}))}),300);return()=>clearTimeout(E)}),[a,t,o,n]);const p=m?.status==="scanning"||m?.status==="importing";r.useEffect((()=>{if(!a||n==null||!p)return;const E=setInterval((()=>{t(we(n)),t(Re({...o,sessionId:n}))}),3e3);return()=>clearInterval(E)}),[a,t,o,p,n]);const f=r.useMemo((()=>{if(n==null)return"";const E=new URLSearchParams;o.moduleId!=null&&E.set("module_id",o.moduleId),o.level!=null&&E.set("level",o.level),o.outcome!=null&&E.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&E.set("search",o.search.trim());const h=E.toString();return`${de?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${h===""?"":`?${h}`}`}),[o,n]),I=v?.fetch.fetchState??"Not-Started";return N(I)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingDataImportDetailPage,isReady:m!=null&&I!=="Not-Started"}),c.jsx(la,{authParams:S,csvDownloadUrl:f,filters:o,navigate:e,sessionId:n,tenantEmailDomain:i,view:u,onFiltersChange:s})]})}const Zn=t=>`invoicing_active_migration:${t}`,re=(t,e)=>{if(t!=null&&t!=="")try{const n=Zn(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},ga=T((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:a,statusRows:o}=e.view;return{isLoading:!(a.fetchState!=="Not-Started"&&a.fetchState!=="In-Progress"||o.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:o}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,a=o=>{const s=o??null;t(se(s)),re(i,s),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),a(o)},onNewImport:()=>{g.trackInvoicingActionClick(l.Event.invoicingNewImportClicked),a()},onRetrySession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),t(qe(o)),a(o)},onRollbackSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),t(bn(o))},onViewSession:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),n(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(Et);function ma(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),a=k(He);r.useEffect((()=>{i&&(t(Ci()),t(xn()))}),[i,t]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingDataImportHubPage,isReady:o}),c.jsx(ga,{navigate:e,tenantEmailDomain:n,view:a})]})}const va=T((function(t,e){const{activeId:n,authParams:i,integrationsView:a,settings:o,templatesDownloadUrl:s,view:u}=e,{actionStateByKind:d,sessionDetail:S,sessions:m}=u,v=a.externalConnections?.revenue?.find((f=>f.connectionName==="chargebee")),p=n!=null?S[n]:void 0;return{authParams:i,templatesDownloadUrl:s,chargebeeConnected:o?.chargebee_connected===!0||(v?.isValid??!1),chargebeeConnectorAvailable:v!=null,chargebeeSite:o?.chargebee_site,connectError:d.connect?.error?.message,connecting:d.connect?.fetchState==="In-Progress",retrying:d.retry?.fetchState==="In-Progress",session:p??m.find((f=>f.id===n)),starting:d.start?.fetchState==="In-Progress",uploading:d.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:a}=e;return{onBack:e.onBack,onDownloadError:()=>{t(Ve({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onDownloadTemplates:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportTemplatesDownloaded)},onFetchFromChargebee:()=>{g.trackInvoicingActionClick(l.Event.invoicingChargebeeConnectClicked),t(yi())},onGoToIntegrations:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"settings_integrations"}),i(`/${a}/invoicing/settings`)},onGoToOverview:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"overview"}),i(`/${a}/invoicing/overview`)},onRetry:()=>{n!=null&&(g.trackInvoicingActionClick(l.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_migrate",sessionId:n}),t(qe(n)))},onSaveLater:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportStarted),n!=null&&t(Ei(n))},onUpload:o=>{g.trackInvoicingActionClick(l.Event.invoicingImportFileUploaded),t(ki({files:o}))},onViewDetails:n==null?void 0:()=>i(`/${a}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(yt);function pa(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),a=k(Sn),o=k(he),s=r.useMemo((()=>{const h=J.getSignedInUser();return{userId:h?.userId??"",sessionId:h?.zeniSessionId??"",tenantId:o.tenantId}}),[o.tenantId]),u=`${de?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/templates`,d=o.companyId??J.getSignedInUserTenant(n??"")?.companyId,S=k((h=>An(h,d))),m=k(He),{activeMigrationSessionId:v}=m,p=v??void 0,f=p!=null?m.sessionDetail[p]??m.sessions.find((h=>h.id===p)):void 0;r.useEffect((()=>{i&&(t(Qe()),t(xn()))}),[i,t]),r.useEffect((()=>{if(v!=null)return;const h=(y=>{if(y==null||y==="")return null;try{return sessionStorage.getItem(Zn(y))}catch{return null}})(n);h!=null&&t(se(h))}),[v,t,n]),r.useEffect((()=>{re(n,v)}),[v,n]);const I=f?.status,E=I==="scanning"||I==="importing";return r.useEffect((()=>{if(!i||p==null||!E)return;const h=setInterval((()=>{t(we(p))}),3e3);return()=>clearInterval(h)}),[i,p,E,t]),r.useEffect((()=>{I==="done"&&(t(se(null)),re(n,null))}),[t,I,n]),c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingDataImportMigratePage}),c.jsx(va,{activeId:p,authParams:s,integrationsView:S,navigate:e,settings:a,templatesDownloadUrl:u,tenantEmailDomain:n,view:m,onBack:()=>{t(se(null)),re(n,null),e(`/${n}/invoicing/data_import`)}})]})}const Sa=T((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,discountsAccountName:n.discountsAccountName,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${n}/discounts`),onLifecycleAction:a=>{g.trackInvoicingActionClick(l.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discount_detail",status:e.editView.coupon?.status}),t(Dn({action:a,id:i}))},onSaveEdit:a=>{const{coupon:o}=e.editView;g.trackInvoicingActionClick(l.Event.invoicingCouponEdited,{couponId:i,mode:"edit",...B(a,{invoice_name:o?.invoiceName,invoice_notes:o?.invoiceNotes,max_redemptions:o?.maxRedemptions,name:o?.name},["invoice_notes"])}),t(xi({data:a,id:i}))}}}))(bt);function fa(){const t=L(),e=P(),{coupon_id:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),o=k((I=>bi(I,n))),s=o.actionState.fetchState==="In-Progress",u=o.pageFetchState.fetchState,d=u==="Completed",[S,m]=r.useState(d?n:void 0);r.useEffect((()=>{n!=null&&d&&m(n)}),[n,d]);const v=S===n;r.useEffect((()=>(t(ge({id:n})),()=>{t(ge({id:n}))})),[n,t]),r.useEffect((()=>{a&&t(_e({id:n}))}),[a,n,t]);const p=r.useCallback((I=>t(_e({cacheOverride:!0,id:I}))),[t]),f=ne(o.fetchState,o.isFormLoading,n,p);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingDiscountDetailPage,isReady:d}),c.jsx(Sa,{hasLoadedRecord:v,couponId:n??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:s,navigate:e,tenantEmailDomain:i},f)]})}const Ia=T((function(t){const e=jn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,discountLifecycleActionOptions:e.discountLifecycleActionOptions,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",coupons:e.coupons,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.coupons.length===0,isLoadingMore:n==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,a)=>{g.trackInvoicingActionClick(l.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discounts_list"}),t(Dn({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"discounts",status:e.activeStatus}),t(Di({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(xt);function ha(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,S]=r.useState(null),m=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),v=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,couponListFetchState:h,runningDiscountActionId:y}=k((b=>{const A=jn(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,couponListFetchState:A.fetchState,runningDiscountActionId:A.runningActionId??null}}),Q),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(xe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(v.search!==f||m?.field!==I?.field||m?.dir!==I?.dir)&&t(xe({cacheOverride:!0,filters:v,sort:m}))}),[i,t,v,m,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingDiscountsListPage,isReady:D}),c.jsx(Ia,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:d,filters:v,sort:m,nextCursor:E,runningDiscountActionId:y,onSearchChange:o,onStatusChange:b=>{t(Ai(b)),t(xe({cacheOverride:!1,filters:v,sort:m}))},onSortChange:S})]})}const Ca=T((function(t,e){const{readView:n}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:n.dunningCase,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress",step:n.step}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,a=i!=="",{dunningCase:o}=e.readView,s={amount:o?.amount?.amount,caseId:i,customerId:o?.customerID,invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID};return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:u=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:u,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(u)}`)},onCancel:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"cancel",fromScreen:"dunning_detail"}),t(z({action:"cancel",id:i}))}:void 0,onResolve:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"resolve",fromScreen:"dunning_detail"}),t(z({action:"resolve",id:i}))}:void 0,onResume:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"resume",fromScreen:"dunning_detail"}),t(z({action:"resume",id:i}))}:void 0,onRetry:a?()=>{g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...s,action:"retry",fromScreen:"dunning_detail"}),t(z({action:"retry",id:i}))}:void 0}}))(Dt);function ka(){const t=L(),e=P(),{case_id:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),o=k((C=>ji(C,n??""))),s=o.fetchState==="Completed",u=o.dunningCase?.invoiceID,[d,S]=r.useState("idle"),[m,v]=r.useState(!1),[p,f]=r.useState(),[I,E]=r.useState(!1),h=r.useCallback((()=>{S("idle"),v(!1),f(void 0),E(!1)}),[]),y=r.useCallback((()=>{if(n==null)return;t(Li({id:n})),S("idle"),v(!1);const C=o.emailPreview.preview;f(C==null?void 0:{body:C.body,cc:C.cc,subject:C.subject,to:C.to}),E(!0)}),[n,t,o.emailPreview.preview]),D=r.useCallback((C=>{n!=null&&d!=="pending"&&(v(!1),S("pending"),g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{action:"send-email",amount:o.dunningCase?.amount?.amount,caseId:n,customerId:o.dunningCase?.customerID,fromScreen:"dunning_detail",invoiceId:o.dunningCase?.invoiceID,status:o.dunningCase?.status,subscriptionId:o.dunningCase?.subscriptionID}),t(z({action:"send-email",body:C,id:n})))}),[n,t,d,o.dunningCase]),b=r.useMemo((()=>o.emailPreview.preview==null?void 0:{bodyToken:o.emailPreview.preview.bodyToken,renderedHtmlTemplate:o.emailPreview.preview.renderedHtmlTemplate,subjectToken:o.emailPreview.preview.subjectToken}),[o.emailPreview.preview]);r.useEffect((()=>{a&&n!=null&&t(Pi({id:n}))}),[a,n,t]),r.useEffect((()=>{a&&u!=null&&t(Ce({invoiceId:u}))}),[a,u,t]),r.useEffect((()=>{S("idle"),v(!1),f(void 0),E(!1)}),[n]),r.useEffect((()=>{a||(S("idle"),v(!1),f(void 0),E(!1))}),[a]),r.useEffect((()=>{I&&p==null&&o.emailPreview.preview!=null&&f({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,p,I]),r.useEffect((()=>{d==="pending"&&(o.actionState.fetchState!=="In-Progress"?m&&o.actionState.fetchState==="Completed"?(n!=null&&t(_i({id:n})),h()):m&&o.actionState.fetchState==="Error"&&S("failed"):v(!0))}),[n,h,t,d,m,o.actionState.fetchState]);const A=u!=null&&o.linkedInvoice?.id===u?o.linkedInvoice.dunningAttempts:void 0;return N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingDunningDetailPage,isReady:s}),c.jsx(Ca,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:o,dunningAttempts:A,onSendEmail:y}),c.jsx(At,{initialDraft:p,isPreviewLoading:o.emailPreview.fetchState==="Not-Started"||o.emailPreview.fetchState==="In-Progress",isSending:d==="pending",onClose:h,onSend:D,open:I,preview:b,previewErrorMessage:o.emailPreview.fetchState==="Error"?o.emailPreview.error?.message:void 0,sendErrorMessage:d==="failed"?o.actionState.error?.message:void 0})]})}const Ea=T((function(t){const e=Ln(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:n==="In-Progress"&&e.dunningCases.length>0,stepById:e.stepById,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=a=>{const o=e.dunningCases.find((s=>s.id===a));return{amount:o?.amount?.amount,caseId:a,customerId:o?.customerID,fromScreen:"dunning_list",invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID}};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${n}/data_import`),onDunningCaseClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingDunningCaseRowClicked,i(a)),e.navigate(`${n}/dunning/${encodeURIComponent(a)}`)},onRowAction:(a,o)=>{o!=="retry"&&o!=="resume"&&o!=="resolve"&&o!=="cancel"||(g.trackInvoicingActionClick(l.Event.invoicingDunningAction,{...i(a),action:o}),t(z({action:o,id:a})))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"dunning",status:e.activeStatus}),t(wi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(jt);function ya(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,S]=r.useState(null),m=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),v=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,dunningCaseListFetchState:h,dunningCases:y}=k((b=>{const A=Ln(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,dunningCaseListFetchState:A.fetchState,dunningCases:A.dunningCases}}),Q),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(Ae({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(v.search!==f||m?.field!==I?.field||m?.dir!==I?.dir)&&t(Ae({cacheOverride:!0,filters:v,sort:m}))}),[i,t,v,m,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingDunningListPage,isReady:D}),c.jsx(Ea,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:d,filters:v,sort:m,dunningCases:y,nextCursor:E,onSearchChange:o,onStatusChange:b=>{t($i(b)),t(Ae({cacheOverride:!1,filters:v,sort:m}))},onSortChange:S})]})}const ba=T((function(t,e){const{view:n}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:n.billingAddress,invoice:n.invoice,invoiceId:e.invoiceId,shippingAddress:n.shippingAddress,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isSaving:n.actionState.fetchState==="In-Progress",isVoiding:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e,{invoice:a}=e.view,o={amount:a?.total?.amount,customerId:a?.customerID,invoiceId:i,status:a?.status};return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(s)}`)},onIssueCreditNote:()=>{g.trackInvoicingActionClick(l.Event.invoicingIssueCreditNoteClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{g.trackInvoicingActionClick(l.Event.invoicingRecordPaymentClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceRegenerated,{...o,fromScreen:"invoice_detail"}),t(q({action:"regenerate",invoiceId:i}))},onSaveEdit:s=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceEdited,{...o,fromScreen:"invoice_detail",mode:"edit",...B(s,{due_date:a?.dueDate?.format("YYYY-MM-DD")??"",notes:(a?.notes??[]).map((u=>u.note)).filter((u=>u!=null&&u!=="")).join(`
2
2
  `),po_number:a?.poNumber??""},["notes"])}),t(Fi({data:{due_date:s.due_date!==""?s.due_date:void 0,notes:s.notes.trim()!==""?s.notes.split(`
3
3
  `).map((u=>u.trim())).filter((u=>u!=="")).map((u=>({note:u}))):void 0,po_number:s.po_number!==""?s.po_number:null},invoiceId:i}))},onSendReminder:()=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceReminderSent,{...o,fromScreen:"invoice_detail"}),t(q({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:s,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(s)}`)},onVoid:s=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,{...o,fromScreen:"invoice_detail"}),t(q({action:"void",invoiceId:i,body:s}))}}}))(Lt);function xa(){const t=L(),e=P(),{invoice_id:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),o=k((f=>Pn(f,n??""))),s=o.pageFetchState.fetchState,u=s==="Completed",[d,S]=r.useState(u?n:void 0);r.useEffect((()=>{n!=null&&u&&S(n)}),[n,u]);const m=d===n;r.useEffect((()=>{a&&n!=null&&t(Ri({invoiceId:n}))}),[a,n,t]);const v=r.useCallback((f=>t(Ce({invoiceId:f}))),[t]),p=ne(o.actionState.fetchState,o.fetchState==="In-Progress",n,v);return N(s)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingInvoiceDetailPage,isReady:u}),c.jsx(ba,{invoiceId:n??"",hasLoadedRecord:m,navigate:e,tenantEmailDomain:i,view:o},p)]})}const Aa=T((function(t){const e=_n(t),{fetchState:n}=e;return{counts:e.counts,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,invoices:e.invoices,statusOptions:e.statusOptions,isLoading:n==="Not-Started"||n==="In-Progress"&&e.invoices.length===0,isLoadingMore:n==="In-Progress"&&e.invoices.length>0,kpis:e.kpis,kpisLoading:e.kpisFetchState.fetchState==="Not-Started"||e.kpisFetchState.fetchState==="In-Progress"&&e.kpis==null,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=a=>{const o=e.invoices.find((s=>s.id===a));return{amount:o?.total?.amount,customerId:o?.customerID,fromScreen:"invoices_list",invoiceId:a,status:o?.status}};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onCreateInvoice:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreateInvoiceClicked),e.navigate(`${n}/invoices/create`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"invoices"}),e.navigate(`${n}/data_import`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceRowClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onRowAction:(a,o)=>{switch(o){case"recordPayment":g.trackInvoicingActionClick(l.Event.invoicingRecordPaymentClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}/record-payment`);break;case"issueCreditNote":g.trackInvoicingActionClick(l.Event.invoicingIssueCreditNoteClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}/issue-credit-note`);break;case"sendReminder":g.trackInvoicingActionClick(l.Event.invoicingInvoiceReminderSent,i(a)),t(q({action:"send-reminder",invoiceId:a}));break;case"regenerate":g.trackInvoicingActionClick(l.Event.invoicingInvoiceRegenerated,i(a)),t(q({action:"regenerate",invoiceId:a}));break;case"void":g.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,i(a)),t(q({action:"void",invoiceId:a}))}},onVoidInvoice:(a,o)=>{g.trackInvoicingActionClick(l.Event.invoicingInvoiceVoided,i(a)),t(q({action:"void",invoiceId:a,body:o}))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"invoices",status:e.activeStatus}),t($n({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Pt);function Da(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,S]=r.useState(null),m=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),v=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,invoiceListFetchState:h,voidingInvoiceId:y,invoices:D}=k((A=>{const C=_n(A);return{activeStatus:C.activeTab,appliedSearch:C.filters.search,appliedSort:A.invoicingInvoiceListState.sort,nextCursor:C.nextCursor,invoiceListFetchState:C.fetchState,voidingInvoiceId:C.runningActionId,invoices:C.invoices}}),Q),b=h==="Completed";return r.useEffect((()=>{const A=setTimeout((()=>u(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&t(De({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(v.search!==f||m?.field!==I?.field||m?.dir!==I?.dir)&&t(De({cacheOverride:!0,filters:v,sort:m}))}),[i,t,v,m,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingInvoicesListPage,isReady:b}),c.jsx(Aa,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:d,filters:v,sort:m,invoices:D,nextCursor:E,voidingInvoiceId:y,onSearchChange:o,onStatusChange:A=>{t(Oi(A)),t(De({cacheOverride:!1,filters:v,sort:m}))},onSortChange:S})]})}function sn(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),i=_t(),a=un(),[o,s]=r.useState(!1),{acceptTermsState:u,status:d}=k(wn),S=Ti(i?.loggedInUserRoleMap),m=`/${n}/invoicing`,v=p=>{s(p)};return d==="completed"?c.jsx(H,{to:`${m}/overview`,replace:!0}):d==="settings"&&S?c.jsx(H,{to:`${m}/settings`,replace:!0}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingPromoPage}),c.jsx(Mo,{isAppContentDrawerOpen:o,handleDrawerToggle:v}),c.jsx($t,{analytics:g,isAccepting:u.fetchState==="In-Progress",isReadOnlyUser:!S,meetingUrl:a("invoicing_promo"),onAcceptClick:()=>{g.trackInvoicingActionClick(l.Event.invoicingTermsAccepted),t(Mi())},onBackClick:()=>{e(`/${n}`)},onClickMenuIcon:()=>{v(!0)}})]})}const ja=T((function(t,e){const n=Rn(t,e.invoiceId),{invoice:i,localData:a,reasonCodeOptions:o,submitState:s,typeOptions:u}=n;return{fieldHelp:n.fieldHelp,amountDue:i?.amountDue,currencyCode:i?.currencyCode??"USD",customerName:i?.customerName??"",errorMessage:s.fetchState==="Error"?s.error?.message??"Failed to issue credit note. Please try again.":void 0,invoiceNumber:i?.invoiceNumber??e.invoiceId,isSubmitting:s.fetchState==="In-Progress",localData:a,reasonCodeOptions:o,typeOptions:u}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing/invoices/${encodeURIComponent(e.invoiceId)}`,i=()=>e.navigate(n);return{onBack:i,onCancel:i,onChange:a=>{t(Hi({localData:a}))},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingCreditNoteIssued,{invoiceId:e.invoiceId}),t(Vi())}}}))(wt);function La(){const t=L(),e=P(),{invoice_id:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),{fetchState:o,invoice:s,isPageReady:u,issuedCreditNoteId:d,submitState:S}=k((f=>Rn(f,n??""))),m=`/${i}/invoicing`,v=r.useRef(null);r.useEffect((()=>{t(Ni()),v.current=null}),[t,n]),r.useEffect((()=>{a&&n!=null&&t(Ce({invoiceId:n}))}),[a,t,n]),r.useEffect((()=>{s!=null&&n!=null&&o==="Completed"&&v.current!==n&&(v.current=n,t(Ui({localData:Bi(s)})))}),[t,o,s,n]);const p=r.useRef(S.fetchState);return r.useEffect((()=>{const f=p.current;p.current=S.fetchState,f!=="Completed"&&S.fetchState==="Completed"&&d!=null&&e(`${m}/credits/${encodeURIComponent(d)}`)}),[d,e,S.fetchState,m]),c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingIssueCreditNotePage,isReady:u}),c.jsx(ja,{invoiceId:n??"",navigate:e,tenantEmailDomain:i})]})}const Pa=T((function(t){return{invoicingOverview:Fn(t)}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onRefresh:()=>{g.trackInvoicingActionClick(l.Event.invoicingOverviewRefreshed),t(On(e.selectedPeriod,!0))},onSubscriptionClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionTileClicked,{subscriptionId:i}),e.navigate(`${n}/subscriptions/${i}`)},onViewInvoices:()=>{g.trackInvoicingActionClick(l.Event.invoicingViewInvoicesClicked),e.navigate(`${n}/invoices`)},onViewPayments:()=>{g.trackInvoicingActionClick(l.Event.invoicingViewPaymentsClicked),e.navigate(`${n}/payments`)}}}))(Rt);function _a(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a]=r.useState((()=>{const s=new Date;return{month:s.getMonth()+1,year:s.getFullYear()}})),o=k((s=>Fn(s).fetchState))==="Completed";return r.useEffect((()=>{i&&t(On(a))}),[i,t,a]),c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingOverviewPage,isReady:o}),c.jsx(Pa,{navigate:e,selectedPeriod:a,tenantEmailDomain:n})]})}const $a=T((function(t){const e=Tn(t),{fetchState:n}=e;return{columns:e.columns,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.transactions.length===0,isLoadingMore:n==="In-Progress"&&e.transactions.length>0,tabIds:e.tabIds,transactions:e.transactions}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeType:e.activeType,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTypeChange:e.onTypeChange,onViewTransactionCustomer:e.onViewTransactionCustomer,onViewTransactionInvoice:e.onViewTransactionInvoice,onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"payments"}),e.navigate(`${n}/data_import`)},onTransactionClick:i=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentRowClicked,{transactionId:i}),e.navigate(`${n}/payments/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"payments",tab:e.activeType}),t(Qi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Ft);function wa(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,S]=r.useState(null),m=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),v=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeType:p,appliedSearch:f,appliedSort:I,nextCursor:E,transactionListFetchState:h,transactions:y}=k((j=>{const R=Tn(j);return{activeType:R.activeTab,appliedSearch:R.filters.search,appliedSort:R.sort,nextCursor:R.nextCursor,transactionListFetchState:R.fetchState,transactions:R.transactions}}),Q),D=h==="Completed",b=`/${n}/invoicing`,A=r.useCallback((j=>{const R=y.find((O=>O.id===j)),U=R?.linkedInvoices?.[0]?.invoiceID??R?.invoiceID;U!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"payments_list",invoiceId:U,toScreen:"invoice"}),e(`${b}/invoices/${encodeURIComponent(U)}`))}),[e,b,y]),C=r.useCallback((j=>{const R=y.find((U=>U.id===j))?.customerID;R!=null&&(g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:R,fromScreen:"payments_list",toScreen:"customer"}),e(`${b}/customers/${encodeURIComponent(R)}`))}),[e,b,y]);return r.useEffect((()=>{const j=setTimeout((()=>u(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t(je({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(v.search!==f||m?.field!==I?.field||m?.dir!==I?.dir)&&t(je({cacheOverride:!0,filters:v,sort:m}))}),[i,t,v,m,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingPaymentsListPage,isReady:D}),c.jsx($a,{navigate:e,tenantEmailDomain:n,activeType:p,searchValue:a,sortState:d,filters:v,sort:m,nextCursor:E,onSearchChange:o,onTypeChange:j=>{t(qi(j)),t(je({cacheOverride:!1,filters:v,sort:m}))},onSortChange:S,onViewTransactionCustomer:C,onViewTransactionInvoice:A})]})}const Ra=t=>{const e=[t.firstName,t.lastName].filter((n=>n!=null&&n.trim()!=="")).join(" ").trim();return(t.company!=null&&t.company.trim()!==""?t.company.trim():"")||e||(t.email!=null&&t.email.trim()!==""?t.email.trim():"")||t.id};function rn(){const t=L(),e=P(),{invoice_id:n,tenantEmailDomain:i}=w(),{areTenantIdsInSync:a}=F(),o=n!=null&&n!=="",s=k(fe),u=k((C=>zi(C))),d=k(Ki),S=k((C=>Pn(C,n??""))),m=S.invoice,v=`/${i}/invoicing`,p=r.useRef(null),f=r.useRef("");r.useEffect((()=>{t(Gi()),p.current=null,f.current=""}),[t,n]),r.useEffect((()=>{a&&t(o&&n!=null?Ce({invoiceId:n}):yn({filters:{},keepExistingListItems:!1}))}),[a,t,n,o]),r.useEffect((()=>{o&&m!=null&&n!=null&&S.fetchState==="Completed"&&p.current!==n&&(p.current=n,t(Wi({contextInvoiceId:n,localData:Yi(m)})))}),[t,m,n,S.fetchState,o]),r.useEffect((()=>{if(o)return;const C=u.localData.customerId;C!==""&&C!==f.current&&(f.current=C,t($n({filters:{customerId:C},keepExistingListItems:!1})),u.localData.invoiceToLink!==""&&t(on({localData:{...u.localData,customerId:C,invoiceToLink:""}})))}),[t,u.localData,o]);const I=r.useRef(d.fetchState);r.useEffect((()=>{const C=I.current;if(I.current=d.fetchState,C!=="Completed"&&d.fetchState==="Completed"){if(d.recordedInvoiceId!=null)return void e(`${v}/invoices/${encodeURIComponent(d.recordedInvoiceId)}`);e(`${v}/payments`)}}),[e,d.fetchState,d.recordedInvoiceId,v]);const E=r.useMemo((()=>s.customers.map((C=>({id:C.id,name:Ra(C)})))),[s.customers]),h=k((C=>Ji(C,u.localData.customerId))),y=r.useMemo((()=>h.map((C=>{return{amountDue:(j=C.amountDue,R=Zi.currencySymbol,Mt("0,0.00",j,R)),amountDueValue:C.amountDue,id:C.id,label:C.invoiceNumber};var j,R}))),[h]),D=r.useMemo((()=>{if(!o||m==null)return;const C=m.currencyCode??"USD",j=m.amountDue?.amount??0;return{amountDue:Ot("0,0.00",m.amountDue),amountDueValue:j,currencyCode:C,customerName:m.customerName??m.customerID,invoiceId:m.id,invoiceNumber:m.invoiceNumber??m.id}}),[m,o]),b=o?`${v}/invoices/${encodeURIComponent(n??"")}`:`${v}/payments`,A=!o||S.fetchState==="Completed"&&u.localData.invoiceToLink!=="";return c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingRecordPaymentPage,isReady:A}),c.jsx(Tt,{customers:E,fieldHelp:u.fieldHelp,errorMessage:d.fetchState==="Error"?d.error?.message??"Failed to record payment. Please try again.":void 0,gatewayOptions:u.gatewayOptions,invoiceContext:D,invoiceOptions:y,isSubmitting:d.fetchState==="In-Progress",localData:u.localData,mode:o?"invoice":"customer",paymentMethodOptions:u.paymentMethodOptions,onBack:()=>{e(b)},onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingRecordPaymentCancelled),e(b)},onChange:C=>{t(on({localData:C}))},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingPaymentRecorded,{customerId:u.localData.customerId,invoiceId:o?n:u.localData.invoiceToLink,paymentMethod:u.localData.paymentMethod}),t(Xi(o?n??void 0:void 0))}})]})}const Xn=(t,e,n)=>{const i=`/${t}/invoicing/subscriptions/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},Fa=T((function(t,e){const{editView:n}=e,i=n.subscription,a=i?.status,o=a!=null&&e.commercialEditAllowedFromStatuses.includes(a);return{cancelReasonCodeOptions:n.cancelReasonCodeOptions,fieldHelp:n.fieldHelp,addons:n.addons,canEditCommercial:o,charges:n.charges,coupons:n.coupons,estimate:n.estimate,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),isRunningAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",lifecycleActionOptions:e.lifecycleActionOptions,localData:n.localData,plans:n.plans,shippingAddressLabel:n.shippingAddressLabel,hasUnsavedShippingAddress:n.hasUnsavedShippingAddress,subscription:i}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,a=i!=="",o=(s,u)=>{const{subscription:d}=e.editView;g.trackInvoicingActionClick(l.Event.invoicingSubscriptionLifecycleAction,{action:s,amount:d?.mrr?.amount,customerId:d?.customerID,fromScreen:"subscription_detail",status:d?.status,subscriptionId:i}),t(Bn({action:s,id:i,body:u}))};return{onBack:()=>e.navigate(`${n}/subscriptions`),onChange:s=>{t(Y({id:i,localData:s}))},onChangeTermEnd:a?s=>{const u=s?.trim()??"";u!==""&&o("change_term_end",{term_ends_at:u})}:void 0,onCustomerClick:s=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${n}/customers/${encodeURIComponent(s)}`,"_blank","noopener,noreferrer")},onDiscardEdit:()=>{t(Ie(ve)),t(to({id:i}))},onOpenAddress:()=>{const s=Xn(e.tenantEmailDomain??"",ve,i),u=ee(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(s,{state:{pathnameStackToGoBack:u}})},onViewInvoices:()=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"subscription_detail",subscriptionId:i,toScreen:"invoices"}),e.navigate(`${n}/invoices`)},onCloseEstimate:()=>{t(Un())},onRequestEstimate:s=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionEstimateCalculation,{mode:"edit",subscriptionId:i,...B(s,Fe(e.editView.subscription))}),t(Y({id:i,localData:s})),t(Nn({id:i}))},onSaveEdit:s=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionEdited,{mode:"edit",subscriptionId:i,...B(s,Fe(e.editView.subscription))}),t(Y({id:i,localData:s})),t(Mn({id:i}))},onCancelSubscription:a?s=>{o("cancel",{cancel_reason_code:s.cancelReasonCode,end_of_term:!1,...s.cancelReason!=null&&s.cancelReason.trim()!==""?{cancel_reason:s.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:a?(s,u)=>{s!=="pause"?o(s):o(s,u!=null&&u.trim()!==""?{resume_date:u.trim()}:void 0)}:void 0}}))(Nt);function Oa(){const t=L(),e=P(),n=X(),{subscription_id:i,tenantEmailDomain:a}=w(),{areTenantIdsInSync:o}=F(),s=k((y=>ze(y,i))),{subscriptionCommercialEditAllowedFromStatuses:u,subscriptionLifecycleActionOptions:d,subscriptionMetadataEditAllowedFromStatuses:S}=s,m=s.pageFetchState.fetchState,v=m==="Completed"&&!s.isFormLoading,[p,f]=r.useState(v?i:void 0);r.useEffect((()=>{i!=null&&v&&f(i)}),[i,v]);const I=p===i;ke(o),r.useEffect((()=>{o&&i!=null&&t(eo({id:i}))}),[o,i,t]);const E=r.useCallback((y=>t(no({id:y}))),[t]),h=ne(s.fetchState,s.isFormLoading,i,E);return N(m)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingSubscriptionDetailPage,isReady:v}),c.jsx(Fa,{hasLoadedRecord:I,commercialEditAllowedFromStatuses:u,editView:s,lifecycleActionOptions:d,location:n,metadataEditAllowedFromStatuses:S,navigate:e,subscriptionId:i??"",tenantEmailDomain:a},h)]})}const Ta=T((function(t,e){const n=ze(t,e.subscriptionId);return{fieldHelp:n.fieldHelp,addons:n.addons,charges:n.charges,coupons:n.coupons,customers:n.customers,estimate:n.estimate,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save subscription.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,plans:n.plans,savedSubscription:n.subscription,shippingAddressLabel:n.shippingAddressLabel}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e;return{onCancel:()=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionFormCancelled),t(Vn({id:i})),t(Ie(ve)),i==null?e.navigate(`${n}/subscriptions`):e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)},onChange:a=>{t(Y({id:i,localData:a}))},onCloseEstimate:()=>{t(Un())},onRequestEstimate:()=>{t(Nn({id:i}))},onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"subscription",fromScreen:"subscription_form"});const a=Xn(e.tenantEmailDomain??"",ve,i),o=ee(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onSubmit:()=>{t(Mn({id:i}))}}}),(function({savedSubscription:t,...e},n,i){const a=()=>({mode:e.mode,subscriptionId:i.subscriptionId,...B(e.localData,t!=null?Fe(t):void 0)});return{...i,...e,...n,onRequestEstimate:()=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionEstimateCalculation,a()),n.onRequestEstimate()},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionSaved,a()),n.onSubmit()}}}))(Ut);function Ma(){const t=L(),e=P(),n=X(),{subscription_id:i,tenantEmailDomain:a}=w(),[o]=Z(),{areTenantIdsInSync:s}=F(),u=o.get("customerId"),{fetchState:d,savedSubscriptionId:S}=k((p=>io(p,i))),m=k((p=>ze(p,i).localData));ke(s),r.useEffect((()=>{s&&t(oo({subscriptionId:i}))}),[s,i,t]);const v=r.useRef(!1);return r.useEffect((()=>{v.current||i!=null||u==null||u===""||m.customerId!==""||(v.current=!0,t(Y({id:i,localData:{...m,customerId:u}})))}),[u,i,m,t]),r.useEffect((()=>{if(d==="Completed"){const p=S??i,f=p!=null?`/${a}/invoicing/subscriptions/${encodeURIComponent(p)}`:`/${a}/invoicing/subscriptions`;e(f),t(Vn({id:i}))}}),[d,S,i,t,e,a]),c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingSubscriptionFormPage}),c.jsx(Ta,{location:n,navigate:e,subscriptionId:i,tenantEmailDomain:a})]})}const Na=T((function(t){const e=Hn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.subscriptions.length===0,isLoadingMore:n==="In-Progress"&&e.subscriptions.length>0,cancelReasonCodeOptions:e.cancelReasonCodeOptions,lifecycleActionOptions:e.subscriptionLifecycleActionOptions,subscriptions:e.subscriptions,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=(a,o,s)=>{const u=e.subscriptions.find((d=>d.id===a));g.trackInvoicingActionClick(l.Event.invoicingSubscriptionLifecycleAction,{action:o,amount:u?.mrr?.amount,customerId:u?.customerID,fromScreen:"subscriptions_list",status:u?.status,subscriptionId:a}),t(Bn({action:o,id:a,body:s}))};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onAddSubscription:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddSubscriptionClicked),e.navigate(`${n}/subscriptions/new`)},onImportCsv:()=>{g.trackInvoicingActionClick(l.Event.invoicingImportCsvClicked,{entity:"subscriptions"}),e.navigate(`${n}/data_import`)},onChangeTermEnd:(a,o)=>{const s=o?.trim()??"";s!==""&&i(a,"change_term_end",{term_ends_at:s})},onSubscriptionAction:(a,o,s)=>{o!=="pause"?i(a,o):i(a,o,s!=null&&s.trim()!==""?{resume_date:s.trim()}:void 0)},onCancelSubscription:(a,o)=>{i(a,"cancel",{cancel_reason_code:o.cancelReasonCode,end_of_term:!1,...o.cancelReason!=null&&o.cancelReason.trim()!==""?{cancel_reason:o.cancelReason.trim()}:{}})},onSubscriptionClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingSubscriptionRowClicked,{subscriptionId:a}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onViewSubscriptionInvoices:()=>{e.navigate(`${n}/invoices`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(l.Event.invoicingListLoadMore,{entity:"subscriptions",status:e.activeStatus}),t(so({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Bt);function Ua(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),[a,o]=r.useState(""),[s,u]=r.useState(""),[d,S]=r.useState(null),m=r.useMemo((()=>d!=null?{dir:d.direction,field:d.columnKey}:void 0),[d]),v=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,subscriptionListFetchState:h,runningActionSubscriptionId:y,subscriptions:D}=k((C=>{const j=Hn(C);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:j.sort,nextCursor:j.nextCursor,subscriptionListFetchState:j.fetchState,runningActionSubscriptionId:j.runningActionId??null,subscriptions:j.subscriptions}}),Q),b=h==="Completed";r.useEffect((()=>{const C=setTimeout((()=>u(a)),300);return()=>clearTimeout(C)}),[a]),r.useEffect((()=>{i&&t(Le({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(v.search!==f||m?.field!==I?.field||m?.dir!==I?.dir)&&t(Le({cacheOverride:!0,filters:v,sort:m}))}),[i,t,v,m,f,I]);const A=r.useRef(y);return r.useEffect((()=>{const C=A.current!=null&&y==null;A.current=y,C&&i&&t(ao())}),[y,i,t]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingSubscriptionsListPage,isReady:b}),c.jsx(Na,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:d,filters:v,sort:m,nextCursor:E,runningActionSubscriptionId:y,subscriptions:D,onSearchChange:o,onStatusChange:C=>{t(co(C)),t(Le({cacheOverride:!1,filters:v,sort:m}))},onSortChange:S})]})}const Ba=T((function(t,e){const{readView:n}=e;return{isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress",transaction:n.transaction,transactionId:e.transactionId}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{transactionId:i}=e;return{onBack:()=>e.navigate(`${n}/payments`),onCustomerClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"transaction_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(a)}`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onSubscriptionClick:a=>{g.trackInvoicingActionClick(l.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onCapture:i!==""?()=>{g.trackInvoicingActionClick(l.Event.invoicingTransactionCaptured,{transactionId:i}),t(uo({action:"capture",id:i}))}:void 0}}))(Vt);function Va(){const t=L(),e=P(),{tenantEmailDomain:n,transaction_id:i}=w(),{areTenantIdsInSync:a}=F(),o=k((u=>ro(u,i??""))),s=o.fetchState==="Completed";return r.useEffect((()=>{a&&i!=null&&t(lo({id:i}))}),[a,i,t]),N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingTransactionDetailPage,isReady:s}),c.jsx(Ba,{navigate:e,tenantEmailDomain:n,transactionId:i??"",readView:o})]})}function et(t={}){const{enabled:e=!0,fetchSyncHealth:n=!1,loadAccountingPickers:i=!1,reuseCached:a=!1}=t,o=L(),{areTenantIdsInSync:s}=F(),u=k(Ke),d=u.connection?.connected===!0,S=u.connectionFetchState.fetchState;return r.useEffect((()=>{e&&s&&(a&&S!=="Not-Started"||o(qn()),n&&o(go()))}),[s,o,e,n,a]),r.useEffect((()=>{e&&s&&d&&i&&o(mo())}),[s,o,e,d,i]),{isQboConnected:d,qboView:u}}const Ha={branding:"invoicing_branding_save",dunning:"invoicing_dunning_settings_save",quickbooks:"invoicing_qbo_settings_save"};function te(t){const e=L(),{areTenantIdsInSync:n}=F(),{tenantEmailDomain:i}=w(),{fetchState:a,fieldHelp:o,logoFile:s,saveState:u,settings:d,stripeConnectState:S}=k(vo),{configError:m,configFetchState:v,dunningScheduleActionOptions:p,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:I,qboSyncStatusOptions:E}=k(Qn),h=k(Ke);et({enabled:t==="quickbooks",fetchSyncHealth:!0,loadAccountingPickers:!0});const y=k(he),D=t==="dunning"||t==="quickbooks",b=y.companyId??J.getSignedInUserTenant(i??"")?.companyId,A=k((_=>An(_,b))),C=po(y.userRole??[]),j=y.tenantId??"",R=J.getSignedInUser(),U={userId:R?.userId??"",sessionId:R?.zeniSessionId??"",tenantId:j},O=s?.fileId,ie=k((_=>O!=null&&O!==""?So(_,O):void 0)),Ge=k((_=>O!=null&&O!==""?fo(_,O):void 0)),nt=O!=null&&O!==""&&ie!=null?{[O]:ie}:{},tt=O!=null&&O!==""&&Ge!=null?{[O]:Ge}:{};r.useEffect((()=>(e(an()),()=>{e(an())})),[e]),r.useEffect((()=>{n&&(a!=="Not-Started"&&a!=="Error"||e(Qe()))}),[n,e,a]),r.useEffect((()=>{n&&D&&v==="Not-Started"&&e(pe())}),[n,e,v,D]),r.useEffect((()=>{if(!n)return;const _=R?.userId;_!=null&&_!==""&&j!==""&&Je.shouldFetchActiveTenant(j)&&(Je.markActiveTenantFetchStarted(j),e(Io(_,j,R?.zeniSessionId)))}),[n,e,R?.userId,R?.zeniSessionId,j]);const it=p.length>0||f.length>0,ot=a==="Not-Started"||a==="In-Progress"&&d==null||D&&!it&&(v==="Not-Started"||v==="In-Progress"),at=a==="Completed"&&(!D||v==="Completed"),We=A.externalConnections?.revenue?.find((_=>_.connectionName==="chargebee"))?.connectionId,Ee=de?.invoicingMicroServiceBaseUrl,Ye=Ee!=null&&Ee.length>0?`${Ee}/1.0/webhooks/stripe`:"",K={deleteConnectionError:A.externalConnections?.deleteConnectionError?.message,deleteConnectionState:A.externalConnections?.deleteConnectionState??"Not-Started",integrationsView:A,isAdmin:C,isStripeBusy:S.fetchState==="In-Progress",onConnectStripe:_=>{g.trackInvoicingActionClick(l.Event.invoicingStripeConnectClicked,{fromScreen:t??"hub"}),e(Do(_))},onDisconnect:(_,V)=>{j!==""&&(g.trackInvoicingActionClick(l.Event.invoicingIntegrationDisconnected,{entity:V,entityId:_,fromScreen:t??"hub"}),e(Ao(j,_,cn(V))))},onDisconnectStripe:()=>{g.trackInvoicingActionClick(l.Event.invoicingStripeDisconnected,{fromScreen:t??"hub"}),e(xo())},onReconnectQBO:()=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"reconnect",fromScreen:t??"hub"});const _=y.tenantEmailDomain??i??"";Se.init("/connection/auth",_),Se.handleClick()},onRefreshQBO:()=>{A.integrations.refreshQBO.fetchState!=="In-Progress"&&(g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"refresh",fromScreen:t??"hub"}),e(Gn()))},onSaveChargeBeeCredentials:(_,V)=>{We!=null&&j!==""&&(g.trackInvoicingActionClick(l.Event.invoicingChargebeeCredentialsSaved,{fromScreen:t??"hub"}),e(yo(j,We,cn("revenue"),bo("chargebee"),{api_key:_,site:V})))},saveChargeBeeError:A.externalConnections?.saveAPIKeyConnectionError?.message,saveChargeBeeState:A.externalConnections?.saveAPIKeyConnectionState??"Not-Started",settings:d,stripeError:S.fetchState==="Error"?S.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Ye};return{authParams:U,deleteFileStatusById:nt,fieldHelp:o,dunningScheduleActionOptions:p,filesEndPoint:de?.fileMicroServiceBaseUrl??"",integrationsSectionProps:K,isInvoicingPageReady:at,isLoading:ot,isSaving:u.fetchState==="In-Progress",isStripeBusy:S.fetchState==="In-Progress",logoFile:s,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:I,qboSyncStatusOptions:E,qboView:h,saveErrorMessage:u.fetchState==="Error"?u.error?.message??"Failed to save settings.":D&&v==="Error"?m?.message??"Failed to load invoicing configuration.":void 0,settings:d,stripeError:S.fetchState==="Error"?S.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Ye,updateFileStatusById:tt,onConnectStripe:K.onConnectStripe,onDeleteFile:_=>{g.trackInvoicingActionClick(l.Event.invoicingLogoRemoved,{fromScreen:t??"hub"}),e(Eo(_,j))},onDisconnectStripe:K.onDisconnectStripe,onEditFileName:(_,V)=>{g.trackInvoicingActionClick(l.Event.invoicingLogoRenamed,{fromScreen:t??"hub"}),e(ko(_,V.split(".")[0],j))},onReconnectQBO:K.onReconnectQBO,onRefreshQBO:K.onRefreshQBO,onRetryQboSyncTask:_=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"retry_task",entityId:_,fromScreen:t??"hub"}),e(Kn(_))},onSave:_=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{fieldsChanged:Object.keys(_).filter((V=>JSON.stringify(_[V])!==JSON.stringify(d?.[V]))),tab:t??"hub"}),e(Co({settings:_,snackbarSection:Ha[t??""]}))},onStartQboBackfill:_=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"backfill",fromScreen:t??"hub"}),e(zn(_))},updateFilesEntity:_=>{g.trackInvoicingActionClick(l.Event.invoicingLogoUploaded,{fromScreen:t??"hub"}),e(ho({files:_}))}}}function dn({appContent:t}){const e=P(),n=X(),i=L(),{tenantEmailDomain:a}=w(),o=te("branding"),s=k((d=>jo(d)));r.useEffect((()=>{s.saveState.fetchState==="Completed"&&i(Lo())}),[s.saveState.fetchState,i]);const u=Me(s.saveState.fetchState);return r.useEffect((()=>{u==="In-Progress"&&s.saveState.fetchState==="Completed"&&e("..")}),[u,s.saveState.fetchState,e]),c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingBrandingSettingsPage,isReady:o.isInvoicingPageReady}),c.jsx(Ht,{address:s.address,fieldHelp:s.fieldHelp,addressLabel:s.addressLabel,appContent:t,authParams:o.authParams,dateFormatOptions:s.dateFormatOptions,deleteFileStatusById:o.deleteFileStatusById,filesEndPoint:o.filesEndPoint,isLoading:o.isLoading,isSaving:o.isSaving,localData:s.localData,logoFile:o.logoFile,saveErrorMessage:o.saveErrorMessage,settings:o.settings,updateFileStatusById:o.updateFileStatusById,onBackClick:()=>e(".."),onChange:d=>{i($o({localData:d}))},onDeleteFile:o.onDeleteFile,onEditFileName:o.onEditFileName,onOpenAddress:()=>{g.trackInvoicingActionClick(l.Event.invoicingAddressOpened,{entity:"branding",fromScreen:"settings_branding"});const d=`/${a}/invoicing/settings/branding/${_o}/`,S=ee(n.state?.pathnameStackToGoBack,n.pathname);e(d,{state:{pathnameStackToGoBack:S}})},onSubmit:()=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{tab:"branding"}),i(Po())},updateFilesEntity:o.updateFilesEntity})]})}function qa(){const t=P(),e=te("dunning");return c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingDunningSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(qt,{dunningScheduleActionOptions:e.dunningScheduleActionOptions,isLoading:e.isLoading,isSaving:e.isSaving,saveErrorMessage:e.saveErrorMessage,settings:e.settings,onBackClick:()=>t(".."),onSave:e.onSave})]})}function Qa(){const t=P(),e=te("integrations");return c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingIntegrationsSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(Qt,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>t("../quickbooks"),onOpenPaymentDestination:()=>t("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>t("..")})]})}function za(){const t=P(),e=te("payment-destination");return c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingPaymentDestinationSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(zt,{fieldHelp:e.fieldHelp,isLoading:e.isLoading,isStripeBusy:e.isStripeBusy,saveErrorMessage:e.saveErrorMessage,settings:e.settings,stripeError:e.stripeError,stripeWebhookUrl:e.stripeWebhookUrl,onBackClick:()=>t(".."),onConnectStripe:e.onConnectStripe})]})}const Ka=["autoCreateItems","closedPeriodVoidAsCreditMemo","customerMatching","isSyncEnabled","syncStartDate","trackingCategoriesEnabled"],Ga=T((function(t){const e=Wn(t);return{accountMappingKindOptions:e.accountMappingKindOptions,fieldHelp:e.fieldHelp,accounts:e.accounts,connection:e.connection,customerMatchingOptions:e.customerMatchingOptions,isBackfilling:e.backfillState.fetchState==="In-Progress",isLoading:e.isLoading,isSaving:e.saveState.fetchState==="In-Progress",isSyncEnabledSaved:e.isSyncEnabledSaved,localData:e.localData,nestedAccountHierarchy:e.nestedAccountHierarchy,retryFetchStateByTaskId:e.retryFetchStateByTaskId,saveErrorMessage:e.saveState.fetchState==="Error"?e.saveState.error?.message:void 0,syncHealth:e.syncHealth,syncStatusOptions:e.syncStatusOptions}}),(function(t){return{onChange:e=>{t(Fo({localData:e}))},onReset:()=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsReset,{tab:"quickbooks"}),t(Ro())},onRetryTask:e=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"retry_task",entityId:e,fromScreen:"settings_qbo"}),t(Kn(e))},onStartBackfill:e=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"backfill",fromScreen:"settings_qbo"}),t(zn(e))}}}))(Kt);function Wa(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),i=k(he),{configFetchState:a,localData:o,savedLocalData:s,saveState:u,settingsFetchState:d}=k(Wn),S=r.useMemo((()=>{return v=o,p=s,[...[...new Set([...Object.keys(v.accountIdByMappingCode),...Object.keys(p.accountIdByMappingCode)])].some((f=>(v.accountIdByMappingCode[f]??"")!==(p.accountIdByMappingCode[f]??"")))?["account_mappings"]:[],...Ka.filter((f=>v[f]!==p[f]))];var v,p}),[o,s]),m=Me(u.fetchState);return r.useEffect((()=>{m==="In-Progress"&&u.fetchState==="Completed"&&e("..")}),[e,m,u.fetchState]),r.useEffect((()=>{d!=="Not-Started"&&d!=="Error"||t(Qe())}),[t,d]),r.useEffect((()=>{a==="Not-Started"&&t(pe())}),[a,t]),et({fetchSyncHealth:!0,loadAccountingPickers:!0}),c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingQboSettingsPage}),c.jsx(Ga,{onBackClick:()=>e(".."),onReconnect:()=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"reconnect",fromScreen:"settings_qbo"}),Se.init("/connection/auth",i.tenantEmailDomain??n??""),Se.handleClick()},onRefresh:()=>{g.trackInvoicingActionClick(l.Event.invoicingQboAction,{action:"refresh",fromScreen:"settings_qbo"}),t(Gn())},onSave:()=>{g.trackInvoicingActionClick(l.Event.invoicingSettingsSaved,{fieldsChanged:S,tab:"quickbooks"}),t(wo())}})]})}const Ya={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function Ja(){const t=un(),e=L(),n=P(),[i,a]=Z(),o=te(),{canEnableInvoicing:s,isEnablingInvoicing:u,isInvoicingEnabled:d,isQboConfigured:S,isStripeConnected:m}=k(Qn),v=i.get("tab");return r.useEffect((()=>{if(v==null)return;const p=Ya[v];a({},{replace:!0}),p!=null&&n(p,{replace:!0})}),[v,n,a]),c.jsxs(c.Fragment,{children:[c.jsx($,{event:l.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),c.jsx(Gt,{analytics:g,integrationsSectionProps:{...o.integrationsSectionProps,onConfigureQBO:()=>n("quickbooks"),onOpenPaymentDestination:()=>n("payment-destination")},isEnablingInvoicing:u,isLoading:o.isLoading,meetingUrl:t("invoicing_settings"),settings:o.settings,onBrandingClick:()=>n("branding"),onDunningClick:()=>n("dunning"),canEnableInvoicing:s,isQboConfigured:S,isStripePaymentsReady:m,onEnableInvoicingClick:d?void 0:()=>{g.trackInvoicingActionClick(l.Event.invoicingEnableClicked),e(Oo())}})]})}function ln(){return c.jsxs(ce,{children:[c.jsx(x,{index:!0,element:c.jsx(Ja,{})}),c.jsx(x,{path:"payment-destination",element:c.jsx(za,{})}),c.jsx(x,{path:"branding",element:c.jsx(dn,{})}),c.jsx(x,{path:"branding/:addressType",element:c.jsx(dn,{appContent:c.jsx(G,{isSubPage:!0,hideAddressBackButton:!0})})}),c.jsx(x,{path:"integrations",element:c.jsx(Qa,{})}),c.jsx(x,{path:"dunning",element:c.jsx(qa,{})}),c.jsx(x,{path:"quickbooks",element:c.jsx(Wa,{})}),c.jsx(x,{path:"*",element:c.jsx(H,{to:"..",replace:!0})})]})}function xc(){const t=L(),e=P(),{tenantEmailDomain:n}=w(),{areTenantIdsInSync:i}=F(),{enableState:a,fetchState:o,status:s}=k(wn),u=Me(a.fetchState),d=`/${n}/invoicing`,S=r.useRef(!1),m=k((v=>Ke(v).connectionFetchState.fetchState));return r.useEffect((()=>{i&&(o!=="Not-Started"?o!=="Error"||S.current||(S.current=!0,t(pe({cacheOverride:!1}))):t(pe({cacheOverride:!1})))}),[i,t,o]),r.useEffect((()=>{i&&m==="Not-Started"&&t(qn())}),[i,t,m]),r.useEffect((()=>{u==="In-Progress"&&a.fetchState==="Completed"&&(e(`${d}/catalog`),t(To()))}),[u,a.fetchState,d,t,e]),s==null&&o!=="Error"?c.jsx(Wt,{fetchState:"In-Progress"}):s==="not_started"?c.jsxs(ce,{children:[c.jsx(x,{path:"promo",element:c.jsx(sn,{})}),c.jsx(x,{path:"*",element:c.jsx(H,{to:`${d}/promo`,replace:!0})})]}):s==="settings"?c.jsxs(ce,{children:[c.jsx(x,{path:"promo",element:c.jsx(sn,{})}),c.jsx(x,{path:"settings/*",element:c.jsx(ln,{})}),c.jsx(x,{path:"*",element:c.jsx(H,{to:`${d}/settings`,replace:!0})})]}):c.jsxs(ce,{children:[c.jsx(x,{path:"/",element:c.jsx(H,{to:"overview",replace:!0})}),c.jsx(x,{path:"overview",element:c.jsx(_a,{})}),c.jsx(x,{path:"promo",element:c.jsx(H,{to:`${d}/overview`,replace:!0})}),c.jsx(x,{path:"customers",element:c.jsx(da,{})}),c.jsx(x,{path:"customers/new",element:c.jsx(sa,{})}),c.jsx(x,{path:"customers/new/:addressType",element:c.jsx(G,{})}),c.jsx(x,{path:"customers/:customer_id",element:c.jsx(aa,{})}),c.jsx(x,{path:"customers/:customer_id/:addressType",element:c.jsx(G,{})}),c.jsx(x,{path:"subscriptions",element:c.jsx(Ua,{})}),c.jsx(x,{path:"subscriptions/new",element:c.jsx(Ma,{})}),c.jsx(x,{path:"subscriptions/new/:addressType",element:c.jsx(G,{})}),c.jsx(x,{path:"subscriptions/:subscription_id",element:c.jsx(Oa,{})}),c.jsx(x,{path:"subscriptions/:subscription_id/:addressType",element:c.jsx(G,{})}),c.jsx(x,{path:"invoices",element:c.jsx(Da,{})}),c.jsx(x,{path:"invoices/create",element:c.jsx(Xo,{})}),c.jsx(x,{path:"invoices/:invoice_id",element:c.jsx(xa,{})}),c.jsx(x,{path:"invoices/:invoice_id/record-payment",element:c.jsx(rn,{})}),c.jsx(x,{path:"invoices/:invoice_id/issue-credit-note",element:c.jsx(La,{})}),c.jsx(x,{path:"payments",element:c.jsx(wa,{})}),c.jsx(x,{path:"payments/record",element:c.jsx(rn,{})}),c.jsx(x,{path:"payments/:transaction_id",element:c.jsx(Va,{})}),c.jsx(x,{path:"credits",element:c.jsx(ia,{})}),c.jsx(x,{path:"credits/:credit_note_id",element:c.jsx(na,{})}),c.jsx(x,{path:"discounts",element:c.jsx(ha,{})}),c.jsx(x,{path:"discounts/new",element:c.jsx(Jo,{})}),c.jsx(x,{path:"discounts/:coupon_id",element:c.jsx(fa,{})}),c.jsx(x,{path:"dunning",element:c.jsx(ya,{})}),c.jsx(x,{path:"dunning/:case_id",element:c.jsx(ka,{})}),c.jsx(x,{path:"catalog",element:c.jsx(Wo,{})}),c.jsx(x,{path:"catalog/new",element:c.jsx(zo,{})}),c.jsx(x,{path:"catalog/:item_id",element:c.jsx(Vo,{})}),c.jsx(x,{path:"settings/*",element:c.jsx(ln,{})}),c.jsx(x,{path:"audit_log",element:c.jsx(No,{})}),c.jsx(x,{path:"data_import",element:c.jsx(ma,{})}),c.jsx(x,{path:"data_import/migrate",element:c.jsx(pa,{})}),c.jsx(x,{path:"data_import/:sessionId",element:c.jsx(ua,{})}),c.jsx(x,{path:"*",element:c.jsx(M,{})})]})}export{xc as default};
@@ -1,4 +1,4 @@
1
- import{j as a}from"./liveblocks-DALtO6SV.js";import{i as S,l as g,h as C,g as y,u as ee,t as ae,j as L,N as te,n as ne,o as p}from"./core-BqvURhsI.js";import{UV as k,UW as j,UX as T,JS as D,JE as U,UY as A,UZ as oe,U_ as ie,JI as se,gl as $,JP as le,JM as de}from"./zeni-epic-state-_CRDfrCw.js";import{$ as x,E as d,a0 as re,j as v,U as M,a1 as ce,a2 as me,a3 as pe,p as G,W as ue,A as he,a4 as ge,Z as xe,f as be,a5 as fe,a6 as we,Y as Se,a7 as ye,a8 as ke,a9 as je,aa as ve}from"./index-tkcziiFe.js";import{n as m,u as $e}from"./mui-DSj4M999.js";import b from"./NotFoundScreen-CM2NXlhe.js";import{a as I}from"./sentry-CWf72ffv.js";import"./recharts-BMVG1gQz.js";import"./analytics-Cf42-eLX.js";import"./plaid-D9ebNRn2.js";import"./dnd-_c-IyjNm.js";import"./stripe-cKAAJElX.js";import"./lottie-Cl-fmeYA.js";import"./lexical-DOFKMtgG.js";import"./pdf-CFPsQLlu.js";import"./utils-1PeqdCv6.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]="b33b25d5-eb54-487d-89b6-52b3d705a8d0",e._sentryDebugIdIdentifier="sentry-dbid-b33b25d5-eb54-487d-89b6-52b3d705a8d0")}catch{}})();const Ie=m.div`
1
+ import{j as a}from"./liveblocks-CZZ7TQJf.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-DtSa7_zJ.js";import{UV as k,UW as v,UX as T,JS as D,JE as U,UY as B,UZ as oe,U_ as ie,JI as se,gl as $,JP as le,JM as re}from"./zeni-epic-state-DIQk-W8f.js";import{$ as x,I as r,a0 as de,k as j,V as M,a1 as ce,a2 as me,a3 as pe,p as V,W as ue,c as he,a4 as ge,Z as xe,f as fe,a5 as we,a6 as be,Y as Se,a7 as ye,a8 as ke,a9 as ve,aa as je}from"./index-CJhgQFRI.js";import{n as m,u as $e}from"./mui-hHF2bYsV.js";import f from"./NotFoundScreen-DHpPkJUq.js";import{a as I}from"./sentry-7oL5NFUY.js";import"./recharts-DHYb1iJa.js";import"./analytics-wUVBNE2n.js";import"./plaid-l93gkere.js";import"./dnd-BRHUZ8LO.js";import"./stripe-cKAAJElX.js";import"./lottie-_8fQYf62.js";import"./lexical-CV0PpHfb.js";import"./pdf-DcTPEGUQ.js";import"./utils-D3PNq8pk.js";(function(){try{var e=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new e.Error().stack;t&&(e._sentryDebugIds=e._sentryDebugIds||{},e._sentryDebugIds[t]="36a0b232-93c9-4109-94a9-ad289151d027",e._sentryDebugIdIdentifier="sentry-dbid-36a0b232-93c9-4109-94a9-ad289151d027")}catch{}})();const Ie=m.div`
2
2
  display: flex;
3
3
  height: 100%;
4
4
  width: 100%;
@@ -6,8 +6,8 @@ import{j as a}from"./liveblocks-DALtO6SV.js";import{i as S,l as g,h as C,g as y,
6
6
  flex-direction: column;
7
7
  align-items: center;
8
8
  background-color: ${e=>e.theme.colors.grey4};
9
- box-shadow: ${e=>`0px 2px ${d.sp1} ${e.theme.colors.dropShadowNormal}`};
10
- `,Ce=g((function(e){const t=k(e),n=j(e),{companyName:o}=t;return{companyName:o,isDisabled:t.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,magicLinkViewState:t}}),(function(e,t){const{vendorId:n,billId:o}=t;return{onFetchBankName:i=>{e(U(i))},onSaveHandler:i=>{v.trackBillPayMagicLinkSubmitBankAccountDetails(o),e(D(i,"standard",n,o))},onACHDetailsUpdated:i=>{const{bankAccountSection:l}=i;e(T({data:l}))}}}))(re);function F(){const e=x(),{vendorId:t,billId:n}=S();return t==null||n==null?a.jsx(b,{}):a.jsx(a.Fragment,{children:a.jsx(Ie,{windowSize:e,children:a.jsx(Ce,{vendorId:t,billId:n})})})}const De=m.div`
9
+ box-shadow: ${e=>`0px 2px ${r.sp1} ${e.theme.colors.dropShadowNormal}`};
10
+ `,Ce=g((function(e){const t=k(e),n=v(e),{companyName:o}=t;return{companyName:o,isDisabled:t.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,magicLinkViewState:t}}),(function(e,t){const{vendorId:n,billId:o}=t;return{onFetchBankName:i=>{e(U(i))},onSaveHandler:i=>{j.trackBillPayMagicLinkSubmitBankAccountDetails(o),e(D(i,"standard",n,o))},onACHDetailsUpdated:i=>{const{bankAccountSection:l}=i;e(T({data:l}))}}}))(de);function F(){const e=x(),{vendorId:t,billId:n}=S();return t==null||n==null?a.jsx(f,{}):a.jsx(a.Fragment,{children:a.jsx(Ie,{windowSize:e,children:a.jsx(Ce,{vendorId:t,billId:n})})})}const De=m.div`
11
11
  display: flex;
12
12
  height: 100vh;
13
13
  width: 100%;
@@ -15,8 +15,8 @@ import{j as a}from"./liveblocks-DALtO6SV.js";import{i as S,l as g,h as C,g as y,
15
15
  flex-direction: column;
16
16
  align-items: center;
17
17
  background-color: ${e=>e.theme.colors.grey4};
18
- box-shadow: ${e=>`0px 2px ${d.sp1} ${e.theme.colors.dropShadowNormal}`};
19
- `,Ae=g((function(e,t){const{isSubPage:n}=t;return{addressToEdit:A(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 Be({isSubPage:e}){const t=C(),n=y(),o=x();return a.jsx(a.Fragment,{children:a.jsx(De,{windowSize:o,children:a.jsx(Ae,{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}),Ee=m.div`
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`
20
20
  display: flex;
21
21
  height: 100%;
22
22
  width: 100%;
@@ -24,8 +24,8 @@ import{j as a}from"./liveblocks-DALtO6SV.js";import{i as S,l as g,h as C,g as y,
24
24
  flex-direction: column;
25
25
  align-items: center;
26
26
  background-color: ${e=>e.theme.colors.grey4};
27
- box-shadow: ${e=>`0px 2px ${d.sp1} ${e.theme.colors.dropShadowNormal}`};
28
- `,Ne=g((function(e){const t=k(e),n=j(e),o=A(e),{companyName:i}=t;return{companyName:i,isDisabled:t.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,mailingAddressDetails:o,magicLinkViewState:t}}),(function(e,t){const{navigate:n,location:o,vendorId:i,billId:l}=t;return{onFetchBankName:s=>{e(U(s))},onSaveHandler:s=>{v.trackBillPayMagicLinkSubmitBankAccountDetails(l),e(D(s,"us-domestic",i,l))},onWireDetailsUpdated:s=>{const{bankAccountSection:r}=s;e(T({data:r}))},onAddressClick:()=>{const s=o.pathname.replace("us-domestic","address"),r=G(o.state?.pathnameStackToGoBack,o.pathname);n(s,{state:{pathnameStackToGoBack:r}})}}}))(pe);function Le(){const e=C(),t=y(),n=x(),{vendorId:o,billId:i}=S();return o==null||i==null?a.jsx(b,{}):a.jsx(a.Fragment,{children:a.jsx(Ee,{windowSize:n,children:a.jsx(Ne,{location:t,navigate:e,vendorId:o,billId:i})})})}const Fe=m.div`
27
+ box-shadow: ${e=>`0px 2px ${r.sp1} ${e.theme.colors.dropShadowNormal}`};
28
+ `,Ne=g((function(e){const t=k(e),n=v(e),o=B(e),{companyName:i}=t;return{companyName:i,isDisabled:t.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,mailingAddressDetails:o,magicLinkViewState:t}}),(function(e,t){const{navigate:n,location:o,vendorId:i,billId:l}=t;return{onFetchBankName:s=>{e(U(s))},onSaveHandler:s=>{j.trackBillPayMagicLinkSubmitBankAccountDetails(l),e(D(s,"us-domestic",i,l))},onWireDetailsUpdated:s=>{const{bankAccountSection:d}=s;e(T({data:d}))},onAddressClick:()=>{const s=o.pathname.replace("us-domestic","address"),d=V(o.state?.pathnameStackToGoBack,o.pathname);n(s,{state:{pathnameStackToGoBack:d}})}}}))(pe);function Ee(){const e=C(),t=y(),n=x(),{vendorId:o,billId:i}=S();return o==null||i==null?a.jsx(f,{}):a.jsx(a.Fragment,{children:a.jsx(Le,{windowSize:n,children:a.jsx(Ne,{location:t,navigate:e,vendorId:o,billId:i})})})}const Fe=m.div`
29
29
  display: flex;
30
30
  height: 100%;
31
31
  width: 100%;
@@ -33,40 +33,40 @@ import{j as a}from"./liveblocks-DALtO6SV.js";import{i as S,l as g,h as C,g as y,
33
33
  flex-direction: column;
34
34
  align-items: center;
35
35
  background-color: ${e=>e.theme.colors.grey4};
36
- box-shadow: ${e=>`0px 2px ${d.sp1} ${e.theme.colors.dropShadowNormal}`};
37
- `,Te=g((function(e){const t=k(e),n=j(e),o=A(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=>{v.trackBillPayMagicLinkSubmitBankAccountDetails(l),e(D(s,"international",i,l,t.isLocalCurrencyEnabled))},onBankDetailsUpdated:s=>{const{internationalWireSwiftAccountSection:r}=s;e(ie({data:r}))},onAddressClick:()=>{const s=o.pathname.replace("international","address"),r=G(o.state?.pathnameStackToGoBack,o.pathname);n(s,{state:{pathnameStackToGoBack:r}})}}}))(ge);function Ue(){const e=C(),t=y(),n=x(),{vendorId:o,billId:i}=S(),{useFeatureGate:l}=ue(),{isFeatureEnabled:s}=l(he.isBillPayLocalCurrencyFeatureEnabled);return o==null||i==null?a.jsx(b,{}):a.jsx(Fe,{windowSize:n,children:a.jsx(Te,{location:t,navigate:e,vendorId:o,billId:i,isLocalCurrencyEnabled:s})})}const Me={containerWidth:new je(100,58)},Ge=m(ye)`
38
- width: ${d.sp4};
39
- height: ${d.sp4};
40
- margin-bottom: ${d.sp3};
41
- margin-top: ${d.sp3};
42
- margin-left: ${d.sp8};
36
+ box-shadow: ${e=>`0px 2px ${r.sp1} ${e.theme.colors.dropShadowNormal}`};
37
+ `,Te=g((function(e){const t=k(e),n=v(e),o=B(e),{companyName:i}=t;return{companyName:i,isDisabled:t.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,mailingAddressDetails:o,magicLinkViewState:t}}),(function(e,t){const{navigate:n,location:o,vendorId:i,billId:l}=t;return{onFetchBankNameBySwift:s=>{e(se(s))},onSaveHandler:s=>{j.trackBillPayMagicLinkSubmitBankAccountDetails(l),e(D(s,"international",i,l,t.isLocalCurrencyEnabled))},onBankDetailsUpdated:s=>{const{internationalWireSwiftAccountSection:d}=s;e(ie({data:d}))},onAddressClick:()=>{const s=o.pathname.replace("international","address"),d=V(o.state?.pathnameStackToGoBack,o.pathname);n(s,{state:{pathnameStackToGoBack:d}})}}}))(ge);function Ue(){const e=C(),t=y(),n=x(),{vendorId:o,billId:i}=S(),{useFeatureGate:l}=ue(),{isFeatureEnabled:s}=l(he.isBillPayLocalCurrencyFeatureEnabled);return o==null||i==null?a.jsx(f,{}):a.jsx(Fe,{windowSize:n,children:a.jsx(Te,{location:t,navigate:e,vendorId:o,billId:i,isLocalCurrencyEnabled:s})})}const Me={containerWidth:new ve(100,58)},Ve=m(ye)`
38
+ width: ${r.sp4};
39
+ height: ${r.sp4};
40
+ margin-bottom: ${r.sp3};
41
+ margin-top: ${r.sp3};
42
+ margin-left: ${r.sp8};
43
43
  cursor: pointer;
44
44
  position: absolute;
45
45
  color: ${e=>e.theme.colors.brandColorJade};
46
- `,Je=m.div`
46
+ `,Ge=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
- `,Ve=m.div`
53
+ `,Je=m.div`
54
54
  display: flex;
55
55
  flex-direction: ${e=>e.windowSize==="small"?"column":"row"};
56
56
  flex-direction: column;
57
57
  width: ${e=>`${Me.containerWidth.value(e.windowSize)}%`};
58
58
  ${e=>e.windowSize!=="small"?"overflow: auto;":""}
59
- box-shadow: ${e=>`0px 2px ${d.sp1} ${e.theme.colors.dropShadowNormal}`};
60
- padding-top: ${e=>e.windowSize!=="small"?d.sp2:"0px"};
59
+ box-shadow: ${e=>`0px 2px ${r.sp1} ${e.theme.colors.dropShadowNormal}`};
60
+ padding-top: ${e=>e.windowSize!=="small"?r.sp2:"0px"};
61
61
  `,We=m.div`
62
62
  display: flex;
63
63
  flex-direction: column;
64
64
  align-items: center;
65
65
  justify-content: center;
66
- padding: ${e=>e.windowSize==="small"?d.sp3:`62px ${d.sp6} ${d.sp9} ${d.sp8}`};
66
+ padding: ${e=>e.windowSize==="small"?r.sp3:`62px ${r.sp6} ${r.sp9} ${r.sp8}`};
67
67
  height: ${e=>e.windowSize==="small"?"490px":"auto"};
68
68
  overflow: ${e=>e.windowSize==="small"?"unset":"hidden"};
69
69
  width: ${e=>e.windowSize=="small"?"auto":"42%"};
70
70
  background-color: ${e=>e.windowSize==="small"?e.theme.colors.grey4:e.theme.colors.background};
71
71
  margin-top: ${e=>e.windowSize==="small"?e.isAddressPage?"0px":"186px":"unset"};
72
- `,_e=g((function(e,t){return{file:t.file,type:t.type}}))(ke);function h({appContent:e}){const t=ee(),n=y(),{tenantEmailDomain:o,vendorId:i,billId:l}=S(),[s]=ae(),r=s.get("token"),J=n.pathname.includes("address"),f=x(),V=xe(),B=$e(),w=be(),W=()=>{V.toggle()},_=L((u=>k(u))),H=L((u=>j(u))),{authParams:K,fetchState:c,billAttachment:O,billFetchState:P,companyName:X,currencySymbol:Y,amount:Z}=_,{tenantId:z,userId:E,sessionId:N}=K,{fetchState:q,internationalBankAccountCreateStatus:Q}=H;return I.useEffect((()=>{$()}),[]),I.useEffect((()=>{w&&c==="Not-Started"&&i!=null&&o!=null&&r!=null&&t(le(i,o,r))}),[w,c,i,o,r,t]),I.useEffect((()=>{w&&c==="Completed"&&($(E,N,z),l!=null&&t(de(l)))}),[c,w,E,N,z,l,t]),c==="Error"?a.jsx(b,{}):q==="Completed"||Q.fetchState==="Completed"?($(),a.jsx(te,{to:"../../../../../../../bank/account/save/success",replace:!0,relative:"path"})):c==="In-Progress"?a.jsx(fe,{fetchState:c,style:{height:"100vh",backgroundColor:B.colors.grey5,boxShadow:`0px 2px ${d.sp1} ${B.colors.dropShadowNormal}`}}):a.jsxs(a.Fragment,{children:[c==="Completed"&&P==="Completed"&&a.jsx(we,{analytics:v,onLoad:u=>(R=>R.trackBillPayMagicLinkPageLoad(o??"",i??"",X,l??"",He(n.pathname),Y,Z))(u)}),a.jsxs(Je,{windowSize:f,children:[f!=="small"?a.jsx(Ge,{onClick:W}):null,a.jsx(We,{windowSize:f,isAddressPage:J,children:P==="In-Progress"?a.jsx(Se,{size:"ExtraLarge",start:!0}):a.jsx(_e,{file:O,type:"bill"})}),a.jsx(Ve,{windowSize:f,children:e})]})]})}const He=e=>`${e.split("/").at(-2)}_${e.split("/").at(-1)}`;function Ke(){return a.jsx(ve,{})}function ra(){return a.jsxs(ne,{children:[a.jsx(p,{path:"bank/account/save/success",element:a.jsx(Ke,{})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/ach/standard",element:a.jsx(h,{appContent:a.jsx(F,{})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/ach/same-day",element:a.jsx(h,{appContent:a.jsx(F,{})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/address",element:a.jsx(h,{appContent:a.jsx(Be,{isSubPage:!0})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/us-domestic",element:a.jsx(h,{appContent:a.jsx(Le,{})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/international",element:a.jsx(h,{appContent:a.jsx(Ue,{})})}),a.jsx(p,{path:"*",element:a.jsx(b,{})})]})}export{ra as default};
72
+ `,_e=g((function(e,t){return{file:t.file,type:t.type}}))(ke);function h({appContent:e}){const t=ee(),n=y(),{tenantEmailDomain:o,vendorId:i,billId:l}=S(),[s]=ae(),d=s.get("token"),G=n.pathname.includes("address"),w=x(),J=xe(),A=$e(),b=fe(),W=()=>{J.toggle()},_=E((u=>k(u))),H=E((u=>v(u))),{authParams:K,fetchState:c,billAttachment:O,billFetchState:P,companyName:X,currencySymbol:Y,amount:Z}=_,{tenantId:z,userId:L,sessionId:N}=K,{fetchState:q,internationalBankAccountCreateStatus:Q}=H;return I.useEffect((()=>{$()}),[]),I.useEffect((()=>{b&&c==="Not-Started"&&i!=null&&o!=null&&d!=null&&t(le(i,o,d))}),[b,c,i,o,d,t]),I.useEffect((()=>{b&&c==="Completed"&&($(L,N,z),l!=null&&t(re(l)))}),[c,b,L,N,z,l,t]),c==="Error"?a.jsx(f,{}):q==="Completed"||Q.fetchState==="Completed"?($(),a.jsx(te,{to:"../../../../../../../bank/account/save/success",replace:!0,relative:"path"})):c==="In-Progress"?a.jsx(we,{fetchState:c,style:{height:"100vh",backgroundColor:A.colors.grey5,boxShadow:`0px 2px ${r.sp1} ${A.colors.dropShadowNormal}`}}):a.jsxs(a.Fragment,{children:[c==="Completed"&&P==="Completed"&&a.jsx(be,{analytics:j,onLoad:u=>(R=>R.trackBillPayMagicLinkPageLoad(o??"",i??"",X,l??"",He(n.pathname),Y,Z))(u)}),a.jsxs(Ge,{windowSize:w,children:[w!=="small"?a.jsx(Ve,{onClick:W}):null,a.jsx(We,{windowSize:w,isAddressPage:G,children:P==="In-Progress"?a.jsx(Se,{size:"ExtraLarge",start:!0}):a.jsx(_e,{file:O,type:"bill"})}),a.jsx(Je,{windowSize:w,children:e})]})]})}const He=e=>`${e.split("/").at(-2)}_${e.split("/").at(-1)}`;function Ke(){return a.jsx(je,{})}function da(){return a.jsxs(ne,{children:[a.jsx(p,{path:"bank/account/save/success",element:a.jsx(Ke,{})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/ach/standard",element:a.jsx(h,{appContent:a.jsx(F,{})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/ach/same-day",element:a.jsx(h,{appContent:a.jsx(F,{})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/address",element:a.jsx(h,{appContent:a.jsx(Ae,{isSubPage:!0})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/us-domestic",element:a.jsx(h,{appContent:a.jsx(Ee,{})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/international",element:a.jsx(h,{appContent:a.jsx(Ue,{})})}),a.jsx(p,{path:"*",element:a.jsx(f,{})})]})}export{da as default};
@@ -0,0 +1,12 @@
1
+ import{j as u}from"./liveblocks-CZZ7TQJf.js";import{a as g}from"./sentry-7oL5NFUY.js";import{u as O,g as _,h as w,t as M,j as l,N as T}from"./core-DtSa7_zJ.js";import{z as r,G as P,Q as V,k as A,R as N,X as R,Y,T as G}from"./index-CJhgQFRI.js";import{fI as Q,Uo as W,UR as X,UI as $,gl as q,gn as B,UN as H,gY as J,dk as K,US as Z,UT as ee}from"./zeni-epic-state-DIQk-W8f.js";import{u as te,n as ne}from"./mui-hHF2bYsV.js";import{u as se}from"./useDeviceId-DpOlnzI_.js";import{f as ae}from"./analyticsHelper-C8wUoU5C.js";import{t as ie}from"./getLocaleForTenant-D03DEBIE.js";import"./recharts-DHYb1iJa.js";import"./analytics-wUVBNE2n.js";import"./plaid-l93gkere.js";import"./dnd-BRHUZ8LO.js";import"./stripe-cKAAJElX.js";import"./lottie-_8fQYf62.js";import"./lexical-CV0PpHfb.js";import"./pdf-DcTPEGUQ.js";import"./utils-D3PNq8pk.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]="00fa60d9-133c-4cfd-9ee2-962353f81046",t._sentryDebugIdIdentifier="sentry-dbid-00fa60d9-133c-4cfd-9ee2-962353f81046")}catch{}})();const U=(t,a)=>t!=null&&t.length>0&&a==="magic_links";function Ue(){const t=O(),a=_(),m=w(),[y]=M(),n=y.get("token"),p=y.get("stytch_token_type"),f=r.getMagicLinkCodeVerifier(),i=se(),{otpChallenge:d,twoFAPhoneNumber:C,magicLinkEmail:c,verifyDeviceFetchState:x,resendVerifyDeviceOTPFetchState:z}=l((e=>e.tenantState)),S=l((e=>e.tenantState.fetchState)),b=l((e=>e.tenantState.activeTenantFetchState.fetchState)),I=l((e=>e.tenantState.signInState)),h=l((e=>e.tenantState.magicLinkSignInFetchState.fetchState)),s=l((e=>e.tenantState.loggedInUser)),o=l((e=>Q(e))),k=l((e=>W(e))),D=r.getSignedInUser(),v=te().mode;g.useEffect((()=>{s?.zeniSessionId==null&&n!=null&&U(n,p)&&i!=null&&f!=null&&(r.saveMagicLinkTriggered(n),t(X(n,i,f)))}),[n,p,t,i,f,s?.zeniSessionId]),g.useEffect((()=>{I!=="In-Progress"||S!=="Completed"&&b!=="Completed"||s?.zeniSessionId==null||o==null||(n!=null&&r.saveLastUsedMagicLinkToken(n),r.saveSignedInUserWithSession(s,s.zeniSessionId),r.saveSignedInUserTenants($(k.tenantsInOrder),s.zeniSessionId),q(s.userId,s.zeniSessionId,o.tenantId),t(B(o.tenantId)),r.saveActiveTenantDomainForUser(o.tenantEmailDomain),t(H("Completed")),P.updateAppLocaleID(ie(o)),ae(s,o,v,void 0,k.tenantsInOrder),J().then((()=>{const e=G();e!=null&&V(e)})),setTimeout((()=>{A.trackLogin(N.Event.loginSuccess,"email",K(o.productSettings))}),2e3))}),[I,S,b,s,o,k,v,a.state,t]);const E=g.useCallback((()=>{m("/signin/auth")}),[m]),j=g.useCallback((()=>{i!=null&&d!=null&&c!=null&&t(Z(i,c,d))}),[i,d,t,c]),F=g.useCallback((e=>{i!=null&&n!=null&&c!=null&&d!=null&&t(ee(e,i,c,d))}),[i,n,t,c,d]);if(h==="Completed"&&d!=null)return u.jsx(R,{phoneNumber:C,verifyOtpFetchState:x.fetchState,resendVerifyDeviceOTPFetchState:z,onResendOtp:j,onVerifyOtp:F,onCancelVerifyDevice:E});if(I==="In-Progress"&&S==="Completed"&&s?.zeniSessionId!=null&&o!=null||D!=null){const e=a.state?.origin??"/";return u.jsx(T,{to:e,state:{...a.state,origin:""}})}if(!U(n,p)||f==null||h==="Error"){const e=a.state?.origin??"/",L=n!=null&&r.getLastUsedMagicLinkToken()===n;return u.jsx(T,{to:e,state:{...a.state,origin:"",magicLinkAlreadyUsed:L,magicLinkExpired:!L&&(r.isMagicLinkTriggered(n??"")||h==="Error"&&s?.zeniSessionId==null)}})}return u.jsx(oe,{"data-testid":"smooth-loader",children:u.jsx(Y,{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{Ue as default};
@@ -0,0 +1 @@
1
+ import{j as B}from"./liveblocks-CZZ7TQJf.js";import{a as m}from"./sentry-7oL5NFUY.js";import{u as te,j as t,i as $e,g as Ge,h as Ue,q as F}from"./core-DtSa7_zJ.js";import{fI as ne,Up as Me,Uq as se,gc as xe,fH as Ne,Uz as Pe,Us as Re,Ut as Ve,q3 as Oe,gp as Le,Uw as b,UB as je,UC as Q,gq as qe,UD as Ze,Ev as ze,h5 as He,cW as We,UE as Ye,gb as Je,gr as Ke}from"./zeni-epic-state-DIQk-W8f.js";import{w as Qe,i as Xe,Z as ea,W as aa,d as ta,f as na,u as sa,c,g as oa,H as ia,z as ra,e as da,l as ca,F as la,q as ua,n as ma,o as X,L as fa,B as ha,C as ba,p as S,k as ee,v as pa,O as ae,y as ga,A as Sa}from"./index-CJhgQFRI.js";import{D as Ea}from"./mui-hHF2bYsV.js";import{u as ka}from"./InboxNotificationsProvider-DrljtAmN.js";import{u as Ca}from"./useTaskManagerAccess-zRd8th0q.js";(function(){try{var l=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},i=new l.Error().stack;i&&(l._sentryDebugIds=l._sentryDebugIds||{},l._sentryDebugIds[i]="35457c7e-b08c-46fe-8624-0546b91397cb",l._sentryDebugIdIdentifier="sentry-dbid-35457c7e-b08c-46fe-8624-0546b91397cb")}catch{}})();const Ta=Qe((({isAppContentDrawerOpen:l,handleDrawerToggle:i})=>{const{tenantEmailDomain:s}=$e(),a=Ge(),E=ea(),n=Ue(),D=xe(),r=te(),{useFeatureGate:d}=aa(),p=ta(),{isTaskManagerAccessEnabled:k}=Ca(p),o=t((e=>ne(e))),oe=o.masterTOSInfo?.isMasterTOSAccepted??!1,$=t((e=>Ne(e))),{status:ie}=t(Pe),G=$.uiState.currentChatSessionId,C=na(),{setLoading:re}=sa(),[w,U]=m.useState(void 0),v=F("/:tenantEmailDomain/dashboard")!==null,M=F("/:tenantEmailDomain/reports")!==null,f=F("/:tenantEmailDomain/onboarding/*")!==null,de=!!o.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:ce}=d(c.isChargeCardFeatureEnabled),{isFeatureEnabled:x}=d(c.isDebitCardFeatureEnabled),le=oa(o,ce,x),{isFeatureEnabled:ue}=d(c.isSettingsFeatureEnabled),N=t((e=>Re(e))),{isFeatureEnabled:T}=d(c.isReferralFeatureEnabled),A=t((e=>Ve(e)));m.useEffect((()=>{C&&T&&!f&&A.fetchState==="Not-Started"&&r(Oe(!0))}),[C,T,A.fetchState,f]);const _=t((e=>e.tenantState)),me=t((e=>_.fetchState==="Completed"?Le(e):[])),g=t((e=>e.expenseAutomationViewState.selectedPeriodByTenantId)),{isFeatureEnabled:fe}=d(c.isApAgingFeatureEnabled),{isFeatureEnabled:he}=d(c.isArAgingFeatureEnabled),P=ia(),{isFeatureEnabled:be}=d(c.isDashboardSidebarHalloweenAnimationEnabled),{isFeatureEnabled:pe}=d(c.isDashboardSidebarThanksGivingAnimationEnabled),{isFeatureEnabled:ge}=d(c.isDashboardSidebarChristmasAnimationEnabled),{isFeatureEnabled:Se}=d(c.isDashboardSidebarNewYearAnimationEnabled),Ee=o.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",ke=t((e=>b(e).totalUnreadCount)),Ce=t((e=>b(e).reducedFetchCountState)),R=t((e=>b(e).notificationDetailsByTab.tasks.uiState.unreadCount)),V=t((e=>b(e).notificationDetailsByTab.comments.uiState.unreadCount)),O=t((e=>b(e).notificationDetailsByTab.tasks.fetchCountState)),I=t((e=>b(e).notificationDetailsByTab.comments.fetchCountState)),{inboxNotifications:L,isLoading:j,isFetchingMore:q,hasFetchedAll:Z,fetchMore:Te}=ka();m.useEffect((()=>{const e=setTimeout((()=>Te?.()),0);return()=>clearTimeout(e)})),m.useEffect((()=>{if(j===!1&&q===!1&&Z===!0)if(o?.companyId!=null&&L!=null){const e=`dashboard_${o.companyId}`;U(L.filter((u=>u.roomId===e&&u.readAt==null)).length)}else U(0)}),[j,q,Z]),m.useEffect((()=>{C&&k&&!f&&O.fetchState==="Not-Started"&&D.tenantId!=null&&r(je("task_manager","dashboard"))}),[C,k,f,O.fetchState,D.tenantId,r]),m.useEffect((()=>{f||I.fetchState!=="Not-Started"||r(Q({fetchCountState:{fetchState:"In-Progress",error:void 0}},"comments"))}),[f,I.fetchState,r]),m.useEffect((()=>{w!=null&&I.fetchState==="In-Progress"&&(r(Q({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),r(se({unreadCount:w},"comments")))}),[w,I.fetchState]);const Ie={fetchStatus:Ce,count:ke},z=s!=null?ra.getSignedInUserTenant(s):null,H=t((e=>z?.tenantId!=null?qe(e,z.tenantId):void 0)),h=[];fe===!1&&h.push("accounts_payable_aging"),he===!1&&h.push("accounts_receivable_aging"),h.push("zeni_accounts_promo_card","treasury_promo_card"),T===!1&&h.push("rewards_card"),P===!1&&h.push("expense_automation_card");const W=t((e=>Ze(e,h).fetchState)),Y=t((e=>ze(e).fetchState)),ye=v&&(W==="Completed"||W==="Error")||M&&(Y==="Completed"||Y==="Error")||!v&&!M?void 0:"disabled",we=m.useMemo((()=>He(o.userRole)),[o.userRole]),ve=We(we),Ae=o?.rewardsLastViewedTime==null,_e=p?.userEmail!=null&&N.fetchState==="Completed"&&Ye(N.notificationSettings,p.userEmail,x,o,k),J=da(),Fe=J&&ca(a);return B.jsx(Ea,{container:window.document.body,variant:"temporary",open:l,onClose:()=>i(!1),PaperProps:{sx:{width:240,zIndex:8,borderRight:"none",backgroundImage:"none"}},ModalProps:{keepMounted:!0},children:B.jsx(la,{signedInUser:p,currentTenantId:_.currentTenantId??"",tenants:_.fetchState==="Completed"?me:H!=null?[H]:[],currentTenant:o,isTenantDropdownDisabled:ye,isSettings:X(a),isInvoicing:ma(a)&&ie==="completed",isSettingsFeatureEnabled:ue,isVendorsTabVisible:ve,isZeniAccountEnabled:de,isChargeCardEnabled:le,isTreasuryEnabled:Ee,isNotificationsTabVisible:_e,notificationCountDetails:Ie,isExpenseAutomationEnabledForUser:P,selectedMenu:ua(a),rewardsConfiguration:{isRewardsTabVisible:T,isRewardsAnimated:Ae,rewardsPlan:A.rewardsPlan},isAiCfoAccessEnabled:J,onNotificationIconClick:()=>{i(!1);let e=R===0&&V>0?"notifications/comments":"notifications/tasks";X(a)&&(e=R===0&&V>0?"../../notifications/comments":"../../notifications/tasks");const u=S(a.state?.pathnameStackToGoBack,a.pathname);n(e,{state:{pathnameStackToGoBack:u}})},handleCockpitClick:()=>{window.open("/cockpit")},handleLogOutClick:()=>{i(!1);const e=S(a.state?.pathnameStackToGoBack,a.pathname);n("/signout",{replace:!0,state:{pathnameStackToGoBack:e,message:"logout"}})},handleMenuChange:e=>{if(i(!1),s==null)return;if(e.type==="invoicing")return void n(`../${s}/invoicing/overview`,{state:{pathnameStackToGoBack:S(a.state?.pathnameStackToGoBack,a.pathname),referrer:"Sidebar"}});if(e.type==="ai_cfo"){if(ee.trackAICFOChatScreenStateChanged("viewed","left_menu",G??null,null),!oe)return void pa({location:a,navigate:n,mergeState:{referrer:"Sidebar"}});const y=S(a.state?.pathnameStackToGoBack,a.pathname);return void n(`/${s}/ai-cfo/explore`,{state:{pathnameStackToGoBack:y,referrer:"Sidebar"}})}const u=S(a.state?.pathnameStackToGoBack,a.pathname),K=e.type,Be=ae(K)&&K!=="command_center";if(ae(e.type)&&g[o.tenantId]!=null&&ee.trackMonthEndCloseClicked(g[o.tenantId].month,g[o.tenantId].year,"Sidebar"),Be&&g[o.tenantId]!=null){const y=g[o.tenantId];return void n(`/${s}/month_end_close_checks/review/${e.type}/${y.month}-${y.year}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})}const De=ga(e.type);Sa(e.type)?(G!=null&&r(Ke()),n(`/${s}/ai-cfo/${e.type}`,{state:{pathnameStackToGoBack:u.slice(0,-1),referrer:"Sidebar"}})):n(`/${s}/${De}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})},handleMyProfileClick:()=>{i(!1),n(`/${s}/settings/my_profile`)},handleReferralsClick:()=>{i(!1),n(`/${s}/rewards`)},handleBackClick:()=>{n(`/${s}/dashboard`)},handleTenantSelect:e=>{re(fa.TENANT_SWITCHING),i(!1),ha({dispatch:r,navigate:n,pathToNavigate:ba(e.tenantEmailDomain,a),selectedTenant:e,signedInUser:p})},onZeniLogoClick:()=>{E.toggle()},isAiCfo:Fe,aiCfoView:$,isOnDashboard:v,updateCurrentChatSessionId:e=>{r(Je({sessionId:e,agentId:"controller"})),n(`/${s}/ai-cfo/${e}`,{state:{...a.state}})},halloweenAnimationEnabled:be,isTaskManagerAccessEnabled:k,thanksGivingAnimationEnabled:pe,christmasAnimationEnabled:ge,newYearAnimationEnabled:Se})})})),Da=l=>{const i=te(),s=t((E=>ne(E))),a={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(E,n)=>{Xe(n)&&Me(n.mode)==="dashboard"&&i(se({unreadCount:n.data.unread},"tasks"))}};return B.jsx(Ta,{...l,...a})};export{Da as M};
@@ -0,0 +1 @@
1
+ import{j as e}from"./liveblocks-CZZ7TQJf.js";import{h as r,l as i}from"./core-DtSa7_zJ.js";import{ak as n}from"./index-CJhgQFRI.js";import"./mui-hHF2bYsV.js";import"./sentry-7oL5NFUY.js";import"./zeni-epic-state-DIQk-W8f.js";import"./recharts-DHYb1iJa.js";import"./analytics-wUVBNE2n.js";import"./plaid-l93gkere.js";import"./dnd-BRHUZ8LO.js";import"./stripe-cKAAJElX.js";import"./lottie-_8fQYf62.js";import"./lexical-CV0PpHfb.js";import"./pdf-DcTPEGUQ.js";import"./utils-D3PNq8pk.js";(function(){try{var o=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},t=new o.Error().stack;t&&(o._sentryDebugIds=o._sentryDebugIds||{},o._sentryDebugIds[t]="e1fe4b0b-a509-4443-892f-577d1dfd5036",o._sentryDebugIdIdentifier="sentry-dbid-e1fe4b0b-a509-4443-892f-577d1dfd5036")}catch{}})();const a=i(null,(function(o,t){return{onGoBack:()=>{t.navigate(-1)},onGoHome:()=>{t.navigate("/")}}}))(n);function _(){const o=r();return e.jsx(a,{navigate:o})}export{_ as default};