@zeniai/web-app-ui 5.3.32-next → 5.3.32-prod

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 (112) hide show
  1. package/dist/assets/{AccountMappingScreen-DA6vMX8n.js → AccountMappingScreen-BXftSVn-.js} +1 -1
  2. package/dist/assets/AddressRoutes-Dx1aQN-n.js +1 -0
  3. package/dist/assets/{AddressScreen-2iFQsQhr.js → AddressScreen-TLZdvXNy.js} +1 -1
  4. package/dist/assets/{AiCfoScreen-C9m6odEm.js → AiCfoScreen-DmLnUFml.js} +1 -1
  5. package/dist/assets/{AppDrawer-AR3pdgjI.js → AppDrawer-BnHpD6dG.js} +1 -1
  6. package/dist/assets/{BillPayApprovalRoutes-D6CaIPVl.js → BillPayApprovalRoutes-DPALyyf2.js} +1 -1
  7. package/dist/assets/{BillPayRoutes-BQGUM9hu.js → BillPayRoutes-qAhjjusa.js} +1 -1
  8. package/dist/assets/{BusinessVerificationPageScreen-bzYA6ugA.js → BusinessVerificationPageScreen-BYV8fDWH.js} +1 -1
  9. package/dist/assets/{CardsAiCfoScreen-DzZaAiTB.js → CardsAiCfoScreen-Cd63K_-0.js} +1 -1
  10. package/dist/assets/{ChargeCardRoutes-DUgnqPWj.js → ChargeCardRoutes-BH9evnp_.js} +1 -1
  11. package/dist/assets/{CompanyPassportScreen-DDPsmPkS.js → CompanyPassportScreen-D0g6Nmxq.js} +1 -1
  12. package/dist/assets/{ConnectionAuthScreen-D0DWsoRm.js → ConnectionAuthScreen-CpG3pE-i.js} +1 -1
  13. package/dist/assets/CustomerOnboardingAuthScreen-CXLOaLgp.js +1 -0
  14. package/dist/assets/{CustomerOnboardingRoutes-BZn_LcyK.js → CustomerOnboardingRoutes-CI_z4poM.js} +1 -1
  15. package/dist/assets/{DashboardRoutes-CY1SDvUL.js → DashboardRoutes-C_4oAXQg.js} +1 -1
  16. package/dist/assets/{DefaultTenantHome-C00MLtaA.js → DefaultTenantHome-D3eb-jo9.js} +1 -1
  17. package/dist/assets/{DomesticWireDetailScreen-5wKaAYNZ.js → DomesticWireDetailScreen-i7JC-m7w.js} +1 -1
  18. package/dist/assets/{DrawerScreen-DXivMtkW.js → DrawerScreen-DUO1Z5ow.js} +1 -1
  19. package/dist/assets/{EntityDetailRoutes-D4JppFuK.js → EntityDetailRoutes-B2ai8pR3.js} +1 -1
  20. package/dist/assets/{ExpenseAutomationRoutes-Dmnf2gk3.js → ExpenseAutomationRoutes-DQA6yQ4O.js} +1 -1
  21. package/dist/assets/{FeaturePreviewScreen-C4egsTmn.js → FeaturePreviewScreen-CjFoHQHk.js} +1 -1
  22. package/dist/assets/{HubSpotOAuthCallbackScreen-BPYlggFo.js → HubSpotOAuthCallbackScreen-qemWA0jI.js} +1 -1
  23. package/dist/assets/{InboxNotificationsProvider-DLtCSJ1e.js → InboxNotificationsProvider-7eYmgI1F.js} +1 -1
  24. package/dist/assets/{InvoicingRoutes-C6KEoVXP.js → InvoicingRoutes-DOUUybBE.js} +1 -1
  25. package/dist/assets/{MagicLinkRoutes-BUBt7N4B.js → MagicLinkRoutes-CTs6OYkH.js} +1 -1
  26. package/dist/assets/{MagicLinkSignInScreen-DthxXwoL.js → MagicLinkSignInScreen-CDEl_Ic_.js} +1 -1
  27. package/dist/assets/{MobileAppDrawer-AMYN8Gjf.js → MobileAppDrawer-BMvh-RAa.js} +1 -1
  28. package/dist/assets/NotFoundScreen-Wkt8x0Ja.js +1 -0
  29. package/dist/assets/{NotificationRoutes-C5bjkJ9x.js → NotificationRoutes-BF1aTPUh.js} +1 -1
  30. package/dist/assets/{OAuthConsentScreen-GS4LIEZY.js → OAuthConsentScreen-8oM_ijmg.js} +1 -1
  31. package/dist/assets/{PandLWithForecastRoutes-1JEKWI4D.js → PandLWithForecastRoutes-DvwOSp2G.js} +1 -1
  32. package/dist/assets/{PaymentLinkScreen-klZ4RFzW.js → PaymentLinkScreen-D0VzMTpF.js} +1 -1
  33. package/dist/assets/{PeopleRoutes-D-8614Cf.js → PeopleRoutes-CMx_k0hr.js} +1 -1
  34. package/dist/assets/{PerformanceRoutes-CkfRYNq2.js → PerformanceRoutes-OuxZJbf_.js} +1 -1
  35. package/dist/assets/{Preview-C2GPv-G6.js → Preview-Dkzm36JB.js} +1 -1
  36. package/dist/assets/{QBOConnectionScreen-CgDmO8dD.js → QBOConnectionScreen-Cxvr0UGn.js} +1 -1
  37. package/dist/assets/{ReimbursementApprovalRoutes-DMPKN0xJ.js → ReimbursementApprovalRoutes-ChPdj5ky.js} +1 -1
  38. package/dist/assets/{ReimbursementApprovalRuleDetailScreen-YsjpcW9c.js → ReimbursementApprovalRuleDetailScreen-kIivYyt0.js} +1 -1
  39. package/dist/assets/{ReimbursementRoutes-DXo4NvYM.js → ReimbursementRoutes-DlTMcw_k.js} +1 -1
  40. package/dist/assets/{ReportsRoutes-C5btuAgR.js → ReportsRoutes-DUvTlB32.js} +1 -1
  41. package/dist/assets/{RewardsRoutes-6WcZW5R0.js → RewardsRoutes-CANJzBfw.js} +1 -1
  42. package/dist/assets/{ScreenRoutes-u4rkodoe.js → ScreenRoutes-B2jpCRd2.js} +2 -2
  43. package/dist/assets/{SettingsRoutes-DNaJE00d.js → SettingsRoutes-D405mYiE.js} +1 -1
  44. package/dist/assets/{SetupPagesScreen-BSF8vuHb.js → SetupPagesScreen-o-PhLBXH.js} +1 -1
  45. package/dist/assets/{SignInScreen-C0k1UkVX.js → SignInScreen-CsdAWM0a.js} +1 -1
  46. package/dist/assets/{SignOutScreen-Ciim2wTk.js → SignOutScreen-DjO_hTaY.js} +1 -1
  47. package/dist/assets/{TaskListScreen-t-HxAdY-.js → TaskListScreen-D5rs0HLr.js} +1 -1
  48. package/dist/assets/{TaskRoutes-B3g-TdsM.js → TaskRoutes-IWzYaX-F.js} +1 -1
  49. package/dist/assets/TransactionDetailRoutes-DExFe-03.js +1 -0
  50. package/dist/assets/{TransactionDetailScreen-CfA-Ugfo.js → TransactionDetailScreen-7v-3l9dA.js} +1 -1
  51. package/dist/assets/{TransactionListRoutes-B_3YnN8q.js → TransactionListRoutes-hxVuwPcb.js} +1 -1
  52. package/dist/assets/{TreasuryRoutes-CjNKU5ec.js → TreasuryRoutes-C4GA1Tde.js} +1 -1
  53. package/dist/assets/{VendorsRoutes-DGaauSBm.js → VendorsRoutes-DLC5o9yJ.js} +1 -1
  54. package/dist/assets/{WiseConfirmationScreen-rPMoKWiH.js → WiseConfirmationScreen-BJNaaQrG.js} +1 -1
  55. package/dist/assets/{ZeniAccountRoutes-CEMKZQ-X.js → ZeniAccountRoutes-CPdfqL23.js} +1 -1
  56. package/dist/assets/{ZeniAccountStatementScreen-BhiffvFR.js → ZeniAccountStatementScreen-Butd8DWu.js} +1 -1
  57. package/dist/assets/{accountMappingHelper-ChrGBc2n.js → accountMappingHelper-DsN6SM7a.js} +1 -1
  58. package/dist/assets/{analytics-WNjEvDwJ.js → analytics-NBT5BH2R.js} +1 -1
  59. package/dist/assets/{analyticsHelper-BMvVz4OD.js → analyticsHelper-Bw6Cjeqd.js} +1 -1
  60. package/dist/assets/{core-BaXck2Yj.js → core-Dlma5MIa.js} +1 -1
  61. package/dist/assets/{decodeURIComponentSafe-B0jtUms3.js → decodeURIComponentSafe-MgEJs-XP.js} +1 -1
  62. package/dist/assets/{dnd-Cyb1SC5Y.js → dnd-BgBEAfSC.js} +1 -1
  63. package/dist/assets/{empty-H7TtSYmV.js → empty-BRn9rxGR.js} +1 -1
  64. package/dist/assets/{empty-M_3v5JZA.js → empty-DpC6uPKD.js} +1 -1
  65. package/dist/assets/{emptyVideoElement-BEqLDot8.js → emptyVideoElement-BpruyOrt.js} +1 -1
  66. package/dist/assets/{epic-sIgFMFjP.js → epic-TdjWG3DC.js} +1 -1
  67. package/dist/assets/{expenseAutomationHelper-DlEi6coP.js → expenseAutomationHelper-BpaM_jjL.js} +1 -1
  68. package/dist/assets/{getLocaleForTenant-DEaI00lX.js → getLocaleForTenant-B0nO-Z7L.js} +1 -1
  69. package/dist/assets/{index-BmT_wdak.js → index-Blw4A66-.js} +8 -8
  70. package/dist/assets/{index-VZMRwvc1.js → index-BtQ2P-s4.js} +1 -1
  71. package/dist/assets/{index-DTuBENEN.js → index-CYHgs6V3.js} +1 -1
  72. package/dist/assets/{index-CS4lDeLL.js → index-CexFEAIL.js} +1 -1
  73. package/dist/assets/{index-DGxDcX9G.js → index-Cr8P80rT.js} +1 -1
  74. package/dist/assets/{index-V57vyw7U.js → index-DHUOQOTf.js} +1 -1
  75. package/dist/assets/{index-DtPBjgXd.js → index-YntXYqu4.js} +2 -2
  76. package/dist/assets/{index-Dx3kI9l2.js → index-ui_UfE_7.js} +1 -1
  77. package/dist/assets/{lexical-VH6dL15l.js → lexical-Cc-23sPJ.js} +1 -1
  78. package/dist/assets/{liveblocks-CM7ZQqxd.js → liveblocks-BD1fi6wA.js} +1 -1
  79. package/dist/assets/{lottie-DYRVCvl4.js → lottie-Dd5kLrRz.js} +1 -1
  80. package/dist/assets/{mui-CeNVlxCm.js → mui-DPmPgDDD.js} +1 -1
  81. package/dist/assets/{pathToGoBack-DfpWL1zC.js → pathToGoBack-C5NlBrdk.js} +1 -1
  82. package/dist/assets/{pdf-Dhhhum3V.js → pdf-BCsxh4ki.js} +3 -3
  83. package/dist/assets/{pdf-lib-BXvJUWv4.js → pdf-lib-BSghpPvP.js} +1 -1
  84. package/dist/assets/{plaid-D9ECXCuG.js → plaid-w5kSeMkL.js} +1 -1
  85. package/dist/assets/{pusher-uue_Yphj.js → pusher-D_NnYp1B.js} +1 -1
  86. package/dist/assets/{react-cHKJDlzC.js → react-BRcmo_so.js} +1 -1
  87. package/dist/assets/{react-CW6xsUDz.js → react-BYFmdCmG.js} +1 -1
  88. package/dist/assets/{react-MyBVZkJi.js → react-BiCIC8nJ.js} +1 -1
  89. package/dist/assets/{react-BX9WMcs9.js → react-CKnkKWiv.js} +1 -1
  90. package/dist/assets/{react-BquQQNXI.js → react-Co4WxHXe.js} +1 -1
  91. package/dist/assets/{react-Bsy3W-uL.js → react-wEOgqpw3.js} +1 -1
  92. package/dist/assets/{recharts-BKC_cH7h.js → recharts-WuCIKI4c.js} +1 -1
  93. package/dist/assets/{routePaths-jc2bzNg2.js → routePaths-1GgW-roh.js} +1 -1
  94. package/dist/assets/{sentry-Dh9UB4O6.js → sentry-C6D8WJ15.js} +1 -1
  95. package/dist/assets/{url-Cpedw1H4.js → url-7hMA9KrE.js} +1 -1
  96. package/dist/assets/{url-CV8DVrqd.js → url-BVCS53n5.js} +1 -1
  97. package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-Ck3TknRq.js → useAiCfoDashboardSuggestedQuestionsChips-Cox0FTmj.js} +1 -1
  98. package/dist/assets/{useAskAiCfoHostNavButtonProps-fsQB3AjS.js → useAskAiCfoHostNavButtonProps-5qRN6gKs.js} +1 -1
  99. package/dist/assets/{useChargeCardPusherEvents-CioB6dpi.js → useChargeCardPusherEvents-Cu201ke6.js} +1 -1
  100. package/dist/assets/{useDeviceId-CilYhYRW.js → useDeviceId-p2IpPhWq.js} +1 -1
  101. package/dist/assets/{useEmailConnectResultRefresh-DfelAgkd.js → useEmailConnectResultRefresh-pFVkjSX_.js} +1 -1
  102. package/dist/assets/{useInitialThreadRequest-DOTaljn2.js → useInitialThreadRequest-Ddm4sao-.js} +1 -1
  103. package/dist/assets/{useTaskManagerAccess-LntCDDBS.js → useTaskManagerAccess-BKVtGCGL.js} +1 -1
  104. package/dist/assets/{utils-X6jrk5Hl.js → utils-Bv9LDtmr.js} +1 -1
  105. package/dist/assets/{withTransactionSidePanel-CSTE6dRA.js → withTransactionSidePanel-QyMR1bIP.js} +1 -1
  106. package/dist/assets/{zeni-epic-state-Bo1fQFWK.js → zeni-epic-state-2zvjmkUL.js} +3 -3
  107. package/dist/index.html +1 -1
  108. package/package.json +1 -1
  109. package/dist/assets/AddressRoutes-WhSb9kOA.js +0 -1
  110. package/dist/assets/CustomerOnboardingAuthScreen-WKQ_F3V-.js +0 -1
  111. package/dist/assets/NotFoundScreen-CbKfgA9a.js +0 -1
  112. package/dist/assets/TransactionDetailRoutes-ds3JOU2Z.js +0 -1
