@zeniai/web-app-ui 5.3.41-qa → 5.3.42-dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/AccountMappingScreen-5txeuTng.js +9 -0
- package/dist/assets/ActualMatchingMatchDetailScreen-BvCTHIwN.js +1 -0
- package/dist/assets/AddressRoutes-CysroEs-.js +1 -0
- package/dist/assets/AddressScreen-C1CfOA8k.js +9 -0
- package/dist/assets/{AiCfoScreen-BjMYvl6E.js → AiCfoScreen-C0gnDsXr.js} +5 -5
- package/dist/assets/{AppDrawer-ByoXxMIV.js → AppDrawer-CZ5MsAyB.js} +2 -2
- package/dist/assets/{BillPayApprovalRoutes-Z4uvf0-n.js → BillPayApprovalRoutes-Dba8jEIY.js} +1 -1
- package/dist/assets/{BillPayRoutes-8zmFRoA_.js → BillPayRoutes-BInjoPbL.js} +11 -11
- package/dist/assets/BusinessVerificationPageScreen-BmHKq1LL.js +9 -0
- package/dist/assets/{CardsAiCfoScreen-B7sfpD2b.js → CardsAiCfoScreen-C6Rnq8nD.js} +1 -1
- package/dist/assets/ChargeCardRoutes-P239JK-b.js +71 -0
- package/dist/assets/{CompanyPassportScreen-DDKosLEE.js → CompanyPassportScreen-yPmE04_9.js} +1 -1
- package/dist/assets/ConnectionAuthScreen-6-1bG5gz.js +11 -0
- package/dist/assets/CustomerOnboardingAuthScreen-C__JnnR_.js +1 -0
- package/dist/assets/CustomerOnboardingRoutes-CbzzxK0y.js +30 -0
- package/dist/assets/{DashboardRoutes-B5yb7VGD.js → DashboardRoutes-DhWNQvqz.js} +4 -4
- package/dist/assets/{DefaultTenantHome-DXPTZTHs.js → DefaultTenantHome-Fsi_QjM5.js} +1 -1
- package/dist/assets/DomesticWireDetailScreen-CuBtrLRo.js +18 -0
- package/dist/assets/{DrawerScreen--7ksii2j.js → DrawerScreen-o43C4sHm.js} +1 -1
- package/dist/assets/EntityDetailRoutes-Vj0NPJut.js +1 -0
- package/dist/assets/ExpenseAutomationRoutes-faxOwOvi.js +38 -0
- package/dist/assets/FeaturePreviewScreen-CEOFkjIy.js +1 -0
- package/dist/assets/HubSpotOAuthCallbackScreen-CnHqx1ge.js +1 -0
- package/dist/assets/{InboxNotificationsProvider-D007v5X6.js → InboxNotificationsProvider-Cf5DQSg3.js} +1 -1
- package/dist/assets/{InvoicingRoutes-6Wikj2BP.js → InvoicingRoutes--kNvLDpX.js} +2 -2
- package/dist/assets/{MagicLinkRoutes-D0y8ZbiR.js → MagicLinkRoutes-_oMvrXOe.js} +8 -8
- package/dist/assets/MagicLinkSignInScreen-D2yfAbuX.js +12 -0
- package/dist/assets/MobileAppDrawer-Q8q8ssn0.js +1 -0
- package/dist/assets/NotFoundScreen-3YmbDG-O.js +1 -0
- package/dist/assets/{NotificationRoutes-La5Ef0Sp.js → NotificationRoutes-BFjfuaHE.js} +1 -1
- package/dist/assets/OAuthConsentScreen-Ce7q6w-7.js +1 -0
- package/dist/assets/PandLWithForecastRoutes-Cb8E55Qo.js +1 -0
- package/dist/assets/{PaymentLinkScreen-C3veO1_u.js → PaymentLinkScreen-CN69RRr9.js} +1 -1
- package/dist/assets/PeopleRoutes-DNCzXaoC.js +22 -0
- package/dist/assets/PerformanceRoutes-DyNYMyLi.js +1 -0
- package/dist/assets/{Preview-DA8U2xpZ.js → Preview-BCwFnEAM.js} +1 -1
- package/dist/assets/{QBOConnectionScreen-BbB3FEE8.js → QBOConnectionScreen-DX5rBjLM.js} +1 -1
- package/dist/assets/ReimbursementApprovalRoutes-DifzmUQS.js +1 -0
- package/dist/assets/{ReimbursementApprovalRuleDetailScreen-lW1DSyNO.js → ReimbursementApprovalRuleDetailScreen-6W7aXQIv.js} +1 -1
- package/dist/assets/{ReimbursementRoutes-03Hgu3V3.js → ReimbursementRoutes-Caztwlhg.js} +9 -9
- package/dist/assets/{ReportsRoutes-B9cy_-f4.js → ReportsRoutes-CfScWyxA.js} +1 -1
- package/dist/assets/RewardsRoutes-BaqYIdkd.js +1 -0
- package/dist/assets/ScheduleDetailsPrepaidExpensesScreen-DuraGGsO.js +33 -0
- package/dist/assets/ScreenRoutes-QNvqH_bZ.js +2 -0
- package/dist/assets/{SettingsRoutes-BAJmUy_d.js → SettingsRoutes-DzQurTcP.js} +6 -6
- package/dist/assets/{SetupPagesScreen-CNVeqnHU.js → SetupPagesScreen-CsSP_P2k.js} +5 -5
- package/dist/assets/SignInScreen-CRymVKij.js +1 -0
- package/dist/assets/SignOutScreen-B0U7u8Hy.js +9 -0
- package/dist/assets/{TaskListScreen-B_HBW--i.js → TaskListScreen-CXn6czhu.js} +2 -2
- package/dist/assets/TaskRoutes-0Yfh5AkX.js +9 -0
- package/dist/assets/TransactionDetailRoutes-BiIqbu_-.js +1 -0
- package/dist/assets/{TransactionDetailScreen-BISRvrnZ.js → TransactionDetailScreen-Cxl44PLi.js} +2 -2
- package/dist/assets/TransactionListRoutes-CBLSrFS8.js +1 -0
- package/dist/assets/{TreasuryRoutes-DQeUZ7RQ.js → TreasuryRoutes-a3UpD3kR.js} +6 -6
- package/dist/assets/{VendorsRoutes-AD9AzaGF.js → VendorsRoutes-DlFjWODu.js} +18 -18
- package/dist/assets/WiseConfirmationScreen-BJ1TyqgG.js +12 -0
- package/dist/assets/ZeniAccountRoutes-C0xgRuTa.js +57 -0
- package/dist/assets/ZeniAccountStatementScreen-C8J1M6mP.js +9 -0
- package/dist/assets/{accountMappingHelper-qlU24D2s.js → accountMappingHelper-2xXLJj4S.js} +1 -1
- package/dist/assets/{analytics-BvodL4nJ.js → analytics-CvsRIk3B.js} +1 -1
- package/dist/assets/{analyticsHelper-BBEm35nD.js → analyticsHelper-tF6p2yRC.js} +1 -1
- package/dist/assets/{core-gUqdW_kq.js → core-DGLzDXWl.js} +1 -1
- package/dist/assets/{decodeURIComponentSafe-Cst3Y24b.js → decodeURIComponentSafe-k3ZAUeWI.js} +1 -1
- package/dist/assets/{dnd-YSyN45zY.js → dnd-SnD389s6.js} +1 -1
- package/dist/assets/{empty-BAVoovBk.js → empty-BfBfVq50.js} +1 -1
- package/dist/assets/{empty-CkcqWk4Z.js → empty-BjVnPUF5.js} +1 -1
- package/dist/assets/{emptyVideoElement-DMVtoCOe.js → emptyVideoElement-Bb1KlJXy.js} +1 -1
- package/dist/assets/epic-CPuRNynX.js +2 -0
- package/dist/assets/expenseAutomationHelper-DWDIPthN.js +1 -0
- package/dist/assets/{getLocaleForTenant-BFGbVplK.js → getLocaleForTenant-CZIO6uAG.js} +1 -1
- package/dist/assets/{index-70FTEc4H.js → index-B2CKeHlo.js} +1 -1
- package/dist/assets/{index-ChcsxO47.js → index-BMI1TT7Z.js} +1 -1
- package/dist/assets/{index-1WLkQfLs.js → index-Buyjnqrt.js} +1 -1
- package/dist/assets/{index-BhZ9H0Qw.js → index-C54xa34r.js} +1 -1
- package/dist/assets/index-CQFc7TiS.js +1 -0
- package/dist/assets/{index-BzFSQsxk.js → index-CzPkUTbT.js} +2 -2
- package/dist/assets/{index-DRDpUzzs.js → index-DGjciFPC.js} +16718 -15885
- package/dist/assets/{index-6dqseRo4.js → index-DPcuwgM-.js} +1 -1
- package/dist/assets/{lexical-Euc6kCJG.js → lexical-CMBMntF_.js} +1 -1
- package/dist/assets/{liveblocks-B3m51ZRo.js → liveblocks-DRsJ0YIJ.js} +1 -1
- package/dist/assets/{lottie-DLBd_qLT.js → lottie-DEqUWUd5.js} +1 -1
- package/dist/assets/{mui-DCW4m3lZ.js → mui-BuJ3P0FU.js} +1 -1
- package/dist/assets/{pathToGoBack-Ds-XNEX3.js → pathToGoBack-BzjHaNqp.js} +1 -1
- package/dist/assets/{pdf-BDXl9G7N.js → pdf-B_v4zyN7.js} +3 -3
- package/dist/assets/{pdf-lib-Bku26ZcE.js → pdf-lib-DxbyphS9.js} +1 -1
- package/dist/assets/{plaid-BrXe9xNf.js → plaid-i7y7YD6O.js} +1 -1
- package/dist/assets/{pusher-BzxZmWnS.js → pusher-BYBfYYCn.js} +1 -1
- package/dist/assets/{react-DtuhKjd8.js → react-B90rw7na.js} +1 -1
- package/dist/assets/{react-pusavzWL.js → react-C2HSs5Iu.js} +1 -1
- package/dist/assets/{react-C43HbBFY.js → react-CAYYQ7Si.js} +1 -1
- package/dist/assets/{react-Db0eqcPH.js → react-CAr2Hff_.js} +1 -1
- package/dist/assets/{react-Cp8yT8Rr.js → react-Dm85ZpZj.js} +1 -1
- package/dist/assets/{react-FxzlmTOI.js → react-leqbcToB.js} +1 -1
- package/dist/assets/{recharts-HpXoq1DR.js → recharts-CJlXFxhv.js} +1 -1
- package/dist/assets/{routePaths-BlnN04aI.js → routePaths-COaM8xFB.js} +1 -1
- package/dist/assets/{sentry-DI7gLUjw.js → sentry-G4ZANa8Z.js} +1 -1
- package/dist/assets/stripSplatSuffix-BTaD_7hZ.js +1 -0
- package/dist/assets/{url-BVmez_R2.js → url--ciz_Nq8.js} +1 -1
- package/dist/assets/{url-qyBRakHR.js → url-CtF92dYM.js} +1 -1
- package/dist/assets/useActualMatchingMatchDetail-Dtg-Odjs.js +1 -0
- package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-C8tiJ4-s.js → useAiCfoDashboardSuggestedQuestionsChips-DXgID2ue.js} +1 -1
- package/dist/assets/useAskAiCfoHostNavButtonProps-DY2m50un.js +1 -0
- package/dist/assets/{useChargeCardPusherEvents-K7_8wfj8.js → useChargeCardPusherEvents-C-hT_5jI.js} +1 -1
- package/dist/assets/{useDeviceId-kl-tdydV.js → useDeviceId-C9MUyzJJ.js} +1 -1
- package/dist/assets/useEmailConnectResultRefresh-B7XzuZ4T.js +1 -0
- package/dist/assets/{useInitialThreadRequest-TMWlbA40.js → useInitialThreadRequest-Cdwnj1Ib.js} +1 -1
- package/dist/assets/useTaskManagerAccess-i7vk79Wr.js +1 -0
- package/dist/assets/{utils-8Dv5nUFZ.js → utils-Bz8wuSWM.js} +1 -1
- package/dist/assets/withTransactionSidePanel-_ek7stLz.js +25 -0
- package/dist/assets/{zeni-epic-state-C-d25VTi.js → zeni-epic-state-Dm2vDWXH.js} +6 -6
- package/dist/index.html +1 -1
- package/package.json +4 -4
- package/dist/assets/AccountMappingScreen-C3HFW5Ij.js +0 -9
- package/dist/assets/AddressRoutes-Bt5wsDb7.js +0 -1
- package/dist/assets/AddressScreen-CSJE0p29.js +0 -9
- package/dist/assets/BusinessVerificationPageScreen-CmhKA9oQ.js +0 -9
- package/dist/assets/ChargeCardRoutes-C7bJJS3x.js +0 -71
- package/dist/assets/ConnectionAuthScreen-tllRDLdE.js +0 -11
- package/dist/assets/CustomerOnboardingAuthScreen-BtQtr6Oc.js +0 -1
- package/dist/assets/CustomerOnboardingRoutes-zfeAaUV5.js +0 -30
- package/dist/assets/DomesticWireDetailScreen-Bl1py3nW.js +0 -18
- package/dist/assets/EntityDetailRoutes-Cjc6zlA1.js +0 -1
- package/dist/assets/ExpenseAutomationRoutes-Dg2fewAy.js +0 -38
- package/dist/assets/FeaturePreviewScreen-CaIMasua.js +0 -1
- package/dist/assets/HubSpotOAuthCallbackScreen-y0UiA1as.js +0 -1
- package/dist/assets/MagicLinkSignInScreen-CYMk4ubj.js +0 -12
- package/dist/assets/MobileAppDrawer-Bh8VAeHB.js +0 -1
- package/dist/assets/NotFoundScreen-BFfoIcMt.js +0 -1
- package/dist/assets/OAuthConsentScreen-qHtuiZOo.js +0 -1
- package/dist/assets/PandLWithForecastRoutes-AChf_KvX.js +0 -1
- package/dist/assets/PeopleRoutes-Dx-0mEVQ.js +0 -22
- package/dist/assets/PerformanceRoutes-3JW12kzP.js +0 -1
- package/dist/assets/ReimbursementApprovalRoutes-CvLfwozC.js +0 -1
- package/dist/assets/RewardsRoutes-DQIZ8X-t.js +0 -1
- package/dist/assets/ScheduleDetailsPrepaidExpensesScreen-D9k6A3OE.js +0 -33
- package/dist/assets/ScreenRoutes-DBgMcdH4.js +0 -2
- package/dist/assets/SignInScreen-_6ovFcIG.js +0 -1
- package/dist/assets/SignOutScreen-DQot6FAh.js +0 -9
- package/dist/assets/TaskRoutes-CIgfsl6U.js +0 -9
- package/dist/assets/TransactionDetailRoutes-CEwE4Bbf.js +0 -1
- package/dist/assets/TransactionListRoutes-DHaTXNgW.js +0 -1
- package/dist/assets/WiseConfirmationScreen-DnPfMtVh.js +0 -12
- package/dist/assets/ZeniAccountRoutes-BKcFRSlc.js +0 -57
- package/dist/assets/ZeniAccountStatementScreen-Cn72q1Zx.js +0 -9
- package/dist/assets/epic-DHyjKhvW.js +0 -2
- package/dist/assets/expenseAutomationHelper-DDRCXr7k.js +0 -1
- package/dist/assets/index-DhQKJDfi.js +0 -1
- package/dist/assets/useAskAiCfoHostNavButtonProps-DNzUy0g0.js +0 -1
- package/dist/assets/useEmailConnectResultRefresh-BJXmlYiy.js +0 -1
- package/dist/assets/useTaskManagerAccess-BJoTHFNB.js +0 -1
- package/dist/assets/withTransactionSidePanel-ZShW5IUX.js +0 -25
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as s}from"./liveblocks-B3m51ZRo.js";import{a as r}from"./sentry-DI7gLUjw.js";import{u as D,h as L,i as R,j as C,t as W,l as _,s as Z,g as J,N as B,n as ie,o as x}from"./core-gUqdW_kq.js";import{a8 as ln,k as p,aq as T,U as m,cb as dn,cc as un,cd as gn,ce as mn,cf as vn,cg as pn,ch as fn,ci as Sn,cj as hn,ck as In,cl as Cn,cm as En,cn as kn,co as yn,p as Y,cp as xn,cq as bn,ae as se,cr as jn,cs as Pn,z as Ie,ct as Dn,cu as Ln,cv as An,cw as $n,cx as wn,cy as Fn,cz as Rn,cA as Tn,Q as On,ai as ft,cB as _n,cC as Mn,cD as Nn,cE as Un,cF as De,cG as Bn,cH as Vn,cI as Zn,cJ as Hn,cK as qn,cL as Kn,t as Qe,j as St,cM as Qn,cN as zn,cO as Gn,cP as Wn,cQ as Jn,cR as Yn,cS as Xn}from"./index-DRDpUzzs.js";import"./mui-DCW4m3lZ.js";import{A as K}from"./AddressScreen-CSJE0p29.js";import M from"./NotFoundScreen-BFfoIcMt.js";import{Z0 as ei,Z1 as ti,uP as ze,Z2 as Q,vg as ce,Z3 as Le,Z4 as z,vT as Ge,v_ as ni,w3 as ht,Z5 as Ae,Z6 as It,vX as Ct,Z7 as $e,vV as Et,yz as ii,vW as oi,vP as ai,xq as We,vf as Ce,Z8 as si,Z9 as kt,wa as ci,Za as G,wh as ri,Zb as li,Zc as yt,Zd as xt,yl as di,Ze as ue,Zf as Je,Zg as bt,vd as ui,Zh as gi,v7 as mi,Zi as vi,xD as pi,Zj as jt,xM as Ye,Zk as fi,xJ as Si,Zl as we,gg as hi,Zm as te,Zn as ne,ww as Ii,vl as Xe,Zo as Fe,vq as Pt,vo as Ci,vi as Ei,wp as ki,vs as yi,wy as xi,Zp as Ee,wF as Dt,wD as ke,Fo as Re,xS as et,Zq as bi,ve as Te,Zr as Oe,vB as ye,vy as xe,vL as Lt,vK as _e,vv as ji,vE as At,vN as oe,fE as Me,UP as $t,vh as Ne,vI as Pi,vJ as Di,vH as Li,Zs as Ai,wd as tt,wi as $i,we as wt,Zt as Ft,v1 as nt,Zu as wi,uZ as Rt,Zv as Fi,xY as Ri,y0 as H,xX as Ti,x4 as Ue,Zw as Oi,Zx as Tt,y9 as it,Zy as _i,y6 as Mi,Zz as Ot,x7 as Ni,x8 as V,xb as Ui,ZA as _t,xl as pe,ZB as Bi,wx as Mt,Tm as Nt,ZC as Vi,xv as Zi,ZD as Ut,ZE as Hi,ZF as qi,ZG as Ki,y_ as Qi,ZH as zi,ZI as Bt,yg as Vt,ZJ as Zt,yY as fe,ZK as Gi,yV as Wi,ZL as Ji,ZM as Yi,ZN as Xi,ZO as eo,ZP as to,ZQ as ot,ZR as no,e9 as io,z2 as oo,ZS as Be,wP as at,ZT as Ve,ZU as re,wZ as Ht,wU as qt,wS as be,ZV as ao,wK as so,ym as Kt,yN as st,yI as co,ZW as ro,yn as lo,ZX as uo,yO as go,yS as mo,ZY as vo,ZZ as Qt,c8 as po,mr as fo,ms as So,Z_ as ct,vU as le,gk as ho,my as Io,yF as zt,ze as Co,yC as Gt,ul as Eo,zb as rt,u9 as ko,z8 as lt,hR as yo,TP as dt,TQ as xo,FA as Wt,hJ as bo,Z$ as jo,UE as Po,_0 as Do,zk as Se,zl as Lo,_1 as Ao,_2 as Jt,zh as $o,_3 as wo,_4 as Fo,xz as Ro,_5 as To}from"./zeni-epic-state-C-d25VTi.js";import{M as Oo}from"./MobileAppDrawer-Bh8VAeHB.js";import{q as de}from"./QBOConnectionScreen-BbB3FEE8.js";import"./recharts-HpXoq1DR.js";import"./analytics-BvodL4nJ.js";import"./plaid-BrXe9xNf.js";import"./dnd-YSyN45zY.js";import"./stripe-cKAAJElX.js";import"./lottie-DLBd_qLT.js";import"./lexical-Euc6kCJG.js";import"./pdf-BDXl9G7N.js";import"./utils-8Dv5nUFZ.js";import"./InboxNotificationsProvider-D007v5X6.js";import"./useTaskManagerAccess-BJoTHFNB.js";import"./empty-CkcqWk4Z.js";import"./pdf-lib-Bku26ZcE.js";import"./index-70FTEc4H.js";import"./url-qyBRakHR.js";import"./index-DhQKJDfi.js";import"./decodeURIComponentSafe-Cst3Y24b.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new n.Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="138f14b6-2314-4f01-b548-2e0f9908fad7",n._sentryDebugIdIdentifier="sentry-dbid-138f14b6-2314-4f01-b548-2e0f9908fad7")}catch{}})();const $=({event:n,isReady:e=!0})=>e?s.jsx(ln,{analytics:p,onLoad:t=>t.trackPageLoaded(n)}):null;function N(...n){return n.some((e=>e==="Error"))}function _o(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=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:g,hasMore:S,items:f,nextCursor:h,auditLogEntityRouteOptions:P,auditLogListSortFieldOptions:b}=C(ei),k=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),y=`/${t??""}/invoicing`,I=r.useCallback(((A,U)=>{const O=ti(y,A,U,P);O!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{entity:A,entityId:U,fromScreen:"audit_log"}),e(O))}),[P,e,y]);r.useEffect((()=>{const A=setTimeout((()=>d(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&n(ze({filters:k,keepExistingListItems:!1,sort:u}))}),[i,k,u,n]);const j=g==="Not-Started"||g==="In-Progress"&&f.length===0,E=g==="In-Progress"&&f.length>0,w=g==="Completed";return N(g)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingAuditLogPage,isReady:w}),s.jsx(dn,{auditLogEntityRouteOptions:P,auditLogListSortFieldOptions:b,entries:f,hasMore:S,isLoading:j,isLoadingMore:E,searchValue:a,sortState:l,onEntityLinkClick:I,onLoadMore:()=>{S&&h!=null&&n(ze({cursor:h,filters:k,keepExistingListItems:!0,sort:u}))},onSearchChange:o,onSortChange:v})]})}function ge(n,e=!1){const t=D(),i=C((c=>Q(c).productNextCursor!=null)),a=C((c=>Q(c).productNextCursor)),o=C((c=>Q(c).productFetchState.fetchState));r.useEffect((()=>{n&&(e&&o!=="Not-Started"||t(ce({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[n,t,e]),r.useEffect((()=>{n&&o!=="In-Progress"&&i&&a!=null&&t(ce({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[n,t,o,i,a])}const Mo=new Set(["plan"]),Yt=[],No=It((n=>n.length>0?n:Yt),mn),Uo=It((n=>n.length>0?n:Yt),gn),Bo=_((function(n,e){const{view:t}=e;return{applicableItemOptions:t.applicableItemOptions,groupedAccountOptions:No(t.qboAccountHierarchy),groupedClassOptions:Uo(t.qboClassHierarchy),catalogItemLifecycleActionOptions:t.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:t.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:t.catalogTierTypeOptionsByPricingModel,periodUnitOptions:t.periodUnitOptions,trialEndActionOptions:t.trialEndActionOptions,trialUnitOptions:t.trialUnitOptions,typeOptions:t.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:t.actionState.fetchState==="In-Progress",isSaving:t.fetchState==="In-Progress",itemId:e.itemId,localData:t.localData,plan:t.plan}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${t}/catalog`),onLifecycleAction:i!==""?a=>{i!==""&&n(Ct({action:a,id:i}))}:void 0,onEditChange:a=>{i!==""&&n(Ae({id:i,localData:a}))},onSaveEdit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemEdited,{itemId:i}),n(ht({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&n(ni({action:o,id:a,parentItemId:i}))}}}))(un);function Vo(){const n=D(),e=L(),{item_id:t,tenantEmailDomain:i}=R(),[a]=W(),{areTenantIdsInSync:o}=T(),c=(d=a.get("kind"))!=null&&Mo.has(d)?d:"plan";var d;const l=C((k=>Le(k,t))),{pageFetchState:v}=l,u=v.fetchState;r.useEffect((()=>(n(z()),()=>{n(z())})),[n]),r.useEffect((()=>{o&&n(Ge({id:t,kind:c}))}),[o,t,c,n]);const[g,S]=r.useState(0);r.useEffect((()=>{l.fetchState==="Completed"&&(n(z()),n(Ge({cacheOverride:!0,id:t,kind:c})),S((k=>k+1)))}),[l.fetchState,n,t,c]);const f=u==="Completed";ge(o,!0);const[h,P]=r.useState(f?t:void 0);r.useEffect((()=>{t!=null&&f&&P(t)}),[t,f]);const b=h!==t&&(u==="Not-Started"||u==="In-Progress");return N(u)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogItemDetailPage,isReady:f}),s.jsx(Bo,{navigate:e,tenantEmailDomain:i,itemId:t??"",kind:c,isLoading:b,view:l},g)]})}function Ze(n={}){const{enabled:e=!0,fetchSyncHealth:t=!1,loadAccountingPickers:i=!1,reuseCached:a=!1}=n,o=D(),{areTenantIdsInSync:c}=T(),d=C($e),l=d.connection?.connected===!0,v=d.connectionFetchState.fetchState;return r.useEffect((()=>{e&&c&&(a&&v!=="Not-Started"||o(Et()),t&&o(ii()))}),[c,o,e,t,a]),r.useEffect((()=>{e&&c&&l&&i&&o(oi())}),[c,o,e,l,i]),{isQboConnected:l,qboView:d}}const Zo=new Set(["addon","charge","plan"]),Ho=new Set(["plan"]),qo=_((function(n,e){const t=Le(n,e.itemId);return{fieldHelp:t.fieldHelp,isQboPickerDataLoading:t.isQboPickerDataLoading,qboClassHierarchy:t.qboClassHierarchy,qboAccountHierarchy:t.qboAccountHierarchy,applicabilityValues:t.applicabilityValues,periodUnitOptions:t.periodUnitOptions,trialEndActionOptions:t.trialEndActionOptions,trialUnitOptions:t.trialUnitOptions,typeOptions:t.typeOptions,applicableItemOptions:t.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save catalog item.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode,pricingModelValues:t.pricingModelValues,prorationValues:t.prorationValues,tierTypeOptionsByPricingModel:t.catalogTierTypeOptionsByPricingModel,tierTypeValues:t.tierTypeValues}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,i=e.isEdit?"edit":"create",{itemId:a}=e,o=a!=null?`${t}/catalog/${encodeURIComponent(a)}`:`${t}/catalog`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemFormCancelled),n(z()),e.navigate(`${t}/catalog`)},onChange:c=>{n(Ae({id:a,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemSaved,{mode:i}),n(ht({id:a}))}}}))(vn);function Ko(){const n=D(),e=L(),{item_id:t,tenantEmailDomain:i}=R(),[a]=W(),{areTenantIdsInSync:o}=T(),c=t!=null,d=a.get("type"),l=d!=null&&Zo.has(d)?d:void 0,v=(u=a.get("kind"))!=null&&Ho.has(u)?u:"plan";var u;const g=C((S=>Le(S,t)));return ge(o,!0),Ze({loadAccountingPickers:!0,reuseCached:!0}),r.useEffect((()=>{o&&t!=null&&n(ai({id:t,kind:v}))}),[o,t,v,n]),r.useEffect((()=>{c||l==null||g.localData.catalogType===l||n(Ae({localData:{...g.localData,catalogType:l}}))}),[c,l,g.localData?.catalogType,n]),r.useEffect((()=>{if(g.fetchState==="Completed"){const S=g.savedItemId??t,f=S!=null?`/${i}/invoicing/catalog/${encodeURIComponent(S)}`:`/${i}/invoicing/catalog`;e(f),n(z())}}),[g.fetchState,g.savedItemId,t,n,e,i]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogItemFormPage}),s.jsx(qo,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:c,itemId:t})]})}const Qo={addons:"addon",all:"item",charges:"charge",plans:"plan"},zo=_((function(n,e){const t=Q(n),i=e.activeTab==="plans",a=e.activeTab==="all",o=i?t.plans:a?[...t.plans,...t.products]:t.products,c=i||a&&t.fetchState==="In-Progress"?t.fetchState:t.productFetchState.fetchState;return{catalogItemLifecycleActionOptions:t.catalogItemLifecycleActionOptions,counts:t.count,countsLoading:t.countsFetchState.fetchState==="Not-Started"||t.countsFetchState.fetchState==="In-Progress",hasMore:i?t.planNextCursor!=null:a&&t.planNextCursor!=null||t.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&o.length===0,isLoadingMore:c==="In-Progress"&&o.length>0,plans:t.plans,productColumns:t.productColumns,products:t.products}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",a=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${t}/data_import`)},onAddItem:()=>{const c=Qo[e.activeTab];p.trackInvoicingActionClick(m.Event.invoicingAddCatalogItemClicked,{itemType:c}),e.navigate(`${t}/catalog/new?type=${c}`)},onItemClick:(c,d)=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemRowClicked,{itemId:d}),e.navigate(`${t}/catalog/${encodeURIComponent(d)}`)},onCatalogItemLifecycleAction:(c,d)=>{n(Ct({action:si(d),id:c}))},onLoadMore:()=>{if(a)return e.planNextCursor!=null&&n(Ce({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&n(ce({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));o!=null&&n(i?Ce({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):ce({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(pn);function Go(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState("plans"),[l,v]=r.useState(""),[u,g]=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]),P=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),b=C((A=>Q(A))),k=b.planFilters.search,y=b.planSort,I=b.planNextCursor,j=b.productNextCursor,E=b.fetchState==="Completed",w=b.runningActionId??null;return r.useEffect((()=>{const A=setTimeout((()=>v(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&n(We({cacheOverride:!1,planFilters:h,productFilters:P,planSort:S,productSort:S}))}),[i,n,h,P,S]),r.useEffect((()=>{i&&(f!==k||S?.field!==y?.field||S?.dir!==y?.dir)&&n(We({cacheOverride:!0,planFilters:h,productFilters:P,planSort:S,productSort:S}))}),[k,y,i,n,h,P,f,S]),N(b.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogPage,isReady:E}),s.jsx(zo,{navigate:e,tenantEmailDomain:t,activeTab:c,searchValue:a,sortState:u,planFilters:h,productFilters:P,sort:S,planNextCursor:I,productNextCursor:j,runningCatalogItemActionId:w,onSearchChange:o,onTabChange:d,onSortChange:g})]})}const Wo=_((function(n,e){const t=kt(n,e.couponId);return{fieldHelp:t.fieldHelp,applyOnOptions:t.applyOnOptions,discountTypeOptions:t.discountTypeOptions,durationTypeOptions:t.durationTypeOptions,errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save coupon.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode,periodUnitOptions:t.periodUnitOptions}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,a=i!=null?"edit":"create",o=i!=null?`${t}/discounts/${encodeURIComponent(i)}`:`${t}/discounts`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCouponFormCancelled),n(G()),e.navigate(`${t}/discounts`)},onChange:c=>{n(li({id:i,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCouponSaved,{mode:a}),n(ri({id:i}))}}}))(fn);function Jo(){const n=D(),e=L(),{coupon_id:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),{fetchState:o,savedCouponId:c}=C((d=>kt(d,t)));return r.useEffect((()=>{a&&t!=null&&n(ci({id:t}))}),[a,t,n]),r.useEffect((()=>{if(o==="Completed"){const d=c??t,l=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(l),n(G())}}),[o,c,t,n,e,i]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCouponFormPage}),s.jsx(Wo,{couponId:t,navigate:e,tenantEmailDomain:i})]})}const Yo=_((function(n){const e=yt(n);return{fieldHelp:e.fieldHelp,customers:e.customers,planNames:e.planNames,errorMessage:e.fetchState==="Error"?e.error?.message??"Failed to create invoice. Please try again.":void 0,isSubmitting:e.fetchState==="In-Progress",localData:e.localData,settings:e.settings}}),(function(n){return{dispatch:n}}),(function(n,{dispatch:e},t){const i=`/${t.tenantEmailDomain}/invoicing`;return{...n,onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreateInvoiceCancelled),t.navigate(`${i}/invoices`)},onChange:a=>{e(bt(a))},onSubmit:()=>{const a=gi(n.localData);p.trackInvoicingActionClick(m.Event.invoicingInvoiceCreated,{customerId:a.customer_id,lineItemCount:a.line_items?.length}),e(mi(a))}}}))(hn);function Xo(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),[i]=W(),{areTenantIdsInSync:a}=T(),o=i.get("customerId"),c=C((I=>yt(I))),d=c.fetchState,l=c.localData,v=c.savedInvoiceId,u=C(xt),g=C((I=>di(I))),S=C(ue),f=g.fetchState==="Not-Started"||g.fetchState==="In-Progress"&&u==null,h=S.fetchState==="Not-Started"||S.fetchState==="In-Progress"&&S.customers.length===0,P=f||h,b=g.fetchState==="Completed"&&S.fetchState==="Completed";r.useEffect((()=>(n(Je()),()=>{n(Je())})),[n]);const k=r.useRef(!1);r.useEffect((()=>{k.current||o==null||o===""||l.customerId!==""||(k.current=!0,n(bt({...l,customerId:o})))}),[o,l,n]),r.useEffect((()=>{a&&n(ui({cacheOverride:!1}))}),[a,n]);const y=r.useRef(d);return r.useEffect((()=>{const I=y.current;if(y.current=d,I!=="Completed"&&d==="Completed"){const j=v!=null?`/${t}/invoicing/invoices/${encodeURIComponent(v)}`:`/${t}/invoicing/invoices`;e(j)}}),[d,v,e,t]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreateInvoicePage,isReady:b}),P?s.jsx(Sn,{}):s.jsx(Yo,{navigate:e,tenantEmailDomain:t})]})}const ea=_((function(n,e){const{detailView:t}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:t.creditNote,creditNoteId:e.creditNoteId,isLoading:t.fetchState==="Not-Started"||t.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${t}/credits`),onCustomerClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${t}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(i)}`)}}}))(In);function ta(){const n=D(),e=L(),{credit_note_id:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=C((d=>vi(d,t??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{a&&t!=null&&n(pi({id:t}))}),[a,t,n]),N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreditDetailPage,isReady:c}),s.jsx(ea,{navigate:e,tenantEmailDomain:i,creditNoteId:t??"",detailView:o})]})}const na=_((function(n){const e=jt(n),{fetchState:t}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",creditNotes:e.creditNotes,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.creditNotes.length===0,isLoadingMore:t==="In-Progress"&&e.creditNotes.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${t}/data_import`)},onCreditNoteClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${t}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&n(Si({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Cn);function ia(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,creditNoteListFetchState:b}=C((y=>{const I=jt(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,creditNoteListFetchState:I.fetchState}}),Z),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&n(Ye({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(Ye({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreditsListPage,isReady:k}),s.jsx(na,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onStatusChange:y=>n(fi(y)),onSortChange:v})]})}const Xt=(n,e,t)=>{const i=`/${n}/invoicing/customers/`;return t!=null?`${i}${encodeURIComponent(t)}/${e}/`:`${i}new/${e}/`},oa=_((function(n,e){const{editView:t,hasLoadedRecord:i}=e;return{fieldHelp:t.fieldHelp,billingAddressLabel:t.billingAddressLabel,customerTypeOptions:t.customerTypeOptions,netTermDayOptions:t.netTermDayOptions,taxabilityOptions:t.taxabilityOptions,customer:t.record.invoicingCustomer,invoices:t.record.invoices.slice(0,5),isLoading:!i&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),hasPaymentLinkEmailPreviewFailed:t.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:t.emailPreviewFetchState.fetchState==="In-Progress",isSaving:t.fetchState==="In-Progress",paymentLinkEmailPreview:t.emailPreview,isSendingPaymentLink:t.record.sendLinkState.fetchState==="In-Progress",localData:t.localData,paymentMethods:t.record.paymentMethods,sendPaymentLinkErrorMessage:t.record.sendLinkState.fetchState==="Error"?t.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:t.record.sendLinkState.fetchState==="Completed"?t.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:t.record.sendLinkState.fetchState==="Completed"?t.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:t.record.stripeConnected}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${t}/customers`),onChange:a=>{n(Ee({id:i,localData:a}))},onCreateInvoice:()=>e.navigate(`${t}/invoices/create`),onInvoiceClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(a)}`)},onCreatePromotionalCredits:()=>e.onCreatePromotionalCredits(),onNewSubscription:()=>e.navigate(`${t}/subscriptions/new`),onOpenAddress:()=>{const a=Xt(e.tenantEmailDomain??"",ke,i),o=Y(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${t}/settings/payment-destination`),onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerEdited,{customerId:i}),n(Ee({id:i,localData:a})),n(Dt({id:i}))},onFetchPaymentLinkEmailPreview:a=>n(xi({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,c)=>n(yi({body:c,customerId:i,email:a,subject:o})),onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(a)}`)}}}))(yn);function aa(){const n=D(),e=L(),t=J(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=T(),c=C((O=>we(O,i))),d=c.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(!1),[g,S]=r.useState(!1),[f,h]=r.useState(c.record.fetchState==="Completed"?i:void 0);r.useEffect((()=>{i!=null&&c.record.fetchState==="Completed"&&h(i)}),[i,c.record.fetchState]);const P=f===i,{plaidTokenFetchState:b,promotionalCreditSubmitState:k}=c,{paymentMethodSaveState:y,setupIntentFetchState:I,stripeConnected:j}=c.record,E=r.useRef(c.record.sendLinkState.fetchState);r.useEffect((()=>{const O=c.record.sendLinkState.fetchState;E.current!=="Error"&&O==="Error"&&n(hi({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),E.current=O}),[n,c.record.sendLinkState.fetchState]);const w=I.fetchState==="Error"?I.error?.message??"Failed to start card setup.":y.fetchState==="Error"?y.error?.message??"Failed to save payment method.":b.fetchState==="Error"?b.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(n(te()),n(ne()),()=>{n(te()),n(ne())})),[n]),r.useEffect((()=>{t.state?.openPromotionalCreditsDialog===!0&&(S(!0),e(t.pathname,{replace:!0,state:null}))}),[t.pathname,t.state,e]),r.useEffect((()=>{o&&i!=null&&n(Ii({id:i}))}),[o,i,n]),r.useEffect((()=>{o&&i!=null&&j&&n(Xe({customerId:i}))}),[o,i,n,j]);const[A,U]=r.useState(0);return r.useEffect((()=>{c.fetchState==="Completed"&&(n(Fe()),i!=null&&n(Pt({id:i})),U((O=>O+1)))}),[c.fetchState,n,i]),N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomerDetailPage,isReady:l}),s.jsx(oa,{customerId:i??"",editView:c,hasLoadedRecord:P,location:t,navigate:e,tenantEmailDomain:a,onAddPaymentMethod:()=>{n(te()),i!=null&&j&&n(Xe({customerId:i})),u(!0)},onCreatePromotionalCredits:()=>{n(ne()),S(!0)}},A),s.jsx(En,{errorMessage:w,isCreatingSetupIntent:I.fetchState==="In-Progress",isSaving:y.fetchState==="In-Progress",open:v,plaidLinkToken:c.record.plaidLinkToken,saveSucceeded:y.fetchState==="Completed",setupIntent:c.record.setupIntent,stripeConnected:j,onChooseCard:()=>{i!=null&&n(Ei({customerId:i}))},onClose:()=>{u(!1),n(te())},onSavePaymentMethod:O=>{i!=null&&n(Ci({customerId:i,data:O}))}}),s.jsx(kn,{currentBalance:c.record.invoicingCustomer?.promotionalCredits,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:k.fetchState==="Error"?k.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:k.fetchState==="In-Progress",open:g,submitSucceeded:k.fetchState==="Completed",onClose:()=>{S(!1),n(ne())},onSubmit:({amount:O,description:ee})=>{i!=null&&n(ki({amount:O,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:ee}))}})]})}const sa=_((function(n,e){const t=we(n,e.customerId);return{fieldHelp:t.fieldHelp,billingAddressLabel:t.billingAddressLabel,customerTypeOptions:t.customerTypeOptions,netTermDayOptions:t.netTermDayOptions,taxabilityOptions:t.taxabilityOptions,errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save customer.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,a=i!=null?"edit":"create",o=i!=null?`${t}/customers/${encodeURIComponent(i)}`:`${t}/customers`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerFormCancelled),n(Fe()),n(Re(ke)),e.navigate(`${t}/customers`)},onChange:c=>{n(Ee({id:i,localData:c}))},onOpenAddress:()=>{const c=Xt(e.tenantEmailDomain??"",ke,i),d=Y(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerSaved,{mode:a}),n(Dt({id:i}))}}}))(xn);function ca(){const n=D(),e=L(),t=J(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=T(),{fetchState:c,savedCustomerId:d}=C((l=>we(l,i)));return r.useEffect((()=>{o&&i!=null&&n(Pt({id:i}))}),[o,i,n]),r.useEffect((()=>{if(c==="Completed"){const l=d??i,v=l!=null?`/${a}/invoicing/customers/${encodeURIComponent(l)}`:`/${a}/invoicing/customers`;e(v),n(Fe())}}),[c,d,i,n,e,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomerFormPage}),s.jsx(sa,{customerId:i,location:t,navigate:e,tenantEmailDomain:a})]})}const ra=_((function(n){const e=ue(n),{fetchState:t}=e;return{addressesById:n.addressState.addressesById,columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",customers:e.customers,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.customers.length===0,isLoadingMore:t==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{p.trackInvoicingActionClick(m.Event.invoicingAddCustomerClicked),e.navigate(`${t}/customers/new`)},onCustomerClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${t}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${t}/data_import`)},onRowAction:(i,a)=>{switch(a){case"createInvoice":e.navigate(`${t}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":e.navigate(`${t}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":e.navigate(`${t}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&n(Te({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(bn);function la(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,customerListFetchState:b}=C((y=>{const I=ue(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,customerListFetchState:I.fetchState}}),Z),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&n(et({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(et({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomersListPage,isReady:k}),s.jsx(ra,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onStatusChange:y=>n(bi(y)),onSortChange:v})]})}const je=(n,e)=>e==null?void 0:n.sessionDetail[e]??n.sessions.find((t=>t.id===e)),da=_((function(n,e){const{filters:t,sessionId:i,view:a}=e,o=i==null?void 0:a.diagnosticsBySession[i],c=o?.fetch.fetchState??"Not-Started";return{diagnostics:o?.items??[],errorMessage:c==="Error"?o?.fetch.error?.message:void 0,expired:o?.expired??!1,filters:t,hasMore:o?.nextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress",isLoadingMore:c==="In-Progress"&&(o?.items.length??0)>0,session:je(a,i)}}),(function(n,e){const{downloadUrl:t,filters:i,navigate:a,sessionId:o,tenantEmailDomain:c,view:d}=e,l=o==null?void 0:d.diagnosticsBySession[o],v=je(d,o),u=d.actionStateByKind.retry?.fetchState==="In-Progress",g=d.actionStateByKind.rollback?.fetchState==="In-Progress",S=v?.status==="done"&&v.rollback_available_until!=null&&new Date(v.rollback_available_until).getTime()>Date.now()&&!g;return{onBack:()=>a(`/${c}/invoicing/data_import`),onDownloadCsv:()=>{t!=null&&window.open(t,"_blank","noopener")},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{o!=null&&l?.nextCursor!=null&&n(xe({...i,cursor:l.nextCursor,sessionId:o}))},onRetry:v?.status!=="failed"||u?void 0:()=>{o!=null&&n(_e(o))},onRollback:S?()=>{o!=null&&n(Lt(o))}:void 0}}))(jn);function ua(){const n=D(),e=L(),{sessionId:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),[o,c]=r.useState({}),d=C(Oe),l=je(d,t),v=t==null?void 0:d.diagnosticsBySession[t];r.useEffect((()=>{a&&t!=null&&n(ye(t))}),[a,n,t]),r.useEffect((()=>{if(!a||t==null)return;const f=setTimeout((()=>{n(xe({...o,sessionId:t}))}),300);return()=>clearTimeout(f)}),[a,n,o,t]);const u=l?.status==="scanning"||l?.status==="importing";r.useEffect((()=>{if(!a||t==null||!u)return;const f=setInterval((()=>{n(ye(t)),n(xe({...o,sessionId:t}))}),3e3);return()=>clearInterval(f)}),[a,n,o,u,t]);const g=r.useMemo((()=>{if(t==null)return;const f=new URLSearchParams;o.moduleId!=null&&f.set("module_id",o.moduleId),o.level!=null&&f.set("level",o.level),o.outcome!=null&&f.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&f.set("search",o.search.trim());const h=f.toString();return`${se?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(t)}/issues.csv${h===""?"":`?${h}`}`}),[o,t]),S=v?.fetch.fetchState??"Not-Started";return N(S)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:l!=null&&S!=="Not-Started"}),s.jsx(da,{downloadUrl:g,filters:o,navigate:e,sessionId:t,tenantEmailDomain:i,view:d,onFiltersChange:c})]})}const en=n=>`invoicing_active_migration:${n}`,ae=(n,e)=>{if(n!=null&&n!=="")try{const t=en(n);e==null?sessionStorage.removeItem(t):sessionStorage.setItem(t,e)}catch{}},ga=_((function(n,e){const{sessions:t,sessionsFetch:i,statusFetch:a,statusRows:o}=e.view;return{isLoading:!(a.fetchState!=="Not-Started"&&a.fetchState!=="In-Progress"||o.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:t,statusRows:o}}),(function(n,e){const{navigate:t,tenantEmailDomain:i}=e,a=o=>{const c=o??null;n(oe(c)),ae(i,c),t(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),a(o)},onNewImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingNewImportClicked),a()},onRetrySession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),n(_e(o)),a(o)},onRollbackSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),n(Lt(o))},onViewSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),t(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(Pn);function ma(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),a=C(Oe);r.useEffect((()=>{i&&(n(ji()),n(At()))}),[i,n]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:o}),s.jsx(ga,{navigate:e,tenantEmailDomain:t,view:a})]})}const va=_((function(n,e){const{activeId:t,integrationsView:i,settings:a,view:o}=e,{actionStateByKind:c,sessionDetail:d,sessions:l}=o,v=i.externalConnections?.revenue?.find((g=>g.connectionName==="chargebee")),u=t!=null?d[t]:void 0;return{chargebeeConnected:a?.chargebee_connected===!0||(v?.isValid??!1),chargebeeConnectorAvailable:v!=null,chargebeeSite:a?.chargebee_site,connectError:c.connect?.error?.message,connecting:c.connect?.fetchState==="In-Progress",retrying:c.retry?.fetchState==="In-Progress",session:u??l.find((g=>g.id===t)),starting:c.start?.fetchState==="In-Progress",uploading:c.upload?.fetchState==="In-Progress"}}),(function(n,e){const{activeId:t,navigate:i,tenantEmailDomain:a}=e;return{onBack:e.onBack,onDownloadTemplates:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportTemplatesDownloaded);const o=se?.invoicingMicroServiceBaseUrl,c=o!=null&&o.length>0?o:"";window.open(`${c}/1.0/data-import/templates`,"_blank","noopener")},onFetchFromChargebee:()=>{p.trackInvoicingActionClick(m.Event.invoicingChargebeeConnectClicked),n(Li())},onGoToIntegrations:()=>{i(`/${a}/invoicing/settings`)},onGoToOverview:()=>i(`/${a}/invoicing/overview`),onRetry:()=>{t!=null&&n(_e(t))},onSaveLater:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportStarted),t!=null&&n(Di(t))},onUpload:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportFileUploaded),n(Pi({files:o}))},onViewDetails:t==null?void 0:()=>i(`/${a}/invoicing/data_import/${encodeURIComponent(t)}`)}}))(Dn);function pa(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),a=C(xt),o=C(Me).companyId??Ie.getSignedInUserTenant(t??"")?.companyId,c=C((f=>$t(f,o))),d=C(Oe),{activeMigrationSessionId:l}=d,v=l??void 0,u=v!=null?d.sessionDetail[v]??d.sessions.find((f=>f.id===v)):void 0;r.useEffect((()=>{i&&(n(Ne()),n(At()))}),[i,n]),r.useEffect((()=>{if(l!=null)return;const f=(h=>{if(h==null||h==="")return null;try{return sessionStorage.getItem(en(h))}catch{return null}})(t);f!=null&&n(oe(f))}),[l,n,t]),r.useEffect((()=>{ae(t,l)}),[l,t]);const g=u?.status,S=g==="scanning"||g==="importing";return r.useEffect((()=>{if(!i||v==null||!S)return;const f=setInterval((()=>{n(ye(v))}),3e3);return()=>clearInterval(f)}),[i,v,S,n]),r.useEffect((()=>{g==="done"&&(n(oe(null)),ae(t,null))}),[n,g,t]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportMigratePage}),s.jsx(va,{activeId:v,integrationsView:c,navigate:e,settings:a,tenantEmailDomain:t,view:d,onBack:()=>{n(oe(null)),ae(t,null),e(`/${t}/invoicing/data_import`)}})]})}const fa=_((function(n,e){const{editView:t}=e;return{fieldHelp:t.fieldHelp,coupon:t.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,isLoading:!e.hasLoadedRecord&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:t.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${t}/discounts`),onLifecycleAction:a=>{n(wt({action:a,id:i}))},onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingCouponEdited,{couponId:i}),n($i({data:a,id:i}))}}}))(Ln);function Sa(){const n=D(),e=L(),{coupon_id:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=C((h=>Ai(h,t))),c=o.actionState.fetchState==="In-Progress",d=o.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(l?t:void 0);r.useEffect((()=>{t!=null&&l&&u(t)}),[t,l]);const g=v===t;r.useEffect((()=>(n(G()),()=>{n(G())})),[n]),r.useEffect((()=>{a&&n(tt({id:t}))}),[a,t,n]);const[S,f]=r.useState(0);return r.useEffect((()=>{o.fetchState==="Completed"&&(n(G()),n(tt({cacheOverride:!0,id:t})),f((h=>h+1)))}),[o.fetchState,n,t]),N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDiscountDetailPage,isReady:l}),s.jsx(fa,{hasLoadedRecord:g,couponId:t??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},S)]})}const ha=_((function(n){const e=Ft(n),{fetchState:t}=e;return{columns:e.columns,counts:e.count,discountLifecycleActionOptions:e.discountLifecycleActionOptions,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",coupons:e.coupons,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.coupons.length===0,isLoadingMore:t==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${t}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreateCouponClicked),e.navigate(`${t}/discounts/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${t}/data_import`)},onDiscountLifecycleAction:(i,a)=>{n(wt({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&n(Rt({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(An);function Ia(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,couponListFetchState:b,runningDiscountActionId:k}=C((I=>{const j=Ft(I);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:j.sort,nextCursor:j.nextCursor,couponListFetchState:j.fetchState,runningDiscountActionId:j.runningActionId??null}}),Z),y=b==="Completed";return r.useEffect((()=>{const I=setTimeout((()=>d(a)),300);return()=>clearTimeout(I)}),[a]),r.useEffect((()=>{i&&n(nt({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(nt({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDiscountsListPage,isReady:y}),s.jsx(ha,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,runningDiscountActionId:k,onSearchChange:o,onStatusChange:I=>n(wi(I)),onSortChange:v})]})}const Ca=_((function(n,e){const{readView:t}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:t.dunningCase,isLoading:t.fetchState==="Not-Started"||t.fetchState==="In-Progress",isRunningAction:t.actionState.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,a=i!=="";return{onBack:()=>e.navigate(`${t}/dunning`),onInvoiceClick:o=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(o)}`)},onCancel:a?()=>n(H({action:"cancel",id:i})):void 0,onResolve:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resolve",caseId:i}),n(H({action:"resolve",id:i}))}:void 0,onResume:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resume",caseId:i}),n(H({action:"resume",id:i}))}:void 0,onRetry:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"retry",caseId:i}),n(H({action:"retry",id:i}))}:void 0}}))(wn);function Ea(){const n=D(),e=L(),{case_id:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=C((E=>Fi(E,t??""))),c=o.fetchState==="Completed",d=o.dunningCase?.invoiceID,[l,v]=r.useState("idle"),[u,g]=r.useState(!1),[S,f]=r.useState(),[h,P]=r.useState(!1),b=r.useCallback((()=>{v("idle"),g(!1),f(void 0),P(!1)}),[]),k=r.useCallback((()=>{if(t==null)return;n(Ri({id:t})),v("idle"),g(!1);const E=o.emailPreview.preview;f(E==null?void 0:{body:E.body,cc:E.cc,subject:E.subject,to:E.to}),P(!0)}),[t,n,o.emailPreview.preview]),y=r.useCallback((E=>{t!=null&&l!=="pending"&&(g(!1),v("pending"),p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"send-email",caseId:t}),n(H({action:"send-email",body:E,id:t})))}),[t,n,l]),I=r.useMemo((()=>o.emailPreview.preview==null?void 0:{bodyToken:o.emailPreview.preview.bodyToken,renderedHtmlTemplate:o.emailPreview.preview.renderedHtmlTemplate,subjectToken:o.emailPreview.preview.subjectToken}),[o.emailPreview.preview]);r.useEffect((()=>{a&&t!=null&&n(Ti({id:t}))}),[a,t,n]),r.useEffect((()=>{a&&d!=null&&n(Ue({invoiceId:d}))}),[a,d,n]),r.useEffect((()=>{v("idle"),g(!1),f(void 0),P(!1)}),[t]),r.useEffect((()=>{a||(v("idle"),g(!1),f(void 0),P(!1))}),[a]),r.useEffect((()=>{h&&S==null&&o.emailPreview.preview!=null&&f({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,S,h]),r.useEffect((()=>{l==="pending"&&(o.actionState.fetchState!=="In-Progress"?u&&o.actionState.fetchState==="Completed"?(t!=null&&n(Oi({id:t})),b()):u&&o.actionState.fetchState==="Error"&&v("failed"):g(!0))}),[t,b,n,l,u,o.actionState.fetchState]);const j=d!=null&&o.linkedInvoice?.id===d?o.linkedInvoice.dunningAttempts:void 0;return N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDunningDetailPage,isReady:c}),s.jsx(Ca,{navigate:e,tenantEmailDomain:i,caseId:t??"",readView:o,dunningAttempts:j,onSendEmail:k}),s.jsx($n,{initialDraft:S,isPreviewLoading:o.emailPreview.fetchState==="Not-Started"||o.emailPreview.fetchState==="In-Progress",isSending:l==="pending",onClose:b,onSend:y,open:h,preview:I,previewErrorMessage:o.emailPreview.fetchState==="Error"?o.emailPreview.error?.message:void 0,sendErrorMessage:l==="failed"?o.actionState.error?.message:void 0})]})}const ka=_((function(n){const e=Tt(n),{fetchState:t}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:t==="In-Progress"&&e.dunningCases.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${t}/data_import`),onDunningCaseClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingDunningCaseRowClicked,{caseId:i}),e.navigate(`${t}/dunning/${encodeURIComponent(i)}`)},onRowAction:(i,a)=>{a!=="retry"&&a!=="resume"&&a!=="resolve"&&a!=="cancel"||n(H({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&n(Mi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Fn);function ya(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,dunningCaseListFetchState:b}=C((y=>{const I=Tt(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,dunningCaseListFetchState:I.fetchState}}),Z),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&n(it({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(it({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDunningListPage,isReady:k}),s.jsx(ka,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onStatusChange:y=>n(_i(y)),onSortChange:v})]})}const xa=_((function(n,e){const{view:t}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:t.billingAddress,invoice:t.invoice,invoiceId:e.invoiceId,shippingAddress:t.shippingAddress,isLoading:!e.hasLoadedRecord&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),isSaving:t.actionState.fetchState==="In-Progress",isVoiding:t.actionState.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e;return{onBack:()=>e.navigate(`${t}/invoices`),onCustomerClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${t}/customers/${encodeURIComponent(a)}`)},onIssueCreditNote:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteIssued,{invoiceId:i}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{p.trackInvoicingActionClick(m.Event.invoicingRecordPaymentClicked,{fromScreen:"invoice_detail",invoiceId:i}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceRegenerated,{invoiceId:i}),n(V({action:"regenerate",invoiceId:i}))},onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceEdited,{invoiceId:i}),n(Ui({data:{due_date:a.due_date!==""?a.due_date:void 0,notes:a.notes.trim()!==""?a.notes.split(`
|
|
2
|
-
`).map((o=>o.trim())).filter((o=>o!=="")).map((o=>({note:o}))):void 0,po_number:a.po_number!==""?a.po_number:null},invoiceId:i}))},onSendReminder:()=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceReminderSent,{invoiceId:i}),n(V({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(a)}`)},onVoid:a=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceVoided,{invoiceId:i}),n(V({action:"void",invoiceId:i,body:a}))}}}))(Rn);function ba(){const n=D(),e=L(),{invoice_id:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=C((g=>Ot(g,t??""))),c=o.pageFetchState.fetchState,d=c==="Completed",[l,v]=r.useState(d?t:void 0);r.useEffect((()=>{t!=null&&d&&v(t)}),[t,d]);const u=l===t;return r.useEffect((()=>{a&&t!=null&&n(Ni({invoiceId:t}))}),[a,t,n]),N(c)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingInvoiceDetailPage,isReady:d}),s.jsx(xa,{invoiceId:t??"",hasLoadedRecord:u,navigate:e,tenantEmailDomain:i,view:o})]})}const ja=_((function(n){const e=_t(n),{fetchState:t}=e;return{counts:e.counts,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,invoices:e.invoices,statusOptions:e.statusOptions,isLoading:t==="Not-Started"||t==="In-Progress"&&e.invoices.length===0,isLoadingMore:t==="In-Progress"&&e.invoices.length>0,kpis:e.kpis,kpisLoading:e.kpisFetchState.fetchState==="Not-Started"||e.kpisFetchState.fetchState==="In-Progress"&&e.kpis==null,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onCreateInvoice:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreateInvoiceClicked),e.navigate(`${t}/invoices/create`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"invoices"}),e.navigate(`${t}/data_import`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceRowClicked,{invoiceId:i}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}`)},onRowAction:(i,a)=>{switch(a){case"recordPayment":e.navigate(`${t}/invoices/${encodeURIComponent(i)}/record-payment`);break;case"issueCreditNote":e.navigate(`${t}/invoices/${encodeURIComponent(i)}/issue-credit-note`);break;case"sendReminder":n(V({action:"send-reminder",invoiceId:i}));break;case"regenerate":n(V({action:"regenerate",invoiceId:i}));break;case"void":n(V({action:"void",invoiceId:i}))}},onVoidInvoice:(i,a)=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceVoided,{invoiceId:i}),n(V({action:"void",invoiceId:i,body:a}))},onLoadMore:()=>{e.nextCursor!=null&&n(Mt({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Tn);function Pa(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,invoiceListFetchState:b,voidingInvoiceId:k}=C((I=>{const j=_t(I);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:I.invoicingInvoiceListState.sort,nextCursor:j.nextCursor,invoiceListFetchState:j.fetchState,voidingInvoiceId:j.runningActionId}}),Z),y=b==="Completed";return r.useEffect((()=>{const I=setTimeout((()=>d(a)),300);return()=>clearTimeout(I)}),[a]),r.useEffect((()=>{i&&n(pe({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(pe({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingInvoicesListPage,isReady:y}),s.jsx(ja,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,voidingInvoiceId:k,onSearchChange:o,onStatusChange:I=>{n(Bi(I)),n(pe({cacheOverride:!1,filters:g,sort:u}))},onSortChange:v})]})}function ut(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),i=On(),a=ft(),[o,c]=r.useState(!1),{acceptTermsState:d,status:l}=C(Nt),v=Vi(i?.loggedInUserRoleMap),u=`/${t}/invoicing`,g=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(Oo,{isAppContentDrawerOpen:o,handleDrawerToggle:g}),s.jsx(_n,{analytics:p,isAccepting:d.fetchState==="In-Progress",isReadOnlyUser:!v,meetingUrl:a("invoicing_promo"),onAcceptClick:()=>{n(Zi())},onBackClick:()=>{e(`/${t}`)},onClickMenuIcon:()=>{g(!0)}})]})}const Da=_((function(n,e){const t=Ut(n,e.invoiceId),{invoice:i,localData:a,reasonCodeOptions:o,submitState:c,typeOptions:d}=t;return{fieldHelp:t.fieldHelp,amountDue:i?.amountDue,currencyCode:i?.currencyCode??"USD",customerName:i?.customerName??"",errorMessage:c.fetchState==="Error"?c.error?.message??"Failed to issue credit note. Please try again.":void 0,invoiceNumber:i?.invoiceNumber??e.invoiceId,isSubmitting:c.fetchState==="In-Progress",localData:a,reasonCodeOptions:o,typeOptions:d}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing/invoices/${encodeURIComponent(e.invoiceId)}`,i=()=>e.navigate(t);return{onBack:i,onCancel:i,onChange:a=>{n(zi({localData:a}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteIssued,{invoiceId:e.invoiceId}),n(Qi())}}}))(Mn);function La(){const n=D(),e=L(),{invoice_id:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),{fetchState:o,invoice:c,isPageReady:d,issuedCreditNoteId:l,submitState:v}=C((f=>Ut(f,t??""))),u=`/${i}/invoicing`,g=r.useRef(null);r.useEffect((()=>{n(Hi()),g.current=null}),[n,t]),r.useEffect((()=>{a&&t!=null&&n(Ue({invoiceId:t}))}),[a,n,t]),r.useEffect((()=>{c!=null&&t!=null&&o==="Completed"&&g.current!==t&&(g.current=t,n(qi({localData:Ki(c)})))}),[n,o,c,t]);const S=r.useRef(v.fetchState);return r.useEffect((()=>{const f=S.current;S.current=v.fetchState,f!=="Completed"&&v.fetchState==="Completed"&&l!=null&&e(`${u}/credits/${encodeURIComponent(l)}`)}),[l,e,v.fetchState,u]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingInvoiceDetailPage,isReady:d}),s.jsx(Da,{invoiceId:t??"",navigate:e,tenantEmailDomain:i})]})}const Aa=_((function(n){return{invoicingOverview:Bt(n)}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{onRefresh:()=>{n(Vt(e.selectedPeriod,!0))},onSubscriptionClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionTileClicked,{subscriptionId:i}),e.navigate(`${t}/subscriptions/${i}`)},onViewInvoices:()=>{p.trackInvoicingActionClick(m.Event.invoicingViewInvoicesClicked),e.navigate(`${t}/invoices`)},onViewPayments:()=>{p.trackInvoicingActionClick(m.Event.invoicingViewPaymentsClicked),e.navigate(`${t}/payments`)}}}))(Nn);function $a(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a]=r.useState((()=>{const c=new Date;return{month:c.getMonth()+1,year:c.getFullYear()}})),o=C((c=>Bt(c).fetchState))==="Completed";return r.useEffect((()=>{i&&n(Vt(a))}),[i,n,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingOverviewPage,isReady:o}),s.jsx(Aa,{navigate:e,selectedPeriod:a,tenantEmailDomain:t})]})}const wa=_((function(n){const e=Zt(n),{fetchState:t}=e;return{columns:e.columns,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.transactions.length===0,isLoadingMore:t==="In-Progress"&&e.transactions.length>0,tabIds:e.tabIds,transactions:e.transactions}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeType:e.activeType,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTypeChange:e.onTypeChange,onViewTransactionCustomer:e.onViewTransactionCustomer,onViewTransactionInvoice:e.onViewTransactionInvoice,onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"payments"}),e.navigate(`${t}/data_import`)},onTransactionClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingPaymentRowClicked,{transactionId:i}),e.navigate(`${t}/payments/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&n(Wi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Un);function Fa(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeType:S,appliedSearch:f,appliedSort:h,nextCursor:P,transactionListFetchState:b,transactions:k}=C((w=>{const A=Zt(w);return{activeType:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,transactionListFetchState:A.fetchState,transactions:A.transactions}}),Z),y=b==="Completed",I=`/${t}/invoicing`,j=r.useCallback((w=>{const A=k.find((O=>O.id===w)),U=A?.linkedInvoices?.[0]?.invoiceID??A?.invoiceID;U!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"payments_list",invoiceId:U,toScreen:"invoice"}),e(`${I}/invoices/${encodeURIComponent(U)}`))}),[e,I,k]),E=r.useCallback((w=>{const A=k.find((U=>U.id===w))?.customerID;A!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:A,fromScreen:"payments_list",toScreen:"customer"}),e(`${I}/customers/${encodeURIComponent(A)}`))}),[e,I,k]);return r.useEffect((()=>{const w=setTimeout((()=>d(a)),300);return()=>clearTimeout(w)}),[a]),r.useEffect((()=>{i&&n(fe({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(fe({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingPaymentsListPage,isReady:y}),s.jsx(wa,{navigate:e,tenantEmailDomain:t,activeType:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onTypeChange:w=>{n(Gi(w)),n(fe({cacheOverride:!1,filters:g,sort:u}))},onSortChange:v,onViewTransactionCustomer:E,onViewTransactionInvoice:j})]})}const Ra=n=>{const e=[n.firstName,n.lastName].filter((t=>t!=null&&t.trim()!=="")).join(" ").trim();return(n.company!=null&&n.company.trim()!==""?n.company.trim():"")||e||(n.email!=null&&n.email.trim()!==""?n.email.trim():"")||n.id};function gt(){const n=D(),e=L(),{invoice_id:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=t!=null&&t!=="",c=C(ue),d=C((E=>Ji(E))),l=C(Yi),v=C((E=>Ot(E,t??""))),u=v.invoice,g=`/${i}/invoicing`,S=r.useRef(null),f=r.useRef("");r.useEffect((()=>{n(Xi()),S.current=null,f.current=""}),[n,t]),r.useEffect((()=>{a&&n(o&&t!=null?Ue({invoiceId:t}):Te({filters:{},keepExistingListItems:!1}))}),[a,n,t,o]),r.useEffect((()=>{o&&u!=null&&t!=null&&v.fetchState==="Completed"&&S.current!==t&&(S.current=t,n(eo({contextInvoiceId:t,localData:to(u)})))}),[n,u,t,v.fetchState,o]),r.useEffect((()=>{if(o)return;const E=d.localData.customerId;E!==""&&E!==f.current&&(f.current=E,n(Mt({filters:{customerId:E},keepExistingListItems:!1})),d.localData.invoiceToLink!==""&&n(ot({localData:{...d.localData,customerId:E,invoiceToLink:""}})))}),[n,d.localData,o]);const h=r.useRef(l.fetchState);r.useEffect((()=>{const E=h.current;if(h.current=l.fetchState,E!=="Completed"&&l.fetchState==="Completed"){if(l.recordedInvoiceId!=null)return void e(`${g}/invoices/${encodeURIComponent(l.recordedInvoiceId)}`);e(`${g}/payments`)}}),[e,l.fetchState,l.recordedInvoiceId,g]);const P=r.useMemo((()=>c.customers.map((E=>({id:E.id,name:Ra(E)})))),[c.customers]),b=C((E=>no(E,d.localData.customerId))),k=r.useMemo((()=>b.map((E=>{return{amountDue:(w=E.amountDue,A=io.currencySymbol,Vn("0,0.00",w,A)),amountDueValue:E.amountDue,id:E.id,label:E.invoiceNumber};var w,A}))),[b]),y=r.useMemo((()=>{if(!o||u==null)return;const E=u.currencyCode??"USD",w=u.amountDue?.amount??0;return{amountDue:De("0,0.00",u.amountDue),amountDueValue:w,currencyCode:E,customerName:u.customerName??u.customerID,invoiceId:u.id,invoiceNumber:u.invoiceNumber??u.id}}),[u,o]),I=o?`${g}/invoices/${encodeURIComponent(t??"")}`:`${g}/payments`,j=!o||v.fetchState==="Completed"&&d.localData.invoiceToLink!=="";return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingRecordPaymentPage,isReady:j}),s.jsx(Bn,{customers:P,fieldHelp:d.fieldHelp,errorMessage:l.fetchState==="Error"?l.error?.message??"Failed to record payment. Please try again.":void 0,gatewayOptions:d.gatewayOptions,invoiceContext:y,invoiceOptions:k,isSubmitting:l.fetchState==="In-Progress",localData:d.localData,mode:o?"invoice":"customer",paymentMethodOptions:d.paymentMethodOptions,onBack:()=>{e(I)},onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingRecordPaymentCancelled),e(I)},onChange:E=>{n(ot({localData:E}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingPaymentRecorded,{customerId:d.localData.customerId,invoiceId:o?t:d.localData.invoiceToLink,paymentMethod:d.localData.paymentMethod}),n(oo(o?t??void 0:void 0))}})]})}const tn=(n,e,t)=>{const i=`/${n}/invoicing/subscriptions/`;return t!=null?`${i}${encodeURIComponent(t)}/${e}/`:`${i}new/${e}/`},Ta=(n,e)=>{if(n==null)return;const t=De("0,0",n);return e!=null?`${t}/${e}`:t},nn=(n,e,t)=>{const i=[n,Ta(e,t)].filter((a=>a!=null&&a!=="")).join(" · ");return i!==""?i:void 0},mt=n=>n.priceCode!=null&&n.priceCode.trim()!=="",Oa=n=>({billingCycles:n.billingCycles,billingPeriod:n.period,billingPeriodUnit:n.periodUnit,label:n.name??n.id,subtitle:nn(n.productCode,n.price,n.periodUnit),value:n.priceCode}),_a=n=>({label:n.name??n.couponCode??n.id,value:n.couponCode??n.id}),Ma=_((function(n,e){const{editView:t}=e,i=t.subscription,a=i?.status,o=a!=null&&e.commercialEditAllowedFromStatuses.includes(a);return{cancelReasonCodeOptions:t.cancelReasonCodeOptions,fieldHelp:t.fieldHelp,addons:t.products.filter((c=>c.itemType==="addon")).filter(mt).map((c=>({label:c.name??c.id,subtitle:nn(c.productCode,c.price,c.periodUnit),value:c.priceCode}))),canEditCommercial:o,coupons:t.coupons.map(_a),isLoading:!e.hasLoadedRecord&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),isRunningAction:t.actionState.fetchState==="In-Progress",isSaving:t.fetchState==="In-Progress",lifecycleActionOptions:e.lifecycleActionOptions,localData:t.localData,plans:t.plans.filter(mt).map(Oa),shippingAddressLabel:t.shippingAddressLabel,subscription:i}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,a=i!=="",o=(c,d)=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionLifecycleAction,{action:c,subscriptionId:i}),n(qt({action:c,id:i,body:d}))};return{onBack:()=>e.navigate(`${t}/subscriptions`),onChange:c=>{n(re({id:i,localData:c}))},onChangeTermEnd:a?c=>{const d=c?.trim()??"";d!==""&&o("change_term_end",{term_ends_at:d})}:void 0,onCustomerClick:c=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:c,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${t}/customers/${encodeURIComponent(c)}`,"_blank","noopener,noreferrer")},onOpenAddress:()=>{const c=tn(e.tenantEmailDomain??"",be,i),d=Y(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onViewInvoices:()=>e.navigate(`${t}/invoices`),onSaveEdit:c=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionEdited,{subscriptionId:i}),n(re({id:i,localData:c})),n(Ht({id:i}))},onCancelSubscription:a?c=>{o("cancel",{cancel_reason_code:c.cancelReasonCode,end_of_term:!1,...c.cancelReason!=null&&c.cancelReason.trim()!==""?{cancel_reason:c.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:a?(c,d)=>{c!=="pause"?o(c):o(c,d!=null&&d.trim()!==""?{resume_date:d.trim()}:void 0)}:void 0}}))(Zn);function Na(){const n=D(),e=L(),t=J(),{subscription_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=T(),c=C((k=>Be(k,i))),{subscriptionCommercialEditAllowedFromStatuses:d,subscriptionLifecycleActionOptions:l,subscriptionMetadataEditAllowedFromStatuses:v}=c,u=c.pageFetchState.fetchState,g=u==="Completed",[S,f]=r.useState(g?i:void 0);r.useEffect((()=>{i!=null&&g&&f(i)}),[i,g]);const h=S===i;ge(o),r.useEffect((()=>{o&&i!=null&&n(at({id:i}))}),[o,i,n]);const[P,b]=r.useState(0);return r.useEffect((()=>{c.fetchState==="Completed"&&(n(Ve()),n(at({cacheOverride:!0,id:i})),b((k=>k+1)))}),[c.fetchState,n,i]),N(u)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSubscriptionDetailPage,isReady:g}),s.jsx(Ma,{hasLoadedRecord:h,commercialEditAllowedFromStatuses:d,editView:c,lifecycleActionOptions:l,location:t,metadataEditAllowedFromStatuses:v,navigate:e,subscriptionId:i??"",tenantEmailDomain:a},P)]})}const Ua=n=>{const e=[n.firstName,n.lastName].filter((t=>t!=null&&t.trim()!=="")).join(" ").trim();return(n.company!=null&&n.company.trim()!==""?n.company.trim():"")||e||(n.email!=null&&n.email.trim()!==""?n.email.trim():"")||n.id},Ba=(n,e)=>{if(n==null)return;const t=De("0,0",n);return e!=null?`${t}/${e}`:t},Pe=(n,e,t)=>{const i=[n,Ba(e,t)].filter((a=>a!=null&&a!=="")).join(" · ");return i!==""?i:void 0},Va=n=>({label:Ua(n),value:n.id}),he=n=>n.priceCode!=null&&n.priceCode.trim()!=="",Za=n=>({billingCycles:n.billingCycles,billingPeriod:n.period,billingPeriodUnit:n.periodUnit,label:n.name??n.id,subtitle:Pe(n.productCode,n.price,n.periodUnit),trialPeriod:n.trialPeriod,trialPeriodUnit:n.trialPeriodUnit,value:n.priceCode}),Ha=n=>({label:n.name??n.couponCode??n.id,value:n.couponCode??n.id}),qa=_((function(n,e){const t=Be(n,e.subscriptionId);return{fieldHelp:t.fieldHelp,addons:t.products.filter((i=>i.itemType==="addon")).filter(he).map((i=>({label:i.name??i.id,subtitle:Pe(i.productCode,i.price,i.periodUnit),value:i.priceCode}))),charges:t.products.filter((i=>i.itemType==="charge")).filter(he).map((i=>({label:i.name??i.id,subtitle:Pe(i.productCode,i.price,void 0),value:i.priceCode}))),coupons:t.coupons.map(Ha),customers:t.customers.map(Va),errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save subscription.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode,plans:t.plans.filter(he).map(Za),shippingAddressLabel:t.shippingAddressLabel}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,a=i!=null?"edit":"create";return{onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionFormCancelled),n(Ve()),n(Re(be)),i==null?e.navigate(`${t}/subscriptions`):e.navigate(`${t}/subscriptions/${encodeURIComponent(i)}`)},onChange:o=>{n(re({id:i,localData:o}))},onOpenAddress:()=>{const o=tn(e.tenantEmailDomain??"",be,i),c=Y(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(o,{state:{pathnameStackToGoBack:c}})},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionSaved,{mode:a}),n(Ht({id:i}))}}}))(Hn);function Ka(){const n=D(),e=L(),t=J(),{subscription_id:i,tenantEmailDomain:a}=R(),[o]=W(),{areTenantIdsInSync:c}=T(),d=o.get("customerId"),{fetchState:l,savedSubscriptionId:v}=C((S=>ao(S,i))),u=C((S=>Be(S,i).localData));ge(c),r.useEffect((()=>{c&&(n(Te({filters:{},keepExistingListItems:!1})),n(Ce({filters:{type:"plan"},keepExistingListItems:!1})),n(Rt({filters:{},keepExistingListItems:!1})),i!=null&&n(so({id:i})))}),[c,i,n]);const g=r.useRef(!1);return r.useEffect((()=>{g.current||i!=null||d==null||d===""||u.customerId!==""||(g.current=!0,n(re({id:i,localData:{...u,customerId:d}})))}),[d,i,u,n]),r.useEffect((()=>{if(l==="Completed"){const S=v??i,f=S!=null?`/${a}/invoicing/subscriptions/${encodeURIComponent(S)}`:`/${a}/invoicing/subscriptions`;e(f),n(Ve())}}),[l,v,i,n,e,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSubscriptionFormPage}),s.jsx(qa,{location:t,navigate:e,subscriptionId:i,tenantEmailDomain:a})]})}const Qa=_((function(n){const e=Kt(n),{fetchState:t}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.subscriptions.length===0,isLoadingMore:t==="In-Progress"&&e.subscriptions.length>0,cancelReasonCodeOptions:e.cancelReasonCodeOptions,lifecycleActionOptions:e.subscriptionLifecycleActionOptions,subscriptions:e.subscriptions,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,i=(a,o,c)=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionLifecycleAction,{action:o,subscriptionId:a}),n(qt({action:o,id:a,body:c}))};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onAddSubscription:()=>{p.trackInvoicingActionClick(m.Event.invoicingAddSubscriptionClicked),e.navigate(`${t}/subscriptions/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"subscriptions"}),e.navigate(`${t}/data_import`)},onChangeTermEnd:(a,o)=>{const c=o?.trim()??"";c!==""&&i(a,"change_term_end",{term_ends_at:c})},onSubscriptionAction:(a,o,c)=>{o!=="pause"?i(a,o):i(a,o,c!=null&&c.trim()!==""?{resume_date:c.trim()}:void 0)},onCancelSubscription:(a,o)=>{i(a,"cancel",{cancel_reason_code:o.cancelReasonCode,end_of_term:!1,...o.cancelReason!=null&&o.cancelReason.trim()!==""?{cancel_reason:o.cancelReason.trim()}:{}})},onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionRowClicked,{subscriptionId:a}),e.navigate(`${t}/subscriptions/${encodeURIComponent(a)}`)},onViewSubscriptionInvoices:()=>{e.navigate(`${t}/invoices`)},onLoadMore:()=>{e.nextCursor!=null&&n(lo({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(qn);function za(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,subscriptionListFetchState:b,runningActionSubscriptionId:k}=C((j=>{const E=Kt(j);return{activeStatus:E.activeTab,appliedSearch:E.filters.search,appliedSort:E.sort,nextCursor:E.nextCursor,subscriptionListFetchState:E.fetchState,runningActionSubscriptionId:E.runningActionId??null}}),Z),y=b==="Completed";r.useEffect((()=>{const j=setTimeout((()=>d(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&n(st({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(st({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]);const I=r.useRef(k);return r.useEffect((()=>{const j=I.current!=null&&k==null;I.current=k,j&&i&&n(co())}),[k,i,n]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSubscriptionsListPage,isReady:y}),s.jsx(Qa,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,runningActionSubscriptionId:k,onSearchChange:o,onStatusChange:j=>n(ro(j)),onSortChange:v})]})}const Ga=_((function(n,e){const{readView:t}=e;return{isLoading:t.fetchState==="Not-Started"||t.fetchState==="In-Progress",isRunningAction:t.actionState.fetchState==="In-Progress",transaction:t.transaction,transactionId:e.transactionId}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{transactionId:i}=e;return{onBack:()=>e.navigate(`${t}/payments`),onCustomerClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"transaction_detail",toScreen:"customer"}),e.navigate(`${t}/customers/${encodeURIComponent(a)}`)},onInvoiceClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(a)}`)},onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(a)}`)},onCapture:i!==""?()=>{p.trackInvoicingActionClick(m.Event.invoicingTransactionCaptured,{transactionId:i}),n(mo({action:"capture",id:i}))}:void 0}}))(Kn);function Wa(){const n=D(),e=L(),{tenantEmailDomain:t,transaction_id:i}=R(),{areTenantIdsInSync:a}=T(),o=C((d=>uo(d,i??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{a&&i!=null&&n(go({id:i}))}),[a,i,n]),N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingTransactionDetailPage,isReady:c}),s.jsx(Ga,{navigate:e,tenantEmailDomain:t,transactionId:i??"",readView:o})]})}const Ja={branding:"invoicing_branding_save",dunning:"invoicing_dunning_settings_save",quickbooks:"invoicing_qbo_settings_save"};function X(n){const e=D(),{areTenantIdsInSync:t}=T(),{tenantEmailDomain:i}=R(),{fetchState:a,fieldHelp:o,logoFile:c,saveState:d,settings:l,stripeConnectState:v}=C(vo),{configError:u,configFetchState:g,dunningScheduleActionOptions:S,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:h,qboSyncStatusOptions:P}=C(Qt),b=C($e);Ze({enabled:n==="quickbooks",fetchSyncHealth:!0,loadAccountingPickers:!0});const k=C(Me),y=n==="dunning"||n==="quickbooks",I=k.companyId??Ie.getSignedInUserTenant(i??"")?.companyId,j=C((F=>$t(F,I))),E=po(k.userRole??[]),w=k.tenantId??"",A=Ie.getSignedInUser(),U={userId:A?.userId??"",sessionId:A?.zeniSessionId??"",tenantId:w},O=c?.fileId,ee=C((F=>O!=null&&O!==""?fo(F,O):void 0)),He=C((F=>O!=null&&O!==""?So(F,O):void 0)),on=O!=null&&O!==""&&ee!=null?{[O]:ee}:{},an=O!=null&&O!==""&&He!=null?{[O]:He}:{};r.useEffect((()=>(e(ct()),()=>{e(ct())})),[e]),r.useEffect((()=>{t&&(a!=="Not-Started"&&a!=="Error"||e(Ne()))}),[t,e,a]),r.useEffect((()=>{t&&y&&g==="Not-Started"&&e(le())}),[t,e,g,y]),r.useEffect((()=>{if(!t)return;const F=A?.userId;F!=null&&F!==""&&w!==""&&Qe.shouldFetchActiveTenant(w)&&(Qe.markActiveTenantFetchStarted(w),e(ho(F,w,A?.zeniSessionId)))}),[t,e,A?.userId,A?.zeniSessionId,w]);const sn=S.length>0||f.length>0,cn=a==="Not-Started"||a==="In-Progress"&&l==null||y&&!sn&&(g==="Not-Started"||g==="In-Progress"),rn=a==="Completed"&&(!y||g==="Completed"),qe=j.externalConnections?.revenue?.find((F=>F.connectionName==="chargebee"))?.connectionId,me=se?.invoicingMicroServiceBaseUrl,Ke=me!=null&&me.length>0?`${me}/1.0/webhooks/stripe`:"",ve={deleteConnectionError:j.externalConnections?.deleteConnectionError?.message,deleteConnectionState:j.externalConnections?.deleteConnectionState??"Not-Started",integrationsView:j,isAdmin:E,isStripeBusy:v.fetchState==="In-Progress",onConnectStripe:F=>e(lt(F)),onDisconnect:(F,q)=>{w!==""&&e(bo(w,F,dt(q)))},onDisconnectStripe:()=>e(rt()),onReconnectQBO:()=>{const F=k.tenantEmailDomain??i??"";de.init("/connection/auth",F),de.handleClick()},onRefreshQBO:()=>{j.integrations.refreshQBO.fetchState!=="In-Progress"&&e(Wt())},onSaveChargeBeeCredentials:(F,q)=>{qe!=null&&w!==""&&e(yo(w,qe,dt("revenue"),xo("chargebee"),{api_key:F,site:q}))},saveChargeBeeError:j.externalConnections?.saveAPIKeyConnectionError?.message,saveChargeBeeState:j.externalConnections?.saveAPIKeyConnectionState??"Not-Started",settings:l,stripeError:v.fetchState==="Error"?v.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Ke};return{authParams:U,deleteFileStatusById:on,fieldHelp:o,dunningScheduleActionOptions:S,filesEndPoint:se?.fileMicroServiceBaseUrl??"",integrationsSectionProps:ve,isInvoicingPageReady:rn,isLoading:cn,isSaving:d.fetchState==="In-Progress",isStripeBusy:v.fetchState==="In-Progress",logoFile:c,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:h,qboSyncStatusOptions:P,qboView:b,saveErrorMessage:d.fetchState==="Error"?d.error?.message??"Failed to save settings.":y&&g==="Error"?u?.message??"Failed to load invoicing configuration.":void 0,settings:l,stripeError:v.fetchState==="Error"?v.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Ke,updateFileStatusById:an,onConnectStripe:F=>e(lt(F)),onDeleteFile:F=>e(ko(F,w)),onDisconnectStripe:()=>e(rt()),onEditFileName:(F,q)=>e(Eo(F,q,w)),onReconnectQBO:ve.onReconnectQBO,onRefreshQBO:ve.onRefreshQBO,onRetryQboSyncTask:F=>e(Gt(F)),onSave:F=>{p.trackInvoicingActionClick(m.Event.invoicingSettingsSaved,{tab:n??"hub"}),e(Co({settings:F,snackbarSection:Ja[n??""]}))},onStartQboBackfill:F=>e(zt(F)),updateFilesEntity:F=>{p.trackInvoicingActionClick(m.Event.invoicingLogoUploaded),e(Io({files:F}))}}}function vt({appContent:n}){const e=L(),t=J(),i=D(),{tenantEmailDomain:a}=R(),o=X("branding"),c=C((v=>jo(v))),d=C((v=>Po(Se,v)?.addressToCreate));r.useEffect((()=>{c.saveState.fetchState==="Completed"&&(i(Do()),i(Re(Se)))}),[c.saveState.fetchState,i]);const l=St(c.saveState.fetchState);return r.useEffect((()=>{l==="In-Progress"&&c.saveState.fetchState==="Completed"&&e("..")}),[l,c.saveState.fetchState,e]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),s.jsx(Qn,{address:d,fieldHelp:c.fieldHelp,addressLabel:c.addressLabel,appContent:n,authParams:o.authParams,dateFormatOptions:c.dateFormatOptions,deleteFileStatusById:o.deleteFileStatusById,filesEndPoint:o.filesEndPoint,isLoading:o.isLoading,isSaving:o.isSaving,localData:c.localData,saveErrorMessage:o.saveErrorMessage,settings:o.settings,updateFileStatusById:o.updateFileStatusById,onBackClick:()=>e(".."),onChange:v=>{i(Ao({localData:v}))},onDeleteFile:o.onDeleteFile,onEditFileName:o.onEditFileName,onOpenAddress:()=>{const v=`/${a}/invoicing/settings/branding/${Se}/`,u=Y(t.state?.pathnameStackToGoBack,t.pathname);e(v,{state:{pathnameStackToGoBack:u}})},onSubmit:()=>i(Lo()),updateFilesEntity:o.updateFilesEntity})]})}function Ya(){const n=L(),e=X("dunning");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(zn,{dunningScheduleActionOptions:e.dunningScheduleActionOptions,isLoading:e.isLoading,isSaving:e.isSaving,saveErrorMessage:e.saveErrorMessage,settings:e.settings,onBackClick:()=>n(".."),onSave:e.onSave})]})}function Xa(){const n=L(),e=X("integrations");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Gn,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>n("../quickbooks"),onOpenPaymentDestination:()=>n("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>n("..")})]})}function es(){const n=L(),e=X("payment-destination");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Wn,{fieldHelp:e.fieldHelp,isLoading:e.isLoading,isStripeBusy:e.isStripeBusy,saveErrorMessage:e.saveErrorMessage,settings:e.settings,stripeError:e.stripeError,stripeWebhookUrl:e.stripeWebhookUrl,onBackClick:()=>n(".."),onConnectStripe:e.onConnectStripe})]})}const ts=_((function(n){const e=Jt(n);return{accountMappingKindOptions:e.accountMappingKindOptions,fieldHelp:e.fieldHelp,accounts:e.accounts,connection:e.connection,customerMatchingOptions:e.customerMatchingOptions,isBackfilling:e.backfillState.fetchState==="In-Progress",isLoading:e.isLoading,isSaving:e.saveState.fetchState==="In-Progress",isSyncEnabledSaved:e.isSyncEnabledSaved,localData:e.localData,nestedAccountHierarchy:e.nestedAccountHierarchy,retryFetchStateByTaskId:e.retryFetchStateByTaskId,saveErrorMessage:e.saveState.fetchState==="Error"?e.saveState.error?.message:void 0,syncHealth:e.syncHealth,syncStatusOptions:e.syncStatusOptions}}),(function(n){return{onChange:e=>{n(Fo({localData:e}))},onReset:()=>{n(wo())},onRetryTask:e=>{n(Gt(e))},onSave:()=>{p.trackInvoicingActionClick(m.Event.invoicingSettingsSaved,{tab:"quickbooks"}),n($o())},onStartBackfill:e=>{n(zt(e))}}}))(Jn);function ns(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),i=C(Me),{configFetchState:a,settingsFetchState:o}=C(Jt);return r.useEffect((()=>{o!=="Not-Started"&&o!=="Error"||n(Ne())}),[n,o]),r.useEffect((()=>{a==="Not-Started"&&n(le())}),[a,n]),Ze({fetchSyncHealth:!0,loadAccountingPickers:!0}),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage}),s.jsx(ts,{onBackClick:()=>e(".."),onReconnect:()=>{de.init("/connection/auth",i.tenantEmailDomain??t??""),de.handleClick()},onRefresh:()=>n(Wt())})]})}const is={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function os(){const n=ft(),e=D(),t=L(),[i,a]=W(),o=X(),{canEnableInvoicing:c,isEnablingInvoicing:d,isInvoicingEnabled:l,isQboConfigured:v,isStripeConnected:u}=C(Qt),g=i.get("tab");return r.useEffect((()=>{if(g==null)return;const S=is[g];a({},{replace:!0}),S!=null&&t(S,{replace:!0})}),[g,t,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),s.jsx(Yn,{analytics:p,integrationsSectionProps:{...o.integrationsSectionProps,onConfigureQBO:()=>t("quickbooks"),onOpenPaymentDestination:()=>t("payment-destination")},isEnablingInvoicing:d,isLoading:o.isLoading,meetingUrl:n("invoicing_settings"),settings:o.settings,onBrandingClick:()=>t("branding"),onDunningClick:()=>t("dunning"),canEnableInvoicing:c,isQboConfigured:v,isStripePaymentsReady:u,onEnableInvoicingClick:l?void 0:()=>{e(Ro())}})]})}function pt(){return s.jsxs(ie,{children:[s.jsx(x,{index:!0,element:s.jsx(os,{})}),s.jsx(x,{path:"payment-destination",element:s.jsx(es,{})}),s.jsx(x,{path:"branding",element:s.jsx(vt,{})}),s.jsx(x,{path:"branding/:addressType",element:s.jsx(vt,{appContent:s.jsx(K,{isSubPage:!0,hideAddressBackButton:!0})})}),s.jsx(x,{path:"integrations",element:s.jsx(Xa,{})}),s.jsx(x,{path:"dunning",element:s.jsx(Ya,{})}),s.jsx(x,{path:"quickbooks",element:s.jsx(ns,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:"..",replace:!0})})]})}function ws(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),{enableState:a,fetchState:o,status:c}=C(Nt),d=St(a.fetchState),l=`/${t}/invoicing`,v=r.useRef(!1),u=C((g=>$e(g).connectionFetchState.fetchState));return r.useEffect((()=>{i&&(o!=="Not-Started"?o!=="Error"||v.current||(v.current=!0,n(le({cacheOverride:!1}))):n(le({cacheOverride:!1})))}),[i,n,o]),r.useEffect((()=>{i&&u==="Not-Started"&&n(Et())}),[i,n,u]),r.useEffect((()=>{d==="In-Progress"&&a.fetchState==="Completed"&&(e(`${l}/catalog`),n(To()))}),[d,a.fetchState,l,n,e]),c==null&&o!=="Error"?s.jsx(Xn,{fetchState:"In-Progress"}):c==="not_started"?s.jsxs(ie,{children:[s.jsx(x,{path:"promo",element:s.jsx(ut,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:`${l}/promo`,replace:!0})})]}):c==="settings"?s.jsxs(ie,{children:[s.jsx(x,{path:"promo",element:s.jsx(ut,{})}),s.jsx(x,{path:"settings/*",element:s.jsx(pt,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:`${l}/settings`,replace:!0})})]}):s.jsxs(ie,{children:[s.jsx(x,{path:"/",element:s.jsx(B,{to:"overview",replace:!0})}),s.jsx(x,{path:"overview",element:s.jsx($a,{})}),s.jsx(x,{path:"promo",element:s.jsx(B,{to:`${l}/overview`,replace:!0})}),s.jsx(x,{path:"customers",element:s.jsx(la,{})}),s.jsx(x,{path:"customers/new",element:s.jsx(ca,{})}),s.jsx(x,{path:"customers/new/:addressType",element:s.jsx(K,{})}),s.jsx(x,{path:"customers/:customer_id",element:s.jsx(aa,{})}),s.jsx(x,{path:"customers/:customer_id/:addressType",element:s.jsx(K,{})}),s.jsx(x,{path:"subscriptions",element:s.jsx(za,{})}),s.jsx(x,{path:"subscriptions/new",element:s.jsx(Ka,{})}),s.jsx(x,{path:"subscriptions/new/:addressType",element:s.jsx(K,{})}),s.jsx(x,{path:"subscriptions/:subscription_id",element:s.jsx(Na,{})}),s.jsx(x,{path:"subscriptions/:subscription_id/:addressType",element:s.jsx(K,{})}),s.jsx(x,{path:"invoices",element:s.jsx(Pa,{})}),s.jsx(x,{path:"invoices/create",element:s.jsx(Xo,{})}),s.jsx(x,{path:"invoices/:invoice_id",element:s.jsx(ba,{})}),s.jsx(x,{path:"invoices/:invoice_id/record-payment",element:s.jsx(gt,{})}),s.jsx(x,{path:"invoices/:invoice_id/issue-credit-note",element:s.jsx(La,{})}),s.jsx(x,{path:"payments",element:s.jsx(Fa,{})}),s.jsx(x,{path:"payments/record",element:s.jsx(gt,{})}),s.jsx(x,{path:"payments/:transaction_id",element:s.jsx(Wa,{})}),s.jsx(x,{path:"credits",element:s.jsx(ia,{})}),s.jsx(x,{path:"credits/:credit_note_id",element:s.jsx(ta,{})}),s.jsx(x,{path:"discounts",element:s.jsx(Ia,{})}),s.jsx(x,{path:"discounts/new",element:s.jsx(Jo,{})}),s.jsx(x,{path:"discounts/:coupon_id",element:s.jsx(Sa,{})}),s.jsx(x,{path:"dunning",element:s.jsx(ya,{})}),s.jsx(x,{path:"dunning/:case_id",element:s.jsx(Ea,{})}),s.jsx(x,{path:"catalog",element:s.jsx(Go,{})}),s.jsx(x,{path:"catalog/new",element:s.jsx(Ko,{})}),s.jsx(x,{path:"catalog/:item_id",element:s.jsx(Vo,{})}),s.jsx(x,{path:"settings/*",element:s.jsx(pt,{})}),s.jsx(x,{path:"audit_log",element:s.jsx(_o,{})}),s.jsx(x,{path:"data_import",element:s.jsx(ma,{})}),s.jsx(x,{path:"data_import/migrate",element:s.jsx(pa,{})}),s.jsx(x,{path:"data_import/:sessionId",element:s.jsx(ua,{})}),s.jsx(x,{path:"*",element:s.jsx(M,{})})]})}export{ws as default};
|
|
1
|
+
import{j as s}from"./liveblocks-DRsJ0YIJ.js";import{a as r}from"./sentry-G4ZANa8Z.js";import{u as D,h as L,i as F,j as C,t as W,l as O,s as H,g as J,N as B,n as ie,o as x}from"./core-DGLzDXWl.js";import{a8 as ln,k as p,aq as T,T as m,cb as dn,cc as un,cd as gn,ce as mn,cf as vn,cg as pn,ch as fn,ci as Sn,cj as hn,ck as In,cl as Cn,cm as En,cn as kn,co as yn,p as X,cp as xn,cq as bn,ae as se,cr as jn,cs as Pn,z as Ie,ct as Dn,cu as Ln,cv as An,cw as $n,cx as wn,cy as Rn,cz as Fn,cA as Tn,U as _n,ai as ft,cB as On,cC as Mn,cD as Nn,cE as Un,cF as De,cG as Bn,cH as Vn,cI as Hn,cJ as Zn,cK as qn,cL as zn,t as Ke,j as St,cM as Kn,cN as Qn,cO as Gn,cP as Wn,cQ as Jn,cR as Xn,cS as Yn}from"./index-DGjciFPC.js";import"./mui-BuJ3P0FU.js";import{A as z}from"./AddressScreen-C1CfOA8k.js";import M from"./NotFoundScreen-3YmbDG-O.js";import{Zy as ei,Zz as ti,vk as Qe,ZA as K,vN as ce,ZB as Le,ZC as Q,wo as Ge,wv as ni,wA as ht,ZD as Ae,ZE as It,ws as Ct,ZF as $e,wq as Et,z4 as ii,wr as oi,wk as ai,xX as We,vM as Ce,ZG as si,ZH as kt,wH as ci,ZI as G,wO as ri,ZJ as li,ZK as yt,ZL as xt,yS as di,ZM as ue,ZN as Je,ZO as bt,vK as ui,ZP as gi,vE as mi,ZQ as vi,y8 as pi,ZR as jt,yh as Xe,ZS as fi,ye as Si,ZT as we,gg as hi,ZU as te,ZV as ne,x1 as Ii,vS as Ye,ZW as Re,vX as Pt,vV as Ci,vP as Ei,wW as ki,vZ as yi,x3 as xi,ZX as Ee,xa as Dt,x8 as ke,FV as Fe,yn as et,ZY as bi,vL as Te,ZZ as _e,w6 as ye,w3 as xe,wg as Lt,wf as Oe,w0 as ji,w9 as At,wi as oe,fE as Me,Vl as $t,vO as Ne,wd as Pi,we as Di,wc as Li,Z_ as Ai,wK as tt,wP as $i,wL as wt,Z$ as Rt,vy as nt,_0 as wi,vu as Ft,_1 as Ri,yt as Fi,yx as Z,ys as Ti,xB as Ue,_2 as _i,_3 as Tt,yG as it,_4 as Oi,yD as Mi,_5 as _t,xE as Ni,xF as V,xI as Ui,_6 as Ot,xS as pe,_7 as Bi,x2 as Mt,TT as Nt,_8 as Vi,y0 as Hi,_9 as Ut,_a as Zi,_b as qi,_c as zi,zv as Ki,_d as Qi,_e as Bt,yN as Vt,_f as Ht,zt as fe,_g as Gi,zq as Wi,_h as Ji,_i as Xi,_j as Yi,_k as eo,_l as to,_m as ot,_n as no,ef as io,zz as oo,_o as Be,xk as at,_p as Ve,_q as re,xu as Zt,xp as qt,xn as be,_r as ao,xf as so,yT as zt,zi as st,zd as co,_s as ro,yU as lo,_t as uo,zj as go,zn as mo,_u as vo,_v as Kt,c8 as po,mr as fo,ms as So,_w as ct,wp as le,gk as ho,my as Io,za as Qt,zL as Co,z7 as Gt,uS as Eo,zI as rt,uG as ko,zF as lt,hR as yo,Uk as dt,Ul as xo,G5 as Wt,hJ as bo,_x as jo,Va as Po,_y as Do,zR as Se,zS as Lo,_z as Ao,_A as Jt,zO as $o,_B as wo,_C as Ro,y4 as Fo,_D as To}from"./zeni-epic-state-Dm2vDWXH.js";import{M as _o}from"./MobileAppDrawer-Q8q8ssn0.js";import{q as de}from"./QBOConnectionScreen-DX5rBjLM.js";import"./recharts-CJlXFxhv.js";import"./analytics-CvsRIk3B.js";import"./plaid-i7y7YD6O.js";import"./dnd-SnD389s6.js";import"./stripe-cKAAJElX.js";import"./lottie-DEqUWUd5.js";import"./lexical-CMBMntF_.js";import"./pdf-B_v4zyN7.js";import"./utils-Bz8wuSWM.js";import"./InboxNotificationsProvider-Cf5DQSg3.js";import"./useTaskManagerAccess-i7vk79Wr.js";import"./empty-BjVnPUF5.js";import"./pdf-lib-DxbyphS9.js";import"./index-B2CKeHlo.js";import"./url-CtF92dYM.js";import"./index-CQFc7TiS.js";import"./decodeURIComponentSafe-k3ZAUeWI.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new n.Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="57865649-34de-46ce-8c86-f4038a798f3f",n._sentryDebugIdIdentifier="sentry-dbid-57865649-34de-46ce-8c86-f4038a798f3f")}catch{}})();const $=({event:n,isReady:e=!0})=>e?s.jsx(ln,{analytics:p,onLoad:t=>t.trackPageLoaded(n)}):null;function N(...n){return n.some((e=>e==="Error"))}function Oo(){const n=D(),e=L(),{tenantEmailDomain:t}=F(),{areTenantIdsInSync:i}=T(),[a,o]=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:g,hasMore:S,items:f,nextCursor:h,auditLogEntityRouteOptions:P,auditLogListSortFieldOptions:b}=C(ei),k=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),y=`/${t??""}/invoicing`,I=r.useCallback(((A,U)=>{const _=ti(y,A,U,P);_!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{entity:A,entityId:U,fromScreen:"audit_log"}),e(_))}),[P,e,y]);r.useEffect((()=>{const A=setTimeout((()=>d(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&n(Qe({filters:k,keepExistingListItems:!1,sort:u}))}),[i,k,u,n]);const j=g==="Not-Started"||g==="In-Progress"&&f.length===0,E=g==="In-Progress"&&f.length>0,w=g==="Completed";return N(g)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingAuditLogPage,isReady:w}),s.jsx(dn,{auditLogEntityRouteOptions:P,auditLogListSortFieldOptions:b,entries:f,hasMore:S,isLoading:j,isLoadingMore:E,searchValue:a,sortState:l,onEntityLinkClick:I,onLoadMore:()=>{S&&h!=null&&n(Qe({cursor:h,filters:k,keepExistingListItems:!0,sort:u}))},onSearchChange:o,onSortChange:v})]})}function ge(n,e=!1){const t=D(),i=C((c=>K(c).productNextCursor!=null)),a=C((c=>K(c).productNextCursor)),o=C((c=>K(c).productFetchState.fetchState));r.useEffect((()=>{n&&(e&&o!=="Not-Started"||t(ce({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[n,t,e]),r.useEffect((()=>{n&&o!=="In-Progress"&&i&&a!=null&&t(ce({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[n,t,o,i,a])}const Mo=new Set(["plan"]),Xt=[],No=It((n=>n.length>0?n:Xt),mn),Uo=It((n=>n.length>0?n:Xt),gn),Bo=O((function(n,e){const{view:t}=e;return{applicableItemOptions:t.applicableItemOptions,groupedAccountOptions:No(t.qboAccountHierarchy),groupedClassOptions:Uo(t.qboClassHierarchy),catalogItemLifecycleActionOptions:t.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:t.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:t.catalogTierTypeOptionsByPricingModel,periodUnitOptions:t.periodUnitOptions,trialEndActionOptions:t.trialEndActionOptions,trialUnitOptions:t.trialUnitOptions,typeOptions:t.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:t.actionState.fetchState==="In-Progress",isSaving:t.fetchState==="In-Progress",itemId:e.itemId,localData:t.localData,plan:t.plan}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${t}/catalog`),onLifecycleAction:i!==""?a=>{i!==""&&n(Ct({action:a,id:i}))}:void 0,onEditChange:a=>{i!==""&&n(Ae({id:i,localData:a}))},onSaveEdit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemEdited,{itemId:i}),n(ht({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&n(ni({action:o,id:a,parentItemId:i}))}}}))(un);function Vo(){const n=D(),e=L(),{item_id:t,tenantEmailDomain:i}=F(),[a]=W(),{areTenantIdsInSync:o}=T(),c=(d=a.get("kind"))!=null&&Mo.has(d)?d:"plan";var d;const l=C((k=>Le(k,t))),{pageFetchState:v}=l,u=v.fetchState;r.useEffect((()=>(n(Q()),()=>{n(Q())})),[n]),r.useEffect((()=>{o&&n(Ge({id:t,kind:c}))}),[o,t,c,n]);const[g,S]=r.useState(0);r.useEffect((()=>{l.fetchState==="Completed"&&(n(Q()),n(Ge({cacheOverride:!0,id:t,kind:c})),S((k=>k+1)))}),[l.fetchState,n,t,c]);const f=u==="Completed";ge(o,!0);const[h,P]=r.useState(f?t:void 0);r.useEffect((()=>{t!=null&&f&&P(t)}),[t,f]);const b=h!==t&&(u==="Not-Started"||u==="In-Progress");return N(u)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogItemDetailPage,isReady:f}),s.jsx(Bo,{navigate:e,tenantEmailDomain:i,itemId:t??"",kind:c,isLoading:b,view:l},g)]})}function He(n={}){const{enabled:e=!0,fetchSyncHealth:t=!1,loadAccountingPickers:i=!1,reuseCached:a=!1}=n,o=D(),{areTenantIdsInSync:c}=T(),d=C($e),l=d.connection?.connected===!0,v=d.connectionFetchState.fetchState;return r.useEffect((()=>{e&&c&&(a&&v!=="Not-Started"||o(Et()),t&&o(ii()))}),[c,o,e,t,a]),r.useEffect((()=>{e&&c&&l&&i&&o(oi())}),[c,o,e,l,i]),{isQboConnected:l,qboView:d}}const Ho=new Set(["addon","charge","plan"]),Zo=new Set(["plan"]),qo=O((function(n,e){const t=Le(n,e.itemId);return{fieldHelp:t.fieldHelp,isQboPickerDataLoading:t.isQboPickerDataLoading,qboClassHierarchy:t.qboClassHierarchy,qboAccountHierarchy:t.qboAccountHierarchy,applicabilityValues:t.applicabilityValues,periodUnitOptions:t.periodUnitOptions,trialEndActionOptions:t.trialEndActionOptions,trialUnitOptions:t.trialUnitOptions,typeOptions:t.typeOptions,applicableItemOptions:t.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save catalog item.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode,pricingModelValues:t.pricingModelValues,prorationValues:t.prorationValues,tierTypeOptionsByPricingModel:t.catalogTierTypeOptionsByPricingModel,tierTypeValues:t.tierTypeValues}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,i=e.isEdit?"edit":"create",{itemId:a}=e,o=a!=null?`${t}/catalog/${encodeURIComponent(a)}`:`${t}/catalog`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemFormCancelled),n(Q()),e.navigate(`${t}/catalog`)},onChange:c=>{n(Ae({id:a,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemSaved,{mode:i}),n(ht({id:a}))}}}))(vn);function zo(){const n=D(),e=L(),{item_id:t,tenantEmailDomain:i}=F(),[a]=W(),{areTenantIdsInSync:o}=T(),c=t!=null,d=a.get("type"),l=d!=null&&Ho.has(d)?d:void 0,v=(u=a.get("kind"))!=null&&Zo.has(u)?u:"plan";var u;const g=C((S=>Le(S,t)));return ge(o,!0),He({loadAccountingPickers:!0,reuseCached:!0}),r.useEffect((()=>{o&&t!=null&&n(ai({id:t,kind:v}))}),[o,t,v,n]),r.useEffect((()=>{c||l==null||g.localData.catalogType===l||n(Ae({localData:{...g.localData,catalogType:l}}))}),[c,l,g.localData?.catalogType,n]),r.useEffect((()=>{if(g.fetchState==="Completed"){const S=g.savedItemId??t,f=S!=null?`/${i}/invoicing/catalog/${encodeURIComponent(S)}`:`/${i}/invoicing/catalog`;e(f),n(Q())}}),[g.fetchState,g.savedItemId,t,n,e,i]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogItemFormPage}),s.jsx(qo,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:c,itemId:t})]})}const Ko={addons:"addon",all:"item",charges:"charge",plans:"plan"},Qo=O((function(n,e){const t=K(n),i=e.activeTab==="plans",a=e.activeTab==="all",o=i?t.plans:a?[...t.plans,...t.products]:t.products,c=i||a&&t.fetchState==="In-Progress"?t.fetchState:t.productFetchState.fetchState;return{catalogItemLifecycleActionOptions:t.catalogItemLifecycleActionOptions,counts:t.count,countsLoading:t.countsFetchState.fetchState==="Not-Started"||t.countsFetchState.fetchState==="In-Progress",hasMore:i?t.planNextCursor!=null:a&&t.planNextCursor!=null||t.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&o.length===0,isLoadingMore:c==="In-Progress"&&o.length>0,plans:t.plans,productColumns:t.productColumns,products:t.products}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",a=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${t}/data_import`)},onAddItem:()=>{const c=Ko[e.activeTab];p.trackInvoicingActionClick(m.Event.invoicingAddCatalogItemClicked,{itemType:c}),e.navigate(`${t}/catalog/new?type=${c}`)},onItemClick:(c,d)=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemRowClicked,{itemId:d}),e.navigate(`${t}/catalog/${encodeURIComponent(d)}`)},onCatalogItemLifecycleAction:(c,d)=>{n(Ct({action:si(d),id:c}))},onLoadMore:()=>{if(a)return e.planNextCursor!=null&&n(Ce({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&n(ce({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));o!=null&&n(i?Ce({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):ce({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(pn);function Go(){const n=D(),e=L(),{tenantEmailDomain:t}=F(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState("plans"),[l,v]=r.useState(""),[u,g]=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]),P=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),b=C((A=>K(A))),k=b.planFilters.search,y=b.planSort,I=b.planNextCursor,j=b.productNextCursor,E=b.fetchState==="Completed",w=b.runningActionId??null;return r.useEffect((()=>{const A=setTimeout((()=>v(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&n(We({cacheOverride:!1,planFilters:h,productFilters:P,planSort:S,productSort:S}))}),[i,n,h,P,S]),r.useEffect((()=>{i&&(f!==k||S?.field!==y?.field||S?.dir!==y?.dir)&&n(We({cacheOverride:!0,planFilters:h,productFilters:P,planSort:S,productSort:S}))}),[k,y,i,n,h,P,f,S]),N(b.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogPage,isReady:E}),s.jsx(Qo,{navigate:e,tenantEmailDomain:t,activeTab:c,searchValue:a,sortState:u,planFilters:h,productFilters:P,sort:S,planNextCursor:I,productNextCursor:j,runningCatalogItemActionId:w,onSearchChange:o,onTabChange:d,onSortChange:g})]})}const Wo=O((function(n,e){const t=kt(n,e.couponId);return{fieldHelp:t.fieldHelp,applyOnOptions:t.applyOnOptions,discountTypeOptions:t.discountTypeOptions,durationTypeOptions:t.durationTypeOptions,errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save coupon.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode,periodUnitOptions:t.periodUnitOptions}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,a=i!=null?"edit":"create",o=i!=null?`${t}/discounts/${encodeURIComponent(i)}`:`${t}/discounts`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCouponFormCancelled),n(G()),e.navigate(`${t}/discounts`)},onChange:c=>{n(li({id:i,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCouponSaved,{mode:a}),n(ri({id:i}))}}}))(fn);function Jo(){const n=D(),e=L(),{coupon_id:t,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=T(),{fetchState:o,savedCouponId:c}=C((d=>kt(d,t)));return r.useEffect((()=>{a&&t!=null&&n(ci({id:t}))}),[a,t,n]),r.useEffect((()=>{if(o==="Completed"){const d=c??t,l=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(l),n(G())}}),[o,c,t,n,e,i]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCouponFormPage}),s.jsx(Wo,{couponId:t,navigate:e,tenantEmailDomain:i})]})}const Xo=O((function(n){const e=yt(n);return{fieldHelp:e.fieldHelp,customers:e.customers,planNames:e.planNames,errorMessage:e.fetchState==="Error"?e.error?.message??"Failed to create invoice. Please try again.":void 0,isSubmitting:e.fetchState==="In-Progress",localData:e.localData,settings:e.settings}}),(function(n){return{dispatch:n}}),(function(n,{dispatch:e},t){const i=`/${t.tenantEmailDomain}/invoicing`;return{...n,onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreateInvoiceCancelled),t.navigate(`${i}/invoices`)},onChange:a=>{e(bt(a))},onSubmit:()=>{const a=gi(n.localData);p.trackInvoicingActionClick(m.Event.invoicingInvoiceCreated,{customerId:a.customer_id,lineItemCount:a.line_items?.length}),e(mi(a))}}}))(hn);function Yo(){const n=D(),e=L(),{tenantEmailDomain:t}=F(),[i]=W(),{areTenantIdsInSync:a}=T(),o=i.get("customerId"),c=C((I=>yt(I))),d=c.fetchState,l=c.localData,v=c.savedInvoiceId,u=C(xt),g=C((I=>di(I))),S=C(ue),f=g.fetchState==="Not-Started"||g.fetchState==="In-Progress"&&u==null,h=S.fetchState==="Not-Started"||S.fetchState==="In-Progress"&&S.customers.length===0,P=f||h,b=g.fetchState==="Completed"&&S.fetchState==="Completed";r.useEffect((()=>(n(Je()),()=>{n(Je())})),[n]);const k=r.useRef(!1);r.useEffect((()=>{k.current||o==null||o===""||l.customerId!==""||(k.current=!0,n(bt({...l,customerId:o})))}),[o,l,n]),r.useEffect((()=>{a&&n(ui({cacheOverride:!1}))}),[a,n]);const y=r.useRef(d);return r.useEffect((()=>{const I=y.current;if(y.current=d,I!=="Completed"&&d==="Completed"){const j=v!=null?`/${t}/invoicing/invoices/${encodeURIComponent(v)}`:`/${t}/invoicing/invoices`;e(j)}}),[d,v,e,t]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreateInvoicePage,isReady:b}),P?s.jsx(Sn,{}):s.jsx(Xo,{navigate:e,tenantEmailDomain:t})]})}const ea=O((function(n,e){const{detailView:t}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:t.creditNote,creditNoteId:e.creditNoteId,isLoading:t.fetchState==="Not-Started"||t.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${t}/credits`),onCustomerClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${t}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(i)}`)}}}))(In);function ta(){const n=D(),e=L(),{credit_note_id:t,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=T(),o=C((d=>vi(d,t??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{a&&t!=null&&n(pi({id:t}))}),[a,t,n]),N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreditDetailPage,isReady:c}),s.jsx(ea,{navigate:e,tenantEmailDomain:i,creditNoteId:t??"",detailView:o})]})}const na=O((function(n){const e=jt(n),{fetchState:t}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",creditNotes:e.creditNotes,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.creditNotes.length===0,isLoadingMore:t==="In-Progress"&&e.creditNotes.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${t}/data_import`)},onCreditNoteClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${t}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&n(Si({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Cn);function ia(){const n=D(),e=L(),{tenantEmailDomain:t}=F(),{areTenantIdsInSync:i}=T(),[a,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,creditNoteListFetchState:b}=C((y=>{const I=jt(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,creditNoteListFetchState:I.fetchState}}),H),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&n(Xe({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(Xe({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreditsListPage,isReady:k}),s.jsx(na,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onStatusChange:y=>n(fi(y)),onSortChange:v})]})}const Yt=(n,e,t)=>{const i=`/${n}/invoicing/customers/`;return t!=null?`${i}${encodeURIComponent(t)}/${e}/`:`${i}new/${e}/`},oa=O((function(n,e){const{editView:t,hasLoadedRecord:i}=e;return{fieldHelp:t.fieldHelp,billingAddressLabel:t.billingAddressLabel,customerTypeOptions:t.customerTypeOptions,netTermDayOptions:t.netTermDayOptions,taxabilityOptions:t.taxabilityOptions,customer:t.record.invoicingCustomer,invoices:t.record.invoices.slice(0,5),isLoading:!i&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),hasPaymentLinkEmailPreviewFailed:t.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:t.emailPreviewFetchState.fetchState==="In-Progress",isSaving:t.fetchState==="In-Progress",paymentLinkEmailPreview:t.emailPreview,isSendingPaymentLink:t.record.sendLinkState.fetchState==="In-Progress",localData:t.localData,paymentMethods:t.record.paymentMethods,sendPaymentLinkErrorMessage:t.record.sendLinkState.fetchState==="Error"?t.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:t.record.sendLinkState.fetchState==="Completed"?t.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:t.record.sendLinkState.fetchState==="Completed"?t.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:t.record.stripeConnected}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${t}/customers`),onChange:a=>{n(Ee({id:i,localData:a}))},onCreateInvoice:()=>e.navigate(`${t}/invoices/create`),onInvoiceClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(a)}`)},onCreatePromotionalCredits:()=>e.onCreatePromotionalCredits(),onNewSubscription:()=>e.navigate(`${t}/subscriptions/new`),onOpenAddress:()=>{const a=Yt(e.tenantEmailDomain??"",ke,i),o=X(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${t}/settings/payment-destination`),onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerEdited,{customerId:i}),n(Ee({id:i,localData:a})),n(Dt({id:i}))},onFetchPaymentLinkEmailPreview:a=>n(xi({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,c)=>n(yi({body:c,customerId:i,email:a,subject:o})),onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(a)}`)}}}))(yn);function aa(){const n=D(),e=L(),t=J(),{customer_id:i,tenantEmailDomain:a}=F(),{areTenantIdsInSync:o}=T(),c=C((_=>we(_,i))),d=c.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(!1),[g,S]=r.useState(!1),[f,h]=r.useState(c.record.fetchState==="Completed"?i:void 0);r.useEffect((()=>{i!=null&&c.record.fetchState==="Completed"&&h(i)}),[i,c.record.fetchState]);const P=f===i,{plaidTokenFetchState:b,promotionalCreditSubmitState:k}=c,{paymentMethodSaveState:y,setupIntentFetchState:I,stripeConnected:j}=c.record,E=r.useRef(c.record.sendLinkState.fetchState);r.useEffect((()=>{const _=c.record.sendLinkState.fetchState;E.current!=="Error"&&_==="Error"&&n(hi({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),E.current=_}),[n,c.record.sendLinkState.fetchState]);const w=I.fetchState==="Error"?I.error?.message??"Failed to start card setup.":y.fetchState==="Error"?y.error?.message??"Failed to save payment method.":b.fetchState==="Error"?b.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(n(te()),n(ne()),()=>{n(te()),n(ne())})),[n]),r.useEffect((()=>{t.state?.openPromotionalCreditsDialog===!0&&(S(!0),e(t.pathname,{replace:!0,state:null}))}),[t.pathname,t.state,e]),r.useEffect((()=>{o&&i!=null&&n(Ii({id:i}))}),[o,i,n]),r.useEffect((()=>{o&&i!=null&&j&&n(Ye({customerId:i}))}),[o,i,n,j]);const[A,U]=r.useState(0);return r.useEffect((()=>{c.fetchState==="Completed"&&(n(Re()),i!=null&&n(Pt({id:i})),U((_=>_+1)))}),[c.fetchState,n,i]),N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomerDetailPage,isReady:l}),s.jsx(oa,{customerId:i??"",editView:c,hasLoadedRecord:P,location:t,navigate:e,tenantEmailDomain:a,onAddPaymentMethod:()=>{n(te()),i!=null&&j&&n(Ye({customerId:i})),u(!0)},onCreatePromotionalCredits:()=>{n(ne()),S(!0)}},A),s.jsx(En,{errorMessage:w,isCreatingSetupIntent:I.fetchState==="In-Progress",isSaving:y.fetchState==="In-Progress",open:v,plaidLinkToken:c.record.plaidLinkToken,saveSucceeded:y.fetchState==="Completed",setupIntent:c.record.setupIntent,stripeConnected:j,onChooseCard:()=>{i!=null&&n(Ei({customerId:i}))},onClose:()=>{u(!1),n(te())},onSavePaymentMethod:_=>{i!=null&&n(Ci({customerId:i,data:_}))}}),s.jsx(kn,{currentBalance:c.record.invoicingCustomer?.promotionalCredits,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:k.fetchState==="Error"?k.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:k.fetchState==="In-Progress",open:g,submitSucceeded:k.fetchState==="Completed",onClose:()=>{S(!1),n(ne())},onSubmit:({amount:_,description:ee})=>{i!=null&&n(ki({amount:_,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:ee}))}})]})}const sa=O((function(n,e){const t=we(n,e.customerId);return{fieldHelp:t.fieldHelp,billingAddressLabel:t.billingAddressLabel,customerTypeOptions:t.customerTypeOptions,netTermDayOptions:t.netTermDayOptions,taxabilityOptions:t.taxabilityOptions,errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save customer.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,a=i!=null?"edit":"create",o=i!=null?`${t}/customers/${encodeURIComponent(i)}`:`${t}/customers`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerFormCancelled),n(Re()),n(Fe(ke)),e.navigate(`${t}/customers`)},onChange:c=>{n(Ee({id:i,localData:c}))},onOpenAddress:()=>{const c=Yt(e.tenantEmailDomain??"",ke,i),d=X(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerSaved,{mode:a}),n(Dt({id:i}))}}}))(xn);function ca(){const n=D(),e=L(),t=J(),{customer_id:i,tenantEmailDomain:a}=F(),{areTenantIdsInSync:o}=T(),{fetchState:c,savedCustomerId:d}=C((l=>we(l,i)));return r.useEffect((()=>{o&&i!=null&&n(Pt({id:i}))}),[o,i,n]),r.useEffect((()=>{if(c==="Completed"){const l=d??i,v=l!=null?`/${a}/invoicing/customers/${encodeURIComponent(l)}`:`/${a}/invoicing/customers`;e(v),n(Re())}}),[c,d,i,n,e,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomerFormPage}),s.jsx(sa,{customerId:i,location:t,navigate:e,tenantEmailDomain:a})]})}const ra=O((function(n){const e=ue(n),{fetchState:t}=e;return{addressesById:n.addressState.addressesById,columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",customers:e.customers,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.customers.length===0,isLoadingMore:t==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{p.trackInvoicingActionClick(m.Event.invoicingAddCustomerClicked),e.navigate(`${t}/customers/new`)},onCustomerClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${t}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${t}/data_import`)},onRowAction:(i,a)=>{switch(a){case"createInvoice":e.navigate(`${t}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":e.navigate(`${t}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":e.navigate(`${t}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&n(Te({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(bn);function la(){const n=D(),e=L(),{tenantEmailDomain:t}=F(),{areTenantIdsInSync:i}=T(),[a,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,customerListFetchState:b}=C((y=>{const I=ue(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,customerListFetchState:I.fetchState}}),H),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&n(et({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(et({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomersListPage,isReady:k}),s.jsx(ra,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onStatusChange:y=>n(bi(y)),onSortChange:v})]})}const je=(n,e)=>e==null?void 0:n.sessionDetail[e]??n.sessions.find((t=>t.id===e)),da=O((function(n,e){const{filters:t,sessionId:i,view:a}=e,o=i==null?void 0:a.diagnosticsBySession[i],c=o?.fetch.fetchState??"Not-Started";return{diagnostics:o?.items??[],errorMessage:c==="Error"?o?.fetch.error?.message:void 0,expired:o?.expired??!1,filters:t,hasMore:o?.nextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress",isLoadingMore:c==="In-Progress"&&(o?.items.length??0)>0,session:je(a,i)}}),(function(n,e){const{downloadUrl:t,filters:i,navigate:a,sessionId:o,tenantEmailDomain:c,view:d}=e,l=o==null?void 0:d.diagnosticsBySession[o],v=je(d,o),u=d.actionStateByKind.retry?.fetchState==="In-Progress",g=d.actionStateByKind.rollback?.fetchState==="In-Progress",S=v?.status==="done"&&v.rollback_available_until!=null&&new Date(v.rollback_available_until).getTime()>Date.now()&&!g;return{onBack:()=>a(`/${c}/invoicing/data_import`),onDownloadCsv:()=>{t!=null&&window.open(t,"_blank","noopener")},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{o!=null&&l?.nextCursor!=null&&n(xe({...i,cursor:l.nextCursor,sessionId:o}))},onRetry:v?.status!=="failed"||u?void 0:()=>{o!=null&&n(Oe(o))},onRollback:S?()=>{o!=null&&n(Lt(o))}:void 0}}))(jn);function ua(){const n=D(),e=L(),{sessionId:t,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=T(),[o,c]=r.useState({}),d=C(_e),l=je(d,t),v=t==null?void 0:d.diagnosticsBySession[t];r.useEffect((()=>{a&&t!=null&&n(ye(t))}),[a,n,t]),r.useEffect((()=>{if(!a||t==null)return;const f=setTimeout((()=>{n(xe({...o,sessionId:t}))}),300);return()=>clearTimeout(f)}),[a,n,o,t]);const u=l?.status==="scanning"||l?.status==="importing";r.useEffect((()=>{if(!a||t==null||!u)return;const f=setInterval((()=>{n(ye(t)),n(xe({...o,sessionId:t}))}),3e3);return()=>clearInterval(f)}),[a,n,o,u,t]);const g=r.useMemo((()=>{if(t==null)return;const f=new URLSearchParams;o.moduleId!=null&&f.set("module_id",o.moduleId),o.level!=null&&f.set("level",o.level),o.outcome!=null&&f.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&f.set("search",o.search.trim());const h=f.toString();return`${se?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(t)}/issues.csv${h===""?"":`?${h}`}`}),[o,t]),S=v?.fetch.fetchState??"Not-Started";return N(S)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:l!=null&&S!=="Not-Started"}),s.jsx(da,{downloadUrl:g,filters:o,navigate:e,sessionId:t,tenantEmailDomain:i,view:d,onFiltersChange:c})]})}const en=n=>`invoicing_active_migration:${n}`,ae=(n,e)=>{if(n!=null&&n!=="")try{const t=en(n);e==null?sessionStorage.removeItem(t):sessionStorage.setItem(t,e)}catch{}},ga=O((function(n,e){const{sessions:t,sessionsFetch:i,statusFetch:a,statusRows:o}=e.view;return{isLoading:!(a.fetchState!=="Not-Started"&&a.fetchState!=="In-Progress"||o.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:t,statusRows:o}}),(function(n,e){const{navigate:t,tenantEmailDomain:i}=e,a=o=>{const c=o??null;n(oe(c)),ae(i,c),t(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),a(o)},onNewImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingNewImportClicked),a()},onRetrySession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),n(Oe(o)),a(o)},onRollbackSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),n(Lt(o))},onViewSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),t(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(Pn);function ma(){const n=D(),e=L(),{tenantEmailDomain:t}=F(),{areTenantIdsInSync:i}=T(),a=C(_e);r.useEffect((()=>{i&&(n(ji()),n(At()))}),[i,n]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:o}),s.jsx(ga,{navigate:e,tenantEmailDomain:t,view:a})]})}const va=O((function(n,e){const{activeId:t,integrationsView:i,settings:a,view:o}=e,{actionStateByKind:c,sessionDetail:d,sessions:l}=o,v=i.externalConnections?.revenue?.find((g=>g.connectionName==="chargebee")),u=t!=null?d[t]:void 0;return{chargebeeConnected:a?.chargebee_connected===!0||(v?.isValid??!1),chargebeeConnectorAvailable:v!=null,chargebeeSite:a?.chargebee_site,connectError:c.connect?.error?.message,connecting:c.connect?.fetchState==="In-Progress",retrying:c.retry?.fetchState==="In-Progress",session:u??l.find((g=>g.id===t)),starting:c.start?.fetchState==="In-Progress",uploading:c.upload?.fetchState==="In-Progress"}}),(function(n,e){const{activeId:t,navigate:i,tenantEmailDomain:a}=e;return{onBack:e.onBack,onDownloadTemplates:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportTemplatesDownloaded);const o=se?.invoicingMicroServiceBaseUrl,c=o!=null&&o.length>0?o:"";window.open(`${c}/1.0/data-import/templates`,"_blank","noopener")},onFetchFromChargebee:()=>{p.trackInvoicingActionClick(m.Event.invoicingChargebeeConnectClicked),n(Li())},onGoToIntegrations:()=>{i(`/${a}/invoicing/settings`)},onGoToOverview:()=>i(`/${a}/invoicing/overview`),onRetry:()=>{t!=null&&n(Oe(t))},onSaveLater:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportStarted),t!=null&&n(Di(t))},onUpload:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportFileUploaded),n(Pi({files:o}))},onViewDetails:t==null?void 0:()=>i(`/${a}/invoicing/data_import/${encodeURIComponent(t)}`)}}))(Dn);function pa(){const n=D(),e=L(),{tenantEmailDomain:t}=F(),{areTenantIdsInSync:i}=T(),a=C(xt),o=C(Me).companyId??Ie.getSignedInUserTenant(t??"")?.companyId,c=C((f=>$t(f,o))),d=C(_e),{activeMigrationSessionId:l}=d,v=l??void 0,u=v!=null?d.sessionDetail[v]??d.sessions.find((f=>f.id===v)):void 0;r.useEffect((()=>{i&&(n(Ne()),n(At()))}),[i,n]),r.useEffect((()=>{if(l!=null)return;const f=(h=>{if(h==null||h==="")return null;try{return sessionStorage.getItem(en(h))}catch{return null}})(t);f!=null&&n(oe(f))}),[l,n,t]),r.useEffect((()=>{ae(t,l)}),[l,t]);const g=u?.status,S=g==="scanning"||g==="importing";return r.useEffect((()=>{if(!i||v==null||!S)return;const f=setInterval((()=>{n(ye(v))}),3e3);return()=>clearInterval(f)}),[i,v,S,n]),r.useEffect((()=>{g==="done"&&(n(oe(null)),ae(t,null))}),[n,g,t]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportMigratePage}),s.jsx(va,{activeId:v,integrationsView:c,navigate:e,settings:a,tenantEmailDomain:t,view:d,onBack:()=>{n(oe(null)),ae(t,null),e(`/${t}/invoicing/data_import`)}})]})}const fa=O((function(n,e){const{editView:t}=e;return{fieldHelp:t.fieldHelp,coupon:t.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,isLoading:!e.hasLoadedRecord&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:t.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${t}/discounts`),onLifecycleAction:a=>{n(wt({action:a,id:i}))},onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingCouponEdited,{couponId:i}),n($i({data:a,id:i}))}}}))(Ln);function Sa(){const n=D(),e=L(),{coupon_id:t,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=T(),o=C((h=>Ai(h,t))),c=o.actionState.fetchState==="In-Progress",d=o.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(l?t:void 0);r.useEffect((()=>{t!=null&&l&&u(t)}),[t,l]);const g=v===t;r.useEffect((()=>(n(G()),()=>{n(G())})),[n]),r.useEffect((()=>{a&&n(tt({id:t}))}),[a,t,n]);const[S,f]=r.useState(0);return r.useEffect((()=>{o.fetchState==="Completed"&&(n(G()),n(tt({cacheOverride:!0,id:t})),f((h=>h+1)))}),[o.fetchState,n,t]),N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDiscountDetailPage,isReady:l}),s.jsx(fa,{hasLoadedRecord:g,couponId:t??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},S)]})}const ha=O((function(n){const e=Rt(n),{fetchState:t}=e;return{columns:e.columns,counts:e.count,discountLifecycleActionOptions:e.discountLifecycleActionOptions,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",coupons:e.coupons,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.coupons.length===0,isLoadingMore:t==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${t}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreateCouponClicked),e.navigate(`${t}/discounts/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${t}/data_import`)},onDiscountLifecycleAction:(i,a)=>{n(wt({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&n(Ft({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(An);function Ia(){const n=D(),e=L(),{tenantEmailDomain:t}=F(),{areTenantIdsInSync:i}=T(),[a,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,couponListFetchState:b,runningDiscountActionId:k}=C((I=>{const j=Rt(I);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:j.sort,nextCursor:j.nextCursor,couponListFetchState:j.fetchState,runningDiscountActionId:j.runningActionId??null}}),H),y=b==="Completed";return r.useEffect((()=>{const I=setTimeout((()=>d(a)),300);return()=>clearTimeout(I)}),[a]),r.useEffect((()=>{i&&n(nt({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(nt({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDiscountsListPage,isReady:y}),s.jsx(ha,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,runningDiscountActionId:k,onSearchChange:o,onStatusChange:I=>n(wi(I)),onSortChange:v})]})}const Ca=O((function(n,e){const{readView:t}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:t.dunningCase,isLoading:t.fetchState==="Not-Started"||t.fetchState==="In-Progress",isRunningAction:t.actionState.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,a=i!=="";return{onBack:()=>e.navigate(`${t}/dunning`),onInvoiceClick:o=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(o)}`)},onCancel:a?()=>n(Z({action:"cancel",id:i})):void 0,onResolve:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resolve",caseId:i}),n(Z({action:"resolve",id:i}))}:void 0,onResume:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resume",caseId:i}),n(Z({action:"resume",id:i}))}:void 0,onRetry:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"retry",caseId:i}),n(Z({action:"retry",id:i}))}:void 0}}))(wn);function Ea(){const n=D(),e=L(),{case_id:t,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=T(),o=C((E=>Ri(E,t??""))),c=o.fetchState==="Completed",d=o.dunningCase?.invoiceID,[l,v]=r.useState("idle"),[u,g]=r.useState(!1),[S,f]=r.useState(),[h,P]=r.useState(!1),b=r.useCallback((()=>{v("idle"),g(!1),f(void 0),P(!1)}),[]),k=r.useCallback((()=>{if(t==null)return;n(Fi({id:t})),v("idle"),g(!1);const E=o.emailPreview.preview;f(E==null?void 0:{body:E.body,cc:E.cc,subject:E.subject,to:E.to}),P(!0)}),[t,n,o.emailPreview.preview]),y=r.useCallback((E=>{t!=null&&l!=="pending"&&(g(!1),v("pending"),p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"send-email",caseId:t}),n(Z({action:"send-email",body:E,id:t})))}),[t,n,l]),I=r.useMemo((()=>o.emailPreview.preview==null?void 0:{bodyToken:o.emailPreview.preview.bodyToken,renderedHtmlTemplate:o.emailPreview.preview.renderedHtmlTemplate,subjectToken:o.emailPreview.preview.subjectToken}),[o.emailPreview.preview]);r.useEffect((()=>{a&&t!=null&&n(Ti({id:t}))}),[a,t,n]),r.useEffect((()=>{a&&d!=null&&n(Ue({invoiceId:d}))}),[a,d,n]),r.useEffect((()=>{v("idle"),g(!1),f(void 0),P(!1)}),[t]),r.useEffect((()=>{a||(v("idle"),g(!1),f(void 0),P(!1))}),[a]),r.useEffect((()=>{h&&S==null&&o.emailPreview.preview!=null&&f({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,S,h]),r.useEffect((()=>{l==="pending"&&(o.actionState.fetchState!=="In-Progress"?u&&o.actionState.fetchState==="Completed"?(t!=null&&n(_i({id:t})),b()):u&&o.actionState.fetchState==="Error"&&v("failed"):g(!0))}),[t,b,n,l,u,o.actionState.fetchState]);const j=d!=null&&o.linkedInvoice?.id===d?o.linkedInvoice.dunningAttempts:void 0;return N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDunningDetailPage,isReady:c}),s.jsx(Ca,{navigate:e,tenantEmailDomain:i,caseId:t??"",readView:o,dunningAttempts:j,onSendEmail:k}),s.jsx($n,{initialDraft:S,isPreviewLoading:o.emailPreview.fetchState==="Not-Started"||o.emailPreview.fetchState==="In-Progress",isSending:l==="pending",onClose:b,onSend:y,open:h,preview:I,previewErrorMessage:o.emailPreview.fetchState==="Error"?o.emailPreview.error?.message:void 0,sendErrorMessage:l==="failed"?o.actionState.error?.message:void 0})]})}const ka=O((function(n){const e=Tt(n),{fetchState:t}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:t==="In-Progress"&&e.dunningCases.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${t}/data_import`),onDunningCaseClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingDunningCaseRowClicked,{caseId:i}),e.navigate(`${t}/dunning/${encodeURIComponent(i)}`)},onRowAction:(i,a)=>{a!=="retry"&&a!=="resume"&&a!=="resolve"&&a!=="cancel"||n(Z({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&n(Mi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Rn);function ya(){const n=D(),e=L(),{tenantEmailDomain:t}=F(),{areTenantIdsInSync:i}=T(),[a,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,dunningCaseListFetchState:b}=C((y=>{const I=Tt(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,dunningCaseListFetchState:I.fetchState}}),H),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&n(it({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(it({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDunningListPage,isReady:k}),s.jsx(ka,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onStatusChange:y=>n(Oi(y)),onSortChange:v})]})}const xa=O((function(n,e){const{view:t}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:t.billingAddress,invoice:t.invoice,invoiceId:e.invoiceId,shippingAddress:t.shippingAddress,isLoading:!e.hasLoadedRecord&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),isSaving:t.actionState.fetchState==="In-Progress",isVoiding:t.actionState.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e;return{onBack:()=>e.navigate(`${t}/invoices`),onCustomerClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${t}/customers/${encodeURIComponent(a)}`)},onIssueCreditNote:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteIssued,{invoiceId:i}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{p.trackInvoicingActionClick(m.Event.invoicingRecordPaymentClicked,{fromScreen:"invoice_detail",invoiceId:i}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceRegenerated,{invoiceId:i}),n(V({action:"regenerate",invoiceId:i}))},onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceEdited,{invoiceId:i}),n(Ui({data:{due_date:a.due_date!==""?a.due_date:void 0,notes:a.notes.trim()!==""?a.notes.split(`
|
|
2
|
+
`).map((o=>o.trim())).filter((o=>o!=="")).map((o=>({note:o}))):void 0,po_number:a.po_number!==""?a.po_number:null},invoiceId:i}))},onSendReminder:()=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceReminderSent,{invoiceId:i}),n(V({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(a)}`)},onVoid:a=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceVoided,{invoiceId:i}),n(V({action:"void",invoiceId:i,body:a}))}}}))(Fn);function ba(){const n=D(),e=L(),{invoice_id:t,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=T(),o=C((g=>_t(g,t??""))),c=o.pageFetchState.fetchState,d=c==="Completed",[l,v]=r.useState(d?t:void 0);r.useEffect((()=>{t!=null&&d&&v(t)}),[t,d]);const u=l===t;return r.useEffect((()=>{a&&t!=null&&n(Ni({invoiceId:t}))}),[a,t,n]),N(c)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingInvoiceDetailPage,isReady:d}),s.jsx(xa,{invoiceId:t??"",hasLoadedRecord:u,navigate:e,tenantEmailDomain:i,view:o})]})}const ja=O((function(n){const e=Ot(n),{fetchState:t}=e;return{counts:e.counts,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,invoices:e.invoices,statusOptions:e.statusOptions,isLoading:t==="Not-Started"||t==="In-Progress"&&e.invoices.length===0,isLoadingMore:t==="In-Progress"&&e.invoices.length>0,kpis:e.kpis,kpisLoading:e.kpisFetchState.fetchState==="Not-Started"||e.kpisFetchState.fetchState==="In-Progress"&&e.kpis==null,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onCreateInvoice:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreateInvoiceClicked),e.navigate(`${t}/invoices/create`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"invoices"}),e.navigate(`${t}/data_import`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceRowClicked,{invoiceId:i}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}`)},onRowAction:(i,a)=>{switch(a){case"recordPayment":e.navigate(`${t}/invoices/${encodeURIComponent(i)}/record-payment`);break;case"issueCreditNote":e.navigate(`${t}/invoices/${encodeURIComponent(i)}/issue-credit-note`);break;case"sendReminder":n(V({action:"send-reminder",invoiceId:i}));break;case"regenerate":n(V({action:"regenerate",invoiceId:i}));break;case"void":n(V({action:"void",invoiceId:i}))}},onVoidInvoice:(i,a)=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceVoided,{invoiceId:i}),n(V({action:"void",invoiceId:i,body:a}))},onLoadMore:()=>{e.nextCursor!=null&&n(Mt({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Tn);function Pa(){const n=D(),e=L(),{tenantEmailDomain:t}=F(),{areTenantIdsInSync:i}=T(),[a,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,invoiceListFetchState:b,voidingInvoiceId:k}=C((I=>{const j=Ot(I);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:I.invoicingInvoiceListState.sort,nextCursor:j.nextCursor,invoiceListFetchState:j.fetchState,voidingInvoiceId:j.runningActionId}}),H),y=b==="Completed";return r.useEffect((()=>{const I=setTimeout((()=>d(a)),300);return()=>clearTimeout(I)}),[a]),r.useEffect((()=>{i&&n(pe({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(pe({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingInvoicesListPage,isReady:y}),s.jsx(ja,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,voidingInvoiceId:k,onSearchChange:o,onStatusChange:I=>{n(Bi(I)),n(pe({cacheOverride:!1,filters:g,sort:u}))},onSortChange:v})]})}function ut(){const n=D(),e=L(),{tenantEmailDomain:t}=F(),i=_n(),a=ft(),[o,c]=r.useState(!1),{acceptTermsState:d,status:l}=C(Nt),v=Vi(i?.loggedInUserRoleMap),u=`/${t}/invoicing`,g=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(_o,{isAppContentDrawerOpen:o,handleDrawerToggle:g}),s.jsx(On,{analytics:p,isAccepting:d.fetchState==="In-Progress",isReadOnlyUser:!v,meetingUrl:a("invoicing_promo"),onAcceptClick:()=>{n(Hi())},onBackClick:()=>{e(`/${t}`)},onClickMenuIcon:()=>{g(!0)}})]})}const Da=O((function(n,e){const t=Ut(n,e.invoiceId),{invoice:i,localData:a,reasonCodeOptions:o,submitState:c,typeOptions:d}=t;return{fieldHelp:t.fieldHelp,amountDue:i?.amountDue,currencyCode:i?.currencyCode??"USD",customerName:i?.customerName??"",errorMessage:c.fetchState==="Error"?c.error?.message??"Failed to issue credit note. Please try again.":void 0,invoiceNumber:i?.invoiceNumber??e.invoiceId,isSubmitting:c.fetchState==="In-Progress",localData:a,reasonCodeOptions:o,typeOptions:d}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing/invoices/${encodeURIComponent(e.invoiceId)}`,i=()=>e.navigate(t);return{onBack:i,onCancel:i,onChange:a=>{n(Qi({localData:a}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteIssued,{invoiceId:e.invoiceId}),n(Ki())}}}))(Mn);function La(){const n=D(),e=L(),{invoice_id:t,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=T(),{fetchState:o,invoice:c,isPageReady:d,issuedCreditNoteId:l,submitState:v}=C((f=>Ut(f,t??""))),u=`/${i}/invoicing`,g=r.useRef(null);r.useEffect((()=>{n(Zi()),g.current=null}),[n,t]),r.useEffect((()=>{a&&t!=null&&n(Ue({invoiceId:t}))}),[a,n,t]),r.useEffect((()=>{c!=null&&t!=null&&o==="Completed"&&g.current!==t&&(g.current=t,n(qi({localData:zi(c)})))}),[n,o,c,t]);const S=r.useRef(v.fetchState);return r.useEffect((()=>{const f=S.current;S.current=v.fetchState,f!=="Completed"&&v.fetchState==="Completed"&&l!=null&&e(`${u}/credits/${encodeURIComponent(l)}`)}),[l,e,v.fetchState,u]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingInvoiceDetailPage,isReady:d}),s.jsx(Da,{invoiceId:t??"",navigate:e,tenantEmailDomain:i})]})}const Aa=O((function(n){return{invoicingOverview:Bt(n)}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{onRefresh:()=>{n(Vt(e.selectedPeriod,!0))},onSubscriptionClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionTileClicked,{subscriptionId:i}),e.navigate(`${t}/subscriptions/${i}`)},onViewInvoices:()=>{p.trackInvoicingActionClick(m.Event.invoicingViewInvoicesClicked),e.navigate(`${t}/invoices`)},onViewPayments:()=>{p.trackInvoicingActionClick(m.Event.invoicingViewPaymentsClicked),e.navigate(`${t}/payments`)}}}))(Nn);function $a(){const n=D(),e=L(),{tenantEmailDomain:t}=F(),{areTenantIdsInSync:i}=T(),[a]=r.useState((()=>{const c=new Date;return{month:c.getMonth()+1,year:c.getFullYear()}})),o=C((c=>Bt(c).fetchState))==="Completed";return r.useEffect((()=>{i&&n(Vt(a))}),[i,n,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingOverviewPage,isReady:o}),s.jsx(Aa,{navigate:e,selectedPeriod:a,tenantEmailDomain:t})]})}const wa=O((function(n){const e=Ht(n),{fetchState:t}=e;return{columns:e.columns,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.transactions.length===0,isLoadingMore:t==="In-Progress"&&e.transactions.length>0,tabIds:e.tabIds,transactions:e.transactions}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeType:e.activeType,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTypeChange:e.onTypeChange,onViewTransactionCustomer:e.onViewTransactionCustomer,onViewTransactionInvoice:e.onViewTransactionInvoice,onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"payments"}),e.navigate(`${t}/data_import`)},onTransactionClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingPaymentRowClicked,{transactionId:i}),e.navigate(`${t}/payments/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&n(Wi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Un);function Ra(){const n=D(),e=L(),{tenantEmailDomain:t}=F(),{areTenantIdsInSync:i}=T(),[a,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeType:S,appliedSearch:f,appliedSort:h,nextCursor:P,transactionListFetchState:b,transactions:k}=C((w=>{const A=Ht(w);return{activeType:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,transactionListFetchState:A.fetchState,transactions:A.transactions}}),H),y=b==="Completed",I=`/${t}/invoicing`,j=r.useCallback((w=>{const A=k.find((_=>_.id===w)),U=A?.linkedInvoices?.[0]?.invoiceID??A?.invoiceID;U!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"payments_list",invoiceId:U,toScreen:"invoice"}),e(`${I}/invoices/${encodeURIComponent(U)}`))}),[e,I,k]),E=r.useCallback((w=>{const A=k.find((U=>U.id===w))?.customerID;A!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:A,fromScreen:"payments_list",toScreen:"customer"}),e(`${I}/customers/${encodeURIComponent(A)}`))}),[e,I,k]);return r.useEffect((()=>{const w=setTimeout((()=>d(a)),300);return()=>clearTimeout(w)}),[a]),r.useEffect((()=>{i&&n(fe({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(fe({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingPaymentsListPage,isReady:y}),s.jsx(wa,{navigate:e,tenantEmailDomain:t,activeType:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onTypeChange:w=>{n(Gi(w)),n(fe({cacheOverride:!1,filters:g,sort:u}))},onSortChange:v,onViewTransactionCustomer:E,onViewTransactionInvoice:j})]})}const Fa=n=>{const e=[n.firstName,n.lastName].filter((t=>t!=null&&t.trim()!=="")).join(" ").trim();return(n.company!=null&&n.company.trim()!==""?n.company.trim():"")||e||(n.email!=null&&n.email.trim()!==""?n.email.trim():"")||n.id};function gt(){const n=D(),e=L(),{invoice_id:t,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=T(),o=t!=null&&t!=="",c=C(ue),d=C((E=>Ji(E))),l=C(Xi),v=C((E=>_t(E,t??""))),u=v.invoice,g=`/${i}/invoicing`,S=r.useRef(null),f=r.useRef("");r.useEffect((()=>{n(Yi()),S.current=null,f.current=""}),[n,t]),r.useEffect((()=>{a&&n(o&&t!=null?Ue({invoiceId:t}):Te({filters:{},keepExistingListItems:!1}))}),[a,n,t,o]),r.useEffect((()=>{o&&u!=null&&t!=null&&v.fetchState==="Completed"&&S.current!==t&&(S.current=t,n(eo({contextInvoiceId:t,localData:to(u)})))}),[n,u,t,v.fetchState,o]),r.useEffect((()=>{if(o)return;const E=d.localData.customerId;E!==""&&E!==f.current&&(f.current=E,n(Mt({filters:{customerId:E},keepExistingListItems:!1})),d.localData.invoiceToLink!==""&&n(ot({localData:{...d.localData,customerId:E,invoiceToLink:""}})))}),[n,d.localData,o]);const h=r.useRef(l.fetchState);r.useEffect((()=>{const E=h.current;if(h.current=l.fetchState,E!=="Completed"&&l.fetchState==="Completed"){if(l.recordedInvoiceId!=null)return void e(`${g}/invoices/${encodeURIComponent(l.recordedInvoiceId)}`);e(`${g}/payments`)}}),[e,l.fetchState,l.recordedInvoiceId,g]);const P=r.useMemo((()=>c.customers.map((E=>({id:E.id,name:Fa(E)})))),[c.customers]),b=C((E=>no(E,d.localData.customerId))),k=r.useMemo((()=>b.map((E=>{return{amountDue:(w=E.amountDue,A=io.currencySymbol,Vn("0,0.00",w,A)),amountDueValue:E.amountDue,id:E.id,label:E.invoiceNumber};var w,A}))),[b]),y=r.useMemo((()=>{if(!o||u==null)return;const E=u.currencyCode??"USD",w=u.amountDue?.amount??0;return{amountDue:De("0,0.00",u.amountDue),amountDueValue:w,currencyCode:E,customerName:u.customerName??u.customerID,invoiceId:u.id,invoiceNumber:u.invoiceNumber??u.id}}),[u,o]),I=o?`${g}/invoices/${encodeURIComponent(t??"")}`:`${g}/payments`,j=!o||v.fetchState==="Completed"&&d.localData.invoiceToLink!=="";return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingRecordPaymentPage,isReady:j}),s.jsx(Bn,{customers:P,fieldHelp:d.fieldHelp,errorMessage:l.fetchState==="Error"?l.error?.message??"Failed to record payment. Please try again.":void 0,gatewayOptions:d.gatewayOptions,invoiceContext:y,invoiceOptions:k,isSubmitting:l.fetchState==="In-Progress",localData:d.localData,mode:o?"invoice":"customer",paymentMethodOptions:d.paymentMethodOptions,onBack:()=>{e(I)},onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingRecordPaymentCancelled),e(I)},onChange:E=>{n(ot({localData:E}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingPaymentRecorded,{customerId:d.localData.customerId,invoiceId:o?t:d.localData.invoiceToLink,paymentMethod:d.localData.paymentMethod}),n(oo(o?t??void 0:void 0))}})]})}const tn=(n,e,t)=>{const i=`/${n}/invoicing/subscriptions/`;return t!=null?`${i}${encodeURIComponent(t)}/${e}/`:`${i}new/${e}/`},Ta=(n,e)=>{if(n==null)return;const t=De("0,0",n);return e!=null?`${t}/${e}`:t},nn=(n,e,t)=>{const i=[n,Ta(e,t)].filter((a=>a!=null&&a!=="")).join(" · ");return i!==""?i:void 0},mt=n=>n.priceCode!=null&&n.priceCode.trim()!=="",_a=n=>({billingCycles:n.billingCycles,billingPeriod:n.period,billingPeriodUnit:n.periodUnit,label:n.name??n.id,subtitle:nn(n.productCode,n.price,n.periodUnit),value:n.priceCode}),Oa=n=>({label:n.name??n.couponCode??n.id,value:n.couponCode??n.id}),Ma=O((function(n,e){const{editView:t}=e,i=t.subscription,a=i?.status,o=a!=null&&e.commercialEditAllowedFromStatuses.includes(a);return{cancelReasonCodeOptions:t.cancelReasonCodeOptions,fieldHelp:t.fieldHelp,addons:t.products.filter((c=>c.itemType==="addon")).filter(mt).map((c=>({label:c.name??c.id,subtitle:nn(c.productCode,c.price,c.periodUnit),value:c.priceCode}))),canEditCommercial:o,coupons:t.coupons.map(Oa),isLoading:!e.hasLoadedRecord&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),isRunningAction:t.actionState.fetchState==="In-Progress",isSaving:t.fetchState==="In-Progress",lifecycleActionOptions:e.lifecycleActionOptions,localData:t.localData,plans:t.plans.filter(mt).map(_a),shippingAddressLabel:t.shippingAddressLabel,subscription:i}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,a=i!=="",o=(c,d)=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionLifecycleAction,{action:c,subscriptionId:i}),n(qt({action:c,id:i,body:d}))};return{onBack:()=>e.navigate(`${t}/subscriptions`),onChange:c=>{n(re({id:i,localData:c}))},onChangeTermEnd:a?c=>{const d=c?.trim()??"";d!==""&&o("change_term_end",{term_ends_at:d})}:void 0,onCustomerClick:c=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:c,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${t}/customers/${encodeURIComponent(c)}`,"_blank","noopener,noreferrer")},onOpenAddress:()=>{const c=tn(e.tenantEmailDomain??"",be,i),d=X(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onViewInvoices:()=>e.navigate(`${t}/invoices`),onSaveEdit:c=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionEdited,{subscriptionId:i}),n(re({id:i,localData:c})),n(Zt({id:i}))},onCancelSubscription:a?c=>{o("cancel",{cancel_reason_code:c.cancelReasonCode,end_of_term:!1,...c.cancelReason!=null&&c.cancelReason.trim()!==""?{cancel_reason:c.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:a?(c,d)=>{c!=="pause"?o(c):o(c,d!=null&&d.trim()!==""?{resume_date:d.trim()}:void 0)}:void 0}}))(Hn);function Na(){const n=D(),e=L(),t=J(),{subscription_id:i,tenantEmailDomain:a}=F(),{areTenantIdsInSync:o}=T(),c=C((k=>Be(k,i))),{subscriptionCommercialEditAllowedFromStatuses:d,subscriptionLifecycleActionOptions:l,subscriptionMetadataEditAllowedFromStatuses:v}=c,u=c.pageFetchState.fetchState,g=u==="Completed",[S,f]=r.useState(g?i:void 0);r.useEffect((()=>{i!=null&&g&&f(i)}),[i,g]);const h=S===i;ge(o),r.useEffect((()=>{o&&i!=null&&n(at({id:i}))}),[o,i,n]);const[P,b]=r.useState(0);return r.useEffect((()=>{c.fetchState==="Completed"&&(n(Ve()),n(at({cacheOverride:!0,id:i})),b((k=>k+1)))}),[c.fetchState,n,i]),N(u)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSubscriptionDetailPage,isReady:g}),s.jsx(Ma,{hasLoadedRecord:h,commercialEditAllowedFromStatuses:d,editView:c,lifecycleActionOptions:l,location:t,metadataEditAllowedFromStatuses:v,navigate:e,subscriptionId:i??"",tenantEmailDomain:a},P)]})}const Ua=n=>{const e=[n.firstName,n.lastName].filter((t=>t!=null&&t.trim()!=="")).join(" ").trim();return(n.company!=null&&n.company.trim()!==""?n.company.trim():"")||e||(n.email!=null&&n.email.trim()!==""?n.email.trim():"")||n.id},Ba=(n,e)=>{if(n==null)return;const t=De("0,0",n);return e!=null?`${t}/${e}`:t},Pe=(n,e,t)=>{const i=[n,Ba(e,t)].filter((a=>a!=null&&a!=="")).join(" · ");return i!==""?i:void 0},Va=n=>({label:Ua(n),value:n.id}),he=n=>n.priceCode!=null&&n.priceCode.trim()!=="",Ha=n=>({billingCycles:n.billingCycles,billingPeriod:n.period,billingPeriodUnit:n.periodUnit,label:n.name??n.id,subtitle:Pe(n.productCode,n.price,n.periodUnit),trialPeriod:n.trialPeriod,trialPeriodUnit:n.trialPeriodUnit,value:n.priceCode}),Za=n=>({label:n.name??n.couponCode??n.id,value:n.couponCode??n.id}),qa=O((function(n,e){const t=Be(n,e.subscriptionId);return{fieldHelp:t.fieldHelp,addons:t.products.filter((i=>i.itemType==="addon")).filter(he).map((i=>({label:i.name??i.id,subtitle:Pe(i.productCode,i.price,i.periodUnit),value:i.priceCode}))),charges:t.products.filter((i=>i.itemType==="charge")).filter(he).map((i=>({label:i.name??i.id,subtitle:Pe(i.productCode,i.price,void 0),value:i.priceCode}))),coupons:t.coupons.map(Za),customers:t.customers.map(Va),errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save subscription.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode,plans:t.plans.filter(he).map(Ha),shippingAddressLabel:t.shippingAddressLabel}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,a=i!=null?"edit":"create";return{onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionFormCancelled),n(Ve()),n(Fe(be)),i==null?e.navigate(`${t}/subscriptions`):e.navigate(`${t}/subscriptions/${encodeURIComponent(i)}`)},onChange:o=>{n(re({id:i,localData:o}))},onOpenAddress:()=>{const o=tn(e.tenantEmailDomain??"",be,i),c=X(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(o,{state:{pathnameStackToGoBack:c}})},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionSaved,{mode:a}),n(Zt({id:i}))}}}))(Zn);function za(){const n=D(),e=L(),t=J(),{subscription_id:i,tenantEmailDomain:a}=F(),[o]=W(),{areTenantIdsInSync:c}=T(),d=o.get("customerId"),{fetchState:l,savedSubscriptionId:v}=C((S=>ao(S,i))),u=C((S=>Be(S,i).localData));ge(c),r.useEffect((()=>{c&&(n(Te({filters:{},keepExistingListItems:!1})),n(Ce({filters:{type:"plan"},keepExistingListItems:!1})),n(Ft({filters:{},keepExistingListItems:!1})),i!=null&&n(so({id:i})))}),[c,i,n]);const g=r.useRef(!1);return r.useEffect((()=>{g.current||i!=null||d==null||d===""||u.customerId!==""||(g.current=!0,n(re({id:i,localData:{...u,customerId:d}})))}),[d,i,u,n]),r.useEffect((()=>{if(l==="Completed"){const S=v??i,f=S!=null?`/${a}/invoicing/subscriptions/${encodeURIComponent(S)}`:`/${a}/invoicing/subscriptions`;e(f),n(Ve())}}),[l,v,i,n,e,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSubscriptionFormPage}),s.jsx(qa,{location:t,navigate:e,subscriptionId:i,tenantEmailDomain:a})]})}const Ka=O((function(n){const e=zt(n),{fetchState:t}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.subscriptions.length===0,isLoadingMore:t==="In-Progress"&&e.subscriptions.length>0,cancelReasonCodeOptions:e.cancelReasonCodeOptions,lifecycleActionOptions:e.subscriptionLifecycleActionOptions,subscriptions:e.subscriptions,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,i=(a,o,c)=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionLifecycleAction,{action:o,subscriptionId:a}),n(qt({action:o,id:a,body:c}))};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onAddSubscription:()=>{p.trackInvoicingActionClick(m.Event.invoicingAddSubscriptionClicked),e.navigate(`${t}/subscriptions/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"subscriptions"}),e.navigate(`${t}/data_import`)},onChangeTermEnd:(a,o)=>{const c=o?.trim()??"";c!==""&&i(a,"change_term_end",{term_ends_at:c})},onSubscriptionAction:(a,o,c)=>{o!=="pause"?i(a,o):i(a,o,c!=null&&c.trim()!==""?{resume_date:c.trim()}:void 0)},onCancelSubscription:(a,o)=>{i(a,"cancel",{cancel_reason_code:o.cancelReasonCode,end_of_term:!1,...o.cancelReason!=null&&o.cancelReason.trim()!==""?{cancel_reason:o.cancelReason.trim()}:{}})},onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionRowClicked,{subscriptionId:a}),e.navigate(`${t}/subscriptions/${encodeURIComponent(a)}`)},onViewSubscriptionInvoices:()=>{e.navigate(`${t}/invoices`)},onLoadMore:()=>{e.nextCursor!=null&&n(lo({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(qn);function Qa(){const n=D(),e=L(),{tenantEmailDomain:t}=F(),{areTenantIdsInSync:i}=T(),[a,o]=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]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,subscriptionListFetchState:b,runningActionSubscriptionId:k}=C((j=>{const E=zt(j);return{activeStatus:E.activeTab,appliedSearch:E.filters.search,appliedSort:E.sort,nextCursor:E.nextCursor,subscriptionListFetchState:E.fetchState,runningActionSubscriptionId:E.runningActionId??null}}),H),y=b==="Completed";r.useEffect((()=>{const j=setTimeout((()=>d(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&n(st({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(st({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]);const I=r.useRef(k);return r.useEffect((()=>{const j=I.current!=null&&k==null;I.current=k,j&&i&&n(co())}),[k,i,n]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSubscriptionsListPage,isReady:y}),s.jsx(Ka,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,runningActionSubscriptionId:k,onSearchChange:o,onStatusChange:j=>n(ro(j)),onSortChange:v})]})}const Ga=O((function(n,e){const{readView:t}=e;return{isLoading:t.fetchState==="Not-Started"||t.fetchState==="In-Progress",isRunningAction:t.actionState.fetchState==="In-Progress",transaction:t.transaction,transactionId:e.transactionId}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{transactionId:i}=e;return{onBack:()=>e.navigate(`${t}/payments`),onCustomerClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"transaction_detail",toScreen:"customer"}),e.navigate(`${t}/customers/${encodeURIComponent(a)}`)},onInvoiceClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(a)}`)},onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(a)}`)},onCapture:i!==""?()=>{p.trackInvoicingActionClick(m.Event.invoicingTransactionCaptured,{transactionId:i}),n(mo({action:"capture",id:i}))}:void 0}}))(zn);function Wa(){const n=D(),e=L(),{tenantEmailDomain:t,transaction_id:i}=F(),{areTenantIdsInSync:a}=T(),o=C((d=>uo(d,i??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{a&&i!=null&&n(go({id:i}))}),[a,i,n]),N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingTransactionDetailPage,isReady:c}),s.jsx(Ga,{navigate:e,tenantEmailDomain:t,transactionId:i??"",readView:o})]})}const Ja={branding:"invoicing_branding_save",dunning:"invoicing_dunning_settings_save",quickbooks:"invoicing_qbo_settings_save"};function Y(n){const e=D(),{areTenantIdsInSync:t}=T(),{tenantEmailDomain:i}=F(),{fetchState:a,fieldHelp:o,logoFile:c,saveState:d,settings:l,stripeConnectState:v}=C(vo),{configError:u,configFetchState:g,dunningScheduleActionOptions:S,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:h,qboSyncStatusOptions:P}=C(Kt),b=C($e);He({enabled:n==="quickbooks",fetchSyncHealth:!0,loadAccountingPickers:!0});const k=C(Me),y=n==="dunning"||n==="quickbooks",I=k.companyId??Ie.getSignedInUserTenant(i??"")?.companyId,j=C((R=>$t(R,I))),E=po(k.userRole??[]),w=k.tenantId??"",A=Ie.getSignedInUser(),U={userId:A?.userId??"",sessionId:A?.zeniSessionId??"",tenantId:w},_=c?.fileId,ee=C((R=>_!=null&&_!==""?fo(R,_):void 0)),Ze=C((R=>_!=null&&_!==""?So(R,_):void 0)),on=_!=null&&_!==""&&ee!=null?{[_]:ee}:{},an=_!=null&&_!==""&&Ze!=null?{[_]:Ze}:{};r.useEffect((()=>(e(ct()),()=>{e(ct())})),[e]),r.useEffect((()=>{t&&(a!=="Not-Started"&&a!=="Error"||e(Ne()))}),[t,e,a]),r.useEffect((()=>{t&&y&&g==="Not-Started"&&e(le())}),[t,e,g,y]),r.useEffect((()=>{if(!t)return;const R=A?.userId;R!=null&&R!==""&&w!==""&&Ke.shouldFetchActiveTenant(w)&&(Ke.markActiveTenantFetchStarted(w),e(ho(R,w,A?.zeniSessionId)))}),[t,e,A?.userId,A?.zeniSessionId,w]);const sn=S.length>0||f.length>0,cn=a==="Not-Started"||a==="In-Progress"&&l==null||y&&!sn&&(g==="Not-Started"||g==="In-Progress"),rn=a==="Completed"&&(!y||g==="Completed"),qe=j.externalConnections?.revenue?.find((R=>R.connectionName==="chargebee"))?.connectionId,me=se?.invoicingMicroServiceBaseUrl,ze=me!=null&&me.length>0?`${me}/1.0/webhooks/stripe`:"",ve={deleteConnectionError:j.externalConnections?.deleteConnectionError?.message,deleteConnectionState:j.externalConnections?.deleteConnectionState??"Not-Started",integrationsView:j,isAdmin:E,isStripeBusy:v.fetchState==="In-Progress",onConnectStripe:R=>e(lt(R)),onDisconnect:(R,q)=>{w!==""&&e(bo(w,R,dt(q)))},onDisconnectStripe:()=>e(rt()),onReconnectQBO:()=>{const R=k.tenantEmailDomain??i??"";de.init("/connection/auth",R),de.handleClick()},onRefreshQBO:()=>{j.integrations.refreshQBO.fetchState!=="In-Progress"&&e(Wt())},onSaveChargeBeeCredentials:(R,q)=>{qe!=null&&w!==""&&e(yo(w,qe,dt("revenue"),xo("chargebee"),{api_key:R,site:q}))},saveChargeBeeError:j.externalConnections?.saveAPIKeyConnectionError?.message,saveChargeBeeState:j.externalConnections?.saveAPIKeyConnectionState??"Not-Started",settings:l,stripeError:v.fetchState==="Error"?v.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:ze};return{authParams:U,deleteFileStatusById:on,fieldHelp:o,dunningScheduleActionOptions:S,filesEndPoint:se?.fileMicroServiceBaseUrl??"",integrationsSectionProps:ve,isInvoicingPageReady:rn,isLoading:cn,isSaving:d.fetchState==="In-Progress",isStripeBusy:v.fetchState==="In-Progress",logoFile:c,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:h,qboSyncStatusOptions:P,qboView:b,saveErrorMessage:d.fetchState==="Error"?d.error?.message??"Failed to save settings.":y&&g==="Error"?u?.message??"Failed to load invoicing configuration.":void 0,settings:l,stripeError:v.fetchState==="Error"?v.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:ze,updateFileStatusById:an,onConnectStripe:R=>e(lt(R)),onDeleteFile:R=>e(ko(R,w)),onDisconnectStripe:()=>e(rt()),onEditFileName:(R,q)=>e(Eo(R,q,w)),onReconnectQBO:ve.onReconnectQBO,onRefreshQBO:ve.onRefreshQBO,onRetryQboSyncTask:R=>e(Gt(R)),onSave:R=>{p.trackInvoicingActionClick(m.Event.invoicingSettingsSaved,{tab:n??"hub"}),e(Co({settings:R,snackbarSection:Ja[n??""]}))},onStartQboBackfill:R=>e(Qt(R)),updateFilesEntity:R=>{p.trackInvoicingActionClick(m.Event.invoicingLogoUploaded),e(Io({files:R}))}}}function vt({appContent:n}){const e=L(),t=J(),i=D(),{tenantEmailDomain:a}=F(),o=Y("branding"),c=C((v=>jo(v))),d=C((v=>Po(Se,v)?.addressToCreate));r.useEffect((()=>{c.saveState.fetchState==="Completed"&&(i(Do()),i(Fe(Se)))}),[c.saveState.fetchState,i]);const l=St(c.saveState.fetchState);return r.useEffect((()=>{l==="In-Progress"&&c.saveState.fetchState==="Completed"&&e("..")}),[l,c.saveState.fetchState,e]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),s.jsx(Kn,{address:d,fieldHelp:c.fieldHelp,addressLabel:c.addressLabel,appContent:n,authParams:o.authParams,dateFormatOptions:c.dateFormatOptions,deleteFileStatusById:o.deleteFileStatusById,filesEndPoint:o.filesEndPoint,isLoading:o.isLoading,isSaving:o.isSaving,localData:c.localData,saveErrorMessage:o.saveErrorMessage,settings:o.settings,updateFileStatusById:o.updateFileStatusById,onBackClick:()=>e(".."),onChange:v=>{i(Ao({localData:v}))},onDeleteFile:o.onDeleteFile,onEditFileName:o.onEditFileName,onOpenAddress:()=>{const v=`/${a}/invoicing/settings/branding/${Se}/`,u=X(t.state?.pathnameStackToGoBack,t.pathname);e(v,{state:{pathnameStackToGoBack:u}})},onSubmit:()=>i(Lo()),updateFilesEntity:o.updateFilesEntity})]})}function Xa(){const n=L(),e=Y("dunning");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Qn,{dunningScheduleActionOptions:e.dunningScheduleActionOptions,isLoading:e.isLoading,isSaving:e.isSaving,saveErrorMessage:e.saveErrorMessage,settings:e.settings,onBackClick:()=>n(".."),onSave:e.onSave})]})}function Ya(){const n=L(),e=Y("integrations");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Gn,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>n("../quickbooks"),onOpenPaymentDestination:()=>n("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>n("..")})]})}function es(){const n=L(),e=Y("payment-destination");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Wn,{fieldHelp:e.fieldHelp,isLoading:e.isLoading,isStripeBusy:e.isStripeBusy,saveErrorMessage:e.saveErrorMessage,settings:e.settings,stripeError:e.stripeError,stripeWebhookUrl:e.stripeWebhookUrl,onBackClick:()=>n(".."),onConnectStripe:e.onConnectStripe})]})}const ts=O((function(n){const e=Jt(n);return{accountMappingKindOptions:e.accountMappingKindOptions,fieldHelp:e.fieldHelp,accounts:e.accounts,connection:e.connection,customerMatchingOptions:e.customerMatchingOptions,isBackfilling:e.backfillState.fetchState==="In-Progress",isLoading:e.isLoading,isSaving:e.saveState.fetchState==="In-Progress",isSyncEnabledSaved:e.isSyncEnabledSaved,localData:e.localData,nestedAccountHierarchy:e.nestedAccountHierarchy,retryFetchStateByTaskId:e.retryFetchStateByTaskId,saveErrorMessage:e.saveState.fetchState==="Error"?e.saveState.error?.message:void 0,syncHealth:e.syncHealth,syncStatusOptions:e.syncStatusOptions}}),(function(n){return{onChange:e=>{n(Ro({localData:e}))},onReset:()=>{n(wo())},onRetryTask:e=>{n(Gt(e))},onSave:()=>{p.trackInvoicingActionClick(m.Event.invoicingSettingsSaved,{tab:"quickbooks"}),n($o())},onStartBackfill:e=>{n(Qt(e))}}}))(Jn);function ns(){const n=D(),e=L(),{tenantEmailDomain:t}=F(),i=C(Me),{configFetchState:a,settingsFetchState:o}=C(Jt);return r.useEffect((()=>{o!=="Not-Started"&&o!=="Error"||n(Ne())}),[n,o]),r.useEffect((()=>{a==="Not-Started"&&n(le())}),[a,n]),He({fetchSyncHealth:!0,loadAccountingPickers:!0}),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage}),s.jsx(ts,{onBackClick:()=>e(".."),onReconnect:()=>{de.init("/connection/auth",i.tenantEmailDomain??t??""),de.handleClick()},onRefresh:()=>n(Wt())})]})}const is={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function os(){const n=ft(),e=D(),t=L(),[i,a]=W(),o=Y(),{canEnableInvoicing:c,isEnablingInvoicing:d,isInvoicingEnabled:l,isQboConfigured:v,isStripeConnected:u}=C(Kt),g=i.get("tab");return r.useEffect((()=>{if(g==null)return;const S=is[g];a({},{replace:!0}),S!=null&&t(S,{replace:!0})}),[g,t,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),s.jsx(Xn,{analytics:p,integrationsSectionProps:{...o.integrationsSectionProps,onConfigureQBO:()=>t("quickbooks"),onOpenPaymentDestination:()=>t("payment-destination")},isEnablingInvoicing:d,isLoading:o.isLoading,meetingUrl:n("invoicing_settings"),settings:o.settings,onBrandingClick:()=>t("branding"),onDunningClick:()=>t("dunning"),canEnableInvoicing:c,isQboConfigured:v,isStripePaymentsReady:u,onEnableInvoicingClick:l?void 0:()=>{e(Fo())}})]})}function pt(){return s.jsxs(ie,{children:[s.jsx(x,{index:!0,element:s.jsx(os,{})}),s.jsx(x,{path:"payment-destination",element:s.jsx(es,{})}),s.jsx(x,{path:"branding",element:s.jsx(vt,{})}),s.jsx(x,{path:"branding/:addressType",element:s.jsx(vt,{appContent:s.jsx(z,{isSubPage:!0,hideAddressBackButton:!0})})}),s.jsx(x,{path:"integrations",element:s.jsx(Ya,{})}),s.jsx(x,{path:"dunning",element:s.jsx(Xa,{})}),s.jsx(x,{path:"quickbooks",element:s.jsx(ns,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:"..",replace:!0})})]})}function ws(){const n=D(),e=L(),{tenantEmailDomain:t}=F(),{areTenantIdsInSync:i}=T(),{enableState:a,fetchState:o,status:c}=C(Nt),d=St(a.fetchState),l=`/${t}/invoicing`,v=r.useRef(!1),u=C((g=>$e(g).connectionFetchState.fetchState));return r.useEffect((()=>{i&&(o!=="Not-Started"?o!=="Error"||v.current||(v.current=!0,n(le({cacheOverride:!1}))):n(le({cacheOverride:!1})))}),[i,n,o]),r.useEffect((()=>{i&&u==="Not-Started"&&n(Et())}),[i,n,u]),r.useEffect((()=>{d==="In-Progress"&&a.fetchState==="Completed"&&(e(`${l}/catalog`),n(To()))}),[d,a.fetchState,l,n,e]),c==null&&o!=="Error"?s.jsx(Yn,{fetchState:"In-Progress"}):c==="not_started"?s.jsxs(ie,{children:[s.jsx(x,{path:"promo",element:s.jsx(ut,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:`${l}/promo`,replace:!0})})]}):c==="settings"?s.jsxs(ie,{children:[s.jsx(x,{path:"promo",element:s.jsx(ut,{})}),s.jsx(x,{path:"settings/*",element:s.jsx(pt,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:`${l}/settings`,replace:!0})})]}):s.jsxs(ie,{children:[s.jsx(x,{path:"/",element:s.jsx(B,{to:"overview",replace:!0})}),s.jsx(x,{path:"overview",element:s.jsx($a,{})}),s.jsx(x,{path:"promo",element:s.jsx(B,{to:`${l}/overview`,replace:!0})}),s.jsx(x,{path:"customers",element:s.jsx(la,{})}),s.jsx(x,{path:"customers/new",element:s.jsx(ca,{})}),s.jsx(x,{path:"customers/new/:addressType",element:s.jsx(z,{})}),s.jsx(x,{path:"customers/:customer_id",element:s.jsx(aa,{})}),s.jsx(x,{path:"customers/:customer_id/:addressType",element:s.jsx(z,{})}),s.jsx(x,{path:"subscriptions",element:s.jsx(Qa,{})}),s.jsx(x,{path:"subscriptions/new",element:s.jsx(za,{})}),s.jsx(x,{path:"subscriptions/new/:addressType",element:s.jsx(z,{})}),s.jsx(x,{path:"subscriptions/:subscription_id",element:s.jsx(Na,{})}),s.jsx(x,{path:"subscriptions/:subscription_id/:addressType",element:s.jsx(z,{})}),s.jsx(x,{path:"invoices",element:s.jsx(Pa,{})}),s.jsx(x,{path:"invoices/create",element:s.jsx(Yo,{})}),s.jsx(x,{path:"invoices/:invoice_id",element:s.jsx(ba,{})}),s.jsx(x,{path:"invoices/:invoice_id/record-payment",element:s.jsx(gt,{})}),s.jsx(x,{path:"invoices/:invoice_id/issue-credit-note",element:s.jsx(La,{})}),s.jsx(x,{path:"payments",element:s.jsx(Ra,{})}),s.jsx(x,{path:"payments/record",element:s.jsx(gt,{})}),s.jsx(x,{path:"payments/:transaction_id",element:s.jsx(Wa,{})}),s.jsx(x,{path:"credits",element:s.jsx(ia,{})}),s.jsx(x,{path:"credits/:credit_note_id",element:s.jsx(ta,{})}),s.jsx(x,{path:"discounts",element:s.jsx(Ia,{})}),s.jsx(x,{path:"discounts/new",element:s.jsx(Jo,{})}),s.jsx(x,{path:"discounts/:coupon_id",element:s.jsx(Sa,{})}),s.jsx(x,{path:"dunning",element:s.jsx(ya,{})}),s.jsx(x,{path:"dunning/:case_id",element:s.jsx(Ea,{})}),s.jsx(x,{path:"catalog",element:s.jsx(Go,{})}),s.jsx(x,{path:"catalog/new",element:s.jsx(zo,{})}),s.jsx(x,{path:"catalog/:item_id",element:s.jsx(Vo,{})}),s.jsx(x,{path:"settings/*",element:s.jsx(pt,{})}),s.jsx(x,{path:"audit_log",element:s.jsx(Oo,{})}),s.jsx(x,{path:"data_import",element:s.jsx(ma,{})}),s.jsx(x,{path:"data_import/migrate",element:s.jsx(pa,{})}),s.jsx(x,{path:"data_import/:sessionId",element:s.jsx(ua,{})}),s.jsx(x,{path:"*",element:s.jsx(M,{})})]})}export{ws as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as a}from"./liveblocks-
|
|
1
|
+
import{j as a}from"./liveblocks-DRsJ0YIJ.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-DGLzDXWl.js";import{Ud as k,Ue as v,Uf as T,Jh as D,J3 as U,Ug as B,Uh as oe,Ui as ie,J7 as se,gh as $,Je as le,Jb as re}from"./zeni-epic-state-Dm2vDWXH.js";import{a1 as x,J as r,a2 as de,k as j,X as G,a3 as ce,a4 as me,a5 as pe,p as J,O as ue,c as he,a6 as ge,$ as xe,E as fe,f as we,a7 as be,a8 as Se,_ as ye,a9 as ke,aa as ve,ab as je,ac as $e}from"./index-DGjciFPC.js";import{n as m}from"./mui-BuJ3P0FU.js";import f from"./NotFoundScreen-3YmbDG-O.js";import{a as I}from"./sentry-G4ZANa8Z.js";import"./recharts-CJlXFxhv.js";import"./analytics-CvsRIk3B.js";import"./plaid-i7y7YD6O.js";import"./dnd-SnD389s6.js";import"./stripe-cKAAJElX.js";import"./lottie-DEqUWUd5.js";import"./lexical-CMBMntF_.js";import"./pdf-B_v4zyN7.js";import"./utils-Bz8wuSWM.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]="d345eb0f-0247-421c-8a70-d9579c95c3e4",e._sentryDebugIdIdentifier="sentry-dbid-d345eb0f-0247-421c-8a70-d9579c95c3e4")}catch{}})();const Ie=m.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
height: 100%;
|
|
4
4
|
width: 100%;
|
|
@@ -7,7 +7,7 @@ import{j as a}from"./liveblocks-B3m51ZRo.js";import{i as S,l as g,h as C,g as y,
|
|
|
7
7
|
align-items: center;
|
|
8
8
|
background-color: ${e=>e.theme.colors.grey4};
|
|
9
9
|
box-shadow: ${e=>`0px 2px ${r.sp1} ${e.theme.colors.dropShadowNormal}`};
|
|
10
|
-
`,Ce=g((function(e){const t=k(e),n=v(e),{companyName:o}=t;return{companyName:o,isDisabled:t.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,magicLinkViewState:t}}),(function(e,t){const{vendorId:n,billId:o}=t;return{onFetchBankName:i=>{e(
|
|
10
|
+
`,Ce=g((function(e){const t=k(e),n=v(e),{companyName:o}=t;return{companyName:o,isDisabled:t.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,magicLinkViewState:t}}),(function(e,t){const{vendorId:n,billId:o}=t;return{onFetchBankName:i=>{e(U(i))},onSaveHandler:i=>{j.trackBillPayMagicLinkSubmitBankAccountDetails(o),e(D(i,"standard",n,o))},onACHDetailsUpdated:i=>{const{bankAccountSection:l}=i;e(T({data:l}))}}}))(de);function F(){const e=x(),{vendorId:t,billId:n}=S();return t==null||n==null?a.jsx(f,{}):a.jsx(a.Fragment,{children:a.jsx(Ie,{windowSize:e,children:a.jsx(Ce,{vendorId:t,billId:n})})})}const De=m.div`
|
|
11
11
|
display: flex;
|
|
12
12
|
height: 100vh;
|
|
13
13
|
width: 100%;
|
|
@@ -25,7 +25,7 @@ import{j as a}from"./liveblocks-B3m51ZRo.js";import{i as S,l as g,h as C,g as y,
|
|
|
25
25
|
align-items: center;
|
|
26
26
|
background-color: ${e=>e.theme.colors.grey4};
|
|
27
27
|
box-shadow: ${e=>`0px 2px ${r.sp1} ${e.theme.colors.dropShadowNormal}`};
|
|
28
|
-
`,Ne=g((function(e){const t=k(e),n=v(e),o=B(e),{companyName:i}=t;return{companyName:i,isDisabled:t.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,mailingAddressDetails:o,magicLinkViewState:t}}),(function(e,t){const{navigate:n,location:o,vendorId:i,billId:l}=t;return{onFetchBankName:s=>{e(
|
|
28
|
+
`,Ne=g((function(e){const t=k(e),n=v(e),o=B(e),{companyName:i}=t;return{companyName:i,isDisabled:t.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,mailingAddressDetails:o,magicLinkViewState:t}}),(function(e,t){const{navigate:n,location:o,vendorId:i,billId:l}=t;return{onFetchBankName:s=>{e(U(s))},onSaveHandler:s=>{j.trackBillPayMagicLinkSubmitBankAccountDetails(l),e(D(s,"us-domestic",i,l))},onWireDetailsUpdated:s=>{const{bankAccountSection:d}=s;e(T({data:d}))},onAddressClick:()=>{const s=o.pathname.replace("us-domestic","address"),d=J(o.state?.pathnameStackToGoBack,o.pathname);n(s,{state:{pathnameStackToGoBack:d}})}}}))(pe);function Ee(){const e=C(),t=y(),n=x(),{vendorId:o,billId:i}=S();return o==null||i==null?a.jsx(f,{}):a.jsx(a.Fragment,{children:a.jsx(Le,{windowSize:n,children:a.jsx(Ne,{location:t,navigate:e,vendorId:o,billId:i})})})}const Fe=m.div`
|
|
29
29
|
display: flex;
|
|
30
30
|
height: 100%;
|
|
31
31
|
width: 100%;
|
|
@@ -34,7 +34,7 @@ import{j as a}from"./liveblocks-B3m51ZRo.js";import{i as S,l as g,h as C,g as y,
|
|
|
34
34
|
align-items: center;
|
|
35
35
|
background-color: ${e=>e.theme.colors.grey4};
|
|
36
36
|
box-shadow: ${e=>`0px 2px ${r.sp1} ${e.theme.colors.dropShadowNormal}`};
|
|
37
|
-
`,
|
|
37
|
+
`,Te=g((function(e){const t=k(e),n=v(e),o=B(e),{companyName:i}=t;return{companyName:i,isDisabled:t.fetchState!=="Completed"?"disabled":void 0,magicLinkBankAccountDetails:n,mailingAddressDetails:o,magicLinkViewState:t}}),(function(e,t){const{navigate:n,location:o,vendorId:i,billId:l}=t;return{onFetchBankNameBySwift:s=>{e(se(s))},onSaveHandler:s=>{j.trackBillPayMagicLinkSubmitBankAccountDetails(l),e(D(s,"international",i,l,t.isLocalCurrencyEnabled))},onBankDetailsUpdated:s=>{const{internationalWireSwiftAccountSection:d}=s;e(ie({data:d}))},onAddressClick:()=>{const s=o.pathname.replace("international","address"),d=J(o.state?.pathnameStackToGoBack,o.pathname);n(s,{state:{pathnameStackToGoBack:d}})}}}))(ge);function Ue(){const e=C(),t=y(),n=x(),{vendorId:o,billId:i}=S(),{useFeatureGate:l}=ue(),{isFeatureEnabled:s}=l(he.isBillPayLocalCurrencyFeatureEnabled);return o==null||i==null?a.jsx(f,{}):a.jsx(Fe,{windowSize:n,children:a.jsx(Te,{location:t,navigate:e,vendorId:o,billId:i,isLocalCurrencyEnabled:s})})}const Ge={containerWidth:new je(100,58)},Je=m(ke)`
|
|
38
38
|
width: ${r.sp4};
|
|
39
39
|
height: ${r.sp4};
|
|
40
40
|
margin-bottom: ${r.sp3};
|
|
@@ -43,14 +43,14 @@ import{j as a}from"./liveblocks-B3m51ZRo.js";import{i as S,l as g,h as C,g as y,
|
|
|
43
43
|
cursor: pointer;
|
|
44
44
|
position: absolute;
|
|
45
45
|
color: ${e=>e.theme.colors.brandColorJade};
|
|
46
|
-
`,
|
|
46
|
+
`,Me=m.div`
|
|
47
47
|
display: flex;
|
|
48
48
|
height: 100vh;
|
|
49
49
|
flex-direction: ${e=>e.windowSize==="small"?"column":"row"};
|
|
50
50
|
width: 100vw;
|
|
51
51
|
overflow-y: scroll;
|
|
52
52
|
background-color: ${e=>e.theme.colors.grey4};
|
|
53
|
-
`,
|
|
53
|
+
`,He=m.div`
|
|
54
54
|
display: flex;
|
|
55
55
|
flex-direction: ${e=>e.windowSize==="small"?"column":"row"};
|
|
56
56
|
flex-direction: column;
|
|
@@ -58,7 +58,7 @@ import{j as a}from"./liveblocks-B3m51ZRo.js";import{i as S,l as g,h as C,g as y,
|
|
|
58
58
|
${e=>e.windowSize!=="small"?"overflow: auto;":""}
|
|
59
59
|
box-shadow: ${e=>`0px 2px ${r.sp1} ${e.theme.colors.dropShadowNormal}`};
|
|
60
60
|
padding-top: ${e=>e.windowSize!=="small"?r.sp2:"0px"};
|
|
61
|
-
`,
|
|
61
|
+
`,Ve=m.div`
|
|
62
62
|
display: flex;
|
|
63
63
|
flex-direction: column;
|
|
64
64
|
align-items: center;
|
|
@@ -69,4 +69,4 @@ import{j as a}from"./liveblocks-B3m51ZRo.js";import{i as S,l as g,h as C,g as y,
|
|
|
69
69
|
width: ${e=>e.windowSize=="small"?"auto":"42%"};
|
|
70
70
|
background-color: ${e=>e.windowSize==="small"?e.theme.colors.grey4:e.theme.colors.background};
|
|
71
71
|
margin-top: ${e=>e.windowSize==="small"?e.isAddressPage?"0px":"186px":"unset"};
|
|
72
|
-
`,
|
|
72
|
+
`,_e=g((function(e,t){return{file:t.file,type:t.type}}))(ve);function h({appContent:e}){const t=ee(),n=y(),{tenantEmailDomain:o,vendorId:i,billId:l}=S(),[s]=ae(),d=s.get("token"),M=n.pathname.includes("address"),w=x(),H=xe(),A=fe(),b=we(),V=()=>{H.toggle()},_=E((u=>k(u))),K=E((u=>v(u))),{authParams:W,fetchState:c,billAttachment:O,billFetchState:P,companyName:X,currencySymbol:q,amount:Q}=_,{tenantId:z,userId:L,sessionId:N}=W,{fetchState:R,internationalBankAccountCreateStatus:Y}=K;return I.useEffect((()=>{$()}),[]),I.useEffect((()=>{b&&c==="Not-Started"&&i!=null&&o!=null&&d!=null&&t(le(i,o,d))}),[b,c,i,o,d,t]),I.useEffect((()=>{b&&c==="Completed"&&($(L,N,z),l!=null&&t(re(l)))}),[c,b,L,N,z,l,t]),c==="Error"?a.jsx(f,{}):R==="Completed"||Y.fetchState==="Completed"?($(),a.jsx(te,{to:"../../../../../../../bank/account/save/success",replace:!0,relative:"path"})):c==="In-Progress"?a.jsx(be,{fetchState:c,style:{height:"100vh",backgroundColor:A.colors.grey5,boxShadow:`0px 2px ${r.sp1} ${A.colors.dropShadowNormal}`}}):a.jsxs(a.Fragment,{children:[c==="Completed"&&P==="Completed"&&a.jsx(Se,{analytics:j,onLoad:u=>(Z=>Z.trackBillPayMagicLinkPageLoad(o??"",i??"",X,l??"",Ke(n.pathname),q,Q))(u)}),a.jsxs(Me,{windowSize:w,children:[w!=="small"?a.jsx(Je,{onClick:V}):null,a.jsx(Ve,{windowSize:w,isAddressPage:M,children:P==="In-Progress"?a.jsx(ye,{size:"ExtraLarge",start:!0}):a.jsx(_e,{file:O,type:"bill"})}),a.jsx(He,{windowSize:w,children:e})]})]})}const Ke=e=>`${e.split("/").at(-2)}_${e.split("/").at(-1)}`;function We(){return a.jsx($e,{})}function da(){return a.jsxs(ne,{children:[a.jsx(p,{path:"bank/account/save/success",element:a.jsx(We,{})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/ach/standard",element:a.jsx(h,{appContent:a.jsx(F,{})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/ach/same-day",element:a.jsx(h,{appContent:a.jsx(F,{})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/address",element:a.jsx(h,{appContent:a.jsx(Ae,{isSubPage:!0})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/us-domestic",element:a.jsx(h,{appContent:a.jsx(Ee,{})})}),a.jsx(p,{path:":tenantEmailDomain/vendor/:vendorId/bill/:billId/wire/international",element:a.jsx(h,{appContent:a.jsx(Ue,{})})}),a.jsx(p,{path:"*",element:a.jsx(f,{})})]})}export{da as default};
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import{j as u}from"./liveblocks-DRsJ0YIJ.js";import{a as g}from"./sentry-G4ZANa8Z.js";import{u as O,g as _,h as w,t as V,j as l,N as L}from"./core-DGLzDXWl.js";import{z as r,E as M,G as P,R as A,k as N,T as R,Y as G,_ as W,V as Y}from"./index-DGjciFPC.js";import{fE as $,TI as q,U9 as B,U0 as H,gh as J,gj as K,U5 as Q,gT as X,di as Z,Ua as ee,Ub as te}from"./zeni-epic-state-Dm2vDWXH.js";import{n as ne}from"./mui-BuJ3P0FU.js";import{u as se}from"./useDeviceId-C9MUyzJJ.js";import{f as ae}from"./analyticsHelper-tF6p2yRC.js";import{t as ie}from"./getLocaleForTenant-CZIO6uAG.js";import"./recharts-CJlXFxhv.js";import"./analytics-CvsRIk3B.js";import"./plaid-i7y7YD6O.js";import"./dnd-SnD389s6.js";import"./stripe-cKAAJElX.js";import"./lottie-DEqUWUd5.js";import"./lexical-CMBMntF_.js";import"./pdf-B_v4zyN7.js";import"./utils-Bz8wuSWM.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]="968015a0-22bd-4150-9065-de1b9ec65181",t._sentryDebugIdIdentifier="sentry-dbid-968015a0-22bd-4150-9065-de1b9ec65181")}catch{}})();const U=(t,a)=>t!=null&&t.length>0&&a==="magic_links";function Ue(){const t=O(),a=_(),f=w(),[k]=V(),n=k.get("token"),p=k.get("stytch_token_type"),m=r.getMagicLinkCodeVerifier(),i=se(),{otpChallenge:d,twoFAPhoneNumber:E,magicLinkEmail:c,verifyDeviceFetchState:x,resendVerifyDeviceOTPFetchState:z}=l((e=>e.tenantState)),S=l((e=>e.tenantState.fetchState)),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=>$(e))),b=l((e=>q(e))),C=r.getSignedInUser(),v=M().mode;g.useEffect((()=>{s?.zeniSessionId==null&&n!=null&&U(n,p)&&i!=null&&m!=null&&(r.saveMagicLinkTriggered(n),t(B(n,i,m)))}),[n,p,t,i,m,s?.zeniSessionId]),g.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(H(b.tenantsInOrder),s.zeniSessionId),J(s.userId,s.zeniSessionId,o.tenantId),t(K(o.tenantId)),r.saveActiveTenantDomainForUser(o.tenantEmailDomain),t(Q("Completed")),P.updateAppLocaleID(ie(o)),ae(s,o,v,void 0,b.tenantsInOrder),X().then((()=>{const e=Y();e!=null&&A(e)})),setTimeout((()=>{N.trackLogin(R.Event.loginSuccess,"email",Z(o.productSettings))}),2e3))}),[I,S,y,s,o,b,v,a.state,t]);const D=g.useCallback((()=>{f("/signin/auth")}),[f]),j=g.useCallback((()=>{i!=null&&d!=null&&c!=null&&t(ee(i,c,d))}),[i,d,t,c]),F=g.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 u.jsx(G,{phoneNumber:E,verifyOtpFetchState:x.fetchState,resendVerifyDeviceOTPFetchState:z,onResendOtp:j,onVerifyOtp:F,onCancelVerifyDevice:D});if(I==="In-Progress"&&S==="Completed"&&s?.zeniSessionId!=null&&o!=null||C!=null){const e=a.state?.origin??"/";return u.jsx(L,{to:e,state:{...a.state,origin:""}})}if(!U(n,p)||m==null||h==="Error"){const e=a.state?.origin??"/",T=n!=null&&r.getLastUsedMagicLinkToken()===n;return u.jsx(L,{to:e,state:{...a.state,origin:"",magicLinkAlreadyUsed:T,magicLinkExpired:!T&&(r.isMagicLinkTriggered(n??"")||h==="Error"&&s?.zeniSessionId==null)}})}return u.jsx(oe,{"data-testid":"smooth-loader",children:u.jsx(W,{size:"ExtraLarge",start:!0})})}const oe=ne.div`
|
|
2
|
+
position: fixed;
|
|
3
|
+
top: 0;
|
|
4
|
+
left: 0;
|
|
5
|
+
right: 0;
|
|
6
|
+
bottom: 0;
|
|
7
|
+
display: flex;
|
|
8
|
+
align-items: center;
|
|
9
|
+
justify-content: center;
|
|
10
|
+
z-index: 9999;
|
|
11
|
+
background-color: ${t=>t.theme.colors.background};
|
|
12
|
+
`;export{Ue as default};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as B}from"./liveblocks-DRsJ0YIJ.js";import{a as f}from"./sentry-G4ZANa8Z.js";import{u as te,j as t,i as $e,g as Ge,h as Me,q as D}from"./core-DGLzDXWl.js";import{fE as ne,TJ as xe,TK as se,g8 as Ne,fD as Ve,TT as Pe,TM as Re,TN as Oe,p_ as Le,gl as je,TQ as b,TV as Ue,TW as Q,gm as Ze,TX as ze,D_ as He,h0 as Ye,cV as Ke,TY as We,g7 as qe,gn as Je}from"./zeni-epic-state-Dm2vDWXH.js";import{w as Qe,i as Xe,$ as ea,O as aa,d as ta,f as na,u as sa,c,g as oa,B as ia,z as ra,e as da,l as ca,S as la,r as ua,n as fa,o as X,L as ma,F as ha,H as ba,p as S,k as ee,x as pa,K as ae,C as ga,D as Sa}from"./index-DGjciFPC.js";import{D as Ta}from"./mui-BuJ3P0FU.js";import{u as ka}from"./InboxNotificationsProvider-Cf5DQSg3.js";import{u as Ea}from"./useTaskManagerAccess-i7vk79Wr.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]="29144485-f797-48fb-a3e2-2b3a8aa04f52",l._sentryDebugIdIdentifier="sentry-dbid-29144485-f797-48fb-a3e2-2b3a8aa04f52")}catch{}})();const Ca=Qe((({isAppContentDrawerOpen:l,handleDrawerToggle:i})=>{const{tenantEmailDomain:s}=$e(),a=Ge(),T=ea(),n=Me(),F=Ne(),r=te(),{useFeatureGate:d}=aa(),p=ta(),{isTaskManagerAccessEnabled:k}=Ea(p),o=t((e=>ne(e))),oe=o.masterTOSInfo?.isMasterTOSAccepted??!1,$=t((e=>Ve(e))),{status:ie}=t(Pe),G=$.uiState.currentChatSessionId,E=na(),{setLoading:re}=sa(),[w,M]=f.useState(void 0),A=D("/:tenantEmailDomain/dashboard")!==null,x=D("/:tenantEmailDomain/reports")!==null,m=D("/: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),V=t((e=>Re(e))),{isFeatureEnabled:C}=d(c.isReferralFeatureEnabled),_=t((e=>Oe(e)));f.useEffect((()=>{E&&C&&!m&&_.fetchState==="Not-Started"&&r(Le(!0))}),[E,C,_.fetchState,m]);const v=t((e=>e.tenantState)),fe=t((e=>v.fetchState==="Completed"?je(e):[])),g=t((e=>e.expenseAutomationViewState.selectedPeriodByTenantId)),{isFeatureEnabled:me}=d(c.isApAgingFeatureEnabled),{isFeatureEnabled:he}=d(c.isArAgingFeatureEnabled),P=ia(),{isFeatureEnabled:be}=d(c.isDashboardSidebarHalloweenAnimationEnabled),{isFeatureEnabled:pe}=d(c.isDashboardSidebarThanksGivingAnimationEnabled),{isFeatureEnabled:ge}=d(c.isDashboardSidebarChristmasAnimationEnabled),{isFeatureEnabled:Se}=d(c.isDashboardSidebarNewYearAnimationEnabled),Te=o.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",ke=t((e=>b(e).totalUnreadCount)),Ee=t((e=>b(e).reducedFetchCountState)),R=t((e=>b(e).notificationDetailsByTab.tasks.uiState.unreadCount)),O=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:j,isLoading:U,isFetchingMore:Z,hasFetchedAll:z,fetchMore:Ce}=ka();f.useEffect((()=>{const e=setTimeout((()=>Ce?.()),0);return()=>clearTimeout(e)})),f.useEffect((()=>{if(U===!1&&Z===!1&&z===!0)if(o?.companyId!=null&&j!=null){const e=`dashboard_${o.companyId}`;M(j.filter((u=>u.roomId===e&&u.readAt==null)).length)}else M(0)}),[U,Z,z]),f.useEffect((()=>{E&&k&&!m&&L.fetchState==="Not-Started"&&F.tenantId!=null&&r(Ue("task_manager","dashboard"))}),[E,k,m,L.fetchState,F.tenantId,r]),f.useEffect((()=>{m||I.fetchState!=="Not-Started"||r(Q({fetchCountState:{fetchState:"In-Progress",error:void 0}},"comments"))}),[m,I.fetchState,r]),f.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:Ee,count:ke},H=s!=null?ra.getSignedInUserTenant(s):null,Y=t((e=>H?.tenantId!=null?Ze(e,H.tenantId):void 0)),h=[];me===!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"),P===!1&&h.push("expense_automation_card");const K=t((e=>ze(e,h).fetchState)),W=t((e=>He(e).fetchState)),ye=A&&(K==="Completed"||K==="Error")||x&&(W==="Completed"||W==="Error")||!A&&!x?void 0:"disabled",we=f.useMemo((()=>Ye(o.userRole)),[o.userRole]),Ae=Ke(we),_e=o?.rewardsLastViewedTime==null,ve=p?.userEmail!=null&&V.fetchState==="Completed"&&We(V.notificationSettings,p.userEmail,N,o,k),q=da(),De=q&&ca(a);return B.jsx(Ta,{container:window.document.body,variant:"temporary",open:l,onClose:()=>i(!1),PaperProps:{sx:{width:240,zIndex:8,borderRight:"none",backgroundImage:"none"}},ModalProps:{keepMounted:!0},children:B.jsx(la,{signedInUser:p,currentTenantId:v.currentTenantId??"",tenants:v.fetchState==="Completed"?fe:Y!=null?[Y]:[],currentTenant:o,isTenantDropdownDisabled:ye,isSettings:X(a),isInvoicing:fa(a)&&ie==="completed",isSettingsFeatureEnabled:ue,isVendorsTabVisible:Ae,isZeniAccountEnabled:de,isChargeCardEnabled:le,isTreasuryEnabled:Te,isNotificationsTabVisible:ve,notificationCountDetails:Ie,isExpenseAutomationEnabledForUser:P,selectedMenu:ua(a),rewardsConfiguration:{isRewardsTabVisible:C,isRewardsAnimated:_e,rewardsPlan:_.rewardsPlan},isAiCfoAccessEnabled:q,onNotificationIconClick:()=>{i(!1);let e=R===0&&O>0?"notifications/comments":"notifications/tasks";X(a)&&(e=R===0&&O>0?"../../notifications/comments":"../../notifications/tasks");const u=S(a.state?.pathnameStackToGoBack,a.pathname);n(e,{state:{pathnameStackToGoBack:u}})},handleCockpitClick:()=>{window.open("/cockpit")},handleLogOutClick:()=>{i(!1);const e=S(a.state?.pathnameStackToGoBack,a.pathname);n("/signout",{replace:!0,state:{pathnameStackToGoBack:e,message:"logout"}})},handleMenuChange:e=>{if(i(!1),s==null)return;if(e.type==="invoicing")return void n(`../${s}/invoicing/overview`,{state:{pathnameStackToGoBack:S(a.state?.pathnameStackToGoBack,a.pathname),referrer:"Sidebar"}});if(e.type==="ai_cfo"){if(ee.trackAICFOChatScreenStateChanged("viewed","left_menu",G??null,null),!oe)return void pa({location:a,navigate:n,mergeState:{referrer:"Sidebar"}});const y=S(a.state?.pathnameStackToGoBack,a.pathname);return void n(`/${s}/ai-cfo/explore`,{state:{pathnameStackToGoBack:y,referrer:"Sidebar"}})}const u=S(a.state?.pathnameStackToGoBack,a.pathname),J=e.type,Be=ae(J)&&J!=="command_center";if(ae(e.type)&&g[o.tenantId]!=null&&ee.trackMonthEndCloseClicked(g[o.tenantId].month,g[o.tenantId].year,"Sidebar"),Be&&g[o.tenantId]!=null){const y=g[o.tenantId];return void n(`/${s}/month_end_close_checks/review/${e.type}/${y.month}-${y.year}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})}const Fe=ga(e.type);Sa(e.type)?(G!=null&&r(Je()),n(`/${s}/ai-cfo/${e.type}`,{state:{pathnameStackToGoBack:u.slice(0,-1),referrer:"Sidebar"}})):n(`/${s}/${Fe}`,{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(ma.TENANT_SWITCHING),i(!1),ha({dispatch:r,navigate:n,pathToNavigate:ba(e.tenantEmailDomain,a),selectedTenant:e,signedInUser:p})},onZeniLogoClick:()=>{T.toggle()},isAiCfo:De,aiCfoView:$,isOnDashboard:A,updateCurrentChatSessionId:e=>{r(qe({sessionId:e,agentId:"controller"})),n(`/${s}/ai-cfo/${e}`,{state:{...a.state}})},halloweenAnimationEnabled:be,isTaskManagerAccessEnabled:k,thanksGivingAnimationEnabled:pe,christmasAnimationEnabled:ge,newYearAnimationEnabled:Se})})})),Fa=l=>{const i=te(),s=t((T=>ne(T))),a={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(T,n)=>{Xe(n)&&xe(n.mode)==="dashboard"&&i(se({unreadCount:n.data.unread},"tasks"))}};return B.jsx(Ca,{...l,...a})};export{Fa as M};
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
import{j as e}from"./liveblocks-DRsJ0YIJ.js";import{h as r,l as i}from"./core-DGLzDXWl.js";import{am as n}from"./index-DGjciFPC.js";import"./mui-BuJ3P0FU.js";import"./sentry-G4ZANa8Z.js";import"./zeni-epic-state-Dm2vDWXH.js";import"./recharts-CJlXFxhv.js";import"./analytics-CvsRIk3B.js";import"./plaid-i7y7YD6O.js";import"./dnd-SnD389s6.js";import"./stripe-cKAAJElX.js";import"./lottie-DEqUWUd5.js";import"./lexical-CMBMntF_.js";import"./pdf-B_v4zyN7.js";import"./utils-Bz8wuSWM.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]="f2f6ef04-8019-4dfe-8bec-98d5efe59039",o._sentryDebugIdIdentifier="sentry-dbid-f2f6ef04-8019-4dfe-8bec-98d5efe59039")}catch{}})();const f=i(null,(function(o,t){return{onGoBack:()=>{t.navigate(-1)},onGoHome:()=>{t.navigate("/")}}}))(n);function _(){const o=r();return e.jsx(f,{navigate:o})}export{_ as default};
|