@zeniai/web-app-ui 5.3.69-dev → 5.3.69-qa
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/assets/{AccountMappingScreen-CAQA7lne.js → AccountMappingScreen-_ej4z-IR.js} +1 -1
- package/dist/assets/{ActualMatchingMatchDetailScreen-BifxUBTA.js → ActualMatchingMatchDetailScreen-BSTuCiFK.js} +1 -1
- package/dist/assets/{AddressRoutes-D2DM52hy.js → AddressRoutes-C517WDi1.js} +1 -1
- package/dist/assets/{AddressScreen-icxXA3w4.js → AddressScreen--Jfrmx_9.js} +1 -1
- package/dist/assets/{AiCfoScreen-BWbqBoIu.js → AiCfoScreen-BNc_vpRn.js} +1 -1
- package/dist/assets/{AppDrawer-hE6okzG9.js → AppDrawer-DNmwo9UW.js} +1 -1
- package/dist/assets/{BillPayApprovalRoutes-eAwSxg7-.js → BillPayApprovalRoutes-DGYCNZA8.js} +1 -1
- package/dist/assets/{BillPayRoutes-CPSa9tRu.js → BillPayRoutes-CjVYIUwf.js} +1 -1
- package/dist/assets/{BusinessVerificationPageScreen-XOO4dt2W.js → BusinessVerificationPageScreen-BCj56xYx.js} +1 -1
- package/dist/assets/{CardsAiCfoScreen-oZaMLLYZ.js → CardsAiCfoScreen-CQF7LKPV.js} +1 -1
- package/dist/assets/{ChargeCardRoutes-CR22MdW5.js → ChargeCardRoutes-D6qT0B9p.js} +1 -1
- package/dist/assets/{CompanyPassportScreen-Cy2hV9k7.js → CompanyPassportScreen-SOXe4P3g.js} +1 -1
- package/dist/assets/{ConnectionAuthScreen-BBARCtpg.js → ConnectionAuthScreen-Czc08mTJ.js} +1 -1
- package/dist/assets/{CustomerOnboardingAuthScreen-B9cNdta1.js → CustomerOnboardingAuthScreen-DHWDR-Cl.js} +1 -1
- package/dist/assets/{CustomerOnboardingRoutes-DaBtZTum.js → CustomerOnboardingRoutes-ByIsWpfM.js} +1 -1
- package/dist/assets/{DashboardRoutes-ksNQmz1b.js → DashboardRoutes-WoUbyotK.js} +1 -1
- package/dist/assets/{DefaultTenantHome-6h7pYNWH.js → DefaultTenantHome-Nt1b5wse.js} +1 -1
- package/dist/assets/{DomesticWireDetailScreen-BYIVpvay.js → DomesticWireDetailScreen-BmflEZ_q.js} +1 -1
- package/dist/assets/{DrawerScreen-D2sNIMxZ.js → DrawerScreen-0K7kuSzC.js} +1 -1
- package/dist/assets/{EntityDetailRoutes-DaTOqhWC.js → EntityDetailRoutes-CePCCMqT.js} +1 -1
- package/dist/assets/{ExpenseAutomationRoutes-WQsWVsrz.js → ExpenseAutomationRoutes-BiJEeP3A.js} +1 -1
- package/dist/assets/{FeaturePreviewScreen-DrW5sKTA.js → FeaturePreviewScreen-CtNAe1_H.js} +1 -1
- package/dist/assets/{HubSpotOAuthCallbackScreen-CDRkL0Tq.js → HubSpotOAuthCallbackScreen-DDXKwaXx.js} +1 -1
- package/dist/assets/{InvoicingRoutes-EwIfHCd8.js → InvoicingRoutes-Dt22Vt58.js} +1 -1
- package/dist/assets/{MagicLinkRoutes-Df_wnLE7.js → MagicLinkRoutes-DlZzQsp9.js} +1 -1
- package/dist/assets/{MagicLinkSignInScreen-CByT-Ct-.js → MagicLinkSignInScreen-_mXKvM1u.js} +1 -1
- package/dist/assets/{MobileAppDrawer-r4WOmIWX.js → MobileAppDrawer-BrOHAjwP.js} +1 -1
- package/dist/assets/{NotFoundScreen-BbJtMThz.js → NotFoundScreen-CyVGP3Vp.js} +1 -1
- package/dist/assets/{NotificationRoutes-CxCX3W_0.js → NotificationRoutes-Cmigr5ed.js} +1 -1
- package/dist/assets/{OAuthConsentScreen-luQCTUbA.js → OAuthConsentScreen-CLk1l_3O.js} +1 -1
- package/dist/assets/{PandLWithForecastRoutes-DNnwlAH1.js → PandLWithForecastRoutes-Bh5hYQzx.js} +1 -1
- package/dist/assets/{PaymentLinkScreen-C_1-1L8E.js → PaymentLinkScreen-CMriKz_8.js} +1 -1
- package/dist/assets/{PeopleRoutes-BInCnWy4.js → PeopleRoutes-sCx80LTz.js} +1 -1
- package/dist/assets/{PerformanceRoutes-cn6KpA4Q.js → PerformanceRoutes-C99Rjk0q.js} +1 -1
- package/dist/assets/{QBOConnectionScreen-Cbteo3If.js → QBOConnectionScreen-CzL0viYI.js} +1 -1
- package/dist/assets/{ReimbursementApprovalRoutes-pw9U836q.js → ReimbursementApprovalRoutes-D9FySrGh.js} +1 -1
- package/dist/assets/{ReimbursementApprovalRuleDetailScreen-Bs4p5t9E.js → ReimbursementApprovalRuleDetailScreen-DsMDfZXO.js} +1 -1
- package/dist/assets/{ReimbursementRoutes-BbvmwzbP.js → ReimbursementRoutes-BA1_AB5H.js} +1 -1
- package/dist/assets/{ReportsRoutes-DHQlYB_r.js → ReportsRoutes-ZTT__qgG.js} +1 -1
- package/dist/assets/{RewardsRoutes--4mAjEXA.js → RewardsRoutes-tAzEgpq8.js} +1 -1
- package/dist/assets/{ScheduleDetailsPrepaidExpensesScreen-DjYg30gm.js → ScheduleDetailsPrepaidExpensesScreen-kyZJN89C.js} +1 -1
- package/dist/assets/{ScreenRoutes-0M7Mtqep.js → ScreenRoutes-C4-I9-wk.js} +2 -2
- package/dist/assets/{SettingsRoutes-CN7GV-oe.js → SettingsRoutes-BUmZV8nU.js} +1 -1
- package/dist/assets/{SetupPagesScreen-BJMKj009.js → SetupPagesScreen-BzFDkOVI.js} +1 -1
- package/dist/assets/{SignInScreen-atM-bsdO.js → SignInScreen-DRFey9on.js} +1 -1
- package/dist/assets/{SignOutScreen-iiZR9Vvf.js → SignOutScreen-D2m0H2Zh.js} +1 -1
- package/dist/assets/{TaskListScreen-B70VtP2u.js → TaskListScreen-CxhPrz3Y.js} +1 -1
- package/dist/assets/{TaskRoutes-Bq52Yuvt.js → TaskRoutes-C0SyfIZR.js} +1 -1
- package/dist/assets/{TransactionDetailRoutes-DliVWUyB.js → TransactionDetailRoutes-BeM7Nvfr.js} +1 -1
- package/dist/assets/{TransactionDetailScreen-1gITEJfr.js → TransactionDetailScreen-BG6zUFU-.js} +1 -1
- package/dist/assets/{TransactionListRoutes-DoKdE5EQ.js → TransactionListRoutes-CnM0i_qu.js} +1 -1
- package/dist/assets/{TreasuryRoutes-DWmpGaGA.js → TreasuryRoutes-U7YfCj52.js} +1 -1
- package/dist/assets/{VendorsRoutes-B0HnUIhj.js → VendorsRoutes-B66p2onP.js} +1 -1
- package/dist/assets/{WiseConfirmationScreen-CmQFx7C9.js → WiseConfirmationScreen-CJytbhsa.js} +1 -1
- package/dist/assets/{ZeniAccountRoutes-BI-IsmW_.js → ZeniAccountRoutes-DRW5DlBI.js} +1 -1
- package/dist/assets/{ZeniAccountStatementScreen-CoNFUylV.js → ZeniAccountStatementScreen-B-cwN_qc.js} +1 -1
- package/dist/assets/{analyticsHelper-qAafKEWE.js → analyticsHelper-DdV5jqT5.js} +1 -1
- package/dist/assets/{getLocaleForTenant-Tff_ZVu3.js → getLocaleForTenant-C8sqw5jB.js} +1 -1
- package/dist/assets/{index-CaO8T0Mn.js → index-uoDX7H4L.js} +5 -5
- package/dist/assets/{routePaths-CIClX-hy.js → routePaths-DzLOO7Om.js} +1 -1
- package/dist/assets/{useActualMatchingMatchDetail-03OPYHW8.js → useActualMatchingMatchDetail-CM9S8AAl.js} +1 -1
- package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-BdGVlzMy.js → useAiCfoDashboardSuggestedQuestionsChips-BNl2X51l.js} +1 -1
- package/dist/assets/{useAskAiCfoHostNavButtonProps-BeCZgIua.js → useAskAiCfoHostNavButtonProps-CsMZr2YE.js} +1 -1
- package/dist/assets/{useChargeCardPusherEvents-Z8m3rGDA.js → useChargeCardPusherEvents-4gxE-aSe.js} +1 -1
- package/dist/assets/{useEmailConnectResultRefresh-xLk05vNk.js → useEmailConnectResultRefresh-B85Z7XsM.js} +1 -1
- package/dist/assets/{useInitialThreadRequest-Decdti18.js → useInitialThreadRequest-DGvbt9bY.js} +1 -1
- package/dist/assets/{useTaskManagerAccess-CSCgZk-0.js → useTaskManagerAccess-OjN4ZWFp.js} +1 -1
- package/dist/assets/{useTaskManagerPusherEvents-9oqzMu2Z.js → useTaskManagerPusherEvents-BDQMuf8L.js} +1 -1
- package/dist/assets/{withTransactionSidePanel-BKpEvUWX.js → withTransactionSidePanel-MoXr5b9J.js} +1 -1
- package/dist/index.html +1 -1
- package/package.json +1 -1
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import{j as c}from"./liveblocks-DtuUpF5h.js";import{a as r}from"./sentry-BWDuLt7o.js";import{u as L,h as _,i as F,j as k,t as W,l as O,s as q,g as Y,N as V,n as oe,o as x}from"./core-Dk5JD2l2.js";import{a8 as Xn,m as g,aq as R,V as d,cc as et,cd as nt,ce as tt,cf as it,cg as ot,ch as at,ci as ct,cj as st,ck as rt,cl as dt,cm as lt,cn as ut,p as Z,co as gt,cp as vt,z as J,ae as se,cq as mt,cr as pt,cs as St,ct as ft,cu as It,cv as ht,cw as Ct,cx as kt,cy as Et,cz as yt,Q as bt,ai as rn,cA as xt,cB as At,cC as Dt,cD as jt,cE as Lt,cF as _t,cG as Pt,cH as $t,cI as wt,cJ as Ft,cK as Rt,t as He,l as _e,cL as Tt,cM as Ot,cN as Mt,cO as Nt,cP as Ut,cQ as Bt,cR as Vt}from"./index-CaO8T0Mn.js";import"./mui-DAOUhz91.js";import{A as K}from"./AddressScreen-icxXA3w4.js";import M from"./NotFoundScreen-BbJtMThz.js";import{_0 as Ht,_1 as qt,vv as qe,_2 as G,v_ as re,_3 as Pe,_4 as de,wB as be,wI as Qt,wN as dn,_5 as $e,wF as ln,yf as Qe,vZ as ze,_6 as zt,_7 as un,wY as xe,_8 as le,x0 as Kt,_9 as Gt,_a as gn,x3 as vn,za as Jt,_b as Se,_c as Ke,_d as mn,vX as Wt,_e as Yt,vP as Zt,_f as Xt,ys as ei,_g as pn,yB as Ge,_h as ni,yy as ti,_i as we,gk as Fe,_j as te,_k as ie,xi as ii,w3 as Je,w8 as Sn,w6 as oi,w0 as ai,xb as ci,wa as si,xk as ri,_l as Ae,xt as fn,xr as fe,xp as ue,xo as di,_m as In,yH as We,_n as li,vY as hn,_o as Re,fI as Ie,wj as De,wg as je,wt as Cn,ws as Te,wd as ui,wm as kn,wv as ae,VN as En,v$ as Oe,wq as gi,wr as vi,wp as mi,_p as pi,x1 as Si,wZ as yn,_q as bn,vJ as Ye,_r as fi,vF as Ii,_s as hi,yN as Ci,yR as Q,yM as ki,xV as he,_t as Ei,_u as xn,y_ as Ze,_v as yi,yX as bi,_w as An,xY as xi,xZ as H,y0 as Ai,_x as Dn,ya as Ee,_y as Di,xj as jn,Uj as Ln,_z as ji,yk as Li,_A as _n,_B as _i,_C as Pi,_D as $i,zP as wi,_E as Fi,_F as Pn,z5 as $n,_G as wn,zN as ye,_H as Ri,zK as Ti,_I as Oi,_J as Mi,_K as Ni,_L as Ui,_M as Bi,_N as Xe,_O as Vi,ei as Hi,zT as qi,_P as Me,xD as Qi,xy as zi,_Q as ge,xO as Fn,xG as ve,xF as Ki,xJ as Rn,_R as Gi,xE as Ji,_S as Tn,zb as On,zC as en,zx as Wi,_T as Yi,zc as Zi,_U as Xi,zD as eo,zH as no,_V as Ne,wD as Mn,zo as to,wE as io,_W as oo,_X as Nn,c9 as ao,mv as co,mw as so,_Y as nn,wC as me,go as ro,mC as lo,zu as Un,A3 as uo,zr as Bn,v1 as go,uR as vo,hV as mo,UM as tn,UN as po,Gp as Vn,A0 as So,hN as fo,zZ as Io,_Z as ho,__ as Co,A9 as ko,A8 as Eo,_$ as yo,$0 as Hn,A6 as bo,$1 as xo,$2 as Ao,yo as Do,$3 as jo}from"./zeni-epic-state-BtP47QJT.js";import{M as Lo}from"./MobileAppDrawer-r4WOmIWX.js";import{q as pe}from"./QBOConnectionScreen-Cbteo3If.js";import"./recharts-BMD3jyO6.js";import"./analytics-C6U4wpfB.js";import"./plaid-DBHSfOGH.js";import"./dnd-CSZKLHxv.js";import"./stripe-cKAAJElX.js";import"./lottie-BlG_vWSt.js";import"./lexical-BtWXzxnq.js";import"./pdf-iocWnEuY.js";import"./utils-CWVNtCN5.js";import"./InboxNotificationsProvider-D6GwXgCp.js";import"./useTaskManagerAccess-CSCgZk-0.js";import"./empty-CDCQLT9Y.js";import"./pdf-lib-BLLTrAOR.js";import"./index-BzY7ptmA.js";import"./url-CCl9sM9J.js";import"./index-BFxiz-4U.js";import"./decodeURIComponentSafe-NBY1IhYb.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="a171b02d-5e47-4fd8-87b5-5abf2cbf8e39",t._sentryDebugIdIdentifier="sentry-dbid-a171b02d-5e47-4fd8-87b5-5abf2cbf8e39")}catch{}})();const w=({event:t,isReady:e=!0})=>e?c.jsx(Xn,{analytics:g,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function _o(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),{fetchState:m,hasMore:p,items:f,nextCursor:I,auditLogEntityRouteOptions:E,auditLogListSortFieldOptions:h}=k(Ht),y=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),D=`/${n??""}/invoicing`,b=r.useCallback(((P,U)=>{const T=qt(D,P,U,E);T!=null&&(g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{entity:P,entityId:U,fromScreen:"audit_log",toScreen:P}),e(T))}),[E,e,D]);r.useEffect((()=>{const P=setTimeout((()=>u(a)),300);return()=>clearTimeout(P)}),[a]),r.useEffect((()=>{i&&t(qe({filters:y,keepExistingListItems:!1,sort:v}))}),[i,y,v,t]);const A=m==="Not-Started"||m==="In-Progress"&&f.length===0,C=m==="In-Progress"&&f.length>0,j=m==="Completed";return N(m)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingAuditLogPage,isReady:j}),c.jsx(et,{auditLogEntityRouteOptions:E,auditLogListSortFieldOptions:h,entries:f,hasMore:p,isLoading:A,isLoadingMore:C,searchValue:a,sortState:l,onEntityLinkClick:b,onLoadMore:()=>{p&&I!=null&&t(qe({cursor:I,filters:y,keepExistingListItems:!0,sort:v}))},onSearchChange:o,onSortChange:S})]})}function Ce(t,e=!1){const n=L(),i=k((s=>G(s).productNextCursor!=null)),a=k((s=>G(s).productNextCursor)),o=k((s=>G(s).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&o!=="Not-Started"||n(re({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&o!=="In-Progress"&&i&&a!=null&&n(re({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,o,i,a])}function X(t,e,n,i){const[a,o]=r.useState(0),[s,u]=r.useState(!1),l=r.useRef(t);return r.useEffect((()=>{const S=l.current==="In-Progress";l.current=t,t==="Completed"&&S&&n!=null&&(u(!0),i(n))}),[t,n,i]),r.useEffect((()=>{s&&!e&&(u(!1),o((S=>S+1)))}),[s,e]),a}const Po=new Set(["plan"]),$o=O((function(t,e){const{view:n}=e;return{applicableItemOptions:n.applicableItemOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboClassHierarchy:n.qboClassHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:n.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",itemId:e.itemId,localData:n.localData,plan:n.plan}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${n}/catalog`),onLifecycleAction:i!==""?a=>{i!==""&&(g.trackInvoicingActionClick(d.Event.invoicingCatalogItemLifecycleAction,{action:a,fromScreen:"catalog_item_detail",itemId:i}),t(ln({action:a,id:i})))}:void 0,onEditChange:a=>{i!==""&&t($e({id:i,localData:a}))},onSaveEdit:()=>{g.trackInvoicingActionClick(d.Event.invoicingCatalogItemEdited,{itemId:i}),t(dn({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&t(Qt({action:o,id:a,parentItemId:i}))}}}))(nt);function wo(){const t=L(),e=_(),{item_id:n,tenantEmailDomain:i}=F(),[a]=W(),{areTenantIdsInSync:o}=R(),s=(u=a.get("kind"))!=null&&Po.has(u)?u:"plan";var u;const l=k((y=>Pe(y,n))),{pageFetchState:S}=l,v=S.fetchState;r.useEffect((()=>(t(de({id:n})),()=>{t(de({id:n}))})),[t,n]),r.useEffect((()=>{o&&t(be({id:n,kind:s}))}),[o,n,s,t]);const m=r.useCallback((y=>t(be({cacheOverride:!0,id:y,kind:s}))),[t,s]),p=X(l.fetchState,l.isFormLoading,n,m),f=v==="Completed"&&!l.isFormLoading;Ce(o,!0);const[I,E]=r.useState(f?n:void 0);r.useEffect((()=>{n!=null&&f&&E(n)}),[n,f]);const h=I!==n&&(v==="Not-Started"||v==="In-Progress"||l.isFormLoading);return N(v)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCatalogItemDetailPage,isReady:f}),c.jsx($o,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:s,isLoading:h,view:l},p)]})}const Fo=new Set(["addon","charge","plan"]),Ro=new Set(["plan"]),To=O((function(t,e){const n=Pe(t,e.itemId);return{fieldHelp:n.fieldHelp,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,applicabilityValues:n.applicabilityValues,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,applicableItemOptions:n.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save catalog item.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,pricingModelValues:n.pricingModelValues,prorationValues:n.prorationValues,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,tierTypeValues:n.tierTypeValues}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.isEdit?"edit":"create",{itemId:a}=e,o=a!=null?`${n}/catalog/${encodeURIComponent(a)}`:`${n}/catalog`;return{onBack:()=>e.navigate(o),onCancel:()=>{g.trackInvoicingActionClick(d.Event.invoicingCatalogItemFormCancelled),t(de({id:a})),e.navigate(`${n}/catalog`)},onChange:s=>{t($e({id:a,localData:s}))},onSubmit:()=>{g.trackInvoicingActionClick(d.Event.invoicingCatalogItemSaved,{mode:i}),t(dn({id:a}))}}}))(tt);function Oo(){const t=L(),e=_(),{item_id:n,tenantEmailDomain:i}=F(),[a]=W(),{areTenantIdsInSync:o}=R(),s=n!=null,u=a.get("type"),l=u!=null&&Fo.has(u)?u:void 0,S=(v=a.get("kind"))!=null&&Ro.has(v)?v:"plan";var v;const m=k((p=>Pe(p,n)));return Ce(o,!0),r.useEffect((()=>{o&&t(be({id:n,kind:S}))}),[o,n,S,t]),r.useEffect((()=>{s||l==null||m.localData.catalogType===l||t($e({localData:{...m.localData,catalogType:l}}))}),[s,l,m.localData?.catalogType,t]),r.useEffect((()=>{if(m.fetchState==="Completed"){const p=m.savedItemId??n,f=p!=null?`/${i}/invoicing/catalog/${encodeURIComponent(p)}`:`/${i}/invoicing/catalog`;e(f),t(de({id:n}))}}),[m.fetchState,m.savedItemId,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCatalogItemFormPage}),c.jsx(To,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:s,itemId:n})]})}const Mo={addons:"addon",all:"item",charges:"charge",plans:"plan"},No=O((function(t,e){const n=G(t),i=e.activeTab==="plans",a=e.activeTab==="all",o=i?n.plans:a?[...n.plans,...n.products]:n.products,s=i||a&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:a&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:s==="Not-Started"||s==="In-Progress"&&o.length===0,isLoadingMore:s==="In-Progress"&&o.length>0,plans:n.plans,productColumns:n.productColumns,products:n.products}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",a=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const s=Mo[e.activeTab];g.trackInvoicingActionClick(d.Event.invoicingAddCatalogItemClicked,{itemType:s}),e.navigate(`${n}/catalog/new?type=${s}`)},onItemClick:(s,u)=>{g.trackInvoicingActionClick(d.Event.invoicingCatalogItemRowClicked,{itemId:u}),e.navigate(`${n}/catalog/${encodeURIComponent(u)}`)},onCatalogItemLifecycleAction:(s,u)=>{g.trackInvoicingActionClick(d.Event.invoicingCatalogItemLifecycleAction,{action:u,fromScreen:"catalog_list",itemId:s}),t(ln({action:zt(u),id:s}))},onLoadMore:()=>{if(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"catalog",tab:e.activeTab}),a)return e.planNextCursor!=null&&t(ze({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&t(re({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));o!=null&&t(i?ze({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):re({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(it);function Uo(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState("plans"),[l,S]=r.useState(""),[v,m]=r.useState(null),p=r.useMemo((()=>v!=null?{dir:v.direction,field:v.columnKey}:void 0),[v]),f=l.trim()!==""?l.trim():void 0,I=r.useMemo((()=>({search:f,type:"plan"})),[f]),E=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),h=k((P=>G(P))),y=h.planFilters.search,D=h.planSort,b=h.planNextCursor,A=h.productNextCursor,C=h.fetchState==="Completed",j=h.runningActionId??null;return r.useEffect((()=>{const P=setTimeout((()=>S(a)),300);return()=>clearTimeout(P)}),[a]),r.useEffect((()=>{i&&t(Qe({cacheOverride:!1,planFilters:I,productFilters:E,planSort:p,productSort:p}))}),[i,t,I,E,p]),r.useEffect((()=>{i&&(f!==y||p?.field!==D?.field||p?.dir!==D?.dir)&&t(Qe({cacheOverride:!0,planFilters:I,productFilters:E,planSort:p,productSort:p}))}),[y,D,i,t,I,E,f,p]),N(h.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCatalogPage,isReady:C}),c.jsx(No,{navigate:e,tenantEmailDomain:n,activeTab:s,searchValue:a,sortState:v,planFilters:I,productFilters:E,sort:p,planNextCursor:b,productNextCursor:A,runningCatalogItemActionId:j,onSearchChange:o,onTabChange:u,onSortChange:m})]})}const Bo=O((function(t,e){const n=un(t,e.couponId);return{fieldHelp:n.fieldHelp,applyOnOptions:n.applyOnOptions,discountTypeOptions:n.discountTypeOptions,durationTypeOptions:n.durationTypeOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save coupon.":void 0,isQboConnected:n.isQboConnected,isQboPickerDataLoading:n.isQboPickerDataLoading,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,periodUnitOptions:n.periodUnitOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,a=i!=null?"edit":"create",o=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>e.navigate(o),onCancel:()=>{g.trackInvoicingActionClick(d.Event.invoicingCouponFormCancelled),t(le({id:i})),e.navigate(`${n}/discounts`)},onChange:s=>{t(Gt({id:i,localData:s}))},onSubmit:()=>{g.trackInvoicingActionClick(d.Event.invoicingCouponSaved,{mode:a}),t(Kt({id:i}))}}}))(ot);function Vo(){const t=L(),e=_(),{coupon_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=R(),{fetchState:o,savedCouponId:s}=k((u=>un(u,n)));return r.useEffect((()=>{a&&t(xe({id:n}))}),[a,n,t]),r.useEffect((()=>{if(o==="Completed"){const u=s??n,l=u!=null?`/${i}/invoicing/discounts/${encodeURIComponent(u)}`:`/${i}/invoicing/discounts`;e(l),t(le({id:n}))}}),[o,s,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCouponFormPage}),c.jsx(Bo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Ho=O((function(t){const e=gn(t);return{fieldHelp:e.fieldHelp,customers:e.customers,planNames:e.planNames,errorMessage:e.fetchState==="Error"?e.error?.message??"Failed to create invoice. Please try again.":void 0,isSubmitting:e.fetchState==="In-Progress",localData:e.localData,settings:e.settings}}),(function(t){return{dispatch:t}}),(function(t,{dispatch:e},n){const i=`/${n.tenantEmailDomain}/invoicing`;return{...t,onCancel:()=>{g.trackInvoicingActionClick(d.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:a=>{e(mn(a))},onSubmit:()=>{const a=Yt(t.localData);g.trackInvoicingActionClick(d.Event.invoicingInvoiceCreated,{customerId:a.customer_id,lineItemCount:a.line_items?.length}),e(Zt(a))}}}))(ct);function qo(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),[i]=W(),{areTenantIdsInSync:a}=R(),o=i.get("customerId"),s=k((b=>gn(b))),u=s.fetchState,l=s.localData,S=s.savedInvoiceId,v=k(vn),m=k((b=>Jt(b))),p=k(Se),f=m.fetchState==="Not-Started"||m.fetchState==="In-Progress"&&v==null,I=p.fetchState==="Not-Started"||p.fetchState==="In-Progress"&&p.customers.length===0,E=f||I,h=m.fetchState==="Completed"&&p.fetchState==="Completed";r.useEffect((()=>(t(Ke()),()=>{t(Ke())})),[t]);const y=r.useRef(!1);r.useEffect((()=>{y.current||o==null||o===""||l.customerId!==""||(y.current=!0,t(mn({...l,customerId:o})))}),[o,l,t]),r.useEffect((()=>{a&&t(Wt({cacheOverride:!1}))}),[a,t]);const D=r.useRef(u);return r.useEffect((()=>{const b=D.current;if(D.current=u,b!=="Completed"&&u==="Completed"){const A=S!=null?`/${n}/invoicing/invoices/${encodeURIComponent(S)}`:`/${n}/invoicing/invoices`;e(A)}}),[u,S,e,n]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCreateInvoicePage,isReady:h}),E?c.jsx(at,{}):c.jsx(Ho,{navigate:e,tenantEmailDomain:n})]})}const Qo=O((function(t,e){const{detailView:n}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:n.creditNote,creditNoteId:e.creditNoteId,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${n}/credits`),onCustomerClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(st);function zo(){const t=L(),e=_(),{credit_note_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=R(),o=k((u=>Xt(u,n??""))),s=o.fetchState==="Completed";return r.useEffect((()=>{a&&n!=null&&t(ei({id:n}))}),[a,n,t]),N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCreditDetailPage,isReady:s}),c.jsx(Qo,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:o})]})}const Ko=O((function(t){const e=pn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",creditNotes:e.creditNotes,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.creditNotes.length===0,isLoadingMore:n==="In-Progress"&&e.creditNotes.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"credits",status:e.activeStatus}),t(ti({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(rt);function Go(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,creditNoteListFetchState:h}=k((D=>{const b=pn(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,creditNoteListFetchState:b.fetchState}}),q),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(Ge({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Ge({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCreditsListPage,isReady:y}),c.jsx(Ko,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:l,filters:m,sort:v,nextCursor:E,onSearchChange:o,onStatusChange:D=>t(ni(D)),onSortChange:S})]})}const qn=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},Jo=O((function(t,e){const{editView:n,hasLoadedRecord:i}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,hasUnsavedBillingAddress:n.hasUnsavedBillingAddress,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:!i&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),hasPaymentLinkEmailPreviewFailed:n.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:n.emailPreviewFetchState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",paymentLinkEmailPreview:n.emailPreview,isSendingPaymentLink:n.record.sendLinkState.fetchState==="In-Progress",localData:n.localData,paymentMethods:n.record.paymentMethods,sendPaymentLinkErrorMessage:n.record.sendLinkState.fetchState==="Error"?n.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:n.record.stripeConnected}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${n}/customers`),onChange:a=>{t(Ae({id:i,localData:a}))},onCreateInvoice:()=>{g.trackInvoicingActionClick(d.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onCreatePromotionalCredits:()=>{g.trackInvoicingActionClick(d.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customer_detail"}),e.onCreatePromotionalCredits()},onNewSubscription:()=>{g.trackInvoicingActionClick(d.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`)},onDiscardEdit:()=>{t(fe(ue)),t(di({id:i}))},onOpenAddress:()=>{const a=qn(e.tenantEmailDomain??"",ue,i),o=Z(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:a=>{g.trackInvoicingActionClick(d.Event.invoicingCustomerEdited,{customerId:i}),t(Ae({id:i,localData:a})),t(fn({id:i}))},onFetchPaymentLinkEmailPreview:a=>t(ri({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,s)=>{g.trackInvoicingActionClick(d.Event.invoicingPaymentLinkSent,{customerId:i,fromScreen:"customer_detail"}),t(si({body:s,customerId:i,email:a,subject:o}))},onSubscriptionClick:a=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)}}}))(ut);function Wo(){const t=L(),e=_(),n=Y(),{customer_id:i,tenantEmailDomain:a}=F(),{areTenantIdsInSync:o}=R(),s=k((T=>we(T,i))),u=s.pageFetchState.fetchState,l=u==="Completed"&&!s.isFormLoading,[S,v]=r.useState(!1),[m,p]=r.useState(!1),[f,I]=r.useState(l?i:void 0);r.useEffect((()=>{i!=null&&l&&I(i)}),[i,l]);const E=f===i,{plaidTokenFetchState:h,promotionalCreditSubmitState:y}=s,{paymentMethodSaveState:D,setupIntentFetchState:b,stripeConnected:A}=s.record,C=r.useRef(s.record.sendLinkState.fetchState);r.useEffect((()=>{const T=s.record.sendLinkState.fetchState;C.current!=="Error"&&T==="Error"&&t(Fe({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),C.current=T}),[t,s.record.sendLinkState.fetchState]);const j=b.fetchState==="Error"?b.error?.message??"Failed to start card setup.":D.fetchState==="Error"?D.error?.message??"Failed to save payment method.":h.fetchState==="Error"?h.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(t(te()),t(ie()),()=>{t(te()),t(ie())})),[t]),r.useEffect((()=>{n.state?.openPromotionalCreditsDialog===!0&&(p(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{o&&i!=null&&t(ii({id:i}))}),[o,i,t]),r.useEffect((()=>{o&&i!=null&&A&&t(Je({customerId:i}))}),[o,i,t,A]);const P=r.useCallback((T=>t(Sn({id:T}))),[t]),U=X(s.fetchState,s.isFormLoading,i,P);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCustomerDetailPage,isReady:l}),c.jsx(Jo,{customerId:i??"",editView:s,hasLoadedRecord:E,location:n,navigate:e,tenantEmailDomain:a,onAddPaymentMethod:()=>{g.trackInvoicingActionClick(d.Event.invoicingPaymentMethodAddClicked,{customerId:i??"",fromScreen:"customer_detail"}),t(te()),i!=null&&A&&t(Je({customerId:i})),v(!0)},onCreatePromotionalCredits:()=>{t(ie()),p(!0)}},U),c.jsx(dt,{errorMessage:j,isCreatingSetupIntent:b.fetchState==="In-Progress",isSaving:D.fetchState==="In-Progress",open:S,plaidLinkToken:s.record.plaidLinkToken,saveSucceeded:D.fetchState==="Completed",setupIntent:s.record.setupIntent,stripeConnected:A,onChooseCard:()=>{i!=null&&t(ai({customerId:i}))},onClose:()=>{v(!1),t(te())},onSavePaymentMethod:T=>{i!=null&&(g.trackInvoicingActionClick(d.Event.invoicingPaymentMethodSaved,{customerId:i,fromScreen:"customer_detail"}),t(oi({customerId:i,data:T})))}}),c.jsx(lt,{currentBalance:s.record.invoicingCustomer?.promotionalCredits,currencyCode:s.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:y.fetchState==="Error"?y.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:y.fetchState==="In-Progress",open:m,submitSucceeded:y.fetchState==="Completed",onClose:()=>{p(!1),t(ie())},onSubmit:({amount:T,description:ne})=>{i!=null&&(g.trackInvoicingActionClick(d.Event.invoicingPromotionalCreditsAdded,{amount:T,customerId:i,fromScreen:"customer_detail"}),t(ci({amount:T,customerId:i,currencyCode:s.record.invoicingCustomer?.preferredCurrencyCode,description:ne})))}})]})}const Yo=O((function(t,e){const n=we(t,e.customerId);return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save customer.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,a=i!=null?"edit":"create",o=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>e.navigate(o),onCancel:()=>{g.trackInvoicingActionClick(d.Event.invoicingCustomerFormCancelled),t(In({id:i})),t(fe(ue)),e.navigate(`${n}/customers`)},onChange:s=>{t(Ae({id:i,localData:s}))},onOpenAddress:()=>{g.trackInvoicingActionClick(d.Event.invoicingAddressOpened,{entity:"customer",fromScreen:"customer_form"});const s=qn(e.tenantEmailDomain??"",ue,i),u=Z(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(s,{state:{pathnameStackToGoBack:u}})},onSubmit:()=>{g.trackInvoicingActionClick(d.Event.invoicingCustomerSaved,{mode:a}),t(fn({id:i}))}}}))(gt);function Zo(){const t=L(),e=_(),n=Y(),{customer_id:i,tenantEmailDomain:a}=F(),{areTenantIdsInSync:o}=R(),{fetchState:s,savedCustomerId:u}=k((l=>we(l,i)));return r.useEffect((()=>{o&&i!=null&&t(Sn({id:i}))}),[o,i,t]),r.useEffect((()=>{if(s==="Completed"){const l=u??i,S=l!=null?`/${a}/invoicing/customers/${encodeURIComponent(l)}`:`/${a}/invoicing/customers`;e(S),t(In({id:i}))}}),[s,u,i,t,e,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCustomerFormPage}),c.jsx(Yo,{customerId:i,location:n,navigate:e,tenantEmailDomain:a})]})}const Xo=O((function(t){const e=Se(t),{fetchState:n}=e;return{addressesById:t.addressState.addressesById,columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",customers:e.customers,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.customers.length===0,isLoadingMore:n==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{g.trackInvoicingActionClick(d.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,a)=>{switch(a){case"createInvoice":g.trackInvoicingActionClick(d.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":g.trackInvoicingActionClick(d.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":g.trackInvoicingActionClick(d.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"customers",status:e.activeStatus}),t(hn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(vt);function ea(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,customerListFetchState:h}=k((D=>{const b=Se(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,customerListFetchState:b.fetchState}}),q),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(We({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(We({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCustomersListPage,isReady:y}),c.jsx(Xo,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:l,filters:m,sort:v,nextCursor:E,onSearchChange:o,onStatusChange:D=>t(li(D)),onSortChange:S})]})}const Le=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),na=O((function(t,e){const{authParams:n,csvDownloadUrl:i,filters:a,sessionId:o,view:s}=e,u=o==null?void 0:s.diagnosticsBySession[o],l=u?.fetch.fetchState??"Not-Started";return{authParams:n,csvDownloadUrl:i,diagnostics:u?.items??[],errorMessage:l==="Error"?u?.fetch.error?.message:void 0,expired:u?.expired??!1,filters:a,hasMore:u?.nextCursor!=null,isLoading:l==="Not-Started"||l==="In-Progress",isLoadingMore:l==="In-Progress"&&(u?.items.length??0)>0,session:Le(s,o)}}),(function(t,e){const{filters:n,navigate:i,sessionId:a,tenantEmailDomain:o,view:s}=e,u=a==null?void 0:s.diagnosticsBySession[a],l=Le(s,a),S=s.actionStateByKind.retry?.fetchState==="In-Progress",v=s.actionStateByKind.rollback?.fetchState==="In-Progress",m=l?.status==="done"&&l.rollback_available_until!=null&&new Date(l.rollback_available_until).getTime()>Date.now()&&!v;return{onBack:()=>i(`/${o}/invoicing/data_import`),onDownloadCsv:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"download_csv",fromScreen:"data_import_detail",sessionId:a})},onDownloadError:()=>{t(Fe({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{a!=null&&u?.nextCursor!=null&&t(je({...n,cursor:u.nextCursor,sessionId:a}))},onRetry:l?.status!=="failed"||S?void 0:()=>{a!=null&&(g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_detail",sessionId:a}),t(Te(a)))},onRollback:m?()=>{a!=null&&(g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"rollback",fromScreen:"data_import_detail",sessionId:a}),t(Cn(a)))}:void 0}}))(mt);function ta(){const t=L(),e=_(),{sessionId:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=R(),[o,s]=r.useState({}),u=k(Re),l=k(Ie),S=r.useMemo((()=>{const E=J.getSignedInUser();return{userId:E?.userId??"",sessionId:E?.zeniSessionId??"",tenantId:l.tenantId}}),[l.tenantId]),v=Le(u,n),m=n==null?void 0:u.diagnosticsBySession[n];r.useEffect((()=>{a&&n!=null&&t(De(n))}),[a,t,n]),r.useEffect((()=>{if(!a||n==null)return;const E=setTimeout((()=>{t(je({...o,sessionId:n}))}),300);return()=>clearTimeout(E)}),[a,t,o,n]);const p=v?.status==="scanning"||v?.status==="importing";r.useEffect((()=>{if(!a||n==null||!p)return;const E=setInterval((()=>{t(De(n)),t(je({...o,sessionId:n}))}),3e3);return()=>clearInterval(E)}),[a,t,o,p,n]);const f=r.useMemo((()=>{if(n==null)return"";const E=new URLSearchParams;o.moduleId!=null&&E.set("module_id",o.moduleId),o.level!=null&&E.set("level",o.level),o.outcome!=null&&E.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&E.set("search",o.search.trim());const h=E.toString();return`${se?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${h===""?"":`?${h}`}`}),[o,n]),I=m?.fetch.fetchState??"Not-Started";return N(I)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingDataImportDetailPage,isReady:v!=null&&I!=="Not-Started"}),c.jsx(na,{authParams:S,csvDownloadUrl:f,filters:o,navigate:e,sessionId:n,tenantEmailDomain:i,view:u,onFiltersChange:s})]})}const Qn=t=>`invoicing_active_migration:${t}`,ce=(t,e)=>{if(t!=null&&t!=="")try{const n=Qn(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},ia=O((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:a,statusRows:o}=e.view;return{isLoading:!(a.fetchState!=="Not-Started"&&a.fetchState!=="In-Progress"||o.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:o}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,a=o=>{const s=o??null;t(ae(s)),ce(i,s),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),a(o)},onNewImport:()=>{g.trackInvoicingActionClick(d.Event.invoicingNewImportClicked),a()},onRetrySession:o=>{g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),t(Te(o)),a(o)},onRollbackSession:o=>{g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),t(Cn(o))},onViewSession:o=>{g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),n(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(pt);function oa(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),a=k(Re);r.useEffect((()=>{i&&(t(ui()),t(kn()))}),[i,t]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingDataImportHubPage,isReady:o}),c.jsx(ia,{navigate:e,tenantEmailDomain:n,view:a})]})}const aa=O((function(t,e){const{activeId:n,authParams:i,integrationsView:a,settings:o,templatesDownloadUrl:s,view:u}=e,{actionStateByKind:l,sessionDetail:S,sessions:v}=u,m=a.externalConnections?.revenue?.find((f=>f.connectionName==="chargebee")),p=n!=null?S[n]:void 0;return{authParams:i,templatesDownloadUrl:s,chargebeeConnected:o?.chargebee_connected===!0||(m?.isValid??!1),chargebeeConnectorAvailable:m!=null,chargebeeSite:o?.chargebee_site,connectError:l.connect?.error?.message,connecting:l.connect?.fetchState==="In-Progress",retrying:l.retry?.fetchState==="In-Progress",session:p??v.find((f=>f.id===n)),starting:l.start?.fetchState==="In-Progress",uploading:l.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:a}=e;return{onBack:e.onBack,onDownloadError:()=>{t(Fe({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onDownloadTemplates:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportTemplatesDownloaded)},onFetchFromChargebee:()=>{g.trackInvoicingActionClick(d.Event.invoicingChargebeeConnectClicked),t(mi())},onGoToIntegrations:()=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"settings_integrations"}),i(`/${a}/invoicing/settings`)},onGoToOverview:()=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"overview"}),i(`/${a}/invoicing/overview`)},onRetry:()=>{n!=null&&(g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_migrate",sessionId:n}),t(Te(n)))},onSaveLater:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportStarted),n!=null&&t(vi(n))},onUpload:o=>{g.trackInvoicingActionClick(d.Event.invoicingImportFileUploaded),t(gi({files:o}))},onViewDetails:n==null?void 0:()=>i(`/${a}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(St);function ca(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),a=k(vn),o=k(Ie),s=r.useMemo((()=>{const h=J.getSignedInUser();return{userId:h?.userId??"",sessionId:h?.zeniSessionId??"",tenantId:o.tenantId}}),[o.tenantId]),u=`${se?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/templates`,l=o.companyId??J.getSignedInUserTenant(n??"")?.companyId,S=k((h=>En(h,l))),v=k(Re),{activeMigrationSessionId:m}=v,p=m??void 0,f=p!=null?v.sessionDetail[p]??v.sessions.find((h=>h.id===p)):void 0;r.useEffect((()=>{i&&(t(Oe()),t(kn()))}),[i,t]),r.useEffect((()=>{if(m!=null)return;const h=(y=>{if(y==null||y==="")return null;try{return sessionStorage.getItem(Qn(y))}catch{return null}})(n);h!=null&&t(ae(h))}),[m,t,n]),r.useEffect((()=>{ce(n,m)}),[m,n]);const I=f?.status,E=I==="scanning"||I==="importing";return r.useEffect((()=>{if(!i||p==null||!E)return;const h=setInterval((()=>{t(De(p))}),3e3);return()=>clearInterval(h)}),[i,p,E,t]),r.useEffect((()=>{I==="done"&&(t(ae(null)),ce(n,null))}),[t,I,n]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingDataImportMigratePage}),c.jsx(aa,{activeId:p,authParams:s,integrationsView:S,navigate:e,settings:a,templatesDownloadUrl:u,tenantEmailDomain:n,view:v,onBack:()=>{t(ae(null)),ce(n,null),e(`/${n}/invoicing/data_import`)}})]})}const sa=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,discountsAccountName:n.discountsAccountName,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${n}/discounts`),onLifecycleAction:a=>{g.trackInvoicingActionClick(d.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discount_detail",status:e.editView.coupon?.status}),t(yn({action:a,id:i}))},onSaveEdit:a=>{g.trackInvoicingActionClick(d.Event.invoicingCouponEdited,{couponId:i}),t(Si({data:a,id:i}))}}}))(ft);function ra(){const t=L(),e=_(),{coupon_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=R(),o=k((I=>pi(I,n))),s=o.actionState.fetchState==="In-Progress",u=o.pageFetchState.fetchState,l=u==="Completed",[S,v]=r.useState(l?n:void 0);r.useEffect((()=>{n!=null&&l&&v(n)}),[n,l]);const m=S===n;r.useEffect((()=>(t(le({id:n})),()=>{t(le({id:n}))})),[n,t]),r.useEffect((()=>{a&&t(xe({id:n}))}),[a,n,t]);const p=r.useCallback((I=>t(xe({cacheOverride:!0,id:I}))),[t]),f=X(o.fetchState,o.isFormLoading,n,p);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingDiscountDetailPage,isReady:l}),c.jsx(sa,{hasLoadedRecord:m,couponId:n??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:s,navigate:e,tenantEmailDomain:i},f)]})}const da=O((function(t){const e=bn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,discountLifecycleActionOptions:e.discountLifecycleActionOptions,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",coupons:e.coupons,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.coupons.length===0,isLoadingMore:n==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{g.trackInvoicingActionClick(d.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,a)=>{g.trackInvoicingActionClick(d.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discounts_list"}),t(yn({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"discounts",status:e.activeStatus}),t(Ii({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(It);function la(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,couponListFetchState:h,runningDiscountActionId:y}=k((b=>{const A=bn(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,couponListFetchState:A.fetchState,runningDiscountActionId:A.runningActionId??null}}),q),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(Ye({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Ye({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingDiscountsListPage,isReady:D}),c.jsx(da,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:l,filters:m,sort:v,nextCursor:E,runningDiscountActionId:y,onSearchChange:o,onStatusChange:b=>t(fi(b)),onSortChange:S})]})}const ua=O((function(t,e){const{readView:n}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:n.dunningCase,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,a=i!=="",{dunningCase:o}=e.readView,s={amount:o?.amount?.amount,caseId:i,customerId:o?.customerID,invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID};return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:u=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:u,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(u)}`)},onCancel:a?()=>{g.trackInvoicingActionClick(d.Event.invoicingDunningAction,{...s,action:"cancel",fromScreen:"dunning_detail"}),t(Q({action:"cancel",id:i}))}:void 0,onResolve:a?()=>{g.trackInvoicingActionClick(d.Event.invoicingDunningAction,{...s,action:"resolve",fromScreen:"dunning_detail"}),t(Q({action:"resolve",id:i}))}:void 0,onResume:a?()=>{g.trackInvoicingActionClick(d.Event.invoicingDunningAction,{...s,action:"resume",fromScreen:"dunning_detail"}),t(Q({action:"resume",id:i}))}:void 0,onRetry:a?()=>{g.trackInvoicingActionClick(d.Event.invoicingDunningAction,{...s,action:"retry",fromScreen:"dunning_detail"}),t(Q({action:"retry",id:i}))}:void 0}}))(Ct);function ga(){const t=L(),e=_(),{case_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=R(),o=k((C=>hi(C,n??""))),s=o.fetchState==="Completed",u=o.dunningCase?.invoiceID,[l,S]=r.useState("idle"),[v,m]=r.useState(!1),[p,f]=r.useState(),[I,E]=r.useState(!1),h=r.useCallback((()=>{S("idle"),m(!1),f(void 0),E(!1)}),[]),y=r.useCallback((()=>{if(n==null)return;t(Ci({id:n})),S("idle"),m(!1);const C=o.emailPreview.preview;f(C==null?void 0:{body:C.body,cc:C.cc,subject:C.subject,to:C.to}),E(!0)}),[n,t,o.emailPreview.preview]),D=r.useCallback((C=>{n!=null&&l!=="pending"&&(m(!1),S("pending"),g.trackInvoicingActionClick(d.Event.invoicingDunningAction,{action:"send-email",amount:o.dunningCase?.amount?.amount,caseId:n,customerId:o.dunningCase?.customerID,fromScreen:"dunning_detail",invoiceId:o.dunningCase?.invoiceID,status:o.dunningCase?.status,subscriptionId:o.dunningCase?.subscriptionID}),t(Q({action:"send-email",body:C,id:n})))}),[n,t,l,o.dunningCase]),b=r.useMemo((()=>o.emailPreview.preview==null?void 0:{bodyToken:o.emailPreview.preview.bodyToken,renderedHtmlTemplate:o.emailPreview.preview.renderedHtmlTemplate,subjectToken:o.emailPreview.preview.subjectToken}),[o.emailPreview.preview]);r.useEffect((()=>{a&&n!=null&&t(ki({id:n}))}),[a,n,t]),r.useEffect((()=>{a&&u!=null&&t(he({invoiceId:u}))}),[a,u,t]),r.useEffect((()=>{S("idle"),m(!1),f(void 0),E(!1)}),[n]),r.useEffect((()=>{a||(S("idle"),m(!1),f(void 0),E(!1))}),[a]),r.useEffect((()=>{I&&p==null&&o.emailPreview.preview!=null&&f({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,p,I]),r.useEffect((()=>{l==="pending"&&(o.actionState.fetchState!=="In-Progress"?v&&o.actionState.fetchState==="Completed"?(n!=null&&t(Ei({id:n})),h()):v&&o.actionState.fetchState==="Error"&&S("failed"):m(!0))}),[n,h,t,l,v,o.actionState.fetchState]);const A=u!=null&&o.linkedInvoice?.id===u?o.linkedInvoice.dunningAttempts:void 0;return N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingDunningDetailPage,isReady:s}),c.jsx(ua,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:o,dunningAttempts:A,onSendEmail:y}),c.jsx(ht,{initialDraft:p,isPreviewLoading:o.emailPreview.fetchState==="Not-Started"||o.emailPreview.fetchState==="In-Progress",isSending:l==="pending",onClose:h,onSend:D,open:I,preview:b,previewErrorMessage:o.emailPreview.fetchState==="Error"?o.emailPreview.error?.message:void 0,sendErrorMessage:l==="failed"?o.actionState.error?.message:void 0})]})}const va=O((function(t){const e=xn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:n==="In-Progress"&&e.dunningCases.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=a=>{const o=e.dunningCases.find((s=>s.id===a));return{amount:o?.amount?.amount,caseId:a,customerId:o?.customerID,fromScreen:"dunning_list",invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID}};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${n}/data_import`),onDunningCaseClick:a=>{g.trackInvoicingActionClick(d.Event.invoicingDunningCaseRowClicked,i(a)),e.navigate(`${n}/dunning/${encodeURIComponent(a)}`)},onRowAction:(a,o)=>{o!=="retry"&&o!=="resume"&&o!=="resolve"&&o!=="cancel"||(g.trackInvoicingActionClick(d.Event.invoicingDunningAction,{...i(a),action:o}),t(Q({action:o,id:a})))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"dunning",status:e.activeStatus}),t(bi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(kt);function ma(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,dunningCaseListFetchState:h,dunningCases:y}=k((b=>{const A=xn(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,dunningCaseListFetchState:A.fetchState,dunningCases:A.dunningCases}}),q),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(Ze({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Ze({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingDunningListPage,isReady:D}),c.jsx(va,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:l,filters:m,sort:v,dunningCases:y,nextCursor:E,onSearchChange:o,onStatusChange:b=>t(yi(b)),onSortChange:S})]})}const pa=O((function(t,e){const{view:n}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:n.billingAddress,invoice:n.invoice,invoiceId:e.invoiceId,shippingAddress:n.shippingAddress,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isSaving:n.actionState.fetchState==="In-Progress",isVoiding:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e,{invoice:a}=e.view,o={amount:a?.total?.amount,customerId:a?.customerID,invoiceId:i,status:a?.status};return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:s=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(s)}`)},onIssueCreditNote:()=>{g.trackInvoicingActionClick(d.Event.invoicingIssueCreditNoteClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{g.trackInvoicingActionClick(d.Event.invoicingRecordPaymentClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{g.trackInvoicingActionClick(d.Event.invoicingInvoiceRegenerated,{...o,fromScreen:"invoice_detail"}),t(H({action:"regenerate",invoiceId:i}))},onSaveEdit:s=>{g.trackInvoicingActionClick(d.Event.invoicingInvoiceEdited,{...o,fromScreen:"invoice_detail"}),t(Ai({data:{due_date:s.due_date!==""?s.due_date:void 0,notes:s.notes.trim()!==""?s.notes.split(`
|
|
1
|
+
import{j as c}from"./liveblocks-DtuUpF5h.js";import{a as r}from"./sentry-BWDuLt7o.js";import{u as L,h as _,i as F,j as k,t as W,l as O,s as q,g as Y,N as V,n as oe,o as x}from"./core-Dk5JD2l2.js";import{a8 as Xn,m as g,aq as R,V as d,cc as et,cd as nt,ce as tt,cf as it,cg as ot,ch as at,ci as ct,cj as st,ck as rt,cl as dt,cm as lt,cn as ut,p as Z,co as gt,cp as vt,z as J,ae as se,cq as mt,cr as pt,cs as St,ct as ft,cu as It,cv as ht,cw as Ct,cx as kt,cy as Et,cz as yt,Q as bt,ai as rn,cA as xt,cB as At,cC as Dt,cD as jt,cE as Lt,cF as _t,cG as Pt,cH as $t,cI as wt,cJ as Ft,cK as Rt,t as He,l as _e,cL as Tt,cM as Ot,cN as Mt,cO as Nt,cP as Ut,cQ as Bt,cR as Vt}from"./index-uoDX7H4L.js";import"./mui-DAOUhz91.js";import{A as K}from"./AddressScreen--Jfrmx_9.js";import M from"./NotFoundScreen-CyVGP3Vp.js";import{_0 as Ht,_1 as qt,vv as qe,_2 as G,v_ as re,_3 as Pe,_4 as de,wB as be,wI as Qt,wN as dn,_5 as $e,wF as ln,yf as Qe,vZ as ze,_6 as zt,_7 as un,wY as xe,_8 as le,x0 as Kt,_9 as Gt,_a as gn,x3 as vn,za as Jt,_b as Se,_c as Ke,_d as mn,vX as Wt,_e as Yt,vP as Zt,_f as Xt,ys as ei,_g as pn,yB as Ge,_h as ni,yy as ti,_i as we,gk as Fe,_j as te,_k as ie,xi as ii,w3 as Je,w8 as Sn,w6 as oi,w0 as ai,xb as ci,wa as si,xk as ri,_l as Ae,xt as fn,xr as fe,xp as ue,xo as di,_m as In,yH as We,_n as li,vY as hn,_o as Re,fI as Ie,wj as De,wg as je,wt as Cn,ws as Te,wd as ui,wm as kn,wv as ae,VN as En,v$ as Oe,wq as gi,wr as vi,wp as mi,_p as pi,x1 as Si,wZ as yn,_q as bn,vJ as Ye,_r as fi,vF as Ii,_s as hi,yN as Ci,yR as Q,yM as ki,xV as he,_t as Ei,_u as xn,y_ as Ze,_v as yi,yX as bi,_w as An,xY as xi,xZ as H,y0 as Ai,_x as Dn,ya as Ee,_y as Di,xj as jn,Uj as Ln,_z as ji,yk as Li,_A as _n,_B as _i,_C as Pi,_D as $i,zP as wi,_E as Fi,_F as Pn,z5 as $n,_G as wn,zN as ye,_H as Ri,zK as Ti,_I as Oi,_J as Mi,_K as Ni,_L as Ui,_M as Bi,_N as Xe,_O as Vi,ei as Hi,zT as qi,_P as Me,xD as Qi,xy as zi,_Q as ge,xO as Fn,xG as ve,xF as Ki,xJ as Rn,_R as Gi,xE as Ji,_S as Tn,zb as On,zC as en,zx as Wi,_T as Yi,zc as Zi,_U as Xi,zD as eo,zH as no,_V as Ne,wD as Mn,zo as to,wE as io,_W as oo,_X as Nn,c9 as ao,mv as co,mw as so,_Y as nn,wC as me,go as ro,mC as lo,zu as Un,A3 as uo,zr as Bn,v1 as go,uR as vo,hV as mo,UM as tn,UN as po,Gp as Vn,A0 as So,hN as fo,zZ as Io,_Z as ho,__ as Co,A9 as ko,A8 as Eo,_$ as yo,$0 as Hn,A6 as bo,$1 as xo,$2 as Ao,yo as Do,$3 as jo}from"./zeni-epic-state-BtP47QJT.js";import{M as Lo}from"./MobileAppDrawer-BrOHAjwP.js";import{q as pe}from"./QBOConnectionScreen-CzL0viYI.js";import"./recharts-BMD3jyO6.js";import"./analytics-C6U4wpfB.js";import"./plaid-DBHSfOGH.js";import"./dnd-CSZKLHxv.js";import"./stripe-cKAAJElX.js";import"./lottie-BlG_vWSt.js";import"./lexical-BtWXzxnq.js";import"./pdf-iocWnEuY.js";import"./utils-CWVNtCN5.js";import"./InboxNotificationsProvider-D6GwXgCp.js";import"./useTaskManagerAccess-OjN4ZWFp.js";import"./empty-CDCQLT9Y.js";import"./pdf-lib-BLLTrAOR.js";import"./index-BzY7ptmA.js";import"./url-CCl9sM9J.js";import"./index-BFxiz-4U.js";import"./decodeURIComponentSafe-NBY1IhYb.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new t.Error().stack;e&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[e]="a171b02d-5e47-4fd8-87b5-5abf2cbf8e39",t._sentryDebugIdIdentifier="sentry-dbid-a171b02d-5e47-4fd8-87b5-5abf2cbf8e39")}catch{}})();const w=({event:t,isReady:e=!0})=>e?c.jsx(Xn,{analytics:g,onLoad:n=>n.trackPageLoaded(t)}):null;function N(...t){return t.some((e=>e==="Error"))}function _o(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),{fetchState:m,hasMore:p,items:f,nextCursor:I,auditLogEntityRouteOptions:E,auditLogListSortFieldOptions:h}=k(Ht),y=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),D=`/${n??""}/invoicing`,b=r.useCallback(((P,U)=>{const T=qt(D,P,U,E);T!=null&&(g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{entity:P,entityId:U,fromScreen:"audit_log",toScreen:P}),e(T))}),[E,e,D]);r.useEffect((()=>{const P=setTimeout((()=>u(a)),300);return()=>clearTimeout(P)}),[a]),r.useEffect((()=>{i&&t(qe({filters:y,keepExistingListItems:!1,sort:v}))}),[i,y,v,t]);const A=m==="Not-Started"||m==="In-Progress"&&f.length===0,C=m==="In-Progress"&&f.length>0,j=m==="Completed";return N(m)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingAuditLogPage,isReady:j}),c.jsx(et,{auditLogEntityRouteOptions:E,auditLogListSortFieldOptions:h,entries:f,hasMore:p,isLoading:A,isLoadingMore:C,searchValue:a,sortState:l,onEntityLinkClick:b,onLoadMore:()=>{p&&I!=null&&t(qe({cursor:I,filters:y,keepExistingListItems:!0,sort:v}))},onSearchChange:o,onSortChange:S})]})}function Ce(t,e=!1){const n=L(),i=k((s=>G(s).productNextCursor!=null)),a=k((s=>G(s).productNextCursor)),o=k((s=>G(s).productFetchState.fetchState));r.useEffect((()=>{t&&(e&&o!=="Not-Started"||n(re({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[t,n,e]),r.useEffect((()=>{t&&o!=="In-Progress"&&i&&a!=null&&n(re({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[t,n,o,i,a])}function X(t,e,n,i){const[a,o]=r.useState(0),[s,u]=r.useState(!1),l=r.useRef(t);return r.useEffect((()=>{const S=l.current==="In-Progress";l.current=t,t==="Completed"&&S&&n!=null&&(u(!0),i(n))}),[t,n,i]),r.useEffect((()=>{s&&!e&&(u(!1),o((S=>S+1)))}),[s,e]),a}const Po=new Set(["plan"]),$o=O((function(t,e){const{view:n}=e;return{applicableItemOptions:n.applicableItemOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboClassHierarchy:n.qboClassHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:n.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",itemId:e.itemId,localData:n.localData,plan:n.plan}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${n}/catalog`),onLifecycleAction:i!==""?a=>{i!==""&&(g.trackInvoicingActionClick(d.Event.invoicingCatalogItemLifecycleAction,{action:a,fromScreen:"catalog_item_detail",itemId:i}),t(ln({action:a,id:i})))}:void 0,onEditChange:a=>{i!==""&&t($e({id:i,localData:a}))},onSaveEdit:()=>{g.trackInvoicingActionClick(d.Event.invoicingCatalogItemEdited,{itemId:i}),t(dn({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&t(Qt({action:o,id:a,parentItemId:i}))}}}))(nt);function wo(){const t=L(),e=_(),{item_id:n,tenantEmailDomain:i}=F(),[a]=W(),{areTenantIdsInSync:o}=R(),s=(u=a.get("kind"))!=null&&Po.has(u)?u:"plan";var u;const l=k((y=>Pe(y,n))),{pageFetchState:S}=l,v=S.fetchState;r.useEffect((()=>(t(de({id:n})),()=>{t(de({id:n}))})),[t,n]),r.useEffect((()=>{o&&t(be({id:n,kind:s}))}),[o,n,s,t]);const m=r.useCallback((y=>t(be({cacheOverride:!0,id:y,kind:s}))),[t,s]),p=X(l.fetchState,l.isFormLoading,n,m),f=v==="Completed"&&!l.isFormLoading;Ce(o,!0);const[I,E]=r.useState(f?n:void 0);r.useEffect((()=>{n!=null&&f&&E(n)}),[n,f]);const h=I!==n&&(v==="Not-Started"||v==="In-Progress"||l.isFormLoading);return N(v)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCatalogItemDetailPage,isReady:f}),c.jsx($o,{navigate:e,tenantEmailDomain:i,itemId:n??"",kind:s,isLoading:h,view:l},p)]})}const Fo=new Set(["addon","charge","plan"]),Ro=new Set(["plan"]),To=O((function(t,e){const n=Pe(t,e.itemId);return{fieldHelp:n.fieldHelp,qboClassHierarchy:n.qboClassHierarchy,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds,applicabilityValues:n.applicabilityValues,periodUnitOptions:n.periodUnitOptions,trialEndActionOptions:n.trialEndActionOptions,trialUnitOptions:n.trialUnitOptions,typeOptions:n.typeOptions,applicableItemOptions:n.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save catalog item.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,pricingModelValues:n.pricingModelValues,prorationValues:n.prorationValues,tierTypeOptionsByPricingModel:n.catalogTierTypeOptionsByPricingModel,tierTypeValues:n.tierTypeValues}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.isEdit?"edit":"create",{itemId:a}=e,o=a!=null?`${n}/catalog/${encodeURIComponent(a)}`:`${n}/catalog`;return{onBack:()=>e.navigate(o),onCancel:()=>{g.trackInvoicingActionClick(d.Event.invoicingCatalogItemFormCancelled),t(de({id:a})),e.navigate(`${n}/catalog`)},onChange:s=>{t($e({id:a,localData:s}))},onSubmit:()=>{g.trackInvoicingActionClick(d.Event.invoicingCatalogItemSaved,{mode:i}),t(dn({id:a}))}}}))(tt);function Oo(){const t=L(),e=_(),{item_id:n,tenantEmailDomain:i}=F(),[a]=W(),{areTenantIdsInSync:o}=R(),s=n!=null,u=a.get("type"),l=u!=null&&Fo.has(u)?u:void 0,S=(v=a.get("kind"))!=null&&Ro.has(v)?v:"plan";var v;const m=k((p=>Pe(p,n)));return Ce(o,!0),r.useEffect((()=>{o&&t(be({id:n,kind:S}))}),[o,n,S,t]),r.useEffect((()=>{s||l==null||m.localData.catalogType===l||t($e({localData:{...m.localData,catalogType:l}}))}),[s,l,m.localData?.catalogType,t]),r.useEffect((()=>{if(m.fetchState==="Completed"){const p=m.savedItemId??n,f=p!=null?`/${i}/invoicing/catalog/${encodeURIComponent(p)}`:`/${i}/invoicing/catalog`;e(f),t(de({id:n}))}}),[m.fetchState,m.savedItemId,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCatalogItemFormPage}),c.jsx(To,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:s,itemId:n})]})}const Mo={addons:"addon",all:"item",charges:"charge",plans:"plan"},No=O((function(t,e){const n=G(t),i=e.activeTab==="plans",a=e.activeTab==="all",o=i?n.plans:a?[...n.plans,...n.products]:n.products,s=i||a&&n.fetchState==="In-Progress"?n.fetchState:n.productFetchState.fetchState;return{catalogItemLifecycleActionOptions:n.catalogItemLifecycleActionOptions,counts:n.count,countsLoading:n.countsFetchState.fetchState==="Not-Started"||n.countsFetchState.fetchState==="In-Progress",hasMore:i?n.planNextCursor!=null:a&&n.planNextCursor!=null||n.productNextCursor!=null,isLoading:s==="Not-Started"||s==="In-Progress"&&o.length===0,isLoadingMore:s==="In-Progress"&&o.length>0,plans:n.plans,productColumns:n.productColumns,products:n.products}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",a=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${n}/data_import`)},onAddItem:()=>{const s=Mo[e.activeTab];g.trackInvoicingActionClick(d.Event.invoicingAddCatalogItemClicked,{itemType:s}),e.navigate(`${n}/catalog/new?type=${s}`)},onItemClick:(s,u)=>{g.trackInvoicingActionClick(d.Event.invoicingCatalogItemRowClicked,{itemId:u}),e.navigate(`${n}/catalog/${encodeURIComponent(u)}`)},onCatalogItemLifecycleAction:(s,u)=>{g.trackInvoicingActionClick(d.Event.invoicingCatalogItemLifecycleAction,{action:u,fromScreen:"catalog_list",itemId:s}),t(ln({action:zt(u),id:s}))},onLoadMore:()=>{if(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"catalog",tab:e.activeTab}),a)return e.planNextCursor!=null&&t(ze({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&t(re({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));o!=null&&t(i?ze({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):re({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(it);function Uo(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState("plans"),[l,S]=r.useState(""),[v,m]=r.useState(null),p=r.useMemo((()=>v!=null?{dir:v.direction,field:v.columnKey}:void 0),[v]),f=l.trim()!==""?l.trim():void 0,I=r.useMemo((()=>({search:f,type:"plan"})),[f]),E=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),h=k((P=>G(P))),y=h.planFilters.search,D=h.planSort,b=h.planNextCursor,A=h.productNextCursor,C=h.fetchState==="Completed",j=h.runningActionId??null;return r.useEffect((()=>{const P=setTimeout((()=>S(a)),300);return()=>clearTimeout(P)}),[a]),r.useEffect((()=>{i&&t(Qe({cacheOverride:!1,planFilters:I,productFilters:E,planSort:p,productSort:p}))}),[i,t,I,E,p]),r.useEffect((()=>{i&&(f!==y||p?.field!==D?.field||p?.dir!==D?.dir)&&t(Qe({cacheOverride:!0,planFilters:I,productFilters:E,planSort:p,productSort:p}))}),[y,D,i,t,I,E,f,p]),N(h.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCatalogPage,isReady:C}),c.jsx(No,{navigate:e,tenantEmailDomain:n,activeTab:s,searchValue:a,sortState:v,planFilters:I,productFilters:E,sort:p,planNextCursor:b,productNextCursor:A,runningCatalogItemActionId:j,onSearchChange:o,onTabChange:u,onSortChange:m})]})}const Bo=O((function(t,e){const n=un(t,e.couponId);return{fieldHelp:n.fieldHelp,applyOnOptions:n.applyOnOptions,discountTypeOptions:n.discountTypeOptions,durationTypeOptions:n.durationTypeOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save coupon.":void 0,isQboConnected:n.isQboConnected,isQboPickerDataLoading:n.isQboPickerDataLoading,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,periodUnitOptions:n.periodUnitOptions,qboAccountHierarchy:n.qboAccountHierarchy,qboIncomeAccountIds:n.qboIncomeAccountIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,a=i!=null?"edit":"create",o=i!=null?`${n}/discounts/${encodeURIComponent(i)}`:`${n}/discounts`;return{onBack:()=>e.navigate(o),onCancel:()=>{g.trackInvoicingActionClick(d.Event.invoicingCouponFormCancelled),t(le({id:i})),e.navigate(`${n}/discounts`)},onChange:s=>{t(Gt({id:i,localData:s}))},onSubmit:()=>{g.trackInvoicingActionClick(d.Event.invoicingCouponSaved,{mode:a}),t(Kt({id:i}))}}}))(ot);function Vo(){const t=L(),e=_(),{coupon_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=R(),{fetchState:o,savedCouponId:s}=k((u=>un(u,n)));return r.useEffect((()=>{a&&t(xe({id:n}))}),[a,n,t]),r.useEffect((()=>{if(o==="Completed"){const u=s??n,l=u!=null?`/${i}/invoicing/discounts/${encodeURIComponent(u)}`:`/${i}/invoicing/discounts`;e(l),t(le({id:n}))}}),[o,s,n,t,e,i]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCouponFormPage}),c.jsx(Bo,{couponId:n,navigate:e,tenantEmailDomain:i})]})}const Ho=O((function(t){const e=gn(t);return{fieldHelp:e.fieldHelp,customers:e.customers,planNames:e.planNames,errorMessage:e.fetchState==="Error"?e.error?.message??"Failed to create invoice. Please try again.":void 0,isSubmitting:e.fetchState==="In-Progress",localData:e.localData,settings:e.settings}}),(function(t){return{dispatch:t}}),(function(t,{dispatch:e},n){const i=`/${n.tenantEmailDomain}/invoicing`;return{...t,onCancel:()=>{g.trackInvoicingActionClick(d.Event.invoicingCreateInvoiceCancelled),n.navigate(`${i}/invoices`)},onChange:a=>{e(mn(a))},onSubmit:()=>{const a=Yt(t.localData);g.trackInvoicingActionClick(d.Event.invoicingInvoiceCreated,{customerId:a.customer_id,lineItemCount:a.line_items?.length}),e(Zt(a))}}}))(ct);function qo(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),[i]=W(),{areTenantIdsInSync:a}=R(),o=i.get("customerId"),s=k((b=>gn(b))),u=s.fetchState,l=s.localData,S=s.savedInvoiceId,v=k(vn),m=k((b=>Jt(b))),p=k(Se),f=m.fetchState==="Not-Started"||m.fetchState==="In-Progress"&&v==null,I=p.fetchState==="Not-Started"||p.fetchState==="In-Progress"&&p.customers.length===0,E=f||I,h=m.fetchState==="Completed"&&p.fetchState==="Completed";r.useEffect((()=>(t(Ke()),()=>{t(Ke())})),[t]);const y=r.useRef(!1);r.useEffect((()=>{y.current||o==null||o===""||l.customerId!==""||(y.current=!0,t(mn({...l,customerId:o})))}),[o,l,t]),r.useEffect((()=>{a&&t(Wt({cacheOverride:!1}))}),[a,t]);const D=r.useRef(u);return r.useEffect((()=>{const b=D.current;if(D.current=u,b!=="Completed"&&u==="Completed"){const A=S!=null?`/${n}/invoicing/invoices/${encodeURIComponent(S)}`:`/${n}/invoicing/invoices`;e(A)}}),[u,S,e,n]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCreateInvoicePage,isReady:h}),E?c.jsx(at,{}):c.jsx(Ho,{navigate:e,tenantEmailDomain:n})]})}const Qo=O((function(t,e){const{detailView:n}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:n.creditNote,creditNoteId:e.creditNoteId,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${n}/credits`),onCustomerClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)}}}))(st);function zo(){const t=L(),e=_(),{credit_note_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=R(),o=k((u=>Xt(u,n??""))),s=o.fetchState==="Completed";return r.useEffect((()=>{a&&n!=null&&t(ei({id:n}))}),[a,n,t]),N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCreditDetailPage,isReady:s}),c.jsx(Qo,{navigate:e,tenantEmailDomain:i,creditNoteId:n??"",detailView:o})]})}const Ko=O((function(t){const e=pn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",creditNotes:e.creditNotes,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.creditNotes.length===0,isLoadingMore:n==="In-Progress"&&e.creditNotes.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${n}/data_import`)},onCreditNoteClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${n}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"credits",status:e.activeStatus}),t(ti({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(rt);function Go(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,creditNoteListFetchState:h}=k((D=>{const b=pn(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,creditNoteListFetchState:b.fetchState}}),q),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(Ge({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Ge({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCreditsListPage,isReady:y}),c.jsx(Ko,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:l,filters:m,sort:v,nextCursor:E,onSearchChange:o,onStatusChange:D=>t(ni(D)),onSortChange:S})]})}const qn=(t,e,n)=>{const i=`/${t}/invoicing/customers/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},Jo=O((function(t,e){const{editView:n,hasLoadedRecord:i}=e;return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,hasUnsavedBillingAddress:n.hasUnsavedBillingAddress,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,customer:n.record.invoicingCustomer,invoices:n.record.invoices.slice(0,5),isLoading:!i&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),hasPaymentLinkEmailPreviewFailed:n.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:n.emailPreviewFetchState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",paymentLinkEmailPreview:n.emailPreview,isSendingPaymentLink:n.record.sendLinkState.fetchState==="In-Progress",localData:n.localData,paymentMethods:n.record.paymentMethods,sendPaymentLinkErrorMessage:n.record.sendLinkState.fetchState==="Error"?n.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:n.record.sendLinkState.fetchState==="Completed"?n.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:n.record.stripeConnected}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${n}/customers`),onChange:a=>{t(Ae({id:i,localData:a}))},onCreateInvoice:()=>{g.trackInvoicingActionClick(d.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onCreatePromotionalCredits:()=>{g.trackInvoicingActionClick(d.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customer_detail"}),e.onCreatePromotionalCredits()},onNewSubscription:()=>{g.trackInvoicingActionClick(d.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customer_detail"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`)},onDiscardEdit:()=>{t(fe(ue)),t(di({id:i}))},onOpenAddress:()=>{const a=qn(e.tenantEmailDomain??"",ue,i),o=Z(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${n}/settings/payment-destination`),onSaveEdit:a=>{g.trackInvoicingActionClick(d.Event.invoicingCustomerEdited,{customerId:i}),t(Ae({id:i,localData:a})),t(fn({id:i}))},onFetchPaymentLinkEmailPreview:a=>t(ri({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,s)=>{g.trackInvoicingActionClick(d.Event.invoicingPaymentLinkSent,{customerId:i,fromScreen:"customer_detail"}),t(si({body:s,customerId:i,email:a,subject:o}))},onSubscriptionClick:a=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)}}}))(ut);function Wo(){const t=L(),e=_(),n=Y(),{customer_id:i,tenantEmailDomain:a}=F(),{areTenantIdsInSync:o}=R(),s=k((T=>we(T,i))),u=s.pageFetchState.fetchState,l=u==="Completed"&&!s.isFormLoading,[S,v]=r.useState(!1),[m,p]=r.useState(!1),[f,I]=r.useState(l?i:void 0);r.useEffect((()=>{i!=null&&l&&I(i)}),[i,l]);const E=f===i,{plaidTokenFetchState:h,promotionalCreditSubmitState:y}=s,{paymentMethodSaveState:D,setupIntentFetchState:b,stripeConnected:A}=s.record,C=r.useRef(s.record.sendLinkState.fetchState);r.useEffect((()=>{const T=s.record.sendLinkState.fetchState;C.current!=="Error"&&T==="Error"&&t(Fe({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),C.current=T}),[t,s.record.sendLinkState.fetchState]);const j=b.fetchState==="Error"?b.error?.message??"Failed to start card setup.":D.fetchState==="Error"?D.error?.message??"Failed to save payment method.":h.fetchState==="Error"?h.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(t(te()),t(ie()),()=>{t(te()),t(ie())})),[t]),r.useEffect((()=>{n.state?.openPromotionalCreditsDialog===!0&&(p(!0),e(n.pathname,{replace:!0,state:null}))}),[n.pathname,n.state,e]),r.useEffect((()=>{o&&i!=null&&t(ii({id:i}))}),[o,i,t]),r.useEffect((()=>{o&&i!=null&&A&&t(Je({customerId:i}))}),[o,i,t,A]);const P=r.useCallback((T=>t(Sn({id:T}))),[t]),U=X(s.fetchState,s.isFormLoading,i,P);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCustomerDetailPage,isReady:l}),c.jsx(Jo,{customerId:i??"",editView:s,hasLoadedRecord:E,location:n,navigate:e,tenantEmailDomain:a,onAddPaymentMethod:()=>{g.trackInvoicingActionClick(d.Event.invoicingPaymentMethodAddClicked,{customerId:i??"",fromScreen:"customer_detail"}),t(te()),i!=null&&A&&t(Je({customerId:i})),v(!0)},onCreatePromotionalCredits:()=>{t(ie()),p(!0)}},U),c.jsx(dt,{errorMessage:j,isCreatingSetupIntent:b.fetchState==="In-Progress",isSaving:D.fetchState==="In-Progress",open:S,plaidLinkToken:s.record.plaidLinkToken,saveSucceeded:D.fetchState==="Completed",setupIntent:s.record.setupIntent,stripeConnected:A,onChooseCard:()=>{i!=null&&t(ai({customerId:i}))},onClose:()=>{v(!1),t(te())},onSavePaymentMethod:T=>{i!=null&&(g.trackInvoicingActionClick(d.Event.invoicingPaymentMethodSaved,{customerId:i,fromScreen:"customer_detail"}),t(oi({customerId:i,data:T})))}}),c.jsx(lt,{currentBalance:s.record.invoicingCustomer?.promotionalCredits,currencyCode:s.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:y.fetchState==="Error"?y.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:y.fetchState==="In-Progress",open:m,submitSucceeded:y.fetchState==="Completed",onClose:()=>{p(!1),t(ie())},onSubmit:({amount:T,description:ne})=>{i!=null&&(g.trackInvoicingActionClick(d.Event.invoicingPromotionalCreditsAdded,{amount:T,customerId:i,fromScreen:"customer_detail"}),t(ci({amount:T,customerId:i,currencyCode:s.record.invoicingCustomer?.preferredCurrencyCode,description:ne})))}})]})}const Yo=O((function(t,e){const n=we(t,e.customerId);return{fieldHelp:n.fieldHelp,billingAddressLabel:n.billingAddressLabel,customerTypeOptions:n.customerTypeOptions,netTermDayOptions:n.netTermDayOptions,taxabilityOptions:n.taxabilityOptions,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save customer.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,a=i!=null?"edit":"create",o=i!=null?`${n}/customers/${encodeURIComponent(i)}`:`${n}/customers`;return{onBack:()=>e.navigate(o),onCancel:()=>{g.trackInvoicingActionClick(d.Event.invoicingCustomerFormCancelled),t(In({id:i})),t(fe(ue)),e.navigate(`${n}/customers`)},onChange:s=>{t(Ae({id:i,localData:s}))},onOpenAddress:()=>{g.trackInvoicingActionClick(d.Event.invoicingAddressOpened,{entity:"customer",fromScreen:"customer_form"});const s=qn(e.tenantEmailDomain??"",ue,i),u=Z(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(s,{state:{pathnameStackToGoBack:u}})},onSubmit:()=>{g.trackInvoicingActionClick(d.Event.invoicingCustomerSaved,{mode:a}),t(fn({id:i}))}}}))(gt);function Zo(){const t=L(),e=_(),n=Y(),{customer_id:i,tenantEmailDomain:a}=F(),{areTenantIdsInSync:o}=R(),{fetchState:s,savedCustomerId:u}=k((l=>we(l,i)));return r.useEffect((()=>{o&&i!=null&&t(Sn({id:i}))}),[o,i,t]),r.useEffect((()=>{if(s==="Completed"){const l=u??i,S=l!=null?`/${a}/invoicing/customers/${encodeURIComponent(l)}`:`/${a}/invoicing/customers`;e(S),t(In({id:i}))}}),[s,u,i,t,e,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCustomerFormPage}),c.jsx(Yo,{customerId:i,location:n,navigate:e,tenantEmailDomain:a})]})}const Xo=O((function(t){const e=Se(t),{fetchState:n}=e;return{addressesById:t.addressState.addressesById,columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",customers:e.customers,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.customers.length===0,isLoadingMore:n==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{g.trackInvoicingActionClick(d.Event.invoicingAddCustomerClicked),e.navigate(`${n}/customers/new`)},onCustomerClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${n}/data_import`)},onRowAction:(i,a)=>{switch(a){case"createInvoice":g.trackInvoicingActionClick(d.Event.invoicingCreateInvoiceClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":g.trackInvoicingActionClick(d.Event.invoicingAddSubscriptionClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":g.trackInvoicingActionClick(d.Event.invoicingPromotionalCreditsClicked,{customerId:i,fromScreen:"customers_list"}),e.navigate(`${n}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"customers",status:e.activeStatus}),t(hn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(vt);function ea(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,customerListFetchState:h}=k((D=>{const b=Se(D);return{activeStatus:b.activeTab,appliedSearch:b.filters.search,appliedSort:b.sort,nextCursor:b.nextCursor,customerListFetchState:b.fetchState}}),q),y=h==="Completed";return r.useEffect((()=>{const D=setTimeout((()=>u(a)),300);return()=>clearTimeout(D)}),[a]),r.useEffect((()=>{i&&t(We({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(We({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingCustomersListPage,isReady:y}),c.jsx(Xo,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:l,filters:m,sort:v,nextCursor:E,onSearchChange:o,onStatusChange:D=>t(li(D)),onSortChange:S})]})}const Le=(t,e)=>e==null?void 0:t.sessionDetail[e]??t.sessions.find((n=>n.id===e)),na=O((function(t,e){const{authParams:n,csvDownloadUrl:i,filters:a,sessionId:o,view:s}=e,u=o==null?void 0:s.diagnosticsBySession[o],l=u?.fetch.fetchState??"Not-Started";return{authParams:n,csvDownloadUrl:i,diagnostics:u?.items??[],errorMessage:l==="Error"?u?.fetch.error?.message:void 0,expired:u?.expired??!1,filters:a,hasMore:u?.nextCursor!=null,isLoading:l==="Not-Started"||l==="In-Progress",isLoadingMore:l==="In-Progress"&&(u?.items.length??0)>0,session:Le(s,o)}}),(function(t,e){const{filters:n,navigate:i,sessionId:a,tenantEmailDomain:o,view:s}=e,u=a==null?void 0:s.diagnosticsBySession[a],l=Le(s,a),S=s.actionStateByKind.retry?.fetchState==="In-Progress",v=s.actionStateByKind.rollback?.fetchState==="In-Progress",m=l?.status==="done"&&l.rollback_available_until!=null&&new Date(l.rollback_available_until).getTime()>Date.now()&&!v;return{onBack:()=>i(`/${o}/invoicing/data_import`),onDownloadCsv:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"download_csv",fromScreen:"data_import_detail",sessionId:a})},onDownloadError:()=>{t(Fe({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{a!=null&&u?.nextCursor!=null&&t(je({...n,cursor:u.nextCursor,sessionId:a}))},onRetry:l?.status!=="failed"||S?void 0:()=>{a!=null&&(g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_detail",sessionId:a}),t(Te(a)))},onRollback:m?()=>{a!=null&&(g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"rollback",fromScreen:"data_import_detail",sessionId:a}),t(Cn(a)))}:void 0}}))(mt);function ta(){const t=L(),e=_(),{sessionId:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=R(),[o,s]=r.useState({}),u=k(Re),l=k(Ie),S=r.useMemo((()=>{const E=J.getSignedInUser();return{userId:E?.userId??"",sessionId:E?.zeniSessionId??"",tenantId:l.tenantId}}),[l.tenantId]),v=Le(u,n),m=n==null?void 0:u.diagnosticsBySession[n];r.useEffect((()=>{a&&n!=null&&t(De(n))}),[a,t,n]),r.useEffect((()=>{if(!a||n==null)return;const E=setTimeout((()=>{t(je({...o,sessionId:n}))}),300);return()=>clearTimeout(E)}),[a,t,o,n]);const p=v?.status==="scanning"||v?.status==="importing";r.useEffect((()=>{if(!a||n==null||!p)return;const E=setInterval((()=>{t(De(n)),t(je({...o,sessionId:n}))}),3e3);return()=>clearInterval(E)}),[a,t,o,p,n]);const f=r.useMemo((()=>{if(n==null)return"";const E=new URLSearchParams;o.moduleId!=null&&E.set("module_id",o.moduleId),o.level!=null&&E.set("level",o.level),o.outcome!=null&&E.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&E.set("search",o.search.trim());const h=E.toString();return`${se?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(n)}/issues.csv${h===""?"":`?${h}`}`}),[o,n]),I=m?.fetch.fetchState??"Not-Started";return N(I)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingDataImportDetailPage,isReady:v!=null&&I!=="Not-Started"}),c.jsx(na,{authParams:S,csvDownloadUrl:f,filters:o,navigate:e,sessionId:n,tenantEmailDomain:i,view:u,onFiltersChange:s})]})}const Qn=t=>`invoicing_active_migration:${t}`,ce=(t,e)=>{if(t!=null&&t!=="")try{const n=Qn(t);e==null?sessionStorage.removeItem(n):sessionStorage.setItem(n,e)}catch{}},ia=O((function(t,e){const{sessions:n,sessionsFetch:i,statusFetch:a,statusRows:o}=e.view;return{isLoading:!(a.fetchState!=="Not-Started"&&a.fetchState!=="In-Progress"||o.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:n,statusRows:o}}),(function(t,e){const{navigate:n,tenantEmailDomain:i}=e,a=o=>{const s=o??null;t(ae(s)),ce(i,s),n(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),a(o)},onNewImport:()=>{g.trackInvoicingActionClick(d.Event.invoicingNewImportClicked),a()},onRetrySession:o=>{g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),t(Te(o)),a(o)},onRollbackSession:o=>{g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),t(Cn(o))},onViewSession:o=>{g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),n(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(pt);function oa(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),a=k(Re);r.useEffect((()=>{i&&(t(ui()),t(kn()))}),[i,t]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingDataImportHubPage,isReady:o}),c.jsx(ia,{navigate:e,tenantEmailDomain:n,view:a})]})}const aa=O((function(t,e){const{activeId:n,authParams:i,integrationsView:a,settings:o,templatesDownloadUrl:s,view:u}=e,{actionStateByKind:l,sessionDetail:S,sessions:v}=u,m=a.externalConnections?.revenue?.find((f=>f.connectionName==="chargebee")),p=n!=null?S[n]:void 0;return{authParams:i,templatesDownloadUrl:s,chargebeeConnected:o?.chargebee_connected===!0||(m?.isValid??!1),chargebeeConnectorAvailable:m!=null,chargebeeSite:o?.chargebee_site,connectError:l.connect?.error?.message,connecting:l.connect?.fetchState==="In-Progress",retrying:l.retry?.fetchState==="In-Progress",session:p??v.find((f=>f.id===n)),starting:l.start?.fetchState==="In-Progress",uploading:l.upload?.fetchState==="In-Progress"}}),(function(t,e){const{activeId:n,navigate:i,tenantEmailDomain:a}=e;return{onBack:e.onBack,onDownloadError:()=>{t(Fe({messageSection:"invoicing_data_import_download",messageText:"failed",showStatusIcon:!0,type:"error"}))},onDownloadTemplates:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportTemplatesDownloaded)},onFetchFromChargebee:()=>{g.trackInvoicingActionClick(d.Event.invoicingChargebeeConnectClicked),t(mi())},onGoToIntegrations:()=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"settings_integrations"}),i(`/${a}/invoicing/settings`)},onGoToOverview:()=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"data_import_migrate",toScreen:"overview"}),i(`/${a}/invoicing/overview`)},onRetry:()=>{n!=null&&(g.trackInvoicingActionClick(d.Event.invoicingImportSessionAction,{action:"retry",fromScreen:"data_import_migrate",sessionId:n}),t(Te(n)))},onSaveLater:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportStarted),n!=null&&t(vi(n))},onUpload:o=>{g.trackInvoicingActionClick(d.Event.invoicingImportFileUploaded),t(gi({files:o}))},onViewDetails:n==null?void 0:()=>i(`/${a}/invoicing/data_import/${encodeURIComponent(n)}`)}}))(St);function ca(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),a=k(vn),o=k(Ie),s=r.useMemo((()=>{const h=J.getSignedInUser();return{userId:h?.userId??"",sessionId:h?.zeniSessionId??"",tenantId:o.tenantId}}),[o.tenantId]),u=`${se?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/templates`,l=o.companyId??J.getSignedInUserTenant(n??"")?.companyId,S=k((h=>En(h,l))),v=k(Re),{activeMigrationSessionId:m}=v,p=m??void 0,f=p!=null?v.sessionDetail[p]??v.sessions.find((h=>h.id===p)):void 0;r.useEffect((()=>{i&&(t(Oe()),t(kn()))}),[i,t]),r.useEffect((()=>{if(m!=null)return;const h=(y=>{if(y==null||y==="")return null;try{return sessionStorage.getItem(Qn(y))}catch{return null}})(n);h!=null&&t(ae(h))}),[m,t,n]),r.useEffect((()=>{ce(n,m)}),[m,n]);const I=f?.status,E=I==="scanning"||I==="importing";return r.useEffect((()=>{if(!i||p==null||!E)return;const h=setInterval((()=>{t(De(p))}),3e3);return()=>clearInterval(h)}),[i,p,E,t]),r.useEffect((()=>{I==="done"&&(t(ae(null)),ce(n,null))}),[t,I,n]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingDataImportMigratePage}),c.jsx(aa,{activeId:p,authParams:s,integrationsView:S,navigate:e,settings:a,templatesDownloadUrl:u,tenantEmailDomain:n,view:v,onBack:()=>{t(ae(null)),ce(n,null),e(`/${n}/invoicing/data_import`)}})]})}const sa=O((function(t,e){const{editView:n}=e;return{fieldHelp:n.fieldHelp,coupon:n.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,discountsAccountName:n.discountsAccountName,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:n.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${n}/discounts`),onLifecycleAction:a=>{g.trackInvoicingActionClick(d.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discount_detail",status:e.editView.coupon?.status}),t(yn({action:a,id:i}))},onSaveEdit:a=>{g.trackInvoicingActionClick(d.Event.invoicingCouponEdited,{couponId:i}),t(Si({data:a,id:i}))}}}))(ft);function ra(){const t=L(),e=_(),{coupon_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=R(),o=k((I=>pi(I,n))),s=o.actionState.fetchState==="In-Progress",u=o.pageFetchState.fetchState,l=u==="Completed",[S,v]=r.useState(l?n:void 0);r.useEffect((()=>{n!=null&&l&&v(n)}),[n,l]);const m=S===n;r.useEffect((()=>(t(le({id:n})),()=>{t(le({id:n}))})),[n,t]),r.useEffect((()=>{a&&t(xe({id:n}))}),[a,n,t]);const p=r.useCallback((I=>t(xe({cacheOverride:!0,id:I}))),[t]),f=X(o.fetchState,o.isFormLoading,n,p);return N(u)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingDiscountDetailPage,isReady:l}),c.jsx(sa,{hasLoadedRecord:m,couponId:n??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:s,navigate:e,tenantEmailDomain:i},f)]})}const da=O((function(t){const e=bn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,discountLifecycleActionOptions:e.discountLifecycleActionOptions,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",coupons:e.coupons,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.coupons.length===0,isLoadingMore:n==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${n}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{g.trackInvoicingActionClick(d.Event.invoicingCreateCouponClicked),e.navigate(`${n}/discounts/new`)},onImportCsv:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${n}/data_import`)},onDiscountLifecycleAction:(i,a)=>{g.trackInvoicingActionClick(d.Event.invoicingCouponLifecycleAction,{action:a,couponId:i,fromScreen:"discounts_list"}),t(yn({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"discounts",status:e.activeStatus}),t(Ii({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(It);function la(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,couponListFetchState:h,runningDiscountActionId:y}=k((b=>{const A=bn(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,couponListFetchState:A.fetchState,runningDiscountActionId:A.runningActionId??null}}),q),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(Ye({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Ye({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingDiscountsListPage,isReady:D}),c.jsx(da,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:l,filters:m,sort:v,nextCursor:E,runningDiscountActionId:y,onSearchChange:o,onStatusChange:b=>t(fi(b)),onSortChange:S})]})}const ua=O((function(t,e){const{readView:n}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:n.dunningCase,isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,a=i!=="",{dunningCase:o}=e.readView,s={amount:o?.amount?.amount,caseId:i,customerId:o?.customerID,invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID};return{onBack:()=>e.navigate(`${n}/dunning`),onInvoiceClick:u=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:u,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(u)}`)},onCancel:a?()=>{g.trackInvoicingActionClick(d.Event.invoicingDunningAction,{...s,action:"cancel",fromScreen:"dunning_detail"}),t(Q({action:"cancel",id:i}))}:void 0,onResolve:a?()=>{g.trackInvoicingActionClick(d.Event.invoicingDunningAction,{...s,action:"resolve",fromScreen:"dunning_detail"}),t(Q({action:"resolve",id:i}))}:void 0,onResume:a?()=>{g.trackInvoicingActionClick(d.Event.invoicingDunningAction,{...s,action:"resume",fromScreen:"dunning_detail"}),t(Q({action:"resume",id:i}))}:void 0,onRetry:a?()=>{g.trackInvoicingActionClick(d.Event.invoicingDunningAction,{...s,action:"retry",fromScreen:"dunning_detail"}),t(Q({action:"retry",id:i}))}:void 0}}))(Ct);function ga(){const t=L(),e=_(),{case_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=R(),o=k((C=>hi(C,n??""))),s=o.fetchState==="Completed",u=o.dunningCase?.invoiceID,[l,S]=r.useState("idle"),[v,m]=r.useState(!1),[p,f]=r.useState(),[I,E]=r.useState(!1),h=r.useCallback((()=>{S("idle"),m(!1),f(void 0),E(!1)}),[]),y=r.useCallback((()=>{if(n==null)return;t(Ci({id:n})),S("idle"),m(!1);const C=o.emailPreview.preview;f(C==null?void 0:{body:C.body,cc:C.cc,subject:C.subject,to:C.to}),E(!0)}),[n,t,o.emailPreview.preview]),D=r.useCallback((C=>{n!=null&&l!=="pending"&&(m(!1),S("pending"),g.trackInvoicingActionClick(d.Event.invoicingDunningAction,{action:"send-email",amount:o.dunningCase?.amount?.amount,caseId:n,customerId:o.dunningCase?.customerID,fromScreen:"dunning_detail",invoiceId:o.dunningCase?.invoiceID,status:o.dunningCase?.status,subscriptionId:o.dunningCase?.subscriptionID}),t(Q({action:"send-email",body:C,id:n})))}),[n,t,l,o.dunningCase]),b=r.useMemo((()=>o.emailPreview.preview==null?void 0:{bodyToken:o.emailPreview.preview.bodyToken,renderedHtmlTemplate:o.emailPreview.preview.renderedHtmlTemplate,subjectToken:o.emailPreview.preview.subjectToken}),[o.emailPreview.preview]);r.useEffect((()=>{a&&n!=null&&t(ki({id:n}))}),[a,n,t]),r.useEffect((()=>{a&&u!=null&&t(he({invoiceId:u}))}),[a,u,t]),r.useEffect((()=>{S("idle"),m(!1),f(void 0),E(!1)}),[n]),r.useEffect((()=>{a||(S("idle"),m(!1),f(void 0),E(!1))}),[a]),r.useEffect((()=>{I&&p==null&&o.emailPreview.preview!=null&&f({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,p,I]),r.useEffect((()=>{l==="pending"&&(o.actionState.fetchState!=="In-Progress"?v&&o.actionState.fetchState==="Completed"?(n!=null&&t(Ei({id:n})),h()):v&&o.actionState.fetchState==="Error"&&S("failed"):m(!0))}),[n,h,t,l,v,o.actionState.fetchState]);const A=u!=null&&o.linkedInvoice?.id===u?o.linkedInvoice.dunningAttempts:void 0;return N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingDunningDetailPage,isReady:s}),c.jsx(ua,{navigate:e,tenantEmailDomain:i,caseId:n??"",readView:o,dunningAttempts:A,onSendEmail:y}),c.jsx(ht,{initialDraft:p,isPreviewLoading:o.emailPreview.fetchState==="Not-Started"||o.emailPreview.fetchState==="In-Progress",isSending:l==="pending",onClose:h,onSend:D,open:I,preview:b,previewErrorMessage:o.emailPreview.fetchState==="Error"?o.emailPreview.error?.message:void 0,sendErrorMessage:l==="failed"?o.actionState.error?.message:void 0})]})}const va=O((function(t){const e=xn(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:n==="In-Progress"&&e.dunningCases.length>0,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=a=>{const o=e.dunningCases.find((s=>s.id===a));return{amount:o?.amount?.amount,caseId:a,customerId:o?.customerID,fromScreen:"dunning_list",invoiceId:o?.invoiceID,status:o?.status,subscriptionId:o?.subscriptionID}};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${n}/data_import`),onDunningCaseClick:a=>{g.trackInvoicingActionClick(d.Event.invoicingDunningCaseRowClicked,i(a)),e.navigate(`${n}/dunning/${encodeURIComponent(a)}`)},onRowAction:(a,o)=>{o!=="retry"&&o!=="resume"&&o!=="resolve"&&o!=="cancel"||(g.trackInvoicingActionClick(d.Event.invoicingDunningAction,{...i(a),action:o}),t(Q({action:o,id:a})))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"dunning",status:e.activeStatus}),t(bi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(kt);function ma(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,dunningCaseListFetchState:h,dunningCases:y}=k((b=>{const A=xn(b);return{activeStatus:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,dunningCaseListFetchState:A.fetchState,dunningCases:A.dunningCases}}),q),D=h==="Completed";return r.useEffect((()=>{const b=setTimeout((()=>u(a)),300);return()=>clearTimeout(b)}),[a]),r.useEffect((()=>{i&&t(Ze({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Ze({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingDunningListPage,isReady:D}),c.jsx(va,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:l,filters:m,sort:v,dunningCases:y,nextCursor:E,onSearchChange:o,onStatusChange:b=>t(yi(b)),onSortChange:S})]})}const pa=O((function(t,e){const{view:n}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:n.billingAddress,invoice:n.invoice,invoiceId:e.invoiceId,shippingAddress:n.shippingAddress,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"),isSaving:n.actionState.fetchState==="In-Progress",isVoiding:n.actionState.fetchState==="In-Progress"}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e,{invoice:a}=e.view,o={amount:a?.total?.amount,customerId:a?.customerID,invoiceId:i,status:a?.status};return{onBack:()=>e.navigate(`${n}/invoices`),onCustomerClick:s=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(s)}`)},onIssueCreditNote:()=>{g.trackInvoicingActionClick(d.Event.invoicingIssueCreditNoteClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{g.trackInvoicingActionClick(d.Event.invoicingRecordPaymentClicked,{...o,fromScreen:"invoice_detail"}),e.navigate(`${n}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{g.trackInvoicingActionClick(d.Event.invoicingInvoiceRegenerated,{...o,fromScreen:"invoice_detail"}),t(H({action:"regenerate",invoiceId:i}))},onSaveEdit:s=>{g.trackInvoicingActionClick(d.Event.invoicingInvoiceEdited,{...o,fromScreen:"invoice_detail"}),t(Ai({data:{due_date:s.due_date!==""?s.due_date:void 0,notes:s.notes.trim()!==""?s.notes.split(`
|
|
2
2
|
`).map((u=>u.trim())).filter((u=>u!=="")).map((u=>({note:u}))):void 0,po_number:s.po_number!==""?s.po_number:null},invoiceId:i}))},onSendReminder:()=>{g.trackInvoicingActionClick(d.Event.invoicingInvoiceReminderSent,{...o,fromScreen:"invoice_detail"}),t(H({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:s=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:s,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(s)}`)},onVoid:s=>{g.trackInvoicingActionClick(d.Event.invoicingInvoiceVoided,{...o,fromScreen:"invoice_detail"}),t(H({action:"void",invoiceId:i,body:s}))}}}))(Et);function Sa(){const t=L(),e=_(),{invoice_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=R(),o=k((f=>An(f,n??""))),s=o.pageFetchState.fetchState,u=s==="Completed",[l,S]=r.useState(u?n:void 0);r.useEffect((()=>{n!=null&&u&&S(n)}),[n,u]);const v=l===n;r.useEffect((()=>{a&&n!=null&&t(xi({invoiceId:n}))}),[a,n,t]);const m=r.useCallback((f=>t(he({invoiceId:f}))),[t]),p=X(o.actionState.fetchState,o.fetchState==="In-Progress",n,m);return N(s)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingInvoiceDetailPage,isReady:u}),c.jsx(pa,{invoiceId:n??"",hasLoadedRecord:v,navigate:e,tenantEmailDomain:i,view:o},p)]})}const fa=O((function(t){const e=Dn(t),{fetchState:n}=e;return{counts:e.counts,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,invoices:e.invoices,statusOptions:e.statusOptions,isLoading:n==="Not-Started"||n==="In-Progress"&&e.invoices.length===0,isLoadingMore:n==="In-Progress"&&e.invoices.length>0,kpis:e.kpis,kpisLoading:e.kpisFetchState.fetchState==="Not-Started"||e.kpisFetchState.fetchState==="In-Progress"&&e.kpis==null,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=a=>{const o=e.invoices.find((s=>s.id===a));return{amount:o?.total?.amount,customerId:o?.customerID,fromScreen:"invoices_list",invoiceId:a,status:o?.status}};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onCreateInvoice:()=>{g.trackInvoicingActionClick(d.Event.invoicingCreateInvoiceClicked),e.navigate(`${n}/invoices/create`)},onImportCsv:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportCsvClicked,{entity:"invoices"}),e.navigate(`${n}/data_import`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(d.Event.invoicingInvoiceRowClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onRowAction:(a,o)=>{switch(o){case"recordPayment":g.trackInvoicingActionClick(d.Event.invoicingRecordPaymentClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}/record-payment`);break;case"issueCreditNote":g.trackInvoicingActionClick(d.Event.invoicingIssueCreditNoteClicked,i(a)),e.navigate(`${n}/invoices/${encodeURIComponent(a)}/issue-credit-note`);break;case"sendReminder":g.trackInvoicingActionClick(d.Event.invoicingInvoiceReminderSent,i(a)),t(H({action:"send-reminder",invoiceId:a}));break;case"regenerate":g.trackInvoicingActionClick(d.Event.invoicingInvoiceRegenerated,i(a)),t(H({action:"regenerate",invoiceId:a}));break;case"void":g.trackInvoicingActionClick(d.Event.invoicingInvoiceVoided,i(a)),t(H({action:"void",invoiceId:a}))}},onVoidInvoice:(a,o)=>{g.trackInvoicingActionClick(d.Event.invoicingInvoiceVoided,i(a)),t(H({action:"void",invoiceId:a,body:o}))},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"invoices",status:e.activeStatus}),t(jn({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(yt);function Ia(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,invoiceListFetchState:h,voidingInvoiceId:y,invoices:D}=k((A=>{const C=Dn(A);return{activeStatus:C.activeTab,appliedSearch:C.filters.search,appliedSort:A.invoicingInvoiceListState.sort,nextCursor:C.nextCursor,invoiceListFetchState:C.fetchState,voidingInvoiceId:C.runningActionId,invoices:C.invoices}}),q),b=h==="Completed";return r.useEffect((()=>{const A=setTimeout((()=>u(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&t(Ee({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(Ee({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingInvoicesListPage,isReady:b}),c.jsx(fa,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:l,filters:m,sort:v,invoices:D,nextCursor:E,voidingInvoiceId:y,onSearchChange:o,onStatusChange:A=>{t(Di(A)),t(Ee({cacheOverride:!1,filters:m,sort:v}))},onSortChange:S})]})}function on(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),i=bt(),a=rn(),[o,s]=r.useState(!1),{acceptTermsState:u,status:l}=k(Ln),S=ji(i?.loggedInUserRoleMap),v=`/${n}/invoicing`,m=p=>{s(p)};return l==="completed"?c.jsx(V,{to:`${v}/overview`,replace:!0}):l==="settings"&&S?c.jsx(V,{to:`${v}/settings`,replace:!0}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingPromoPage}),c.jsx(Lo,{isAppContentDrawerOpen:o,handleDrawerToggle:m}),c.jsx(xt,{analytics:g,isAccepting:u.fetchState==="In-Progress",isReadOnlyUser:!S,meetingUrl:a("invoicing_promo"),onAcceptClick:()=>{g.trackInvoicingActionClick(d.Event.invoicingTermsAccepted),t(Li())},onBackClick:()=>{e(`/${n}`)},onClickMenuIcon:()=>{m(!0)}})]})}const ha=O((function(t,e){const n=_n(t,e.invoiceId),{invoice:i,localData:a,reasonCodeOptions:o,submitState:s,typeOptions:u}=n;return{fieldHelp:n.fieldHelp,amountDue:i?.amountDue,currencyCode:i?.currencyCode??"USD",customerName:i?.customerName??"",errorMessage:s.fetchState==="Error"?s.error?.message??"Failed to issue credit note. Please try again.":void 0,invoiceNumber:i?.invoiceNumber??e.invoiceId,isSubmitting:s.fetchState==="In-Progress",localData:a,reasonCodeOptions:o,typeOptions:u}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing/invoices/${encodeURIComponent(e.invoiceId)}`,i=()=>e.navigate(n);return{onBack:i,onCancel:i,onChange:a=>{t(Fi({localData:a}))},onSubmit:()=>{g.trackInvoicingActionClick(d.Event.invoicingCreditNoteIssued,{invoiceId:e.invoiceId}),t(wi())}}}))(At);function Ca(){const t=L(),e=_(),{invoice_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=R(),{fetchState:o,invoice:s,isPageReady:u,issuedCreditNoteId:l,submitState:S}=k((f=>_n(f,n??""))),v=`/${i}/invoicing`,m=r.useRef(null);r.useEffect((()=>{t(_i()),m.current=null}),[t,n]),r.useEffect((()=>{a&&n!=null&&t(he({invoiceId:n}))}),[a,t,n]),r.useEffect((()=>{s!=null&&n!=null&&o==="Completed"&&m.current!==n&&(m.current=n,t(Pi({localData:$i(s)})))}),[t,o,s,n]);const p=r.useRef(S.fetchState);return r.useEffect((()=>{const f=p.current;p.current=S.fetchState,f!=="Completed"&&S.fetchState==="Completed"&&l!=null&&e(`${v}/credits/${encodeURIComponent(l)}`)}),[l,e,S.fetchState,v]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingIssueCreditNotePage,isReady:u}),c.jsx(ha,{invoiceId:n??"",navigate:e,tenantEmailDomain:i})]})}const ka=O((function(t){return{invoicingOverview:Pn(t)}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{onRefresh:()=>{g.trackInvoicingActionClick(d.Event.invoicingOverviewRefreshed),t($n(e.selectedPeriod,!0))},onSubscriptionClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingSubscriptionTileClicked,{subscriptionId:i}),e.navigate(`${n}/subscriptions/${i}`)},onViewInvoices:()=>{g.trackInvoicingActionClick(d.Event.invoicingViewInvoicesClicked),e.navigate(`${n}/invoices`)},onViewPayments:()=>{g.trackInvoicingActionClick(d.Event.invoicingViewPaymentsClicked),e.navigate(`${n}/payments`)}}}))(Dt);function Ea(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),[a]=r.useState((()=>{const s=new Date;return{month:s.getMonth()+1,year:s.getFullYear()}})),o=k((s=>Pn(s).fetchState))==="Completed";return r.useEffect((()=>{i&&t($n(a))}),[i,t,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingOverviewPage,isReady:o}),c.jsx(ka,{navigate:e,selectedPeriod:a,tenantEmailDomain:n})]})}const ya=O((function(t){const e=wn(t),{fetchState:n}=e;return{columns:e.columns,hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.transactions.length===0,isLoadingMore:n==="In-Progress"&&e.transactions.length>0,tabIds:e.tabIds,transactions:e.transactions}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`;return{activeType:e.activeType,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTypeChange:e.onTypeChange,onViewTransactionCustomer:e.onViewTransactionCustomer,onViewTransactionInvoice:e.onViewTransactionInvoice,onImportCsv:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportCsvClicked,{entity:"payments"}),e.navigate(`${n}/data_import`)},onTransactionClick:i=>{g.trackInvoicingActionClick(d.Event.invoicingPaymentRowClicked,{transactionId:i}),e.navigate(`${n}/payments/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"payments",tab:e.activeType}),t(Ti({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(jt);function ba(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeType:p,appliedSearch:f,appliedSort:I,nextCursor:E,transactionListFetchState:h,transactions:y}=k((j=>{const P=wn(j);return{activeType:P.activeTab,appliedSearch:P.filters.search,appliedSort:P.sort,nextCursor:P.nextCursor,transactionListFetchState:P.fetchState,transactions:P.transactions}}),q),D=h==="Completed",b=`/${n}/invoicing`,A=r.useCallback((j=>{const P=y.find((T=>T.id===j)),U=P?.linkedInvoices?.[0]?.invoiceID??P?.invoiceID;U!=null&&(g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"payments_list",invoiceId:U,toScreen:"invoice"}),e(`${b}/invoices/${encodeURIComponent(U)}`))}),[e,b,y]),C=r.useCallback((j=>{const P=y.find((U=>U.id===j))?.customerID;P!=null&&(g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{customerId:P,fromScreen:"payments_list",toScreen:"customer"}),e(`${b}/customers/${encodeURIComponent(P)}`))}),[e,b,y]);return r.useEffect((()=>{const j=setTimeout((()=>u(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&t(ye({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(ye({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingPaymentsListPage,isReady:D}),c.jsx(ya,{navigate:e,tenantEmailDomain:n,activeType:p,searchValue:a,sortState:l,filters:m,sort:v,nextCursor:E,onSearchChange:o,onTypeChange:j=>{t(Ri(j)),t(ye({cacheOverride:!1,filters:m,sort:v}))},onSortChange:S,onViewTransactionCustomer:C,onViewTransactionInvoice:A})]})}const xa=t=>{const e=[t.firstName,t.lastName].filter((n=>n!=null&&n.trim()!=="")).join(" ").trim();return(t.company!=null&&t.company.trim()!==""?t.company.trim():"")||e||(t.email!=null&&t.email.trim()!==""?t.email.trim():"")||t.id};function an(){const t=L(),e=_(),{invoice_id:n,tenantEmailDomain:i}=F(),{areTenantIdsInSync:a}=R(),o=n!=null&&n!=="",s=k(Se),u=k((C=>Oi(C))),l=k(Mi),S=k((C=>An(C,n??""))),v=S.invoice,m=`/${i}/invoicing`,p=r.useRef(null),f=r.useRef("");r.useEffect((()=>{t(Ni()),p.current=null,f.current=""}),[t,n]),r.useEffect((()=>{a&&t(o&&n!=null?he({invoiceId:n}):hn({filters:{},keepExistingListItems:!1}))}),[a,t,n,o]),r.useEffect((()=>{o&&v!=null&&n!=null&&S.fetchState==="Completed"&&p.current!==n&&(p.current=n,t(Ui({contextInvoiceId:n,localData:Bi(v)})))}),[t,v,n,S.fetchState,o]),r.useEffect((()=>{if(o)return;const C=u.localData.customerId;C!==""&&C!==f.current&&(f.current=C,t(jn({filters:{customerId:C},keepExistingListItems:!1})),u.localData.invoiceToLink!==""&&t(Xe({localData:{...u.localData,customerId:C,invoiceToLink:""}})))}),[t,u.localData,o]);const I=r.useRef(l.fetchState);r.useEffect((()=>{const C=I.current;if(I.current=l.fetchState,C!=="Completed"&&l.fetchState==="Completed"){if(l.recordedInvoiceId!=null)return void e(`${m}/invoices/${encodeURIComponent(l.recordedInvoiceId)}`);e(`${m}/payments`)}}),[e,l.fetchState,l.recordedInvoiceId,m]);const E=r.useMemo((()=>s.customers.map((C=>({id:C.id,name:xa(C)})))),[s.customers]),h=k((C=>Vi(C,u.localData.customerId))),y=r.useMemo((()=>h.map((C=>{return{amountDue:(j=C.amountDue,P=Hi.currencySymbol,Pt("0,0.00",j,P)),amountDueValue:C.amountDue,id:C.id,label:C.invoiceNumber};var j,P}))),[h]),D=r.useMemo((()=>{if(!o||v==null)return;const C=v.currencyCode??"USD",j=v.amountDue?.amount??0;return{amountDue:Lt("0,0.00",v.amountDue),amountDueValue:j,currencyCode:C,customerName:v.customerName??v.customerID,invoiceId:v.id,invoiceNumber:v.invoiceNumber??v.id}}),[v,o]),b=o?`${m}/invoices/${encodeURIComponent(n??"")}`:`${m}/payments`,A=!o||S.fetchState==="Completed"&&u.localData.invoiceToLink!=="";return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingRecordPaymentPage,isReady:A}),c.jsx(_t,{customers:E,fieldHelp:u.fieldHelp,errorMessage:l.fetchState==="Error"?l.error?.message??"Failed to record payment. Please try again.":void 0,gatewayOptions:u.gatewayOptions,invoiceContext:D,invoiceOptions:y,isSubmitting:l.fetchState==="In-Progress",localData:u.localData,mode:o?"invoice":"customer",paymentMethodOptions:u.paymentMethodOptions,onBack:()=>{e(b)},onCancel:()=>{g.trackInvoicingActionClick(d.Event.invoicingRecordPaymentCancelled),e(b)},onChange:C=>{t(Xe({localData:C}))},onSubmit:()=>{g.trackInvoicingActionClick(d.Event.invoicingPaymentRecorded,{customerId:u.localData.customerId,invoiceId:o?n:u.localData.invoiceToLink,paymentMethod:u.localData.paymentMethod}),t(qi(o?n??void 0:void 0))}})]})}const zn=(t,e,n)=>{const i=`/${t}/invoicing/subscriptions/`;return n!=null?`${i}${encodeURIComponent(n)}/${e}/`:`${i}new/${e}/`},Aa=O((function(t,e){const{editView:n}=e,i=n.subscription,a=i?.status,o=a!=null&&e.commercialEditAllowedFromStatuses.includes(a);return{cancelReasonCodeOptions:n.cancelReasonCodeOptions,fieldHelp:n.fieldHelp,addons:n.addons,canEditCommercial:o,charges:n.charges,coupons:n.coupons,isLoading:!e.hasLoadedRecord&&(n.pageFetchState.fetchState==="Not-Started"||n.pageFetchState.fetchState==="In-Progress"||n.isFormLoading),isRunningAction:n.actionState.fetchState==="In-Progress",isSaving:n.fetchState==="In-Progress",lifecycleActionOptions:e.lifecycleActionOptions,localData:n.localData,plans:n.plans,shippingAddressLabel:n.shippingAddressLabel,hasUnsavedShippingAddress:n.hasUnsavedShippingAddress,subscription:i}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,a=i!=="",o=(s,u)=>{const{subscription:l}=e.editView;g.trackInvoicingActionClick(d.Event.invoicingSubscriptionLifecycleAction,{action:s,amount:l?.mrr?.amount,customerId:l?.customerID,fromScreen:"subscription_detail",status:l?.status,subscriptionId:i}),t(Rn({action:s,id:i,body:u}))};return{onBack:()=>e.navigate(`${n}/subscriptions`),onChange:s=>{t(ge({id:i,localData:s}))},onChangeTermEnd:a?s=>{const u=s?.trim()??"";u!==""&&o("change_term_end",{term_ends_at:u})}:void 0,onCustomerClick:s=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{customerId:s,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${n}/customers/${encodeURIComponent(s)}`,"_blank","noopener,noreferrer")},onDiscardEdit:()=>{t(fe(ve)),t(Ki({id:i}))},onOpenAddress:()=>{const s=zn(e.tenantEmailDomain??"",ve,i),u=Z(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(s,{state:{pathnameStackToGoBack:u}})},onViewInvoices:()=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"subscription_detail",subscriptionId:i,toScreen:"invoices"}),e.navigate(`${n}/invoices`)},onSaveEdit:s=>{g.trackInvoicingActionClick(d.Event.invoicingSubscriptionEdited,{subscriptionId:i}),t(ge({id:i,localData:s})),t(Fn({id:i}))},onCancelSubscription:a?s=>{o("cancel",{cancel_reason_code:s.cancelReasonCode,end_of_term:!1,...s.cancelReason!=null&&s.cancelReason.trim()!==""?{cancel_reason:s.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:a?(s,u)=>{s!=="pause"?o(s):o(s,u!=null&&u.trim()!==""?{resume_date:u.trim()}:void 0)}:void 0}}))($t);function Da(){const t=L(),e=_(),n=Y(),{subscription_id:i,tenantEmailDomain:a}=F(),{areTenantIdsInSync:o}=R(),s=k((y=>Me(y,i))),{subscriptionCommercialEditAllowedFromStatuses:u,subscriptionLifecycleActionOptions:l,subscriptionMetadataEditAllowedFromStatuses:S}=s,v=s.pageFetchState.fetchState,m=v==="Completed"&&!s.isFormLoading,[p,f]=r.useState(m?i:void 0);r.useEffect((()=>{i!=null&&m&&f(i)}),[i,m]);const I=p===i;Ce(o),r.useEffect((()=>{o&&i!=null&&t(Qi({id:i}))}),[o,i,t]);const E=r.useCallback((y=>t(zi({id:y}))),[t]),h=X(s.fetchState,s.isFormLoading,i,E);return N(v)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingSubscriptionDetailPage,isReady:m}),c.jsx(Aa,{hasLoadedRecord:I,commercialEditAllowedFromStatuses:u,editView:s,lifecycleActionOptions:l,location:n,metadataEditAllowedFromStatuses:S,navigate:e,subscriptionId:i??"",tenantEmailDomain:a},h)]})}const ja=O((function(t,e){const n=Me(t,e.subscriptionId);return{fieldHelp:n.fieldHelp,addons:n.addons,charges:n.charges,coupons:n.coupons,customers:n.customers,errorMessage:n.fetchState==="Error"?n.error?.message??"Failed to save subscription.":void 0,isSubmitting:n.fetchState==="In-Progress",isLoading:n.isFormLoading,localData:n.localData,mode:n.mode,plans:n.plans,shippingAddressLabel:n.shippingAddressLabel}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,a=i!=null?"edit":"create";return{onCancel:()=>{g.trackInvoicingActionClick(d.Event.invoicingSubscriptionFormCancelled),t(Tn({id:i})),t(fe(ve)),i==null?e.navigate(`${n}/subscriptions`):e.navigate(`${n}/subscriptions/${encodeURIComponent(i)}`)},onChange:o=>{t(ge({id:i,localData:o}))},onOpenAddress:()=>{g.trackInvoicingActionClick(d.Event.invoicingAddressOpened,{entity:"subscription",fromScreen:"subscription_form"});const o=zn(e.tenantEmailDomain??"",ve,i),s=Z(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(o,{state:{pathnameStackToGoBack:s}})},onSubmit:()=>{g.trackInvoicingActionClick(d.Event.invoicingSubscriptionSaved,{mode:a}),t(Fn({id:i}))}}}))(wt);function La(){const t=L(),e=_(),n=Y(),{subscription_id:i,tenantEmailDomain:a}=F(),[o]=W(),{areTenantIdsInSync:s}=R(),u=o.get("customerId"),{fetchState:l,savedSubscriptionId:S}=k((p=>Gi(p,i))),v=k((p=>Me(p,i).localData));Ce(s),r.useEffect((()=>{s&&t(Ji({subscriptionId:i}))}),[s,i,t]);const m=r.useRef(!1);return r.useEffect((()=>{m.current||i!=null||u==null||u===""||v.customerId!==""||(m.current=!0,t(ge({id:i,localData:{...v,customerId:u}})))}),[u,i,v,t]),r.useEffect((()=>{if(l==="Completed"){const p=S??i,f=p!=null?`/${a}/invoicing/subscriptions/${encodeURIComponent(p)}`:`/${a}/invoicing/subscriptions`;e(f),t(Tn({id:i}))}}),[l,S,i,t,e,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingSubscriptionFormPage}),c.jsx(ja,{location:n,navigate:e,subscriptionId:i,tenantEmailDomain:a})]})}const _a=O((function(t){const e=On(t),{fetchState:n}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,isLoading:n==="Not-Started"||n==="In-Progress"&&e.subscriptions.length===0,isLoadingMore:n==="In-Progress"&&e.subscriptions.length>0,cancelReasonCodeOptions:e.cancelReasonCodeOptions,lifecycleActionOptions:e.subscriptionLifecycleActionOptions,subscriptions:e.subscriptions,tabIds:e.tabIds}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,i=(a,o,s)=>{const u=e.subscriptions.find((l=>l.id===a));g.trackInvoicingActionClick(d.Event.invoicingSubscriptionLifecycleAction,{action:o,amount:u?.mrr?.amount,customerId:u?.customerID,fromScreen:"subscriptions_list",status:u?.status,subscriptionId:a}),t(Rn({action:o,id:a,body:s}))};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onAddSubscription:()=>{g.trackInvoicingActionClick(d.Event.invoicingAddSubscriptionClicked),e.navigate(`${n}/subscriptions/new`)},onImportCsv:()=>{g.trackInvoicingActionClick(d.Event.invoicingImportCsvClicked,{entity:"subscriptions"}),e.navigate(`${n}/data_import`)},onChangeTermEnd:(a,o)=>{const s=o?.trim()??"";s!==""&&i(a,"change_term_end",{term_ends_at:s})},onSubscriptionAction:(a,o,s)=>{o!=="pause"?i(a,o):i(a,o,s!=null&&s.trim()!==""?{resume_date:s.trim()}:void 0)},onCancelSubscription:(a,o)=>{i(a,"cancel",{cancel_reason_code:o.cancelReasonCode,end_of_term:!1,...o.cancelReason!=null&&o.cancelReason.trim()!==""?{cancel_reason:o.cancelReason.trim()}:{}})},onSubscriptionClick:a=>{g.trackInvoicingActionClick(d.Event.invoicingSubscriptionRowClicked,{subscriptionId:a}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onViewSubscriptionInvoices:()=>{e.navigate(`${n}/invoices`)},onLoadMore:()=>{e.nextCursor!=null&&(g.trackInvoicingActionClick(d.Event.invoicingListLoadMore,{entity:"subscriptions",status:e.activeStatus}),t(Zi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort})))}}}))(Ft);function Pa(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),[a,o]=r.useState(""),[s,u]=r.useState(""),[l,S]=r.useState(null),v=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),m=r.useMemo((()=>({search:s.trim()!==""?s.trim():void 0})),[s]),{activeStatus:p,appliedSearch:f,appliedSort:I,nextCursor:E,subscriptionListFetchState:h,runningActionSubscriptionId:y,subscriptions:D}=k((C=>{const j=On(C);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:j.sort,nextCursor:j.nextCursor,subscriptionListFetchState:j.fetchState,runningActionSubscriptionId:j.runningActionId??null,subscriptions:j.subscriptions}}),q),b=h==="Completed";r.useEffect((()=>{const C=setTimeout((()=>u(a)),300);return()=>clearTimeout(C)}),[a]),r.useEffect((()=>{i&&t(en({cacheOverride:!1}))}),[i,t]),r.useEffect((()=>{i&&(m.search!==f||v?.field!==I?.field||v?.dir!==I?.dir)&&t(en({cacheOverride:!0,filters:m,sort:v}))}),[i,t,m,v,f,I]);const A=r.useRef(y);return r.useEffect((()=>{const C=A.current!=null&&y==null;A.current=y,C&&i&&t(Wi())}),[y,i,t]),N(h)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingSubscriptionsListPage,isReady:b}),c.jsx(_a,{navigate:e,tenantEmailDomain:n,activeStatus:p,searchValue:a,sortState:l,filters:m,sort:v,nextCursor:E,runningActionSubscriptionId:y,subscriptions:D,onSearchChange:o,onStatusChange:C=>t(Yi(C)),onSortChange:S})]})}const $a=O((function(t,e){const{readView:n}=e;return{isLoading:n.fetchState==="Not-Started"||n.fetchState==="In-Progress",isRunningAction:n.actionState.fetchState==="In-Progress",transaction:n.transaction,transactionId:e.transactionId}}),(function(t,e){const n=`/${e.tenantEmailDomain}/invoicing`,{transactionId:i}=e;return{onBack:()=>e.navigate(`${n}/payments`),onCustomerClick:a=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"transaction_detail",toScreen:"customer"}),e.navigate(`${n}/customers/${encodeURIComponent(a)}`)},onInvoiceClick:a=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${n}/invoices/${encodeURIComponent(a)}`)},onSubscriptionClick:a=>{g.trackInvoicingActionClick(d.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${n}/subscriptions/${encodeURIComponent(a)}`)},onCapture:i!==""?()=>{g.trackInvoicingActionClick(d.Event.invoicingTransactionCaptured,{transactionId:i}),t(no({action:"capture",id:i}))}:void 0}}))(Rt);function wa(){const t=L(),e=_(),{tenantEmailDomain:n,transaction_id:i}=F(),{areTenantIdsInSync:a}=R(),o=k((u=>Xi(u,i??""))),s=o.fetchState==="Completed";return r.useEffect((()=>{a&&i!=null&&t(eo({id:i}))}),[a,i,t]),N(o.fetchState)?c.jsx(M,{}):c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingTransactionDetailPage,isReady:s}),c.jsx($a,{navigate:e,tenantEmailDomain:n,transactionId:i??"",readView:o})]})}function Kn(t={}){const{enabled:e=!0,fetchSyncHealth:n=!1,loadAccountingPickers:i=!1,reuseCached:a=!1}=t,o=L(),{areTenantIdsInSync:s}=R(),u=k(Ne),l=u.connection?.connected===!0,S=u.connectionFetchState.fetchState;return r.useEffect((()=>{e&&s&&(a&&S!=="Not-Started"||o(Mn()),n&&o(to()))}),[s,o,e,n,a]),r.useEffect((()=>{e&&s&&l&&i&&o(io())}),[s,o,e,l,i]),{isQboConnected:l,qboView:u}}const Fa={branding:"invoicing_branding_save",dunning:"invoicing_dunning_settings_save",quickbooks:"invoicing_qbo_settings_save"};function ee(t){const e=L(),{areTenantIdsInSync:n}=R(),{tenantEmailDomain:i}=F(),{fetchState:a,fieldHelp:o,logoFile:s,saveState:u,settings:l,stripeConnectState:S}=k(oo),{configError:v,configFetchState:m,dunningScheduleActionOptions:p,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:I,qboSyncStatusOptions:E}=k(Nn),h=k(Ne);Kn({enabled:t==="quickbooks",fetchSyncHealth:!0,loadAccountingPickers:!0});const y=k(Ie),D=t==="dunning"||t==="quickbooks",b=y.companyId??J.getSignedInUserTenant(i??"")?.companyId,A=k(($=>En($,b))),C=ao(y.userRole??[]),j=y.tenantId??"",P=J.getSignedInUser(),U={userId:P?.userId??"",sessionId:P?.zeniSessionId??"",tenantId:j},T=s?.fileId,ne=k(($=>T!=null&&T!==""?co($,T):void 0)),Ue=k(($=>T!=null&&T!==""?so($,T):void 0)),Gn=T!=null&&T!==""&&ne!=null?{[T]:ne}:{},Jn=T!=null&&T!==""&&Ue!=null?{[T]:Ue}:{};r.useEffect((()=>(e(nn()),()=>{e(nn())})),[e]),r.useEffect((()=>{n&&(a!=="Not-Started"&&a!=="Error"||e(Oe()))}),[n,e,a]),r.useEffect((()=>{n&&D&&m==="Not-Started"&&e(me())}),[n,e,m,D]),r.useEffect((()=>{if(!n)return;const $=P?.userId;$!=null&&$!==""&&j!==""&&He.shouldFetchActiveTenant(j)&&(He.markActiveTenantFetchStarted(j),e(ro($,j,P?.zeniSessionId)))}),[n,e,P?.userId,P?.zeniSessionId,j]);const Wn=p.length>0||f.length>0,Yn=a==="Not-Started"||a==="In-Progress"&&l==null||D&&!Wn&&(m==="Not-Started"||m==="In-Progress"),Zn=a==="Completed"&&(!D||m==="Completed"),Be=A.externalConnections?.revenue?.find(($=>$.connectionName==="chargebee"))?.connectionId,ke=se?.invoicingMicroServiceBaseUrl,Ve=ke!=null&&ke.length>0?`${ke}/1.0/webhooks/stripe`:"",z={deleteConnectionError:A.externalConnections?.deleteConnectionError?.message,deleteConnectionState:A.externalConnections?.deleteConnectionState??"Not-Started",integrationsView:A,isAdmin:C,isStripeBusy:S.fetchState==="In-Progress",onConnectStripe:$=>{g.trackInvoicingActionClick(d.Event.invoicingStripeConnectClicked,{fromScreen:t??"hub"}),e(Io($))},onDisconnect:($,B)=>{j!==""&&(g.trackInvoicingActionClick(d.Event.invoicingIntegrationDisconnected,{entity:B,entityId:$,fromScreen:t??"hub"}),e(fo(j,$,tn(B))))},onDisconnectStripe:()=>{g.trackInvoicingActionClick(d.Event.invoicingStripeDisconnected,{fromScreen:t??"hub"}),e(So())},onReconnectQBO:()=>{g.trackInvoicingActionClick(d.Event.invoicingQboAction,{action:"reconnect",fromScreen:t??"hub"});const $=y.tenantEmailDomain??i??"";pe.init("/connection/auth",$),pe.handleClick()},onRefreshQBO:()=>{A.integrations.refreshQBO.fetchState!=="In-Progress"&&(g.trackInvoicingActionClick(d.Event.invoicingQboAction,{action:"refresh",fromScreen:t??"hub"}),e(Vn()))},onSaveChargeBeeCredentials:($,B)=>{Be!=null&&j!==""&&(g.trackInvoicingActionClick(d.Event.invoicingChargebeeCredentialsSaved,{fromScreen:t??"hub"}),e(mo(j,Be,tn("revenue"),po("chargebee"),{api_key:$,site:B})))},saveChargeBeeError:A.externalConnections?.saveAPIKeyConnectionError?.message,saveChargeBeeState:A.externalConnections?.saveAPIKeyConnectionState??"Not-Started",settings:l,stripeError:S.fetchState==="Error"?S.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Ve};return{authParams:U,deleteFileStatusById:Gn,fieldHelp:o,dunningScheduleActionOptions:p,filesEndPoint:se?.fileMicroServiceBaseUrl??"",integrationsSectionProps:z,isInvoicingPageReady:Zn,isLoading:Yn,isSaving:u.fetchState==="In-Progress",isStripeBusy:S.fetchState==="In-Progress",logoFile:s,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:I,qboSyncStatusOptions:E,qboView:h,saveErrorMessage:u.fetchState==="Error"?u.error?.message??"Failed to save settings.":D&&m==="Error"?v?.message??"Failed to load invoicing configuration.":void 0,settings:l,stripeError:S.fetchState==="Error"?S.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Ve,updateFileStatusById:Jn,onConnectStripe:z.onConnectStripe,onDeleteFile:$=>{g.trackInvoicingActionClick(d.Event.invoicingLogoRemoved,{fromScreen:t??"hub"}),e(vo($,j))},onDisconnectStripe:z.onDisconnectStripe,onEditFileName:($,B)=>{g.trackInvoicingActionClick(d.Event.invoicingLogoRenamed,{fromScreen:t??"hub"}),e(go($,B.split(".")[0],j))},onReconnectQBO:z.onReconnectQBO,onRefreshQBO:z.onRefreshQBO,onRetryQboSyncTask:$=>{g.trackInvoicingActionClick(d.Event.invoicingQboAction,{action:"retry_task",entityId:$,fromScreen:t??"hub"}),e(Bn($))},onSave:$=>{g.trackInvoicingActionClick(d.Event.invoicingSettingsSaved,{fieldsChanged:Object.keys($).filter((B=>JSON.stringify($[B])!==JSON.stringify(l?.[B]))),tab:t??"hub"}),e(uo({settings:$,snackbarSection:Fa[t??""]}))},onStartQboBackfill:$=>{g.trackInvoicingActionClick(d.Event.invoicingQboAction,{action:"backfill",fromScreen:t??"hub"}),e(Un($))},updateFilesEntity:$=>{g.trackInvoicingActionClick(d.Event.invoicingLogoUploaded,{fromScreen:t??"hub"}),e(lo({files:$}))}}}function cn({appContent:t}){const e=_(),n=Y(),i=L(),{tenantEmailDomain:a}=F(),o=ee("branding"),s=k((l=>ho(l)));r.useEffect((()=>{s.saveState.fetchState==="Completed"&&i(Co())}),[s.saveState.fetchState,i]);const u=_e(s.saveState.fetchState);return r.useEffect((()=>{u==="In-Progress"&&s.saveState.fetchState==="Completed"&&e("..")}),[u,s.saveState.fetchState,e]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingBrandingSettingsPage,isReady:o.isInvoicingPageReady}),c.jsx(Tt,{address:s.address,fieldHelp:s.fieldHelp,addressLabel:s.addressLabel,appContent:t,authParams:o.authParams,dateFormatOptions:s.dateFormatOptions,deleteFileStatusById:o.deleteFileStatusById,filesEndPoint:o.filesEndPoint,isLoading:o.isLoading,isSaving:o.isSaving,localData:s.localData,logoFile:o.logoFile,saveErrorMessage:o.saveErrorMessage,settings:o.settings,updateFileStatusById:o.updateFileStatusById,onBackClick:()=>e(".."),onChange:l=>{i(yo({localData:l}))},onDeleteFile:o.onDeleteFile,onEditFileName:o.onEditFileName,onOpenAddress:()=>{g.trackInvoicingActionClick(d.Event.invoicingAddressOpened,{entity:"branding",fromScreen:"settings_branding"});const l=`/${a}/invoicing/settings/branding/${Eo}/`,S=Z(n.state?.pathnameStackToGoBack,n.pathname);e(l,{state:{pathnameStackToGoBack:S}})},onSubmit:()=>{g.trackInvoicingActionClick(d.Event.invoicingSettingsSaved,{tab:"branding"}),i(ko())},updateFilesEntity:o.updateFilesEntity})]})}function Ra(){const t=_(),e=ee("dunning");return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingDunningSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(Ot,{dunningScheduleActionOptions:e.dunningScheduleActionOptions,isLoading:e.isLoading,isSaving:e.isSaving,saveErrorMessage:e.saveErrorMessage,settings:e.settings,onBackClick:()=>t(".."),onSave:e.onSave})]})}function Ta(){const t=_(),e=ee("integrations");return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingIntegrationsSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(Mt,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>t("../quickbooks"),onOpenPaymentDestination:()=>t("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>t("..")})]})}function Oa(){const t=_(),e=ee("payment-destination");return c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingPaymentDestinationSettingsPage,isReady:e.isInvoicingPageReady}),c.jsx(Nt,{fieldHelp:e.fieldHelp,isLoading:e.isLoading,isStripeBusy:e.isStripeBusy,saveErrorMessage:e.saveErrorMessage,settings:e.settings,stripeError:e.stripeError,stripeWebhookUrl:e.stripeWebhookUrl,onBackClick:()=>t(".."),onConnectStripe:e.onConnectStripe})]})}const Ma=["autoCreateItems","closedPeriodVoidAsCreditMemo","customerMatching","isSyncEnabled","syncStartDate","trackingCategoriesEnabled"],Na=O((function(t){const e=Hn(t);return{accountMappingKindOptions:e.accountMappingKindOptions,fieldHelp:e.fieldHelp,accounts:e.accounts,connection:e.connection,customerMatchingOptions:e.customerMatchingOptions,isBackfilling:e.backfillState.fetchState==="In-Progress",isLoading:e.isLoading,isSaving:e.saveState.fetchState==="In-Progress",isSyncEnabledSaved:e.isSyncEnabledSaved,localData:e.localData,nestedAccountHierarchy:e.nestedAccountHierarchy,retryFetchStateByTaskId:e.retryFetchStateByTaskId,saveErrorMessage:e.saveState.fetchState==="Error"?e.saveState.error?.message:void 0,syncHealth:e.syncHealth,syncStatusOptions:e.syncStatusOptions}}),(function(t){return{onChange:e=>{t(Ao({localData:e}))},onReset:()=>{g.trackInvoicingActionClick(d.Event.invoicingSettingsReset,{tab:"quickbooks"}),t(xo())},onRetryTask:e=>{g.trackInvoicingActionClick(d.Event.invoicingQboAction,{action:"retry_task",entityId:e,fromScreen:"settings_qbo"}),t(Bn(e))},onStartBackfill:e=>{g.trackInvoicingActionClick(d.Event.invoicingQboAction,{action:"backfill",fromScreen:"settings_qbo"}),t(Un(e))}}}))(Ut);function Ua(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),i=k(Ie),{configFetchState:a,localData:o,savedLocalData:s,saveState:u,settingsFetchState:l}=k(Hn),S=r.useMemo((()=>{return m=o,p=s,[...[...new Set([...Object.keys(m.accountIdByMappingCode),...Object.keys(p.accountIdByMappingCode)])].some((f=>(m.accountIdByMappingCode[f]??"")!==(p.accountIdByMappingCode[f]??"")))?["account_mappings"]:[],...Ma.filter((f=>m[f]!==p[f]))];var m,p}),[o,s]),v=_e(u.fetchState);return r.useEffect((()=>{v==="In-Progress"&&u.fetchState==="Completed"&&e("..")}),[e,v,u.fetchState]),r.useEffect((()=>{l!=="Not-Started"&&l!=="Error"||t(Oe())}),[t,l]),r.useEffect((()=>{a==="Not-Started"&&t(me())}),[a,t]),Kn({fetchSyncHealth:!0,loadAccountingPickers:!0}),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingQboSettingsPage}),c.jsx(Na,{onBackClick:()=>e(".."),onReconnect:()=>{g.trackInvoicingActionClick(d.Event.invoicingQboAction,{action:"reconnect",fromScreen:"settings_qbo"}),pe.init("/connection/auth",i.tenantEmailDomain??n??""),pe.handleClick()},onRefresh:()=>{g.trackInvoicingActionClick(d.Event.invoicingQboAction,{action:"refresh",fromScreen:"settings_qbo"}),t(Vn())},onSave:()=>{g.trackInvoicingActionClick(d.Event.invoicingSettingsSaved,{fieldsChanged:S,tab:"quickbooks"}),t(bo())}})]})}const Ba={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function Va(){const t=rn(),e=L(),n=_(),[i,a]=W(),o=ee(),{canEnableInvoicing:s,isEnablingInvoicing:u,isInvoicingEnabled:l,isQboConfigured:S,isStripeConnected:v}=k(Nn),m=i.get("tab");return r.useEffect((()=>{if(m==null)return;const p=Ba[m];a({},{replace:!0}),p!=null&&n(p,{replace:!0})}),[m,n,a]),c.jsxs(c.Fragment,{children:[c.jsx(w,{event:d.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),c.jsx(Bt,{analytics:g,integrationsSectionProps:{...o.integrationsSectionProps,onConfigureQBO:()=>n("quickbooks"),onOpenPaymentDestination:()=>n("payment-destination")},isEnablingInvoicing:u,isLoading:o.isLoading,meetingUrl:t("invoicing_settings"),settings:o.settings,onBrandingClick:()=>n("branding"),onDunningClick:()=>n("dunning"),canEnableInvoicing:s,isQboConfigured:S,isStripePaymentsReady:v,onEnableInvoicingClick:l?void 0:()=>{g.trackInvoicingActionClick(d.Event.invoicingEnableClicked),e(Do())}})]})}function sn(){return c.jsxs(oe,{children:[c.jsx(x,{index:!0,element:c.jsx(Va,{})}),c.jsx(x,{path:"payment-destination",element:c.jsx(Oa,{})}),c.jsx(x,{path:"branding",element:c.jsx(cn,{})}),c.jsx(x,{path:"branding/:addressType",element:c.jsx(cn,{appContent:c.jsx(K,{isSubPage:!0,hideAddressBackButton:!0})})}),c.jsx(x,{path:"integrations",element:c.jsx(Ta,{})}),c.jsx(x,{path:"dunning",element:c.jsx(Ra,{})}),c.jsx(x,{path:"quickbooks",element:c.jsx(Ua,{})}),c.jsx(x,{path:"*",element:c.jsx(V,{to:"..",replace:!0})})]})}function Sc(){const t=L(),e=_(),{tenantEmailDomain:n}=F(),{areTenantIdsInSync:i}=R(),{enableState:a,fetchState:o,status:s}=k(Ln),u=_e(a.fetchState),l=`/${n}/invoicing`,S=r.useRef(!1),v=k((m=>Ne(m).connectionFetchState.fetchState));return r.useEffect((()=>{i&&(o!=="Not-Started"?o!=="Error"||S.current||(S.current=!0,t(me({cacheOverride:!1}))):t(me({cacheOverride:!1})))}),[i,t,o]),r.useEffect((()=>{i&&v==="Not-Started"&&t(Mn())}),[i,t,v]),r.useEffect((()=>{u==="In-Progress"&&a.fetchState==="Completed"&&(e(`${l}/catalog`),t(jo()))}),[u,a.fetchState,l,t,e]),s==null&&o!=="Error"?c.jsx(Vt,{fetchState:"In-Progress"}):s==="not_started"?c.jsxs(oe,{children:[c.jsx(x,{path:"promo",element:c.jsx(on,{})}),c.jsx(x,{path:"*",element:c.jsx(V,{to:`${l}/promo`,replace:!0})})]}):s==="settings"?c.jsxs(oe,{children:[c.jsx(x,{path:"promo",element:c.jsx(on,{})}),c.jsx(x,{path:"settings/*",element:c.jsx(sn,{})}),c.jsx(x,{path:"*",element:c.jsx(V,{to:`${l}/settings`,replace:!0})})]}):c.jsxs(oe,{children:[c.jsx(x,{path:"/",element:c.jsx(V,{to:"overview",replace:!0})}),c.jsx(x,{path:"overview",element:c.jsx(Ea,{})}),c.jsx(x,{path:"promo",element:c.jsx(V,{to:`${l}/overview`,replace:!0})}),c.jsx(x,{path:"customers",element:c.jsx(ea,{})}),c.jsx(x,{path:"customers/new",element:c.jsx(Zo,{})}),c.jsx(x,{path:"customers/new/:addressType",element:c.jsx(K,{})}),c.jsx(x,{path:"customers/:customer_id",element:c.jsx(Wo,{})}),c.jsx(x,{path:"customers/:customer_id/:addressType",element:c.jsx(K,{})}),c.jsx(x,{path:"subscriptions",element:c.jsx(Pa,{})}),c.jsx(x,{path:"subscriptions/new",element:c.jsx(La,{})}),c.jsx(x,{path:"subscriptions/new/:addressType",element:c.jsx(K,{})}),c.jsx(x,{path:"subscriptions/:subscription_id",element:c.jsx(Da,{})}),c.jsx(x,{path:"subscriptions/:subscription_id/:addressType",element:c.jsx(K,{})}),c.jsx(x,{path:"invoices",element:c.jsx(Ia,{})}),c.jsx(x,{path:"invoices/create",element:c.jsx(qo,{})}),c.jsx(x,{path:"invoices/:invoice_id",element:c.jsx(Sa,{})}),c.jsx(x,{path:"invoices/:invoice_id/record-payment",element:c.jsx(an,{})}),c.jsx(x,{path:"invoices/:invoice_id/issue-credit-note",element:c.jsx(Ca,{})}),c.jsx(x,{path:"payments",element:c.jsx(ba,{})}),c.jsx(x,{path:"payments/record",element:c.jsx(an,{})}),c.jsx(x,{path:"payments/:transaction_id",element:c.jsx(wa,{})}),c.jsx(x,{path:"credits",element:c.jsx(Go,{})}),c.jsx(x,{path:"credits/:credit_note_id",element:c.jsx(zo,{})}),c.jsx(x,{path:"discounts",element:c.jsx(la,{})}),c.jsx(x,{path:"discounts/new",element:c.jsx(Vo,{})}),c.jsx(x,{path:"discounts/:coupon_id",element:c.jsx(ra,{})}),c.jsx(x,{path:"dunning",element:c.jsx(ma,{})}),c.jsx(x,{path:"dunning/:case_id",element:c.jsx(ga,{})}),c.jsx(x,{path:"catalog",element:c.jsx(Uo,{})}),c.jsx(x,{path:"catalog/new",element:c.jsx(Oo,{})}),c.jsx(x,{path:"catalog/:item_id",element:c.jsx(wo,{})}),c.jsx(x,{path:"settings/*",element:c.jsx(sn,{})}),c.jsx(x,{path:"audit_log",element:c.jsx(_o,{})}),c.jsx(x,{path:"data_import",element:c.jsx(oa,{})}),c.jsx(x,{path:"data_import/migrate",element:c.jsx(ca,{})}),c.jsx(x,{path:"data_import/:sessionId",element:c.jsx(ta,{})}),c.jsx(x,{path:"*",element:c.jsx(M,{})})]})}export{Sc as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as a}from"./liveblocks-DtuUpF5h.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-Dk5JD2l2.js";import{UF as k,UG as v,UH as T,JG as D,Js as G,UI as A,UJ as oe,UK as se,Jw as ie,gl as $,JD as le,JA as de}from"./zeni-epic-state-BtP47QJT.js";import{a1 as x,N as d,a2 as re,m as j,Z as U,a3 as ce,a4 as me,a5 as pe,p as H,c as ue,g as he,a6 as ge,d as xe,E as fe,j as we,a7 as be,a8 as Se,$ as ye,a9 as ke,aa as ve,ab as je,ac as $e}from"./index-
|
|
1
|
+
import{j as a}from"./liveblocks-DtuUpF5h.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-Dk5JD2l2.js";import{UF as k,UG as v,UH as T,JG as D,Js as G,UI as A,UJ as oe,UK as se,Jw as ie,gl as $,JD as le,JA as de}from"./zeni-epic-state-BtP47QJT.js";import{a1 as x,N as d,a2 as re,m as j,Z as U,a3 as ce,a4 as me,a5 as pe,p as H,c as ue,g as he,a6 as ge,d as xe,E as fe,j as we,a7 as be,a8 as Se,$ as ye,a9 as ke,aa as ve,ab as je,ac as $e}from"./index-uoDX7H4L.js";import{n as m}from"./mui-DAOUhz91.js";import f from"./NotFoundScreen-CyVGP3Vp.js";import{a as I}from"./sentry-BWDuLt7o.js";import"./recharts-BMD3jyO6.js";import"./analytics-C6U4wpfB.js";import"./plaid-DBHSfOGH.js";import"./dnd-CSZKLHxv.js";import"./stripe-cKAAJElX.js";import"./lottie-BlG_vWSt.js";import"./lexical-BtWXzxnq.js";import"./pdf-iocWnEuY.js";import"./utils-CWVNtCN5.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]="61edcafd-b3d5-458d-818a-1e5541461b3e",e._sentryDebugIdIdentifier="sentry-dbid-61edcafd-b3d5-458d-818a-1e5541461b3e")}catch{}})();const Ie=m.div`
|
|
2
2
|
display: flex;
|
|
3
3
|
height: 100%;
|
|
4
4
|
width: 100%;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as u}from"./liveblocks-DtuUpF5h.js";import{a as g}from"./sentry-BWDuLt7o.js";import{u as O,g as _,h as w,t as V,j as l,N as T}from"./core-Dk5JD2l2.js";import{z as r,E as M,G as P,T as A,m as N,V as X,_ as $,$ as B,X as G}from"./index-
|
|
1
|
+
import{j as u}from"./liveblocks-DtuUpF5h.js";import{a as g}from"./sentry-BWDuLt7o.js";import{u as O,g as _,h as w,t as V,j as l,N as T}from"./core-Dk5JD2l2.js";import{z as r,E as M,G as P,T as A,m as N,V as X,_ as $,$ as B,X as G}from"./index-uoDX7H4L.js";import{fI as R,U8 as W,UB as q,Us as H,gl as J,gn as K,Ux as Q,gX as Y,dk as Z,UC as ee,UD as te}from"./zeni-epic-state-BtP47QJT.js";import{n as ne}from"./mui-DAOUhz91.js";import{u as se}from"./useDeviceId-BRjUTxWs.js";import{f as ae}from"./analyticsHelper-DdV5jqT5.js";import{t as ie}from"./getLocaleForTenant-C8sqw5jB.js";import"./recharts-BMD3jyO6.js";import"./analytics-C6U4wpfB.js";import"./plaid-DBHSfOGH.js";import"./dnd-CSZKLHxv.js";import"./stripe-cKAAJElX.js";import"./lottie-BlG_vWSt.js";import"./lexical-BtWXzxnq.js";import"./pdf-iocWnEuY.js";import"./utils-CWVNtCN5.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]="62b9ea4d-39d3-4997-b492-be41ff992808",t._sentryDebugIdIdentifier="sentry-dbid-62b9ea4d-39d3-4997-b492-be41ff992808")}catch{}})();const U=(t,a)=>t!=null&&t.length>0&&a==="magic_links";function Ue(){const t=O(),a=_(),m=w(),[k]=V(),n=k.get("token"),p=k.get("stytch_token_type"),f=r.getMagicLinkCodeVerifier(),i=se(),{otpChallenge:d,twoFAPhoneNumber:x,magicLinkEmail:c,verifyDeviceFetchState:C,resendVerifyDeviceOTPFetchState:D}=l((e=>e.tenantState)),S=l((e=>e.tenantState.fetchState)),y=l((e=>e.tenantState.activeTenantFetchState.fetchState)),I=l((e=>e.tenantState.signInState)),h=l((e=>e.tenantState.magicLinkSignInFetchState.fetchState)),s=l((e=>e.tenantState.loggedInUser)),o=l((e=>R(e))),b=l((e=>W(e))),z=r.getSignedInUser(),v=M().mode;g.useEffect((()=>{s?.zeniSessionId==null&&n!=null&&U(n,p)&&i!=null&&f!=null&&(r.saveMagicLinkTriggered(n),t(q(n,i,f)))}),[n,p,t,i,f,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),Y().then((()=>{const e=G();e!=null&&A(e)})),setTimeout((()=>{N.trackLogin(X.Event.loginSuccess,"email",Z(o.productSettings))}),2e3))}),[I,S,y,s,o,b,v,a.state,t]);const E=g.useCallback((()=>{m("/signin/auth")}),[m]),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($,{phoneNumber:x,verifyOtpFetchState:C.fetchState,resendVerifyDeviceOTPFetchState:D,onResendOtp:j,onVerifyOtp:F,onCancelVerifyDevice:E});if(I==="In-Progress"&&S==="Completed"&&s?.zeniSessionId!=null&&o!=null||z!=null){const e=a.state?.origin??"/";return u.jsx(T,{to:e,state:{...a.state,origin:""}})}if(!U(n,p)||f==null||h==="Error"){const e=a.state?.origin??"/",L=n!=null&&r.getLastUsedMagicLinkToken()===n;return u.jsx(T,{to:e,state:{...a.state,origin:"",magicLinkAlreadyUsed:L,magicLinkExpired:!L&&(r.isMagicLinkTriggered(n??"")||h==="Error"&&s?.zeniSessionId==null)}})}return u.jsx(oe,{"data-testid":"smooth-loader",children:u.jsx(B,{size:"ExtraLarge",start:!0})})}const oe=ne.div`
|
|
2
2
|
position: fixed;
|
|
3
3
|
top: 0;
|
|
4
4
|
left: 0;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as D}from"./liveblocks-DtuUpF5h.js";import{a as f}from"./sentry-BWDuLt7o.js";import{u as te,j as t,i as $e,g as Ge,h as Ue,q as F}from"./core-Dk5JD2l2.js";import{fI as ne,U9 as Me,Ua as se,gc as xe,fH as Ne,Uj as Pe,Uc as Re,Ud as je,q2 as Ve,gp as Oe,Ug as b,Ul as Le,Um as Q,gq as Ze,Un as qe,Ej as ze,h4 as He,cW as We,Uo as Ye,gb as Je,gr as Ke}from"./zeni-epic-state-BtP47QJT.js";import{w as Qe,i as Xe,d as ea,c as aa,e as ta,j as na,u as sa,g as c,k as oa,h as ia,z as ra,f as da,o as ca,r as la,x as ua,q as fa,s as X,L as ma,F as ha,I as ba,p as S,m as ee,A as pa,O as ae,C as ga,D as Sa}from"./index-
|
|
1
|
+
import{j as D}from"./liveblocks-DtuUpF5h.js";import{a as f}from"./sentry-BWDuLt7o.js";import{u as te,j as t,i as $e,g as Ge,h as Ue,q as F}from"./core-Dk5JD2l2.js";import{fI as ne,U9 as Me,Ua as se,gc as xe,fH as Ne,Uj as Pe,Uc as Re,Ud as je,q2 as Ve,gp as Oe,Ug as b,Ul as Le,Um as Q,gq as Ze,Un as qe,Ej as ze,h4 as He,cW as We,Uo as Ye,gb as Je,gr as Ke}from"./zeni-epic-state-BtP47QJT.js";import{w as Qe,i as Xe,d as ea,c as aa,e as ta,j as na,u as sa,g as c,k as oa,h as ia,z as ra,f as da,o as ca,r as la,x as ua,q as fa,s as X,L as ma,F as ha,I as ba,p as S,m as ee,A as pa,O as ae,C as ga,D as Sa}from"./index-uoDX7H4L.js";import{D as ka}from"./mui-DAOUhz91.js";import{u as Ea}from"./InboxNotificationsProvider-D6GwXgCp.js";import{u as Ca}from"./useTaskManagerAccess-OjN4ZWFp.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]="e95ad5a9-9d6d-490b-b332-df47540f6ffe",l._sentryDebugIdIdentifier="sentry-dbid-e95ad5a9-9d6d-490b-b332-df47540f6ffe")}catch{}})();const Ta=Qe((({isAppContentDrawerOpen:l,handleDrawerToggle:i})=>{const{tenantEmailDomain:s}=$e(),a=Ge(),k=ea(),n=Ue(),B=xe(),r=te(),{useFeatureGate:d}=aa(),p=ta(),{isTaskManagerAccessEnabled:E}=Ca(p),o=t((e=>ne(e))),oe=o.masterTOSInfo?.isMasterTOSAccepted??!1,$=t((e=>Ne(e))),{status:ie}=t(Pe),G=$.uiState.currentChatSessionId,C=na(),{setLoading:re}=sa(),[w,U]=f.useState(void 0),A=F("/:tenantEmailDomain/dashboard")!==null,M=F("/:tenantEmailDomain/reports")!==null,m=F("/:tenantEmailDomain/onboarding/*")!==null,de=!!o.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:ce}=d(c.isChargeCardFeatureEnabled),{isFeatureEnabled:x}=d(c.isDebitCardFeatureEnabled),le=oa(o,ce,x),{isFeatureEnabled:ue}=d(c.isSettingsFeatureEnabled),N=t((e=>Re(e))),{isFeatureEnabled:T}=d(c.isReferralFeatureEnabled),v=t((e=>je(e)));f.useEffect((()=>{C&&T&&!m&&v.fetchState==="Not-Started"&&r(Ve(!0))}),[C,T,v.fetchState,m]);const _=t((e=>e.tenantState)),fe=t((e=>_.fetchState==="Completed"?Oe(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),ke=o.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",Ee=t((e=>b(e).totalUnreadCount)),Ce=t((e=>b(e).reducedFetchCountState)),R=t((e=>b(e).notificationDetailsByTab.tasks.uiState.unreadCount)),j=t((e=>b(e).notificationDetailsByTab.comments.uiState.unreadCount)),V=t((e=>b(e).notificationDetailsByTab.tasks.fetchCountState)),I=t((e=>b(e).notificationDetailsByTab.comments.fetchCountState)),{inboxNotifications:O,isLoading:L,isFetchingMore:Z,hasFetchedAll:q,fetchMore:Te}=Ea();f.useEffect((()=>{const e=setTimeout((()=>Te?.()),0);return()=>clearTimeout(e)})),f.useEffect((()=>{if(L===!1&&Z===!1&&q===!0)if(o?.companyId!=null&&O!=null){const e=`dashboard_${o.companyId}`;U(O.filter((u=>u.roomId===e&&u.readAt==null)).length)}else U(0)}),[L,Z,q]),f.useEffect((()=>{C&&E&&!m&&V.fetchState==="Not-Started"&&B.tenantId!=null&&r(Le("task_manager","dashboard"))}),[C,E,m,V.fetchState,B.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:Ce,count:Ee},z=s!=null?ra.getSignedInUserTenant(s):null,H=t((e=>z?.tenantId!=null?Ze(e,z.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"),T===!1&&h.push("rewards_card"),P===!1&&h.push("expense_automation_card");const W=t((e=>qe(e,h).fetchState)),Y=t((e=>ze(e).fetchState)),ye=A&&(W==="Completed"||W==="Error")||M&&(Y==="Completed"||Y==="Error")||!A&&!M?void 0:"disabled",we=f.useMemo((()=>He(o.userRole)),[o.userRole]),Ae=We(we),ve=o?.rewardsLastViewedTime==null,_e=p?.userEmail!=null&&N.fetchState==="Completed"&&Ye(N.notificationSettings,p.userEmail,x,o,E),J=da(),Fe=J&&ca(a);return D.jsx(ka,{container:window.document.body,variant:"temporary",open:l,onClose:()=>i(!1),PaperProps:{sx:{width:240,zIndex:8,borderRight:"none",backgroundImage:"none"}},ModalProps:{keepMounted:!0},children:D.jsx(la,{signedInUser:p,currentTenantId:_.currentTenantId??"",tenants:_.fetchState==="Completed"?fe:H!=null?[H]:[],currentTenant:o,isTenantDropdownDisabled:ye,isSettings:X(a),isInvoicing:fa(a)&&ie==="completed",isSettingsFeatureEnabled:ue,isVendorsTabVisible:Ae,isZeniAccountEnabled:de,isChargeCardEnabled:le,isTreasuryEnabled:ke,isNotificationsTabVisible:_e,notificationCountDetails:Ie,isExpenseAutomationEnabledForUser:P,selectedMenu:ua(a),rewardsConfiguration:{isRewardsTabVisible:T,isRewardsAnimated:ve,rewardsPlan:v.rewardsPlan},isAiCfoAccessEnabled:J,onNotificationIconClick:()=>{i(!1);let e=R===0&&j>0?"notifications/comments":"notifications/tasks";X(a)&&(e=R===0&&j>0?"../../notifications/comments":"../../notifications/tasks");const u=S(a.state?.pathnameStackToGoBack,a.pathname);n(e,{state:{pathnameStackToGoBack:u}})},handleCockpitClick:()=>{window.open("/cockpit")},handleLogOutClick:()=>{i(!1);const e=S(a.state?.pathnameStackToGoBack,a.pathname);n("/signout",{replace:!0,state:{pathnameStackToGoBack:e,message:"logout"}})},handleMenuChange:e=>{if(i(!1),s==null)return;if(e.type==="invoicing")return void n(`../${s}/invoicing/overview`,{state:{pathnameStackToGoBack:S(a.state?.pathnameStackToGoBack,a.pathname),referrer:"Sidebar"}});if(e.type==="ai_cfo"){if(ee.trackAICFOChatScreenStateChanged("viewed","left_menu",G??null,null),!oe)return void pa({location:a,navigate:n,mergeState:{referrer:"Sidebar"}});const y=S(a.state?.pathnameStackToGoBack,a.pathname);return void n(`/${s}/ai-cfo/explore`,{state:{pathnameStackToGoBack:y,referrer:"Sidebar"}})}const u=S(a.state?.pathnameStackToGoBack,a.pathname),K=e.type,De=ae(K)&&K!=="command_center";if(ae(e.type)&&g[o.tenantId]!=null&&ee.trackMonthEndCloseClicked(g[o.tenantId].month,g[o.tenantId].year,"Sidebar"),De&&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 Be=ga(e.type);Sa(e.type)?(G!=null&&r(Ke()),n(`/${s}/ai-cfo/${e.type}`,{state:{pathnameStackToGoBack:u.slice(0,-1),referrer:"Sidebar"}})):n(`/${s}/${Be}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})},handleMyProfileClick:()=>{i(!1),n(`/${s}/settings/my_profile`)},handleReferralsClick:()=>{i(!1),n(`/${s}/rewards`)},handleBackClick:()=>{n(`/${s}/dashboard`)},handleTenantSelect:e=>{re(ma.TENANT_SWITCHING),i(!1),ha({dispatch:r,navigate:n,pathToNavigate:ba(e.tenantEmailDomain,a),selectedTenant:e,signedInUser:p})},onZeniLogoClick:()=>{k.toggle()},isAiCfo:Fe,aiCfoView:$,isOnDashboard:A,updateCurrentChatSessionId:e=>{r(Je({sessionId:e,agentId:"controller"})),n(`/${s}/ai-cfo/${e}`,{state:{...a.state}})},halloweenAnimationEnabled:be,isTaskManagerAccessEnabled:E,thanksGivingAnimationEnabled:pe,christmasAnimationEnabled:ge,newYearAnimationEnabled:Se})})})),Ba=l=>{const i=te(),s=t((k=>ne(k))),a={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(k,n)=>{Xe(n)&&Me(n.mode)==="dashboard"&&i(se({unreadCount:n.data.unread},"tasks"))}};return D.jsx(Ta,{...l,...a})};export{Ba as M};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as e}from"./liveblocks-DtuUpF5h.js";import{h as r,l as i}from"./core-Dk5JD2l2.js";import{am as n}from"./index-
|
|
1
|
+
import{j as e}from"./liveblocks-DtuUpF5h.js";import{h as r,l as i}from"./core-Dk5JD2l2.js";import{am as n}from"./index-uoDX7H4L.js";import"./mui-DAOUhz91.js";import"./sentry-BWDuLt7o.js";import"./zeni-epic-state-BtP47QJT.js";import"./recharts-BMD3jyO6.js";import"./analytics-C6U4wpfB.js";import"./plaid-DBHSfOGH.js";import"./dnd-CSZKLHxv.js";import"./stripe-cKAAJElX.js";import"./lottie-BlG_vWSt.js";import"./lexical-BtWXzxnq.js";import"./pdf-iocWnEuY.js";import"./utils-CWVNtCN5.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};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{n as mt,b as lt,o as ft,j as N}from"./liveblocks-DtuUpF5h.js";import ut from"./NotFoundScreen-
|
|
1
|
+
import{n as mt,b as lt,o as ft,j as N}from"./liveblocks-DtuUpF5h.js";import ut from"./NotFoundScreen-CyVGP3Vp.js";import{a as k}from"./sentry-BWDuLt7o.js";import{h as ht,g as pt,i as kt,u as gt,j as b,l as bt,n as St,o as O}from"./core-Dk5JD2l2.js";import{cB as It,Uc as Y,fI as J,h4 as Tt,Ug as S,a1b as Q,Um as m,Ua as E,Az as F,Gg as Ct,a1c as At,U9 as Et,Uo as yt,AE as _t,a1d as $,br as j,gk as x,AI as X,a1e as Nt,cN as Bt,cG as wt}from"./zeni-epic-state-BtP47QJT.js";import{aq as xt,e as Ut,c as vt,g as Gt,as as Dt,dK as Rt,p as B,dL as Pt,w as Mt,dM as $t,i as jt,a4 as Ft}from"./index-uoDX7H4L.js";import"./mui-DAOUhz91.js";import{u as Vt}from"./useAskAiCfoHostNavButtonProps-CsMZr2YE.js";import{u as qt}from"./useTaskManagerAccess-OjN4ZWFp.js";import"./recharts-BMD3jyO6.js";import"./analytics-C6U4wpfB.js";import"./plaid-DBHSfOGH.js";import"./dnd-CSZKLHxv.js";import"./stripe-cKAAJElX.js";import"./lottie-BlG_vWSt.js";import"./lexical-BtWXzxnq.js";import"./pdf-iocWnEuY.js";import"./utils-CWVNtCN5.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},l=new t.Error().stack;l&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[l]="8106d730-1ab1-4098-93df-c04b7e11b1b3",t._sentryDebugIdIdentifier="sentry-dbid-8106d730-1ab1-4098-93df-c04b7e11b1b3")}catch{}})();const Lt=(t,l)=>new Promise(((n,h)=>{const g=t.map((c=>new Promise((o=>{l(c),o()}))));Promise.all(g).then((()=>{setTimeout((()=>{n()}),2e3)})).catch((c=>{h(c)}))})),zt=bt((function(t,l){const n=Y(t),{signedInUser:h,isDebitCardFeatureEnabled:g,isTaskManagerAccessEnabled:c}=l,o=S(t),f=J(t),{currentTab:I}=o;return{notificationView:o,isNotificationSettingsVisible:h.userEmail!=null&&yt(n.notificationSettings,h.userEmail,g,f,c),isDisabled:o.notificationDetailsByTab[I].fetchState==="In-Progress"?"disabled":void 0}}),(function(t,l){const{location:n,tenantEmailDomain:h,loggedInUserRoleMap:g,externalNotificationsUnreadCount:c,allUnreadCommentsNotificationIds:o,navigate:f,markInboxNotificationAsRead:I,fetchMoreCommentsNotifications:v}=l;return{onNotificationClick:(a,s,d,r)=>{if(r==="task_deleted"){const i=`/${h}/tasks`,T=B(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}else{const i=`/${h}/tasks/${s}`,T=B(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}d==="unread"&&t(X("task_manager","read",[a],!1))},onCommentNotificationClick:(a,s,d)=>{const r=s.toString().split(`/${h}/`);if(r[1]!=null){d==="unread"&&(I(a),t($([a],j())));let i=`/${h}/${r[1]}`;const T=B(n.state?.pathnameStackToGoBack,n.pathname);r[1].startsWith("reimbursement")&&!Bt(g)&&(i="not-found"),r[1].startsWith("bill")&&!wt(g)&&(i="not-found"),f(i,{state:{pathnameStackToGoBack:T,message:"triggerBackClick"}})}},onUpdateNotificationViewUIState:(a,s)=>{t(E(a,s))},onUpdateNotificationTabState:(a,s)=>{t(m(a,s))},onUpdateNotificationViewCurrentTabAndSubTab:(a,s)=>{t(Q(a,s));const d=`../${a}`,r=B(n.state?.pathnameStackToGoBack,n.pathname);f(d,{state:{pathnameStackToGoBack:r}})},onUpdateNotificationViewSubTab:a=>{t(Nt(a))},onFetchMoreNotifications:(a,s)=>{if(a==="tasks"){const d=[];s==="all"?d.push("read","unread"):s!=="mentions"&&d.push(s),t(F("task_manager","dashboard",d))}else v?.()},onUpdateNotificationStatus:(a,s,d,r)=>{a==="tasks"?t(X("task_manager",d,r)):(t(m({markAsReadState:{fetchState:"In-Progress",error:void 0}},"comments")),Promise.all(r.map((i=>{d==="read"&&(I(i),t($([i],j())))}))).then((()=>{t(m({markAsReadState:{fetchState:"Completed",error:void 0},selectedNotificationIds:[]},"comments")),t(E({unreadCount:c-r.length>0?c-r.length:0},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"success",type:"success",showStatusIcon:!0}))}),(i=>{t(m({markAsReadState:{fetchState:"Error",error:i}},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",showStatusIcon:!0}))})).catch((i=>{t(m({markAsReadState:{fetchState:"Error",error:i}},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",showStatusIcon:!0}))})))},onMarkAllNotificationsAsRead:a=>{a==="tasks"?t(_t("task_manager","read")):(t(m({markAsAllReadState:{fetchState:"In-Progress",error:void 0}},"comments")),Lt(o,I).then((()=>{t($(o,j())),t(m({markAsAllReadState:{fetchState:"Completed",error:void 0}},"comments")),t(E({unreadCount:0},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"success",type:"success",showStatusIcon:!0}))})).catch((s=>{t(m({markAsAllReadState:{fetchState:"Error",error:s}},"comments")),t(x({messageSection:"notification_mark_as_read",messageText:"failed",type:"error",showStatusIcon:!0}))})))},onBackClick:()=>{const a=Ft(n.state?.pathnameStackToGoBack),s=a.poppedPathname??"../../dashboard";f(s,{state:{pathnameStackToGoBack:a.newStack}})},onSettingsClick:()=>{const a=B(n.state?.pathnameStackToGoBack,n.pathname);f("../../settings/notifications",{state:{pathnameStackToGoBack:a}})}}}))(Mt($t)),Wt=()=>{const t=ht(),l=pt(),{tenantEmailDomain:n,selectedTab:h}=kt(),{areTenantIdsInSync:g}=xt(),c=It(h??""),o=gt(),f=Ut(),[I,v]=k.useState(!1),a=b((e=>Y(e))),s=b((e=>J(e))),{useFeatureGate:d}=vt(),{isFeatureEnabled:r}=d(Gt.isDebitCardFeatureEnabled),{isAiCfoAccessEnabled:i,onAskAiCfoClick:T}=Vt({mobileExploreReferrer:"Notifications"});Dt({isDataReady:!0});const Z=Tt(s.userRole);if(s==null||n==null||s.companyId==null)throw Error("Can't access notifications page without current tenant...");if(f==null)throw Error("Can't access notifications page without signed in...");const V=b((e=>S(e).notificationDetailsByTab.tasks.fetchState)),q=b((e=>S(e).currentTab)),G=b((e=>S(e).currentSubTab)),tt=b((e=>S(e).notificationDetailsByTab.comments.fetchCountState)),D=b((e=>S(e).notificationDetailsByTab.comments.fetchState)),et=b((e=>S(e).notificationDetailsByTab.comments.uiState.unreadCount)),at=b((e=>S(e).allExternalNotifications)).filter((e=>e.inboxNotification.readAt==null)).map((e=>e.inboxNotification.id)),st=Rt().allUsers,{inboxNotifications:w,isLoading:y,hasFetchedAll:C,isFetchingMore:R,fetchMore:ot}=mt(),{threads:L,isLoading:z,fetchMore:W,isFetchingMore:H,hasFetchedAll:K}=lt({query:{metadata:{companyId:s.companyId,application:"dashboard"}}});k.useEffect((()=>{if(q!==c&&c!=null&&o(Q(c)),c==null){const e=`../${q}`,p=B(l.state?.pathnameStackToGoBack,l.pathname);t(e,{state:{pathnameStackToGoBack:p}})}}),[c]),k.useEffect((()=>{tt.fetchState==="Not-Started"&&o(m({fetchCountState:{fetchState:"In-Progress",error:void 0}},"comments"))}),[]),k.useEffect((()=>{if(y===!1&&C===!0&&s?.companyId!=null&&w!=null){const e=`dashboard_${s.companyId}`,p=w.filter((A=>A.roomId===e&&A.readAt==null)).length;o(m({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),o(E({unreadCount:p},"comments"))}}),[y,C]),k.useEffect((()=>{V!=="In-Progress"&&g&&o(F("task_manager","dashboard",["read","unread"]))}),[g]),k.useEffect((()=>{const e=setTimeout((()=>ot?.()),0);return()=>clearTimeout(e)}));const P=y||R===!0||C!==!0||y||R===!0||C!==!0;k.useEffect((()=>{P&&D!=="In-Progress"?o(m({fetchState:"In-Progress",error:void 0},"comments")):P||D!=="In-Progress"||o(m({fetchState:"Completed",error:void 0},"comments"))}),[P,D]),k.useEffect((()=>{o(E({hasMore:C!==!0},"comments"))}),[C]),k.useEffect((()=>{a.fetchState!=="In-Progress"&&a.fetchState!=="Completed"&&I===!1&&(v(!0),o(Ct()))}),[a.fetchState]),k.useEffect((()=>{if(y===!1&&z===!1&&w!=null&&L!=null){const e=`dashboard_${s.companyId}`,p=w.filter((u=>u.roomId===e)).filter((u=>Pt(u.kind))),A=p.filter((u=>u.readAt==null)),_=p.map((u=>u.id)),ct=p.map((u=>{const M=L.find((dt=>{return dt.id===((U=u).kind==="thread"?U.threadId:"subjectId"in U?U.subjectId:void 0);var U}));return M!=null?{inboxNotification:{...u,threadId:M.id},thread:M}:(H||K===!0||W==null||W(),null)})).filter((u=>u!=null));o(m({allNotificationsIds:_},"comments")),o(E({totalCount:_.length,unreadCount:A.length},"comments")),o(At(ct))}}),[y,R,H,C,K,z,w?.length]);const nt={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(e,p)=>{if(jt(p)){const A=Et(p.mode);if(A==="dashboard"&&o(E({unreadCount:p.data.unread},"tasks")),V!=="In-Progress"){const _=[];G==="all"?_.push("read","unread"):G!=="mentions"&&_.push(G),o(F("task_manager",A,_,!0))}}}},it=ft(),{isTaskManagerAccessEnabled:rt}=qt(f);return N.jsx(zt,{tenantEmailDomain:n,loggedInUserRoleMap:Z,signedInUser:f,externalNotificationsUnreadCount:et,location:l,navigate:t,isDebitCardFeatureEnabled:r,isTaskManagerAccessEnabled:rt,users:st,markInboxNotificationAsRead:it,allUnreadCommentsNotificationIds:at,isAiCfoAccessEnabled:i,onAskAiCfoClick:T,...nt})};function me(){return N.jsxs(St,{children:[N.jsx(O,{path:"/:selectedTab",element:N.jsx(Wt,{})}),N.jsx(O,{path:"*",element:N.jsx(ut,{})})]})}export{me as default};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as m}from"./liveblocks-DtuUpF5h.js";import{a as r}from"./sentry-BWDuLt7o.js";import{u as A,g as P,j as o,N as j}from"./core-Dk5JD2l2.js";import{UP as C,fI as R,gp as x,UQ as z,UR as D,US as M,UT as L,pV as k,Tu as N}from"./zeni-epic-state-BtP47QJT.js";import{z as h,ah as I}from"./index-
|
|
1
|
+
import{j as m}from"./liveblocks-DtuUpF5h.js";import{a as r}from"./sentry-BWDuLt7o.js";import{u as A,g as P,j as o,N as j}from"./core-Dk5JD2l2.js";import{UP as C,fI as R,gp as x,UQ as z,UR as D,US as M,UT as L,pV as k,Tu as N}from"./zeni-epic-state-BtP47QJT.js";import{z as h,ah as I}from"./index-uoDX7H4L.js";import"./mui-DAOUhz91.js";import"./recharts-BMD3jyO6.js";import"./analytics-C6U4wpfB.js";import"./plaid-DBHSfOGH.js";import"./dnd-CSZKLHxv.js";import"./stripe-cKAAJElX.js";import"./lottie-BlG_vWSt.js";import"./lexical-BtWXzxnq.js";import"./pdf-iocWnEuY.js";import"./utils-CWVNtCN5.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},s=new n.Error().stack;s&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[s]="7bdbc3f5-64b0-4785-9436-87bfe1f4f291",n._sentryDebugIdIdentifier="sentry-dbid-7bdbc3f5-64b0-4785-9436-87bfe1f4f291")}catch{}})();function ee(){const n=A(),s=P(),{params:t,error:i}=r.useMemo((()=>C(s.search)),[s.search]),b=r.useMemo((()=>new URLSearchParams(s.search).get("client_name")??t?.clientId??"Unknown Application"),[s.search,t]),f=h.isSignedIn(),a=h.getSignedInUser(),p=o((e=>R(e))),l=o((e=>x(e))),d=o((e=>e.tenantState.fetchState)),w=o(z),y=o(D),u=o(M),[S,U]=r.useState(null),[v,E]=r.useState(null);r.useEffect((()=>{document.querySelector("#app-shell-loader")?.remove()}),[]),r.useEffect((()=>()=>{n(L())}),[n,s.search]),r.useEffect((()=>{i!=null&&console.warn("[OAuthConsent] invalid params:",i)}),[i]);const g=r.useRef(!1);r.useEffect((()=>{f&&a!=null&&!g.current&&(d!=="Not-Started"&&d!=="Error"||(g.current=!0,n(k(a.userId,a.zeniSessionId??void 0))))}),[f,a,d,n]),r.useEffect((()=>{u!=null&&u!==""&&(window.location.href=u)}),[u]);const _=r.useMemo((()=>{if(p?.tenantId!=null)return p.tenantId;const e=h.getActiveTenantForUser()?.tenantId;return e!=null&&l.some((T=>T.tenantId===e))?e:l.length===1?l[0].tenantId:null}),[p?.tenantId,l]),c=S??_;return i!=null?m.jsx(I,{variant:"invalid_params",paramsError:i}):f?m.jsx(I,{variant:"signed_in",clientName:b,userEmail:a?.userEmail,isInitializing:d!=="Completed",tenants:l,selectedTenantId:c,onSelectTenant:U,approveError:v??y,isApproving:w==="In-Progress",showAllowButton:c!=null,onApprove:()=>{t!=null&&a!=null&&c!=null&&n(N(a.userId,a.zeniSessionId??void 0,c,t.clientId,t.redirectUri,t.codeChallenge,t.codeChallengeMethod,t.state,t.responseType))},onDeny:()=>{if(t!=null)try{const e=new URL(t.redirectUri);e.searchParams.set("error","access_denied"),e.searchParams.set("error_description","The user denied the request"),e.searchParams.set("state",t.state),window.location.href=e.toString()}catch{E("Unable to deny: redirect_uri is not a valid URL. Close this window or contact support.")}}}):m.jsx(j,{to:"/signin/auth",state:{origin:s.pathname+s.search},replace:!0})}export{ee as default};
|
package/dist/assets/{PandLWithForecastRoutes-DNnwlAH1.js → PandLWithForecastRoutes-Bh5hYQzx.js}
RENAMED
|
@@ -1 +1 @@
|
|
|
1
|
-
import{j as n}from"./liveblocks-DtuUpF5h.js";import{h as G,u as W,g as z,i as H,j as d,l as J,n as Q,o as S}from"./core-Dk5JD2l2.js";import{fI as v,Ak as R,vb as K,VH as w,v6 as T,bq as X,c0 as Z,v7 as ee,VI as ae,Vp as C,ek as te,E8 as se,VJ as oe,Ew as re,e0 as ne,d$ as ce}from"./zeni-epic-state-BtP47QJT.js";import{ai as ie,z as le,aq as de,as as me,Q as fe,a8 as pe,m as M,aD as ue,p as he,c as ge,g as Fe}from"./index-
|
|
1
|
+
import{j as n}from"./liveblocks-DtuUpF5h.js";import{h as G,u as W,g as z,i as H,j as d,l as J,n as Q,o as S}from"./core-Dk5JD2l2.js";import{fI as v,Ak as R,vb as K,VH as w,v6 as T,bq as X,c0 as Z,v7 as ee,VI as ae,Vp as C,ek as te,E8 as se,VJ as oe,Ew as re,e0 as ne,d$ as ce}from"./zeni-epic-state-BtP47QJT.js";import{ai as ie,z as le,aq as de,as as me,Q as fe,a8 as pe,m as M,aD as ue,p as he,c as ge,g as Fe}from"./index-uoDX7H4L.js";import"./mui-DAOUhz91.js";import Ie from"./NotFoundScreen-CyVGP3Vp.js";import{F as be}from"./FeaturePreviewScreen-CtNAe1_H.js";import{a as g}from"./sentry-BWDuLt7o.js";import{u as Se}from"./useAskAiCfoHostNavButtonProps-CsMZr2YE.js";import{u as Ce}from"./useInitialThreadRequest-DGvbt9bY.js";import{t as Te}from"./routePaths-DzLOO7Om.js";import{M as ye}from"./MobileAppDrawer-BrOHAjwP.js";import"./recharts-BMD3jyO6.js";import"./analytics-C6U4wpfB.js";import"./plaid-DBHSfOGH.js";import"./dnd-CSZKLHxv.js";import"./stripe-cKAAJElX.js";import"./lottie-BlG_vWSt.js";import"./lexical-BtWXzxnq.js";import"./pdf-iocWnEuY.js";import"./utils-CWVNtCN5.js";import"./InboxNotificationsProvider-D6GwXgCp.js";import"./useTaskManagerAccess-OjN4ZWFp.js";(function(){try{var s=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new s.Error().stack;e&&(s._sentryDebugIds=s._sentryDebugIds||{},s._sentryDebugIds[e]="28d2b4d5-ee53-4c69-8e14-a491abef7fcc",s._sentryDebugIdIdentifier="sentry-dbid-28d2b4d5-ee53-4c69-8e14-a491abef7fcc")}catch{}})();const y=(s,e,a,o)=>{if(s!=e){const r=o??"";s!=null&&s.length>0?a(`../${e}${r}`,{replace:!0}):a(`${e}${r}`,{replace:!0})}},Ae=J((function(s){const e=ae(s),a={},o=e.pandLReportWithForecast.uiState.nodeCollapseState;return Object.keys(o).forEach((r=>{a[r]=o[r]===!1})),{selectedTimeframe:e.selectedTimeframe,isForecastVsActualOn:e.isForecastVsActualOn,compareMode:e.compareMode,forecastList:e.forecastList,selectedForecast:e.selectedForecast,pandLreport:e.pandLReportWithForecast,scrollPosition:e.pandLReportWithForecast.uiState.scrollPosition,nodeOpenStatus:a,type:"name+balances_forecast",analytics:M}}),(function(s,e){return{onForecastSelectionChanged:(a,o)=>{s(w(a,o)),e.isPandLReportFetched(a)||s(T(a)),y(e.forecastIdFromUrlPath,a,e.navigate)},onTimeframeChanged:a=>{s(re(a))},onForecastVsActualsCompareToggle:a=>{s(oe(a)),s(C({forecastId:e.forecastIdFromUrlPath,scrollPosition:{scrollLeft:0,scrollTop:0}}))},onCompareModeChanged:a=>{s(se(e.firstMonthOfFY,a,0,[]))},onAccountBalanceClick:e.hasTransactionAccess!==!0?void 0:(a,o)=>{let r,c;const p=a.accountName===""?a.accountDescription:a.accountName;if(o.balanceTimeFrame==="month"||o.balanceTimeFrame==="quarter"?(r=o.balanceTimeFrame,c=te(o)):o.balanceTimeFrame==="year"?(r="quarter",c={startDate:o.endDate.startOf("quarter"),endDate:o.endDate}):console.error(`timeframe ${o.balanceTimeFrame} is not supported`),c!=null&&r!=null){const u=Te(e.tenantEmailDomain,a.accountId,a.accountType,p,r,c),m=he(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(u,{state:{pathnameStackToGoBack:m,referrer:"Forecast"}})}},onNodeCollapseToggled:(a,o)=>{s(C({forecastId:e.forecastIdFromUrlPath,nodeCollapseState:{nodeId:a,isCollapsed:o===!1}}))},onTableScroll:a=>{s(C({forecastId:e.forecastIdFromUrlPath,scrollPosition:a}))},onBackClick:()=>{e.navigate("../../")}}}))(ue);function U(){const s=ie(),e=G(),a=W(),o=z(),{forecastId:r,tenantEmailDomain:c}=H(),[p,u]=g.useState(!1),[m,A]=g.useState(!1),F=le.getSignedInUser(),D=d((t=>v(t))),q=D.company?.companyInfo.firstMonthOfFY??1,i=d((t=>R(t.forecastState,t.forecastListState))),l=d((t=>t.forecastListState.fetchState==="Completed")),k=d((t=>t.profitAndLossState)),x=d((t=>t.reportUIOptionsState.selectedForecast)),j=t=>k.pandLByForecastID[t]!=null&&ee(t,k).reducedAllFetchState.fetchState==="Completed",{areTenantIdsInSync:I}=de();me({isDataReady:l});const{isAiCfoAccessEnabled:V,onAskAiCfoClick:B}=Se({mobileExploreReferrer:"Forecast"});g.useEffect((()=>{if(!p&&I)u(!0),l||a(K());else if(l&&!m){A(!0);const t=((f,P,O)=>P!=null?f.forecasts.findIndex((b=>b.id===P)):O!=null?f.forecasts.findIndex((b=>b.id===O)):f.forecasts.length>0?0:-1)(i,r,x?.id);t===-1&&r!=null?e("page-not-found",{replace:!0}):t!==-1&&t!=x?.index?(a(w(i.forecasts[t].id,t)),y(r,i.forecasts[t].id,e,o.search)):r==null&&t!==-1&&y(void 0,i.forecasts[t].id,e,o.search),t!==-1&&!j(i.forecasts[t].id)&&I&&a(T(i.forecasts[t].id))}}),[p,u,a,l,i,m,A,R,T,I]);const E=fe(),_=E?.loggedInUserRole!=null&&X(E.loggedInUserRole),$=Ce(D?.companyId,{clearParams:l&&m}),[N,Y]=g.useState(!1),h=new URL(s("forecast_pandl"));h.searchParams.set("firstname",F?.firstName??""),h.searchParams.set("lastname",F?.lastName??""),h.searchParams.set("email",F?.userEmail??"");const L=t=>{Y(t)};return n.jsxs(n.Fragment,{children:[l?n.jsx(pe,{analytics:M,onLoad:t=>(f=>f.trackForecast())(t)}):null,n.jsx(ye,{isAppContentDrawerOpen:N,handleDrawerToggle:L}),n.jsx(Ae,{firstMonthOfFY:q,tenantEmailDomain:c,forecastIdFromUrlPath:r,navigate:e,location:o,isPandLReportFetched:j,meetingUrl:Z(h.toString()),hasTransactionAccess:_,isAiCfoAccessEnabled:V,onAskAiCfoClick:B,initialOpenThreadRequest:$,onClickMenuIcon:()=>{L(!0)}})]})}function He(){const s=d((c=>v(c))),{useFeatureGate:e}=ge(),{isFeatureEnabled:a}=e(Fe.isDebitCardFeatureEnabled),o=ne(a,s),r=ce(s);return o===!0||r===!0?n.jsx(be,{}):n.jsxs(Q,{children:[n.jsx(S,{path:"/",element:n.jsx(U,{})}),n.jsx(S,{path:"/:forecastId",element:n.jsx(U,{})}),n.jsx(S,{path:"/:forecastId/*",element:n.jsx(Ie,{})})]})}export{He as default};
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import{j as r}from"./liveblocks-DtuUpF5h.js";import{a as d}from"./sentry-BWDuLt7o.js";import{M as c,N as a,a9 as m,ad as f,ae as h}from"./index-
|
|
1
|
+
import{j as r}from"./liveblocks-DtuUpF5h.js";import{a as d}from"./sentry-BWDuLt7o.js";import{M as c,N as a,a9 as m,ad as f,ae as h}from"./index-uoDX7H4L.js";import"./mui-DAOUhz91.js";import{i as y}from"./core-Dk5JD2l2.js";import"./zeni-epic-state-BtP47QJT.js";import"./recharts-BMD3jyO6.js";import"./analytics-C6U4wpfB.js";import"./plaid-DBHSfOGH.js";import"./dnd-CSZKLHxv.js";import"./stripe-cKAAJElX.js";import"./lottie-BlG_vWSt.js";import"./lexical-BtWXzxnq.js";import"./pdf-iocWnEuY.js";import"./utils-CWVNtCN5.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]="342721ba-9151-4823-a562-b43901ec5b0b",e._sentryDebugIdIdentifier="sentry-dbid-342721ba-9151-4823-a562-b43901ec5b0b")}catch{}})();const b=c("div")`
|
|
2
2
|
display: flex;
|
|
3
3
|
flex-direction: column;
|
|
4
4
|
width: 100%;
|