@@ -1,2 +1,2 @@
1
- import{j as s}from"./liveblocks-CM7ZQqxd.js";import{a as r}from"./sentry-Dh9UB4O6.js";import{u as P,h as A,i as F,j as E,t as z,l as O,s as H,g as W,N as B,n as te,o as y}from"./core-BaXck2Yj.js";import{a6 as lt,l as p,ao as T,S as g,c9 as dt,ca as ut,cb as gt,cc as mt,cd as vt,ce as pt,cf as ft,cg as St,ch as ht,ci as Ct,cj as It,ck as Et,cl as kt,cm as yt,p as J,cn as xt,co as bt,ac as ae,cp as jt,cq as Dt,z as Se,cr as Pt,cs as At,ct as Lt,cu as $t,cv as wt,cw as Ft,cx as Tt,cy as Rt,U as Ot,ag as Sn,cz as _t,cA as Mt,cB as Nt,cC as Ut,cD as Bt,cE as Vt,cF as Ht,cG as Zt,cH as qt,t as Ye,k as hn,cI as Yt,cJ as Kt,cK as Qt,cL as Gt,cM as zt,cN as Wt,cO as Jt}from"./index-BmT_wdak.js";import"./mui-CeNVlxCm.js";import{A as Y}from"./AddressScreen-2iFQsQhr.js";import M from"./NotFoundScreen-CbKfgA9a.js";import{YI as Xt,YJ as ei,uv as Ke,YK as je,YL as K,vz as Qe,vG as ni,vL as Cn,YM as De,YN as In,vD as En,YO as Pe,vB as kn,yg as ti,vC as ii,YP as Q,uY as se,vv as oi,x7 as Ge,uX as he,YQ as ai,YR as yn,vS as si,YS as G,vZ as ci,YT as ri,YU as xn,YV as bn,y2 as li,YW as de,YX as ze,YY as jn,uV as di,YZ as ui,uP as gi,Y_ as mi,xk as vi,Y$ as Dn,xt as We,Z0 as pi,xq as fi,Z1 as Ae,gd as Si,Z2 as ee,Z3 as ne,wc as hi,v1 as Je,Z4 as Le,v6 as Pn,v4 as Ci,u_ as Ii,w5 as Ei,v8 as ki,we as yi,Z5 as Ce,wm as An,wk as Ie,F6 as $e,xz as Xe,Z6 as xi,uW as we,Z7 as Fe,vh as Ee,ve as ke,vr as Ln,vq as Te,vb as bi,vk as $n,vt as ie,fB as Re,Uv as wn,uZ as Oe,vo as ji,vp as Di,vn as Pi,Z8 as Ai,vV as en,v_ as Li,vW as Fn,Z9 as Tn,uJ as nn,Za as $i,uF as Rn,Zb as wi,xF as Fi,xJ as Z,xE as Ti,wN as _e,Zc as Ri,Zd as On,xS as tn,Ze as Oi,xP as _i,Zf as _n,wQ as Mi,wR as V,wU as Ni,Zg as Mn,x2 as me,Zh as Ui,wd as Nn,T3 as Un,Zi as Bi,xc as Vi,Zj as Bn,Zk as Hi,Zl as Zi,Zm as qi,yH as Yi,Zn as Ki,Zo as Vn,xZ as Hn,Zp as Zn,yF as ve,Zq as Qi,yC as Gi,Zr as zi,Zs as Wi,Zt as Ji,Zu as Xi,Zv as eo,Zw as on,Zx as no,yL as to,Zy as Me,ww as an,Zz as Ne,ZA as ce,wG as qn,wB as Yn,wz as ye,ZB as io,wr as oo,y3 as Kn,yu as sn,yp as ao,ZC as so,y4 as co,ZD as ro,yv as lo,yz as uo,ZE as go,ZF as Qn,c7 as mo,m6 as vo,m7 as po,ZG as cn,vA as re,gh as fo,tX as So,md as ho,ym as Gn,yX as Co,yj as zn,u1 as Io,yU as rn,tR as Eo,yR as ln,hP as ko,Tv as dn,Tw as yo,Fi as Wn,hH as xo,ZH as bo,Uk as jo,ZI as Do,z1 as pe,z2 as Po,ZJ as Ao,ZK as Jn,y_ as Lo,ZL as $o,ZM as wo,xg as Fo,ZN as To}from"./zeni-epic-state-Bo1fQFWK.js";import{M as Ro}from"./MobileAppDrawer-AMYN8Gjf.js";import{q as le}from"./QBOConnectionScreen-CgDmO8dD.js";import"./recharts-BKC_cH7h.js";import"./analytics-WNjEvDwJ.js";import"./plaid-D9ECXCuG.js";import"./dnd-Cyb1SC5Y.js";import"./stripe-cKAAJElX.js";import"./lottie-DYRVCvl4.js";import"./lexical-VH6dL15l.js";import"./pdf-Dhhhum3V.js";import"./utils-X6jrk5Hl.js";import"./InboxNotificationsProvider-DLtCSJ1e.js";import"./useTaskManagerAccess-LntCDDBS.js";import"./empty-M_3v5JZA.js";import"./pdf-lib-BXvJUWv4.js";import"./index-DGxDcX9G.js";import"./url-CV8DVrqd.js";import"./index-DTuBENEN.js";import"./decodeURIComponentSafe-B0jtUms3.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]="18b6efff-cf65-45db-9f1c-27dcf4e6765e",t._sentryDebugIdIdentifier="sentry-dbid-18b6efff-cf65-45db-9f1c-27dcf4e6765e")}catch{}})();const w=({event:t,isReady:e=!0})=>e?s.jsx(lt,{analytics:p,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function Oo(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),{fetchState:m,hasMore:S,items:f,nextCursor:h,auditLogEntityRouteOptions:j,auditLogListSortFieldOptions:k}=E(Xt),x=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),b=`/${n??""}/invoicing`,I=r.useCallback(((_,R)=>{const U=ei(b,_,R,j);U!=null&&(p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{entity:_,entityId:R,fromScreen:"audit_log"}),e(U))}),[j,e,b]);r.useEffect((()=>{const _=setTimeout((()=>d(o)),300);return()=>clearTimeout(_)}),[o]),r.useEffect((()=>{i&&t(Ke({filters:x,keepExistingListItems:!1,sort:u}))}),[i,x,u,t]);const D=m==="Not-Started"||m==="In-Progress"&&f.length===0,C=m==="In-Progress"&&f.length>0,L=m==="Completed";return N(m)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingAuditLogPage,isReady:L}),s.jsx(dt,{auditLogEntityRouteOptions:j,auditLogListSortFieldOptions:k,entries:f,hasMore:S,isLoading:D,isLoadingMore:C,searchValue:o,sortState:l,onEntityLinkClick:I,onLoadMore:()=>{S&&h!=null&&t(Ke({cursor:h,filters:x,keepExistingListItems:!0,sort:u}))},onSearchChange:a,onSortChange:v})]})}const _o=new Set(["plan"]),Xn=[],Mo=In((t=>t.length>0?t:Xn),mt),No=In((t=>t.length>0?t:Xn),gt),Uo=O((function(t,e){const{view:n}=e;return{groupedAccountOptions:Mo(n.qboAccountHierarchy),groupedClassOptions:No(n.qboClassHierarchy),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!==""?o=>{i!==""&&t(En({action:o,id:i}))}:void 0,onEditChange:o=>{i!==""&&t(De({id:i,localData:o}))},onSaveEdit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemEdited,{itemId:i}),t(Cn({id:i}))},onSubFamilyLifecycleAction:(o,a)=>{i!==""&&t(ni({action:a,id:o,parentItemId:i}))}}}))(ut);function Bo(){const t=P(),e=A(),{item_id:n,tenantEmailDomain:i}=F(),[o]=z(),{areTenantIdsInSync:a}=T(),c=(d=o.get("kind"))!=null&&_o.has(d)?d:"plan";var d;const l=E((k=>je(k,n))),{pageFetchState:v,plan:u}=l,m=v.fetchState;r.useEffect((()=>(t(K()),()=>{t(K())})),[t]),r.useEffect((()=>{a&&t(Qe({id:n,kind:c}))}),[a,n,c,t]);const[S,f]=r.useState(0);r.useEffect((()=>{l.fetchState==="Completed"&&(t(K()),t(Qe({cacheOverride:!0,id:n,kind:c})),f((k=>k+1)))}),[l.fetchState,t,n,c]);const h=u==null&&(m==="Not-Started"||m==="In-Progress"),j=m==="Completed";return N(m)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCatalogItemDetailPage,isReady:j}),s.jsx(Uo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:c,isLoading:h,view:l},S)]})}function Ue(t={}){const{enabled:e=!0,fetchSyncHealth:n=!1,loadAccountingPickers:i=!1,reuseCached:o=!1}=t,a=P(),{areTenantIdsInSync:c}=T(),d=E(Pe),l=d.connection?.connected===!0,v=d.connectionFetchState.fetchState;return r.useEffect((()=>{e&&c&&(o&&v!=="Not-Started"||a(kn()),n&&a(ti()))}),[c,a,e,n,o]),r.useEffect((()=>{e&&c&&l&&i&&a(ii())}),[c,a,e,l,i]),{isQboConnected:l,qboView:d}}function Be(t,e=!1){const n=P(),i=E((c=>Q(c).productNextCursor!=null)),o=E((c=>Q(c).productNextCursor)),a=E((c=>Q(c).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&a!=="Not-Started"||n(se({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&a!=="In-Progress"&&i&&o!=null&&n(se({cursor:o,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,a,i,o])}const Vo=new Set(["addon","charge","plan"]),Ho=new Set(["plan"]),Zo=O((function(t,e){const n=je(t,e.itemId);return{fieldHelp:n.fieldHelp,isQboPickerDataLoading:n.isQboPickerDataLoading,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,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",localData:n.localData,mode:n.mode,pricingModelValues:n.pricingModelValues,prorationValues:n.prorationValues,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,tierTypeValues:n.tierTypeValues}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.isEdit?"edit":"create",{itemId:o}=e,a=o!=null?`${n}/catalog/${encodeURIComponent(o)}`:`${n}/catalog`;return{onBack:()=>e.navigate(a),onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemFormCancelled),t(K()),e.navigate(`${n}/catalog`)},onChange:c=>{t(De({id:o,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemSaved,{mode:i}),t(Cn({id:o}))}}}))(vt);function qo(){const t=P(),e=A(),{item_id:n,tenantEmailDomain:i}=F(),[o]=z(),{areTenantIdsInSync:a}=T(),c=n!=null,d=o.get("type"),l=d!=null&&Vo.has(d)?d:void 0,v=(u=o.get("kind"))!=null&&Ho.has(u)?u:"plan";var u;const m=E((S=>je(S,n)));return Be(a,!0),Ue({loadAccountingPickers:!0,reuseCached:!0}),r.useEffect((()=>{a&&n!=null&&t(oi({id:n,kind:v}))}),[a,n,v,t]),r.useEffect((()=>{c||l==null||m.localData.catalogType===l||t(De({localData:{...m.localData,catalogType:l}}))}),[c,l,m.localData?.catalogType,t]),r.useEffect((()=>{if(m.fetchState==="Completed"){const S=m.savedItemId??n,f=S!=null?`/${i}/invoicing/catalog/${encodeURIComponent(S)}`:`/${i}/invoicing/catalog`;e(f),t(K())}}),[m.fetchState,m.savedItemId,n,t,e,i]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCatalogItemFormPage}),s.jsx(Zo,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:c,itemId:n})]})}const Yo={addons:"addon",all:"item",charges:"charge",plans:"plan"},Ko=O((function(t,e){const n=Q(t),i=e.activeTab==="plans",o=e.activeTab==="all",a=i?n.plans:o?[...n.plans,...n.products]:n.products,c=i||o&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:o&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&a.length===0,isLoadingMore:c==="In-Progress"&&a.length>0,plans:n.plans,productColumns:n.productColumns,products:n.products}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",o=e.activeTab==="all",a=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const c=Yo[e.activeTab];p.trackInvoicingActionClick(g.Event.invoicingAddCatalogItemClicked,{itemType:c}),e.navigate(`${n}/catalog/new?type=${c}`)},onItemClick:(c,d)=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemRowClicked,{itemId:d}),e.navigate(`${n}/catalog/${encodeURIComponent(d)}`)},onCatalogItemLifecycleAction:(c,d)=>{t(En({action:ai(d),id:c}))},onLoadMore:()=>{if(o)return e.planNextCursor!=null&&t(he({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&t(se({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));a!=null&&t(i?he({cursor:a,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):se({cursor:a,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(pt);function Qo(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState("plans"),[l,v]=r.useState(""),[u,m]=r.useState(null),S=r.useMemo((()=>u!=null?{dir:u.direction,field:u.columnKey}:void 0),[u]),f=l.trim()!==""?l.trim():void 0,h=r.useMemo((()=>({search:f,type:"plan"})),[f]),j=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),k=E((_=>Q(_))),x=k.planFilters.search,b=k.planSort,I=k.planNextCursor,D=k.productNextCursor,C=k.fetchState==="Completed",L=k.runningActionId??null;return r.useEffect((()=>{const _=setTimeout((()=>v(o)),300);return()=>clearTimeout(_)}),[o]),r.useEffect((()=>{i&&t(Ge({cacheOverride:!1,planFilters:h,productFilters:j,planSort:S,productSort:S}))}),[i,t,h,j,S]),r.useEffect((()=>{i&&(f!==x||S?.field!==b?.field||S?.dir!==b?.dir)&&t(Ge({cacheOverride:!0,planFilters:h,productFilters:j,planSort:S,productSort:S}))}),[x,b,i,t,h,j,f,S]),N(k.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCatalogPage,isReady:C}),s.jsx(Ko,{navigate:e,tenantEmailDomain:n,activeTab:c,searchValue:o,sortState:u,planFilters:h,productFilters:j,sort:S,planNextCursor:I,productNextCursor:D,runningCatalogItemActionId:L,onSearchChange:a,onTabChange:d,onSortChange:m})]})}const Go=O((function(t,e){const n=yn(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,isSubmitting:n.fetchState==="In-Progress",localData:n.localData,mode:n.mode,periodUnitOptions:n.periodUnitOptions}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,o=i!=null?"edit":"create",a=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>e.navigate(a),onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCouponFormCancelled),t(G()),e.navigate(`${n}/discounts`)},onChange:c=>{t(ri({id:i,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCouponSaved,{mode:o}),t(ci({id:i}))}}}))(ft);function zo(){const t=P(),e=A(),{coupon_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),{fetchState:a,savedCouponId:c}=E((d=>yn(d,n)));return r.useEffect((()=>{o&&n!=null&&t(si({id:n}))}),[o,n,t]),r.useEffect((()=>{if(a==="Completed"){const d=c??n,l=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(l),t(G())}}),[a,c,n,t,e,i]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCouponFormPage}),s.jsx(Go,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Wo=O((function(t){const e=xn(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:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:o=>{e(jn(o))},onSubmit:()=>{const o=ui(t.localData);p.trackInvoicingActionClick(g.Event.invoicingInvoiceCreated,{customerId:o.customer_id,lineItemCount:o.line_items?.length}),e(gi(o))}}}))(ht);function Jo(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),[i]=z(),{areTenantIdsInSync:o}=T(),a=i.get("customerId"),c=E((I=>xn(I))),d=c.fetchState,l=c.localData,v=c.savedInvoiceId,u=E(bn),m=E((I=>li(I))),S=E(de),f=m.fetchState==="Not-Started"||m.fetchState==="In-Progress"&&u==null,h=S.fetchState==="Not-Started"||S.fetchState==="In-Progress"&&S.customers.length===0,j=f||h,k=m.fetchState==="Completed"&&S.fetchState==="Completed";r.useEffect((()=>(t(ze()),()=>{t(ze())})),[t]);const x=r.useRef(!1);r.useEffect((()=>{x.current||a==null||a===""||l.customerId!==""||(x.current=!0,t(jn({...l,customerId:a})))}),[a,l,t]),r.useEffect((()=>{o&&t(di({cacheOverride:!1}))}),[o,t]);const b=r.useRef(d);return r.useEffect((()=>{const I=b.current;if(b.current=d,I!=="Completed"&&d==="Completed"){const D=v!=null?`/${n}/invoicing/invoices/${encodeURIComponent(v)}`:`/${n}/invoicing/invoices`;e(D)}}),[d,v,e,n]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCreateInvoicePage,isReady:k}),j?s.jsx(St,{}):s.jsx(Wo,{navigate:e,tenantEmailDomain:n})]})}const Xo=O((function(t,e){const{detailView:n}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:n.creditNote,creditNoteId:e.creditNoteId,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${n}/credits`),onCustomerClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(Ct);function ea(){const t=P(),e=A(),{credit_note_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),a=E((d=>mi(d,n??""))),c=a.fetchState==="Completed";return r.useEffect((()=>{o&&n!=null&&t(vi({id:n}))}),[o,n,t]),N(a.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCreditDetailPage,isReady:c}),s.jsx(Xo,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:a})]})}const na=O((function(t){const e=Dn(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:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&t(fi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(It);function ta(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,creditNoteListFetchState:k}=E((b=>{const I=Dn(b);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,creditNoteListFetchState:I.fetchState}}),H),x=k==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&t(We({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(We({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCreditsListPage,isReady:x}),s.jsx(na,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onStatusChange:b=>t(pi(b)),onSortChange:v})]})}const et=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},ia=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:n.record.invoicingCustomer==null&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),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:o=>{t(Ce({id:i,localData:o}))},onCreateInvoice:()=>e.navigate(`${n}/invoices/create`),onInvoiceClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(o)}`)},onCreatePromotionalCredits:()=>e.onCreatePromotionalCredits(),onNewSubscription:()=>e.navigate(`${n}/subscriptions/new`),onOpenAddress:()=>{const o=et(e.tenantEmailDomain??"",Ie,i),a=J(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(o,{state:{pathnameStackToGoBack:a}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:o=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerEdited,{customerId:i}),t(Ce({id:i,localData:o})),t(An({id:i}))},onFetchPaymentLinkEmailPreview:o=>t(yi({cacheOverride:o,customerId:i})),onSendPaymentLink:(o,a,c)=>t(ki({body:c,customerId:i,email:o,subject:a})),onSubscriptionClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:o,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(o)}`)}}}))(yt);function oa(){const t=P(),e=A(),n=W(),{customer_id:i,tenantEmailDomain:o}=F(),{areTenantIdsInSync:a}=T(),c=E((L=>Ae(L,i))),d=c.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(!1),[m,S]=r.useState(!1),{plaidTokenFetchState:f,promotionalCreditSubmitState:h}=c,{paymentMethodSaveState:j,setupIntentFetchState:k,stripeConnected:x}=c.record,b=r.useRef(c.record.sendLinkState.fetchState);r.useEffect((()=>{const L=c.record.sendLinkState.fetchState;b.current!=="Error"&&L==="Error"&&t(Si({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),b.current=L}),[t,c.record.sendLinkState.fetchState]);const I=k.fetchState==="Error"?k.error?.message??"Failed to start card setup.":j.fetchState==="Error"?j.error?.message??"Failed to save payment method.":f.fetchState==="Error"?f.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(t(ee()),t(ne()),()=>{t(ee()),t(ne())})),[t]),r.useEffect((()=>{n.state?.openPromotionalCreditsDialog===!0&&(S(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{a&&i!=null&&t(hi({id:i}))}),[a,i,t]),r.useEffect((()=>{a&&i!=null&&x&&t(Je({customerId:i}))}),[a,i,t,x]);const[D,C]=r.useState(0);return r.useEffect((()=>{c.fetchState==="Completed"&&(t(Le()),i!=null&&t(Pn({id:i})),C((L=>L+1)))}),[c.fetchState,t,i]),N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCustomerDetailPage,isReady:l}),s.jsx(ia,{customerId:i??"",editView:c,location:n,navigate:e,tenantEmailDomain:o,onAddPaymentMethod:()=>{t(ee()),i!=null&&x&&t(Je({customerId:i})),u(!0)},onCreatePromotionalCredits:()=>{t(ne()),S(!0)}},D),s.jsx(Et,{errorMessage:I,isCreatingSetupIntent:k.fetchState==="In-Progress",isSaving:j.fetchState==="In-Progress",open:v,plaidLinkToken:c.record.plaidLinkToken,saveSucceeded:j.fetchState==="Completed",setupIntent:c.record.setupIntent,stripeConnected:x,onChooseCard:()=>{i!=null&&t(Ii({customerId:i}))},onClose:()=>{u(!1),t(ee())},onSavePaymentMethod:L=>{i!=null&&t(Ci({customerId:i,data:L}))}}),s.jsx(kt,{currentBalance:c.record.invoicingCustomer?.promotionalCredits,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:h.fetchState==="Error"?h.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:h.fetchState==="In-Progress",open:m,submitSucceeded:h.fetchState==="Completed",onClose:()=>{S(!1),t(ne())},onSubmit:({amount:L,description:_})=>{i!=null&&t(Ei({amount:L,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:_}))}})]})}const aa=O((function(t,e){const n=Ae(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",localData:n.localData,mode:n.mode}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,o=i!=null?"edit":"create",a=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>e.navigate(a),onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerFormCancelled),t(Le()),t($e(Ie)),e.navigate(`${n}/customers`)},onChange:c=>{t(Ce({id:i,localData:c}))},onOpenAddress:()=>{const c=et(e.tenantEmailDomain??"",Ie,i),d=J(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerSaved,{mode:o}),t(An({id:i}))}}}))(xt);function sa(){const t=P(),e=A(),n=W(),{customer_id:i,tenantEmailDomain:o}=F(),{areTenantIdsInSync:a}=T(),{fetchState:c,savedCustomerId:d}=E((l=>Ae(l,i)));return r.useEffect((()=>{a&&i!=null&&t(Pn({id:i}))}),[a,i,t]),r.useEffect((()=>{if(c==="Completed"){const l=d??i,v=l!=null?`/${o}/invoicing/customers/${encodeURIComponent(l)}`:`/${o}/invoicing/customers`;e(v),t(Le())}}),[c,d,i,t,e,o]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCustomerFormPage}),s.jsx(aa,{customerId:i,location:n,navigate:e,tenantEmailDomain:o})]})}const ca=O((function(t){const e=de(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:()=>{p.trackInvoicingActionClick(g.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,o)=>{switch(o){case"createInvoice":e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":e.navigate(`${n}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&t(we({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(bt);function ra(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,customerListFetchState:k}=E((b=>{const I=de(b);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,customerListFetchState:I.fetchState}}),H),x=k==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&t(Xe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Xe({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCustomersListPage,isReady:x}),s.jsx(ca,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onStatusChange:b=>t(xi(b)),onSortChange:v})]})}const xe=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),la=O((function(t,e){const{filters:n,sessionId:i,view:o}=e,a=i==null?void 0:o.diagnosticsBySession[i],c=a?.fetch.fetchState??"Not-Started";return{diagnostics:a?.items??[],errorMessage:c==="Error"?a?.fetch.error?.message:void 0,expired:a?.expired??!1,filters:n,hasMore:a?.nextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress",isLoadingMore:c==="In-Progress"&&(a?.items.length??0)>0,session:xe(o,i)}}),(function(t,e){const{downloadUrl:n,filters:i,navigate:o,sessionId:a,tenantEmailDomain:c,view:d}=e,l=a==null?void 0:d.diagnosticsBySession[a],v=xe(d,a),u=d.actionStateByKind.retry?.fetchState==="In-Progress",m=d.actionStateByKind.rollback?.fetchState==="In-Progress",S=v?.status==="done"&&v.rollback_available_until!=null&&new Date(v.rollback_available_until).getTime()>Date.now()&&!m;return{onBack:()=>o(`/${c}/invoicing/data_import`),onDownloadCsv:()=>{n!=null&&window.open(n,"_blank","noopener")},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{a!=null&&l?.nextCursor!=null&&t(ke({...i,cursor:l.nextCursor,sessionId:a}))},onRetry:v?.status!=="failed"||u?void 0:()=>{a!=null&&t(Te(a))},onRollback:S?()=>{a!=null&&t(Ln(a))}:void 0}}))(jt);function da(){const t=P(),e=A(),{sessionId:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),[a,c]=r.useState({}),d=E(Fe),l=xe(d,n),v=n==null?void 0:d.diagnosticsBySession[n];r.useEffect((()=>{o&&n!=null&&t(Ee(n))}),[o,t,n]),r.useEffect((()=>{if(!o||n==null)return;const f=setTimeout((()=>{t(ke({...a,sessionId:n}))}),300);return()=>clearTimeout(f)}),[o,t,a,n]);const u=l?.status==="scanning"||l?.status==="importing";r.useEffect((()=>{if(!o||n==null||!u)return;const f=setInterval((()=>{t(Ee(n)),t(ke({...a,sessionId:n}))}),3e3);return()=>clearInterval(f)}),[o,t,a,u,n]);const m=r.useMemo((()=>{if(n==null)return;const f=new URLSearchParams;a.moduleId!=null&&f.set("module_id",a.moduleId),a.level!=null&&f.set("level",a.level),a.outcome!=null&&f.set("outcome",a.outcome),a.search!=null&&a.search.trim()!==""&&f.set("search",a.search.trim());const h=f.toString();return`${ae?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${h===""?"":`?${h}`}`}),[a,n]),S=v?.fetch.fetchState??"Not-Started";return N(S)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDataImportHubPage,isReady:l!=null&&S!=="Not-Started"}),s.jsx(la,{downloadUrl:m,filters:a,navigate:e,sessionId:n,tenantEmailDomain:i,view:d,onFiltersChange:c})]})}const nt=t=>`invoicing_active_migration:${t}`,oe=(t,e)=>{if(t!=null&&t!=="")try{const n=nt(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},ua=O((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:o,statusRows:a}=e.view;return{isLoading:!(o.fetchState!=="Not-Started"&&o.fetchState!=="In-Progress"||a.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:a}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,o=a=>{const c=a??null;t(ie(c)),oe(i,c),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"continue",sessionId:a}),o(a)},onNewImport:()=>{p.trackInvoicingActionClick(g.Event.invoicingNewImportClicked),o()},onRetrySession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"retry",sessionId:a}),t(Te(a)),o(a)},onRollbackSession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"rollback",sessionId:a}),t(Ln(a))},onViewSession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"view_details",sessionId:a}),n(`/${i}/invoicing/data_import/${encodeURIComponent(a)}`)}}}))(Dt);function ga(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),o=E(Fe);r.useEffect((()=>{i&&(t(bi()),t($n()))}),[i,t]);const a=o.statusFetch.fetchState==="Completed"&&o.sessionsFetch.fetchState==="Completed";return s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDataImportHubPage,isReady:a}),s.jsx(ua,{navigate:e,tenantEmailDomain:n,view:o})]})}const ma=O((function(t,e){const{activeId:n,integrationsView:i,settings:o,view:a}=e,{actionStateByKind:c,sessionDetail:d,sessions:l}=a,v=i.externalConnections?.revenue?.find((m=>m.connectionName==="chargebee")),u=n!=null?d[n]:void 0;return{chargebeeConnected:o?.chargebee_connected===!0||(v?.isValid??!1),chargebeeConnectorAvailable:v!=null,chargebeeSite:o?.chargebee_site,connectError:c.connect?.error?.message,connecting:c.connect?.fetchState==="In-Progress",retrying:c.retry?.fetchState==="In-Progress",session:u??l.find((m=>m.id===n)),starting:c.start?.fetchState==="In-Progress",uploading:c.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:o}=e;return{onBack:e.onBack,onDownloadTemplates:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportTemplatesDownloaded);const a=ae?.invoicingMicroServiceBaseUrl,c=a!=null&&a.length>0?a:"";window.open(`${c}/1.0/data-import/templates`,"_blank","noopener")},onFetchFromChargebee:()=>{p.trackInvoicingActionClick(g.Event.invoicingChargebeeConnectClicked),t(Pi())},onGoToIntegrations:()=>{i(`/${o}/invoicing/settings`)},onGoToOverview:()=>i(`/${o}/invoicing/overview`),onRetry:()=>{n!=null&&t(Te(n))},onSaveLater:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportStarted),n!=null&&t(Di(n))},onUpload:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportFileUploaded),t(ji({files:a}))},onViewDetails:n==null?void 0:()=>i(`/${o}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(Pt);function va(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),o=E(bn),a=E(Re).companyId??Se.getSignedInUserTenant(n??"")?.companyId,c=E((f=>wn(f,a))),d=E(Fe),{activeMigrationSessionId:l}=d,v=l??void 0,u=v!=null?d.sessionDetail[v]??d.sessions.find((f=>f.id===v)):void 0;r.useEffect((()=>{i&&(t(Oe()),t($n()))}),[i,t]),r.useEffect((()=>{if(l!=null)return;const f=(h=>{if(h==null||h==="")return null;try{return sessionStorage.getItem(nt(h))}catch{return null}})(n);f!=null&&t(ie(f))}),[l,t,n]),r.useEffect((()=>{oe(n,l)}),[l,n]);const m=u?.status,S=m==="scanning"||m==="importing";return r.useEffect((()=>{if(!i||v==null||!S)return;const f=setInterval((()=>{t(Ee(v))}),3e3);return()=>clearInterval(f)}),[i,v,S,t]),r.useEffect((()=>{m==="done"&&(t(ie(null)),oe(n,null))}),[t,m,n]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDataImportMigratePage}),s.jsx(ma,{activeId:v,integrationsView:c,navigate:e,settings:o,tenantEmailDomain:n,view:d,onBack:()=>{t(ie(null)),oe(n,null),e(`/${n}/invoicing/data_import`)}})]})}const pa=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,isLoading:n.coupon==null&&(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:o=>{t(Fn({action:o,id:i}))},onSaveEdit:o=>{p.trackInvoicingActionClick(g.Event.invoicingCouponEdited,{couponId:i}),t(Li({data:o,id:i}))}}}))(At);function fa(){const t=P(),e=A(),{coupon_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),a=E((m=>Ai(m,n))),c=a.actionState.fetchState==="In-Progress",d=a.pageFetchState.fetchState,l=d==="Completed";r.useEffect((()=>(t(G()),()=>{t(G())})),[t]),r.useEffect((()=>{o&&t(en({id:n}))}),[o,n,t]);const[v,u]=r.useState(0);return r.useEffect((()=>{a.fetchState==="Completed"&&(t(G()),t(en({cacheOverride:!0,id:n})),u((m=>m+1)))}),[a.fetchState,t,n]),N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDiscountDetailPage,isReady:l}),s.jsx(pa,{couponId:n??"",discountLifecycleActionOptions:a.discountLifecycleActionOptions,editView:a,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},v)]})}const Sa=O((function(t){const e=Tn(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=>{p.trackInvoicingActionClick(g.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,o)=>{t(Fn({action:o,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(Rn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Lt);function ha(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,couponListFetchState:k,runningDiscountActionId:x}=E((I=>{const D=Tn(I);return{activeStatus:D.activeTab,appliedSearch:D.filters.search,appliedSort:D.sort,nextCursor:D.nextCursor,couponListFetchState:D.fetchState,runningDiscountActionId:D.runningActionId??null}}),H),b=k==="Completed";return r.useEffect((()=>{const I=setTimeout((()=>d(o)),300);return()=>clearTimeout(I)}),[o]),r.useEffect((()=>{i&&t(nn({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(nn({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDiscountsListPage,isReady:b}),s.jsx(Sa,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,runningDiscountActionId:x,onSearchChange:a,onStatusChange:I=>t($i(I)),onSortChange:v})]})}const Ca=O((function(t,e){const{readView:n}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:n.dunningCase,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,o=i!=="";return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:a=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onCancel:o?()=>t(Z({action:"cancel",id:i})):void 0,onResolve:o?()=>{p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"resolve",caseId:i}),t(Z({action:"resolve",id:i}))}:void 0,onResume:o?()=>{p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"resume",caseId:i}),t(Z({action:"resume",id:i}))}:void 0,onRetry:o?()=>{p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"retry",caseId:i}),t(Z({action:"retry",id:i}))}:void 0}}))(wt);function Ia(){const t=P(),e=A(),{case_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),a=E((C=>wi(C,n??""))),c=a.fetchState==="Completed",d=a.dunningCase?.invoiceID,[l,v]=r.useState("idle"),[u,m]=r.useState(!1),[S,f]=r.useState(),[h,j]=r.useState(!1),k=r.useCallback((()=>{v("idle"),m(!1),f(void 0),j(!1)}),[]),x=r.useCallback((()=>{if(n==null)return;t(Fi({id:n})),v("idle"),m(!1);const C=a.emailPreview.preview;f(C==null?void 0:{body:C.body,cc:C.cc,subject:C.subject,to:C.to}),j(!0)}),[n,t,a.emailPreview.preview]),b=r.useCallback((C=>{n!=null&&l!=="pending"&&(m(!1),v("pending"),p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"send-email",caseId:n}),t(Z({action:"send-email",body:C,id:n})))}),[n,t,l]),I=r.useMemo((()=>a.emailPreview.preview==null?void 0:{bodyToken:a.emailPreview.preview.bodyToken,renderedHtmlTemplate:a.emailPreview.preview.renderedHtmlTemplate,subjectToken:a.emailPreview.preview.subjectToken}),[a.emailPreview.preview]);r.useEffect((()=>{o&&n!=null&&t(Ti({id:n}))}),[o,n,t]),r.useEffect((()=>{o&&d!=null&&t(_e({invoiceId:d}))}),[o,d,t]),r.useEffect((()=>{v("idle"),m(!1),f(void 0),j(!1)}),[n]),r.useEffect((()=>{o||(v("idle"),m(!1),f(void 0),j(!1))}),[o]),r.useEffect((()=>{h&&S==null&&a.emailPreview.preview!=null&&f({body:a.emailPreview.preview.body,cc:a.emailPreview.preview.cc,subject:a.emailPreview.preview.subject,to:a.emailPreview.preview.to})}),[a.emailPreview.preview,S,h]),r.useEffect((()=>{l==="pending"&&(a.actionState.fetchState!=="In-Progress"?u&&a.actionState.fetchState==="Completed"?(n!=null&&t(Ri({id:n})),k()):u&&a.actionState.fetchState==="Error"&&v("failed"):m(!0))}),[n,k,t,l,u,a.actionState.fetchState]);const D=d!=null&&a.linkedInvoice?.id===d?a.linkedInvoice.dunningAttempts:void 0;return N(a.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDunningDetailPage,isReady:c}),s.jsx(Ca,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:a,dunningAttempts:D,onSendEmail:x}),s.jsx($t,{initialDraft:S,isPreviewLoading:a.emailPreview.fetchState==="Not-Started"||a.emailPreview.fetchState==="In-Progress",isSending:l==="pending",onClose:k,onSend:b,open:h,preview:I,previewErrorMessage:a.emailPreview.fetchState==="Error"?a.emailPreview.error?.message:void 0,sendErrorMessage:l==="failed"?a.actionState.error?.message:void 0})]})}const Ea=O((function(t){const e=On(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:n==="In-Progress"&&e.dunningCases.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;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:i=>{p.trackInvoicingActionClick(g.Event.invoicingDunningCaseRowClicked,{caseId:i}),e.navigate(`${n}/dunning/${encodeURIComponent(i)}`)},onRowAction:(i,o)=>{o!=="retry"&&o!=="resume"&&o!=="resolve"&&o!=="cancel"||t(Z({action:o,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(_i({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Ft);function ka(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,dunningCaseListFetchState:k}=E((b=>{const I=On(b);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,dunningCaseListFetchState:I.fetchState}}),H),x=k==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&t(tn({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(tn({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDunningListPage,isReady:x}),s.jsx(Ea,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onStatusChange:b=>t(Oi(b)),onSortChange:v})]})}const ya=O((function(t,e){const{view:n}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:n.billingAddress,invoice:n.invoice,invoiceId:e.invoiceId,shippingAddress:n.shippingAddress,isLoading:n.invoice==null&&(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;return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:o,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(o)}`)},onIssueCreditNote:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreditNoteIssued,{invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{p.trackInvoicingActionClick(g.Event.invoicingRecordPaymentClicked,{fromScreen:"invoice_detail",invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceRegenerated,{invoiceId:i}),t(V({action:"regenerate",invoiceId:i}))},onSaveEdit:o=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceEdited,{invoiceId:i}),t(Ni({data:{due_date:o.due_date!==""?o.due_date:void 0,notes:o.notes.trim()!==""?o.notes.split(`
1
+ import{j as s}from"./liveblocks-BD1fi6wA.js";import{a as r}from"./sentry-C6D8WJ15.js";import{u as P,h as A,i as F,j as E,t as z,l as O,s as H,g as W,N as B,n as te,o as y}from"./core-Dlma5MIa.js";import{a6 as lt,l as p,ao as T,S as g,c9 as dt,ca as ut,cb as gt,cc as mt,cd as vt,ce as pt,cf as ft,cg as St,ch as ht,ci as Ct,cj as It,ck as Et,cl as kt,cm as yt,p as J,cn as xt,co as bt,ac as ae,cp as jt,cq as Dt,z as Se,cr as Pt,cs as At,ct as Lt,cu as $t,cv as wt,cw as Ft,cx as Tt,cy as Rt,U as Ot,ag as Sn,cz as _t,cA as Mt,cB as Nt,cC as Ut,cD as Bt,cE as Vt,cF as Ht,cG as Zt,cH as qt,t as Ye,k as hn,cI as Yt,cJ as Kt,cK as Qt,cL as Gt,cM as zt,cN as Wt,cO as Jt}from"./index-Blw4A66-.js";import"./mui-DPmPgDDD.js";import{A as Y}from"./AddressScreen-TLZdvXNy.js";import M from"./NotFoundScreen-Wkt8x0Ja.js";import{YI as Xt,YJ as ei,uv as Ke,YK as je,YL as K,vz as Qe,vG as ni,vL as Cn,YM as De,YN as In,vD as En,YO as Pe,vB as kn,yg as ti,vC as ii,YP as Q,uY as se,vv as oi,x7 as Ge,uX as he,YQ as ai,YR as yn,vS as si,YS as G,vZ as ci,YT as ri,YU as xn,YV as bn,y2 as li,YW as de,YX as ze,YY as jn,uV as di,YZ as ui,uP as gi,Y_ as mi,xk as vi,Y$ as Dn,xt as We,Z0 as pi,xq as fi,Z1 as Ae,gd as Si,Z2 as ee,Z3 as ne,wc as hi,v1 as Je,Z4 as Le,v6 as Pn,v4 as Ci,u_ as Ii,w5 as Ei,v8 as ki,we as yi,Z5 as Ce,wm as An,wk as Ie,F6 as $e,xz as Xe,Z6 as xi,uW as we,Z7 as Fe,vh as Ee,ve as ke,vr as Ln,vq as Te,vb as bi,vk as $n,vt as ie,fB as Re,Uv as wn,uZ as Oe,vo as ji,vp as Di,vn as Pi,Z8 as Ai,vV as en,v_ as Li,vW as Fn,Z9 as Tn,uJ as nn,Za as $i,uF as Rn,Zb as wi,xF as Fi,xJ as Z,xE as Ti,wN as _e,Zc as Ri,Zd as On,xS as tn,Ze as Oi,xP as _i,Zf as _n,wQ as Mi,wR as V,wU as Ni,Zg as Mn,x2 as me,Zh as Ui,wd as Nn,T3 as Un,Zi as Bi,xc as Vi,Zj as Bn,Zk as Hi,Zl as Zi,Zm as qi,yH as Yi,Zn as Ki,Zo as Vn,xZ as Hn,Zp as Zn,yF as ve,Zq as Qi,yC as Gi,Zr as zi,Zs as Wi,Zt as Ji,Zu as Xi,Zv as eo,Zw as on,Zx as no,yL as to,Zy as Me,ww as an,Zz as Ne,ZA as ce,wG as qn,wB as Yn,wz as ye,ZB as io,wr as oo,y3 as Kn,yu as sn,yp as ao,ZC as so,y4 as co,ZD as ro,yv as lo,yz as uo,ZE as go,ZF as Qn,c7 as mo,m6 as vo,m7 as po,ZG as cn,vA as re,gh as fo,tX as So,md as ho,ym as Gn,yX as Co,yj as zn,u1 as Io,yU as rn,tR as Eo,yR as ln,hP as ko,Tv as dn,Tw as yo,Fi as Wn,hH as xo,ZH as bo,Uk as jo,ZI as Do,z1 as pe,z2 as Po,ZJ as Ao,ZK as Jn,y_ as Lo,ZL as $o,ZM as wo,xg as Fo,ZN as To}from"./zeni-epic-state-2zvjmkUL.js";import{M as Ro}from"./MobileAppDrawer-BMvh-RAa.js";import{q as le}from"./QBOConnectionScreen-Cxvr0UGn.js";import"./recharts-WuCIKI4c.js";import"./analytics-NBT5BH2R.js";import"./plaid-w5kSeMkL.js";import"./dnd-BgBEAfSC.js";import"./stripe-cKAAJElX.js";import"./lottie-Dd5kLrRz.js";import"./lexical-Cc-23sPJ.js";import"./pdf-BCsxh4ki.js";import"./utils-Bv9LDtmr.js";import"./InboxNotificationsProvider-7eYmgI1F.js";import"./useTaskManagerAccess-BKVtGCGL.js";import"./empty-DpC6uPKD.js";import"./pdf-lib-BSghpPvP.js";import"./index-Cr8P80rT.js";import"./url-BVCS53n5.js";import"./index-CYHgs6V3.js";import"./decodeURIComponentSafe-MgEJs-XP.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]="18b6efff-cf65-45db-9f1c-27dcf4e6765e",t._sentryDebugIdIdentifier="sentry-dbid-18b6efff-cf65-45db-9f1c-27dcf4e6765e")}catch{}})();const w=({event:t,isReady:e=!0})=>e?s.jsx(lt,{analytics:p,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function Oo(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),{fetchState:m,hasMore:S,items:f,nextCursor:h,auditLogEntityRouteOptions:j,auditLogListSortFieldOptions:k}=E(Xt),x=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),b=`/${n??""}/invoicing`,I=r.useCallback(((_,R)=>{const U=ei(b,_,R,j);U!=null&&(p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{entity:_,entityId:R,fromScreen:"audit_log"}),e(U))}),[j,e,b]);r.useEffect((()=>{const _=setTimeout((()=>d(o)),300);return()=>clearTimeout(_)}),[o]),r.useEffect((()=>{i&&t(Ke({filters:x,keepExistingListItems:!1,sort:u}))}),[i,x,u,t]);const D=m==="Not-Started"||m==="In-Progress"&&f.length===0,C=m==="In-Progress"&&f.length>0,L=m==="Completed";return N(m)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingAuditLogPage,isReady:L}),s.jsx(dt,{auditLogEntityRouteOptions:j,auditLogListSortFieldOptions:k,entries:f,hasMore:S,isLoading:D,isLoadingMore:C,searchValue:o,sortState:l,onEntityLinkClick:I,onLoadMore:()=>{S&&h!=null&&t(Ke({cursor:h,filters:x,keepExistingListItems:!0,sort:u}))},onSearchChange:a,onSortChange:v})]})}const _o=new Set(["plan"]),Xn=[],Mo=In((t=>t.length>0?t:Xn),mt),No=In((t=>t.length>0?t:Xn),gt),Uo=O((function(t,e){const{view:n}=e;return{groupedAccountOptions:Mo(n.qboAccountHierarchy),groupedClassOptions:No(n.qboClassHierarchy),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!==""?o=>{i!==""&&t(En({action:o,id:i}))}:void 0,onEditChange:o=>{i!==""&&t(De({id:i,localData:o}))},onSaveEdit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemEdited,{itemId:i}),t(Cn({id:i}))},onSubFamilyLifecycleAction:(o,a)=>{i!==""&&t(ni({action:a,id:o,parentItemId:i}))}}}))(ut);function Bo(){const t=P(),e=A(),{item_id:n,tenantEmailDomain:i}=F(),[o]=z(),{areTenantIdsInSync:a}=T(),c=(d=o.get("kind"))!=null&&_o.has(d)?d:"plan";var d;const l=E((k=>je(k,n))),{pageFetchState:v,plan:u}=l,m=v.fetchState;r.useEffect((()=>(t(K()),()=>{t(K())})),[t]),r.useEffect((()=>{a&&t(Qe({id:n,kind:c}))}),[a,n,c,t]);const[S,f]=r.useState(0);r.useEffect((()=>{l.fetchState==="Completed"&&(t(K()),t(Qe({cacheOverride:!0,id:n,kind:c})),f((k=>k+1)))}),[l.fetchState,t,n,c]);const h=u==null&&(m==="Not-Started"||m==="In-Progress"),j=m==="Completed";return N(m)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCatalogItemDetailPage,isReady:j}),s.jsx(Uo,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:c,isLoading:h,view:l},S)]})}function Ue(t={}){const{enabled:e=!0,fetchSyncHealth:n=!1,loadAccountingPickers:i=!1,reuseCached:o=!1}=t,a=P(),{areTenantIdsInSync:c}=T(),d=E(Pe),l=d.connection?.connected===!0,v=d.connectionFetchState.fetchState;return r.useEffect((()=>{e&&c&&(o&&v!=="Not-Started"||a(kn()),n&&a(ti()))}),[c,a,e,n,o]),r.useEffect((()=>{e&&c&&l&&i&&a(ii())}),[c,a,e,l,i]),{isQboConnected:l,qboView:d}}function Be(t,e=!1){const n=P(),i=E((c=>Q(c).productNextCursor!=null)),o=E((c=>Q(c).productNextCursor)),a=E((c=>Q(c).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&a!=="Not-Started"||n(se({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&a!=="In-Progress"&&i&&o!=null&&n(se({cursor:o,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,a,i,o])}const Vo=new Set(["addon","charge","plan"]),Ho=new Set(["plan"]),Zo=O((function(t,e){const n=je(t,e.itemId);return{fieldHelp:n.fieldHelp,isQboPickerDataLoading:n.isQboPickerDataLoading,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,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",localData:n.localData,mode:n.mode,pricingModelValues:n.pricingModelValues,prorationValues:n.prorationValues,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,tierTypeValues:n.tierTypeValues}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.isEdit?"edit":"create",{itemId:o}=e,a=o!=null?`${n}/catalog/${encodeURIComponent(o)}`:`${n}/catalog`;return{onBack:()=>e.navigate(a),onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemFormCancelled),t(K()),e.navigate(`${n}/catalog`)},onChange:c=>{t(De({id:o,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemSaved,{mode:i}),t(Cn({id:o}))}}}))(vt);function qo(){const t=P(),e=A(),{item_id:n,tenantEmailDomain:i}=F(),[o]=z(),{areTenantIdsInSync:a}=T(),c=n!=null,d=o.get("type"),l=d!=null&&Vo.has(d)?d:void 0,v=(u=o.get("kind"))!=null&&Ho.has(u)?u:"plan";var u;const m=E((S=>je(S,n)));return Be(a,!0),Ue({loadAccountingPickers:!0,reuseCached:!0}),r.useEffect((()=>{a&&n!=null&&t(oi({id:n,kind:v}))}),[a,n,v,t]),r.useEffect((()=>{c||l==null||m.localData.catalogType===l||t(De({localData:{...m.localData,catalogType:l}}))}),[c,l,m.localData?.catalogType,t]),r.useEffect((()=>{if(m.fetchState==="Completed"){const S=m.savedItemId??n,f=S!=null?`/${i}/invoicing/catalog/${encodeURIComponent(S)}`:`/${i}/invoicing/catalog`;e(f),t(K())}}),[m.fetchState,m.savedItemId,n,t,e,i]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCatalogItemFormPage}),s.jsx(Zo,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:c,itemId:n})]})}const Yo={addons:"addon",all:"item",charges:"charge",plans:"plan"},Ko=O((function(t,e){const n=Q(t),i=e.activeTab==="plans",o=e.activeTab==="all",a=i?n.plans:o?[...n.plans,...n.products]:n.products,c=i||o&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:o&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&a.length===0,isLoadingMore:c==="In-Progress"&&a.length>0,plans:n.plans,productColumns:n.productColumns,products:n.products}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",o=e.activeTab==="all",a=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const c=Yo[e.activeTab];p.trackInvoicingActionClick(g.Event.invoicingAddCatalogItemClicked,{itemType:c}),e.navigate(`${n}/catalog/new?type=${c}`)},onItemClick:(c,d)=>{p.trackInvoicingActionClick(g.Event.invoicingCatalogItemRowClicked,{itemId:d}),e.navigate(`${n}/catalog/${encodeURIComponent(d)}`)},onCatalogItemLifecycleAction:(c,d)=>{t(En({action:ai(d),id:c}))},onLoadMore:()=>{if(o)return e.planNextCursor!=null&&t(he({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&t(se({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));a!=null&&t(i?he({cursor:a,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):se({cursor:a,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(pt);function Qo(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState("plans"),[l,v]=r.useState(""),[u,m]=r.useState(null),S=r.useMemo((()=>u!=null?{dir:u.direction,field:u.columnKey}:void 0),[u]),f=l.trim()!==""?l.trim():void 0,h=r.useMemo((()=>({search:f,type:"plan"})),[f]),j=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),k=E((_=>Q(_))),x=k.planFilters.search,b=k.planSort,I=k.planNextCursor,D=k.productNextCursor,C=k.fetchState==="Completed",L=k.runningActionId??null;return r.useEffect((()=>{const _=setTimeout((()=>v(o)),300);return()=>clearTimeout(_)}),[o]),r.useEffect((()=>{i&&t(Ge({cacheOverride:!1,planFilters:h,productFilters:j,planSort:S,productSort:S}))}),[i,t,h,j,S]),r.useEffect((()=>{i&&(f!==x||S?.field!==b?.field||S?.dir!==b?.dir)&&t(Ge({cacheOverride:!0,planFilters:h,productFilters:j,planSort:S,productSort:S}))}),[x,b,i,t,h,j,f,S]),N(k.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCatalogPage,isReady:C}),s.jsx(Ko,{navigate:e,tenantEmailDomain:n,activeTab:c,searchValue:o,sortState:u,planFilters:h,productFilters:j,sort:S,planNextCursor:I,productNextCursor:D,runningCatalogItemActionId:L,onSearchChange:a,onTabChange:d,onSortChange:m})]})}const Go=O((function(t,e){const n=yn(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,isSubmitting:n.fetchState==="In-Progress",localData:n.localData,mode:n.mode,periodUnitOptions:n.periodUnitOptions}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,o=i!=null?"edit":"create",a=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>e.navigate(a),onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCouponFormCancelled),t(G()),e.navigate(`${n}/discounts`)},onChange:c=>{t(ri({id:i,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCouponSaved,{mode:o}),t(ci({id:i}))}}}))(ft);function zo(){const t=P(),e=A(),{coupon_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),{fetchState:a,savedCouponId:c}=E((d=>yn(d,n)));return r.useEffect((()=>{o&&n!=null&&t(si({id:n}))}),[o,n,t]),r.useEffect((()=>{if(a==="Completed"){const d=c??n,l=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(l),t(G())}}),[a,c,n,t,e,i]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCouponFormPage}),s.jsx(Go,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Wo=O((function(t){const e=xn(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:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:o=>{e(jn(o))},onSubmit:()=>{const o=ui(t.localData);p.trackInvoicingActionClick(g.Event.invoicingInvoiceCreated,{customerId:o.customer_id,lineItemCount:o.line_items?.length}),e(gi(o))}}}))(ht);function Jo(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),[i]=z(),{areTenantIdsInSync:o}=T(),a=i.get("customerId"),c=E((I=>xn(I))),d=c.fetchState,l=c.localData,v=c.savedInvoiceId,u=E(bn),m=E((I=>li(I))),S=E(de),f=m.fetchState==="Not-Started"||m.fetchState==="In-Progress"&&u==null,h=S.fetchState==="Not-Started"||S.fetchState==="In-Progress"&&S.customers.length===0,j=f||h,k=m.fetchState==="Completed"&&S.fetchState==="Completed";r.useEffect((()=>(t(ze()),()=>{t(ze())})),[t]);const x=r.useRef(!1);r.useEffect((()=>{x.current||a==null||a===""||l.customerId!==""||(x.current=!0,t(jn({...l,customerId:a})))}),[a,l,t]),r.useEffect((()=>{o&&t(di({cacheOverride:!1}))}),[o,t]);const b=r.useRef(d);return r.useEffect((()=>{const I=b.current;if(b.current=d,I!=="Completed"&&d==="Completed"){const D=v!=null?`/${n}/invoicing/invoices/${encodeURIComponent(v)}`:`/${n}/invoicing/invoices`;e(D)}}),[d,v,e,n]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCreateInvoicePage,isReady:k}),j?s.jsx(St,{}):s.jsx(Wo,{navigate:e,tenantEmailDomain:n})]})}const Xo=O((function(t,e){const{detailView:n}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:n.creditNote,creditNoteId:e.creditNoteId,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${n}/credits`),onCustomerClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(Ct);function ea(){const t=P(),e=A(),{credit_note_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),a=E((d=>mi(d,n??""))),c=a.fetchState==="Completed";return r.useEffect((()=>{o&&n!=null&&t(vi({id:n}))}),[o,n,t]),N(a.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCreditDetailPage,isReady:c}),s.jsx(Xo,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:a})]})}const na=O((function(t){const e=Dn(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:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&t(fi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(It);function ta(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,creditNoteListFetchState:k}=E((b=>{const I=Dn(b);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,creditNoteListFetchState:I.fetchState}}),H),x=k==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&t(We({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(We({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCreditsListPage,isReady:x}),s.jsx(na,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onStatusChange:b=>t(pi(b)),onSortChange:v})]})}const et=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},ia=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:n.record.invoicingCustomer==null&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),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:o=>{t(Ce({id:i,localData:o}))},onCreateInvoice:()=>e.navigate(`${n}/invoices/create`),onInvoiceClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(o)}`)},onCreatePromotionalCredits:()=>e.onCreatePromotionalCredits(),onNewSubscription:()=>e.navigate(`${n}/subscriptions/new`),onOpenAddress:()=>{const o=et(e.tenantEmailDomain??"",Ie,i),a=J(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(o,{state:{pathnameStackToGoBack:a}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:o=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerEdited,{customerId:i}),t(Ce({id:i,localData:o})),t(An({id:i}))},onFetchPaymentLinkEmailPreview:o=>t(yi({cacheOverride:o,customerId:i})),onSendPaymentLink:(o,a,c)=>t(ki({body:c,customerId:i,email:o,subject:a})),onSubscriptionClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:o,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(o)}`)}}}))(yt);function oa(){const t=P(),e=A(),n=W(),{customer_id:i,tenantEmailDomain:o}=F(),{areTenantIdsInSync:a}=T(),c=E((L=>Ae(L,i))),d=c.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(!1),[m,S]=r.useState(!1),{plaidTokenFetchState:f,promotionalCreditSubmitState:h}=c,{paymentMethodSaveState:j,setupIntentFetchState:k,stripeConnected:x}=c.record,b=r.useRef(c.record.sendLinkState.fetchState);r.useEffect((()=>{const L=c.record.sendLinkState.fetchState;b.current!=="Error"&&L==="Error"&&t(Si({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),b.current=L}),[t,c.record.sendLinkState.fetchState]);const I=k.fetchState==="Error"?k.error?.message??"Failed to start card setup.":j.fetchState==="Error"?j.error?.message??"Failed to save payment method.":f.fetchState==="Error"?f.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(t(ee()),t(ne()),()=>{t(ee()),t(ne())})),[t]),r.useEffect((()=>{n.state?.openPromotionalCreditsDialog===!0&&(S(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{a&&i!=null&&t(hi({id:i}))}),[a,i,t]),r.useEffect((()=>{a&&i!=null&&x&&t(Je({customerId:i}))}),[a,i,t,x]);const[D,C]=r.useState(0);return r.useEffect((()=>{c.fetchState==="Completed"&&(t(Le()),i!=null&&t(Pn({id:i})),C((L=>L+1)))}),[c.fetchState,t,i]),N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCustomerDetailPage,isReady:l}),s.jsx(ia,{customerId:i??"",editView:c,location:n,navigate:e,tenantEmailDomain:o,onAddPaymentMethod:()=>{t(ee()),i!=null&&x&&t(Je({customerId:i})),u(!0)},onCreatePromotionalCredits:()=>{t(ne()),S(!0)}},D),s.jsx(Et,{errorMessage:I,isCreatingSetupIntent:k.fetchState==="In-Progress",isSaving:j.fetchState==="In-Progress",open:v,plaidLinkToken:c.record.plaidLinkToken,saveSucceeded:j.fetchState==="Completed",setupIntent:c.record.setupIntent,stripeConnected:x,onChooseCard:()=>{i!=null&&t(Ii({customerId:i}))},onClose:()=>{u(!1),t(ee())},onSavePaymentMethod:L=>{i!=null&&t(Ci({customerId:i,data:L}))}}),s.jsx(kt,{currentBalance:c.record.invoicingCustomer?.promotionalCredits,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:h.fetchState==="Error"?h.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:h.fetchState==="In-Progress",open:m,submitSucceeded:h.fetchState==="Completed",onClose:()=>{S(!1),t(ne())},onSubmit:({amount:L,description:_})=>{i!=null&&t(Ei({amount:L,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:_}))}})]})}const aa=O((function(t,e){const n=Ae(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",localData:n.localData,mode:n.mode}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,o=i!=null?"edit":"create",a=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>e.navigate(a),onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerFormCancelled),t(Le()),t($e(Ie)),e.navigate(`${n}/customers`)},onChange:c=>{t(Ce({id:i,localData:c}))},onOpenAddress:()=>{const c=et(e.tenantEmailDomain??"",Ie,i),d=J(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerSaved,{mode:o}),t(An({id:i}))}}}))(xt);function sa(){const t=P(),e=A(),n=W(),{customer_id:i,tenantEmailDomain:o}=F(),{areTenantIdsInSync:a}=T(),{fetchState:c,savedCustomerId:d}=E((l=>Ae(l,i)));return r.useEffect((()=>{a&&i!=null&&t(Pn({id:i}))}),[a,i,t]),r.useEffect((()=>{if(c==="Completed"){const l=d??i,v=l!=null?`/${o}/invoicing/customers/${encodeURIComponent(l)}`:`/${o}/invoicing/customers`;e(v),t(Le())}}),[c,d,i,t,e,o]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCustomerFormPage}),s.jsx(aa,{customerId:i,location:n,navigate:e,tenantEmailDomain:o})]})}const ca=O((function(t){const e=de(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:()=>{p.trackInvoicingActionClick(g.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,o)=>{switch(o){case"createInvoice":e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":e.navigate(`${n}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&t(we({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(bt);function ra(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,customerListFetchState:k}=E((b=>{const I=de(b);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,customerListFetchState:I.fetchState}}),H),x=k==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&t(Xe({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(Xe({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingCustomersListPage,isReady:x}),s.jsx(ca,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onStatusChange:b=>t(xi(b)),onSortChange:v})]})}const xe=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),la=O((function(t,e){const{filters:n,sessionId:i,view:o}=e,a=i==null?void 0:o.diagnosticsBySession[i],c=a?.fetch.fetchState??"Not-Started";return{diagnostics:a?.items??[],errorMessage:c==="Error"?a?.fetch.error?.message:void 0,expired:a?.expired??!1,filters:n,hasMore:a?.nextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress",isLoadingMore:c==="In-Progress"&&(a?.items.length??0)>0,session:xe(o,i)}}),(function(t,e){const{downloadUrl:n,filters:i,navigate:o,sessionId:a,tenantEmailDomain:c,view:d}=e,l=a==null?void 0:d.diagnosticsBySession[a],v=xe(d,a),u=d.actionStateByKind.retry?.fetchState==="In-Progress",m=d.actionStateByKind.rollback?.fetchState==="In-Progress",S=v?.status==="done"&&v.rollback_available_until!=null&&new Date(v.rollback_available_until).getTime()>Date.now()&&!m;return{onBack:()=>o(`/${c}/invoicing/data_import`),onDownloadCsv:()=>{n!=null&&window.open(n,"_blank","noopener")},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{a!=null&&l?.nextCursor!=null&&t(ke({...i,cursor:l.nextCursor,sessionId:a}))},onRetry:v?.status!=="failed"||u?void 0:()=>{a!=null&&t(Te(a))},onRollback:S?()=>{a!=null&&t(Ln(a))}:void 0}}))(jt);function da(){const t=P(),e=A(),{sessionId:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),[a,c]=r.useState({}),d=E(Fe),l=xe(d,n),v=n==null?void 0:d.diagnosticsBySession[n];r.useEffect((()=>{o&&n!=null&&t(Ee(n))}),[o,t,n]),r.useEffect((()=>{if(!o||n==null)return;const f=setTimeout((()=>{t(ke({...a,sessionId:n}))}),300);return()=>clearTimeout(f)}),[o,t,a,n]);const u=l?.status==="scanning"||l?.status==="importing";r.useEffect((()=>{if(!o||n==null||!u)return;const f=setInterval((()=>{t(Ee(n)),t(ke({...a,sessionId:n}))}),3e3);return()=>clearInterval(f)}),[o,t,a,u,n]);const m=r.useMemo((()=>{if(n==null)return;const f=new URLSearchParams;a.moduleId!=null&&f.set("module_id",a.moduleId),a.level!=null&&f.set("level",a.level),a.outcome!=null&&f.set("outcome",a.outcome),a.search!=null&&a.search.trim()!==""&&f.set("search",a.search.trim());const h=f.toString();return`${ae?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${h===""?"":`?${h}`}`}),[a,n]),S=v?.fetch.fetchState??"Not-Started";return N(S)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDataImportHubPage,isReady:l!=null&&S!=="Not-Started"}),s.jsx(la,{downloadUrl:m,filters:a,navigate:e,sessionId:n,tenantEmailDomain:i,view:d,onFiltersChange:c})]})}const nt=t=>`invoicing_active_migration:${t}`,oe=(t,e)=>{if(t!=null&&t!=="")try{const n=nt(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},ua=O((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:o,statusRows:a}=e.view;return{isLoading:!(o.fetchState!=="Not-Started"&&o.fetchState!=="In-Progress"||a.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:a}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,o=a=>{const c=a??null;t(ie(c)),oe(i,c),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"continue",sessionId:a}),o(a)},onNewImport:()=>{p.trackInvoicingActionClick(g.Event.invoicingNewImportClicked),o()},onRetrySession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"retry",sessionId:a}),t(Te(a)),o(a)},onRollbackSession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"rollback",sessionId:a}),t(Ln(a))},onViewSession:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportSessionAction,{action:"view_details",sessionId:a}),n(`/${i}/invoicing/data_import/${encodeURIComponent(a)}`)}}}))(Dt);function ga(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),o=E(Fe);r.useEffect((()=>{i&&(t(bi()),t($n()))}),[i,t]);const a=o.statusFetch.fetchState==="Completed"&&o.sessionsFetch.fetchState==="Completed";return s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDataImportHubPage,isReady:a}),s.jsx(ua,{navigate:e,tenantEmailDomain:n,view:o})]})}const ma=O((function(t,e){const{activeId:n,integrationsView:i,settings:o,view:a}=e,{actionStateByKind:c,sessionDetail:d,sessions:l}=a,v=i.externalConnections?.revenue?.find((m=>m.connectionName==="chargebee")),u=n!=null?d[n]:void 0;return{chargebeeConnected:o?.chargebee_connected===!0||(v?.isValid??!1),chargebeeConnectorAvailable:v!=null,chargebeeSite:o?.chargebee_site,connectError:c.connect?.error?.message,connecting:c.connect?.fetchState==="In-Progress",retrying:c.retry?.fetchState==="In-Progress",session:u??l.find((m=>m.id===n)),starting:c.start?.fetchState==="In-Progress",uploading:c.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:o}=e;return{onBack:e.onBack,onDownloadTemplates:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportTemplatesDownloaded);const a=ae?.invoicingMicroServiceBaseUrl,c=a!=null&&a.length>0?a:"";window.open(`${c}/1.0/data-import/templates`,"_blank","noopener")},onFetchFromChargebee:()=>{p.trackInvoicingActionClick(g.Event.invoicingChargebeeConnectClicked),t(Pi())},onGoToIntegrations:()=>{i(`/${o}/invoicing/settings`)},onGoToOverview:()=>i(`/${o}/invoicing/overview`),onRetry:()=>{n!=null&&t(Te(n))},onSaveLater:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportStarted),n!=null&&t(Di(n))},onUpload:a=>{p.trackInvoicingActionClick(g.Event.invoicingImportFileUploaded),t(ji({files:a}))},onViewDetails:n==null?void 0:()=>i(`/${o}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(Pt);function va(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),o=E(bn),a=E(Re).companyId??Se.getSignedInUserTenant(n??"")?.companyId,c=E((f=>wn(f,a))),d=E(Fe),{activeMigrationSessionId:l}=d,v=l??void 0,u=v!=null?d.sessionDetail[v]??d.sessions.find((f=>f.id===v)):void 0;r.useEffect((()=>{i&&(t(Oe()),t($n()))}),[i,t]),r.useEffect((()=>{if(l!=null)return;const f=(h=>{if(h==null||h==="")return null;try{return sessionStorage.getItem(nt(h))}catch{return null}})(n);f!=null&&t(ie(f))}),[l,t,n]),r.useEffect((()=>{oe(n,l)}),[l,n]);const m=u?.status,S=m==="scanning"||m==="importing";return r.useEffect((()=>{if(!i||v==null||!S)return;const f=setInterval((()=>{t(Ee(v))}),3e3);return()=>clearInterval(f)}),[i,v,S,t]),r.useEffect((()=>{m==="done"&&(t(ie(null)),oe(n,null))}),[t,m,n]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDataImportMigratePage}),s.jsx(ma,{activeId:v,integrationsView:c,navigate:e,settings:o,tenantEmailDomain:n,view:d,onBack:()=>{t(ie(null)),oe(n,null),e(`/${n}/invoicing/data_import`)}})]})}const pa=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,isLoading:n.coupon==null&&(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:o=>{t(Fn({action:o,id:i}))},onSaveEdit:o=>{p.trackInvoicingActionClick(g.Event.invoicingCouponEdited,{couponId:i}),t(Li({data:o,id:i}))}}}))(At);function fa(){const t=P(),e=A(),{coupon_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),a=E((m=>Ai(m,n))),c=a.actionState.fetchState==="In-Progress",d=a.pageFetchState.fetchState,l=d==="Completed";r.useEffect((()=>(t(G()),()=>{t(G())})),[t]),r.useEffect((()=>{o&&t(en({id:n}))}),[o,n,t]);const[v,u]=r.useState(0);return r.useEffect((()=>{a.fetchState==="Completed"&&(t(G()),t(en({cacheOverride:!0,id:n})),u((m=>m+1)))}),[a.fetchState,t,n]),N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDiscountDetailPage,isReady:l}),s.jsx(pa,{couponId:n??"",discountLifecycleActionOptions:a.discountLifecycleActionOptions,editView:a,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},v)]})}const Sa=O((function(t){const e=Tn(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=>{p.trackInvoicingActionClick(g.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,o)=>{t(Fn({action:o,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(Rn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Lt);function ha(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,couponListFetchState:k,runningDiscountActionId:x}=E((I=>{const D=Tn(I);return{activeStatus:D.activeTab,appliedSearch:D.filters.search,appliedSort:D.sort,nextCursor:D.nextCursor,couponListFetchState:D.fetchState,runningDiscountActionId:D.runningActionId??null}}),H),b=k==="Completed";return r.useEffect((()=>{const I=setTimeout((()=>d(o)),300);return()=>clearTimeout(I)}),[o]),r.useEffect((()=>{i&&t(nn({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(nn({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDiscountsListPage,isReady:b}),s.jsx(Sa,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,runningDiscountActionId:x,onSearchChange:a,onStatusChange:I=>t($i(I)),onSortChange:v})]})}const Ca=O((function(t,e){const{readView:n}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:n.dunningCase,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,o=i!=="";return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:a=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onCancel:o?()=>t(Z({action:"cancel",id:i})):void 0,onResolve:o?()=>{p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"resolve",caseId:i}),t(Z({action:"resolve",id:i}))}:void 0,onResume:o?()=>{p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"resume",caseId:i}),t(Z({action:"resume",id:i}))}:void 0,onRetry:o?()=>{p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"retry",caseId:i}),t(Z({action:"retry",id:i}))}:void 0}}))(wt);function Ia(){const t=P(),e=A(),{case_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),a=E((C=>wi(C,n??""))),c=a.fetchState==="Completed",d=a.dunningCase?.invoiceID,[l,v]=r.useState("idle"),[u,m]=r.useState(!1),[S,f]=r.useState(),[h,j]=r.useState(!1),k=r.useCallback((()=>{v("idle"),m(!1),f(void 0),j(!1)}),[]),x=r.useCallback((()=>{if(n==null)return;t(Fi({id:n})),v("idle"),m(!1);const C=a.emailPreview.preview;f(C==null?void 0:{body:C.body,cc:C.cc,subject:C.subject,to:C.to}),j(!0)}),[n,t,a.emailPreview.preview]),b=r.useCallback((C=>{n!=null&&l!=="pending"&&(m(!1),v("pending"),p.trackInvoicingActionClick(g.Event.invoicingDunningAction,{action:"send-email",caseId:n}),t(Z({action:"send-email",body:C,id:n})))}),[n,t,l]),I=r.useMemo((()=>a.emailPreview.preview==null?void 0:{bodyToken:a.emailPreview.preview.bodyToken,renderedHtmlTemplate:a.emailPreview.preview.renderedHtmlTemplate,subjectToken:a.emailPreview.preview.subjectToken}),[a.emailPreview.preview]);r.useEffect((()=>{o&&n!=null&&t(Ti({id:n}))}),[o,n,t]),r.useEffect((()=>{o&&d!=null&&t(_e({invoiceId:d}))}),[o,d,t]),r.useEffect((()=>{v("idle"),m(!1),f(void 0),j(!1)}),[n]),r.useEffect((()=>{o||(v("idle"),m(!1),f(void 0),j(!1))}),[o]),r.useEffect((()=>{h&&S==null&&a.emailPreview.preview!=null&&f({body:a.emailPreview.preview.body,cc:a.emailPreview.preview.cc,subject:a.emailPreview.preview.subject,to:a.emailPreview.preview.to})}),[a.emailPreview.preview,S,h]),r.useEffect((()=>{l==="pending"&&(a.actionState.fetchState!=="In-Progress"?u&&a.actionState.fetchState==="Completed"?(n!=null&&t(Ri({id:n})),k()):u&&a.actionState.fetchState==="Error"&&v("failed"):m(!0))}),[n,k,t,l,u,a.actionState.fetchState]);const D=d!=null&&a.linkedInvoice?.id===d?a.linkedInvoice.dunningAttempts:void 0;return N(a.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDunningDetailPage,isReady:c}),s.jsx(Ca,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:a,dunningAttempts:D,onSendEmail:x}),s.jsx($t,{initialDraft:S,isPreviewLoading:a.emailPreview.fetchState==="Not-Started"||a.emailPreview.fetchState==="In-Progress",isSending:l==="pending",onClose:k,onSend:b,open:h,preview:I,previewErrorMessage:a.emailPreview.fetchState==="Error"?a.emailPreview.error?.message:void 0,sendErrorMessage:l==="failed"?a.actionState.error?.message:void 0})]})}const Ea=O((function(t){const e=On(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:n==="In-Progress"&&e.dunningCases.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;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:i=>{p.trackInvoicingActionClick(g.Event.invoicingDunningCaseRowClicked,{caseId:i}),e.navigate(`${n}/dunning/${encodeURIComponent(i)}`)},onRowAction:(i,o)=>{o!=="retry"&&o!=="resume"&&o!=="resolve"&&o!=="cancel"||t(Z({action:o,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&t(_i({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Ft);function ka(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,dunningCaseListFetchState:k}=E((b=>{const I=On(b);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,dunningCaseListFetchState:I.fetchState}}),H),x=k==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>d(o)),300);return()=>clearTimeout(b)}),[o]),r.useEffect((()=>{i&&t(tn({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(tn({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingDunningListPage,isReady:x}),s.jsx(Ea,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onStatusChange:b=>t(Oi(b)),onSortChange:v})]})}const ya=O((function(t,e){const{view:n}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:n.billingAddress,invoice:n.invoice,invoiceId:e.invoiceId,shippingAddress:n.shippingAddress,isLoading:n.invoice==null&&(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;return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:o,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(o)}`)},onIssueCreditNote:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreditNoteIssued,{invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{p.trackInvoicingActionClick(g.Event.invoicingRecordPaymentClicked,{fromScreen:"invoice_detail",invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceRegenerated,{invoiceId:i}),t(V({action:"regenerate",invoiceId:i}))},onSaveEdit:o=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceEdited,{invoiceId:i}),t(Ni({data:{due_date:o.due_date!==""?o.due_date:void 0,notes:o.notes.trim()!==""?o.notes.split(`
2
2
  `).map((a=>a.trim())).filter((a=>a!=="")).map((a=>({note:a}))):void 0,po_number:o.po_number!==""?o.po_number:null},invoiceId:i}))},onSendReminder:()=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceReminderSent,{invoiceId:i}),t(V({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:o,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(o)}`)},onVoid:o=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceVoided,{invoiceId:i}),t(V({action:"void",invoiceId:i,body:o}))}}}))(Tt);function xa(){const t=P(),e=A(),{invoice_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),a=E((l=>_n(l,n??""))),c=a.pageFetchState.fetchState,d=c==="Completed";return r.useEffect((()=>{o&&n!=null&&t(Mi({invoiceId:n}))}),[o,n,t]),N(c)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingInvoiceDetailPage,isReady:d}),s.jsx(ya,{invoiceId:n??"",navigate:e,tenantEmailDomain:i,view:a})]})}const ba=O((function(t){const e=Mn(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`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onCreateInvoice:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreateInvoiceClicked),e.navigate(`${n}/invoices/create`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"invoices"}),e.navigate(`${n}/data_import`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceRowClicked,{invoiceId:i}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onRowAction:(i,o)=>{switch(o){case"recordPayment":e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`);break;case"issueCreditNote":e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`);break;case"sendReminder":t(V({action:"send-reminder",invoiceId:i}));break;case"regenerate":t(V({action:"regenerate",invoiceId:i}));break;case"void":t(V({action:"void",invoiceId:i}))}},onVoidInvoice:(i,o)=>{p.trackInvoicingActionClick(g.Event.invoicingInvoiceVoided,{invoiceId:i}),t(V({action:"void",invoiceId:i,body:o}))},onLoadMore:()=>{e.nextCursor!=null&&t(Nn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Rt);function ja(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,invoiceListFetchState:k,voidingInvoiceId:x}=E((I=>{const D=Mn(I);return{activeStatus:D.activeTab,appliedSearch:D.filters.search,appliedSort:I.invoicingInvoiceListState.sort,nextCursor:D.nextCursor,invoiceListFetchState:D.fetchState,voidingInvoiceId:D.runningActionId}}),H),b=k==="Completed";return r.useEffect((()=>{const I=setTimeout((()=>d(o)),300);return()=>clearTimeout(I)}),[o]),r.useEffect((()=>{i&&t(me({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(me({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingInvoicesListPage,isReady:b}),s.jsx(ba,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,voidingInvoiceId:x,onSearchChange:a,onStatusChange:I=>{t(Ui(I)),t(me({cacheOverride:!1,filters:m,sort:u}))},onSortChange:v})]})}function un(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),i=Ot(),o=Sn(),[a,c]=r.useState(!1),{acceptTermsState:d,status:l}=E(Un),v=Bi(i?.loggedInUserRoleMap),u=`/${n}/invoicing`,m=S=>{c(S)};return l==="completed"?s.jsx(B,{to:`${u}/overview`,replace:!0}):l==="settings"&&v?s.jsx(B,{to:`${u}/settings`,replace:!0}):s.jsxs(s.Fragment,{children:[s.jsx(Ro,{isAppContentDrawerOpen:a,handleDrawerToggle:m}),s.jsx(_t,{analytics:p,isAccepting:d.fetchState==="In-Progress",isReadOnlyUser:!v,meetingUrl:o("invoicing_promo"),onAcceptClick:()=>{t(Vi())},onBackClick:()=>{e(`/${n}`)},onClickMenuIcon:()=>{m(!0)}})]})}const Da=O((function(t,e){const n=Bn(t,e.invoiceId),{invoice:i,localData:o,reasonCodeOptions:a,submitState:c,typeOptions:d}=n;return{fieldHelp:n.fieldHelp,amountDue:i?.amountDue,currencyCode:i?.currencyCode??"USD",customerName:i?.customerName??"",errorMessage:c.fetchState==="Error"?c.error?.message??"Failed to issue credit note. Please try again.":void 0,invoiceNumber:i?.invoiceNumber??e.invoiceId,isSubmitting:c.fetchState==="In-Progress",localData:o,reasonCodeOptions:a,typeOptions:d}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing/invoices/${encodeURIComponent(e.invoiceId)}`,i=()=>e.navigate(n);return{onBack:i,onCancel:i,onChange:o=>{t(Ki({localData:o}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingCreditNoteIssued,{invoiceId:e.invoiceId}),t(Yi())}}}))(Mt);function Pa(){const t=P(),e=A(),{invoice_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),{fetchState:a,invoice:c,isPageReady:d,issuedCreditNoteId:l,submitState:v}=E((f=>Bn(f,n??""))),u=`/${i}/invoicing`,m=r.useRef(null);r.useEffect((()=>{t(Hi()),m.current=null}),[t,n]),r.useEffect((()=>{o&&n!=null&&t(_e({invoiceId:n}))}),[o,t,n]),r.useEffect((()=>{c!=null&&n!=null&&a==="Completed"&&m.current!==n&&(m.current=n,t(Zi({localData:qi(c)})))}),[t,a,c,n]);const S=r.useRef(v.fetchState);return r.useEffect((()=>{const f=S.current;S.current=v.fetchState,f!=="Completed"&&v.fetchState==="Completed"&&l!=null&&e(`${u}/credits/${encodeURIComponent(l)}`)}),[l,e,v.fetchState,u]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingInvoiceDetailPage,isReady:d}),s.jsx(Da,{invoiceId:n??"",navigate:e,tenantEmailDomain:i})]})}const Aa=O((function(t){return{invoicingOverview:Vn(t)}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onRefresh:()=>{t(Hn(e.selectedPeriod,!0))},onSubscriptionClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionTileClicked,{subscriptionId:i}),e.navigate(`${n}/subscriptions/${i}`)},onViewInvoices:()=>{p.trackInvoicingActionClick(g.Event.invoicingViewInvoicesClicked),e.navigate(`${n}/invoices`)},onViewPayments:()=>{p.trackInvoicingActionClick(g.Event.invoicingViewPaymentsClicked),e.navigate(`${n}/payments`)}}}))(Nt);function La(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o]=r.useState((()=>{const c=new Date;return{month:c.getMonth()+1,year:c.getFullYear()}})),a=E((c=>Vn(c).fetchState))==="Completed";return r.useEffect((()=>{i&&t(Hn(o))}),[i,t,o]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingOverviewPage,isReady:a}),s.jsx(Aa,{navigate:e,selectedPeriod:o,tenantEmailDomain:n})]})}const $a=O((function(t){const e=Zn(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:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"payments"}),e.navigate(`${n}/data_import`)},onTransactionClick:i=>{p.trackInvoicingActionClick(g.Event.invoicingPaymentRowClicked,{transactionId:i}),e.navigate(`${n}/payments/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&t(Gi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Ut);function wa(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeType:S,appliedSearch:f,appliedSort:h,nextCursor:j,transactionListFetchState:k,transactions:x}=E((L=>{const _=Zn(L);return{activeType:_.activeTab,appliedSearch:_.filters.search,appliedSort:_.sort,nextCursor:_.nextCursor,transactionListFetchState:_.fetchState,transactions:_.transactions}}),H),b=k==="Completed",I=`/${n}/invoicing`,D=r.useCallback((L=>{const _=x.find((U=>U.id===L)),R=_?.linkedInvoices?.[0]?.invoiceID??_?.invoiceID;R!=null&&(p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"payments_list",invoiceId:R,toScreen:"invoice"}),e(`${I}/invoices/${encodeURIComponent(R)}`))}),[e,I,x]),C=r.useCallback((L=>{const _=x.find((R=>R.id===L))?.customerID;_!=null&&(p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:_,fromScreen:"payments_list",toScreen:"customer"}),e(`${I}/customers/${encodeURIComponent(_)}`))}),[e,I,x]);return r.useEffect((()=>{const L=setTimeout((()=>d(o)),300);return()=>clearTimeout(L)}),[o]),r.useEffect((()=>{i&&t(ve({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(ve({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingPaymentsListPage,isReady:b}),s.jsx($a,{navigate:e,tenantEmailDomain:n,activeType:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,onSearchChange:a,onTypeChange:L=>{t(Qi(L)),t(ve({cacheOverride:!1,filters:m,sort:u}))},onSortChange:v,onViewTransactionCustomer:C,onViewTransactionInvoice:D})]})}const Fa=t=>{const e=[t.firstName,t.lastName].filter((n=>n!=null&&n.trim()!=="")).join(" ").trim();return(t.company!=null&&t.company.trim()!==""?t.company.trim():"")||e||(t.email!=null&&t.email.trim()!==""?t.email.trim():"")||t.id},gn=(t,e)=>new Intl.NumberFormat("en-US",{currency:e,style:"currency"}).format(t);function mn(){const t=P(),e=A(),{invoice_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:o}=T(),a=n!=null&&n!=="",c=E(de),d=E((C=>zi(C))),l=E(Wi),v=E((C=>_n(C,n??""))),u=v.invoice,m=`/${i}/invoicing`,S=r.useRef(null),f=r.useRef("");r.useEffect((()=>{t(Ji()),S.current=null,f.current=""}),[t,n]),r.useEffect((()=>{o&&t(a&&n!=null?_e({invoiceId:n}):we({filters:{},keepExistingListItems:!1}))}),[o,t,n,a]),r.useEffect((()=>{a&&u!=null&&n!=null&&v.fetchState==="Completed"&&S.current!==n&&(S.current=n,t(Xi({contextInvoiceId:n,localData:eo(u)})))}),[t,u,n,v.fetchState,a]),r.useEffect((()=>{if(a)return;const C=d.localData.customerId;C!==""&&C!==f.current&&(f.current=C,t(Nn({filters:{customerId:C},keepExistingListItems:!1})),d.localData.invoiceToLink!==""&&t(on({localData:{...d.localData,customerId:C,invoiceToLink:""}})))}),[t,d.localData,a]);const h=r.useRef(l.fetchState);r.useEffect((()=>{const C=h.current;if(h.current=l.fetchState,C!=="Completed"&&l.fetchState==="Completed"){if(l.recordedInvoiceId!=null)return void e(`${m}/invoices/${encodeURIComponent(l.recordedInvoiceId)}`);e(`${m}/payments`)}}),[e,l.fetchState,l.recordedInvoiceId,m]);const j=r.useMemo((()=>c.customers.map((C=>({id:C.id,name:Fa(C)})))),[c.customers]),k=E((C=>no(C,d.localData.customerId))),x=r.useMemo((()=>k.map((C=>({amountDue:gn(C.amountDue,"USD"),amountDueValue:C.amountDue,id:C.id,label:C.invoiceNumber})))),[k]),b=r.useMemo((()=>{if(!a||u==null)return;const C=u.currencyCode??"USD",L=u.amountDue?.amount??0;return{amountDue:gn(L,C),amountDueValue:L,currencyCode:C,customerName:u.customerName??u.customerID,invoiceId:u.id,invoiceNumber:u.invoiceNumber??u.id}}),[u,a]),I=a?`${m}/invoices/${encodeURIComponent(n??"")}`:`${m}/payments`,D=!a||v.fetchState==="Completed"&&d.localData.invoiceToLink!=="";return s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingRecordPaymentPage,isReady:D}),s.jsx(Bt,{customers:j,fieldHelp:d.fieldHelp,errorMessage:l.fetchState==="Error"?l.error?.message??"Failed to record payment. Please try again.":void 0,gatewayOptions:d.gatewayOptions,invoiceContext:b,invoiceOptions:x,isSubmitting:l.fetchState==="In-Progress",localData:d.localData,mode:a?"invoice":"customer",paymentMethodOptions:d.paymentMethodOptions,onBack:()=>{e(I)},onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingRecordPaymentCancelled),e(I)},onChange:C=>{t(on({localData:C}))},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingPaymentRecorded,{customerId:d.localData.customerId,invoiceId:a?n:d.localData.invoiceToLink,paymentMethod:d.localData.paymentMethod}),t(to(a?n??void 0:void 0))}})]})}const tt=(t,e,n)=>{const i=`/${t}/invoicing/subscriptions/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},Ta=(t,e)=>{if(t==null)return;const n=new Intl.NumberFormat("en-US",{currency:t.currencyCode??"USD",maximumFractionDigits:0,style:"currency"}).format(t.amount);return e!=null?`${n}/${e}`:n},it=(t,e,n)=>{const i=[t,Ta(e,n)].filter((o=>o!=null&&o!=="")).join(" · ");return i!==""?i:void 0},vn=t=>t.priceCode!=null&&t.priceCode.trim()!=="",Ra=t=>({billingCycles:t.billingCycles,billingPeriod:t.period,billingPeriodUnit:t.periodUnit,label:t.name??t.id,subtitle:it(t.productCode,t.price,t.periodUnit),value:t.priceCode}),Oa=t=>({label:t.name??t.couponCode??t.id,value:t.couponCode??t.id}),_a=O((function(t,e){const{editView:n}=e,i=n.subscription,o=i?.status,a=o!=null&&e.commercialEditAllowedFromStatuses.includes(o);return{cancelReasonCodeOptions:n.cancelReasonCodeOptions,fieldHelp:n.fieldHelp,addons:n.products.filter((c=>c.itemType==="addon")).filter(vn).map((c=>({label:c.name??c.id,subtitle:it(c.productCode,c.price,c.periodUnit),value:c.priceCode}))),canEditCommercial:a,coupons:n.coupons.map(Oa),isLoading:n.subscription==null&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",lifecycleActionOptions:e.lifecycleActionOptions,localData:n.localData,plans:n.plans.filter(vn).map(Ra),shippingAddressLabel:n.shippingAddressLabel,subscription:i}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,o=i!=="",a=(c,d)=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionLifecycleAction,{action:c,subscriptionId:i}),t(Yn({action:c,id:i,body:d}))};return{onBack:()=>e.navigate(`${n}/subscriptions`),onChange:c=>{t(ce({id:i,localData:c}))},onChangeTermEnd:o?c=>{const d=c?.trim()??"";d!==""&&a("change_term_end",{term_ends_at:d})}:void 0,onCustomerClick:c=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:c,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${n}/customers/${encodeURIComponent(c)}`,"_blank","noopener,noreferrer")},onOpenAddress:()=>{const c=tt(e.tenantEmailDomain??"",ye,i),d=J(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onViewInvoices:()=>e.navigate(`${n}/invoices`),onSaveEdit:c=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionEdited,{subscriptionId:i}),t(ce({id:i,localData:c})),t(qn({id:i}))},onCancelSubscription:o?c=>{a("cancel",{cancel_reason_code:c.cancelReasonCode,end_of_term:!1,...c.cancelReason!=null&&c.cancelReason.trim()!==""?{cancel_reason:c.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:o?(c,d)=>{c!=="pause"?a(c):a(c,d!=null&&d.trim()!==""?{resume_date:d.trim()}:void 0)}:void 0}}))(Vt);function Ma(){const t=P(),e=A(),n=W(),{subscription_id:i,tenantEmailDomain:o}=F(),{areTenantIdsInSync:a}=T(),c=E((h=>Me(h,i))),{subscriptionCommercialEditAllowedFromStatuses:d,subscriptionLifecycleActionOptions:l,subscriptionMetadataEditAllowedFromStatuses:v}=c,u=c.pageFetchState.fetchState,m=u==="Completed";Be(a),r.useEffect((()=>{a&&i!=null&&t(an({id:i}))}),[a,i,t]);const[S,f]=r.useState(0);return r.useEffect((()=>{c.fetchState==="Completed"&&(t(Ne()),t(an({cacheOverride:!0,id:i})),f((h=>h+1)))}),[c.fetchState,t,i]),N(u)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingSubscriptionDetailPage,isReady:m}),s.jsx(_a,{commercialEditAllowedFromStatuses:d,editView:c,lifecycleActionOptions:l,location:n,metadataEditAllowedFromStatuses:v,navigate:e,subscriptionId:i??"",tenantEmailDomain:o},S)]})}const Na=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},Ua=(t,e)=>{if(t==null)return;const n=new Intl.NumberFormat("en-US",{currency:t.currencyCode??"USD",maximumFractionDigits:0,style:"currency"}).format(t.amount);return e!=null?`${n}/${e}`:n},be=(t,e,n)=>{const i=[t,Ua(e,n)].filter((o=>o!=null&&o!=="")).join(" · ");return i!==""?i:void 0},Ba=t=>({label:Na(t),value:t.id}),fe=t=>t.priceCode!=null&&t.priceCode.trim()!=="",Va=t=>({billingCycles:t.billingCycles,billingPeriod:t.period,billingPeriodUnit:t.periodUnit,label:t.name??t.id,subtitle:be(t.productCode,t.price,t.periodUnit),trialPeriod:t.trialPeriod,trialPeriodUnit:t.trialPeriodUnit,value:t.priceCode}),Ha=t=>({label:t.name??t.couponCode??t.id,value:t.couponCode??t.id}),Za=O((function(t,e){const n=Me(t,e.subscriptionId);return{fieldHelp:n.fieldHelp,addons:n.products.filter((i=>i.itemType==="addon")).filter(fe).map((i=>({label:i.name??i.id,subtitle:be(i.productCode,i.price,i.periodUnit),value:i.priceCode}))),charges:n.products.filter((i=>i.itemType==="charge")).filter(fe).map((i=>({label:i.name??i.id,subtitle:be(i.productCode,i.price,void 0),value:i.priceCode}))),coupons:n.coupons.map(Ha),customers:n.customers.map(Ba),errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save subscription.":void 0,isSubmitting:n.fetchState==="In-Progress",localData:n.localData,mode:n.mode,plans:n.plans.filter(fe).map(Va),shippingAddressLabel:n.shippingAddressLabel}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,o=i!=null?"edit":"create";return{onCancel:()=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionFormCancelled),t(Ne()),t($e(ye)),i==null?e.navigate(`${n}/subscriptions`):e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)},onChange:a=>{t(ce({id:i,localData:a}))},onOpenAddress:()=>{const a=tt(e.tenantEmailDomain??"",ye,i),c=J(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:c}})},onSubmit:()=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionSaved,{mode:o}),t(qn({id:i}))}}}))(Ht);function qa(){const t=P(),e=A(),n=W(),{subscription_id:i,tenantEmailDomain:o}=F(),[a]=z(),{areTenantIdsInSync:c}=T(),d=a.get("customerId"),{fetchState:l,savedSubscriptionId:v}=E((S=>io(S,i))),u=E((S=>Me(S,i).localData));Be(c),r.useEffect((()=>{c&&(t(we({filters:{},keepExistingListItems:!1})),t(he({filters:{type:"plan"},keepExistingListItems:!1})),t(Rn({filters:{},keepExistingListItems:!1})),i!=null&&t(oo({id:i})))}),[c,i,t]);const m=r.useRef(!1);return r.useEffect((()=>{m.current||i!=null||d==null||d===""||u.customerId!==""||(m.current=!0,t(ce({id:i,localData:{...u,customerId:d}})))}),[d,i,u,t]),r.useEffect((()=>{if(l==="Completed"){const S=v??i,f=S!=null?`/${o}/invoicing/subscriptions/${encodeURIComponent(S)}`:`/${o}/invoicing/subscriptions`;e(f),t(Ne())}}),[l,v,i,t,e,o]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingSubscriptionFormPage}),s.jsx(Za,{location:n,navigate:e,subscriptionId:i,tenantEmailDomain:o})]})}const Ya=O((function(t){const e=Kn(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=(o,a,c)=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionLifecycleAction,{action:a,subscriptionId:o}),t(Yn({action:a,id:o,body:c}))};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onAddSubscription:()=>{p.trackInvoicingActionClick(g.Event.invoicingAddSubscriptionClicked),e.navigate(`${n}/subscriptions/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(g.Event.invoicingImportCsvClicked,{entity:"subscriptions"}),e.navigate(`${n}/data_import`)},onChangeTermEnd:(o,a)=>{const c=a?.trim()??"";c!==""&&i(o,"change_term_end",{term_ends_at:c})},onSubscriptionAction:(o,a,c)=>{a!=="pause"?i(o,a):i(o,a,c!=null&&c.trim()!==""?{resume_date:c.trim()}:void 0)},onCancelSubscription:(o,a)=>{i(o,"cancel",{cancel_reason_code:a.cancelReasonCode,end_of_term:!1,...a.cancelReason!=null&&a.cancelReason.trim()!==""?{cancel_reason:a.cancelReason.trim()}:{}})},onSubscriptionClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingSubscriptionRowClicked,{subscriptionId:o}),e.navigate(`${n}/subscriptions/${encodeURIComponent(o)}`)},onViewSubscriptionInvoices:()=>{e.navigate(`${n}/invoices`)},onLoadMore:()=>{e.nextCursor!=null&&t(co({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Zt);function Ka(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),[o,a]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:j,subscriptionListFetchState:k,runningActionSubscriptionId:x}=E((D=>{const C=Kn(D);return{activeStatus:C.activeTab,appliedSearch:C.filters.search,appliedSort:C.sort,nextCursor:C.nextCursor,subscriptionListFetchState:C.fetchState,runningActionSubscriptionId:C.runningActionId??null}}),H),b=k==="Completed";r.useEffect((()=>{const D=setTimeout((()=>d(o)),300);return()=>clearTimeout(D)}),[o]),r.useEffect((()=>{i&&t(sn({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&t(sn({cacheOverride:!0,filters:m,sort:u}))}),[i,t,m,u,f,h]);const I=r.useRef(x);return r.useEffect((()=>{const D=I.current!=null&&x==null;I.current=x,D&&i&&t(ao())}),[x,i,t]),N(k)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingSubscriptionsListPage,isReady:b}),s.jsx(Ya,{navigate:e,tenantEmailDomain:n,activeStatus:S,searchValue:o,sortState:l,filters:m,sort:u,nextCursor:j,runningActionSubscriptionId:x,onSearchChange:a,onStatusChange:D=>t(so(D)),onSortChange:v})]})}const Qa=O((function(t,e){const{readView:n}=e;return{isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress",transaction:n.transaction,transactionId:e.transactionId}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{transactionId:i}=e;return{onBack:()=>e.navigate(`${n}/payments`),onCustomerClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{customerId:o,fromScreen:"transaction_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(o)}`)},onInvoiceClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(o)}`)},onSubscriptionClick:o=>{p.trackInvoicingActionClick(g.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",subscriptionId:o,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(o)}`)},onCapture:i!==""?()=>{p.trackInvoicingActionClick(g.Event.invoicingTransactionCaptured,{transactionId:i}),t(uo({action:"capture",id:i}))}:void 0}}))(qt);function Ga(){const t=P(),e=A(),{tenantEmailDomain:n,transaction_id:i}=F(),{areTenantIdsInSync:o}=T(),a=E((d=>ro(d,i??""))),c=a.fetchState==="Completed";return r.useEffect((()=>{o&&i!=null&&t(lo({id:i}))}),[o,i,t]),N(a.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingTransactionDetailPage,isReady:c}),s.jsx(Qa,{navigate:e,tenantEmailDomain:n,transactionId:i??"",readView:a})]})}const za={branding:"invoicing_branding_save",dunning:"invoicing_dunning_settings_save",quickbooks:"invoicing_qbo_settings_save"};function X(t){const e=P(),{areTenantIdsInSync:n}=T(),{tenantEmailDomain:i}=F(),{fetchState:o,fieldHelp:a,saveState:c,settings:d,stripeConnectState:l}=E(go),{configError:v,configFetchState:u,dunningScheduleActionOptions:m,qboAccountMappingKindOptions:S,qboCustomerMatchingOptions:f,qboSyncStatusOptions:h}=E(Qn),j=E(Pe);Ue({enabled:t==="quickbooks",fetchSyncHealth:!0,loadAccountingPickers:!0});const k=E(Re),x=t==="dunning"||t==="quickbooks",b=k.companyId??Se.getSignedInUserTenant(i??"")?.companyId,I=E(($=>wn($,b))),D=mo(k.userRole??[]),C=k.tenantId??"",L=Se.getSignedInUser(),_={userId:L?.userId??"",sessionId:L?.zeniSessionId??"",tenantId:C},R=d?.logo_file_id,U=E(($=>R!=null&&R!==""?$.fileState.fileByFileId[R]:void 0)),Ve=E(($=>R!=null&&R!==""?vo($,R):void 0)),He=E(($=>R!=null&&R!==""?po($,R):void 0)),ot=R!=null&&R!==""&&Ve!=null?{[R]:Ve}:{},at=R!=null&&R!==""&&He!=null?{[R]:He}:{};r.useEffect((()=>(e(cn()),()=>{e(cn())})),[e]),r.useEffect((()=>{n&&(o!=="Not-Started"&&o!=="Error"||e(Oe()))}),[n,e,o]),r.useEffect((()=>{n&&x&&u==="Not-Started"&&e(re())}),[n,e,u,x]),r.useEffect((()=>{if(!n)return;const $=L?.userId;$!=null&&$!==""&&C!==""&&Ye.shouldFetchActiveTenant(C)&&(Ye.markActiveTenantFetchStarted(C),e(fo($,C,L?.zeniSessionId)))}),[n,e,L?.userId,L?.zeniSessionId,C]),r.useEffect((()=>{n&&R!=null&&R!==""&&C!==""&&U==null&&e(So(R,C))}),[n,e,U,R,C]);const st=m.length>0||S.length>0,ct=o==="Not-Started"||o==="In-Progress"&&d==null||x&&!st&&(u==="Not-Started"||u==="In-Progress"),rt=o==="Completed"&&(!x||u==="Completed"),Ze=I.externalConnections?.revenue?.find(($=>$.connectionName==="chargebee"))?.connectionId,ue=ae?.invoicingMicroServiceBaseUrl,qe=ue!=null&&ue.length>0?`${ue}/1.0/webhooks/stripe`:"",ge={deleteConnectionError:I.externalConnections?.deleteConnectionError?.message,deleteConnectionState:I.externalConnections?.deleteConnectionState??"Not-Started",integrationsView:I,isAdmin:D,isStripeBusy:l.fetchState==="In-Progress",onConnectStripe:$=>e(ln($)),onDisconnect:($,q)=>{C!==""&&e(xo(C,$,dn(q)))},onDisconnectStripe:()=>e(rn()),onReconnectQBO:()=>{const $=k.tenantEmailDomain??i??"";le.init("/connection/auth",$),le.handleClick()},onRefreshQBO:()=>{I.integrations.refreshQBO.fetchState!=="In-Progress"&&e(Wn())},onSaveChargeBeeCredentials:($,q)=>{Ze!=null&&C!==""&&e(ko(C,Ze,dn("revenue"),yo("chargebee"),{api_key:$,site:q}))},saveChargeBeeError:I.externalConnections?.saveAPIKeyConnectionError?.message,saveChargeBeeState:I.externalConnections?.saveAPIKeyConnectionState??"Not-Started",settings:d,stripeError:l.fetchState==="Error"?l.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:qe};return{authParams:_,deleteFileStatusById:ot,fieldHelp:a,dunningScheduleActionOptions:m,filesEndPoint:ae?.fileMicroServiceBaseUrl??"",integrationsSectionProps:ge,isInvoicingPageReady:rt,isLoading:ct,isSaving:c.fetchState==="In-Progress",isStripeBusy:l.fetchState==="In-Progress",logoFile:U,qboAccountMappingKindOptions:S,qboCustomerMatchingOptions:f,qboSyncStatusOptions:h,qboView:j,saveErrorMessage:c.fetchState==="Error"?c.error?.message??"Failed to save settings.":x&&u==="Error"?v?.message??"Failed to load invoicing configuration.":void 0,settings:d,stripeError:l.fetchState==="Error"?l.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:qe,updateFileStatusById:at,onConnectStripe:$=>e(ln($)),onDeleteFile:$=>e(Eo($)),onDisconnectStripe:()=>e(rn()),onEditFileName:($,q)=>e(Io($,q)),onReconnectQBO:ge.onReconnectQBO,onRefreshQBO:ge.onRefreshQBO,onRetryQboSyncTask:$=>e(zn($)),onSave:$=>{p.trackInvoicingActionClick(g.Event.invoicingSettingsSaved,{tab:t??"hub"}),e(Co({settings:$,snackbarSection:za[t??""]}))},onStartQboBackfill:$=>e(Gn($)),updateFilesEntity:$=>{p.trackInvoicingActionClick(g.Event.invoicingLogoUploaded),e(ho({files:$}))}}}function pn({appContent:t}){const e=A(),n=W(),i=P(),{tenantEmailDomain:o}=F(),a=X("branding"),c=E((v=>bo(v))),d=E((v=>jo(pe,v)?.addressToCreate));r.useEffect((()=>{c.saveState.fetchState==="Completed"&&(i(Do()),i($e(pe)))}),[c.saveState.fetchState,i]);const l=hn(c.saveState.fetchState);return r.useEffect((()=>{l==="In-Progress"&&c.saveState.fetchState==="Completed"&&e("..")}),[l,c.saveState.fetchState,e]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingSettingsPage,isReady:a.isInvoicingPageReady}),s.jsx(Yt,{address:d,fieldHelp:c.fieldHelp,addressLabel:c.addressLabel,appContent:t,authParams:a.authParams,dateFormatOptions:c.dateFormatOptions,deleteFileStatusById:a.deleteFileStatusById,filesEndPoint:a.filesEndPoint,isLoading:a.isLoading,isSaving:a.isSaving,localData:c.localData,saveErrorMessage:a.saveErrorMessage,settings:a.settings,updateFileStatusById:a.updateFileStatusById,onBackClick:()=>e(".."),onChange:v=>{i(Ao({localData:v}))},onDeleteFile:a.onDeleteFile,onEditFileName:a.onEditFileName,onOpenAddress:()=>{const v=`/${o}/invoicing/settings/branding/${pe}/`,u=J(n.state?.pathnameStackToGoBack,n.pathname);e(v,{state:{pathnameStackToGoBack:u}})},onSubmit:()=>i(Po()),updateFilesEntity:a.updateFilesEntity})]})}function Wa(){const t=A(),e=X("dunning");return s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Kt,{dunningScheduleActionOptions:e.dunningScheduleActionOptions,isLoading:e.isLoading,isSaving:e.isSaving,saveErrorMessage:e.saveErrorMessage,settings:e.settings,onBackClick:()=>t(".."),onSave:e.onSave})]})}function Ja(){const t=A(),e=X("integrations");return s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Qt,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>t("../quickbooks"),onOpenPaymentDestination:()=>t("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>t("..")})]})}function Xa(){const t=A(),e=X("payment-destination");return s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Gt,{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 es=O((function(t){const e=Jn(t);return{accountMappingKindOptions:e.accountMappingKindOptions,fieldHelp:e.fieldHelp,accounts:e.accounts,connection:e.connection,customerMatchingOptions:e.customerMatchingOptions,isBackfilling:e.backfillState.fetchState==="In-Progress",isLoading:e.isLoading,isSaving:e.saveState.fetchState==="In-Progress",isSyncEnabledSaved:e.isSyncEnabledSaved,localData:e.localData,nestedAccountHierarchy:e.nestedAccountHierarchy,retryFetchStateByTaskId:e.retryFetchStateByTaskId,saveErrorMessage:e.saveState.fetchState==="Error"?e.saveState.error?.message:void 0,syncHealth:e.syncHealth,syncStatusOptions:e.syncStatusOptions}}),(function(t){return{onChange:e=>{t(wo({localData:e}))},onReset:()=>{t($o())},onRetryTask:e=>{t(zn(e))},onSave:()=>{p.trackInvoicingActionClick(g.Event.invoicingSettingsSaved,{tab:"quickbooks"}),t(Lo())},onStartBackfill:e=>{t(Gn(e))}}}))(zt);function ns(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),i=E(Re),{configFetchState:o,settingsFetchState:a}=E(Jn);return r.useEffect((()=>{a!=="Not-Started"&&a!=="Error"||t(Oe())}),[t,a]),r.useEffect((()=>{o==="Not-Started"&&t(re())}),[o,t]),Ue({fetchSyncHealth:!0,loadAccountingPickers:!0}),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingSettingsPage}),s.jsx(es,{onBackClick:()=>e(".."),onReconnect:()=>{le.init("/connection/auth",i.tenantEmailDomain??n??""),le.handleClick()},onRefresh:()=>t(Wn())})]})}const ts={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function is(){const t=Sn(),e=P(),n=A(),[i,o]=z(),a=X(),{canEnableInvoicing:c,isEnablingInvoicing:d,isInvoicingEnabled:l,isQboConfigured:v,isStripeConnected:u}=E(Qn),m=i.get("tab");return r.useEffect((()=>{if(m==null)return;const S=ts[m];o({},{replace:!0}),S!=null&&n(S,{replace:!0})}),[m,n,o]),s.jsxs(s.Fragment,{children:[s.jsx(w,{event:g.Event.invoicingSettingsPage,isReady:a.isInvoicingPageReady}),s.jsx(Wt,{analytics:p,integrationsSectionProps:{...a.integrationsSectionProps,onConfigureQBO:()=>n("quickbooks"),onOpenPaymentDestination:()=>n("payment-destination")},isEnablingInvoicing:d,isLoading:a.isLoading,meetingUrl:t("invoicing_settings"),settings:a.settings,onBrandingClick:()=>n("branding"),onDunningClick:()=>n("dunning"),canEnableInvoicing:c,isQboConfigured:v,isStripePaymentsReady:u,onEnableInvoicingClick:l?void 0:()=>{e(Fo())}})]})}function fn(){return s.jsxs(te,{children:[s.jsx(y,{index:!0,element:s.jsx(is,{})}),s.jsx(y,{path:"payment-destination",element:s.jsx(Xa,{})}),s.jsx(y,{path:"branding",element:s.jsx(pn,{})}),s.jsx(y,{path:"branding/:addressType",element:s.jsx(pn,{appContent:s.jsx(Y,{isSubPage:!0,hideAddressBackButton:!0})})}),s.jsx(y,{path:"integrations",element:s.jsx(Ja,{})}),s.jsx(y,{path:"dunning",element:s.jsx(Wa,{})}),s.jsx(y,{path:"quickbooks",element:s.jsx(ns,{})}),s.jsx(y,{path:"*",element:s.jsx(B,{to:"..",replace:!0})})]})}function $s(){const t=P(),e=A(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=T(),{enableState:o,fetchState:a,status:c}=E(Un),d=hn(o.fetchState),l=`/${n}/invoicing`,v=r.useRef(!1),u=E((m=>Pe(m).connectionFetchState.fetchState));return r.useEffect((()=>{i&&(a!=="Not-Started"?a!=="Error"||v.current||(v.current=!0,t(re({cacheOverride:!1}))):t(re({cacheOverride:!1})))}),[i,t,a]),r.useEffect((()=>{i&&u==="Not-Started"&&t(kn())}),[i,t,u]),r.useEffect((()=>{d==="In-Progress"&&o.fetchState==="Completed"&&(e(`${l}/catalog`),t(To()))}),[d,o.fetchState,l,t,e]),c==null&&a!=="Error"?s.jsx(Jt,{}):c==="not_started"?s.jsxs(te,{children:[s.jsx(y,{path:"promo",element:s.jsx(un,{})}),s.jsx(y,{path:"*",element:s.jsx(B,{to:`${l}/promo`,replace:!0})})]}):c==="settings"?s.jsxs(te,{children:[s.jsx(y,{path:"promo",element:s.jsx(un,{})}),s.jsx(y,{path:"settings/*",element:s.jsx(fn,{})}),s.jsx(y,{path:"*",element:s.jsx(B,{to:`${l}/settings`,replace:!0})})]}):s.jsxs(te,{children:[s.jsx(y,{path:"/",element:s.jsx(B,{to:"overview",replace:!0})}),s.jsx(y,{path:"overview",element:s.jsx(La,{})}),s.jsx(y,{path:"promo",element:s.jsx(B,{to:`${l}/overview`,replace:!0})}),s.jsx(y,{path:"customers",element:s.jsx(ra,{})}),s.jsx(y,{path:"customers/new",element:s.jsx(sa,{})}),s.jsx(y,{path:"customers/new/:addressType",element:s.jsx(Y,{})}),s.jsx(y,{path:"customers/:customer_id",element:s.jsx(oa,{})}),s.jsx(y,{path:"customers/:customer_id/:addressType",element:s.jsx(Y,{})}),s.jsx(y,{path:"subscriptions",element:s.jsx(Ka,{})}),s.jsx(y,{path:"subscriptions/new",element:s.jsx(qa,{})}),s.jsx(y,{path:"subscriptions/new/:addressType",element:s.jsx(Y,{})}),s.jsx(y,{path:"subscriptions/:subscription_id",element:s.jsx(Ma,{})}),s.jsx(y,{path:"subscriptions/:subscription_id/:addressType",element:s.jsx(Y,{})}),s.jsx(y,{path:"invoices",element:s.jsx(ja,{})}),s.jsx(y,{path:"invoices/create",element:s.jsx(Jo,{})}),s.jsx(y,{path:"invoices/:invoice_id",element:s.jsx(xa,{})}),s.jsx(y,{path:"invoices/:invoice_id/record-payment",element:s.jsx(mn,{})}),s.jsx(y,{path:"invoices/:invoice_id/issue-credit-note",element:s.jsx(Pa,{})}),s.jsx(y,{path:"payments",element:s.jsx(wa,{})}),s.jsx(y,{path:"payments/record",element:s.jsx(mn,{})}),s.jsx(y,{path:"payments/:transaction_id",element:s.jsx(Ga,{})}),s.jsx(y,{path:"credits",element:s.jsx(ta,{})}),s.jsx(y,{path:"credits/:credit_note_id",element:s.jsx(ea,{})}),s.jsx(y,{path:"discounts",element:s.jsx(ha,{})}),s.jsx(y,{path:"discounts/new",element:s.jsx(zo,{})}),s.jsx(y,{path:"discounts/:coupon_id",element:s.jsx(fa,{})}),s.jsx(y,{path:"dunning",element:s.jsx(ka,{})}),s.jsx(y,{path:"dunning/:case_id",element:s.jsx(Ia,{})}),s.jsx(y,{path:"catalog",element:s.jsx(Qo,{})}),s.jsx(y,{path:"catalog/new",element:s.jsx(qo,{})}),s.jsx(y,{path:"catalog/:item_id",element:s.jsx(Bo,{})}),s.jsx(y,{path:"settings/*",element:s.jsx(fn,{})}),s.jsx(y,{path:"audit_log",element:s.jsx(Oo,{})}),s.jsx(y,{path:"data_import",element:s.jsx(ga,{})}),s.jsx(y,{path:"data_import/migrate",element:s.jsx(va,{})}),s.jsx(y,{path:"data_import/:sessionId",element:s.jsx(da,{})}),s.jsx(y,{path:"*",element:s.jsx(M,{})})]})}export{$s as default};
@@ -1,4 +1,4 @@
1
- import{j as a}from"./liveblocks-CM7ZQqxd.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-BaXck2Yj.js";import{To as k,Tp as v,Tq as F,Iw as D,Ii as G,Tr as B,Ts as oe,Tt as ie,Im as se,ge as j,It as le,Iq as re}from"./zeni-epic-state-Bo1fQFWK.js";import{$ as x,K as r,a0 as de,l as I,X as K,a1 as ce,a2 as me,a3 as pe,p as M,I as ue,d as he,a4 as ge,c as xe,E as fe,h as we,a5 as be,a6 as Se,Z as ye,a7 as ke,a8 as ve,a9 as Ie,aa as je}from"./index-BmT_wdak.js";import{n as m}from"./mui-CeNVlxCm.js";import f from"./NotFoundScreen-CbKfgA9a.js";import{a as $}from"./sentry-Dh9UB4O6.js";import"./recharts-BKC_cH7h.js";import"./analytics-WNjEvDwJ.js";import"./plaid-D9ECXCuG.js";import"./dnd-Cyb1SC5Y.js";import"./stripe-cKAAJElX.js";import"./lottie-DYRVCvl4.js";import"./lexical-VH6dL15l.js";import"./pdf-Dhhhum3V.js";import"./utils-X6jrk5Hl.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]="3c6df0c8-d510-4025-aeeb-8aa8b80262c0",e._sentryDebugIdIdentifier="sentry-dbid-3c6df0c8-d510-4025-aeeb-8aa8b80262c0")}catch{}})();const $e=m.div`
1
+ import{j as a}from"./liveblocks-BD1fi6wA.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-Dlma5MIa.js";import{To as k,Tp as v,Tq as F,Iw as D,Ii as G,Tr as B,Ts as oe,Tt as ie,Im as se,ge as j,It as le,Iq as re}from"./zeni-epic-state-2zvjmkUL.js";import{$ as x,K as r,a0 as de,l as I,X as K,a1 as ce,a2 as me,a3 as pe,p as M,I as ue,d as he,a4 as ge,c as xe,E as fe,h as we,a5 as be,a6 as Se,Z as ye,a7 as ke,a8 as ve,a9 as Ie,aa as je}from"./index-Blw4A66-.js";import{n as m}from"./mui-DPmPgDDD.js";import f from"./NotFoundScreen-Wkt8x0Ja.js";import{a as $}from"./sentry-C6D8WJ15.js";import"./recharts-WuCIKI4c.js";import"./analytics-NBT5BH2R.js";import"./plaid-w5kSeMkL.js";import"./dnd-BgBEAfSC.js";import"./stripe-cKAAJElX.js";import"./lottie-Dd5kLrRz.js";import"./lexical-Cc-23sPJ.js";import"./pdf-BCsxh4ki.js";import"./utils-Bv9LDtmr.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]="3c6df0c8-d510-4025-aeeb-8aa8b80262c0",e._sentryDebugIdIdentifier="sentry-dbid-3c6df0c8-d510-4025-aeeb-8aa8b80262c0")}catch{}})();const $e=m.div`
2
2
  display: flex;
3
3
  height: 100%;
4
4
  width: 100%;
@@ -1,4 +1,4 @@
1
- import{j as g}from"./liveblocks-CM7ZQqxd.js";import{a as u}from"./sentry-Dh9UB4O6.js";import{u as U,g as _,h as w,t as V,j as l,N as L}from"./core-BaXck2Yj.js";import{z as r,E as M,G as P,R as A,l as N,S as R,Y as B,Z as G,V as W}from"./index-BmT_wdak.js";import{fB as X,SX as Y,Tk as Z,Tb as $,ge as q,gg as H,Tg as J,gR as K,df as Q,Tl as ee,Tm as te}from"./zeni-epic-state-Bo1fQFWK.js";import{n as ne}from"./mui-CeNVlxCm.js";import{u as se}from"./useDeviceId-CilYhYRW.js";import{f as ae}from"./analyticsHelper-BMvVz4OD.js";import{t as ie}from"./getLocaleForTenant-DEaI00lX.js";import"./recharts-BKC_cH7h.js";import"./analytics-WNjEvDwJ.js";import"./plaid-D9ECXCuG.js";import"./dnd-Cyb1SC5Y.js";import"./stripe-cKAAJElX.js";import"./lottie-DYRVCvl4.js";import"./lexical-VH6dL15l.js";import"./pdf-Dhhhum3V.js";import"./utils-X6jrk5Hl.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]="4bcc7136-387c-40d0-8b32-d6046018eeae",t._sentryDebugIdIdentifier="sentry-dbid-4bcc7136-387c-40d0-8b32-d6046018eeae")}catch{}})();const C=(t,a)=>t!=null&&t.length>0&&a==="magic_links";function Ce(){const t=U(),a=_(),f=w(),[k]=V(),n=k.get("token"),p=k.get("stytch_token_type"),m=r.getMagicLinkCodeVerifier(),i=se(),{otpChallenge:d,twoFAPhoneNumber:x,magicLinkEmail:c,verifyDeviceFetchState:z,resendVerifyDeviceOTPFetchState:D}=l((e=>e.tenantState)),S=l((e=>e.tenantState.fetchState)),y=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=>X(e))),b=l((e=>Y(e))),E=r.getSignedInUser(),v=M().mode;u.useEffect((()=>{s?.zeniSessionId==null&&n!=null&&C(n,p)&&i!=null&&m!=null&&(r.saveMagicLinkTriggered(n),t(Z(n,i,m)))}),[n,p,t,i,m,s?.zeniSessionId]),u.useEffect((()=>{I!=="In-Progress"||S!=="Completed"&&y!=="Completed"||s?.zeniSessionId==null||o==null||(n!=null&&r.saveLastUsedMagicLinkToken(n),r.saveSignedInUserWithSession(s,s.zeniSessionId),r.saveSignedInUserTenants($(b.tenantsInOrder),s.zeniSessionId),q(s.userId,s.zeniSessionId,o.tenantId),t(H(o.tenantId)),r.saveActiveTenantDomainForUser(o.tenantEmailDomain),t(J("Completed")),P.updateAppLocaleID(ie(o)),ae(s,o,v,void 0,b.tenantsInOrder),K().then((()=>{const e=W();e!=null&&A(e)})),setTimeout((()=>{N.trackLogin(R.Event.loginSuccess,"email",Q(o.productSettings))}),2e3))}),[I,S,y,s,o,b,v,a.state,t]);const j=u.useCallback((()=>{f("/signin/auth")}),[f]),F=u.useCallback((()=>{i!=null&&d!=null&&c!=null&&t(ee(i,c,d))}),[i,d,t,c]),O=u.useCallback((e=>{i!=null&&n!=null&&c!=null&&d!=null&&t(te(e,i,c,d))}),[i,n,t,c,d]);if(h==="Completed"&&d!=null)return g.jsx(B,{phoneNumber:x,verifyOtpFetchState:z.fetchState,resendVerifyDeviceOTPFetchState:D,onResendOtp:F,onVerifyOtp:O,onCancelVerifyDevice:j});if(I==="In-Progress"&&S==="Completed"&&s?.zeniSessionId!=null&&o!=null||E!=null){const e=a.state?.origin??"/";return g.jsx(L,{to:e,state:{...a.state,origin:""}})}if(!C(n,p)||m==null||h==="Error"){const e=a.state?.origin??"/",T=n!=null&&r.getLastUsedMagicLinkToken()===n;return g.jsx(L,{to:e,state:{...a.state,origin:"",magicLinkAlreadyUsed:T,magicLinkExpired:!T&&(r.isMagicLinkTriggered(n??"")||h==="Error"&&s?.zeniSessionId==null)}})}return g.jsx(oe,{"data-testid":"smooth-loader",children:g.jsx(G,{size:"ExtraLarge",start:!0})})}const oe=ne.div`
1
+ import{j as g}from"./liveblocks-BD1fi6wA.js";import{a as u}from"./sentry-C6D8WJ15.js";import{u as U,g as _,h as w,t as V,j as l,N as L}from"./core-Dlma5MIa.js";import{z as r,E as M,G as P,R as A,l as N,S as R,Y as B,Z as G,V as W}from"./index-Blw4A66-.js";import{fB as X,SX as Y,Tk as Z,Tb as $,ge as q,gg as H,Tg as J,gR as K,df as Q,Tl as ee,Tm as te}from"./zeni-epic-state-2zvjmkUL.js";import{n as ne}from"./mui-DPmPgDDD.js";import{u as se}from"./useDeviceId-p2IpPhWq.js";import{f as ae}from"./analyticsHelper-Bw6Cjeqd.js";import{t as ie}from"./getLocaleForTenant-B0nO-Z7L.js";import"./recharts-WuCIKI4c.js";import"./analytics-NBT5BH2R.js";import"./plaid-w5kSeMkL.js";import"./dnd-BgBEAfSC.js";import"./stripe-cKAAJElX.js";import"./lottie-Dd5kLrRz.js";import"./lexical-Cc-23sPJ.js";import"./pdf-BCsxh4ki.js";import"./utils-Bv9LDtmr.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]="4bcc7136-387c-40d0-8b32-d6046018eeae",t._sentryDebugIdIdentifier="sentry-dbid-4bcc7136-387c-40d0-8b32-d6046018eeae")}catch{}})();const C=(t,a)=>t!=null&&t.length>0&&a==="magic_links";function Ce(){const t=U(),a=_(),f=w(),[k]=V(),n=k.get("token"),p=k.get("stytch_token_type"),m=r.getMagicLinkCodeVerifier(),i=se(),{otpChallenge:d,twoFAPhoneNumber:x,magicLinkEmail:c,verifyDeviceFetchState:z,resendVerifyDeviceOTPFetchState:D}=l((e=>e.tenantState)),S=l((e=>e.tenantState.fetchState)),y=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=>X(e))),b=l((e=>Y(e))),E=r.getSignedInUser(),v=M().mode;u.useEffect((()=>{s?.zeniSessionId==null&&n!=null&&C(n,p)&&i!=null&&m!=null&&(r.saveMagicLinkTriggered(n),t(Z(n,i,m)))}),[n,p,t,i,m,s?.zeniSessionId]),u.useEffect((()=>{I!=="In-Progress"||S!=="Completed"&&y!=="Completed"||s?.zeniSessionId==null||o==null||(n!=null&&r.saveLastUsedMagicLinkToken(n),r.saveSignedInUserWithSession(s,s.zeniSessionId),r.saveSignedInUserTenants($(b.tenantsInOrder),s.zeniSessionId),q(s.userId,s.zeniSessionId,o.tenantId),t(H(o.tenantId)),r.saveActiveTenantDomainForUser(o.tenantEmailDomain),t(J("Completed")),P.updateAppLocaleID(ie(o)),ae(s,o,v,void 0,b.tenantsInOrder),K().then((()=>{const e=W();e!=null&&A(e)})),setTimeout((()=>{N.trackLogin(R.Event.loginSuccess,"email",Q(o.productSettings))}),2e3))}),[I,S,y,s,o,b,v,a.state,t]);const j=u.useCallback((()=>{f("/signin/auth")}),[f]),F=u.useCallback((()=>{i!=null&&d!=null&&c!=null&&t(ee(i,c,d))}),[i,d,t,c]),O=u.useCallback((e=>{i!=null&&n!=null&&c!=null&&d!=null&&t(te(e,i,c,d))}),[i,n,t,c,d]);if(h==="Completed"&&d!=null)return g.jsx(B,{phoneNumber:x,verifyOtpFetchState:z.fetchState,resendVerifyDeviceOTPFetchState:D,onResendOtp:F,onVerifyOtp:O,onCancelVerifyDevice:j});if(I==="In-Progress"&&S==="Completed"&&s?.zeniSessionId!=null&&o!=null||E!=null){const e=a.state?.origin??"/";return g.jsx(L,{to:e,state:{...a.state,origin:""}})}if(!C(n,p)||m==null||h==="Error"){const e=a.state?.origin??"/",T=n!=null&&r.getLastUsedMagicLinkToken()===n;return g.jsx(L,{to:e,state:{...a.state,origin:"",magicLinkAlreadyUsed:T,magicLinkExpired:!T&&(r.isMagicLinkTriggered(n??"")||h==="Error"&&s?.zeniSessionId==null)}})}return g.jsx(oe,{"data-testid":"smooth-loader",children:g.jsx(G,{size:"ExtraLarge",start:!0})})}const oe=ne.div`
2
2
  position: fixed;
3
3
  top: 0;
4
4
  left: 0;
@@ -1 +1 @@
1
- import{j as _}from"./liveblocks-CM7ZQqxd.js";import{a as m}from"./sentry-Dh9UB4O6.js";import{u as te,j as t,i as $e,g as Ge,h as Me,q as F}from"./core-BaXck2Yj.js";import{fB as ne,SY as xe,SZ as se,g5 as Ne,fA as Pe,T3 as Re,S_ as Ve,S$ as je,pF as Le,gi as Oe,T2 as b,T5 as Ue,T6 as Q,gj as Ze,T7 as ze,Db as He,g_ as Ye,cS as qe,T8 as We,g4 as Je,gk as Ke}from"./zeni-epic-state-Bo1fQFWK.js";import{w as Qe,i as Xe,c as ea,I as aa,e as ta,h as na,u as sa,d as c,j as oa,g as ia,z as ra,f as da,n as ca,o as la,v as ua,q as ma,r as X,L as fa,F as ha,H as ba,p as g,l as ee,A as pa,M as ae,C as Sa,D as ga}from"./index-BmT_wdak.js";import{D as ka}from"./mui-CeNVlxCm.js";import{u as Ea}from"./InboxNotificationsProvider-DLtCSJ1e.js";import{u as Ta}from"./useTaskManagerAccess-LntCDDBS.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]="77a549ed-c279-4946-a263-4920a073d926",l._sentryDebugIdIdentifier="sentry-dbid-77a549ed-c279-4946-a263-4920a073d926")}catch{}})();const Ca=Qe((({isAppContentDrawerOpen:l,handleDrawerToggle:i})=>{const{tenantEmailDomain:s}=$e(),a=Ge(),k=ea(),n=Me(),B=Ne(),r=te(),{useFeatureGate:d}=aa(),p=ta(),{isTaskManagerAccessEnabled:E}=Ta(p),o=t((e=>ne(e))),oe=o.masterTOSInfo?.isMasterTOSAccepted??!1,$=t((e=>Pe(e))),{status:ie}=t(Re),G=$.uiState.currentChatSessionId,T=na(),{setLoading:re}=sa(),[w,M]=m.useState(void 0),A=F("/:tenantEmailDomain/dashboard")!==null,x=F("/:tenantEmailDomain/reports")!==null,f=F("/:tenantEmailDomain/onboarding/*")!==null,de=!!o.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:ce}=d(c.isChargeCardFeatureEnabled),{isFeatureEnabled:N}=d(c.isDebitCardFeatureEnabled),le=oa(o,ce,N),{isFeatureEnabled:ue}=d(c.isSettingsFeatureEnabled),P=t((e=>Ve(e))),{isFeatureEnabled:C}=d(c.isReferralFeatureEnabled),v=t((e=>je(e)));m.useEffect((()=>{T&&C&&!f&&v.fetchState==="Not-Started"&&r(Le(!0))}),[T,C,v.fetchState,f]);const D=t((e=>e.tenantState)),me=t((e=>D.fetchState==="Completed"?Oe(e):[])),S=t((e=>e.expenseAutomationViewState.selectedPeriodByTenantId)),{isFeatureEnabled:fe}=d(c.isApAgingFeatureEnabled),{isFeatureEnabled:he}=d(c.isArAgingFeatureEnabled),R=ia(),{isFeatureEnabled:be}=d(c.isDashboardSidebarHalloweenAnimationEnabled),{isFeatureEnabled:pe}=d(c.isDashboardSidebarThanksGivingAnimationEnabled),{isFeatureEnabled:Se}=d(c.isDashboardSidebarChristmasAnimationEnabled),{isFeatureEnabled:ge}=d(c.isDashboardSidebarNewYearAnimationEnabled),ke=o.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",Ee=t((e=>b(e).totalUnreadCount)),Te=t((e=>b(e).reducedFetchCountState)),V=t((e=>b(e).notificationDetailsByTab.tasks.uiState.unreadCount)),j=t((e=>b(e).notificationDetailsByTab.comments.uiState.unreadCount)),L=t((e=>b(e).notificationDetailsByTab.tasks.fetchCountState)),I=t((e=>b(e).notificationDetailsByTab.comments.fetchCountState)),{inboxNotifications:O,isLoading:U,isFetchingMore:Z,hasFetchedAll:z,fetchMore:Ce}=Ea();m.useEffect((()=>{const e=setTimeout((()=>Ce?.()),0);return()=>clearTimeout(e)})),m.useEffect((()=>{if(U===!1&&Z===!1&&z===!0)if(o?.companyId!=null&&O!=null){const e=`dashboard_${o.companyId}`;M(O.filter((u=>u.roomId===e&&u.readAt==null)).length)}else M(0)}),[U,Z,z]),m.useEffect((()=>{T&&E&&!f&&L.fetchState==="Not-Started"&&B.tenantId!=null&&r(Ue("task_manager","dashboard"))}),[T,E,f,L.fetchState,B.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:Te,count:Ee},H=s!=null?ra.getSignedInUserTenant(s):null,Y=t((e=>H?.tenantId!=null?Ze(e,H.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"),C===!1&&h.push("rewards_card"),R===!1&&h.push("expense_automation_card");const q=t((e=>ze(e,h).fetchState)),W=t((e=>He(e).fetchState)),ye=A&&(q==="Completed"||q==="Error")||x&&(W==="Completed"||W==="Error")||!A&&!x?void 0:"disabled",we=m.useMemo((()=>Ye(o.userRole)),[o.userRole]),Ae=qe(we),ve=o?.rewardsLastViewedTime==null,De=p?.userEmail!=null&&P.fetchState==="Completed"&&We(P.notificationSettings,p.userEmail,N,o,E),J=da(),Fe=J&&ca(a);return _.jsx(ka,{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:_.jsx(la,{signedInUser:p,currentTenantId:D.currentTenantId??"",tenants:D.fetchState==="Completed"?me:Y!=null?[Y]:[],currentTenant:o,isTenantDropdownDisabled:ye,isSettings:X(a),isInvoicing:ma(a)&&ie==="completed",isSettingsFeatureEnabled:ue,isVendorsTabVisible:Ae,isZeniAccountEnabled:de,isChargeCardEnabled:le,isTreasuryEnabled:ke,isNotificationsTabVisible:De,notificationCountDetails:Ie,isExpenseAutomationEnabledForUser:R,selectedMenu:ua(a),rewardsConfiguration:{isRewardsTabVisible:C,isRewardsAnimated:ve,rewardsPlan:v.rewardsPlan},isAiCfoAccessEnabled:J,onNotificationIconClick:()=>{i(!1);let e=V===0&&j>0?"notifications/comments":"notifications/tasks";X(a)&&(e=V===0&&j>0?"../../notifications/comments":"../../notifications/tasks");const u=g(a.state?.pathnameStackToGoBack,a.pathname);n(e,{state:{pathnameStackToGoBack:u}})},handleCockpitClick:()=>{window.open("/cockpit")},handleLogOutClick:()=>{i(!1);const e=g(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:g(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=g(a.state?.pathnameStackToGoBack,a.pathname);return void n(`/${s}/ai-cfo/explore`,{state:{pathnameStackToGoBack:y,referrer:"Sidebar"}})}const u=g(a.state?.pathnameStackToGoBack,a.pathname),K=e.type,_e=ae(K)&&K!=="command_center";if(ae(e.type)&&S[o.tenantId]!=null&&ee.trackMonthEndCloseClicked(S[o.tenantId].month,S[o.tenantId].year,"Sidebar"),_e&&S[o.tenantId]!=null){const y=S[o.tenantId];return void n(`/${s}/month_end_close_checks/review/${e.type}/${y.month}-${y.year}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})}const Be=Sa(e.type);ga(e.type)?(G!=null&&r(Ke()),n(`/${s}/ai-cfo/${e.type}`,{state:{pathnameStackToGoBack:u.slice(0,-1),referrer:"Sidebar"}})):n(`/${s}/${Be}`,{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:()=>{k.toggle()},isAiCfo:Fe,aiCfoView:$,isOnDashboard:A,updateCurrentChatSessionId:e=>{r(Je({sessionId:e,agentId:"controller"})),n(`/${s}/ai-cfo/${e}`,{state:{...a.state}})},halloweenAnimationEnabled:be,isTaskManagerAccessEnabled:E,thanksGivingAnimationEnabled:pe,christmasAnimationEnabled:Se,newYearAnimationEnabled:ge})})})),Ba=l=>{const i=te(),s=t((k=>ne(k))),a={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(k,n)=>{Xe(n)&&xe(n.mode)==="dashboard"&&i(se({unreadCount:n.data.unread},"tasks"))}};return _.jsx(Ca,{...l,...a})};export{Ba as M};
1
+ import{j as _}from"./liveblocks-BD1fi6wA.js";import{a as m}from"./sentry-C6D8WJ15.js";import{u as te,j as t,i as $e,g as Ge,h as Me,q as F}from"./core-Dlma5MIa.js";import{fB as ne,SY as xe,SZ as se,g5 as Ne,fA as Pe,T3 as Re,S_ as Ve,S$ as je,pF as Le,gi as Oe,T2 as b,T5 as Ue,T6 as Q,gj as Ze,T7 as ze,Db as He,g_ as Ye,cS as qe,T8 as We,g4 as Je,gk as Ke}from"./zeni-epic-state-2zvjmkUL.js";import{w as Qe,i as Xe,c as ea,I as aa,e as ta,h as na,u as sa,d as c,j as oa,g as ia,z as ra,f as da,n as ca,o as la,v as ua,q as ma,r as X,L as fa,F as ha,H as ba,p as g,l as ee,A as pa,M as ae,C as Sa,D as ga}from"./index-Blw4A66-.js";import{D as ka}from"./mui-DPmPgDDD.js";import{u as Ea}from"./InboxNotificationsProvider-7eYmgI1F.js";import{u as Ta}from"./useTaskManagerAccess-BKVtGCGL.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]="77a549ed-c279-4946-a263-4920a073d926",l._sentryDebugIdIdentifier="sentry-dbid-77a549ed-c279-4946-a263-4920a073d926")}catch{}})();const Ca=Qe((({isAppContentDrawerOpen:l,handleDrawerToggle:i})=>{const{tenantEmailDomain:s}=$e(),a=Ge(),k=ea(),n=Me(),B=Ne(),r=te(),{useFeatureGate:d}=aa(),p=ta(),{isTaskManagerAccessEnabled:E}=Ta(p),o=t((e=>ne(e))),oe=o.masterTOSInfo?.isMasterTOSAccepted??!1,$=t((e=>Pe(e))),{status:ie}=t(Re),G=$.uiState.currentChatSessionId,T=na(),{setLoading:re}=sa(),[w,M]=m.useState(void 0),A=F("/:tenantEmailDomain/dashboard")!==null,x=F("/:tenantEmailDomain/reports")!==null,f=F("/:tenantEmailDomain/onboarding/*")!==null,de=!!o.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:ce}=d(c.isChargeCardFeatureEnabled),{isFeatureEnabled:N}=d(c.isDebitCardFeatureEnabled),le=oa(o,ce,N),{isFeatureEnabled:ue}=d(c.isSettingsFeatureEnabled),P=t((e=>Ve(e))),{isFeatureEnabled:C}=d(c.isReferralFeatureEnabled),v=t((e=>je(e)));m.useEffect((()=>{T&&C&&!f&&v.fetchState==="Not-Started"&&r(Le(!0))}),[T,C,v.fetchState,f]);const D=t((e=>e.tenantState)),me=t((e=>D.fetchState==="Completed"?Oe(e):[])),S=t((e=>e.expenseAutomationViewState.selectedPeriodByTenantId)),{isFeatureEnabled:fe}=d(c.isApAgingFeatureEnabled),{isFeatureEnabled:he}=d(c.isArAgingFeatureEnabled),R=ia(),{isFeatureEnabled:be}=d(c.isDashboardSidebarHalloweenAnimationEnabled),{isFeatureEnabled:pe}=d(c.isDashboardSidebarThanksGivingAnimationEnabled),{isFeatureEnabled:Se}=d(c.isDashboardSidebarChristmasAnimationEnabled),{isFeatureEnabled:ge}=d(c.isDashboardSidebarNewYearAnimationEnabled),ke=o.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",Ee=t((e=>b(e).totalUnreadCount)),Te=t((e=>b(e).reducedFetchCountState)),V=t((e=>b(e).notificationDetailsByTab.tasks.uiState.unreadCount)),j=t((e=>b(e).notificationDetailsByTab.comments.uiState.unreadCount)),L=t((e=>b(e).notificationDetailsByTab.tasks.fetchCountState)),I=t((e=>b(e).notificationDetailsByTab.comments.fetchCountState)),{inboxNotifications:O,isLoading:U,isFetchingMore:Z,hasFetchedAll:z,fetchMore:Ce}=Ea();m.useEffect((()=>{const e=setTimeout((()=>Ce?.()),0);return()=>clearTimeout(e)})),m.useEffect((()=>{if(U===!1&&Z===!1&&z===!0)if(o?.companyId!=null&&O!=null){const e=`dashboard_${o.companyId}`;M(O.filter((u=>u.roomId===e&&u.readAt==null)).length)}else M(0)}),[U,Z,z]),m.useEffect((()=>{T&&E&&!f&&L.fetchState==="Not-Started"&&B.tenantId!=null&&r(Ue("task_manager","dashboard"))}),[T,E,f,L.fetchState,B.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:Te,count:Ee},H=s!=null?ra.getSignedInUserTenant(s):null,Y=t((e=>H?.tenantId!=null?Ze(e,H.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"),C===!1&&h.push("rewards_card"),R===!1&&h.push("expense_automation_card");const q=t((e=>ze(e,h).fetchState)),W=t((e=>He(e).fetchState)),ye=A&&(q==="Completed"||q==="Error")||x&&(W==="Completed"||W==="Error")||!A&&!x?void 0:"disabled",we=m.useMemo((()=>Ye(o.userRole)),[o.userRole]),Ae=qe(we),ve=o?.rewardsLastViewedTime==null,De=p?.userEmail!=null&&P.fetchState==="Completed"&&We(P.notificationSettings,p.userEmail,N,o,E),J=da(),Fe=J&&ca(a);return _.jsx(ka,{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:_.jsx(la,{signedInUser:p,currentTenantId:D.currentTenantId??"",tenants:D.fetchState==="Completed"?me:Y!=null?[Y]:[],currentTenant:o,isTenantDropdownDisabled:ye,isSettings:X(a),isInvoicing:ma(a)&&ie==="completed",isSettingsFeatureEnabled:ue,isVendorsTabVisible:Ae,isZeniAccountEnabled:de,isChargeCardEnabled:le,isTreasuryEnabled:ke,isNotificationsTabVisible:De,notificationCountDetails:Ie,isExpenseAutomationEnabledForUser:R,selectedMenu:ua(a),rewardsConfiguration:{isRewardsTabVisible:C,isRewardsAnimated:ve,rewardsPlan:v.rewardsPlan},isAiCfoAccessEnabled:J,onNotificationIconClick:()=>{i(!1);let e=V===0&&j>0?"notifications/comments":"notifications/tasks";X(a)&&(e=V===0&&j>0?"../../notifications/comments":"../../notifications/tasks");const u=g(a.state?.pathnameStackToGoBack,a.pathname);n(e,{state:{pathnameStackToGoBack:u}})},handleCockpitClick:()=>{window.open("/cockpit")},handleLogOutClick:()=>{i(!1);const e=g(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:g(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=g(a.state?.pathnameStackToGoBack,a.pathname);return void n(`/${s}/ai-cfo/explore`,{state:{pathnameStackToGoBack:y,referrer:"Sidebar"}})}const u=g(a.state?.pathnameStackToGoBack,a.pathname),K=e.type,_e=ae(K)&&K!=="command_center";if(ae(e.type)&&S[o.tenantId]!=null&&ee.trackMonthEndCloseClicked(S[o.tenantId].month,S[o.tenantId].year,"Sidebar"),_e&&S[o.tenantId]!=null){const y=S[o.tenantId];return void n(`/${s}/month_end_close_checks/review/${e.type}/${y.month}-${y.year}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})}const Be=Sa(e.type);ga(e.type)?(G!=null&&r(Ke()),n(`/${s}/ai-cfo/${e.type}`,{state:{pathnameStackToGoBack:u.slice(0,-1),referrer:"Sidebar"}})):n(`/${s}/${Be}`,{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:()=>{k.toggle()},isAiCfo:Fe,aiCfoView:$,isOnDashboard:A,updateCurrentChatSessionId:e=>{r(Je({sessionId:e,agentId:"controller"})),n(`/${s}/ai-cfo/${e}`,{state:{...a.state}})},halloweenAnimationEnabled:be,isTaskManagerAccessEnabled:E,thanksGivingAnimationEnabled:pe,christmasAnimationEnabled:Se,newYearAnimationEnabled:ge})})})),Ba=l=>{const i=te(),s=t((k=>ne(k))),a={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(k,n)=>{Xe(n)&&xe(n.mode)==="dashboard"&&i(se({unreadCount:n.data.unread},"tasks"))}};return _.jsx(Ca,{...l,...a})};export{Ba as M};
@@ -0,0 +1 @@
1
+ import{j as e}from"./liveblocks-BD1fi6wA.js";import{h as r,l as i}from"./core-Dlma5MIa.js";import{ak as n}from"./index-Blw4A66-.js";import"./mui-DPmPgDDD.js";import"./sentry-C6D8WJ15.js";import"./zeni-epic-state-2zvjmkUL.js";import"./recharts-WuCIKI4c.js";import"./analytics-NBT5BH2R.js";import"./plaid-w5kSeMkL.js";import"./dnd-BgBEAfSC.js";import"./stripe-cKAAJElX.js";import"./lottie-Dd5kLrRz.js";import"./lexical-Cc-23sPJ.js";import"./pdf-BCsxh4ki.js";import"./utils-Bv9LDtmr.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};
@@ -1 +1 @@
1
- import{m as mt,a as lt,n as ft,j as N}from"./liveblocks-CM7ZQqxd.js";import ut from"./NotFoundScreen-CbKfgA9a.js";import{a as k}from"./sentry-Dh9UB4O6.js";import{h as ht,g as pt,i as kt,u as gt,j as S,l as St,n as bt,o as Z}from"./core-BaXck2Yj.js";import{cz as It,S_ as O,fB as X,g_ as Tt,T2 as b,$V as H,T6 as m,SZ as E,zt as j,F9 as Ct,$W as yt,SY as Et,T8 as At,zy as _t,$X as M,br as F,gd as x,zC as J,$Y as Nt,cL as Bt,cE as wt}from"./zeni-epic-state-Bo1fQFWK.js";import{ao as xt,e as vt,I as Rt,d as Dt,aq as Pt,dI as Gt,p as B,dJ as Ut,w as $t,dK as Mt,i as Ft,a2 as jt}from"./index-BmT_wdak.js";import"./mui-CeNVlxCm.js";import{u as Vt}from"./useAskAiCfoHostNavButtonProps-fsQB3AjS.js";import{u as zt}from"./useTaskManagerAccess-LntCDDBS.js";import"./recharts-BKC_cH7h.js";import"./analytics-WNjEvDwJ.js";import"./plaid-D9ECXCuG.js";import"./dnd-Cyb1SC5Y.js";import"./stripe-cKAAJElX.js";import"./lottie-DYRVCvl4.js";import"./lexical-VH6dL15l.js";import"./pdf-Dhhhum3V.js";import"./utils-X6jrk5Hl.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},l=new t.Error().stack;l&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[l]="b43d38ef-41d5-41a5-96e5-d8b7092fe39e",t._sentryDebugIdIdentifier="sentry-dbid-b43d38ef-41d5-41a5-96e5-d8b7092fe39e")}catch{}})();const Lt=(t,l)=>new Promise(((n,h)=>{const g=t.map((c=>new Promise((o=>{l(c),o()}))));Promise.all(g).then((()=>{setTimeout((()=>{n()}),2e3)})).catch((c=>{h(c)}))})),Wt=St((function(t,l){const n=O(t),{signedInUser:h,isDebitCardFeatureEnabled:g,isTaskManagerAccessEnabled:c}=l,o=b(t),f=X(t),{currentTab:I}=o;return{notificationView:o,isNotificationSettingsVisible:h.userEmail!=null&&At(n.notificationSettings,h.userEmail,g,f,c),isDisabled:o.notificationDetailsByTab[I].fetchState==="In-Progress"?"disabled":void 0}}),(function(t,l){const{location:n,tenantEmailDomain:h,loggedInUserRoleMap:g,externalNotificationsUnreadCount:c,allUnreadCommentsNotificationIds:o,navigate:f,markInboxNotificationAsRead:I,fetchMoreCommentsNotifications:R}=l;return{onNotificationClick:(a,s,d,r)=>{if(r==="task_deleted"){const i=`/${h}/tasks`,T=B(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}else{const i=`/${h}/tasks/${s}`,T=B(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}d==="unread"&&t(J("task_manager","read",[a],!1))},onCommentNotificationClick:(a,s,d)=>{const r=s.toString().split(`/${h}/`);if(r[1]!=null){d==="unread"&&(I(a),t(M([a],F())));let i=`/${h}/${r[1]}`;const T=B(n.state?.pathnameStackToGoBack,n.pathname);r[1].startsWith("reimbursement")&&!Bt(g)&&(i="not-found"),r[1].startsWith("bill")&&!wt(g)&&(i="not-found"),f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}},onUpdateNotificationViewUIState:(a,s)=>{t(E(a,s))},onUpdateNotificationTabState:(a,s)=>{t(m(a,s))},onUpdateNotificationViewCurrentTabAndSubTab:(a,s)=>{t(H(a,s));const d=`../${a}`,r=B(n.state?.pathnameStackToGoBack,n.pathname);f(d,{state:{pathnameStackToGoBack:r}})},onUpdateNotificationViewSubTab:a=>{t(Nt(a))},onFetchMoreNotifications:(a,s)=>{if(a==="tasks"){const d=[];s==="all"?d.push("read","unread"):s!=="mentions"&&d.push(s),t(j("task_manager","dashboard",d))}else R?.()},onUpdateNotificationStatus:(a,s,d,r)=>{a==="tasks"?t(J("task_manager",d,r)):(t(m({markAsReadState:{fetchState:"In-Progress",error:void 0}},"comments")),Promise.all(r.map((i=>{d==="read"&&(I(i),t(M([i],F())))}))).then((()=>{t(m({markAsReadState:{fetchState:"Completed",error:void 0},selectedNotificationIds:[]},"comments")),t(E({unreadCount:c-r.length>0?c-r.length:0},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"success",type:"success",showStatusIcon:!0}))}),(i=>{t(m({markAsReadState:{fetchState:"Error",error:i}},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",showStatusIcon:!0}))})).catch((i=>{t(m({markAsReadState:{fetchState:"Error",error:i}},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",showStatusIcon:!0}))})))},onMarkAllNotificationsAsRead:a=>{a==="tasks"?t(_t("task_manager","read")):(t(m({markAsAllReadState:{fetchState:"In-Progress",error:void 0}},"comments")),Lt(o,I).then((()=>{t(M(o,F())),t(m({markAsAllReadState:{fetchState:"Completed",error:void 0}},"comments")),t(E({unreadCount:0},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"success",type:"success",showStatusIcon:!0}))})).catch((s=>{t(m({markAsAllReadState:{fetchState:"Error",error:s}},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",showStatusIcon:!0}))})))},onBackClick:()=>{const a=jt(n.state?.pathnameStackToGoBack),s=a.poppedPathname??"../../dashboard";f(s,{state:{pathnameStackToGoBack:a.newStack}})},onSettingsClick:()=>{const a=B(n.state?.pathnameStackToGoBack,n.pathname);f("../../settings/notifications",{state:{pathnameStackToGoBack:a}})}}}))($t(Mt)),Yt=()=>{const t=ht(),l=pt(),{tenantEmailDomain:n,selectedTab:h}=kt(),{areTenantIdsInSync:g}=xt(),c=It(h??""),o=gt(),f=vt(),[I,R]=k.useState(!1),a=S((e=>O(e))),s=S((e=>X(e))),{useFeatureGate:d}=Rt(),{isFeatureEnabled:r}=d(Dt.isDebitCardFeatureEnabled),{isAiCfoAccessEnabled:i,onAskAiCfoClick:T}=Vt({mobileExploreReferrer:"Notifications"});Pt({isDataReady:!0});const Q=Tt(s.userRole);if(s==null||n==null||s.companyId==null)throw Error("Can't access notifications page without current tenant...");if(f==null)throw Error("Can't access notifications page without signed in...");const V=S((e=>b(e).notificationDetailsByTab.tasks.fetchState)),z=S((e=>b(e).currentTab)),D=S((e=>b(e).currentSubTab)),tt=S((e=>b(e).notificationDetailsByTab.comments.fetchCountState)),P=S((e=>b(e).notificationDetailsByTab.comments.fetchState)),et=S((e=>b(e).notificationDetailsByTab.comments.uiState.unreadCount)),at=S((e=>b(e).allExternalNotifications)).filter((e=>e.inboxNotification.readAt==null)).map((e=>e.inboxNotification.id)),st=Gt().allUsers,{inboxNotifications:w,isLoading:A,hasFetchedAll:C,isFetchingMore:G,fetchMore:ot}=mt(),{threads:L,isLoading:W,fetchMore:Y,isFetchingMore:q,hasFetchedAll:K}=lt({query:{metadata:{companyId:s.companyId,application:"dashboard"}}});k.useEffect((()=>{if(z!==c&&c!=null&&o(H(c)),c==null){const e=`../${z}`,p=B(l.state?.pathnameStackToGoBack,l.pathname);t(e,{state:{pathnameStackToGoBack:p}})}}),[c]),k.useEffect((()=>{tt.fetchState==="Not-Started"&&o(m({fetchCountState:{fetchState:"In-Progress",error:void 0}},"comments"))}),[]),k.useEffect((()=>{if(A===!1&&C===!0&&s?.companyId!=null&&w!=null){const e=`dashboard_${s.companyId}`,p=w.filter((y=>y.roomId===e&&y.readAt==null)).length;o(m({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),o(E({unreadCount:p},"comments"))}}),[A,C]),k.useEffect((()=>{V!=="In-Progress"&&g&&o(j("task_manager","dashboard",["read","unread"]))}),[g]),k.useEffect((()=>{const e=setTimeout((()=>ot?.()),0);return()=>clearTimeout(e)}));const U=A||G===!0||C!==!0||A||G===!0||C!==!0;k.useEffect((()=>{U&&P!=="In-Progress"?o(m({fetchState:"In-Progress",error:void 0},"comments")):U||P!=="In-Progress"||o(m({fetchState:"Completed",error:void 0},"comments"))}),[U,P]),k.useEffect((()=>{o(E({hasMore:C!==!0},"comments"))}),[C]),k.useEffect((()=>{a.fetchState!=="In-Progress"&&a.fetchState!=="Completed"&&I===!1&&(R(!0),o(Ct()))}),[a.fetchState]),k.useEffect((()=>{if(A===!1&&W===!1&&w!=null&&L!=null){const e=`dashboard_${s.companyId}`,p=w.filter((u=>u.roomId===e)).filter((u=>Ut(u.kind))),y=p.filter((u=>u.readAt==null)),_=p.map((u=>u.id)),ct=p.map((u=>{const $=L.find((dt=>{return dt.id===((v=u).kind==="thread"?v.threadId:"subjectId"in v?v.subjectId:void 0);var v}));return $!=null?{inboxNotification:{...u,threadId:$.id},thread:$}:(q||K===!0||Y==null||Y(),null)})).filter((u=>u!=null));o(m({allNotificationsIds:_},"comments")),o(E({totalCount:_.length,unreadCount:y.length},"comments")),o(yt(ct))}}),[A,G,q,C,K,W,w?.length]);const nt={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(e,p)=>{if(Ft(p)){const y=Et(p.mode);if(y==="dashboard"&&o(E({unreadCount:p.data.unread},"tasks")),V!=="In-Progress"){const _=[];D==="all"?_.push("read","unread"):D!=="mentions"&&_.push(D),o(j("task_manager",y,_,!0))}}}},it=ft(),{isTaskManagerAccessEnabled:rt}=zt(f);return N.jsx(Wt,{tenantEmailDomain:n,loggedInUserRoleMap:Q,signedInUser:f,externalNotificationsUnreadCount:et,location:l,navigate:t,isDebitCardFeatureEnabled:r,isTaskManagerAccessEnabled:rt,users:st,markInboxNotificationAsRead:it,allUnreadCommentsNotificationIds:at,isAiCfoAccessEnabled:i,onAskAiCfoClick:T,...nt})};function me(){return N.jsxs(bt,{children:[N.jsx(Z,{path:"/:selectedTab",element:N.jsx(Yt,{})}),N.jsx(Z,{path:"*",element:N.jsx(ut,{})})]})}export{me as default};
1
+ import{m as mt,a as lt,n as ft,j as N}from"./liveblocks-BD1fi6wA.js";import ut from"./NotFoundScreen-Wkt8x0Ja.js";import{a as k}from"./sentry-C6D8WJ15.js";import{h as ht,g as pt,i as kt,u as gt,j as S,l as St,n as bt,o as Z}from"./core-Dlma5MIa.js";import{cz as It,S_ as O,fB as X,g_ as Tt,T2 as b,$V as H,T6 as m,SZ as E,zt as j,F9 as Ct,$W as yt,SY as Et,T8 as At,zy as _t,$X as M,br as F,gd as x,zC as J,$Y as Nt,cL as Bt,cE as wt}from"./zeni-epic-state-2zvjmkUL.js";import{ao as xt,e as vt,I as Rt,d as Dt,aq as Pt,dI as Gt,p as B,dJ as Ut,w as $t,dK as Mt,i as Ft,a2 as jt}from"./index-Blw4A66-.js";import"./mui-DPmPgDDD.js";import{u as Vt}from"./useAskAiCfoHostNavButtonProps-5qRN6gKs.js";import{u as zt}from"./useTaskManagerAccess-BKVtGCGL.js";import"./recharts-WuCIKI4c.js";import"./analytics-NBT5BH2R.js";import"./plaid-w5kSeMkL.js";import"./dnd-BgBEAfSC.js";import"./stripe-cKAAJElX.js";import"./lottie-Dd5kLrRz.js";import"./lexical-Cc-23sPJ.js";import"./pdf-BCsxh4ki.js";import"./utils-Bv9LDtmr.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},l=new t.Error().stack;l&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[l]="b43d38ef-41d5-41a5-96e5-d8b7092fe39e",t._sentryDebugIdIdentifier="sentry-dbid-b43d38ef-41d5-41a5-96e5-d8b7092fe39e")}catch{}})();const Lt=(t,l)=>new Promise(((n,h)=>{const g=t.map((c=>new Promise((o=>{l(c),o()}))));Promise.all(g).then((()=>{setTimeout((()=>{n()}),2e3)})).catch((c=>{h(c)}))})),Wt=St((function(t,l){const n=O(t),{signedInUser:h,isDebitCardFeatureEnabled:g,isTaskManagerAccessEnabled:c}=l,o=b(t),f=X(t),{currentTab:I}=o;return{notificationView:o,isNotificationSettingsVisible:h.userEmail!=null&&At(n.notificationSettings,h.userEmail,g,f,c),isDisabled:o.notificationDetailsByTab[I].fetchState==="In-Progress"?"disabled":void 0}}),(function(t,l){const{location:n,tenantEmailDomain:h,loggedInUserRoleMap:g,externalNotificationsUnreadCount:c,allUnreadCommentsNotificationIds:o,navigate:f,markInboxNotificationAsRead:I,fetchMoreCommentsNotifications:R}=l;return{onNotificationClick:(a,s,d,r)=>{if(r==="task_deleted"){const i=`/${h}/tasks`,T=B(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}else{const i=`/${h}/tasks/${s}`,T=B(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}d==="unread"&&t(J("task_manager","read",[a],!1))},onCommentNotificationClick:(a,s,d)=>{const r=s.toString().split(`/${h}/`);if(r[1]!=null){d==="unread"&&(I(a),t(M([a],F())));let i=`/${h}/${r[1]}`;const T=B(n.state?.pathnameStackToGoBack,n.pathname);r[1].startsWith("reimbursement")&&!Bt(g)&&(i="not-found"),r[1].startsWith("bill")&&!wt(g)&&(i="not-found"),f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}},onUpdateNotificationViewUIState:(a,s)=>{t(E(a,s))},onUpdateNotificationTabState:(a,s)=>{t(m(a,s))},onUpdateNotificationViewCurrentTabAndSubTab:(a,s)=>{t(H(a,s));const d=`../${a}`,r=B(n.state?.pathnameStackToGoBack,n.pathname);f(d,{state:{pathnameStackToGoBack:r}})},onUpdateNotificationViewSubTab:a=>{t(Nt(a))},onFetchMoreNotifications:(a,s)=>{if(a==="tasks"){const d=[];s==="all"?d.push("read","unread"):s!=="mentions"&&d.push(s),t(j("task_manager","dashboard",d))}else R?.()},onUpdateNotificationStatus:(a,s,d,r)=>{a==="tasks"?t(J("task_manager",d,r)):(t(m({markAsReadState:{fetchState:"In-Progress",error:void 0}},"comments")),Promise.all(r.map((i=>{d==="read"&&(I(i),t(M([i],F())))}))).then((()=>{t(m({markAsReadState:{fetchState:"Completed",error:void 0},selectedNotificationIds:[]},"comments")),t(E({unreadCount:c-r.length>0?c-r.length:0},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"success",type:"success",showStatusIcon:!0}))}),(i=>{t(m({markAsReadState:{fetchState:"Error",error:i}},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",showStatusIcon:!0}))})).catch((i=>{t(m({markAsReadState:{fetchState:"Error",error:i}},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",showStatusIcon:!0}))})))},onMarkAllNotificationsAsRead:a=>{a==="tasks"?t(_t("task_manager","read")):(t(m({markAsAllReadState:{fetchState:"In-Progress",error:void 0}},"comments")),Lt(o,I).then((()=>{t(M(o,F())),t(m({markAsAllReadState:{fetchState:"Completed",error:void 0}},"comments")),t(E({unreadCount:0},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"success",type:"success",showStatusIcon:!0}))})).catch((s=>{t(m({markAsAllReadState:{fetchState:"Error",error:s}},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",showStatusIcon:!0}))})))},onBackClick:()=>{const a=jt(n.state?.pathnameStackToGoBack),s=a.poppedPathname??"../../dashboard";f(s,{state:{pathnameStackToGoBack:a.newStack}})},onSettingsClick:()=>{const a=B(n.state?.pathnameStackToGoBack,n.pathname);f("../../settings/notifications",{state:{pathnameStackToGoBack:a}})}}}))($t(Mt)),Yt=()=>{const t=ht(),l=pt(),{tenantEmailDomain:n,selectedTab:h}=kt(),{areTenantIdsInSync:g}=xt(),c=It(h??""),o=gt(),f=vt(),[I,R]=k.useState(!1),a=S((e=>O(e))),s=S((e=>X(e))),{useFeatureGate:d}=Rt(),{isFeatureEnabled:r}=d(Dt.isDebitCardFeatureEnabled),{isAiCfoAccessEnabled:i,onAskAiCfoClick:T}=Vt({mobileExploreReferrer:"Notifications"});Pt({isDataReady:!0});const Q=Tt(s.userRole);if(s==null||n==null||s.companyId==null)throw Error("Can't access notifications page without current tenant...");if(f==null)throw Error("Can't access notifications page without signed in...");const V=S((e=>b(e).notificationDetailsByTab.tasks.fetchState)),z=S((e=>b(e).currentTab)),D=S((e=>b(e).currentSubTab)),tt=S((e=>b(e).notificationDetailsByTab.comments.fetchCountState)),P=S((e=>b(e).notificationDetailsByTab.comments.fetchState)),et=S((e=>b(e).notificationDetailsByTab.comments.uiState.unreadCount)),at=S((e=>b(e).allExternalNotifications)).filter((e=>e.inboxNotification.readAt==null)).map((e=>e.inboxNotification.id)),st=Gt().allUsers,{inboxNotifications:w,isLoading:A,hasFetchedAll:C,isFetchingMore:G,fetchMore:ot}=mt(),{threads:L,isLoading:W,fetchMore:Y,isFetchingMore:q,hasFetchedAll:K}=lt({query:{metadata:{companyId:s.companyId,application:"dashboard"}}});k.useEffect((()=>{if(z!==c&&c!=null&&o(H(c)),c==null){const e=`../${z}`,p=B(l.state?.pathnameStackToGoBack,l.pathname);t(e,{state:{pathnameStackToGoBack:p}})}}),[c]),k.useEffect((()=>{tt.fetchState==="Not-Started"&&o(m({fetchCountState:{fetchState:"In-Progress",error:void 0}},"comments"))}),[]),k.useEffect((()=>{if(A===!1&&C===!0&&s?.companyId!=null&&w!=null){const e=`dashboard_${s.companyId}`,p=w.filter((y=>y.roomId===e&&y.readAt==null)).length;o(m({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),o(E({unreadCount:p},"comments"))}}),[A,C]),k.useEffect((()=>{V!=="In-Progress"&&g&&o(j("task_manager","dashboard",["read","unread"]))}),[g]),k.useEffect((()=>{const e=setTimeout((()=>ot?.()),0);return()=>clearTimeout(e)}));const U=A||G===!0||C!==!0||A||G===!0||C!==!0;k.useEffect((()=>{U&&P!=="In-Progress"?o(m({fetchState:"In-Progress",error:void 0},"comments")):U||P!=="In-Progress"||o(m({fetchState:"Completed",error:void 0},"comments"))}),[U,P]),k.useEffect((()=>{o(E({hasMore:C!==!0},"comments"))}),[C]),k.useEffect((()=>{a.fetchState!=="In-Progress"&&a.fetchState!=="Completed"&&I===!1&&(R(!0),o(Ct()))}),[a.fetchState]),k.useEffect((()=>{if(A===!1&&W===!1&&w!=null&&L!=null){const e=`dashboard_${s.companyId}`,p=w.filter((u=>u.roomId===e)).filter((u=>Ut(u.kind))),y=p.filter((u=>u.readAt==null)),_=p.map((u=>u.id)),ct=p.map((u=>{const $=L.find((dt=>{return dt.id===((v=u).kind==="thread"?v.threadId:"subjectId"in v?v.subjectId:void 0);var v}));return $!=null?{inboxNotification:{...u,threadId:$.id},thread:$}:(q||K===!0||Y==null||Y(),null)})).filter((u=>u!=null));o(m({allNotificationsIds:_},"comments")),o(E({totalCount:_.length,unreadCount:y.length},"comments")),o(yt(ct))}}),[A,G,q,C,K,W,w?.length]);const nt={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(e,p)=>{if(Ft(p)){const y=Et(p.mode);if(y==="dashboard"&&o(E({unreadCount:p.data.unread},"tasks")),V!=="In-Progress"){const _=[];D==="all"?_.push("read","unread"):D!=="mentions"&&_.push(D),o(j("task_manager",y,_,!0))}}}},it=ft(),{isTaskManagerAccessEnabled:rt}=zt(f);return N.jsx(Wt,{tenantEmailDomain:n,loggedInUserRoleMap:Q,signedInUser:f,externalNotificationsUnreadCount:et,location:l,navigate:t,isDebitCardFeatureEnabled:r,isTaskManagerAccessEnabled:rt,users:st,markInboxNotificationAsRead:it,allUnreadCommentsNotificationIds:at,isAiCfoAccessEnabled:i,onAskAiCfoClick:T,...nt})};function me(){return N.jsxs(bt,{children:[N.jsx(Z,{path:"/:selectedTab",element:N.jsx(Yt,{})}),N.jsx(Z,{path:"*",element:N.jsx(ut,{})})]})}export{me as default};
@@ -1 +1 @@
1
- import{j as m}from"./liveblocks-CM7ZQqxd.js";import{a as r}from"./sentry-Dh9UB4O6.js";import{u as A,g as C,j as o,N as j}from"./core-BaXck2Yj.js";import{Ty as z,fB as P,gi as x,Tz as D,TA as M,TB as R,TC as B,pw as k,Sh as L}from"./zeni-epic-state-Bo1fQFWK.js";import{z as h,af as I}from"./index-BmT_wdak.js";import"./mui-CeNVlxCm.js";import"./recharts-BKC_cH7h.js";import"./analytics-WNjEvDwJ.js";import"./plaid-D9ECXCuG.js";import"./dnd-Cyb1SC5Y.js";import"./stripe-cKAAJElX.js";import"./lottie-DYRVCvl4.js";import"./lexical-VH6dL15l.js";import"./pdf-Dhhhum3V.js";import"./utils-X6jrk5Hl.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new n.Error().stack;a&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[a]="cc779f62-37dc-4c1a-acfa-672e1c6f32db",n._sentryDebugIdIdentifier="sentry-dbid-cc779f62-37dc-4c1a-acfa-672e1c6f32db")}catch{}})();function ee(){const n=A(),a=C(),{params:t,error:i}=r.useMemo((()=>z(a.search)),[a.search]),w=r.useMemo((()=>new URLSearchParams(a.search).get("client_name")??t?.clientId??"Unknown Application"),[a.search,t]),f=h.isSignedIn(),s=h.getSignedInUser(),p=o((e=>P(e))),l=o((e=>x(e))),c=o((e=>e.tenantState.fetchState)),y=o(D),S=o(M),d=o(R),[v,b]=r.useState(null),[T,E]=r.useState(null);r.useEffect((()=>{document.querySelector("#app-shell-loader")?.remove()}),[]),r.useEffect((()=>()=>{n(B())}),[n,a.search]),r.useEffect((()=>{i!=null&&console.warn("[OAuthConsent] invalid params:",i)}),[i]);const g=r.useRef(!1);r.useEffect((()=>{f&&s!=null&&!g.current&&(c!=="Not-Started"&&c!=="Error"||(g.current=!0,n(k(s.userId,s.zeniSessionId??void 0))))}),[f,s,c,n]),r.useEffect((()=>{d!=null&&d!==""&&(window.location.href=d)}),[d]);const _=r.useMemo((()=>{if(p?.tenantId!=null)return p.tenantId;const e=h.getActiveTenantForUser()?.tenantId;return e!=null&&l.some((U=>U.tenantId===e))?e:l.length===1?l[0].tenantId:null}),[p?.tenantId,l]),u=v??_;return i!=null?m.jsx(I,{variant:"invalid_params",paramsError:i}):f?m.jsx(I,{variant:"signed_in",clientName:w,userEmail:s?.userEmail,isInitializing:c!=="Completed",tenants:l,selectedTenantId:u,onSelectTenant:b,approveError:T??S,isApproving:y==="In-Progress",showAllowButton:u!=null,onApprove:()=>{t!=null&&s!=null&&u!=null&&n(L(s.userId,s.zeniSessionId??void 0,u,t.clientId,t.redirectUri,t.codeChallenge,t.codeChallengeMethod,t.state,t.responseType))},onDeny:()=>{if(t!=null)try{const e=new URL(t.redirectUri);e.searchParams.set("error","access_denied"),e.searchParams.set("error_description","The user denied the request"),e.searchParams.set("state",t.state),window.location.href=e.toString()}catch{E("Unable to deny: redirect_uri is not a valid URL. Close this window or contact support.")}}}):m.jsx(j,{to:"/signin/auth",state:{origin:a.pathname+a.search},replace:!0})}export{ee as default};
1
+ import{j as m}from"./liveblocks-BD1fi6wA.js";import{a as r}from"./sentry-C6D8WJ15.js";import{u as A,g as C,j as o,N as j}from"./core-Dlma5MIa.js";import{Ty as z,fB as P,gi as x,Tz as D,TA as M,TB as R,TC as B,pw as k,Sh as L}from"./zeni-epic-state-2zvjmkUL.js";import{z as h,af as I}from"./index-Blw4A66-.js";import"./mui-DPmPgDDD.js";import"./recharts-WuCIKI4c.js";import"./analytics-NBT5BH2R.js";import"./plaid-w5kSeMkL.js";import"./dnd-BgBEAfSC.js";import"./stripe-cKAAJElX.js";import"./lottie-Dd5kLrRz.js";import"./lexical-Cc-23sPJ.js";import"./pdf-BCsxh4ki.js";import"./utils-Bv9LDtmr.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},a=new n.Error().stack;a&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[a]="cc779f62-37dc-4c1a-acfa-672e1c6f32db",n._sentryDebugIdIdentifier="sentry-dbid-cc779f62-37dc-4c1a-acfa-672e1c6f32db")}catch{}})();function ee(){const n=A(),a=C(),{params:t,error:i}=r.useMemo((()=>z(a.search)),[a.search]),w=r.useMemo((()=>new URLSearchParams(a.search).get("client_name")??t?.clientId??"Unknown Application"),[a.search,t]),f=h.isSignedIn(),s=h.getSignedInUser(),p=o((e=>P(e))),l=o((e=>x(e))),c=o((e=>e.tenantState.fetchState)),y=o(D),S=o(M),d=o(R),[v,b]=r.useState(null),[T,E]=r.useState(null);r.useEffect((()=>{document.querySelector("#app-shell-loader")?.remove()}),[]),r.useEffect((()=>()=>{n(B())}),[n,a.search]),r.useEffect((()=>{i!=null&&console.warn("[OAuthConsent] invalid params:",i)}),[i]);const g=r.useRef(!1);r.useEffect((()=>{f&&s!=null&&!g.current&&(c!=="Not-Started"&&c!=="Error"||(g.current=!0,n(k(s.userId,s.zeniSessionId??void 0))))}),[f,s,c,n]),r.useEffect((()=>{d!=null&&d!==""&&(window.location.href=d)}),[d]);const _=r.useMemo((()=>{if(p?.tenantId!=null)return p.tenantId;const e=h.getActiveTenantForUser()?.tenantId;return e!=null&&l.some((U=>U.tenantId===e))?e:l.length===1?l[0].tenantId:null}),[p?.tenantId,l]),u=v??_;return i!=null?m.jsx(I,{variant:"invalid_params",paramsError:i}):f?m.jsx(I,{variant:"signed_in",clientName:w,userEmail:s?.userEmail,isInitializing:c!=="Completed",tenants:l,selectedTenantId:u,onSelectTenant:b,approveError:T??S,isApproving:y==="In-Progress",showAllowButton:u!=null,onApprove:()=>{t!=null&&s!=null&&u!=null&&n(L(s.userId,s.zeniSessionId??void 0,u,t.clientId,t.redirectUri,t.codeChallenge,t.codeChallengeMethod,t.state,t.responseType))},onDeny:()=>{if(t!=null)try{const e=new URL(t.redirectUri);e.searchParams.set("error","access_denied"),e.searchParams.set("error_description","The user denied the request"),e.searchParams.set("state",t.state),window.location.href=e.toString()}catch{E("Unable to deny: redirect_uri is not a valid URL. Close this window or contact support.")}}}):m.jsx(j,{to:"/signin/auth",state:{origin:a.pathname+a.search},replace:!0})}export{ee as default};
@@ -1 +1 @@
1
- import{j as n}from"./liveblocks-CM7ZQqxd.js";import{h as J,u as K,g as Q,i as X,j as d,l as Z,n as ee,o as C}from"./core-BaXck2Yj.js";import{fB as M,ze as O,ub as ae,Up as q,u6 as T,bq as te,b_ as se,u7 as oe,Uq as re,U7 as S,e8 as ne,D0 as ce,Ur as ie,Do as le,dV as de,dU as me}from"./zeni-epic-state-Bo1fQFWK.js";import{ag as fe,z as pe,ao as ue,aq as he,U as ge,I as w,d as B,a6 as Fe,l as _,aB as be,p as Ie}from"./index-BmT_wdak.js";import"./mui-CeNVlxCm.js";import Ce from"./NotFoundScreen-CbKfgA9a.js";import{F as Se}from"./FeaturePreviewScreen-C4egsTmn.js";import{a as g}from"./sentry-Dh9UB4O6.js";import{u as Te}from"./useAskAiCfoHostNavButtonProps-fsQB3AjS.js";import{u as ye}from"./useInitialThreadRequest-DOTaljn2.js";import{t as De}from"./routePaths-jc2bzNg2.js";import{M as Ae}from"./MobileAppDrawer-AMYN8Gjf.js";import"./recharts-BKC_cH7h.js";import"./analytics-WNjEvDwJ.js";import"./plaid-D9ECXCuG.js";import"./dnd-Cyb1SC5Y.js";import"./stripe-cKAAJElX.js";import"./lottie-DYRVCvl4.js";import"./lexical-VH6dL15l.js";import"./pdf-Dhhhum3V.js";import"./utils-X6jrk5Hl.js";import"./InboxNotificationsProvider-DLtCSJ1e.js";import"./useTaskManagerAccess-LntCDDBS.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new s.Error().stack;e&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[e]="b437cc5c-a50e-41c9-9f8e-9b00d39dfbf6",s._sentryDebugIdIdentifier="sentry-dbid-b437cc5c-a50e-41c9-9f8e-9b00d39dfbf6")}catch{}})();const y=(s,e,a,o)=>{if(s!=e){const r=o??"";s!=null&&s.length>0?a(`../${e}${r}`,{replace:!0}):a(`${e}${r}`,{replace:!0})}},xe=Z((function(s){const e=re(s),a={},o=e.pandLReportWithForecast.uiState.nodeCollapseState;return Object.keys(o).forEach((r=>{a[r]=o[r]===!1})),{selectedTimeframe:e.selectedTimeframe,isForecastVsActualOn:e.isForecastVsActualOn,compareMode:e.compareMode,forecastList:e.forecastList,selectedForecast:e.selectedForecast,pandLreport:e.pandLReportWithForecast,scrollPosition:e.pandLReportWithForecast.uiState.scrollPosition,nodeOpenStatus:a,type:"name+balances_forecast",analytics:_}}),(function(s,e){return{onForecastSelectionChanged:(a,o)=>{s(q(a,o)),e.isPandLReportFetched(a)||s(T(a)),y(e.forecastIdFromUrlPath,a,e.navigate)},onTimeframeChanged:a=>{s(le(a))},onForecastVsActualsCompareToggle:a=>{s(ie(a)),s(S({forecastId:e.forecastIdFromUrlPath,scrollPosition:{scrollLeft:0,scrollTop:0}}))},onCompareModeChanged:a=>{s(ce(e.firstMonthOfFY,a,0,[]))},onAccountBalanceClick:e.hasTransactionAccess!==!0?void 0:(a,o)=>{let r,c;const p=a.accountName===""?a.accountDescription:a.accountName;if(o.balanceTimeFrame==="month"||o.balanceTimeFrame==="quarter"?(r=o.balanceTimeFrame,c=ne(o)):o.balanceTimeFrame==="year"?(r="quarter",c={startDate:o.endDate.startOf("quarter"),endDate:o.endDate}):console.error(`timeframe ${o.balanceTimeFrame} is not supported`),c!=null&&r!=null){const u=De(e.tenantEmailDomain,a.accountId,a.accountType,p,r,c),m=Ie(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(u,{state:{pathnameStackToGoBack:m,referrer:"Forecast"}})}},onNodeCollapseToggled:(a,o)=>{s(S({forecastId:e.forecastIdFromUrlPath,nodeCollapseState:{nodeId:a,isCollapsed:o===!1}}))},onTableScroll:a=>{s(S({forecastId:e.forecastIdFromUrlPath,scrollPosition:a}))},onBackClick:()=>{e.navigate("../../")}}}))(be);function v(){const s=fe(),e=J(),a=K(),o=Q(),{forecastId:r,tenantEmailDomain:c}=X(),[p,u]=g.useState(!1),[m,D]=g.useState(!1),F=pe.getSignedInUser(),A=d((t=>M(t))),$=A.company?.companyInfo.firstMonthOfFY??1,i=d((t=>O(t.forecastState,t.forecastListState))),l=d((t=>t.forecastListState.fetchState==="Completed")),x=d((t=>t.profitAndLossState)),U=d((t=>t.reportUIOptionsState.selectedForecast)),j=t=>x.pandLByForecastID[t]!=null&&oe(t,x).reducedAllFetchState.fetchState==="Completed",{areTenantIdsInSync:b}=ue();he({isDataReady:l});const{isAiCfoAccessEnabled:N,onAskAiCfoClick:G}=Te({mobileExploreReferrer:"Forecast"});g.useEffect((()=>{if(!p&&b)u(!0),l||a(ae());else if(l&&!m){D(!0);const t=((f,P,R)=>P!=null?f.forecasts.findIndex((I=>I.id===P)):R!=null?f.forecasts.findIndex((I=>I.id===R)):f.forecasts.length>0?0:-1)(i,r,U?.id);t===-1&&r!=null?e("page-not-found",{replace:!0}):t!==-1&&t!=U?.index?(a(q(i.forecasts[t].id,t)),y(r,i.forecasts[t].id,e,o.search)):r==null&&t!==-1&&y(void 0,i.forecasts[t].id,e,o.search),t!==-1&&!j(i.forecasts[t].id)&&b&&a(T(i.forecasts[t].id))}}),[p,u,a,l,i,m,D,O,T,b]);const k=ge(),V=k?.loggedInUserRole!=null&&te(k.loggedInUserRole),{useFeatureGate:W}=w(),{isFeatureEnabled:E}=W(B.isReportsCommentingEnabled),Y=ye(E?A?.companyId:void 0,{clearParams:l&&m}),[z,H]=g.useState(!1),h=new URL(s("forecast_pandl"));h.searchParams.set("firstname",F?.firstName??""),h.searchParams.set("lastname",F?.lastName??""),h.searchParams.set("email",F?.userEmail??"");const L=t=>{H(t)};return n.jsxs(n.Fragment,{children:[l?n.jsx(Fe,{analytics:_,onLoad:t=>(f=>f.trackForecast())(t)}):null,n.jsx(Ae,{isAppContentDrawerOpen:z,handleDrawerToggle:L}),n.jsx(xe,{firstMonthOfFY:$,tenantEmailDomain:c,forecastIdFromUrlPath:r,navigate:e,location:o,isPandLReportFetched:j,meetingUrl:se(h.toString()),hasTransactionAccess:V,isAiCfoAccessEnabled:N,onAskAiCfoClick:G,isReportsCommentingEnabled:E,initialOpenThreadRequest:Y,onClickMenuIcon:()=>{L(!0)}})]})}function Ke(){const s=d((c=>M(c))),{useFeatureGate:e}=w(),{isFeatureEnabled:a}=e(B.isDebitCardFeatureEnabled),o=de(a,s),r=me(s);return o===!0||r===!0?n.jsx(Se,{}):n.jsxs(ee,{children:[n.jsx(C,{path:"/",element:n.jsx(v,{})}),n.jsx(C,{path:"/:forecastId",element:n.jsx(v,{})}),n.jsx(C,{path:"/:forecastId/*",element:n.jsx(Ce,{})})]})}export{Ke as default};
1
+ import{j as n}from"./liveblocks-BD1fi6wA.js";import{h as J,u as K,g as Q,i as X,j as d,l as Z,n as ee,o as C}from"./core-Dlma5MIa.js";import{fB as M,ze as O,ub as ae,Up as q,u6 as T,bq as te,b_ as se,u7 as oe,Uq as re,U7 as S,e8 as ne,D0 as ce,Ur as ie,Do as le,dV as de,dU as me}from"./zeni-epic-state-2zvjmkUL.js";import{ag as fe,z as pe,ao as ue,aq as he,U as ge,I as w,d as B,a6 as Fe,l as _,aB as be,p as Ie}from"./index-Blw4A66-.js";import"./mui-DPmPgDDD.js";import Ce from"./NotFoundScreen-Wkt8x0Ja.js";import{F as Se}from"./FeaturePreviewScreen-CjFoHQHk.js";import{a as g}from"./sentry-C6D8WJ15.js";import{u as Te}from"./useAskAiCfoHostNavButtonProps-5qRN6gKs.js";import{u as ye}from"./useInitialThreadRequest-Ddm4sao-.js";import{t as De}from"./routePaths-1GgW-roh.js";import{M as Ae}from"./MobileAppDrawer-BMvh-RAa.js";import"./recharts-WuCIKI4c.js";import"./analytics-NBT5BH2R.js";import"./plaid-w5kSeMkL.js";import"./dnd-BgBEAfSC.js";import"./stripe-cKAAJElX.js";import"./lottie-Dd5kLrRz.js";import"./lexical-Cc-23sPJ.js";import"./pdf-BCsxh4ki.js";import"./utils-Bv9LDtmr.js";import"./InboxNotificationsProvider-7eYmgI1F.js";import"./useTaskManagerAccess-BKVtGCGL.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new s.Error().stack;e&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[e]="b437cc5c-a50e-41c9-9f8e-9b00d39dfbf6",s._sentryDebugIdIdentifier="sentry-dbid-b437cc5c-a50e-41c9-9f8e-9b00d39dfbf6")}catch{}})();const y=(s,e,a,o)=>{if(s!=e){const r=o??"";s!=null&&s.length>0?a(`../${e}${r}`,{replace:!0}):a(`${e}${r}`,{replace:!0})}},xe=Z((function(s){const e=re(s),a={},o=e.pandLReportWithForecast.uiState.nodeCollapseState;return Object.keys(o).forEach((r=>{a[r]=o[r]===!1})),{selectedTimeframe:e.selectedTimeframe,isForecastVsActualOn:e.isForecastVsActualOn,compareMode:e.compareMode,forecastList:e.forecastList,selectedForecast:e.selectedForecast,pandLreport:e.pandLReportWithForecast,scrollPosition:e.pandLReportWithForecast.uiState.scrollPosition,nodeOpenStatus:a,type:"name+balances_forecast",analytics:_}}),(function(s,e){return{onForecastSelectionChanged:(a,o)=>{s(q(a,o)),e.isPandLReportFetched(a)||s(T(a)),y(e.forecastIdFromUrlPath,a,e.navigate)},onTimeframeChanged:a=>{s(le(a))},onForecastVsActualsCompareToggle:a=>{s(ie(a)),s(S({forecastId:e.forecastIdFromUrlPath,scrollPosition:{scrollLeft:0,scrollTop:0}}))},onCompareModeChanged:a=>{s(ce(e.firstMonthOfFY,a,0,[]))},onAccountBalanceClick:e.hasTransactionAccess!==!0?void 0:(a,o)=>{let r,c;const p=a.accountName===""?a.accountDescription:a.accountName;if(o.balanceTimeFrame==="month"||o.balanceTimeFrame==="quarter"?(r=o.balanceTimeFrame,c=ne(o)):o.balanceTimeFrame==="year"?(r="quarter",c={startDate:o.endDate.startOf("quarter"),endDate:o.endDate}):console.error(`timeframe ${o.balanceTimeFrame} is not supported`),c!=null&&r!=null){const u=De(e.tenantEmailDomain,a.accountId,a.accountType,p,r,c),m=Ie(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(u,{state:{pathnameStackToGoBack:m,referrer:"Forecast"}})}},onNodeCollapseToggled:(a,o)=>{s(S({forecastId:e.forecastIdFromUrlPath,nodeCollapseState:{nodeId:a,isCollapsed:o===!1}}))},onTableScroll:a=>{s(S({forecastId:e.forecastIdFromUrlPath,scrollPosition:a}))},onBackClick:()=>{e.navigate("../../")}}}))(be);function v(){const s=fe(),e=J(),a=K(),o=Q(),{forecastId:r,tenantEmailDomain:c}=X(),[p,u]=g.useState(!1),[m,D]=g.useState(!1),F=pe.getSignedInUser(),A=d((t=>M(t))),$=A.company?.companyInfo.firstMonthOfFY??1,i=d((t=>O(t.forecastState,t.forecastListState))),l=d((t=>t.forecastListState.fetchState==="Completed")),x=d((t=>t.profitAndLossState)),U=d((t=>t.reportUIOptionsState.selectedForecast)),j=t=>x.pandLByForecastID[t]!=null&&oe(t,x).reducedAllFetchState.fetchState==="Completed",{areTenantIdsInSync:b}=ue();he({isDataReady:l});const{isAiCfoAccessEnabled:N,onAskAiCfoClick:G}=Te({mobileExploreReferrer:"Forecast"});g.useEffect((()=>{if(!p&&b)u(!0),l||a(ae());else if(l&&!m){D(!0);const t=((f,P,R)=>P!=null?f.forecasts.findIndex((I=>I.id===P)):R!=null?f.forecasts.findIndex((I=>I.id===R)):f.forecasts.length>0?0:-1)(i,r,U?.id);t===-1&&r!=null?e("page-not-found",{replace:!0}):t!==-1&&t!=U?.index?(a(q(i.forecasts[t].id,t)),y(r,i.forecasts[t].id,e,o.search)):r==null&&t!==-1&&y(void 0,i.forecasts[t].id,e,o.search),t!==-1&&!j(i.forecasts[t].id)&&b&&a(T(i.forecasts[t].id))}}),[p,u,a,l,i,m,D,O,T,b]);const k=ge(),V=k?.loggedInUserRole!=null&&te(k.loggedInUserRole),{useFeatureGate:W}=w(),{isFeatureEnabled:E}=W(B.isReportsCommentingEnabled),Y=ye(E?A?.companyId:void 0,{clearParams:l&&m}),[z,H]=g.useState(!1),h=new URL(s("forecast_pandl"));h.searchParams.set("firstname",F?.firstName??""),h.searchParams.set("lastname",F?.lastName??""),h.searchParams.set("email",F?.userEmail??"");const L=t=>{H(t)};return n.jsxs(n.Fragment,{children:[l?n.jsx(Fe,{analytics:_,onLoad:t=>(f=>f.trackForecast())(t)}):null,n.jsx(Ae,{isAppContentDrawerOpen:z,handleDrawerToggle:L}),n.jsx(xe,{firstMonthOfFY:$,tenantEmailDomain:c,forecastIdFromUrlPath:r,navigate:e,location:o,isPandLReportFetched:j,meetingUrl:se(h.toString()),hasTransactionAccess:V,isAiCfoAccessEnabled:N,onAskAiCfoClick:G,isReportsCommentingEnabled:E,initialOpenThreadRequest:Y,onClickMenuIcon:()=>{L(!0)}})]})}function Ke(){const s=d((c=>M(c))),{useFeatureGate:e}=w(),{isFeatureEnabled:a}=e(B.isDebitCardFeatureEnabled),o=de(a,s),r=me(s);return o===!0||r===!0?n.jsx(Se,{}):n.jsxs(ee,{children:[n.jsx(C,{path:"/",element:n.jsx(v,{})}),n.jsx(C,{path:"/:forecastId",element:n.jsx(v,{})}),n.jsx(C,{path:"/:forecastId/*",element:n.jsx(Ce,{})})]})}export{Ke as default};
@@ -1,4 +1,4 @@
1
- import{j as r}from"./liveblocks-CM7ZQqxd.js";import{a as p}from"./sentry-Dh9UB4O6.js";import{J as c,K as a,a7 as m,ab as f,ac as h}from"./index-BmT_wdak.js";import"./mui-CeNVlxCm.js";import{i as y}from"./core-BaXck2Yj.js";import"./zeni-epic-state-Bo1fQFWK.js";import"./recharts-BKC_cH7h.js";import"./analytics-WNjEvDwJ.js";import"./plaid-D9ECXCuG.js";import"./dnd-Cyb1SC5Y.js";import"./stripe-cKAAJElX.js";import"./lottie-DYRVCvl4.js";import"./lexical-VH6dL15l.js";import"./pdf-Dhhhum3V.js";import"./utils-X6jrk5Hl.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]="2012cfb4-548c-4aab-9220-efd79b933e1c",e._sentryDebugIdIdentifier="sentry-dbid-2012cfb4-548c-4aab-9220-efd79b933e1c")}catch{}})();const g=c("div")`
1
+ import{j as r}from"./liveblocks-BD1fi6wA.js";import{a as p}from"./sentry-C6D8WJ15.js";import{J as c,K as a,a7 as m,ab as f,ac as h}from"./index-Blw4A66-.js";import"./mui-DPmPgDDD.js";import{i as y}from"./core-Dlma5MIa.js";import"./zeni-epic-state-2zvjmkUL.js";import"./recharts-WuCIKI4c.js";import"./analytics-NBT5BH2R.js";import"./plaid-w5kSeMkL.js";import"./dnd-BgBEAfSC.js";import"./stripe-cKAAJElX.js";import"./lottie-Dd5kLrRz.js";import"./lexical-Cc-23sPJ.js";import"./pdf-BCsxh4ki.js";import"./utils-Bv9LDtmr.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]="2012cfb4-548c-4aab-9220-efd79b933e1c",e._sentryDebugIdIdentifier="sentry-dbid-2012cfb4-548c-4aab-9220-efd79b933e1c")}catch{}})();const g=c("div")`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  width: 100%;
@@ -1,4 +1,4 @@
1
- import{j as a}from"./liveblocks-CM7ZQqxd.js";import{Ul as re,fB as Y,lF as G,dV as N,dU as le,Rh as Q,TK as ce,BZ as Pe,Um as J,BO as je,C7 as Le,C1 as de,BS as pe,C5 as Te,C2 as ve,Un as ue,rr as Ae,g2 as Oe,gA as Re,Uo as H,BW as me,BV as ge,Ca as Ve,c7 as Fe}from"./zeni-epic-state-Bo1fQFWK.js";import{$ as fe,I as X,d as _,z as K,j as he,O as Ce,ad as ye,ax as be,ay as Be,a9 as Se,K as V,ae as we,G as W,az as Ue,ao as Ze,aq as $e,a6 as ze,l as xe,S as He,p as _e,aA as Ge,U as Ke}from"./index-BmT_wdak.js";import{D as De,n as M,S as Ie}from"./mui-CeNVlxCm.js";import ae from"./NotFoundScreen-CbKfgA9a.js";import{a as c}from"./sentry-Dh9UB4O6.js";import{u as ee,i as We,j as g,h as Me,g as qe,l as Je,n as se,o as z}from"./core-BaXck2Yj.js";import{u as Ye}from"./useAskAiCfoHostNavButtonProps-fsQB3AjS.js";import{M as Ne}from"./MobileAppDrawer-AMYN8Gjf.js";import"./recharts-BKC_cH7h.js";import"./analytics-WNjEvDwJ.js";import"./plaid-D9ECXCuG.js";import"./dnd-Cyb1SC5Y.js";import"./stripe-cKAAJElX.js";import"./lottie-DYRVCvl4.js";import"./lexical-VH6dL15l.js";import"./pdf-Dhhhum3V.js";import"./utils-X6jrk5Hl.js";import"./InboxNotificationsProvider-DLtCSJ1e.js";import"./useTaskManagerAccess-LntCDDBS.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]="68af401e-d3fb-4423-94cf-04964b51eec2",e._sentryDebugIdIdentifier="sentry-dbid-68af401e-d3fb-4423-94cf-04964b51eec2")}catch{}})();const Qe={overlayWidth:new Se(100,100,48)},te=W.getLocalizedStrings().peoplePage.invitePage,ne=W.getLocalizedStrings().common,Xe=({companyId:e,managersListView:t,companyPassportView:d,classListView:n,mode:f,isEditPeopleDrawerOpen:i,closeDrawerHandler:b})=>{const h=fe(),m=ee(),[F,B]=c.useState(!1),[k,S]=c.useState(!1),{userId:w}=We(),r=g((l=>re(l))),p=g((l=>Y(l))),E=g((l=>G(l))),{useFeatureGate:D}=X(),{isFeatureEnabled:I}=D(_.isDebitCardFeatureEnabled),P=N(I,p),T=le(p),v=Q(p),U=ce(p),Z=!!p.company?.featuresActivationInfo?.isReimbursementFeatureEnabled,x=!P&&E&&n.fetchState!=="Completed"||t.fetchState!=="Completed"||d.fetchState!=="Completed"||e==null;if(K.getSignedInUser()==null)throw Error("Can't access invite people page without signing in...");const C=()=>{m(J()),b()},A=()=>{F===!0?S(!0):C()},$=d.companyView?.controllers?.map((l=>l.user)),u=!!p.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:j}=D(_.isChargeCardFeatureEnabled),L=he(p,j,I),{isCardsHidden:O}=Ce(p?.tenantId),y=!L||O,R=p.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",s={peopleDetails:r,classList:n.classes,managersList:t.users,controllersList:$,mode:f,isZeniTenant:v,isAccountingClassesEnabled:E,isReimbursementDisabled:Z===!1,isZeniAccountsDisabled:u===!1,isChargeCardDisabled:y,isTreasuryDisabled:R===!1,isLiteRoleDisabled:U===!1,isBankingOnlyTenant:P,isCardsOnlyTenant:T,onResetClick:C,onDeleteUser:l=>{m(pe(l.userId,l.userRole.userRoleId))},onPeopleLocalDataUpdated:l=>{m(de({peopleLocalData:l})),B(!0)},onSaveClick:()=>{m(f==="zeni_only"?je(e):Le(v))},onCloseClick:A,isLoading:x||r.person==null},o={onOkClick:()=>{S(!1),C()},onCancelClick:()=>{S(!1)}};return c.useEffect((()=>{x===!1&&w!=null&&m(Pe(w))}),[x,w]),c.useEffect((()=>{r.updatePersonState.fetchState==="Completed"&&C()}),[r.updatePersonState.fetchState]),a.jsx(De,{anchor:"right",open:i,PaperProps:{style:{width:Qe.overlayWidth.valuePercentage(h),boxShadow:"none"}},slotProps:{backdrop:{style:{backgroundColor:ye.overlayDark,cursor:"pointer"}}},onClose:A,children:a.jsxs(ea,{onClick:l=>l.stopPropagation(),children:[k===!0?a.jsx(be,{titleComponent:a.jsx(ke,{children:te.discardTitle}),descriptionComponent:a.jsx(Ee,{children:te.discardDescription}),primaryButtonText:ne.yes,secondaryButtonText:ne.no,action:o,isEditPopup:!0}):null,a.jsx(Be,{...s})]})})},ea=M(Ie)`
1
+ import{j as a}from"./liveblocks-BD1fi6wA.js";import{Ul as re,fB as Y,lF as G,dV as N,dU as le,Rh as Q,TK as ce,BZ as Pe,Um as J,BO as je,C7 as Le,C1 as de,BS as pe,C5 as Te,C2 as ve,Un as ue,rr as Ae,g2 as Oe,gA as Re,Uo as H,BW as me,BV as ge,Ca as Ve,c7 as Fe}from"./zeni-epic-state-2zvjmkUL.js";import{$ as fe,I as X,d as _,z as K,j as he,O as Ce,ad as ye,ax as be,ay as Be,a9 as Se,K as V,ae as we,G as W,az as Ue,ao as Ze,aq as $e,a6 as ze,l as xe,S as He,p as _e,aA as Ge,U as Ke}from"./index-Blw4A66-.js";import{D as De,n as M,S as Ie}from"./mui-DPmPgDDD.js";import ae from"./NotFoundScreen-Wkt8x0Ja.js";import{a as c}from"./sentry-C6D8WJ15.js";import{u as ee,i as We,j as g,h as Me,g as qe,l as Je,n as se,o as z}from"./core-Dlma5MIa.js";import{u as Ye}from"./useAskAiCfoHostNavButtonProps-5qRN6gKs.js";import{M as Ne}from"./MobileAppDrawer-BMvh-RAa.js";import"./recharts-WuCIKI4c.js";import"./analytics-NBT5BH2R.js";import"./plaid-w5kSeMkL.js";import"./dnd-BgBEAfSC.js";import"./stripe-cKAAJElX.js";import"./lottie-Dd5kLrRz.js";import"./lexical-Cc-23sPJ.js";import"./pdf-BCsxh4ki.js";import"./utils-Bv9LDtmr.js";import"./InboxNotificationsProvider-7eYmgI1F.js";import"./useTaskManagerAccess-BKVtGCGL.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]="68af401e-d3fb-4423-94cf-04964b51eec2",e._sentryDebugIdIdentifier="sentry-dbid-68af401e-d3fb-4423-94cf-04964b51eec2")}catch{}})();const Qe={overlayWidth:new Se(100,100,48)},te=W.getLocalizedStrings().peoplePage.invitePage,ne=W.getLocalizedStrings().common,Xe=({companyId:e,managersListView:t,companyPassportView:d,classListView:n,mode:f,isEditPeopleDrawerOpen:i,closeDrawerHandler:b})=>{const h=fe(),m=ee(),[F,B]=c.useState(!1),[k,S]=c.useState(!1),{userId:w}=We(),r=g((l=>re(l))),p=g((l=>Y(l))),E=g((l=>G(l))),{useFeatureGate:D}=X(),{isFeatureEnabled:I}=D(_.isDebitCardFeatureEnabled),P=N(I,p),T=le(p),v=Q(p),U=ce(p),Z=!!p.company?.featuresActivationInfo?.isReimbursementFeatureEnabled,x=!P&&E&&n.fetchState!=="Completed"||t.fetchState!=="Completed"||d.fetchState!=="Completed"||e==null;if(K.getSignedInUser()==null)throw Error("Can't access invite people page without signing in...");const C=()=>{m(J()),b()},A=()=>{F===!0?S(!0):C()},$=d.companyView?.controllers?.map((l=>l.user)),u=!!p.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:j}=D(_.isChargeCardFeatureEnabled),L=he(p,j,I),{isCardsHidden:O}=Ce(p?.tenantId),y=!L||O,R=p.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",s={peopleDetails:r,classList:n.classes,managersList:t.users,controllersList:$,mode:f,isZeniTenant:v,isAccountingClassesEnabled:E,isReimbursementDisabled:Z===!1,isZeniAccountsDisabled:u===!1,isChargeCardDisabled:y,isTreasuryDisabled:R===!1,isLiteRoleDisabled:U===!1,isBankingOnlyTenant:P,isCardsOnlyTenant:T,onResetClick:C,onDeleteUser:l=>{m(pe(l.userId,l.userRole.userRoleId))},onPeopleLocalDataUpdated:l=>{m(de({peopleLocalData:l})),B(!0)},onSaveClick:()=>{m(f==="zeni_only"?je(e):Le(v))},onCloseClick:A,isLoading:x||r.person==null},o={onOkClick:()=>{S(!1),C()},onCancelClick:()=>{S(!1)}};return c.useEffect((()=>{x===!1&&w!=null&&m(Pe(w))}),[x,w]),c.useEffect((()=>{r.updatePersonState.fetchState==="Completed"&&C()}),[r.updatePersonState.fetchState]),a.jsx(De,{anchor:"right",open:i,PaperProps:{style:{width:Qe.overlayWidth.valuePercentage(h),boxShadow:"none"}},slotProps:{backdrop:{style:{backgroundColor:ye.overlayDark,cursor:"pointer"}}},onClose:A,children:a.jsxs(ea,{onClick:l=>l.stopPropagation(),children:[k===!0?a.jsx(be,{titleComponent:a.jsx(ke,{children:te.discardTitle}),descriptionComponent:a.jsx(Ee,{children:te.discardDescription}),primaryButtonText:ne.yes,secondaryButtonText:ne.no,action:o,isEditPopup:!0}):null,a.jsx(Be,{...s})]})})},ea=M(Ie)`
2
2
  display: flex;
3
3
  min-height: 100%;
4
4
  flex-direction: column;