@zeniai/web-app-ui 5.3.40-dev → 5.3.40-qa

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (68) hide show
  1. package/dist/assets/{AccountMappingScreen-BIUIsIRE.js → AccountMappingScreen-BBc4_4t5.js} +1 -1
  2. package/dist/assets/{AddressRoutes--gUEIlXc.js → AddressRoutes-DUeinmsu.js} +1 -1
  3. package/dist/assets/{AddressScreen-Bej9zQot.js → AddressScreen-ueBXhh2E.js} +1 -1
  4. package/dist/assets/{AiCfoScreen-BQaocZqa.js → AiCfoScreen-CSA0NZQ_.js} +1 -1
  5. package/dist/assets/{AppDrawer-BYM-DSkR.js → AppDrawer-BtmKncXK.js} +1 -1
  6. package/dist/assets/{BillPayApprovalRoutes-qtIPcgB0.js → BillPayApprovalRoutes-DIMv5HVt.js} +1 -1
  7. package/dist/assets/{BillPayRoutes-CnpuGuHe.js → BillPayRoutes-CWQjup6l.js} +1 -1
  8. package/dist/assets/{BusinessVerificationPageScreen-D2Ary0QP.js → BusinessVerificationPageScreen-gxvPC9Nc.js} +1 -1
  9. package/dist/assets/{CardsAiCfoScreen-V1ZiSm5h.js → CardsAiCfoScreen-X_JzwNdn.js} +1 -1
  10. package/dist/assets/{ChargeCardRoutes-DgTzZTph.js → ChargeCardRoutes-Bh1W2yGQ.js} +1 -1
  11. package/dist/assets/{CompanyPassportScreen-CNlNZlol.js → CompanyPassportScreen-XQqdGh6R.js} +1 -1
  12. package/dist/assets/{ConnectionAuthScreen-5CXbYx5t.js → ConnectionAuthScreen-BKS6qkfS.js} +1 -1
  13. package/dist/assets/{CustomerOnboardingAuthScreen-Dwb1vXcC.js → CustomerOnboardingAuthScreen-_W8JsjC9.js} +1 -1
  14. package/dist/assets/{CustomerOnboardingRoutes-BKJm_JEE.js → CustomerOnboardingRoutes-DTHzcTqs.js} +1 -1
  15. package/dist/assets/{DashboardRoutes-BKHZJKkt.js → DashboardRoutes-CxJPxihE.js} +1 -1
  16. package/dist/assets/{DefaultTenantHome-ttl2hapk.js → DefaultTenantHome-DyfCOvBU.js} +1 -1
  17. package/dist/assets/{DomesticWireDetailScreen-BZaPu7aX.js → DomesticWireDetailScreen-Cpm9Bc_C.js} +1 -1
  18. package/dist/assets/{DrawerScreen-CeUxZGpo.js → DrawerScreen-BT9F-F5I.js} +1 -1
  19. package/dist/assets/{EntityDetailRoutes-CjcEzz2g.js → EntityDetailRoutes-GrYbpLDE.js} +1 -1
  20. package/dist/assets/{ExpenseAutomationRoutes-BJzy8xal.js → ExpenseAutomationRoutes-BAcJRoU4.js} +1 -1
  21. package/dist/assets/{FeaturePreviewScreen-ClB4hfhH.js → FeaturePreviewScreen-CWY6I3fG.js} +1 -1
  22. package/dist/assets/{HubSpotOAuthCallbackScreen-CvNAfhTh.js → HubSpotOAuthCallbackScreen-C1emp8KW.js} +1 -1
  23. package/dist/assets/{InvoicingRoutes-B1gAqEf9.js → InvoicingRoutes-BVupJlN7.js} +1 -1
  24. package/dist/assets/{MagicLinkRoutes-B0E48n4q.js → MagicLinkRoutes-ujyytXrV.js} +1 -1
  25. package/dist/assets/{MagicLinkSignInScreen-DmrCJmgr.js → MagicLinkSignInScreen-yhSK6wYK.js} +1 -1
  26. package/dist/assets/{MobileAppDrawer-ezuGFNmX.js → MobileAppDrawer-DH0tVOfv.js} +1 -1
  27. package/dist/assets/{NotFoundScreen-BHK2wcy4.js → NotFoundScreen-BF2gJW91.js} +1 -1
  28. package/dist/assets/{NotificationRoutes-CJaAWW0k.js → NotificationRoutes-CnZ8t_aV.js} +1 -1
  29. package/dist/assets/{OAuthConsentScreen-Lh-iiFIq.js → OAuthConsentScreen-CXv-sRc6.js} +1 -1
  30. package/dist/assets/{PandLWithForecastRoutes-BbdTHIrJ.js → PandLWithForecastRoutes-D_qmzE70.js} +1 -1
  31. package/dist/assets/{PaymentLinkScreen-DtmVsAJS.js → PaymentLinkScreen-CRIOI45V.js} +1 -1
  32. package/dist/assets/{PeopleRoutes-CNtwYayL.js → PeopleRoutes-BBOCzTBv.js} +1 -1
  33. package/dist/assets/{PerformanceRoutes-DKKm8Wqd.js → PerformanceRoutes-C5sk5hTF.js} +1 -1
  34. package/dist/assets/{QBOConnectionScreen-IJewO3Tq.js → QBOConnectionScreen-3h-qdoms.js} +1 -1
  35. package/dist/assets/{ReimbursementApprovalRoutes-CaWqEdpt.js → ReimbursementApprovalRoutes-Bt3jod66.js} +1 -1
  36. package/dist/assets/{ReimbursementApprovalRuleDetailScreen-C9pFfWce.js → ReimbursementApprovalRuleDetailScreen-Bc4MC7ZP.js} +1 -1
  37. package/dist/assets/{ReimbursementRoutes-DxyXmLRP.js → ReimbursementRoutes-DGCHkbRG.js} +1 -1
  38. package/dist/assets/{ReportsRoutes-C6GStBGQ.js → ReportsRoutes-C7NbqVqm.js} +1 -1
  39. package/dist/assets/{RewardsRoutes-DsLNX64E.js → RewardsRoutes-CnXmBpce.js} +1 -1
  40. package/dist/assets/{ScheduleDetailsPrepaidExpensesScreen-BsuRR9R3.js → ScheduleDetailsPrepaidExpensesScreen-CplHlAVo.js} +1 -1
  41. package/dist/assets/{ScreenRoutes-L97Vug0k.js → ScreenRoutes-DW0KFZF8.js} +2 -2
  42. package/dist/assets/{SettingsRoutes-BOJoESyV.js → SettingsRoutes-CapPSjQN.js} +1 -1
  43. package/dist/assets/{SetupPagesScreen-D-0MxRfj.js → SetupPagesScreen-D0wYkNmR.js} +1 -1
  44. package/dist/assets/{SignInScreen-BE9J9fIz.js → SignInScreen-ByJdILpU.js} +1 -1
  45. package/dist/assets/{SignOutScreen-CTevoMDc.js → SignOutScreen-BAACKxOn.js} +1 -1
  46. package/dist/assets/{TaskListScreen-CnVcsAwc.js → TaskListScreen-CsxsJBj1.js} +1 -1
  47. package/dist/assets/{TaskRoutes-CQy6J4IF.js → TaskRoutes-DjWmgiZP.js} +1 -1
  48. package/dist/assets/{TransactionDetailRoutes-WkmYYr0f.js → TransactionDetailRoutes-B97JNzan.js} +1 -1
  49. package/dist/assets/{TransactionDetailScreen-DE0VBfkC.js → TransactionDetailScreen-p3o65tsz.js} +1 -1
  50. package/dist/assets/{TransactionListRoutes-D9kITRhY.js → TransactionListRoutes-BNdbZ30T.js} +1 -1
  51. package/dist/assets/{TreasuryRoutes-C6jv6nMF.js → TreasuryRoutes-DR87vhnp.js} +1 -1
  52. package/dist/assets/{VendorsRoutes-CaVrball.js → VendorsRoutes-CropWmWa.js} +1 -1
  53. package/dist/assets/{WiseConfirmationScreen-CzbEV-Z5.js → WiseConfirmationScreen-Of1qjtDz.js} +1 -1
  54. package/dist/assets/{ZeniAccountRoutes-GdGf0SYA.js → ZeniAccountRoutes-BROaca6I.js} +1 -1
  55. package/dist/assets/{ZeniAccountStatementScreen-Cy-_EAj7.js → ZeniAccountStatementScreen-CBSpTdBS.js} +1 -1
  56. package/dist/assets/{analyticsHelper-Cw60VlOq.js → analyticsHelper-BSm7IqEZ.js} +1 -1
  57. package/dist/assets/{getLocaleForTenant-Cb4ANH4Q.js → getLocaleForTenant-Ct5cBG_c.js} +1 -1
  58. package/dist/assets/{index-nXM19luG.js → index-DXVI9ztu.js} +5 -5
  59. package/dist/assets/{routePaths-WEgtxKVV.js → routePaths-3iKgurJn.js} +1 -1
  60. package/dist/assets/{useAiCfoDashboardSuggestedQuestionsChips-DJIBd7UL.js → useAiCfoDashboardSuggestedQuestionsChips-DtwiUC9S.js} +1 -1
  61. package/dist/assets/{useAskAiCfoHostNavButtonProps-CRADLi0_.js → useAskAiCfoHostNavButtonProps-C4hcJx1x.js} +1 -1
  62. package/dist/assets/{useChargeCardPusherEvents-BwfDpPGN.js → useChargeCardPusherEvents-BQSY-ppK.js} +1 -1
  63. package/dist/assets/{useEmailConnectResultRefresh-f-R3NS2J.js → useEmailConnectResultRefresh-BzSlD1q5.js} +1 -1
  64. package/dist/assets/{useInitialThreadRequest-CbTk8gTV.js → useInitialThreadRequest-BFDb_b7F.js} +1 -1
  65. package/dist/assets/{useTaskManagerAccess-CCKD6ndI.js → useTaskManagerAccess-B7YJLgDK.js} +1 -1
  66. package/dist/assets/{withTransactionSidePanel-D-Ctl_K2.js → withTransactionSidePanel-CkEUNYr4.js} +1 -1
  67. package/dist/index.html +1 -1
  68. package/package.json +1 -1
@@ -1,2 +1,2 @@
1
- import{j as s}from"./liveblocks-C_WAhyd7.js";import{a as r}from"./sentry-lC29HHPj.js";import{u as D,h as L,i as R,j as C,t as W,l as _,s as Z,g as J,N as B,n as ie,o as x}from"./core-1xnf2RtE.js";import{a8 as ln,h as p,aq as T,R as m,cb as dn,cc as un,cd as gn,ce as mn,cf as vn,cg as pn,ch as fn,ci as Sn,cj as hn,ck as In,cl as Cn,cm as En,cn as kn,co as yn,p as Y,cp as xn,cq as bn,ae as se,cr as jn,cs as Pn,z as Ie,ct as Dn,cu as Ln,cv as An,cw as $n,cx as wn,cy as Fn,cz as Rn,cA as Tn,V as On,ai as ft,cB as _n,cC as Mn,cD as Nn,cE as Un,cF as De,cG as Bn,cH as Vn,cI as Zn,cJ as Hn,cK as qn,cL as Kn,t as Qe,l as St,cM as Qn,cN as zn,cO as Gn,cP as Wn,cQ as Jn,cR as Yn,cS as Xn}from"./index-nXM19luG.js";import"./mui-BAsIRnB1.js";import{A as K}from"./AddressScreen-Bej9zQot.js";import M from"./NotFoundScreen-BHK2wcy4.js";import{Z0 as ei,Z1 as ti,uP as ze,Z2 as Q,vg as ce,Z3 as Le,Z4 as z,vT as Ge,v_ as ni,w3 as ht,Z5 as Ae,Z6 as It,vX as Ct,Z7 as $e,vV as Et,yz as ii,vW as oi,vP as ai,xq as We,vf as Ce,Z8 as si,Z9 as kt,wa as ci,Za as G,wh as ri,Zb as li,Zc as yt,Zd as xt,yl as di,Ze as ue,Zf as Je,Zg as bt,vd as ui,Zh as gi,v7 as mi,Zi as vi,xD as pi,Zj as jt,xM as Ye,Zk as fi,xJ as Si,Zl as we,gg as hi,Zm as te,Zn as ne,ww as Ii,vl as Xe,Zo as Fe,vq as Pt,vo as Ci,vi as Ei,wp as ki,vs as yi,wy as xi,Zp as Ee,wF as Dt,wD as ke,Fo as Re,xS as et,Zq as bi,ve as Te,Zr as Oe,vB as ye,vy as xe,vL as Lt,vK as _e,vv as ji,vE as At,vN as oe,fE as Me,UP as $t,vh as Ne,vI as Pi,vJ as Di,vH as Li,Zs as Ai,wd as tt,wi as $i,we as wt,Zt as Ft,v1 as nt,Zu as wi,uZ as Rt,Zv as Fi,xY as Ri,y0 as H,xX as Ti,x4 as Ue,Zw as Oi,Zx as Tt,y9 as it,Zy as _i,y6 as Mi,Zz as Ot,x7 as Ni,x8 as V,xb as Ui,ZA as _t,xl as pe,ZB as Bi,wx as Mt,Tm as Nt,ZC as Vi,xv as Zi,ZD as Ut,ZE as Hi,ZF as qi,ZG as Ki,y_ as Qi,ZH as zi,ZI as Bt,yg as Vt,ZJ as Zt,yY as fe,ZK as Gi,yV as Wi,ZL as Ji,ZM as Yi,ZN as Xi,ZO as eo,ZP as to,ZQ as ot,ZR as no,e9 as io,z2 as oo,ZS as Be,wP as at,ZT as Ve,ZU as re,wZ as Ht,wU as qt,wS as be,ZV as ao,wK as so,ym as Kt,yN as st,yI as co,ZW as ro,yn as lo,ZX as uo,yO as go,yS as mo,ZY as vo,ZZ as Qt,c8 as po,mr as fo,ms as So,Z_ as ct,vU as le,gk as ho,my as Io,yF as zt,ze as Co,yC as Gt,ul as Eo,zb as rt,u9 as ko,z8 as lt,hR as yo,TP as dt,TQ as xo,FA as Wt,hJ as bo,Z$ as jo,UE as Po,_0 as Do,zk as Se,zl as Lo,_1 as Ao,_2 as Jt,zh as $o,_3 as wo,_4 as Fo,xz as Ro,_5 as To}from"./zeni-epic-state-BVNUxmav.js";import{M as Oo}from"./MobileAppDrawer-ezuGFNmX.js";import{q as de}from"./QBOConnectionScreen-IJewO3Tq.js";import"./recharts-C2rsrRI6.js";import"./analytics-N153TuwK.js";import"./plaid-dW1_MCaE.js";import"./dnd-DsH8jkrb.js";import"./stripe-cKAAJElX.js";import"./lottie-NIzYzhlS.js";import"./lexical-d2so_3As.js";import"./pdf-BKNPlqtE.js";import"./utils-BBaMea9r.js";import"./InboxNotificationsProvider-BU6hQETc.js";import"./useTaskManagerAccess-CCKD6ndI.js";import"./empty-GMcl-a5k.js";import"./pdf-lib-RqzDns79.js";import"./index-Ctq16f6K.js";import"./url-LYbpMOZt.js";import"./index-Dc3AC-iD.js";import"./decodeURIComponentSafe-DcD-XNVX.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new n.Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="78def842-33ce-4d43-8f0f-25bbc4e24880",n._sentryDebugIdIdentifier="sentry-dbid-78def842-33ce-4d43-8f0f-25bbc4e24880")}catch{}})();const $=({event:n,isReady:e=!0})=>e?s.jsx(ln,{analytics:p,onLoad:t=>t.trackPageLoaded(n)}):null;function N(...n){return n.some((e=>e==="Error"))}function _o(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),{fetchState:g,hasMore:S,items:f,nextCursor:h,auditLogEntityRouteOptions:P,auditLogListSortFieldOptions:b}=C(ei),k=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),y=`/${t??""}/invoicing`,I=r.useCallback(((A,U)=>{const O=ti(y,A,U,P);O!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{entity:A,entityId:U,fromScreen:"audit_log"}),e(O))}),[P,e,y]);r.useEffect((()=>{const A=setTimeout((()=>d(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&n(ze({filters:k,keepExistingListItems:!1,sort:u}))}),[i,k,u,n]);const j=g==="Not-Started"||g==="In-Progress"&&f.length===0,E=g==="In-Progress"&&f.length>0,w=g==="Completed";return N(g)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingAuditLogPage,isReady:w}),s.jsx(dn,{auditLogEntityRouteOptions:P,auditLogListSortFieldOptions:b,entries:f,hasMore:S,isLoading:j,isLoadingMore:E,searchValue:a,sortState:l,onEntityLinkClick:I,onLoadMore:()=>{S&&h!=null&&n(ze({cursor:h,filters:k,keepExistingListItems:!0,sort:u}))},onSearchChange:o,onSortChange:v})]})}function ge(n,e=!1){const t=D(),i=C((c=>Q(c).productNextCursor!=null)),a=C((c=>Q(c).productNextCursor)),o=C((c=>Q(c).productFetchState.fetchState));r.useEffect((()=>{n&&(e&&o!=="Not-Started"||t(ce({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[n,t,e]),r.useEffect((()=>{n&&o!=="In-Progress"&&i&&a!=null&&t(ce({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[n,t,o,i,a])}const Mo=new Set(["plan"]),Yt=[],No=It((n=>n.length>0?n:Yt),mn),Uo=It((n=>n.length>0?n:Yt),gn),Bo=_((function(n,e){const{view:t}=e;return{applicableItemOptions:t.applicableItemOptions,groupedAccountOptions:No(t.qboAccountHierarchy),groupedClassOptions:Uo(t.qboClassHierarchy),catalogItemLifecycleActionOptions:t.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:t.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:t.catalogTierTypeOptionsByPricingModel,periodUnitOptions:t.periodUnitOptions,trialEndActionOptions:t.trialEndActionOptions,trialUnitOptions:t.trialUnitOptions,typeOptions:t.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:t.actionState.fetchState==="In-Progress",isSaving:t.fetchState==="In-Progress",itemId:e.itemId,localData:t.localData,plan:t.plan}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${t}/catalog`),onLifecycleAction:i!==""?a=>{i!==""&&n(Ct({action:a,id:i}))}:void 0,onEditChange:a=>{i!==""&&n(Ae({id:i,localData:a}))},onSaveEdit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemEdited,{itemId:i}),n(ht({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&n(ni({action:o,id:a,parentItemId:i}))}}}))(un);function Vo(){const n=D(),e=L(),{item_id:t,tenantEmailDomain:i}=R(),[a]=W(),{areTenantIdsInSync:o}=T(),c=(d=a.get("kind"))!=null&&Mo.has(d)?d:"plan";var d;const l=C((k=>Le(k,t))),{pageFetchState:v}=l,u=v.fetchState;r.useEffect((()=>(n(z()),()=>{n(z())})),[n]),r.useEffect((()=>{o&&n(Ge({id:t,kind:c}))}),[o,t,c,n]);const[g,S]=r.useState(0);r.useEffect((()=>{l.fetchState==="Completed"&&(n(z()),n(Ge({cacheOverride:!0,id:t,kind:c})),S((k=>k+1)))}),[l.fetchState,n,t,c]);const f=u==="Completed";ge(o,!0);const[h,P]=r.useState(f?t:void 0);r.useEffect((()=>{t!=null&&f&&P(t)}),[t,f]);const b=h!==t&&(u==="Not-Started"||u==="In-Progress");return N(u)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogItemDetailPage,isReady:f}),s.jsx(Bo,{navigate:e,tenantEmailDomain:i,itemId:t??"",kind:c,isLoading:b,view:l},g)]})}function Ze(n={}){const{enabled:e=!0,fetchSyncHealth:t=!1,loadAccountingPickers:i=!1,reuseCached:a=!1}=n,o=D(),{areTenantIdsInSync:c}=T(),d=C($e),l=d.connection?.connected===!0,v=d.connectionFetchState.fetchState;return r.useEffect((()=>{e&&c&&(a&&v!=="Not-Started"||o(Et()),t&&o(ii()))}),[c,o,e,t,a]),r.useEffect((()=>{e&&c&&l&&i&&o(oi())}),[c,o,e,l,i]),{isQboConnected:l,qboView:d}}const Zo=new Set(["addon","charge","plan"]),Ho=new Set(["plan"]),qo=_((function(n,e){const t=Le(n,e.itemId);return{fieldHelp:t.fieldHelp,isQboPickerDataLoading:t.isQboPickerDataLoading,qboClassHierarchy:t.qboClassHierarchy,qboAccountHierarchy:t.qboAccountHierarchy,applicabilityValues:t.applicabilityValues,periodUnitOptions:t.periodUnitOptions,trialEndActionOptions:t.trialEndActionOptions,trialUnitOptions:t.trialUnitOptions,typeOptions:t.typeOptions,applicableItemOptions:t.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save catalog item.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode,pricingModelValues:t.pricingModelValues,prorationValues:t.prorationValues,tierTypeOptionsByPricingModel:t.catalogTierTypeOptionsByPricingModel,tierTypeValues:t.tierTypeValues}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,i=e.isEdit?"edit":"create",{itemId:a}=e,o=a!=null?`${t}/catalog/${encodeURIComponent(a)}`:`${t}/catalog`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemFormCancelled),n(z()),e.navigate(`${t}/catalog`)},onChange:c=>{n(Ae({id:a,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemSaved,{mode:i}),n(ht({id:a}))}}}))(vn);function Ko(){const n=D(),e=L(),{item_id:t,tenantEmailDomain:i}=R(),[a]=W(),{areTenantIdsInSync:o}=T(),c=t!=null,d=a.get("type"),l=d!=null&&Zo.has(d)?d:void 0,v=(u=a.get("kind"))!=null&&Ho.has(u)?u:"plan";var u;const g=C((S=>Le(S,t)));return ge(o,!0),Ze({loadAccountingPickers:!0,reuseCached:!0}),r.useEffect((()=>{o&&t!=null&&n(ai({id:t,kind:v}))}),[o,t,v,n]),r.useEffect((()=>{c||l==null||g.localData.catalogType===l||n(Ae({localData:{...g.localData,catalogType:l}}))}),[c,l,g.localData?.catalogType,n]),r.useEffect((()=>{if(g.fetchState==="Completed"){const S=g.savedItemId??t,f=S!=null?`/${i}/invoicing/catalog/${encodeURIComponent(S)}`:`/${i}/invoicing/catalog`;e(f),n(z())}}),[g.fetchState,g.savedItemId,t,n,e,i]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogItemFormPage}),s.jsx(qo,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:c,itemId:t})]})}const Qo={addons:"addon",all:"item",charges:"charge",plans:"plan"},zo=_((function(n,e){const t=Q(n),i=e.activeTab==="plans",a=e.activeTab==="all",o=i?t.plans:a?[...t.plans,...t.products]:t.products,c=i||a&&t.fetchState==="In-Progress"?t.fetchState:t.productFetchState.fetchState;return{catalogItemLifecycleActionOptions:t.catalogItemLifecycleActionOptions,counts:t.count,countsLoading:t.countsFetchState.fetchState==="Not-Started"||t.countsFetchState.fetchState==="In-Progress",hasMore:i?t.planNextCursor!=null:a&&t.planNextCursor!=null||t.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&o.length===0,isLoadingMore:c==="In-Progress"&&o.length>0,plans:t.plans,productColumns:t.productColumns,products:t.products}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",a=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${t}/data_import`)},onAddItem:()=>{const c=Qo[e.activeTab];p.trackInvoicingActionClick(m.Event.invoicingAddCatalogItemClicked,{itemType:c}),e.navigate(`${t}/catalog/new?type=${c}`)},onItemClick:(c,d)=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemRowClicked,{itemId:d}),e.navigate(`${t}/catalog/${encodeURIComponent(d)}`)},onCatalogItemLifecycleAction:(c,d)=>{n(Ct({action:si(d),id:c}))},onLoadMore:()=>{if(a)return e.planNextCursor!=null&&n(Ce({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&n(ce({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));o!=null&&n(i?Ce({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):ce({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(pn);function Go(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState("plans"),[l,v]=r.useState(""),[u,g]=r.useState(null),S=r.useMemo((()=>u!=null?{dir:u.direction,field:u.columnKey}:void 0),[u]),f=l.trim()!==""?l.trim():void 0,h=r.useMemo((()=>({search:f,type:"plan"})),[f]),P=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),b=C((A=>Q(A))),k=b.planFilters.search,y=b.planSort,I=b.planNextCursor,j=b.productNextCursor,E=b.fetchState==="Completed",w=b.runningActionId??null;return r.useEffect((()=>{const A=setTimeout((()=>v(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&n(We({cacheOverride:!1,planFilters:h,productFilters:P,planSort:S,productSort:S}))}),[i,n,h,P,S]),r.useEffect((()=>{i&&(f!==k||S?.field!==y?.field||S?.dir!==y?.dir)&&n(We({cacheOverride:!0,planFilters:h,productFilters:P,planSort:S,productSort:S}))}),[k,y,i,n,h,P,f,S]),N(b.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogPage,isReady:E}),s.jsx(zo,{navigate:e,tenantEmailDomain:t,activeTab:c,searchValue:a,sortState:u,planFilters:h,productFilters:P,sort:S,planNextCursor:I,productNextCursor:j,runningCatalogItemActionId:w,onSearchChange:o,onTabChange:d,onSortChange:g})]})}const Wo=_((function(n,e){const t=kt(n,e.couponId);return{fieldHelp:t.fieldHelp,applyOnOptions:t.applyOnOptions,discountTypeOptions:t.discountTypeOptions,durationTypeOptions:t.durationTypeOptions,errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save coupon.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode,periodUnitOptions:t.periodUnitOptions}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,a=i!=null?"edit":"create",o=i!=null?`${t}/discounts/${encodeURIComponent(i)}`:`${t}/discounts`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCouponFormCancelled),n(G()),e.navigate(`${t}/discounts`)},onChange:c=>{n(li({id:i,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCouponSaved,{mode:a}),n(ri({id:i}))}}}))(fn);function Jo(){const n=D(),e=L(),{coupon_id:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),{fetchState:o,savedCouponId:c}=C((d=>kt(d,t)));return r.useEffect((()=>{a&&t!=null&&n(ci({id:t}))}),[a,t,n]),r.useEffect((()=>{if(o==="Completed"){const d=c??t,l=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(l),n(G())}}),[o,c,t,n,e,i]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCouponFormPage}),s.jsx(Wo,{couponId:t,navigate:e,tenantEmailDomain:i})]})}const Yo=_((function(n){const e=yt(n);return{fieldHelp:e.fieldHelp,customers:e.customers,planNames:e.planNames,errorMessage:e.fetchState==="Error"?e.error?.message??"Failed to create invoice. Please try again.":void 0,isSubmitting:e.fetchState==="In-Progress",localData:e.localData,settings:e.settings}}),(function(n){return{dispatch:n}}),(function(n,{dispatch:e},t){const i=`/${t.tenantEmailDomain}/invoicing`;return{...n,onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreateInvoiceCancelled),t.navigate(`${i}/invoices`)},onChange:a=>{e(bt(a))},onSubmit:()=>{const a=gi(n.localData);p.trackInvoicingActionClick(m.Event.invoicingInvoiceCreated,{customerId:a.customer_id,lineItemCount:a.line_items?.length}),e(mi(a))}}}))(hn);function Xo(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),[i]=W(),{areTenantIdsInSync:a}=T(),o=i.get("customerId"),c=C((I=>yt(I))),d=c.fetchState,l=c.localData,v=c.savedInvoiceId,u=C(xt),g=C((I=>di(I))),S=C(ue),f=g.fetchState==="Not-Started"||g.fetchState==="In-Progress"&&u==null,h=S.fetchState==="Not-Started"||S.fetchState==="In-Progress"&&S.customers.length===0,P=f||h,b=g.fetchState==="Completed"&&S.fetchState==="Completed";r.useEffect((()=>(n(Je()),()=>{n(Je())})),[n]);const k=r.useRef(!1);r.useEffect((()=>{k.current||o==null||o===""||l.customerId!==""||(k.current=!0,n(bt({...l,customerId:o})))}),[o,l,n]),r.useEffect((()=>{a&&n(ui({cacheOverride:!1}))}),[a,n]);const y=r.useRef(d);return r.useEffect((()=>{const I=y.current;if(y.current=d,I!=="Completed"&&d==="Completed"){const j=v!=null?`/${t}/invoicing/invoices/${encodeURIComponent(v)}`:`/${t}/invoicing/invoices`;e(j)}}),[d,v,e,t]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreateInvoicePage,isReady:b}),P?s.jsx(Sn,{}):s.jsx(Yo,{navigate:e,tenantEmailDomain:t})]})}const ea=_((function(n,e){const{detailView:t}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:t.creditNote,creditNoteId:e.creditNoteId,isLoading:t.fetchState==="Not-Started"||t.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${t}/credits`),onCustomerClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${t}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(i)}`)}}}))(In);function ta(){const n=D(),e=L(),{credit_note_id:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=C((d=>vi(d,t??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{a&&t!=null&&n(pi({id:t}))}),[a,t,n]),N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreditDetailPage,isReady:c}),s.jsx(ea,{navigate:e,tenantEmailDomain:i,creditNoteId:t??"",detailView:o})]})}const na=_((function(n){const e=jt(n),{fetchState:t}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",creditNotes:e.creditNotes,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.creditNotes.length===0,isLoadingMore:t==="In-Progress"&&e.creditNotes.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${t}/data_import`)},onCreditNoteClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${t}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&n(Si({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Cn);function ia(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,creditNoteListFetchState:b}=C((y=>{const I=jt(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,creditNoteListFetchState:I.fetchState}}),Z),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&n(Ye({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(Ye({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreditsListPage,isReady:k}),s.jsx(na,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onStatusChange:y=>n(fi(y)),onSortChange:v})]})}const Xt=(n,e,t)=>{const i=`/${n}/invoicing/customers/`;return t!=null?`${i}${encodeURIComponent(t)}/${e}/`:`${i}new/${e}/`},oa=_((function(n,e){const{editView:t,hasLoadedRecord:i}=e;return{fieldHelp:t.fieldHelp,billingAddressLabel:t.billingAddressLabel,customerTypeOptions:t.customerTypeOptions,netTermDayOptions:t.netTermDayOptions,taxabilityOptions:t.taxabilityOptions,customer:t.record.invoicingCustomer,invoices:t.record.invoices.slice(0,5),isLoading:!i&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),hasPaymentLinkEmailPreviewFailed:t.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:t.emailPreviewFetchState.fetchState==="In-Progress",isSaving:t.fetchState==="In-Progress",paymentLinkEmailPreview:t.emailPreview,isSendingPaymentLink:t.record.sendLinkState.fetchState==="In-Progress",localData:t.localData,paymentMethods:t.record.paymentMethods,sendPaymentLinkErrorMessage:t.record.sendLinkState.fetchState==="Error"?t.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:t.record.sendLinkState.fetchState==="Completed"?t.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:t.record.sendLinkState.fetchState==="Completed"?t.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:t.record.stripeConnected}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${t}/customers`),onChange:a=>{n(Ee({id:i,localData:a}))},onCreateInvoice:()=>e.navigate(`${t}/invoices/create`),onInvoiceClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(a)}`)},onCreatePromotionalCredits:()=>e.onCreatePromotionalCredits(),onNewSubscription:()=>e.navigate(`${t}/subscriptions/new`),onOpenAddress:()=>{const a=Xt(e.tenantEmailDomain??"",ke,i),o=Y(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${t}/settings/payment-destination`),onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerEdited,{customerId:i}),n(Ee({id:i,localData:a})),n(Dt({id:i}))},onFetchPaymentLinkEmailPreview:a=>n(xi({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,c)=>n(yi({body:c,customerId:i,email:a,subject:o})),onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(a)}`)}}}))(yn);function aa(){const n=D(),e=L(),t=J(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=T(),c=C((O=>we(O,i))),d=c.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(!1),[g,S]=r.useState(!1),[f,h]=r.useState(c.record.fetchState==="Completed"?i:void 0);r.useEffect((()=>{i!=null&&c.record.fetchState==="Completed"&&h(i)}),[i,c.record.fetchState]);const P=f===i,{plaidTokenFetchState:b,promotionalCreditSubmitState:k}=c,{paymentMethodSaveState:y,setupIntentFetchState:I,stripeConnected:j}=c.record,E=r.useRef(c.record.sendLinkState.fetchState);r.useEffect((()=>{const O=c.record.sendLinkState.fetchState;E.current!=="Error"&&O==="Error"&&n(hi({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),E.current=O}),[n,c.record.sendLinkState.fetchState]);const w=I.fetchState==="Error"?I.error?.message??"Failed to start card setup.":y.fetchState==="Error"?y.error?.message??"Failed to save payment method.":b.fetchState==="Error"?b.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(n(te()),n(ne()),()=>{n(te()),n(ne())})),[n]),r.useEffect((()=>{t.state?.openPromotionalCreditsDialog===!0&&(S(!0),e(t.pathname,{replace:!0,state:null}))}),[t.pathname,t.state,e]),r.useEffect((()=>{o&&i!=null&&n(Ii({id:i}))}),[o,i,n]),r.useEffect((()=>{o&&i!=null&&j&&n(Xe({customerId:i}))}),[o,i,n,j]);const[A,U]=r.useState(0);return r.useEffect((()=>{c.fetchState==="Completed"&&(n(Fe()),i!=null&&n(Pt({id:i})),U((O=>O+1)))}),[c.fetchState,n,i]),N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomerDetailPage,isReady:l}),s.jsx(oa,{customerId:i??"",editView:c,hasLoadedRecord:P,location:t,navigate:e,tenantEmailDomain:a,onAddPaymentMethod:()=>{n(te()),i!=null&&j&&n(Xe({customerId:i})),u(!0)},onCreatePromotionalCredits:()=>{n(ne()),S(!0)}},A),s.jsx(En,{errorMessage:w,isCreatingSetupIntent:I.fetchState==="In-Progress",isSaving:y.fetchState==="In-Progress",open:v,plaidLinkToken:c.record.plaidLinkToken,saveSucceeded:y.fetchState==="Completed",setupIntent:c.record.setupIntent,stripeConnected:j,onChooseCard:()=>{i!=null&&n(Ei({customerId:i}))},onClose:()=>{u(!1),n(te())},onSavePaymentMethod:O=>{i!=null&&n(Ci({customerId:i,data:O}))}}),s.jsx(kn,{currentBalance:c.record.invoicingCustomer?.promotionalCredits,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:k.fetchState==="Error"?k.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:k.fetchState==="In-Progress",open:g,submitSucceeded:k.fetchState==="Completed",onClose:()=>{S(!1),n(ne())},onSubmit:({amount:O,description:ee})=>{i!=null&&n(ki({amount:O,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:ee}))}})]})}const sa=_((function(n,e){const t=we(n,e.customerId);return{fieldHelp:t.fieldHelp,billingAddressLabel:t.billingAddressLabel,customerTypeOptions:t.customerTypeOptions,netTermDayOptions:t.netTermDayOptions,taxabilityOptions:t.taxabilityOptions,errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save customer.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,a=i!=null?"edit":"create",o=i!=null?`${t}/customers/${encodeURIComponent(i)}`:`${t}/customers`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerFormCancelled),n(Fe()),n(Re(ke)),e.navigate(`${t}/customers`)},onChange:c=>{n(Ee({id:i,localData:c}))},onOpenAddress:()=>{const c=Xt(e.tenantEmailDomain??"",ke,i),d=Y(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerSaved,{mode:a}),n(Dt({id:i}))}}}))(xn);function ca(){const n=D(),e=L(),t=J(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=T(),{fetchState:c,savedCustomerId:d}=C((l=>we(l,i)));return r.useEffect((()=>{o&&i!=null&&n(Pt({id:i}))}),[o,i,n]),r.useEffect((()=>{if(c==="Completed"){const l=d??i,v=l!=null?`/${a}/invoicing/customers/${encodeURIComponent(l)}`:`/${a}/invoicing/customers`;e(v),n(Fe())}}),[c,d,i,n,e,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomerFormPage}),s.jsx(sa,{customerId:i,location:t,navigate:e,tenantEmailDomain:a})]})}const ra=_((function(n){const e=ue(n),{fetchState:t}=e;return{addressesById:n.addressState.addressesById,columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",customers:e.customers,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.customers.length===0,isLoadingMore:t==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{p.trackInvoicingActionClick(m.Event.invoicingAddCustomerClicked),e.navigate(`${t}/customers/new`)},onCustomerClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${t}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${t}/data_import`)},onRowAction:(i,a)=>{switch(a){case"createInvoice":e.navigate(`${t}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":e.navigate(`${t}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":e.navigate(`${t}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&n(Te({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(bn);function la(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,customerListFetchState:b}=C((y=>{const I=ue(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,customerListFetchState:I.fetchState}}),Z),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&n(et({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(et({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomersListPage,isReady:k}),s.jsx(ra,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onStatusChange:y=>n(bi(y)),onSortChange:v})]})}const je=(n,e)=>e==null?void 0:n.sessionDetail[e]??n.sessions.find((t=>t.id===e)),da=_((function(n,e){const{filters:t,sessionId:i,view:a}=e,o=i==null?void 0:a.diagnosticsBySession[i],c=o?.fetch.fetchState??"Not-Started";return{diagnostics:o?.items??[],errorMessage:c==="Error"?o?.fetch.error?.message:void 0,expired:o?.expired??!1,filters:t,hasMore:o?.nextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress",isLoadingMore:c==="In-Progress"&&(o?.items.length??0)>0,session:je(a,i)}}),(function(n,e){const{downloadUrl:t,filters:i,navigate:a,sessionId:o,tenantEmailDomain:c,view:d}=e,l=o==null?void 0:d.diagnosticsBySession[o],v=je(d,o),u=d.actionStateByKind.retry?.fetchState==="In-Progress",g=d.actionStateByKind.rollback?.fetchState==="In-Progress",S=v?.status==="done"&&v.rollback_available_until!=null&&new Date(v.rollback_available_until).getTime()>Date.now()&&!g;return{onBack:()=>a(`/${c}/invoicing/data_import`),onDownloadCsv:()=>{t!=null&&window.open(t,"_blank","noopener")},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{o!=null&&l?.nextCursor!=null&&n(xe({...i,cursor:l.nextCursor,sessionId:o}))},onRetry:v?.status!=="failed"||u?void 0:()=>{o!=null&&n(_e(o))},onRollback:S?()=>{o!=null&&n(Lt(o))}:void 0}}))(jn);function ua(){const n=D(),e=L(),{sessionId:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),[o,c]=r.useState({}),d=C(Oe),l=je(d,t),v=t==null?void 0:d.diagnosticsBySession[t];r.useEffect((()=>{a&&t!=null&&n(ye(t))}),[a,n,t]),r.useEffect((()=>{if(!a||t==null)return;const f=setTimeout((()=>{n(xe({...o,sessionId:t}))}),300);return()=>clearTimeout(f)}),[a,n,o,t]);const u=l?.status==="scanning"||l?.status==="importing";r.useEffect((()=>{if(!a||t==null||!u)return;const f=setInterval((()=>{n(ye(t)),n(xe({...o,sessionId:t}))}),3e3);return()=>clearInterval(f)}),[a,n,o,u,t]);const g=r.useMemo((()=>{if(t==null)return;const f=new URLSearchParams;o.moduleId!=null&&f.set("module_id",o.moduleId),o.level!=null&&f.set("level",o.level),o.outcome!=null&&f.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&f.set("search",o.search.trim());const h=f.toString();return`${se?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(t)}/issues.csv${h===""?"":`?${h}`}`}),[o,t]),S=v?.fetch.fetchState??"Not-Started";return N(S)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:l!=null&&S!=="Not-Started"}),s.jsx(da,{downloadUrl:g,filters:o,navigate:e,sessionId:t,tenantEmailDomain:i,view:d,onFiltersChange:c})]})}const en=n=>`invoicing_active_migration:${n}`,ae=(n,e)=>{if(n!=null&&n!=="")try{const t=en(n);e==null?sessionStorage.removeItem(t):sessionStorage.setItem(t,e)}catch{}},ga=_((function(n,e){const{sessions:t,sessionsFetch:i,statusFetch:a,statusRows:o}=e.view;return{isLoading:!(a.fetchState!=="Not-Started"&&a.fetchState!=="In-Progress"||o.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:t,statusRows:o}}),(function(n,e){const{navigate:t,tenantEmailDomain:i}=e,a=o=>{const c=o??null;n(oe(c)),ae(i,c),t(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),a(o)},onNewImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingNewImportClicked),a()},onRetrySession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),n(_e(o)),a(o)},onRollbackSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),n(Lt(o))},onViewSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),t(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(Pn);function ma(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),a=C(Oe);r.useEffect((()=>{i&&(n(ji()),n(At()))}),[i,n]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:o}),s.jsx(ga,{navigate:e,tenantEmailDomain:t,view:a})]})}const va=_((function(n,e){const{activeId:t,integrationsView:i,settings:a,view:o}=e,{actionStateByKind:c,sessionDetail:d,sessions:l}=o,v=i.externalConnections?.revenue?.find((g=>g.connectionName==="chargebee")),u=t!=null?d[t]:void 0;return{chargebeeConnected:a?.chargebee_connected===!0||(v?.isValid??!1),chargebeeConnectorAvailable:v!=null,chargebeeSite:a?.chargebee_site,connectError:c.connect?.error?.message,connecting:c.connect?.fetchState==="In-Progress",retrying:c.retry?.fetchState==="In-Progress",session:u??l.find((g=>g.id===t)),starting:c.start?.fetchState==="In-Progress",uploading:c.upload?.fetchState==="In-Progress"}}),(function(n,e){const{activeId:t,navigate:i,tenantEmailDomain:a}=e;return{onBack:e.onBack,onDownloadTemplates:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportTemplatesDownloaded);const o=se?.invoicingMicroServiceBaseUrl,c=o!=null&&o.length>0?o:"";window.open(`${c}/1.0/data-import/templates`,"_blank","noopener")},onFetchFromChargebee:()=>{p.trackInvoicingActionClick(m.Event.invoicingChargebeeConnectClicked),n(Li())},onGoToIntegrations:()=>{i(`/${a}/invoicing/settings`)},onGoToOverview:()=>i(`/${a}/invoicing/overview`),onRetry:()=>{t!=null&&n(_e(t))},onSaveLater:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportStarted),t!=null&&n(Di(t))},onUpload:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportFileUploaded),n(Pi({files:o}))},onViewDetails:t==null?void 0:()=>i(`/${a}/invoicing/data_import/${encodeURIComponent(t)}`)}}))(Dn);function pa(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),a=C(xt),o=C(Me).companyId??Ie.getSignedInUserTenant(t??"")?.companyId,c=C((f=>$t(f,o))),d=C(Oe),{activeMigrationSessionId:l}=d,v=l??void 0,u=v!=null?d.sessionDetail[v]??d.sessions.find((f=>f.id===v)):void 0;r.useEffect((()=>{i&&(n(Ne()),n(At()))}),[i,n]),r.useEffect((()=>{if(l!=null)return;const f=(h=>{if(h==null||h==="")return null;try{return sessionStorage.getItem(en(h))}catch{return null}})(t);f!=null&&n(oe(f))}),[l,n,t]),r.useEffect((()=>{ae(t,l)}),[l,t]);const g=u?.status,S=g==="scanning"||g==="importing";return r.useEffect((()=>{if(!i||v==null||!S)return;const f=setInterval((()=>{n(ye(v))}),3e3);return()=>clearInterval(f)}),[i,v,S,n]),r.useEffect((()=>{g==="done"&&(n(oe(null)),ae(t,null))}),[n,g,t]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportMigratePage}),s.jsx(va,{activeId:v,integrationsView:c,navigate:e,settings:a,tenantEmailDomain:t,view:d,onBack:()=>{n(oe(null)),ae(t,null),e(`/${t}/invoicing/data_import`)}})]})}const fa=_((function(n,e){const{editView:t}=e;return{fieldHelp:t.fieldHelp,coupon:t.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,isLoading:!e.hasLoadedRecord&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:t.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${t}/discounts`),onLifecycleAction:a=>{n(wt({action:a,id:i}))},onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingCouponEdited,{couponId:i}),n($i({data:a,id:i}))}}}))(Ln);function Sa(){const n=D(),e=L(),{coupon_id:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=C((h=>Ai(h,t))),c=o.actionState.fetchState==="In-Progress",d=o.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(l?t:void 0);r.useEffect((()=>{t!=null&&l&&u(t)}),[t,l]);const g=v===t;r.useEffect((()=>(n(G()),()=>{n(G())})),[n]),r.useEffect((()=>{a&&n(tt({id:t}))}),[a,t,n]);const[S,f]=r.useState(0);return r.useEffect((()=>{o.fetchState==="Completed"&&(n(G()),n(tt({cacheOverride:!0,id:t})),f((h=>h+1)))}),[o.fetchState,n,t]),N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDiscountDetailPage,isReady:l}),s.jsx(fa,{hasLoadedRecord:g,couponId:t??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},S)]})}const ha=_((function(n){const e=Ft(n),{fetchState:t}=e;return{columns:e.columns,counts:e.count,discountLifecycleActionOptions:e.discountLifecycleActionOptions,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",coupons:e.coupons,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.coupons.length===0,isLoadingMore:t==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${t}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreateCouponClicked),e.navigate(`${t}/discounts/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${t}/data_import`)},onDiscountLifecycleAction:(i,a)=>{n(wt({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&n(Rt({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(An);function Ia(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,couponListFetchState:b,runningDiscountActionId:k}=C((I=>{const j=Ft(I);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:j.sort,nextCursor:j.nextCursor,couponListFetchState:j.fetchState,runningDiscountActionId:j.runningActionId??null}}),Z),y=b==="Completed";return r.useEffect((()=>{const I=setTimeout((()=>d(a)),300);return()=>clearTimeout(I)}),[a]),r.useEffect((()=>{i&&n(nt({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(nt({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDiscountsListPage,isReady:y}),s.jsx(ha,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,runningDiscountActionId:k,onSearchChange:o,onStatusChange:I=>n(wi(I)),onSortChange:v})]})}const Ca=_((function(n,e){const{readView:t}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:t.dunningCase,isLoading:t.fetchState==="Not-Started"||t.fetchState==="In-Progress",isRunningAction:t.actionState.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,a=i!=="";return{onBack:()=>e.navigate(`${t}/dunning`),onInvoiceClick:o=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(o)}`)},onCancel:a?()=>n(H({action:"cancel",id:i})):void 0,onResolve:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resolve",caseId:i}),n(H({action:"resolve",id:i}))}:void 0,onResume:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resume",caseId:i}),n(H({action:"resume",id:i}))}:void 0,onRetry:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"retry",caseId:i}),n(H({action:"retry",id:i}))}:void 0}}))(wn);function Ea(){const n=D(),e=L(),{case_id:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=C((E=>Fi(E,t??""))),c=o.fetchState==="Completed",d=o.dunningCase?.invoiceID,[l,v]=r.useState("idle"),[u,g]=r.useState(!1),[S,f]=r.useState(),[h,P]=r.useState(!1),b=r.useCallback((()=>{v("idle"),g(!1),f(void 0),P(!1)}),[]),k=r.useCallback((()=>{if(t==null)return;n(Ri({id:t})),v("idle"),g(!1);const E=o.emailPreview.preview;f(E==null?void 0:{body:E.body,cc:E.cc,subject:E.subject,to:E.to}),P(!0)}),[t,n,o.emailPreview.preview]),y=r.useCallback((E=>{t!=null&&l!=="pending"&&(g(!1),v("pending"),p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"send-email",caseId:t}),n(H({action:"send-email",body:E,id:t})))}),[t,n,l]),I=r.useMemo((()=>o.emailPreview.preview==null?void 0:{bodyToken:o.emailPreview.preview.bodyToken,renderedHtmlTemplate:o.emailPreview.preview.renderedHtmlTemplate,subjectToken:o.emailPreview.preview.subjectToken}),[o.emailPreview.preview]);r.useEffect((()=>{a&&t!=null&&n(Ti({id:t}))}),[a,t,n]),r.useEffect((()=>{a&&d!=null&&n(Ue({invoiceId:d}))}),[a,d,n]),r.useEffect((()=>{v("idle"),g(!1),f(void 0),P(!1)}),[t]),r.useEffect((()=>{a||(v("idle"),g(!1),f(void 0),P(!1))}),[a]),r.useEffect((()=>{h&&S==null&&o.emailPreview.preview!=null&&f({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,S,h]),r.useEffect((()=>{l==="pending"&&(o.actionState.fetchState!=="In-Progress"?u&&o.actionState.fetchState==="Completed"?(t!=null&&n(Oi({id:t})),b()):u&&o.actionState.fetchState==="Error"&&v("failed"):g(!0))}),[t,b,n,l,u,o.actionState.fetchState]);const j=d!=null&&o.linkedInvoice?.id===d?o.linkedInvoice.dunningAttempts:void 0;return N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDunningDetailPage,isReady:c}),s.jsx(Ca,{navigate:e,tenantEmailDomain:i,caseId:t??"",readView:o,dunningAttempts:j,onSendEmail:k}),s.jsx($n,{initialDraft:S,isPreviewLoading:o.emailPreview.fetchState==="Not-Started"||o.emailPreview.fetchState==="In-Progress",isSending:l==="pending",onClose:b,onSend:y,open:h,preview:I,previewErrorMessage:o.emailPreview.fetchState==="Error"?o.emailPreview.error?.message:void 0,sendErrorMessage:l==="failed"?o.actionState.error?.message:void 0})]})}const ka=_((function(n){const e=Tt(n),{fetchState:t}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:t==="In-Progress"&&e.dunningCases.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${t}/data_import`),onDunningCaseClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingDunningCaseRowClicked,{caseId:i}),e.navigate(`${t}/dunning/${encodeURIComponent(i)}`)},onRowAction:(i,a)=>{a!=="retry"&&a!=="resume"&&a!=="resolve"&&a!=="cancel"||n(H({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&n(Mi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Fn);function ya(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,dunningCaseListFetchState:b}=C((y=>{const I=Tt(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,dunningCaseListFetchState:I.fetchState}}),Z),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&n(it({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(it({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDunningListPage,isReady:k}),s.jsx(ka,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onStatusChange:y=>n(_i(y)),onSortChange:v})]})}const xa=_((function(n,e){const{view:t}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:t.billingAddress,invoice:t.invoice,invoiceId:e.invoiceId,shippingAddress:t.shippingAddress,isLoading:!e.hasLoadedRecord&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),isSaving:t.actionState.fetchState==="In-Progress",isVoiding:t.actionState.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e;return{onBack:()=>e.navigate(`${t}/invoices`),onCustomerClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${t}/customers/${encodeURIComponent(a)}`)},onIssueCreditNote:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteIssued,{invoiceId:i}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{p.trackInvoicingActionClick(m.Event.invoicingRecordPaymentClicked,{fromScreen:"invoice_detail",invoiceId:i}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceRegenerated,{invoiceId:i}),n(V({action:"regenerate",invoiceId:i}))},onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceEdited,{invoiceId:i}),n(Ui({data:{due_date:a.due_date!==""?a.due_date:void 0,notes:a.notes.trim()!==""?a.notes.split(`
1
+ import{j as s}from"./liveblocks-C_WAhyd7.js";import{a as r}from"./sentry-lC29HHPj.js";import{u as D,h as L,i as R,j as C,t as W,l as _,s as Z,g as J,N as B,n as ie,o as x}from"./core-1xnf2RtE.js";import{a8 as ln,h as p,aq as T,R as m,cb as dn,cc as un,cd as gn,ce as mn,cf as vn,cg as pn,ch as fn,ci as Sn,cj as hn,ck as In,cl as Cn,cm as En,cn as kn,co as yn,p as Y,cp as xn,cq as bn,ae as se,cr as jn,cs as Pn,z as Ie,ct as Dn,cu as Ln,cv as An,cw as $n,cx as wn,cy as Fn,cz as Rn,cA as Tn,V as On,ai as ft,cB as _n,cC as Mn,cD as Nn,cE as Un,cF as De,cG as Bn,cH as Vn,cI as Zn,cJ as Hn,cK as qn,cL as Kn,t as Qe,l as St,cM as Qn,cN as zn,cO as Gn,cP as Wn,cQ as Jn,cR as Yn,cS as Xn}from"./index-DXVI9ztu.js";import"./mui-BAsIRnB1.js";import{A as K}from"./AddressScreen-ueBXhh2E.js";import M from"./NotFoundScreen-BF2gJW91.js";import{Z0 as ei,Z1 as ti,uP as ze,Z2 as Q,vg as ce,Z3 as Le,Z4 as z,vT as Ge,v_ as ni,w3 as ht,Z5 as Ae,Z6 as It,vX as Ct,Z7 as $e,vV as Et,yz as ii,vW as oi,vP as ai,xq as We,vf as Ce,Z8 as si,Z9 as kt,wa as ci,Za as G,wh as ri,Zb as li,Zc as yt,Zd as xt,yl as di,Ze as ue,Zf as Je,Zg as bt,vd as ui,Zh as gi,v7 as mi,Zi as vi,xD as pi,Zj as jt,xM as Ye,Zk as fi,xJ as Si,Zl as we,gg as hi,Zm as te,Zn as ne,ww as Ii,vl as Xe,Zo as Fe,vq as Pt,vo as Ci,vi as Ei,wp as ki,vs as yi,wy as xi,Zp as Ee,wF as Dt,wD as ke,Fo as Re,xS as et,Zq as bi,ve as Te,Zr as Oe,vB as ye,vy as xe,vL as Lt,vK as _e,vv as ji,vE as At,vN as oe,fE as Me,UP as $t,vh as Ne,vI as Pi,vJ as Di,vH as Li,Zs as Ai,wd as tt,wi as $i,we as wt,Zt as Ft,v1 as nt,Zu as wi,uZ as Rt,Zv as Fi,xY as Ri,y0 as H,xX as Ti,x4 as Ue,Zw as Oi,Zx as Tt,y9 as it,Zy as _i,y6 as Mi,Zz as Ot,x7 as Ni,x8 as V,xb as Ui,ZA as _t,xl as pe,ZB as Bi,wx as Mt,Tm as Nt,ZC as Vi,xv as Zi,ZD as Ut,ZE as Hi,ZF as qi,ZG as Ki,y_ as Qi,ZH as zi,ZI as Bt,yg as Vt,ZJ as Zt,yY as fe,ZK as Gi,yV as Wi,ZL as Ji,ZM as Yi,ZN as Xi,ZO as eo,ZP as to,ZQ as ot,ZR as no,e9 as io,z2 as oo,ZS as Be,wP as at,ZT as Ve,ZU as re,wZ as Ht,wU as qt,wS as be,ZV as ao,wK as so,ym as Kt,yN as st,yI as co,ZW as ro,yn as lo,ZX as uo,yO as go,yS as mo,ZY as vo,ZZ as Qt,c8 as po,mr as fo,ms as So,Z_ as ct,vU as le,gk as ho,my as Io,yF as zt,ze as Co,yC as Gt,ul as Eo,zb as rt,u9 as ko,z8 as lt,hR as yo,TP as dt,TQ as xo,FA as Wt,hJ as bo,Z$ as jo,UE as Po,_0 as Do,zk as Se,zl as Lo,_1 as Ao,_2 as Jt,zh as $o,_3 as wo,_4 as Fo,xz as Ro,_5 as To}from"./zeni-epic-state-BVNUxmav.js";import{M as Oo}from"./MobileAppDrawer-DH0tVOfv.js";import{q as de}from"./QBOConnectionScreen-3h-qdoms.js";import"./recharts-C2rsrRI6.js";import"./analytics-N153TuwK.js";import"./plaid-dW1_MCaE.js";import"./dnd-DsH8jkrb.js";import"./stripe-cKAAJElX.js";import"./lottie-NIzYzhlS.js";import"./lexical-d2so_3As.js";import"./pdf-BKNPlqtE.js";import"./utils-BBaMea9r.js";import"./InboxNotificationsProvider-BU6hQETc.js";import"./useTaskManagerAccess-B7YJLgDK.js";import"./empty-GMcl-a5k.js";import"./pdf-lib-RqzDns79.js";import"./index-Ctq16f6K.js";import"./url-LYbpMOZt.js";import"./index-Dc3AC-iD.js";import"./decodeURIComponentSafe-DcD-XNVX.js";(function(){try{var n=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},e=new n.Error().stack;e&&(n._sentryDebugIds=n._sentryDebugIds||{},n._sentryDebugIds[e]="78def842-33ce-4d43-8f0f-25bbc4e24880",n._sentryDebugIdIdentifier="sentry-dbid-78def842-33ce-4d43-8f0f-25bbc4e24880")}catch{}})();const $=({event:n,isReady:e=!0})=>e?s.jsx(ln,{analytics:p,onLoad:t=>t.trackPageLoaded(n)}):null;function N(...n){return n.some((e=>e==="Error"))}function _o(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),{fetchState:g,hasMore:S,items:f,nextCursor:h,auditLogEntityRouteOptions:P,auditLogListSortFieldOptions:b}=C(ei),k=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),y=`/${t??""}/invoicing`,I=r.useCallback(((A,U)=>{const O=ti(y,A,U,P);O!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{entity:A,entityId:U,fromScreen:"audit_log"}),e(O))}),[P,e,y]);r.useEffect((()=>{const A=setTimeout((()=>d(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&n(ze({filters:k,keepExistingListItems:!1,sort:u}))}),[i,k,u,n]);const j=g==="Not-Started"||g==="In-Progress"&&f.length===0,E=g==="In-Progress"&&f.length>0,w=g==="Completed";return N(g)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingAuditLogPage,isReady:w}),s.jsx(dn,{auditLogEntityRouteOptions:P,auditLogListSortFieldOptions:b,entries:f,hasMore:S,isLoading:j,isLoadingMore:E,searchValue:a,sortState:l,onEntityLinkClick:I,onLoadMore:()=>{S&&h!=null&&n(ze({cursor:h,filters:k,keepExistingListItems:!0,sort:u}))},onSearchChange:o,onSortChange:v})]})}function ge(n,e=!1){const t=D(),i=C((c=>Q(c).productNextCursor!=null)),a=C((c=>Q(c).productNextCursor)),o=C((c=>Q(c).productFetchState.fetchState));r.useEffect((()=>{n&&(e&&o!=="Not-Started"||t(ce({filters:{type:"addon|charge"},keepExistingListItems:!1})))}),[n,t,e]),r.useEffect((()=>{n&&o!=="In-Progress"&&i&&a!=null&&t(ce({cursor:a,filters:{type:"addon|charge"},keepExistingListItems:!0}))}),[n,t,o,i,a])}const Mo=new Set(["plan"]),Yt=[],No=It((n=>n.length>0?n:Yt),mn),Uo=It((n=>n.length>0?n:Yt),gn),Bo=_((function(n,e){const{view:t}=e;return{applicableItemOptions:t.applicableItemOptions,groupedAccountOptions:No(t.qboAccountHierarchy),groupedClassOptions:Uo(t.qboClassHierarchy),catalogItemLifecycleActionOptions:t.catalogItemLifecycleActionOptions,catalogProductLifecycleActionOptions:t.catalogProductLifecycleActionOptions,tierTypeOptionsByPricingModel:t.catalogTierTypeOptionsByPricingModel,periodUnitOptions:t.periodUnitOptions,trialEndActionOptions:t.trialEndActionOptions,trialUnitOptions:t.trialUnitOptions,typeOptions:t.typeOptions,isLoading:e.isLoading,isRunningLifecycleAction:t.actionState.fetchState==="In-Progress",isSaving:t.fetchState==="In-Progress",itemId:e.itemId,localData:t.localData,plan:t.plan}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{itemId:i}=e;return{onBack:()=>e.navigate(`${t}/catalog`),onLifecycleAction:i!==""?a=>{i!==""&&n(Ct({action:a,id:i}))}:void 0,onEditChange:a=>{i!==""&&n(Ae({id:i,localData:a}))},onSaveEdit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemEdited,{itemId:i}),n(ht({id:i}))},onSubFamilyLifecycleAction:(a,o)=>{i!==""&&n(ni({action:o,id:a,parentItemId:i}))}}}))(un);function Vo(){const n=D(),e=L(),{item_id:t,tenantEmailDomain:i}=R(),[a]=W(),{areTenantIdsInSync:o}=T(),c=(d=a.get("kind"))!=null&&Mo.has(d)?d:"plan";var d;const l=C((k=>Le(k,t))),{pageFetchState:v}=l,u=v.fetchState;r.useEffect((()=>(n(z()),()=>{n(z())})),[n]),r.useEffect((()=>{o&&n(Ge({id:t,kind:c}))}),[o,t,c,n]);const[g,S]=r.useState(0);r.useEffect((()=>{l.fetchState==="Completed"&&(n(z()),n(Ge({cacheOverride:!0,id:t,kind:c})),S((k=>k+1)))}),[l.fetchState,n,t,c]);const f=u==="Completed";ge(o,!0);const[h,P]=r.useState(f?t:void 0);r.useEffect((()=>{t!=null&&f&&P(t)}),[t,f]);const b=h!==t&&(u==="Not-Started"||u==="In-Progress");return N(u)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogItemDetailPage,isReady:f}),s.jsx(Bo,{navigate:e,tenantEmailDomain:i,itemId:t??"",kind:c,isLoading:b,view:l},g)]})}function Ze(n={}){const{enabled:e=!0,fetchSyncHealth:t=!1,loadAccountingPickers:i=!1,reuseCached:a=!1}=n,o=D(),{areTenantIdsInSync:c}=T(),d=C($e),l=d.connection?.connected===!0,v=d.connectionFetchState.fetchState;return r.useEffect((()=>{e&&c&&(a&&v!=="Not-Started"||o(Et()),t&&o(ii()))}),[c,o,e,t,a]),r.useEffect((()=>{e&&c&&l&&i&&o(oi())}),[c,o,e,l,i]),{isQboConnected:l,qboView:d}}const Zo=new Set(["addon","charge","plan"]),Ho=new Set(["plan"]),qo=_((function(n,e){const t=Le(n,e.itemId);return{fieldHelp:t.fieldHelp,isQboPickerDataLoading:t.isQboPickerDataLoading,qboClassHierarchy:t.qboClassHierarchy,qboAccountHierarchy:t.qboAccountHierarchy,applicabilityValues:t.applicabilityValues,periodUnitOptions:t.periodUnitOptions,trialEndActionOptions:t.trialEndActionOptions,trialUnitOptions:t.trialUnitOptions,typeOptions:t.typeOptions,applicableItemOptions:t.applicableItemOptions,defaultType:e.isEdit?void 0:e.defaultType,errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save catalog item.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode,pricingModelValues:t.pricingModelValues,prorationValues:t.prorationValues,tierTypeOptionsByPricingModel:t.catalogTierTypeOptionsByPricingModel,tierTypeValues:t.tierTypeValues}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,i=e.isEdit?"edit":"create",{itemId:a}=e,o=a!=null?`${t}/catalog/${encodeURIComponent(a)}`:`${t}/catalog`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemFormCancelled),n(z()),e.navigate(`${t}/catalog`)},onChange:c=>{n(Ae({id:a,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemSaved,{mode:i}),n(ht({id:a}))}}}))(vn);function Ko(){const n=D(),e=L(),{item_id:t,tenantEmailDomain:i}=R(),[a]=W(),{areTenantIdsInSync:o}=T(),c=t!=null,d=a.get("type"),l=d!=null&&Zo.has(d)?d:void 0,v=(u=a.get("kind"))!=null&&Ho.has(u)?u:"plan";var u;const g=C((S=>Le(S,t)));return ge(o,!0),Ze({loadAccountingPickers:!0,reuseCached:!0}),r.useEffect((()=>{o&&t!=null&&n(ai({id:t,kind:v}))}),[o,t,v,n]),r.useEffect((()=>{c||l==null||g.localData.catalogType===l||n(Ae({localData:{...g.localData,catalogType:l}}))}),[c,l,g.localData?.catalogType,n]),r.useEffect((()=>{if(g.fetchState==="Completed"){const S=g.savedItemId??t,f=S!=null?`/${i}/invoicing/catalog/${encodeURIComponent(S)}`:`/${i}/invoicing/catalog`;e(f),n(z())}}),[g.fetchState,g.savedItemId,t,n,e,i]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogItemFormPage}),s.jsx(qo,{navigate:e,tenantEmailDomain:i,defaultType:l,isEdit:c,itemId:t})]})}const Qo={addons:"addon",all:"item",charges:"charge",plans:"plan"},zo=_((function(n,e){const t=Q(n),i=e.activeTab==="plans",a=e.activeTab==="all",o=i?t.plans:a?[...t.plans,...t.products]:t.products,c=i||a&&t.fetchState==="In-Progress"?t.fetchState:t.productFetchState.fetchState;return{catalogItemLifecycleActionOptions:t.catalogItemLifecycleActionOptions,counts:t.count,countsLoading:t.countsFetchState.fetchState==="Not-Started"||t.countsFetchState.fetchState==="In-Progress",hasMore:i?t.planNextCursor!=null:a&&t.planNextCursor!=null||t.productNextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress"&&o.length===0,isLoadingMore:c==="In-Progress"&&o.length>0,plans:t.plans,productColumns:t.productColumns,products:t.products}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,i=e.activeTab==="plans",a=e.activeTab==="all",o=i?e.planNextCursor:e.productNextCursor;return{activeTab:e.activeTab,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTabChange:e.onTabChange,onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"catalog"}),e.navigate(`${t}/data_import`)},onAddItem:()=>{const c=Qo[e.activeTab];p.trackInvoicingActionClick(m.Event.invoicingAddCatalogItemClicked,{itemType:c}),e.navigate(`${t}/catalog/new?type=${c}`)},onItemClick:(c,d)=>{p.trackInvoicingActionClick(m.Event.invoicingCatalogItemRowClicked,{itemId:d}),e.navigate(`${t}/catalog/${encodeURIComponent(d)}`)},onCatalogItemLifecycleAction:(c,d)=>{n(Ct({action:si(d),id:c}))},onLoadMore:()=>{if(a)return e.planNextCursor!=null&&n(Ce({cursor:e.planNextCursor,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort})),void(e.productNextCursor!=null&&n(ce({cursor:e.productNextCursor,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort})));o!=null&&n(i?Ce({cursor:o,filters:e.planFilters,keepExistingListItems:!0,sort:e.sort}):ce({cursor:o,filters:e.productFilters,keepExistingListItems:!0,sort:e.sort}))}}}))(pn);function Go(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState("plans"),[l,v]=r.useState(""),[u,g]=r.useState(null),S=r.useMemo((()=>u!=null?{dir:u.direction,field:u.columnKey}:void 0),[u]),f=l.trim()!==""?l.trim():void 0,h=r.useMemo((()=>({search:f,type:"plan"})),[f]),P=r.useMemo((()=>({search:f,type:"addon|charge"})),[f]),b=C((A=>Q(A))),k=b.planFilters.search,y=b.planSort,I=b.planNextCursor,j=b.productNextCursor,E=b.fetchState==="Completed",w=b.runningActionId??null;return r.useEffect((()=>{const A=setTimeout((()=>v(a)),300);return()=>clearTimeout(A)}),[a]),r.useEffect((()=>{i&&n(We({cacheOverride:!1,planFilters:h,productFilters:P,planSort:S,productSort:S}))}),[i,n,h,P,S]),r.useEffect((()=>{i&&(f!==k||S?.field!==y?.field||S?.dir!==y?.dir)&&n(We({cacheOverride:!0,planFilters:h,productFilters:P,planSort:S,productSort:S}))}),[k,y,i,n,h,P,f,S]),N(b.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCatalogPage,isReady:E}),s.jsx(zo,{navigate:e,tenantEmailDomain:t,activeTab:c,searchValue:a,sortState:u,planFilters:h,productFilters:P,sort:S,planNextCursor:I,productNextCursor:j,runningCatalogItemActionId:w,onSearchChange:o,onTabChange:d,onSortChange:g})]})}const Wo=_((function(n,e){const t=kt(n,e.couponId);return{fieldHelp:t.fieldHelp,applyOnOptions:t.applyOnOptions,discountTypeOptions:t.discountTypeOptions,durationTypeOptions:t.durationTypeOptions,errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save coupon.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode,periodUnitOptions:t.periodUnitOptions}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e,a=i!=null?"edit":"create",o=i!=null?`${t}/discounts/${encodeURIComponent(i)}`:`${t}/discounts`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCouponFormCancelled),n(G()),e.navigate(`${t}/discounts`)},onChange:c=>{n(li({id:i,localData:c}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCouponSaved,{mode:a}),n(ri({id:i}))}}}))(fn);function Jo(){const n=D(),e=L(),{coupon_id:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),{fetchState:o,savedCouponId:c}=C((d=>kt(d,t)));return r.useEffect((()=>{a&&t!=null&&n(ci({id:t}))}),[a,t,n]),r.useEffect((()=>{if(o==="Completed"){const d=c??t,l=d!=null?`/${i}/invoicing/discounts/${encodeURIComponent(d)}`:`/${i}/invoicing/discounts`;e(l),n(G())}}),[o,c,t,n,e,i]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCouponFormPage}),s.jsx(Wo,{couponId:t,navigate:e,tenantEmailDomain:i})]})}const Yo=_((function(n){const e=yt(n);return{fieldHelp:e.fieldHelp,customers:e.customers,planNames:e.planNames,errorMessage:e.fetchState==="Error"?e.error?.message??"Failed to create invoice. Please try again.":void 0,isSubmitting:e.fetchState==="In-Progress",localData:e.localData,settings:e.settings}}),(function(n){return{dispatch:n}}),(function(n,{dispatch:e},t){const i=`/${t.tenantEmailDomain}/invoicing`;return{...n,onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreateInvoiceCancelled),t.navigate(`${i}/invoices`)},onChange:a=>{e(bt(a))},onSubmit:()=>{const a=gi(n.localData);p.trackInvoicingActionClick(m.Event.invoicingInvoiceCreated,{customerId:a.customer_id,lineItemCount:a.line_items?.length}),e(mi(a))}}}))(hn);function Xo(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),[i]=W(),{areTenantIdsInSync:a}=T(),o=i.get("customerId"),c=C((I=>yt(I))),d=c.fetchState,l=c.localData,v=c.savedInvoiceId,u=C(xt),g=C((I=>di(I))),S=C(ue),f=g.fetchState==="Not-Started"||g.fetchState==="In-Progress"&&u==null,h=S.fetchState==="Not-Started"||S.fetchState==="In-Progress"&&S.customers.length===0,P=f||h,b=g.fetchState==="Completed"&&S.fetchState==="Completed";r.useEffect((()=>(n(Je()),()=>{n(Je())})),[n]);const k=r.useRef(!1);r.useEffect((()=>{k.current||o==null||o===""||l.customerId!==""||(k.current=!0,n(bt({...l,customerId:o})))}),[o,l,n]),r.useEffect((()=>{a&&n(ui({cacheOverride:!1}))}),[a,n]);const y=r.useRef(d);return r.useEffect((()=>{const I=y.current;if(y.current=d,I!=="Completed"&&d==="Completed"){const j=v!=null?`/${t}/invoicing/invoices/${encodeURIComponent(v)}`:`/${t}/invoicing/invoices`;e(j)}}),[d,v,e,t]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreateInvoicePage,isReady:b}),P?s.jsx(Sn,{}):s.jsx(Yo,{navigate:e,tenantEmailDomain:t})]})}const ea=_((function(n,e){const{detailView:t}=e;return{fieldHelp:e.detailView.fieldHelp,creditNote:t.creditNote,creditNoteId:e.creditNoteId,isLoading:t.fetchState==="Not-Started"||t.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{onBack:()=>e.navigate(`${t}/credits`),onCustomerClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:i,fromScreen:"credit_detail",toScreen:"customer"}),e.navigate(`${t}/customers/${encodeURIComponent(i)}`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",invoiceId:i,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}`)},onSubscriptionClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"credit_detail",subscriptionId:i,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(i)}`)}}}))(In);function ta(){const n=D(),e=L(),{credit_note_id:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=C((d=>vi(d,t??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{a&&t!=null&&n(pi({id:t}))}),[a,t,n]),N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreditDetailPage,isReady:c}),s.jsx(ea,{navigate:e,tenantEmailDomain:i,creditNoteId:t??"",detailView:o})]})}const na=_((function(n){const e=jt(n),{fetchState:t}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",creditNotes:e.creditNotes,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.creditNotes.length===0,isLoadingMore:t==="In-Progress"&&e.creditNotes.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"credits"}),e.navigate(`${t}/data_import`)},onCreditNoteClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteRowClicked,{creditNoteId:i}),e.navigate(`${t}/credits/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&n(Si({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Cn);function ia(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,creditNoteListFetchState:b}=C((y=>{const I=jt(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,creditNoteListFetchState:I.fetchState}}),Z),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&n(Ye({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(Ye({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCreditsListPage,isReady:k}),s.jsx(na,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onStatusChange:y=>n(fi(y)),onSortChange:v})]})}const Xt=(n,e,t)=>{const i=`/${n}/invoicing/customers/`;return t!=null?`${i}${encodeURIComponent(t)}/${e}/`:`${i}new/${e}/`},oa=_((function(n,e){const{editView:t,hasLoadedRecord:i}=e;return{fieldHelp:t.fieldHelp,billingAddressLabel:t.billingAddressLabel,customerTypeOptions:t.customerTypeOptions,netTermDayOptions:t.netTermDayOptions,taxabilityOptions:t.taxabilityOptions,customer:t.record.invoicingCustomer,invoices:t.record.invoices.slice(0,5),isLoading:!i&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),hasPaymentLinkEmailPreviewFailed:t.emailPreviewFetchState.fetchState==="Error",isPaymentLinkEmailPreviewLoading:t.emailPreviewFetchState.fetchState==="In-Progress",isSaving:t.fetchState==="In-Progress",paymentLinkEmailPreview:t.emailPreview,isSendingPaymentLink:t.record.sendLinkState.fetchState==="In-Progress",localData:t.localData,paymentMethods:t.record.paymentMethods,sendPaymentLinkErrorMessage:t.record.sendLinkState.fetchState==="Error"?t.record.sendLinkState.error?.message??"Failed to send payment link.":void 0,sentPaymentLinkEmail:t.record.sendLinkState.fetchState==="Completed"?t.record.sentPaymentLinkEmail:void 0,sentPaymentLinkMagicUrl:t.record.sendLinkState.fetchState==="Completed"?t.record.sentPaymentLinkMagicUrl:void 0,stripeConnected:t.record.stripeConnected}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e;return{onBack:()=>e.navigate(`${t}/customers`),onChange:a=>{n(Ee({id:i,localData:a}))},onCreateInvoice:()=>e.navigate(`${t}/invoices/create`),onInvoiceClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(a)}`)},onCreatePromotionalCredits:()=>e.onCreatePromotionalCredits(),onNewSubscription:()=>e.navigate(`${t}/subscriptions/new`),onOpenAddress:()=>{const a=Xt(e.tenantEmailDomain??"",ke,i),o=Y(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(a,{state:{pathnameStackToGoBack:o}})},onOpenPaymentSettings:()=>e.navigate(`${t}/settings/payment-destination`),onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerEdited,{customerId:i}),n(Ee({id:i,localData:a})),n(Dt({id:i}))},onFetchPaymentLinkEmailPreview:a=>n(xi({cacheOverride:a,customerId:i})),onSendPaymentLink:(a,o,c)=>n(yi({body:c,customerId:i,email:a,subject:o})),onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"customer_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(a)}`)}}}))(yn);function aa(){const n=D(),e=L(),t=J(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=T(),c=C((O=>we(O,i))),d=c.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(!1),[g,S]=r.useState(!1),[f,h]=r.useState(c.record.fetchState==="Completed"?i:void 0);r.useEffect((()=>{i!=null&&c.record.fetchState==="Completed"&&h(i)}),[i,c.record.fetchState]);const P=f===i,{plaidTokenFetchState:b,promotionalCreditSubmitState:k}=c,{paymentMethodSaveState:y,setupIntentFetchState:I,stripeConnected:j}=c.record,E=r.useRef(c.record.sendLinkState.fetchState);r.useEffect((()=>{const O=c.record.sendLinkState.fetchState;E.current!=="Error"&&O==="Error"&&n(hi({messageSection:"common",messageText:"failed",showStatusIcon:!0,type:"error"})),E.current=O}),[n,c.record.sendLinkState.fetchState]);const w=I.fetchState==="Error"?I.error?.message??"Failed to start card setup.":y.fetchState==="Error"?y.error?.message??"Failed to save payment method.":b.fetchState==="Error"?b.error?.message??"Failed to connect bank account.":void 0;r.useEffect((()=>(n(te()),n(ne()),()=>{n(te()),n(ne())})),[n]),r.useEffect((()=>{t.state?.openPromotionalCreditsDialog===!0&&(S(!0),e(t.pathname,{replace:!0,state:null}))}),[t.pathname,t.state,e]),r.useEffect((()=>{o&&i!=null&&n(Ii({id:i}))}),[o,i,n]),r.useEffect((()=>{o&&i!=null&&j&&n(Xe({customerId:i}))}),[o,i,n,j]);const[A,U]=r.useState(0);return r.useEffect((()=>{c.fetchState==="Completed"&&(n(Fe()),i!=null&&n(Pt({id:i})),U((O=>O+1)))}),[c.fetchState,n,i]),N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomerDetailPage,isReady:l}),s.jsx(oa,{customerId:i??"",editView:c,hasLoadedRecord:P,location:t,navigate:e,tenantEmailDomain:a,onAddPaymentMethod:()=>{n(te()),i!=null&&j&&n(Xe({customerId:i})),u(!0)},onCreatePromotionalCredits:()=>{n(ne()),S(!0)}},A),s.jsx(En,{errorMessage:w,isCreatingSetupIntent:I.fetchState==="In-Progress",isSaving:y.fetchState==="In-Progress",open:v,plaidLinkToken:c.record.plaidLinkToken,saveSucceeded:y.fetchState==="Completed",setupIntent:c.record.setupIntent,stripeConnected:j,onChooseCard:()=>{i!=null&&n(Ei({customerId:i}))},onClose:()=>{u(!1),n(te())},onSavePaymentMethod:O=>{i!=null&&n(Ci({customerId:i,data:O}))}}),s.jsx(kn,{currentBalance:c.record.invoicingCustomer?.promotionalCredits,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,errorMessage:k.fetchState==="Error"?k.error?.message??"Failed to add promotional credits.":void 0,isSubmitting:k.fetchState==="In-Progress",open:g,submitSucceeded:k.fetchState==="Completed",onClose:()=>{S(!1),n(ne())},onSubmit:({amount:O,description:ee})=>{i!=null&&n(ki({amount:O,customerId:i,currencyCode:c.record.invoicingCustomer?.preferredCurrencyCode,description:ee}))}})]})}const sa=_((function(n,e){const t=we(n,e.customerId);return{fieldHelp:t.fieldHelp,billingAddressLabel:t.billingAddressLabel,customerTypeOptions:t.customerTypeOptions,netTermDayOptions:t.netTermDayOptions,taxabilityOptions:t.taxabilityOptions,errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save customer.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{customerId:i}=e,a=i!=null?"edit":"create",o=i!=null?`${t}/customers/${encodeURIComponent(i)}`:`${t}/customers`;return{onBack:()=>e.navigate(o),onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerFormCancelled),n(Fe()),n(Re(ke)),e.navigate(`${t}/customers`)},onChange:c=>{n(Ee({id:i,localData:c}))},onOpenAddress:()=>{const c=Xt(e.tenantEmailDomain??"",ke,i),d=Y(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerSaved,{mode:a}),n(Dt({id:i}))}}}))(xn);function ca(){const n=D(),e=L(),t=J(),{customer_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=T(),{fetchState:c,savedCustomerId:d}=C((l=>we(l,i)));return r.useEffect((()=>{o&&i!=null&&n(Pt({id:i}))}),[o,i,n]),r.useEffect((()=>{if(c==="Completed"){const l=d??i,v=l!=null?`/${a}/invoicing/customers/${encodeURIComponent(l)}`:`/${a}/invoicing/customers`;e(v),n(Fe())}}),[c,d,i,n,e,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomerFormPage}),s.jsx(sa,{customerId:i,location:t,navigate:e,tenantEmailDomain:a})]})}const ra=_((function(n){const e=ue(n),{fetchState:t}=e;return{addressesById:n.addressState.addressesById,columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",customers:e.customers,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.customers.length===0,isLoadingMore:t==="In-Progress"&&e.customers.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onAddCustomer:()=>{p.trackInvoicingActionClick(m.Event.invoicingAddCustomerClicked),e.navigate(`${t}/customers/new`)},onCustomerClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingCustomerRowClicked,{customerId:i}),e.navigate(`${t}/customers/${encodeURIComponent(i)}`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"customers"}),e.navigate(`${t}/data_import`)},onRowAction:(i,a)=>{switch(a){case"createInvoice":e.navigate(`${t}/invoices/create?customerId=${encodeURIComponent(i)}`);break;case"newSubscription":e.navigate(`${t}/subscriptions/new?customerId=${encodeURIComponent(i)}`);break;case"createPromotionalCredits":e.navigate(`${t}/customers/${encodeURIComponent(i)}`,{state:{openPromotionalCreditsDialog:!0}})}},onLoadMore:()=>{e.nextCursor!=null&&n(Te({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(bn);function la(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,customerListFetchState:b}=C((y=>{const I=ue(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,customerListFetchState:I.fetchState}}),Z),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&n(et({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(et({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingCustomersListPage,isReady:k}),s.jsx(ra,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onStatusChange:y=>n(bi(y)),onSortChange:v})]})}const je=(n,e)=>e==null?void 0:n.sessionDetail[e]??n.sessions.find((t=>t.id===e)),da=_((function(n,e){const{filters:t,sessionId:i,view:a}=e,o=i==null?void 0:a.diagnosticsBySession[i],c=o?.fetch.fetchState??"Not-Started";return{diagnostics:o?.items??[],errorMessage:c==="Error"?o?.fetch.error?.message:void 0,expired:o?.expired??!1,filters:t,hasMore:o?.nextCursor!=null,isLoading:c==="Not-Started"||c==="In-Progress",isLoadingMore:c==="In-Progress"&&(o?.items.length??0)>0,session:je(a,i)}}),(function(n,e){const{downloadUrl:t,filters:i,navigate:a,sessionId:o,tenantEmailDomain:c,view:d}=e,l=o==null?void 0:d.diagnosticsBySession[o],v=je(d,o),u=d.actionStateByKind.retry?.fetchState==="In-Progress",g=d.actionStateByKind.rollback?.fetchState==="In-Progress",S=v?.status==="done"&&v.rollback_available_until!=null&&new Date(v.rollback_available_until).getTime()>Date.now()&&!g;return{onBack:()=>a(`/${c}/invoicing/data_import`),onDownloadCsv:()=>{t!=null&&window.open(t,"_blank","noopener")},onFiltersChange:e.onFiltersChange,onLoadMore:()=>{o!=null&&l?.nextCursor!=null&&n(xe({...i,cursor:l.nextCursor,sessionId:o}))},onRetry:v?.status!=="failed"||u?void 0:()=>{o!=null&&n(_e(o))},onRollback:S?()=>{o!=null&&n(Lt(o))}:void 0}}))(jn);function ua(){const n=D(),e=L(),{sessionId:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),[o,c]=r.useState({}),d=C(Oe),l=je(d,t),v=t==null?void 0:d.diagnosticsBySession[t];r.useEffect((()=>{a&&t!=null&&n(ye(t))}),[a,n,t]),r.useEffect((()=>{if(!a||t==null)return;const f=setTimeout((()=>{n(xe({...o,sessionId:t}))}),300);return()=>clearTimeout(f)}),[a,n,o,t]);const u=l?.status==="scanning"||l?.status==="importing";r.useEffect((()=>{if(!a||t==null||!u)return;const f=setInterval((()=>{n(ye(t)),n(xe({...o,sessionId:t}))}),3e3);return()=>clearInterval(f)}),[a,n,o,u,t]);const g=r.useMemo((()=>{if(t==null)return;const f=new URLSearchParams;o.moduleId!=null&&f.set("module_id",o.moduleId),o.level!=null&&f.set("level",o.level),o.outcome!=null&&f.set("outcome",o.outcome),o.search!=null&&o.search.trim()!==""&&f.set("search",o.search.trim());const h=f.toString();return`${se?.invoicingMicroServiceBaseUrl??""}/1.0/data-import/${encodeURIComponent(t)}/issues.csv${h===""?"":`?${h}`}`}),[o,t]),S=v?.fetch.fetchState??"Not-Started";return N(S)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:l!=null&&S!=="Not-Started"}),s.jsx(da,{downloadUrl:g,filters:o,navigate:e,sessionId:t,tenantEmailDomain:i,view:d,onFiltersChange:c})]})}const en=n=>`invoicing_active_migration:${n}`,ae=(n,e)=>{if(n!=null&&n!=="")try{const t=en(n);e==null?sessionStorage.removeItem(t):sessionStorage.setItem(t,e)}catch{}},ga=_((function(n,e){const{sessions:t,sessionsFetch:i,statusFetch:a,statusRows:o}=e.view;return{isLoading:!(a.fetchState!=="Not-Started"&&a.fetchState!=="In-Progress"||o.length!==0||i.fetchState!=="Not-Started"&&i.fetchState!=="In-Progress"),sessions:t,statusRows:o}}),(function(n,e){const{navigate:t,tenantEmailDomain:i}=e,a=o=>{const c=o??null;n(oe(c)),ae(i,c),t(`/${i}/invoicing/data_import/migrate`)};return{onContinueSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"continue",sessionId:o}),a(o)},onNewImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingNewImportClicked),a()},onRetrySession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"retry",sessionId:o}),n(_e(o)),a(o)},onRollbackSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"rollback",sessionId:o}),n(Lt(o))},onViewSession:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportSessionAction,{action:"view_details",sessionId:o}),t(`/${i}/invoicing/data_import/${encodeURIComponent(o)}`)}}}))(Pn);function ma(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),a=C(Oe);r.useEffect((()=>{i&&(n(ji()),n(At()))}),[i,n]);const o=a.statusFetch.fetchState==="Completed"&&a.sessionsFetch.fetchState==="Completed";return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportHubPage,isReady:o}),s.jsx(ga,{navigate:e,tenantEmailDomain:t,view:a})]})}const va=_((function(n,e){const{activeId:t,integrationsView:i,settings:a,view:o}=e,{actionStateByKind:c,sessionDetail:d,sessions:l}=o,v=i.externalConnections?.revenue?.find((g=>g.connectionName==="chargebee")),u=t!=null?d[t]:void 0;return{chargebeeConnected:a?.chargebee_connected===!0||(v?.isValid??!1),chargebeeConnectorAvailable:v!=null,chargebeeSite:a?.chargebee_site,connectError:c.connect?.error?.message,connecting:c.connect?.fetchState==="In-Progress",retrying:c.retry?.fetchState==="In-Progress",session:u??l.find((g=>g.id===t)),starting:c.start?.fetchState==="In-Progress",uploading:c.upload?.fetchState==="In-Progress"}}),(function(n,e){const{activeId:t,navigate:i,tenantEmailDomain:a}=e;return{onBack:e.onBack,onDownloadTemplates:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportTemplatesDownloaded);const o=se?.invoicingMicroServiceBaseUrl,c=o!=null&&o.length>0?o:"";window.open(`${c}/1.0/data-import/templates`,"_blank","noopener")},onFetchFromChargebee:()=>{p.trackInvoicingActionClick(m.Event.invoicingChargebeeConnectClicked),n(Li())},onGoToIntegrations:()=>{i(`/${a}/invoicing/settings`)},onGoToOverview:()=>i(`/${a}/invoicing/overview`),onRetry:()=>{t!=null&&n(_e(t))},onSaveLater:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportSavedForLater),e.onBack()},onStartImport:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportStarted),t!=null&&n(Di(t))},onUpload:o=>{p.trackInvoicingActionClick(m.Event.invoicingImportFileUploaded),n(Pi({files:o}))},onViewDetails:t==null?void 0:()=>i(`/${a}/invoicing/data_import/${encodeURIComponent(t)}`)}}))(Dn);function pa(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),a=C(xt),o=C(Me).companyId??Ie.getSignedInUserTenant(t??"")?.companyId,c=C((f=>$t(f,o))),d=C(Oe),{activeMigrationSessionId:l}=d,v=l??void 0,u=v!=null?d.sessionDetail[v]??d.sessions.find((f=>f.id===v)):void 0;r.useEffect((()=>{i&&(n(Ne()),n(At()))}),[i,n]),r.useEffect((()=>{if(l!=null)return;const f=(h=>{if(h==null||h==="")return null;try{return sessionStorage.getItem(en(h))}catch{return null}})(t);f!=null&&n(oe(f))}),[l,n,t]),r.useEffect((()=>{ae(t,l)}),[l,t]);const g=u?.status,S=g==="scanning"||g==="importing";return r.useEffect((()=>{if(!i||v==null||!S)return;const f=setInterval((()=>{n(ye(v))}),3e3);return()=>clearInterval(f)}),[i,v,S,n]),r.useEffect((()=>{g==="done"&&(n(oe(null)),ae(t,null))}),[n,g,t]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDataImportMigratePage}),s.jsx(va,{activeId:v,integrationsView:c,navigate:e,settings:a,tenantEmailDomain:t,view:d,onBack:()=>{n(oe(null)),ae(t,null),e(`/${t}/invoicing/data_import`)}})]})}const fa=_((function(n,e){const{editView:t}=e;return{fieldHelp:t.fieldHelp,coupon:t.coupon,discountLifecycleActionOptions:e.discountLifecycleActionOptions,isLoading:!e.hasLoadedRecord&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),isRunningLifecycleAction:e.isRunningLifecycleAction,isSaving:t.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{couponId:i}=e;return{onBack:()=>e.navigate(`${t}/discounts`),onLifecycleAction:a=>{n(wt({action:a,id:i}))},onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingCouponEdited,{couponId:i}),n($i({data:a,id:i}))}}}))(Ln);function Sa(){const n=D(),e=L(),{coupon_id:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=C((h=>Ai(h,t))),c=o.actionState.fetchState==="In-Progress",d=o.pageFetchState.fetchState,l=d==="Completed",[v,u]=r.useState(l?t:void 0);r.useEffect((()=>{t!=null&&l&&u(t)}),[t,l]);const g=v===t;r.useEffect((()=>(n(G()),()=>{n(G())})),[n]),r.useEffect((()=>{a&&n(tt({id:t}))}),[a,t,n]);const[S,f]=r.useState(0);return r.useEffect((()=>{o.fetchState==="Completed"&&(n(G()),n(tt({cacheOverride:!0,id:t})),f((h=>h+1)))}),[o.fetchState,n,t]),N(d)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDiscountDetailPage,isReady:l}),s.jsx(fa,{hasLoadedRecord:g,couponId:t??"",discountLifecycleActionOptions:o.discountLifecycleActionOptions,editView:o,isRunningLifecycleAction:c,navigate:e,tenantEmailDomain:i},S)]})}const ha=_((function(n){const e=Ft(n),{fetchState:t}=e;return{columns:e.columns,counts:e.count,discountLifecycleActionOptions:e.discountLifecycleActionOptions,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",coupons:e.coupons,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.coupons.length===0,isLoadingMore:t==="In-Progress"&&e.coupons.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onStatusChange:e.onStatusChange,onSortChange:e.onSortChange,onCouponClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingDiscountRowClicked,{couponId:i}),e.navigate(`${t}/discounts/${encodeURIComponent(i)}`)},onCreateCoupon:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreateCouponClicked),e.navigate(`${t}/discounts/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"discounts"}),e.navigate(`${t}/data_import`)},onDiscountLifecycleAction:(i,a)=>{n(wt({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&n(Rt({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(An);function Ia(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,couponListFetchState:b,runningDiscountActionId:k}=C((I=>{const j=Ft(I);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:j.sort,nextCursor:j.nextCursor,couponListFetchState:j.fetchState,runningDiscountActionId:j.runningActionId??null}}),Z),y=b==="Completed";return r.useEffect((()=>{const I=setTimeout((()=>d(a)),300);return()=>clearTimeout(I)}),[a]),r.useEffect((()=>{i&&n(nt({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(nt({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDiscountsListPage,isReady:y}),s.jsx(ha,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,runningDiscountActionId:k,onSearchChange:o,onStatusChange:I=>n(wi(I)),onSortChange:v})]})}const Ca=_((function(n,e){const{readView:t}=e;return{fieldHelp:e.readView.fieldHelp,caseId:e.caseId,dunningAttempts:e.dunningAttempts,dunningCase:t.dunningCase,isLoading:t.fetchState==="Not-Started"||t.fetchState==="In-Progress",isRunningAction:t.actionState.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{caseId:i}=e,a=i!=="";return{onBack:()=>e.navigate(`${t}/dunning`),onInvoiceClick:o=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{caseId:i,fromScreen:"dunning_detail",invoiceId:o,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(o)}`)},onCancel:a?()=>n(H({action:"cancel",id:i})):void 0,onResolve:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resolve",caseId:i}),n(H({action:"resolve",id:i}))}:void 0,onResume:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"resume",caseId:i}),n(H({action:"resume",id:i}))}:void 0,onRetry:a?()=>{p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"retry",caseId:i}),n(H({action:"retry",id:i}))}:void 0}}))(wn);function Ea(){const n=D(),e=L(),{case_id:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=C((E=>Fi(E,t??""))),c=o.fetchState==="Completed",d=o.dunningCase?.invoiceID,[l,v]=r.useState("idle"),[u,g]=r.useState(!1),[S,f]=r.useState(),[h,P]=r.useState(!1),b=r.useCallback((()=>{v("idle"),g(!1),f(void 0),P(!1)}),[]),k=r.useCallback((()=>{if(t==null)return;n(Ri({id:t})),v("idle"),g(!1);const E=o.emailPreview.preview;f(E==null?void 0:{body:E.body,cc:E.cc,subject:E.subject,to:E.to}),P(!0)}),[t,n,o.emailPreview.preview]),y=r.useCallback((E=>{t!=null&&l!=="pending"&&(g(!1),v("pending"),p.trackInvoicingActionClick(m.Event.invoicingDunningAction,{action:"send-email",caseId:t}),n(H({action:"send-email",body:E,id:t})))}),[t,n,l]),I=r.useMemo((()=>o.emailPreview.preview==null?void 0:{bodyToken:o.emailPreview.preview.bodyToken,renderedHtmlTemplate:o.emailPreview.preview.renderedHtmlTemplate,subjectToken:o.emailPreview.preview.subjectToken}),[o.emailPreview.preview]);r.useEffect((()=>{a&&t!=null&&n(Ti({id:t}))}),[a,t,n]),r.useEffect((()=>{a&&d!=null&&n(Ue({invoiceId:d}))}),[a,d,n]),r.useEffect((()=>{v("idle"),g(!1),f(void 0),P(!1)}),[t]),r.useEffect((()=>{a||(v("idle"),g(!1),f(void 0),P(!1))}),[a]),r.useEffect((()=>{h&&S==null&&o.emailPreview.preview!=null&&f({body:o.emailPreview.preview.body,cc:o.emailPreview.preview.cc,subject:o.emailPreview.preview.subject,to:o.emailPreview.preview.to})}),[o.emailPreview.preview,S,h]),r.useEffect((()=>{l==="pending"&&(o.actionState.fetchState!=="In-Progress"?u&&o.actionState.fetchState==="Completed"?(t!=null&&n(Oi({id:t})),b()):u&&o.actionState.fetchState==="Error"&&v("failed"):g(!0))}),[t,b,n,l,u,o.actionState.fetchState]);const j=d!=null&&o.linkedInvoice?.id===d?o.linkedInvoice.dunningAttempts:void 0;return N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDunningDetailPage,isReady:c}),s.jsx(Ca,{navigate:e,tenantEmailDomain:i,caseId:t??"",readView:o,dunningAttempts:j,onSendEmail:k}),s.jsx($n,{initialDraft:S,isPreviewLoading:o.emailPreview.fetchState==="Not-Started"||o.emailPreview.fetchState==="In-Progress",isSending:l==="pending",onClose:b,onSend:y,open:h,preview:I,previewErrorMessage:o.emailPreview.fetchState==="Error"?o.emailPreview.error?.message:void 0,sendErrorMessage:l==="failed"?o.actionState.error?.message:void 0})]})}const ka=_((function(n){const e=Tt(n),{fetchState:t}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",dunningCases:e.dunningCases,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.dunningCases.length===0,isLoadingMore:t==="In-Progress"&&e.dunningCases.length>0,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onImportCsv:()=>e.navigate(`${t}/data_import`),onDunningCaseClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingDunningCaseRowClicked,{caseId:i}),e.navigate(`${t}/dunning/${encodeURIComponent(i)}`)},onRowAction:(i,a)=>{a!=="retry"&&a!=="resume"&&a!=="resolve"&&a!=="cancel"||n(H({action:a,id:i}))},onLoadMore:()=>{e.nextCursor!=null&&n(Mi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Fn);function ya(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,dunningCaseListFetchState:b}=C((y=>{const I=Tt(y);return{activeStatus:I.activeTab,appliedSearch:I.filters.search,appliedSort:I.sort,nextCursor:I.nextCursor,dunningCaseListFetchState:I.fetchState}}),Z),k=b==="Completed";return r.useEffect((()=>{const y=setTimeout((()=>d(a)),300);return()=>clearTimeout(y)}),[a]),r.useEffect((()=>{i&&n(it({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(it({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingDunningListPage,isReady:k}),s.jsx(ka,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onStatusChange:y=>n(_i(y)),onSortChange:v})]})}const xa=_((function(n,e){const{view:t}=e;return{fieldHelp:e.view.fieldHelp,billingAddress:t.billingAddress,invoice:t.invoice,invoiceId:e.invoiceId,shippingAddress:t.shippingAddress,isLoading:!e.hasLoadedRecord&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),isSaving:t.actionState.fetchState==="In-Progress",isVoiding:t.actionState.fetchState==="In-Progress"}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{invoiceId:i}=e;return{onBack:()=>e.navigate(`${t}/invoices`),onCustomerClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"invoice_detail",toScreen:"customer"}),e.navigate(`${t}/customers/${encodeURIComponent(a)}`)},onIssueCreditNote:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteIssued,{invoiceId:i}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}/issue-credit-note`)},onRecordPayment:()=>{p.trackInvoicingActionClick(m.Event.invoicingRecordPaymentClicked,{fromScreen:"invoice_detail",invoiceId:i}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}/record-payment`)},onRegenerate:()=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceRegenerated,{invoiceId:i}),n(V({action:"regenerate",invoiceId:i}))},onSaveEdit:a=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceEdited,{invoiceId:i}),n(Ui({data:{due_date:a.due_date!==""?a.due_date:void 0,notes:a.notes.trim()!==""?a.notes.split(`
2
2
  `).map((o=>o.trim())).filter((o=>o!=="")).map((o=>({note:o}))):void 0,po_number:a.po_number!==""?a.po_number:null},invoiceId:i}))},onSendReminder:()=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceReminderSent,{invoiceId:i}),n(V({action:"send-reminder",invoiceId:i}))},onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"invoice_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(a)}`)},onVoid:a=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceVoided,{invoiceId:i}),n(V({action:"void",invoiceId:i,body:a}))}}}))(Rn);function ba(){const n=D(),e=L(),{invoice_id:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=C((g=>Ot(g,t??""))),c=o.pageFetchState.fetchState,d=c==="Completed",[l,v]=r.useState(d?t:void 0);r.useEffect((()=>{t!=null&&d&&v(t)}),[t,d]);const u=l===t;return r.useEffect((()=>{a&&t!=null&&n(Ni({invoiceId:t}))}),[a,t,n]),N(c)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingInvoiceDetailPage,isReady:d}),s.jsx(xa,{invoiceId:t??"",hasLoadedRecord:u,navigate:e,tenantEmailDomain:i,view:o})]})}const ja=_((function(n){const e=_t(n),{fetchState:t}=e;return{counts:e.counts,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,invoices:e.invoices,statusOptions:e.statusOptions,isLoading:t==="Not-Started"||t==="In-Progress"&&e.invoices.length===0,isLoadingMore:t==="In-Progress"&&e.invoices.length>0,kpis:e.kpis,kpisLoading:e.kpisFetchState.fetchState==="Not-Started"||e.kpisFetchState.fetchState==="In-Progress"&&e.kpis==null,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onCreateInvoice:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreateInvoiceClicked),e.navigate(`${t}/invoices/create`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"invoices"}),e.navigate(`${t}/data_import`)},onInvoiceClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceRowClicked,{invoiceId:i}),e.navigate(`${t}/invoices/${encodeURIComponent(i)}`)},onRowAction:(i,a)=>{switch(a){case"recordPayment":e.navigate(`${t}/invoices/${encodeURIComponent(i)}/record-payment`);break;case"issueCreditNote":e.navigate(`${t}/invoices/${encodeURIComponent(i)}/issue-credit-note`);break;case"sendReminder":n(V({action:"send-reminder",invoiceId:i}));break;case"regenerate":n(V({action:"regenerate",invoiceId:i}));break;case"void":n(V({action:"void",invoiceId:i}))}},onVoidInvoice:(i,a)=>{p.trackInvoicingActionClick(m.Event.invoicingInvoiceVoided,{invoiceId:i}),n(V({action:"void",invoiceId:i,body:a}))},onLoadMore:()=>{e.nextCursor!=null&&n(Mt({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Tn);function Pa(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,invoiceListFetchState:b,voidingInvoiceId:k}=C((I=>{const j=_t(I);return{activeStatus:j.activeTab,appliedSearch:j.filters.search,appliedSort:I.invoicingInvoiceListState.sort,nextCursor:j.nextCursor,invoiceListFetchState:j.fetchState,voidingInvoiceId:j.runningActionId}}),Z),y=b==="Completed";return r.useEffect((()=>{const I=setTimeout((()=>d(a)),300);return()=>clearTimeout(I)}),[a]),r.useEffect((()=>{i&&n(pe({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(pe({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingInvoicesListPage,isReady:y}),s.jsx(ja,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,voidingInvoiceId:k,onSearchChange:o,onStatusChange:I=>{n(Bi(I)),n(pe({cacheOverride:!1,filters:g,sort:u}))},onSortChange:v})]})}function ut(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),i=On(),a=ft(),[o,c]=r.useState(!1),{acceptTermsState:d,status:l}=C(Nt),v=Vi(i?.loggedInUserRoleMap),u=`/${t}/invoicing`,g=S=>{c(S)};return l==="completed"?s.jsx(B,{to:`${u}/overview`,replace:!0}):l==="settings"&&v?s.jsx(B,{to:`${u}/settings`,replace:!0}):s.jsxs(s.Fragment,{children:[s.jsx(Oo,{isAppContentDrawerOpen:o,handleDrawerToggle:g}),s.jsx(_n,{analytics:p,isAccepting:d.fetchState==="In-Progress",isReadOnlyUser:!v,meetingUrl:a("invoicing_promo"),onAcceptClick:()=>{n(Zi())},onBackClick:()=>{e(`/${t}`)},onClickMenuIcon:()=>{g(!0)}})]})}const Da=_((function(n,e){const t=Ut(n,e.invoiceId),{invoice:i,localData:a,reasonCodeOptions:o,submitState:c,typeOptions:d}=t;return{fieldHelp:t.fieldHelp,amountDue:i?.amountDue,currencyCode:i?.currencyCode??"USD",customerName:i?.customerName??"",errorMessage:c.fetchState==="Error"?c.error?.message??"Failed to issue credit note. Please try again.":void 0,invoiceNumber:i?.invoiceNumber??e.invoiceId,isSubmitting:c.fetchState==="In-Progress",localData:a,reasonCodeOptions:o,typeOptions:d}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing/invoices/${encodeURIComponent(e.invoiceId)}`,i=()=>e.navigate(t);return{onBack:i,onCancel:i,onChange:a=>{n(zi({localData:a}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingCreditNoteIssued,{invoiceId:e.invoiceId}),n(Qi())}}}))(Mn);function La(){const n=D(),e=L(),{invoice_id:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),{fetchState:o,invoice:c,isPageReady:d,issuedCreditNoteId:l,submitState:v}=C((f=>Ut(f,t??""))),u=`/${i}/invoicing`,g=r.useRef(null);r.useEffect((()=>{n(Hi()),g.current=null}),[n,t]),r.useEffect((()=>{a&&t!=null&&n(Ue({invoiceId:t}))}),[a,n,t]),r.useEffect((()=>{c!=null&&t!=null&&o==="Completed"&&g.current!==t&&(g.current=t,n(qi({localData:Ki(c)})))}),[n,o,c,t]);const S=r.useRef(v.fetchState);return r.useEffect((()=>{const f=S.current;S.current=v.fetchState,f!=="Completed"&&v.fetchState==="Completed"&&l!=null&&e(`${u}/credits/${encodeURIComponent(l)}`)}),[l,e,v.fetchState,u]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingInvoiceDetailPage,isReady:d}),s.jsx(Da,{invoiceId:t??"",navigate:e,tenantEmailDomain:i})]})}const Aa=_((function(n){return{invoicingOverview:Bt(n)}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{onRefresh:()=>{n(Vt(e.selectedPeriod,!0))},onSubscriptionClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionTileClicked,{subscriptionId:i}),e.navigate(`${t}/subscriptions/${i}`)},onViewInvoices:()=>{p.trackInvoicingActionClick(m.Event.invoicingViewInvoicesClicked),e.navigate(`${t}/invoices`)},onViewPayments:()=>{p.trackInvoicingActionClick(m.Event.invoicingViewPaymentsClicked),e.navigate(`${t}/payments`)}}}))(Nn);function $a(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a]=r.useState((()=>{const c=new Date;return{month:c.getMonth()+1,year:c.getFullYear()}})),o=C((c=>Bt(c).fetchState))==="Completed";return r.useEffect((()=>{i&&n(Vt(a))}),[i,n,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingOverviewPage,isReady:o}),s.jsx(Aa,{navigate:e,selectedPeriod:a,tenantEmailDomain:t})]})}const wa=_((function(n){const e=Zt(n),{fetchState:t}=e;return{columns:e.columns,hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.transactions.length===0,isLoadingMore:t==="In-Progress"&&e.transactions.length>0,tabIds:e.tabIds,transactions:e.transactions}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`;return{activeType:e.activeType,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onTypeChange:e.onTypeChange,onViewTransactionCustomer:e.onViewTransactionCustomer,onViewTransactionInvoice:e.onViewTransactionInvoice,onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"payments"}),e.navigate(`${t}/data_import`)},onTransactionClick:i=>{p.trackInvoicingActionClick(m.Event.invoicingPaymentRowClicked,{transactionId:i}),e.navigate(`${t}/payments/${encodeURIComponent(i)}`)},onLoadMore:()=>{e.nextCursor!=null&&n(Wi({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(Un);function Fa(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeType:S,appliedSearch:f,appliedSort:h,nextCursor:P,transactionListFetchState:b,transactions:k}=C((w=>{const A=Zt(w);return{activeType:A.activeTab,appliedSearch:A.filters.search,appliedSort:A.sort,nextCursor:A.nextCursor,transactionListFetchState:A.fetchState,transactions:A.transactions}}),Z),y=b==="Completed",I=`/${t}/invoicing`,j=r.useCallback((w=>{const A=k.find((O=>O.id===w)),U=A?.linkedInvoices?.[0]?.invoiceID??A?.invoiceID;U!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"payments_list",invoiceId:U,toScreen:"invoice"}),e(`${I}/invoices/${encodeURIComponent(U)}`))}),[e,I,k]),E=r.useCallback((w=>{const A=k.find((U=>U.id===w))?.customerID;A!=null&&(p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:A,fromScreen:"payments_list",toScreen:"customer"}),e(`${I}/customers/${encodeURIComponent(A)}`))}),[e,I,k]);return r.useEffect((()=>{const w=setTimeout((()=>d(a)),300);return()=>clearTimeout(w)}),[a]),r.useEffect((()=>{i&&n(fe({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(fe({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingPaymentsListPage,isReady:y}),s.jsx(wa,{navigate:e,tenantEmailDomain:t,activeType:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,onSearchChange:o,onTypeChange:w=>{n(Gi(w)),n(fe({cacheOverride:!1,filters:g,sort:u}))},onSortChange:v,onViewTransactionCustomer:E,onViewTransactionInvoice:j})]})}const Ra=n=>{const e=[n.firstName,n.lastName].filter((t=>t!=null&&t.trim()!=="")).join(" ").trim();return(n.company!=null&&n.company.trim()!==""?n.company.trim():"")||e||(n.email!=null&&n.email.trim()!==""?n.email.trim():"")||n.id};function gt(){const n=D(),e=L(),{invoice_id:t,tenantEmailDomain:i}=R(),{areTenantIdsInSync:a}=T(),o=t!=null&&t!=="",c=C(ue),d=C((E=>Ji(E))),l=C(Yi),v=C((E=>Ot(E,t??""))),u=v.invoice,g=`/${i}/invoicing`,S=r.useRef(null),f=r.useRef("");r.useEffect((()=>{n(Xi()),S.current=null,f.current=""}),[n,t]),r.useEffect((()=>{a&&n(o&&t!=null?Ue({invoiceId:t}):Te({filters:{},keepExistingListItems:!1}))}),[a,n,t,o]),r.useEffect((()=>{o&&u!=null&&t!=null&&v.fetchState==="Completed"&&S.current!==t&&(S.current=t,n(eo({contextInvoiceId:t,localData:to(u)})))}),[n,u,t,v.fetchState,o]),r.useEffect((()=>{if(o)return;const E=d.localData.customerId;E!==""&&E!==f.current&&(f.current=E,n(Mt({filters:{customerId:E},keepExistingListItems:!1})),d.localData.invoiceToLink!==""&&n(ot({localData:{...d.localData,customerId:E,invoiceToLink:""}})))}),[n,d.localData,o]);const h=r.useRef(l.fetchState);r.useEffect((()=>{const E=h.current;if(h.current=l.fetchState,E!=="Completed"&&l.fetchState==="Completed"){if(l.recordedInvoiceId!=null)return void e(`${g}/invoices/${encodeURIComponent(l.recordedInvoiceId)}`);e(`${g}/payments`)}}),[e,l.fetchState,l.recordedInvoiceId,g]);const P=r.useMemo((()=>c.customers.map((E=>({id:E.id,name:Ra(E)})))),[c.customers]),b=C((E=>no(E,d.localData.customerId))),k=r.useMemo((()=>b.map((E=>{return{amountDue:(w=E.amountDue,A=io.currencySymbol,Vn("0,0.00",w,A)),amountDueValue:E.amountDue,id:E.id,label:E.invoiceNumber};var w,A}))),[b]),y=r.useMemo((()=>{if(!o||u==null)return;const E=u.currencyCode??"USD",w=u.amountDue?.amount??0;return{amountDue:De("0,0.00",u.amountDue),amountDueValue:w,currencyCode:E,customerName:u.customerName??u.customerID,invoiceId:u.id,invoiceNumber:u.invoiceNumber??u.id}}),[u,o]),I=o?`${g}/invoices/${encodeURIComponent(t??"")}`:`${g}/payments`,j=!o||v.fetchState==="Completed"&&d.localData.invoiceToLink!=="";return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingRecordPaymentPage,isReady:j}),s.jsx(Bn,{customers:P,fieldHelp:d.fieldHelp,errorMessage:l.fetchState==="Error"?l.error?.message??"Failed to record payment. Please try again.":void 0,gatewayOptions:d.gatewayOptions,invoiceContext:y,invoiceOptions:k,isSubmitting:l.fetchState==="In-Progress",localData:d.localData,mode:o?"invoice":"customer",paymentMethodOptions:d.paymentMethodOptions,onBack:()=>{e(I)},onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingRecordPaymentCancelled),e(I)},onChange:E=>{n(ot({localData:E}))},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingPaymentRecorded,{customerId:d.localData.customerId,invoiceId:o?t:d.localData.invoiceToLink,paymentMethod:d.localData.paymentMethod}),n(oo(o?t??void 0:void 0))}})]})}const tn=(n,e,t)=>{const i=`/${n}/invoicing/subscriptions/`;return t!=null?`${i}${encodeURIComponent(t)}/${e}/`:`${i}new/${e}/`},Ta=(n,e)=>{if(n==null)return;const t=De("0,0",n);return e!=null?`${t}/${e}`:t},nn=(n,e,t)=>{const i=[n,Ta(e,t)].filter((a=>a!=null&&a!=="")).join(" · ");return i!==""?i:void 0},mt=n=>n.priceCode!=null&&n.priceCode.trim()!=="",Oa=n=>({billingCycles:n.billingCycles,billingPeriod:n.period,billingPeriodUnit:n.periodUnit,label:n.name??n.id,subtitle:nn(n.productCode,n.price,n.periodUnit),value:n.priceCode}),_a=n=>({label:n.name??n.couponCode??n.id,value:n.couponCode??n.id}),Ma=_((function(n,e){const{editView:t}=e,i=t.subscription,a=i?.status,o=a!=null&&e.commercialEditAllowedFromStatuses.includes(a);return{cancelReasonCodeOptions:t.cancelReasonCodeOptions,fieldHelp:t.fieldHelp,addons:t.products.filter((c=>c.itemType==="addon")).filter(mt).map((c=>({label:c.name??c.id,subtitle:nn(c.productCode,c.price,c.periodUnit),value:c.priceCode}))),canEditCommercial:o,coupons:t.coupons.map(_a),isLoading:!e.hasLoadedRecord&&(t.pageFetchState.fetchState==="Not-Started"||t.pageFetchState.fetchState==="In-Progress"),isRunningAction:t.actionState.fetchState==="In-Progress",isSaving:t.fetchState==="In-Progress",lifecycleActionOptions:e.lifecycleActionOptions,localData:t.localData,plans:t.plans.filter(mt).map(Oa),shippingAddressLabel:t.shippingAddressLabel,subscription:i}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,a=i!=="",o=(c,d)=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionLifecycleAction,{action:c,subscriptionId:i}),n(qt({action:c,id:i,body:d}))};return{onBack:()=>e.navigate(`${t}/subscriptions`),onChange:c=>{n(re({id:i,localData:c}))},onChangeTermEnd:a?c=>{const d=c?.trim()??"";d!==""&&o("change_term_end",{term_ends_at:d})}:void 0,onCustomerClick:c=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:c,fromScreen:"subscription_detail",toScreen:"customer"}),window.open(`${t}/customers/${encodeURIComponent(c)}`,"_blank","noopener,noreferrer")},onOpenAddress:()=>{const c=tn(e.tenantEmailDomain??"",be,i),d=Y(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(c,{state:{pathnameStackToGoBack:d}})},onViewInvoices:()=>e.navigate(`${t}/invoices`),onSaveEdit:c=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionEdited,{subscriptionId:i}),n(re({id:i,localData:c})),n(Ht({id:i}))},onCancelSubscription:a?c=>{o("cancel",{cancel_reason_code:c.cancelReasonCode,end_of_term:!1,...c.cancelReason!=null&&c.cancelReason.trim()!==""?{cancel_reason:c.cancelReason.trim()}:{}})}:void 0,onLifecycleAction:a?(c,d)=>{c!=="pause"?o(c):o(c,d!=null&&d.trim()!==""?{resume_date:d.trim()}:void 0)}:void 0}}))(Zn);function Na(){const n=D(),e=L(),t=J(),{subscription_id:i,tenantEmailDomain:a}=R(),{areTenantIdsInSync:o}=T(),c=C((k=>Be(k,i))),{subscriptionCommercialEditAllowedFromStatuses:d,subscriptionLifecycleActionOptions:l,subscriptionMetadataEditAllowedFromStatuses:v}=c,u=c.pageFetchState.fetchState,g=u==="Completed",[S,f]=r.useState(g?i:void 0);r.useEffect((()=>{i!=null&&g&&f(i)}),[i,g]);const h=S===i;ge(o),r.useEffect((()=>{o&&i!=null&&n(at({id:i}))}),[o,i,n]);const[P,b]=r.useState(0);return r.useEffect((()=>{c.fetchState==="Completed"&&(n(Ve()),n(at({cacheOverride:!0,id:i})),b((k=>k+1)))}),[c.fetchState,n,i]),N(u)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSubscriptionDetailPage,isReady:g}),s.jsx(Ma,{hasLoadedRecord:h,commercialEditAllowedFromStatuses:d,editView:c,lifecycleActionOptions:l,location:t,metadataEditAllowedFromStatuses:v,navigate:e,subscriptionId:i??"",tenantEmailDomain:a},P)]})}const Ua=n=>{const e=[n.firstName,n.lastName].filter((t=>t!=null&&t.trim()!=="")).join(" ").trim();return(n.company!=null&&n.company.trim()!==""?n.company.trim():"")||e||(n.email!=null&&n.email.trim()!==""?n.email.trim():"")||n.id},Ba=(n,e)=>{if(n==null)return;const t=De("0,0",n);return e!=null?`${t}/${e}`:t},Pe=(n,e,t)=>{const i=[n,Ba(e,t)].filter((a=>a!=null&&a!=="")).join(" · ");return i!==""?i:void 0},Va=n=>({label:Ua(n),value:n.id}),he=n=>n.priceCode!=null&&n.priceCode.trim()!=="",Za=n=>({billingCycles:n.billingCycles,billingPeriod:n.period,billingPeriodUnit:n.periodUnit,label:n.name??n.id,subtitle:Pe(n.productCode,n.price,n.periodUnit),trialPeriod:n.trialPeriod,trialPeriodUnit:n.trialPeriodUnit,value:n.priceCode}),Ha=n=>({label:n.name??n.couponCode??n.id,value:n.couponCode??n.id}),qa=_((function(n,e){const t=Be(n,e.subscriptionId);return{fieldHelp:t.fieldHelp,addons:t.products.filter((i=>i.itemType==="addon")).filter(he).map((i=>({label:i.name??i.id,subtitle:Pe(i.productCode,i.price,i.periodUnit),value:i.priceCode}))),charges:t.products.filter((i=>i.itemType==="charge")).filter(he).map((i=>({label:i.name??i.id,subtitle:Pe(i.productCode,i.price,void 0),value:i.priceCode}))),coupons:t.coupons.map(Ha),customers:t.customers.map(Va),errorMessage:t.fetchState==="Error"?t.error?.message??"Failed to save subscription.":void 0,isSubmitting:t.fetchState==="In-Progress",localData:t.localData,mode:t.mode,plans:t.plans.filter(he).map(Za),shippingAddressLabel:t.shippingAddressLabel}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{subscriptionId:i}=e,a=i!=null?"edit":"create";return{onCancel:()=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionFormCancelled),n(Ve()),n(Re(be)),i==null?e.navigate(`${t}/subscriptions`):e.navigate(`${t}/subscriptions/${encodeURIComponent(i)}`)},onChange:o=>{n(re({id:i,localData:o}))},onOpenAddress:()=>{const o=tn(e.tenantEmailDomain??"",be,i),c=Y(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(o,{state:{pathnameStackToGoBack:c}})},onSubmit:()=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionSaved,{mode:a}),n(Ht({id:i}))}}}))(Hn);function Ka(){const n=D(),e=L(),t=J(),{subscription_id:i,tenantEmailDomain:a}=R(),[o]=W(),{areTenantIdsInSync:c}=T(),d=o.get("customerId"),{fetchState:l,savedSubscriptionId:v}=C((S=>ao(S,i))),u=C((S=>Be(S,i).localData));ge(c),r.useEffect((()=>{c&&(n(Te({filters:{},keepExistingListItems:!1})),n(Ce({filters:{type:"plan"},keepExistingListItems:!1})),n(Rt({filters:{},keepExistingListItems:!1})),i!=null&&n(so({id:i})))}),[c,i,n]);const g=r.useRef(!1);return r.useEffect((()=>{g.current||i!=null||d==null||d===""||u.customerId!==""||(g.current=!0,n(re({id:i,localData:{...u,customerId:d}})))}),[d,i,u,n]),r.useEffect((()=>{if(l==="Completed"){const S=v??i,f=S!=null?`/${a}/invoicing/subscriptions/${encodeURIComponent(S)}`:`/${a}/invoicing/subscriptions`;e(f),n(Ve())}}),[l,v,i,n,e,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSubscriptionFormPage}),s.jsx(qa,{location:t,navigate:e,subscriptionId:i,tenantEmailDomain:a})]})}const Qa=_((function(n){const e=Kt(n),{fetchState:t}=e;return{columns:e.columns,counts:e.count,countsLoading:e.countsFetchState.fetchState==="Not-Started"||e.countsFetchState.fetchState==="In-Progress",hasMore:e.nextCursor!=null,isLoading:t==="Not-Started"||t==="In-Progress"&&e.subscriptions.length===0,isLoadingMore:t==="In-Progress"&&e.subscriptions.length>0,cancelReasonCodeOptions:e.cancelReasonCodeOptions,lifecycleActionOptions:e.subscriptionLifecycleActionOptions,subscriptions:e.subscriptions,tabIds:e.tabIds}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,i=(a,o,c)=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionLifecycleAction,{action:o,subscriptionId:a}),n(qt({action:o,id:a,body:c}))};return{activeStatus:e.activeStatus,searchValue:e.searchValue,sortState:e.sortState,onSearchChange:e.onSearchChange,onSortChange:e.onSortChange,onStatusChange:e.onStatusChange,onAddSubscription:()=>{p.trackInvoicingActionClick(m.Event.invoicingAddSubscriptionClicked),e.navigate(`${t}/subscriptions/new`)},onImportCsv:()=>{p.trackInvoicingActionClick(m.Event.invoicingImportCsvClicked,{entity:"subscriptions"}),e.navigate(`${t}/data_import`)},onChangeTermEnd:(a,o)=>{const c=o?.trim()??"";c!==""&&i(a,"change_term_end",{term_ends_at:c})},onSubscriptionAction:(a,o,c)=>{o!=="pause"?i(a,o):i(a,o,c!=null&&c.trim()!==""?{resume_date:c.trim()}:void 0)},onCancelSubscription:(a,o)=>{i(a,"cancel",{cancel_reason_code:o.cancelReasonCode,end_of_term:!1,...o.cancelReason!=null&&o.cancelReason.trim()!==""?{cancel_reason:o.cancelReason.trim()}:{}})},onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingSubscriptionRowClicked,{subscriptionId:a}),e.navigate(`${t}/subscriptions/${encodeURIComponent(a)}`)},onViewSubscriptionInvoices:()=>{e.navigate(`${t}/invoices`)},onLoadMore:()=>{e.nextCursor!=null&&n(lo({cursor:e.nextCursor,filters:e.filters,keepExistingListItems:!0,sort:e.sort}))}}}))(qn);function za(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),[a,o]=r.useState(""),[c,d]=r.useState(""),[l,v]=r.useState(null),u=r.useMemo((()=>l!=null?{dir:l.direction,field:l.columnKey}:void 0),[l]),g=r.useMemo((()=>({search:c.trim()!==""?c.trim():void 0})),[c]),{activeStatus:S,appliedSearch:f,appliedSort:h,nextCursor:P,subscriptionListFetchState:b,runningActionSubscriptionId:k}=C((j=>{const E=Kt(j);return{activeStatus:E.activeTab,appliedSearch:E.filters.search,appliedSort:E.sort,nextCursor:E.nextCursor,subscriptionListFetchState:E.fetchState,runningActionSubscriptionId:E.runningActionId??null}}),Z),y=b==="Completed";r.useEffect((()=>{const j=setTimeout((()=>d(a)),300);return()=>clearTimeout(j)}),[a]),r.useEffect((()=>{i&&n(st({cacheOverride:!1}))}),[i,n]),r.useEffect((()=>{i&&(g.search!==f||u?.field!==h?.field||u?.dir!==h?.dir)&&n(st({cacheOverride:!0,filters:g,sort:u}))}),[i,n,g,u,f,h]);const I=r.useRef(k);return r.useEffect((()=>{const j=I.current!=null&&k==null;I.current=k,j&&i&&n(co())}),[k,i,n]),N(b)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSubscriptionsListPage,isReady:y}),s.jsx(Qa,{navigate:e,tenantEmailDomain:t,activeStatus:S,searchValue:a,sortState:l,filters:g,sort:u,nextCursor:P,runningActionSubscriptionId:k,onSearchChange:o,onStatusChange:j=>n(ro(j)),onSortChange:v})]})}const Ga=_((function(n,e){const{readView:t}=e;return{isLoading:t.fetchState==="Not-Started"||t.fetchState==="In-Progress",isRunningAction:t.actionState.fetchState==="In-Progress",transaction:t.transaction,transactionId:e.transactionId}}),(function(n,e){const t=`/${e.tenantEmailDomain}/invoicing`,{transactionId:i}=e;return{onBack:()=>e.navigate(`${t}/payments`),onCustomerClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{customerId:a,fromScreen:"transaction_detail",toScreen:"customer"}),e.navigate(`${t}/customers/${encodeURIComponent(a)}`)},onInvoiceClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",invoiceId:a,toScreen:"invoice"}),e.navigate(`${t}/invoices/${encodeURIComponent(a)}`)},onSubscriptionClick:a=>{p.trackInvoicingActionClick(m.Event.invoicingEntityLinkClicked,{fromScreen:"transaction_detail",subscriptionId:a,toScreen:"subscription"}),e.navigate(`${t}/subscriptions/${encodeURIComponent(a)}`)},onCapture:i!==""?()=>{p.trackInvoicingActionClick(m.Event.invoicingTransactionCaptured,{transactionId:i}),n(mo({action:"capture",id:i}))}:void 0}}))(Kn);function Wa(){const n=D(),e=L(),{tenantEmailDomain:t,transaction_id:i}=R(),{areTenantIdsInSync:a}=T(),o=C((d=>uo(d,i??""))),c=o.fetchState==="Completed";return r.useEffect((()=>{a&&i!=null&&n(go({id:i}))}),[a,i,n]),N(o.fetchState)?s.jsx(M,{}):s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingTransactionDetailPage,isReady:c}),s.jsx(Ga,{navigate:e,tenantEmailDomain:t,transactionId:i??"",readView:o})]})}const Ja={branding:"invoicing_branding_save",dunning:"invoicing_dunning_settings_save",quickbooks:"invoicing_qbo_settings_save"};function X(n){const e=D(),{areTenantIdsInSync:t}=T(),{tenantEmailDomain:i}=R(),{fetchState:a,fieldHelp:o,logoFile:c,saveState:d,settings:l,stripeConnectState:v}=C(vo),{configError:u,configFetchState:g,dunningScheduleActionOptions:S,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:h,qboSyncStatusOptions:P}=C(Qt),b=C($e);Ze({enabled:n==="quickbooks",fetchSyncHealth:!0,loadAccountingPickers:!0});const k=C(Me),y=n==="dunning"||n==="quickbooks",I=k.companyId??Ie.getSignedInUserTenant(i??"")?.companyId,j=C((F=>$t(F,I))),E=po(k.userRole??[]),w=k.tenantId??"",A=Ie.getSignedInUser(),U={userId:A?.userId??"",sessionId:A?.zeniSessionId??"",tenantId:w},O=c?.fileId,ee=C((F=>O!=null&&O!==""?fo(F,O):void 0)),He=C((F=>O!=null&&O!==""?So(F,O):void 0)),on=O!=null&&O!==""&&ee!=null?{[O]:ee}:{},an=O!=null&&O!==""&&He!=null?{[O]:He}:{};r.useEffect((()=>(e(ct()),()=>{e(ct())})),[e]),r.useEffect((()=>{t&&(a!=="Not-Started"&&a!=="Error"||e(Ne()))}),[t,e,a]),r.useEffect((()=>{t&&y&&g==="Not-Started"&&e(le())}),[t,e,g,y]),r.useEffect((()=>{if(!t)return;const F=A?.userId;F!=null&&F!==""&&w!==""&&Qe.shouldFetchActiveTenant(w)&&(Qe.markActiveTenantFetchStarted(w),e(ho(F,w,A?.zeniSessionId)))}),[t,e,A?.userId,A?.zeniSessionId,w]);const sn=S.length>0||f.length>0,cn=a==="Not-Started"||a==="In-Progress"&&l==null||y&&!sn&&(g==="Not-Started"||g==="In-Progress"),rn=a==="Completed"&&(!y||g==="Completed"),qe=j.externalConnections?.revenue?.find((F=>F.connectionName==="chargebee"))?.connectionId,me=se?.invoicingMicroServiceBaseUrl,Ke=me!=null&&me.length>0?`${me}/1.0/webhooks/stripe`:"",ve={deleteConnectionError:j.externalConnections?.deleteConnectionError?.message,deleteConnectionState:j.externalConnections?.deleteConnectionState??"Not-Started",integrationsView:j,isAdmin:E,isStripeBusy:v.fetchState==="In-Progress",onConnectStripe:F=>e(lt(F)),onDisconnect:(F,q)=>{w!==""&&e(bo(w,F,dt(q)))},onDisconnectStripe:()=>e(rt()),onReconnectQBO:()=>{const F=k.tenantEmailDomain??i??"";de.init("/connection/auth",F),de.handleClick()},onRefreshQBO:()=>{j.integrations.refreshQBO.fetchState!=="In-Progress"&&e(Wt())},onSaveChargeBeeCredentials:(F,q)=>{qe!=null&&w!==""&&e(yo(w,qe,dt("revenue"),xo("chargebee"),{api_key:F,site:q}))},saveChargeBeeError:j.externalConnections?.saveAPIKeyConnectionError?.message,saveChargeBeeState:j.externalConnections?.saveAPIKeyConnectionState??"Not-Started",settings:l,stripeError:v.fetchState==="Error"?v.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Ke};return{authParams:U,deleteFileStatusById:on,fieldHelp:o,dunningScheduleActionOptions:S,filesEndPoint:se?.fileMicroServiceBaseUrl??"",integrationsSectionProps:ve,isInvoicingPageReady:rn,isLoading:cn,isSaving:d.fetchState==="In-Progress",isStripeBusy:v.fetchState==="In-Progress",logoFile:c,qboAccountMappingKindOptions:f,qboCustomerMatchingOptions:h,qboSyncStatusOptions:P,qboView:b,saveErrorMessage:d.fetchState==="Error"?d.error?.message??"Failed to save settings.":y&&g==="Error"?u?.message??"Failed to load invoicing configuration.":void 0,settings:l,stripeError:v.fetchState==="Error"?v.error?.message??"Failed to connect Stripe. Check your keys and try again.":void 0,stripeWebhookUrl:Ke,updateFileStatusById:an,onConnectStripe:F=>e(lt(F)),onDeleteFile:F=>e(ko(F,w)),onDisconnectStripe:()=>e(rt()),onEditFileName:(F,q)=>e(Eo(F,q,w)),onReconnectQBO:ve.onReconnectQBO,onRefreshQBO:ve.onRefreshQBO,onRetryQboSyncTask:F=>e(Gt(F)),onSave:F=>{p.trackInvoicingActionClick(m.Event.invoicingSettingsSaved,{tab:n??"hub"}),e(Co({settings:F,snackbarSection:Ja[n??""]}))},onStartQboBackfill:F=>e(zt(F)),updateFilesEntity:F=>{p.trackInvoicingActionClick(m.Event.invoicingLogoUploaded),e(Io({files:F}))}}}function vt({appContent:n}){const e=L(),t=J(),i=D(),{tenantEmailDomain:a}=R(),o=X("branding"),c=C((v=>jo(v))),d=C((v=>Po(Se,v)?.addressToCreate));r.useEffect((()=>{c.saveState.fetchState==="Completed"&&(i(Do()),i(Re(Se)))}),[c.saveState.fetchState,i]);const l=St(c.saveState.fetchState);return r.useEffect((()=>{l==="In-Progress"&&c.saveState.fetchState==="Completed"&&e("..")}),[l,c.saveState.fetchState,e]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),s.jsx(Qn,{address:d,fieldHelp:c.fieldHelp,addressLabel:c.addressLabel,appContent:n,authParams:o.authParams,dateFormatOptions:c.dateFormatOptions,deleteFileStatusById:o.deleteFileStatusById,filesEndPoint:o.filesEndPoint,isLoading:o.isLoading,isSaving:o.isSaving,localData:c.localData,saveErrorMessage:o.saveErrorMessage,settings:o.settings,updateFileStatusById:o.updateFileStatusById,onBackClick:()=>e(".."),onChange:v=>{i(Ao({localData:v}))},onDeleteFile:o.onDeleteFile,onEditFileName:o.onEditFileName,onOpenAddress:()=>{const v=`/${a}/invoicing/settings/branding/${Se}/`,u=Y(t.state?.pathnameStackToGoBack,t.pathname);e(v,{state:{pathnameStackToGoBack:u}})},onSubmit:()=>i(Lo()),updateFilesEntity:o.updateFilesEntity})]})}function Ya(){const n=L(),e=X("dunning");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(zn,{dunningScheduleActionOptions:e.dunningScheduleActionOptions,isLoading:e.isLoading,isSaving:e.isSaving,saveErrorMessage:e.saveErrorMessage,settings:e.settings,onBackClick:()=>n(".."),onSave:e.onSave})]})}function Xa(){const n=L(),e=X("integrations");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Gn,{integrationsSectionProps:{...e.integrationsSectionProps,onConfigureQBO:()=>n("../quickbooks"),onOpenPaymentDestination:()=>n("../payment-destination")},isLoading:e.isLoading,onBackClick:()=>n("..")})]})}function es(){const n=L(),e=X("payment-destination");return s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:e.isInvoicingPageReady}),s.jsx(Wn,{fieldHelp:e.fieldHelp,isLoading:e.isLoading,isStripeBusy:e.isStripeBusy,saveErrorMessage:e.saveErrorMessage,settings:e.settings,stripeError:e.stripeError,stripeWebhookUrl:e.stripeWebhookUrl,onBackClick:()=>n(".."),onConnectStripe:e.onConnectStripe})]})}const ts=_((function(n){const e=Jt(n);return{accountMappingKindOptions:e.accountMappingKindOptions,fieldHelp:e.fieldHelp,accounts:e.accounts,connection:e.connection,customerMatchingOptions:e.customerMatchingOptions,isBackfilling:e.backfillState.fetchState==="In-Progress",isLoading:e.isLoading,isSaving:e.saveState.fetchState==="In-Progress",isSyncEnabledSaved:e.isSyncEnabledSaved,localData:e.localData,nestedAccountHierarchy:e.nestedAccountHierarchy,retryFetchStateByTaskId:e.retryFetchStateByTaskId,saveErrorMessage:e.saveState.fetchState==="Error"?e.saveState.error?.message:void 0,syncHealth:e.syncHealth,syncStatusOptions:e.syncStatusOptions}}),(function(n){return{onChange:e=>{n(Fo({localData:e}))},onReset:()=>{n(wo())},onRetryTask:e=>{n(Gt(e))},onSave:()=>{p.trackInvoicingActionClick(m.Event.invoicingSettingsSaved,{tab:"quickbooks"}),n($o())},onStartBackfill:e=>{n(zt(e))}}}))(Jn);function ns(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),i=C(Me),{configFetchState:a,settingsFetchState:o}=C(Jt);return r.useEffect((()=>{o!=="Not-Started"&&o!=="Error"||n(Ne())}),[n,o]),r.useEffect((()=>{a==="Not-Started"&&n(le())}),[a,n]),Ze({fetchSyncHealth:!0,loadAccountingPickers:!0}),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage}),s.jsx(ts,{onBackClick:()=>e(".."),onReconnect:()=>{de.init("/connection/auth",i.tenantEmailDomain??t??""),de.handleClick()},onRefresh:()=>n(Wt())})]})}const is={"payment-destination":"payment-destination",general:"branding",integrations:null,dunning:"dunning"};function os(){const n=ft(),e=D(),t=L(),[i,a]=W(),o=X(),{canEnableInvoicing:c,isEnablingInvoicing:d,isInvoicingEnabled:l,isQboConfigured:v,isStripeConnected:u}=C(Qt),g=i.get("tab");return r.useEffect((()=>{if(g==null)return;const S=is[g];a({},{replace:!0}),S!=null&&t(S,{replace:!0})}),[g,t,a]),s.jsxs(s.Fragment,{children:[s.jsx($,{event:m.Event.invoicingSettingsPage,isReady:o.isInvoicingPageReady}),s.jsx(Yn,{analytics:p,integrationsSectionProps:{...o.integrationsSectionProps,onConfigureQBO:()=>t("quickbooks"),onOpenPaymentDestination:()=>t("payment-destination")},isEnablingInvoicing:d,isLoading:o.isLoading,meetingUrl:n("invoicing_settings"),settings:o.settings,onBrandingClick:()=>t("branding"),onDunningClick:()=>t("dunning"),canEnableInvoicing:c,isQboConfigured:v,isStripePaymentsReady:u,onEnableInvoicingClick:l?void 0:()=>{e(Ro())}})]})}function pt(){return s.jsxs(ie,{children:[s.jsx(x,{index:!0,element:s.jsx(os,{})}),s.jsx(x,{path:"payment-destination",element:s.jsx(es,{})}),s.jsx(x,{path:"branding",element:s.jsx(vt,{})}),s.jsx(x,{path:"branding/:addressType",element:s.jsx(vt,{appContent:s.jsx(K,{isSubPage:!0,hideAddressBackButton:!0})})}),s.jsx(x,{path:"integrations",element:s.jsx(Xa,{})}),s.jsx(x,{path:"dunning",element:s.jsx(Ya,{})}),s.jsx(x,{path:"quickbooks",element:s.jsx(ns,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:"..",replace:!0})})]})}function ws(){const n=D(),e=L(),{tenantEmailDomain:t}=R(),{areTenantIdsInSync:i}=T(),{enableState:a,fetchState:o,status:c}=C(Nt),d=St(a.fetchState),l=`/${t}/invoicing`,v=r.useRef(!1),u=C((g=>$e(g).connectionFetchState.fetchState));return r.useEffect((()=>{i&&(o!=="Not-Started"?o!=="Error"||v.current||(v.current=!0,n(le({cacheOverride:!1}))):n(le({cacheOverride:!1})))}),[i,n,o]),r.useEffect((()=>{i&&u==="Not-Started"&&n(Et())}),[i,n,u]),r.useEffect((()=>{d==="In-Progress"&&a.fetchState==="Completed"&&(e(`${l}/catalog`),n(To()))}),[d,a.fetchState,l,n,e]),c==null&&o!=="Error"?s.jsx(Xn,{fetchState:"In-Progress"}):c==="not_started"?s.jsxs(ie,{children:[s.jsx(x,{path:"promo",element:s.jsx(ut,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:`${l}/promo`,replace:!0})})]}):c==="settings"?s.jsxs(ie,{children:[s.jsx(x,{path:"promo",element:s.jsx(ut,{})}),s.jsx(x,{path:"settings/*",element:s.jsx(pt,{})}),s.jsx(x,{path:"*",element:s.jsx(B,{to:`${l}/settings`,replace:!0})})]}):s.jsxs(ie,{children:[s.jsx(x,{path:"/",element:s.jsx(B,{to:"overview",replace:!0})}),s.jsx(x,{path:"overview",element:s.jsx($a,{})}),s.jsx(x,{path:"promo",element:s.jsx(B,{to:`${l}/overview`,replace:!0})}),s.jsx(x,{path:"customers",element:s.jsx(la,{})}),s.jsx(x,{path:"customers/new",element:s.jsx(ca,{})}),s.jsx(x,{path:"customers/new/:addressType",element:s.jsx(K,{})}),s.jsx(x,{path:"customers/:customer_id",element:s.jsx(aa,{})}),s.jsx(x,{path:"customers/:customer_id/:addressType",element:s.jsx(K,{})}),s.jsx(x,{path:"subscriptions",element:s.jsx(za,{})}),s.jsx(x,{path:"subscriptions/new",element:s.jsx(Ka,{})}),s.jsx(x,{path:"subscriptions/new/:addressType",element:s.jsx(K,{})}),s.jsx(x,{path:"subscriptions/:subscription_id",element:s.jsx(Na,{})}),s.jsx(x,{path:"subscriptions/:subscription_id/:addressType",element:s.jsx(K,{})}),s.jsx(x,{path:"invoices",element:s.jsx(Pa,{})}),s.jsx(x,{path:"invoices/create",element:s.jsx(Xo,{})}),s.jsx(x,{path:"invoices/:invoice_id",element:s.jsx(ba,{})}),s.jsx(x,{path:"invoices/:invoice_id/record-payment",element:s.jsx(gt,{})}),s.jsx(x,{path:"invoices/:invoice_id/issue-credit-note",element:s.jsx(La,{})}),s.jsx(x,{path:"payments",element:s.jsx(Fa,{})}),s.jsx(x,{path:"payments/record",element:s.jsx(gt,{})}),s.jsx(x,{path:"payments/:transaction_id",element:s.jsx(Wa,{})}),s.jsx(x,{path:"credits",element:s.jsx(ia,{})}),s.jsx(x,{path:"credits/:credit_note_id",element:s.jsx(ta,{})}),s.jsx(x,{path:"discounts",element:s.jsx(Ia,{})}),s.jsx(x,{path:"discounts/new",element:s.jsx(Jo,{})}),s.jsx(x,{path:"discounts/:coupon_id",element:s.jsx(Sa,{})}),s.jsx(x,{path:"dunning",element:s.jsx(ya,{})}),s.jsx(x,{path:"dunning/:case_id",element:s.jsx(Ea,{})}),s.jsx(x,{path:"catalog",element:s.jsx(Go,{})}),s.jsx(x,{path:"catalog/new",element:s.jsx(Ko,{})}),s.jsx(x,{path:"catalog/:item_id",element:s.jsx(Vo,{})}),s.jsx(x,{path:"settings/*",element:s.jsx(pt,{})}),s.jsx(x,{path:"audit_log",element:s.jsx(_o,{})}),s.jsx(x,{path:"data_import",element:s.jsx(ma,{})}),s.jsx(x,{path:"data_import/migrate",element:s.jsx(pa,{})}),s.jsx(x,{path:"data_import/:sessionId",element:s.jsx(ua,{})}),s.jsx(x,{path:"*",element:s.jsx(M,{})})]})}export{ws as default};
@@ -1,4 +1,4 @@
1
- import{j as a}from"./liveblocks-C_WAhyd7.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-1xnf2RtE.js";import{TI as k,TJ as I,TK as F,IM as D,Iy as M,TL as B,TM as oe,TN as ie,IC as se,gh as j,IJ as le,IG as re}from"./zeni-epic-state-BVNUxmav.js";import{a1 as x,I as r,a2 as de,h as v,W as G,a3 as ce,a4 as me,a5 as pe,p as K,M as ue,y as he,a6 as ge,X as xe,E as fe,f as be,a7 as we,a8 as Se,_ as ye,a9 as ke,aa as Ie,ab as ve,ac as je}from"./index-nXM19luG.js";import{n as m}from"./mui-BAsIRnB1.js";import f from"./NotFoundScreen-BHK2wcy4.js";import{a as $}from"./sentry-lC29HHPj.js";import"./recharts-C2rsrRI6.js";import"./analytics-N153TuwK.js";import"./plaid-dW1_MCaE.js";import"./dnd-DsH8jkrb.js";import"./stripe-cKAAJElX.js";import"./lottie-NIzYzhlS.js";import"./lexical-d2so_3As.js";import"./pdf-BKNPlqtE.js";import"./utils-BBaMea9r.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]="cd55e2b3-8bae-4754-9f0e-ab2af3a3535d",e._sentryDebugIdIdentifier="sentry-dbid-cd55e2b3-8bae-4754-9f0e-ab2af3a3535d")}catch{}})();const $e=m.div`
1
+ import{j as a}from"./liveblocks-C_WAhyd7.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-1xnf2RtE.js";import{TI as k,TJ as I,TK as F,IM as D,Iy as M,TL as B,TM as oe,TN as ie,IC as se,gh as j,IJ as le,IG as re}from"./zeni-epic-state-BVNUxmav.js";import{a1 as x,I as r,a2 as de,h as v,W as G,a3 as ce,a4 as me,a5 as pe,p as K,M as ue,y as he,a6 as ge,X as xe,E as fe,f as be,a7 as we,a8 as Se,_ as ye,a9 as ke,aa as Ie,ab as ve,ac as je}from"./index-DXVI9ztu.js";import{n as m}from"./mui-BAsIRnB1.js";import f from"./NotFoundScreen-BF2gJW91.js";import{a as $}from"./sentry-lC29HHPj.js";import"./recharts-C2rsrRI6.js";import"./analytics-N153TuwK.js";import"./plaid-dW1_MCaE.js";import"./dnd-DsH8jkrb.js";import"./stripe-cKAAJElX.js";import"./lottie-NIzYzhlS.js";import"./lexical-d2so_3As.js";import"./pdf-BKNPlqtE.js";import"./utils-BBaMea9r.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]="cd55e2b3-8bae-4754-9f0e-ab2af3a3535d",e._sentryDebugIdIdentifier="sentry-dbid-cd55e2b3-8bae-4754-9f0e-ab2af3a3535d")}catch{}})();const $e=m.div`
2
2
  display: flex;
3
3
  height: 100%;
4
4
  width: 100%;
@@ -1,4 +1,4 @@
1
- import{j as u}from"./liveblocks-C_WAhyd7.js";import{a as g}from"./sentry-lC29HHPj.js";import{u as U,g as _,h as w,t as A,j as l,N as L}from"./core-1xnf2RtE.js";import{z as r,E as M,G as P,Q as V,h as N,R as G,Y as R,_ as Q,S as W}from"./index-nXM19luG.js";import{fE as Y,Tb as $,TE as q,Tv as B,gh as H,gj as J,TA as K,gT as X,di as Z,TF as ee,TG as te}from"./zeni-epic-state-BVNUxmav.js";import{n as ne}from"./mui-BAsIRnB1.js";import{u as se}from"./useDeviceId-BX84j5B2.js";import{f as ie}from"./analyticsHelper-Cw60VlOq.js";import{t as ae}from"./getLocaleForTenant-Cb4ANH4Q.js";import"./recharts-C2rsrRI6.js";import"./analytics-N153TuwK.js";import"./plaid-dW1_MCaE.js";import"./dnd-DsH8jkrb.js";import"./stripe-cKAAJElX.js";import"./lottie-NIzYzhlS.js";import"./lexical-d2so_3As.js";import"./pdf-BKNPlqtE.js";import"./utils-BBaMea9r.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},i=new t.Error().stack;i&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[i]="de970221-83ff-468d-950b-1500220dd0ef",t._sentryDebugIdIdentifier="sentry-dbid-de970221-83ff-468d-950b-1500220dd0ef")}catch{}})();const E=(t,i)=>t!=null&&t.length>0&&i==="magic_links";function Ee(){const t=U(),i=_(),m=w(),[k]=A(),n=k.get("token"),p=k.get("stytch_token_type"),f=r.getMagicLinkCodeVerifier(),a=se(),{otpChallenge:d,twoFAPhoneNumber:x,magicLinkEmail:c,verifyDeviceFetchState:z,resendVerifyDeviceOTPFetchState:C}=l((e=>e.tenantState)),S=l((e=>e.tenantState.fetchState)),y=l((e=>e.tenantState.activeTenantFetchState.fetchState)),h=l((e=>e.tenantState.signInState)),I=l((e=>e.tenantState.magicLinkSignInFetchState.fetchState)),s=l((e=>e.tenantState.loggedInUser)),o=l((e=>Y(e))),b=l((e=>$(e))),D=r.getSignedInUser(),T=M().mode;g.useEffect((()=>{s?.zeniSessionId==null&&n!=null&&E(n,p)&&a!=null&&f!=null&&(r.saveMagicLinkTriggered(n),t(q(n,a,f)))}),[n,p,t,a,f,s?.zeniSessionId]),g.useEffect((()=>{h!=="In-Progress"||S!=="Completed"&&y!=="Completed"||s?.zeniSessionId==null||o==null||(n!=null&&r.saveLastUsedMagicLinkToken(n),r.saveSignedInUserWithSession(s,s.zeniSessionId),r.saveSignedInUserTenants(B(b.tenantsInOrder),s.zeniSessionId),H(s.userId,s.zeniSessionId,o.tenantId),t(J(o.tenantId)),r.saveActiveTenantDomainForUser(o.tenantEmailDomain),t(K("Completed")),P.updateAppLocaleID(ae(o)),ie(s,o,T,void 0,b.tenantsInOrder),X().then((()=>{const e=W();e!=null&&V(e)})),setTimeout((()=>{N.trackLogin(G.Event.loginSuccess,"email",Z(o.productSettings))}),2e3))}),[h,S,y,s,o,b,T,i.state,t]);const j=g.useCallback((()=>{m("/signin/auth")}),[m]),F=g.useCallback((()=>{a!=null&&d!=null&&c!=null&&t(ee(a,c,d))}),[a,d,t,c]),O=g.useCallback((e=>{a!=null&&n!=null&&c!=null&&d!=null&&t(te(e,a,c,d))}),[a,n,t,c,d]);if(I==="Completed"&&d!=null)return u.jsx(R,{phoneNumber:x,verifyOtpFetchState:z.fetchState,resendVerifyDeviceOTPFetchState:C,onResendOtp:F,onVerifyOtp:O,onCancelVerifyDevice:j});if(h==="In-Progress"&&S==="Completed"&&s?.zeniSessionId!=null&&o!=null||D!=null){const e=i.state?.origin??"/";return u.jsx(L,{to:e,state:{...i.state,origin:""}})}if(!E(n,p)||f==null||I==="Error"){const e=i.state?.origin??"/",v=n!=null&&r.getLastUsedMagicLinkToken()===n;return u.jsx(L,{to:e,state:{...i.state,origin:"",magicLinkAlreadyUsed:v,magicLinkExpired:!v&&(r.isMagicLinkTriggered(n??"")||I==="Error"&&s?.zeniSessionId==null)}})}return u.jsx(oe,{"data-testid":"smooth-loader",children:u.jsx(Q,{size:"ExtraLarge",start:!0})})}const oe=ne.div`
1
+ import{j as u}from"./liveblocks-C_WAhyd7.js";import{a as g}from"./sentry-lC29HHPj.js";import{u as U,g as _,h as w,t as A,j as l,N as L}from"./core-1xnf2RtE.js";import{z as r,E as M,G as P,Q as V,h as N,R as G,Y as R,_ as Q,S as W}from"./index-DXVI9ztu.js";import{fE as Y,Tb as $,TE as q,Tv as B,gh as H,gj as J,TA as K,gT as X,di as Z,TF as ee,TG as te}from"./zeni-epic-state-BVNUxmav.js";import{n as ne}from"./mui-BAsIRnB1.js";import{u as se}from"./useDeviceId-BX84j5B2.js";import{f as ie}from"./analyticsHelper-BSm7IqEZ.js";import{t as ae}from"./getLocaleForTenant-Ct5cBG_c.js";import"./recharts-C2rsrRI6.js";import"./analytics-N153TuwK.js";import"./plaid-dW1_MCaE.js";import"./dnd-DsH8jkrb.js";import"./stripe-cKAAJElX.js";import"./lottie-NIzYzhlS.js";import"./lexical-d2so_3As.js";import"./pdf-BKNPlqtE.js";import"./utils-BBaMea9r.js";(function(){try{var t=typeof window<"u"?window:typeof global<"u"?global:typeof globalThis<"u"?globalThis:typeof self<"u"?self:{},i=new t.Error().stack;i&&(t._sentryDebugIds=t._sentryDebugIds||{},t._sentryDebugIds[i]="de970221-83ff-468d-950b-1500220dd0ef",t._sentryDebugIdIdentifier="sentry-dbid-de970221-83ff-468d-950b-1500220dd0ef")}catch{}})();const E=(t,i)=>t!=null&&t.length>0&&i==="magic_links";function Ee(){const t=U(),i=_(),m=w(),[k]=A(),n=k.get("token"),p=k.get("stytch_token_type"),f=r.getMagicLinkCodeVerifier(),a=se(),{otpChallenge:d,twoFAPhoneNumber:x,magicLinkEmail:c,verifyDeviceFetchState:z,resendVerifyDeviceOTPFetchState:C}=l((e=>e.tenantState)),S=l((e=>e.tenantState.fetchState)),y=l((e=>e.tenantState.activeTenantFetchState.fetchState)),h=l((e=>e.tenantState.signInState)),I=l((e=>e.tenantState.magicLinkSignInFetchState.fetchState)),s=l((e=>e.tenantState.loggedInUser)),o=l((e=>Y(e))),b=l((e=>$(e))),D=r.getSignedInUser(),T=M().mode;g.useEffect((()=>{s?.zeniSessionId==null&&n!=null&&E(n,p)&&a!=null&&f!=null&&(r.saveMagicLinkTriggered(n),t(q(n,a,f)))}),[n,p,t,a,f,s?.zeniSessionId]),g.useEffect((()=>{h!=="In-Progress"||S!=="Completed"&&y!=="Completed"||s?.zeniSessionId==null||o==null||(n!=null&&r.saveLastUsedMagicLinkToken(n),r.saveSignedInUserWithSession(s,s.zeniSessionId),r.saveSignedInUserTenants(B(b.tenantsInOrder),s.zeniSessionId),H(s.userId,s.zeniSessionId,o.tenantId),t(J(o.tenantId)),r.saveActiveTenantDomainForUser(o.tenantEmailDomain),t(K("Completed")),P.updateAppLocaleID(ae(o)),ie(s,o,T,void 0,b.tenantsInOrder),X().then((()=>{const e=W();e!=null&&V(e)})),setTimeout((()=>{N.trackLogin(G.Event.loginSuccess,"email",Z(o.productSettings))}),2e3))}),[h,S,y,s,o,b,T,i.state,t]);const j=g.useCallback((()=>{m("/signin/auth")}),[m]),F=g.useCallback((()=>{a!=null&&d!=null&&c!=null&&t(ee(a,c,d))}),[a,d,t,c]),O=g.useCallback((e=>{a!=null&&n!=null&&c!=null&&d!=null&&t(te(e,a,c,d))}),[a,n,t,c,d]);if(I==="Completed"&&d!=null)return u.jsx(R,{phoneNumber:x,verifyOtpFetchState:z.fetchState,resendVerifyDeviceOTPFetchState:C,onResendOtp:F,onVerifyOtp:O,onCancelVerifyDevice:j});if(h==="In-Progress"&&S==="Completed"&&s?.zeniSessionId!=null&&o!=null||D!=null){const e=i.state?.origin??"/";return u.jsx(L,{to:e,state:{...i.state,origin:""}})}if(!E(n,p)||f==null||I==="Error"){const e=i.state?.origin??"/",v=n!=null&&r.getLastUsedMagicLinkToken()===n;return u.jsx(L,{to:e,state:{...i.state,origin:"",magicLinkAlreadyUsed:v,magicLinkExpired:!v&&(r.isMagicLinkTriggered(n??"")||I==="Error"&&s?.zeniSessionId==null)}})}return u.jsx(oe,{"data-testid":"smooth-loader",children:u.jsx(Q,{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 B}from"./liveblocks-C_WAhyd7.js";import{a as m}from"./sentry-lC29HHPj.js";import{u as te,j as t,i as $e,g as Ge,h as Me,q as _}from"./core-1xnf2RtE.js";import{fE as ne,Tc as xe,Td as se,g8 as Ne,fD as Pe,Tm as Re,Tf as Ve,Tg as je,p_ as Le,gl as Oe,Tj as b,To as Ue,Tp as K,gm as Ze,Tq as ze,Dt as qe,h0 as He,cV as Ye,Tr as Je,g7 as We,gn as Xe}from"./zeni-epic-state-BVNUxmav.js";import{w as Ke,i as Qe,X as ea,M as aa,c as ta,f as na,u as sa,y as c,g as oa,e as ia,z as ra,d as da,j as ca,k as la,r as ua,n as ma,o as Q,L as fa,D as ha,F as ba,p as S,h as ee,v as pa,J as ae,A as ga,B as Sa}from"./index-nXM19luG.js";import{D as Ta}from"./mui-BAsIRnB1.js";import{u as ka}from"./InboxNotificationsProvider-BU6hQETc.js";import{u as Ea}from"./useTaskManagerAccess-CCKD6ndI.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]="071968c8-78b6-4a9d-a069-f1c66b70593f",l._sentryDebugIdIdentifier="sentry-dbid-071968c8-78b6-4a9d-a069-f1c66b70593f")}catch{}})();const Ca=Ke((({isAppContentDrawerOpen:l,handleDrawerToggle:i})=>{const{tenantEmailDomain:s}=$e(),a=Ge(),T=ea(),n=Me(),F=Ne(),r=te(),{useFeatureGate:d}=aa(),p=ta(),{isTaskManagerAccessEnabled:k}=Ea(p),o=t((e=>ne(e))),oe=o.masterTOSInfo?.isMasterTOSAccepted??!1,$=t((e=>Pe(e))),{status:ie}=t(Re),G=$.uiState.currentChatSessionId,E=na(),{setLoading:re}=sa(),[w,M]=m.useState(void 0),A=_("/:tenantEmailDomain/dashboard")!==null,x=_("/:tenantEmailDomain/reports")!==null,f=_("/:tenantEmailDomain/onboarding/*")!==null,de=!!o.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:ce}=d(c.isChargeCardFeatureEnabled),{isFeatureEnabled:N}=d(c.isDebitCardFeatureEnabled),le=oa(o,ce,N),{isFeatureEnabled:ue}=d(c.isSettingsFeatureEnabled),P=t((e=>Ve(e))),{isFeatureEnabled:C}=d(c.isReferralFeatureEnabled),v=t((e=>je(e)));m.useEffect((()=>{E&&C&&!f&&v.fetchState==="Not-Started"&&r(Le(!0))}),[E,C,v.fetchState,f]);const D=t((e=>e.tenantState)),me=t((e=>D.fetchState==="Completed"?Oe(e):[])),g=t((e=>e.expenseAutomationViewState.selectedPeriodByTenantId)),{isFeatureEnabled:fe}=d(c.isApAgingFeatureEnabled),{isFeatureEnabled:he}=d(c.isArAgingFeatureEnabled),R=ia(),{isFeatureEnabled:be}=d(c.isDashboardSidebarHalloweenAnimationEnabled),{isFeatureEnabled:pe}=d(c.isDashboardSidebarThanksGivingAnimationEnabled),{isFeatureEnabled:ge}=d(c.isDashboardSidebarChristmasAnimationEnabled),{isFeatureEnabled:Se}=d(c.isDashboardSidebarNewYearAnimationEnabled),Te=o.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",ke=t((e=>b(e).totalUnreadCount)),Ee=t((e=>b(e).reducedFetchCountState)),V=t((e=>b(e).notificationDetailsByTab.tasks.uiState.unreadCount)),j=t((e=>b(e).notificationDetailsByTab.comments.uiState.unreadCount)),L=t((e=>b(e).notificationDetailsByTab.tasks.fetchCountState)),I=t((e=>b(e).notificationDetailsByTab.comments.fetchCountState)),{inboxNotifications:O,isLoading:U,isFetchingMore:Z,hasFetchedAll:z,fetchMore:Ce}=ka();m.useEffect((()=>{const e=setTimeout((()=>Ce?.()),0);return()=>clearTimeout(e)})),m.useEffect((()=>{if(U===!1&&Z===!1&&z===!0)if(o?.companyId!=null&&O!=null){const e=`dashboard_${o.companyId}`;M(O.filter((u=>u.roomId===e&&u.readAt==null)).length)}else M(0)}),[U,Z,z]),m.useEffect((()=>{E&&k&&!f&&L.fetchState==="Not-Started"&&F.tenantId!=null&&r(Ue("task_manager","dashboard"))}),[E,k,f,L.fetchState,F.tenantId,r]),m.useEffect((()=>{f||I.fetchState!=="Not-Started"||r(K({fetchCountState:{fetchState:"In-Progress",error:void 0}},"comments"))}),[f,I.fetchState,r]),m.useEffect((()=>{w!=null&&I.fetchState==="In-Progress"&&(r(K({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),r(se({unreadCount:w},"comments")))}),[w,I.fetchState]);const Ie={fetchStatus:Ee,count:ke},q=s!=null?ra.getSignedInUserTenant(s):null,H=t((e=>q?.tenantId!=null?Ze(e,q.tenantId):void 0)),h=[];fe===!1&&h.push("accounts_payable_aging"),he===!1&&h.push("accounts_receivable_aging"),h.push("zeni_accounts_promo_card","treasury_promo_card"),C===!1&&h.push("rewards_card"),R===!1&&h.push("expense_automation_card");const Y=t((e=>ze(e,h).fetchState)),J=t((e=>qe(e).fetchState)),ye=A&&(Y==="Completed"||Y==="Error")||x&&(J==="Completed"||J==="Error")||!A&&!x?void 0:"disabled",we=m.useMemo((()=>He(o.userRole)),[o.userRole]),Ae=Ye(we),ve=o?.rewardsLastViewedTime==null,De=p?.userEmail!=null&&P.fetchState==="Completed"&&Je(P.notificationSettings,p.userEmail,N,o,k),W=da(),_e=W&&ca(a);return B.jsx(Ta,{container:window.document.body,variant:"temporary",open:l,onClose:()=>i(!1),PaperProps:{sx:{width:240,zIndex:8,borderRight:"none",backgroundImage:"none"}},ModalProps:{keepMounted:!0},children:B.jsx(la,{signedInUser:p,currentTenantId:D.currentTenantId??"",tenants:D.fetchState==="Completed"?me:H!=null?[H]:[],currentTenant:o,isTenantDropdownDisabled:ye,isSettings:Q(a),isInvoicing:ma(a)&&ie==="completed",isSettingsFeatureEnabled:ue,isVendorsTabVisible:Ae,isZeniAccountEnabled:de,isChargeCardEnabled:le,isTreasuryEnabled:Te,isNotificationsTabVisible:De,notificationCountDetails:Ie,isExpenseAutomationEnabledForUser:R,selectedMenu:ua(a),rewardsConfiguration:{isRewardsTabVisible:C,isRewardsAnimated:ve,rewardsPlan:v.rewardsPlan},isAiCfoAccessEnabled:W,onNotificationIconClick:()=>{i(!1);let e=V===0&&j>0?"notifications/comments":"notifications/tasks";Q(a)&&(e=V===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),X=e.type,Be=ae(X)&&X!=="command_center";if(ae(e.type)&&g[o.tenantId]!=null&&ee.trackMonthEndCloseClicked(g[o.tenantId].month,g[o.tenantId].year,"Sidebar"),Be&&g[o.tenantId]!=null){const y=g[o.tenantId];return void n(`/${s}/month_end_close_checks/review/${e.type}/${y.month}-${y.year}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})}const Fe=ga(e.type);Sa(e.type)?(G!=null&&r(Xe()),n(`/${s}/ai-cfo/${e.type}`,{state:{pathnameStackToGoBack:u.slice(0,-1),referrer:"Sidebar"}})):n(`/${s}/${Fe}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})},handleMyProfileClick:()=>{i(!1),n(`/${s}/settings/my_profile`)},handleReferralsClick:()=>{i(!1),n(`/${s}/rewards`)},handleBackClick:()=>{n(`/${s}/dashboard`)},handleTenantSelect:e=>{re(fa.TENANT_SWITCHING),i(!1),ha({dispatch:r,navigate:n,pathToNavigate:ba(e.tenantEmailDomain,a),selectedTenant:e,signedInUser:p})},onZeniLogoClick:()=>{T.toggle()},isAiCfo:_e,aiCfoView:$,isOnDashboard:A,updateCurrentChatSessionId:e=>{r(We({sessionId:e,agentId:"controller"})),n(`/${s}/ai-cfo/${e}`,{state:{...a.state}})},halloweenAnimationEnabled:be,isTaskManagerAccessEnabled:k,thanksGivingAnimationEnabled:pe,christmasAnimationEnabled:ge,newYearAnimationEnabled:Se})})})),Fa=l=>{const i=te(),s=t((T=>ne(T))),a={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(T,n)=>{Qe(n)&&xe(n.mode)==="dashboard"&&i(se({unreadCount:n.data.unread},"tasks"))}};return B.jsx(Ca,{...l,...a})};export{Fa as M};
1
+ import{j as B}from"./liveblocks-C_WAhyd7.js";import{a as m}from"./sentry-lC29HHPj.js";import{u as te,j as t,i as $e,g as Ge,h as Me,q as _}from"./core-1xnf2RtE.js";import{fE as ne,Tc as xe,Td as se,g8 as Ne,fD as Pe,Tm as Re,Tf as Ve,Tg as je,p_ as Le,gl as Oe,Tj as b,To as Ue,Tp as K,gm as Ze,Tq as ze,Dt as qe,h0 as He,cV as Ye,Tr as Je,g7 as We,gn as Xe}from"./zeni-epic-state-BVNUxmav.js";import{w as Ke,i as Qe,X as ea,M as aa,c as ta,f as na,u as sa,y as c,g as oa,e as ia,z as ra,d as da,j as ca,k as la,r as ua,n as ma,o as Q,L as fa,D as ha,F as ba,p as S,h as ee,v as pa,J as ae,A as ga,B as Sa}from"./index-DXVI9ztu.js";import{D as Ta}from"./mui-BAsIRnB1.js";import{u as ka}from"./InboxNotificationsProvider-BU6hQETc.js";import{u as Ea}from"./useTaskManagerAccess-B7YJLgDK.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]="071968c8-78b6-4a9d-a069-f1c66b70593f",l._sentryDebugIdIdentifier="sentry-dbid-071968c8-78b6-4a9d-a069-f1c66b70593f")}catch{}})();const Ca=Ke((({isAppContentDrawerOpen:l,handleDrawerToggle:i})=>{const{tenantEmailDomain:s}=$e(),a=Ge(),T=ea(),n=Me(),F=Ne(),r=te(),{useFeatureGate:d}=aa(),p=ta(),{isTaskManagerAccessEnabled:k}=Ea(p),o=t((e=>ne(e))),oe=o.masterTOSInfo?.isMasterTOSAccepted??!1,$=t((e=>Pe(e))),{status:ie}=t(Re),G=$.uiState.currentChatSessionId,E=na(),{setLoading:re}=sa(),[w,M]=m.useState(void 0),A=_("/:tenantEmailDomain/dashboard")!==null,x=_("/:tenantEmailDomain/reports")!==null,f=_("/:tenantEmailDomain/onboarding/*")!==null,de=!!o.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:ce}=d(c.isChargeCardFeatureEnabled),{isFeatureEnabled:N}=d(c.isDebitCardFeatureEnabled),le=oa(o,ce,N),{isFeatureEnabled:ue}=d(c.isSettingsFeatureEnabled),P=t((e=>Ve(e))),{isFeatureEnabled:C}=d(c.isReferralFeatureEnabled),v=t((e=>je(e)));m.useEffect((()=>{E&&C&&!f&&v.fetchState==="Not-Started"&&r(Le(!0))}),[E,C,v.fetchState,f]);const D=t((e=>e.tenantState)),me=t((e=>D.fetchState==="Completed"?Oe(e):[])),g=t((e=>e.expenseAutomationViewState.selectedPeriodByTenantId)),{isFeatureEnabled:fe}=d(c.isApAgingFeatureEnabled),{isFeatureEnabled:he}=d(c.isArAgingFeatureEnabled),R=ia(),{isFeatureEnabled:be}=d(c.isDashboardSidebarHalloweenAnimationEnabled),{isFeatureEnabled:pe}=d(c.isDashboardSidebarThanksGivingAnimationEnabled),{isFeatureEnabled:ge}=d(c.isDashboardSidebarChristmasAnimationEnabled),{isFeatureEnabled:Se}=d(c.isDashboardSidebarNewYearAnimationEnabled),Te=o.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",ke=t((e=>b(e).totalUnreadCount)),Ee=t((e=>b(e).reducedFetchCountState)),V=t((e=>b(e).notificationDetailsByTab.tasks.uiState.unreadCount)),j=t((e=>b(e).notificationDetailsByTab.comments.uiState.unreadCount)),L=t((e=>b(e).notificationDetailsByTab.tasks.fetchCountState)),I=t((e=>b(e).notificationDetailsByTab.comments.fetchCountState)),{inboxNotifications:O,isLoading:U,isFetchingMore:Z,hasFetchedAll:z,fetchMore:Ce}=ka();m.useEffect((()=>{const e=setTimeout((()=>Ce?.()),0);return()=>clearTimeout(e)})),m.useEffect((()=>{if(U===!1&&Z===!1&&z===!0)if(o?.companyId!=null&&O!=null){const e=`dashboard_${o.companyId}`;M(O.filter((u=>u.roomId===e&&u.readAt==null)).length)}else M(0)}),[U,Z,z]),m.useEffect((()=>{E&&k&&!f&&L.fetchState==="Not-Started"&&F.tenantId!=null&&r(Ue("task_manager","dashboard"))}),[E,k,f,L.fetchState,F.tenantId,r]),m.useEffect((()=>{f||I.fetchState!=="Not-Started"||r(K({fetchCountState:{fetchState:"In-Progress",error:void 0}},"comments"))}),[f,I.fetchState,r]),m.useEffect((()=>{w!=null&&I.fetchState==="In-Progress"&&(r(K({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),r(se({unreadCount:w},"comments")))}),[w,I.fetchState]);const Ie={fetchStatus:Ee,count:ke},q=s!=null?ra.getSignedInUserTenant(s):null,H=t((e=>q?.tenantId!=null?Ze(e,q.tenantId):void 0)),h=[];fe===!1&&h.push("accounts_payable_aging"),he===!1&&h.push("accounts_receivable_aging"),h.push("zeni_accounts_promo_card","treasury_promo_card"),C===!1&&h.push("rewards_card"),R===!1&&h.push("expense_automation_card");const Y=t((e=>ze(e,h).fetchState)),J=t((e=>qe(e).fetchState)),ye=A&&(Y==="Completed"||Y==="Error")||x&&(J==="Completed"||J==="Error")||!A&&!x?void 0:"disabled",we=m.useMemo((()=>He(o.userRole)),[o.userRole]),Ae=Ye(we),ve=o?.rewardsLastViewedTime==null,De=p?.userEmail!=null&&P.fetchState==="Completed"&&Je(P.notificationSettings,p.userEmail,N,o,k),W=da(),_e=W&&ca(a);return B.jsx(Ta,{container:window.document.body,variant:"temporary",open:l,onClose:()=>i(!1),PaperProps:{sx:{width:240,zIndex:8,borderRight:"none",backgroundImage:"none"}},ModalProps:{keepMounted:!0},children:B.jsx(la,{signedInUser:p,currentTenantId:D.currentTenantId??"",tenants:D.fetchState==="Completed"?me:H!=null?[H]:[],currentTenant:o,isTenantDropdownDisabled:ye,isSettings:Q(a),isInvoicing:ma(a)&&ie==="completed",isSettingsFeatureEnabled:ue,isVendorsTabVisible:Ae,isZeniAccountEnabled:de,isChargeCardEnabled:le,isTreasuryEnabled:Te,isNotificationsTabVisible:De,notificationCountDetails:Ie,isExpenseAutomationEnabledForUser:R,selectedMenu:ua(a),rewardsConfiguration:{isRewardsTabVisible:C,isRewardsAnimated:ve,rewardsPlan:v.rewardsPlan},isAiCfoAccessEnabled:W,onNotificationIconClick:()=>{i(!1);let e=V===0&&j>0?"notifications/comments":"notifications/tasks";Q(a)&&(e=V===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),X=e.type,Be=ae(X)&&X!=="command_center";if(ae(e.type)&&g[o.tenantId]!=null&&ee.trackMonthEndCloseClicked(g[o.tenantId].month,g[o.tenantId].year,"Sidebar"),Be&&g[o.tenantId]!=null){const y=g[o.tenantId];return void n(`/${s}/month_end_close_checks/review/${e.type}/${y.month}-${y.year}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})}const Fe=ga(e.type);Sa(e.type)?(G!=null&&r(Xe()),n(`/${s}/ai-cfo/${e.type}`,{state:{pathnameStackToGoBack:u.slice(0,-1),referrer:"Sidebar"}})):n(`/${s}/${Fe}`,{state:{pathnameStackToGoBack:u,referrer:"Sidebar"}})},handleMyProfileClick:()=>{i(!1),n(`/${s}/settings/my_profile`)},handleReferralsClick:()=>{i(!1),n(`/${s}/rewards`)},handleBackClick:()=>{n(`/${s}/dashboard`)},handleTenantSelect:e=>{re(fa.TENANT_SWITCHING),i(!1),ha({dispatch:r,navigate:n,pathToNavigate:ba(e.tenantEmailDomain,a),selectedTenant:e,signedInUser:p})},onZeniLogoClick:()=>{T.toggle()},isAiCfo:_e,aiCfoView:$,isOnDashboard:A,updateCurrentChatSessionId:e=>{r(We({sessionId:e,agentId:"controller"})),n(`/${s}/ai-cfo/${e}`,{state:{...a.state}})},halloweenAnimationEnabled:be,isTaskManagerAccessEnabled:k,thanksGivingAnimationEnabled:pe,christmasAnimationEnabled:ge,newYearAnimationEnabled:Se})})})),Fa=l=>{const i=te(),s=t((T=>ne(T))),a={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(T,n)=>{Qe(n)&&xe(n.mode)==="dashboard"&&i(se({unreadCount:n.data.unread},"tasks"))}};return B.jsx(Ca,{...l,...a})};export{Fa as M};
@@ -1 +1 @@
1
- import{j as e}from"./liveblocks-C_WAhyd7.js";import{h as r,l as i}from"./core-1xnf2RtE.js";import{am as n}from"./index-nXM19luG.js";import"./mui-BAsIRnB1.js";import"./sentry-lC29HHPj.js";import"./zeni-epic-state-BVNUxmav.js";import"./recharts-C2rsrRI6.js";import"./analytics-N153TuwK.js";import"./plaid-dW1_MCaE.js";import"./dnd-DsH8jkrb.js";import"./stripe-cKAAJElX.js";import"./lottie-NIzYzhlS.js";import"./lexical-d2so_3As.js";import"./pdf-BKNPlqtE.js";import"./utils-BBaMea9r.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
+ import{j as e}from"./liveblocks-C_WAhyd7.js";import{h as r,l as i}from"./core-1xnf2RtE.js";import{am as n}from"./index-DXVI9ztu.js";import"./mui-BAsIRnB1.js";import"./sentry-lC29HHPj.js";import"./zeni-epic-state-BVNUxmav.js";import"./recharts-C2rsrRI6.js";import"./analytics-N153TuwK.js";import"./plaid-dW1_MCaE.js";import"./dnd-DsH8jkrb.js";import"./stripe-cKAAJElX.js";import"./lottie-NIzYzhlS.js";import"./lexical-d2so_3As.js";import"./pdf-BKNPlqtE.js";import"./utils-BBaMea9r.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{m as mt,a as lt,n as ft,j as N}from"./liveblocks-C_WAhyd7.js";import ut from"./NotFoundScreen-BHK2wcy4.js";import{a as k}from"./sentry-lC29HHPj.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-1xnf2RtE.js";import{cA as Tt,Tf as X,fE as Y,h0 as It,Tj as S,a0d as K,Tp as m,Td as A,zL as $,Fr as Ct,a0e as yt,Tc as At,Tr as Et,zQ as _t,a0f as F,br as j,gg as x,zU as Q,a0g as Nt,cM as Bt,cF as wt}from"./zeni-epic-state-BVNUxmav.js";import{aq as xt,c as vt,M as Dt,y as Mt,as as Rt,dM as Pt,p as B,dN as Ut,w as Gt,dO as Ft,i as jt,a4 as $t}from"./index-nXM19luG.js";import"./mui-BAsIRnB1.js";import{u as Vt}from"./useAskAiCfoHostNavButtonProps-CRADLi0_.js";import{u as Lt}from"./useTaskManagerAccess-CCKD6ndI.js";import"./recharts-C2rsrRI6.js";import"./analytics-N153TuwK.js";import"./plaid-dW1_MCaE.js";import"./dnd-DsH8jkrb.js";import"./stripe-cKAAJElX.js";import"./lottie-NIzYzhlS.js";import"./lexical-d2so_3As.js";import"./pdf-BKNPlqtE.js";import"./utils-BBaMea9r.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]="4718f262-37d1-40dc-ab63-e504e7febb2a",t._sentryDebugIdIdentifier="sentry-dbid-4718f262-37d1-40dc-ab63-e504e7febb2a")}catch{}})();const qt=(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=X(t),{signedInUser:h,isDebitCardFeatureEnabled:g,isTaskManagerAccessEnabled:c}=l,o=S(t),f=Y(t),{currentTab:T}=o;return{notificationView:o,isNotificationSettingsVisible:h.userEmail!=null&&Et(n.notificationSettings,h.userEmail,g,f,c),isDisabled:o.notificationDetailsByTab[T].fetchState==="In-Progress"?"disabled":void 0}}),(function(t,l){const{location:n,tenantEmailDomain:h,loggedInUserRoleMap:g,externalNotificationsUnreadCount:c,allUnreadCommentsNotificationIds:o,navigate:f,markInboxNotificationAsRead:T,fetchMoreCommentsNotifications:D}=l;return{onNotificationClick:(a,s,d,r)=>{if(r==="task_deleted"){const i=`/${h}/tasks`,I=B(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:I,message:"triggerBackClick"}})}else{const i=`/${h}/tasks/${s}`,I=B(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:I,message:"triggerBackClick"}})}d==="unread"&&t(Q("task_manager","read",[a],!1))},onCommentNotificationClick:(a,s,d)=>{const r=s.toString().split(`/${h}/`);if(r[1]!=null){d==="unread"&&(T(a),t(F([a],j())));let i=`/${h}/${r[1]}`;const I=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:I,message:"triggerBackClick"}})}},onUpdateNotificationViewUIState:(a,s)=>{t(A(a,s))},onUpdateNotificationTabState:(a,s)=>{t(m(a,s))},onUpdateNotificationViewCurrentTabAndSubTab:(a,s)=>{t(K(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($("task_manager","dashboard",d))}else D?.()},onUpdateNotificationStatus:(a,s,d,r)=>{a==="tasks"?t(Q("task_manager",d,r)):(t(m({markAsReadState:{fetchState:"In-Progress",error:void 0}},"comments")),Promise.all(r.map((i=>{d==="read"&&(T(i),t(F([i],j())))}))).then((()=>{t(m({markAsReadState:{fetchState:"Completed",error:void 0},selectedNotificationIds:[]},"comments")),t(A({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")),qt(o,T).then((()=>{t(F(o,j())),t(m({markAsAllReadState:{fetchState:"Completed",error:void 0}},"comments")),t(A({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=$t(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}})}}}))(Gt(Ft)),Wt=()=>{const t=ht(),l=pt(),{tenantEmailDomain:n,selectedTab:h}=kt(),{areTenantIdsInSync:g}=xt(),c=Tt(h??""),o=gt(),f=vt(),[T,D]=k.useState(!1),a=b((e=>X(e))),s=b((e=>Y(e))),{useFeatureGate:d}=Dt(),{isFeatureEnabled:r}=d(Mt.isDebitCardFeatureEnabled),{isAiCfoAccessEnabled:i,onAskAiCfoClick:I}=Vt({mobileExploreReferrer:"Notifications"});Rt({isDataReady:!0});const Z=It(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)),L=b((e=>S(e).currentTab)),M=b((e=>S(e).currentSubTab)),tt=b((e=>S(e).notificationDetailsByTab.comments.fetchCountState)),R=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=Pt().allUsers,{inboxNotifications:w,isLoading:E,hasFetchedAll:C,isFetchingMore:P,fetchMore:ot}=mt(),{threads:q,isLoading:z,fetchMore:W,isFetchingMore:H,hasFetchedAll:J}=lt({query:{metadata:{companyId:s.companyId,application:"dashboard"}}});k.useEffect((()=>{if(L!==c&&c!=null&&o(K(c)),c==null){const e=`../${L}`,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(E===!1&&C===!0&&s?.companyId!=null&&w!=null){const e=`dashboard_${s.companyId}`,p=w.filter((y=>y.roomId===e&&y.readAt==null)).length;o(m({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),o(A({unreadCount:p},"comments"))}}),[E,C]),k.useEffect((()=>{V!=="In-Progress"&&g&&o($("task_manager","dashboard",["read","unread"]))}),[g]),k.useEffect((()=>{const e=setTimeout((()=>ot?.()),0);return()=>clearTimeout(e)}));const U=E||P===!0||C!==!0||E||P===!0||C!==!0;k.useEffect((()=>{U&&R!=="In-Progress"?o(m({fetchState:"In-Progress",error:void 0},"comments")):U||R!=="In-Progress"||o(m({fetchState:"Completed",error:void 0},"comments"))}),[U,R]),k.useEffect((()=>{o(A({hasMore:C!==!0},"comments"))}),[C]),k.useEffect((()=>{a.fetchState!=="In-Progress"&&a.fetchState!=="Completed"&&T===!1&&(D(!0),o(Ct()))}),[a.fetchState]),k.useEffect((()=>{if(E===!1&&z===!1&&w!=null&&q!=null){const e=`dashboard_${s.companyId}`,p=w.filter((u=>u.roomId===e)).filter((u=>Ut(u.kind))),y=p.filter((u=>u.readAt==null)),_=p.map((u=>u.id)),ct=p.map((u=>{const G=q.find((dt=>{return dt.id===((v=u).kind==="thread"?v.threadId:"subjectId"in v?v.subjectId:void 0);var v}));return G!=null?{inboxNotification:{...u,threadId:G.id},thread:G}:(H||J===!0||W==null||W(),null)})).filter((u=>u!=null));o(m({allNotificationsIds:_},"comments")),o(A({totalCount:_.length,unreadCount:y.length},"comments")),o(yt(ct))}}),[E,P,H,C,J,z,w?.length]);const nt={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(e,p)=>{if(jt(p)){const y=At(p.mode);if(y==="dashboard"&&o(A({unreadCount:p.data.unread},"tasks")),V!=="In-Progress"){const _=[];M==="all"?_.push("read","unread"):M!=="mentions"&&_.push(M),o($("task_manager",y,_,!0))}}}},it=ft(),{isTaskManagerAccessEnabled:rt}=Lt(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:I,...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
+ import{m as mt,a as lt,n as ft,j as N}from"./liveblocks-C_WAhyd7.js";import ut from"./NotFoundScreen-BF2gJW91.js";import{a as k}from"./sentry-lC29HHPj.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-1xnf2RtE.js";import{cA as Tt,Tf as X,fE as Y,h0 as It,Tj as S,a0d as K,Tp as m,Td as A,zL as $,Fr as Ct,a0e as yt,Tc as At,Tr as Et,zQ as _t,a0f as F,br as j,gg as x,zU as Q,a0g as Nt,cM as Bt,cF as wt}from"./zeni-epic-state-BVNUxmav.js";import{aq as xt,c as vt,M as Dt,y as Mt,as as Rt,dM as Pt,p as B,dN as Ut,w as Gt,dO as Ft,i as jt,a4 as $t}from"./index-DXVI9ztu.js";import"./mui-BAsIRnB1.js";import{u as Vt}from"./useAskAiCfoHostNavButtonProps-C4hcJx1x.js";import{u as Lt}from"./useTaskManagerAccess-B7YJLgDK.js";import"./recharts-C2rsrRI6.js";import"./analytics-N153TuwK.js";import"./plaid-dW1_MCaE.js";import"./dnd-DsH8jkrb.js";import"./stripe-cKAAJElX.js";import"./lottie-NIzYzhlS.js";import"./lexical-d2so_3As.js";import"./pdf-BKNPlqtE.js";import"./utils-BBaMea9r.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]="4718f262-37d1-40dc-ab63-e504e7febb2a",t._sentryDebugIdIdentifier="sentry-dbid-4718f262-37d1-40dc-ab63-e504e7febb2a")}catch{}})();const qt=(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=X(t),{signedInUser:h,isDebitCardFeatureEnabled:g,isTaskManagerAccessEnabled:c}=l,o=S(t),f=Y(t),{currentTab:T}=o;return{notificationView:o,isNotificationSettingsVisible:h.userEmail!=null&&Et(n.notificationSettings,h.userEmail,g,f,c),isDisabled:o.notificationDetailsByTab[T].fetchState==="In-Progress"?"disabled":void 0}}),(function(t,l){const{location:n,tenantEmailDomain:h,loggedInUserRoleMap:g,externalNotificationsUnreadCount:c,allUnreadCommentsNotificationIds:o,navigate:f,markInboxNotificationAsRead:T,fetchMoreCommentsNotifications:D}=l;return{onNotificationClick:(a,s,d,r)=>{if(r==="task_deleted"){const i=`/${h}/tasks`,I=B(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:I,message:"triggerBackClick"}})}else{const i=`/${h}/tasks/${s}`,I=B(n.state?.pathnameStackToGoBack,n.pathname);f(i,{state:{pathnameStackToGoBack:I,message:"triggerBackClick"}})}d==="unread"&&t(Q("task_manager","read",[a],!1))},onCommentNotificationClick:(a,s,d)=>{const r=s.toString().split(`/${h}/`);if(r[1]!=null){d==="unread"&&(T(a),t(F([a],j())));let i=`/${h}/${r[1]}`;const I=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:I,message:"triggerBackClick"}})}},onUpdateNotificationViewUIState:(a,s)=>{t(A(a,s))},onUpdateNotificationTabState:(a,s)=>{t(m(a,s))},onUpdateNotificationViewCurrentTabAndSubTab:(a,s)=>{t(K(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($("task_manager","dashboard",d))}else D?.()},onUpdateNotificationStatus:(a,s,d,r)=>{a==="tasks"?t(Q("task_manager",d,r)):(t(m({markAsReadState:{fetchState:"In-Progress",error:void 0}},"comments")),Promise.all(r.map((i=>{d==="read"&&(T(i),t(F([i],j())))}))).then((()=>{t(m({markAsReadState:{fetchState:"Completed",error:void 0},selectedNotificationIds:[]},"comments")),t(A({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")),qt(o,T).then((()=>{t(F(o,j())),t(m({markAsAllReadState:{fetchState:"Completed",error:void 0}},"comments")),t(A({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=$t(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}})}}}))(Gt(Ft)),Wt=()=>{const t=ht(),l=pt(),{tenantEmailDomain:n,selectedTab:h}=kt(),{areTenantIdsInSync:g}=xt(),c=Tt(h??""),o=gt(),f=vt(),[T,D]=k.useState(!1),a=b((e=>X(e))),s=b((e=>Y(e))),{useFeatureGate:d}=Dt(),{isFeatureEnabled:r}=d(Mt.isDebitCardFeatureEnabled),{isAiCfoAccessEnabled:i,onAskAiCfoClick:I}=Vt({mobileExploreReferrer:"Notifications"});Rt({isDataReady:!0});const Z=It(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)),L=b((e=>S(e).currentTab)),M=b((e=>S(e).currentSubTab)),tt=b((e=>S(e).notificationDetailsByTab.comments.fetchCountState)),R=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=Pt().allUsers,{inboxNotifications:w,isLoading:E,hasFetchedAll:C,isFetchingMore:P,fetchMore:ot}=mt(),{threads:q,isLoading:z,fetchMore:W,isFetchingMore:H,hasFetchedAll:J}=lt({query:{metadata:{companyId:s.companyId,application:"dashboard"}}});k.useEffect((()=>{if(L!==c&&c!=null&&o(K(c)),c==null){const e=`../${L}`,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(E===!1&&C===!0&&s?.companyId!=null&&w!=null){const e=`dashboard_${s.companyId}`,p=w.filter((y=>y.roomId===e&&y.readAt==null)).length;o(m({fetchCountState:{fetchState:"Completed",error:void 0}},"comments")),o(A({unreadCount:p},"comments"))}}),[E,C]),k.useEffect((()=>{V!=="In-Progress"&&g&&o($("task_manager","dashboard",["read","unread"]))}),[g]),k.useEffect((()=>{const e=setTimeout((()=>ot?.()),0);return()=>clearTimeout(e)}));const U=E||P===!0||C!==!0||E||P===!0||C!==!0;k.useEffect((()=>{U&&R!=="In-Progress"?o(m({fetchState:"In-Progress",error:void 0},"comments")):U||R!=="In-Progress"||o(m({fetchState:"Completed",error:void 0},"comments"))}),[U,R]),k.useEffect((()=>{o(A({hasMore:C!==!0},"comments"))}),[C]),k.useEffect((()=>{a.fetchState!=="In-Progress"&&a.fetchState!=="Completed"&&T===!1&&(D(!0),o(Ct()))}),[a.fetchState]),k.useEffect((()=>{if(E===!1&&z===!1&&w!=null&&q!=null){const e=`dashboard_${s.companyId}`,p=w.filter((u=>u.roomId===e)).filter((u=>Ut(u.kind))),y=p.filter((u=>u.readAt==null)),_=p.map((u=>u.id)),ct=p.map((u=>{const G=q.find((dt=>{return dt.id===((v=u).kind==="thread"?v.threadId:"subjectId"in v?v.subjectId:void 0);var v}));return G!=null?{inboxNotification:{...u,threadId:G.id},thread:G}:(H||J===!0||W==null||W(),null)})).filter((u=>u!=null));o(m({allNotificationsIds:_},"comments")),o(A({totalCount:_.length,unreadCount:y.length},"comments")),o(yt(ct))}}),[E,P,H,C,J,z,w?.length]);const nt={events:s.userRoleId!=null?[`private-encrypted-${s.userRoleId}.dashboard-user-notification`]:[],eventCallback:(e,p)=>{if(jt(p)){const y=At(p.mode);if(y==="dashboard"&&o(A({unreadCount:p.data.unread},"tasks")),V!=="In-Progress"){const _=[];M==="all"?_.push("read","unread"):M!=="mentions"&&_.push(M),o($("task_manager",y,_,!0))}}}},it=ft(),{isTaskManagerAccessEnabled:rt}=Lt(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:I,...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-C_WAhyd7.js";import{a as r}from"./sentry-lC29HHPj.js";import{u as A,g as j,j as o,N as x}from"./core-1xnf2RtE.js";import{TS as C,fE as P,gl as R,TT as z,TU as D,TV as M,TW as L,pR as k,Sx as N}from"./zeni-epic-state-BVNUxmav.js";import{z as h,ah as I}from"./index-nXM19luG.js";import"./mui-BAsIRnB1.js";import"./recharts-C2rsrRI6.js";import"./analytics-N153TuwK.js";import"./plaid-dW1_MCaE.js";import"./dnd-DsH8jkrb.js";import"./stripe-cKAAJElX.js";import"./lottie-NIzYzhlS.js";import"./lexical-d2so_3As.js";import"./pdf-BKNPlqtE.js";import"./utils-BBaMea9r.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]="4e1249b3-deeb-43bd-8854-70af7383960e",n._sentryDebugIdIdentifier="sentry-dbid-4e1249b3-deeb-43bd-8854-70af7383960e")}catch{}})();function ee(){const n=A(),s=j(),{params:t,error:i}=r.useMemo((()=>C(s.search)),[s.search]),w=r.useMemo((()=>new URLSearchParams(s.search).get("client_name")??t?.clientId??"Unknown Application"),[s.search,t]),p=h.isSignedIn(),a=h.getSignedInUser(),f=o((e=>P(e))),l=o((e=>R(e))),d=o((e=>e.tenantState.fetchState)),b=o(z),y=o(D),u=o(M),[S,v]=r.useState(null),[T,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((()=>{p&&a!=null&&!g.current&&(d!=="Not-Started"&&d!=="Error"||(g.current=!0,n(k(a.userId,a.zeniSessionId??void 0))))}),[p,a,d,n]),r.useEffect((()=>{u!=null&&u!==""&&(window.location.href=u)}),[u]);const U=r.useMemo((()=>{if(f?.tenantId!=null)return f.tenantId;const e=h.getActiveTenantForUser()?.tenantId;return e!=null&&l.some((_=>_.tenantId===e))?e:l.length===1?l[0].tenantId:null}),[f?.tenantId,l]),c=S??U;return i!=null?m.jsx(I,{variant:"invalid_params",paramsError:i}):p?m.jsx(I,{variant:"signed_in",clientName:w,userEmail:a?.userEmail,isInitializing:d!=="Completed",tenants:l,selectedTenantId:c,onSelectTenant:v,approveError:T??y,isApproving:b==="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(x,{to:"/signin/auth",state:{origin:s.pathname+s.search},replace:!0})}export{ee as default};
1
+ import{j as m}from"./liveblocks-C_WAhyd7.js";import{a as r}from"./sentry-lC29HHPj.js";import{u as A,g as j,j as o,N as x}from"./core-1xnf2RtE.js";import{TS as C,fE as P,gl as R,TT as z,TU as D,TV as M,TW as L,pR as k,Sx as N}from"./zeni-epic-state-BVNUxmav.js";import{z as h,ah as I}from"./index-DXVI9ztu.js";import"./mui-BAsIRnB1.js";import"./recharts-C2rsrRI6.js";import"./analytics-N153TuwK.js";import"./plaid-dW1_MCaE.js";import"./dnd-DsH8jkrb.js";import"./stripe-cKAAJElX.js";import"./lottie-NIzYzhlS.js";import"./lexical-d2so_3As.js";import"./pdf-BKNPlqtE.js";import"./utils-BBaMea9r.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]="4e1249b3-deeb-43bd-8854-70af7383960e",n._sentryDebugIdIdentifier="sentry-dbid-4e1249b3-deeb-43bd-8854-70af7383960e")}catch{}})();function ee(){const n=A(),s=j(),{params:t,error:i}=r.useMemo((()=>C(s.search)),[s.search]),w=r.useMemo((()=>new URLSearchParams(s.search).get("client_name")??t?.clientId??"Unknown Application"),[s.search,t]),p=h.isSignedIn(),a=h.getSignedInUser(),f=o((e=>P(e))),l=o((e=>R(e))),d=o((e=>e.tenantState.fetchState)),b=o(z),y=o(D),u=o(M),[S,v]=r.useState(null),[T,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((()=>{p&&a!=null&&!g.current&&(d!=="Not-Started"&&d!=="Error"||(g.current=!0,n(k(a.userId,a.zeniSessionId??void 0))))}),[p,a,d,n]),r.useEffect((()=>{u!=null&&u!==""&&(window.location.href=u)}),[u]);const U=r.useMemo((()=>{if(f?.tenantId!=null)return f.tenantId;const e=h.getActiveTenantForUser()?.tenantId;return e!=null&&l.some((_=>_.tenantId===e))?e:l.length===1?l[0].tenantId:null}),[f?.tenantId,l]),c=S??U;return i!=null?m.jsx(I,{variant:"invalid_params",paramsError:i}):p?m.jsx(I,{variant:"signed_in",clientName:w,userEmail:a?.userEmail,isInitializing:d!=="Completed",tenants:l,selectedTenantId:c,onSelectTenant:v,approveError:T??y,isApproving:b==="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(x,{to:"/signin/auth",state:{origin:s.pathname+s.search},replace:!0})}export{ee as default};
@@ -1 +1 @@
1
- import{j as n}from"./liveblocks-C_WAhyd7.js";import{h as K,u as X,g as H,i as Q,j as d,l as Z,n as ee,o as C}from"./core-1xnf2RtE.js";import{fE as M,zw as O,uv as ae,UJ as w,uq as y,bq as te,b$ as se,ur as oe,UK as re,Ur as S,eb as ne,Di as ce,UL as ie,DG as le,dY as de,dX as me}from"./zeni-epic-state-BVNUxmav.js";import{ai as fe,z as pe,aq as ue,as as he,V as Fe,M as q,y as $,a8 as ge,h as _,aD as be,p as Ie}from"./index-nXM19luG.js";import"./mui-BAsIRnB1.js";import Ce from"./NotFoundScreen-BHK2wcy4.js";import{F as Se}from"./FeaturePreviewScreen-ClB4hfhH.js";import{a as F}from"./sentry-lC29HHPj.js";import{u as ye}from"./useAskAiCfoHostNavButtonProps-CRADLi0_.js";import{u as Te}from"./useInitialThreadRequest-CbTk8gTV.js";import{t as De}from"./routePaths-WEgtxKVV.js";import{M as Ae}from"./MobileAppDrawer-ezuGFNmX.js";import"./recharts-C2rsrRI6.js";import"./analytics-N153TuwK.js";import"./plaid-dW1_MCaE.js";import"./dnd-DsH8jkrb.js";import"./stripe-cKAAJElX.js";import"./lottie-NIzYzhlS.js";import"./lexical-d2so_3As.js";import"./pdf-BKNPlqtE.js";import"./utils-BBaMea9r.js";import"./InboxNotificationsProvider-BU6hQETc.js";import"./useTaskManagerAccess-CCKD6ndI.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]="8a28c74b-3f24-45a4-a38d-62d3d055f0d3",s._sentryDebugIdIdentifier="sentry-dbid-8a28c74b-3f24-45a4-a38d-62d3d055f0d3")}catch{}})();const T=(s,e,a,o)=>{if(s!=e){const r=o??"";s!=null&&s.length>0?a(`../${e}${r}`,{replace:!0}):a(`${e}${r}`,{replace:!0})}},xe=Z((function(s){const e=re(s),a={},o=e.pandLReportWithForecast.uiState.nodeCollapseState;return Object.keys(o).forEach((r=>{a[r]=o[r]===!1})),{selectedTimeframe:e.selectedTimeframe,isForecastVsActualOn:e.isForecastVsActualOn,compareMode:e.compareMode,forecastList:e.forecastList,selectedForecast:e.selectedForecast,pandLreport:e.pandLReportWithForecast,scrollPosition:e.pandLReportWithForecast.uiState.scrollPosition,nodeOpenStatus:a,type:"name+balances_forecast",analytics:_}}),(function(s,e){return{onForecastSelectionChanged:(a,o)=>{s(w(a,o)),e.isPandLReportFetched(a)||s(y(a)),T(e.forecastIdFromUrlPath,a,e.navigate)},onTimeframeChanged:a=>{s(le(a))},onForecastVsActualsCompareToggle:a=>{s(ie(a)),s(S({forecastId:e.forecastIdFromUrlPath,scrollPosition:{scrollLeft:0,scrollTop:0}}))},onCompareModeChanged:a=>{s(ce(e.firstMonthOfFY,a,0,[]))},onAccountBalanceClick:e.hasTransactionAccess!==!0?void 0:(a,o)=>{let r,c;const p=a.accountName===""?a.accountDescription:a.accountName;if(o.balanceTimeFrame==="month"||o.balanceTimeFrame==="quarter"?(r=o.balanceTimeFrame,c=ne(o)):o.balanceTimeFrame==="year"?(r="quarter",c={startDate:o.endDate.startOf("quarter"),endDate:o.endDate}):console.error(`timeframe ${o.balanceTimeFrame} is not supported`),c!=null&&r!=null){const u=De(e.tenantEmailDomain,a.accountId,a.accountType,p,r,c),m=Ie(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(u,{state:{pathnameStackToGoBack:m,referrer:"Forecast"}})}},onNodeCollapseToggled:(a,o)=>{s(S({forecastId:e.forecastIdFromUrlPath,nodeCollapseState:{nodeId:a,isCollapsed:o===!1}}))},onTableScroll:a=>{s(S({forecastId:e.forecastIdFromUrlPath,scrollPosition:a}))},onBackClick:()=>{e.navigate("../../")}}}))(be);function v(){const s=fe(),e=K(),a=X(),o=H(),{forecastId:r,tenantEmailDomain:c}=Q(),[p,u]=F.useState(!1),[m,D]=F.useState(!1),g=pe.getSignedInUser(),A=d((t=>M(t))),B=A.company?.companyInfo.firstMonthOfFY??1,i=d((t=>O(t.forecastState,t.forecastListState))),l=d((t=>t.forecastListState.fetchState==="Completed")),x=d((t=>t.profitAndLossState)),E=d((t=>t.reportUIOptionsState.selectedForecast)),L=t=>x.pandLByForecastID[t]!=null&&oe(t,x).reducedAllFetchState.fetchState==="Completed",{areTenantIdsInSync:b}=ue();he({isDataReady:l});const{isAiCfoAccessEnabled:G,onAskAiCfoClick:N}=ye({mobileExploreReferrer:"Forecast"});F.useEffect((()=>{if(!p&&b)u(!0),l||a(ae());else if(l&&!m){D(!0);const t=((f,U,R)=>U!=null?f.forecasts.findIndex((I=>I.id===U)):R!=null?f.forecasts.findIndex((I=>I.id===R)):f.forecasts.length>0?0:-1)(i,r,E?.id);t===-1&&r!=null?e("page-not-found",{replace:!0}):t!==-1&&t!=E?.index?(a(w(i.forecasts[t].id,t)),T(r,i.forecasts[t].id,e,o.search)):r==null&&t!==-1&&T(void 0,i.forecasts[t].id,e,o.search),t!==-1&&!L(i.forecasts[t].id)&&b&&a(y(i.forecasts[t].id))}}),[p,u,a,l,i,m,D,O,y,b]);const j=Fe(),V=j?.loggedInUserRole!=null&&te(j.loggedInUserRole),{useFeatureGate:W}=q(),{isFeatureEnabled:k}=W($.isReportsCommentingEnabled),Y=Te(k?A?.companyId:void 0,{clearParams:l&&m}),[z,J]=F.useState(!1),h=new URL(s("forecast_pandl"));h.searchParams.set("firstname",g?.firstName??""),h.searchParams.set("lastname",g?.lastName??""),h.searchParams.set("email",g?.userEmail??"");const P=t=>{J(t)};return n.jsxs(n.Fragment,{children:[l?n.jsx(ge,{analytics:_,onLoad:t=>(f=>f.trackForecast())(t)}):null,n.jsx(Ae,{isAppContentDrawerOpen:z,handleDrawerToggle:P}),n.jsx(xe,{firstMonthOfFY:B,tenantEmailDomain:c,forecastIdFromUrlPath:r,navigate:e,location:o,isPandLReportFetched:L,meetingUrl:se(h.toString()),hasTransactionAccess:V,isAiCfoAccessEnabled:G,onAskAiCfoClick:N,isReportsCommentingEnabled:k,initialOpenThreadRequest:Y,onClickMenuIcon:()=>{P(!0)}})]})}function Xe(){const s=d((c=>M(c))),{useFeatureGate:e}=q(),{isFeatureEnabled:a}=e($.isDebitCardFeatureEnabled),o=de(a,s),r=me(s);return o===!0||r===!0?n.jsx(Se,{}):n.jsxs(ee,{children:[n.jsx(C,{path:"/",element:n.jsx(v,{})}),n.jsx(C,{path:"/:forecastId",element:n.jsx(v,{})}),n.jsx(C,{path:"/:forecastId/*",element:n.jsx(Ce,{})})]})}export{Xe as default};
1
+ import{j as n}from"./liveblocks-C_WAhyd7.js";import{h as K,u as X,g as H,i as Q,j as d,l as Z,n as ee,o as C}from"./core-1xnf2RtE.js";import{fE as M,zw as O,uv as ae,UJ as w,uq as y,bq as te,b$ as se,ur as oe,UK as re,Ur as S,eb as ne,Di as ce,UL as ie,DG as le,dY as de,dX as me}from"./zeni-epic-state-BVNUxmav.js";import{ai as fe,z as pe,aq as ue,as as he,V as Fe,M as q,y as $,a8 as ge,h as _,aD as be,p as Ie}from"./index-DXVI9ztu.js";import"./mui-BAsIRnB1.js";import Ce from"./NotFoundScreen-BF2gJW91.js";import{F as Se}from"./FeaturePreviewScreen-CWY6I3fG.js";import{a as F}from"./sentry-lC29HHPj.js";import{u as ye}from"./useAskAiCfoHostNavButtonProps-C4hcJx1x.js";import{u as Te}from"./useInitialThreadRequest-BFDb_b7F.js";import{t as De}from"./routePaths-3iKgurJn.js";import{M as Ae}from"./MobileAppDrawer-DH0tVOfv.js";import"./recharts-C2rsrRI6.js";import"./analytics-N153TuwK.js";import"./plaid-dW1_MCaE.js";import"./dnd-DsH8jkrb.js";import"./stripe-cKAAJElX.js";import"./lottie-NIzYzhlS.js";import"./lexical-d2so_3As.js";import"./pdf-BKNPlqtE.js";import"./utils-BBaMea9r.js";import"./InboxNotificationsProvider-BU6hQETc.js";import"./useTaskManagerAccess-B7YJLgDK.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]="8a28c74b-3f24-45a4-a38d-62d3d055f0d3",s._sentryDebugIdIdentifier="sentry-dbid-8a28c74b-3f24-45a4-a38d-62d3d055f0d3")}catch{}})();const T=(s,e,a,o)=>{if(s!=e){const r=o??"";s!=null&&s.length>0?a(`../${e}${r}`,{replace:!0}):a(`${e}${r}`,{replace:!0})}},xe=Z((function(s){const e=re(s),a={},o=e.pandLReportWithForecast.uiState.nodeCollapseState;return Object.keys(o).forEach((r=>{a[r]=o[r]===!1})),{selectedTimeframe:e.selectedTimeframe,isForecastVsActualOn:e.isForecastVsActualOn,compareMode:e.compareMode,forecastList:e.forecastList,selectedForecast:e.selectedForecast,pandLreport:e.pandLReportWithForecast,scrollPosition:e.pandLReportWithForecast.uiState.scrollPosition,nodeOpenStatus:a,type:"name+balances_forecast",analytics:_}}),(function(s,e){return{onForecastSelectionChanged:(a,o)=>{s(w(a,o)),e.isPandLReportFetched(a)||s(y(a)),T(e.forecastIdFromUrlPath,a,e.navigate)},onTimeframeChanged:a=>{s(le(a))},onForecastVsActualsCompareToggle:a=>{s(ie(a)),s(S({forecastId:e.forecastIdFromUrlPath,scrollPosition:{scrollLeft:0,scrollTop:0}}))},onCompareModeChanged:a=>{s(ce(e.firstMonthOfFY,a,0,[]))},onAccountBalanceClick:e.hasTransactionAccess!==!0?void 0:(a,o)=>{let r,c;const p=a.accountName===""?a.accountDescription:a.accountName;if(o.balanceTimeFrame==="month"||o.balanceTimeFrame==="quarter"?(r=o.balanceTimeFrame,c=ne(o)):o.balanceTimeFrame==="year"?(r="quarter",c={startDate:o.endDate.startOf("quarter"),endDate:o.endDate}):console.error(`timeframe ${o.balanceTimeFrame} is not supported`),c!=null&&r!=null){const u=De(e.tenantEmailDomain,a.accountId,a.accountType,p,r,c),m=Ie(e.location.state?.pathnameStackToGoBack,e.location.pathname);e.navigate(u,{state:{pathnameStackToGoBack:m,referrer:"Forecast"}})}},onNodeCollapseToggled:(a,o)=>{s(S({forecastId:e.forecastIdFromUrlPath,nodeCollapseState:{nodeId:a,isCollapsed:o===!1}}))},onTableScroll:a=>{s(S({forecastId:e.forecastIdFromUrlPath,scrollPosition:a}))},onBackClick:()=>{e.navigate("../../")}}}))(be);function v(){const s=fe(),e=K(),a=X(),o=H(),{forecastId:r,tenantEmailDomain:c}=Q(),[p,u]=F.useState(!1),[m,D]=F.useState(!1),g=pe.getSignedInUser(),A=d((t=>M(t))),B=A.company?.companyInfo.firstMonthOfFY??1,i=d((t=>O(t.forecastState,t.forecastListState))),l=d((t=>t.forecastListState.fetchState==="Completed")),x=d((t=>t.profitAndLossState)),E=d((t=>t.reportUIOptionsState.selectedForecast)),L=t=>x.pandLByForecastID[t]!=null&&oe(t,x).reducedAllFetchState.fetchState==="Completed",{areTenantIdsInSync:b}=ue();he({isDataReady:l});const{isAiCfoAccessEnabled:G,onAskAiCfoClick:N}=ye({mobileExploreReferrer:"Forecast"});F.useEffect((()=>{if(!p&&b)u(!0),l||a(ae());else if(l&&!m){D(!0);const t=((f,U,R)=>U!=null?f.forecasts.findIndex((I=>I.id===U)):R!=null?f.forecasts.findIndex((I=>I.id===R)):f.forecasts.length>0?0:-1)(i,r,E?.id);t===-1&&r!=null?e("page-not-found",{replace:!0}):t!==-1&&t!=E?.index?(a(w(i.forecasts[t].id,t)),T(r,i.forecasts[t].id,e,o.search)):r==null&&t!==-1&&T(void 0,i.forecasts[t].id,e,o.search),t!==-1&&!L(i.forecasts[t].id)&&b&&a(y(i.forecasts[t].id))}}),[p,u,a,l,i,m,D,O,y,b]);const j=Fe(),V=j?.loggedInUserRole!=null&&te(j.loggedInUserRole),{useFeatureGate:W}=q(),{isFeatureEnabled:k}=W($.isReportsCommentingEnabled),Y=Te(k?A?.companyId:void 0,{clearParams:l&&m}),[z,J]=F.useState(!1),h=new URL(s("forecast_pandl"));h.searchParams.set("firstname",g?.firstName??""),h.searchParams.set("lastname",g?.lastName??""),h.searchParams.set("email",g?.userEmail??"");const P=t=>{J(t)};return n.jsxs(n.Fragment,{children:[l?n.jsx(ge,{analytics:_,onLoad:t=>(f=>f.trackForecast())(t)}):null,n.jsx(Ae,{isAppContentDrawerOpen:z,handleDrawerToggle:P}),n.jsx(xe,{firstMonthOfFY:B,tenantEmailDomain:c,forecastIdFromUrlPath:r,navigate:e,location:o,isPandLReportFetched:L,meetingUrl:se(h.toString()),hasTransactionAccess:V,isAiCfoAccessEnabled:G,onAskAiCfoClick:N,isReportsCommentingEnabled:k,initialOpenThreadRequest:Y,onClickMenuIcon:()=>{P(!0)}})]})}function Xe(){const s=d((c=>M(c))),{useFeatureGate:e}=q(),{isFeatureEnabled:a}=e($.isDebitCardFeatureEnabled),o=de(a,s),r=me(s);return o===!0||r===!0?n.jsx(Se,{}):n.jsxs(ee,{children:[n.jsx(C,{path:"/",element:n.jsx(v,{})}),n.jsx(C,{path:"/:forecastId",element:n.jsx(v,{})}),n.jsx(C,{path:"/:forecastId/*",element:n.jsx(Ce,{})})]})}export{Xe as default};
@@ -1,4 +1,4 @@
1
- import{j as a}from"./liveblocks-C_WAhyd7.js";import{a as p}from"./sentry-lC29HHPj.js";import{H as c,I as r,a9 as m,ad as f,ae as h}from"./index-nXM19luG.js";import"./mui-BAsIRnB1.js";import{i as y}from"./core-1xnf2RtE.js";import"./zeni-epic-state-BVNUxmav.js";import"./recharts-C2rsrRI6.js";import"./analytics-N153TuwK.js";import"./plaid-dW1_MCaE.js";import"./dnd-DsH8jkrb.js";import"./stripe-cKAAJElX.js";import"./lottie-NIzYzhlS.js";import"./lexical-d2so_3As.js";import"./pdf-BKNPlqtE.js";import"./utils-BBaMea9r.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]="a04db822-8766-4f56-9a88-ff18fc054a0c",e._sentryDebugIdIdentifier="sentry-dbid-a04db822-8766-4f56-9a88-ff18fc054a0c")}catch{}})();const g=c("div")`
1
+ import{j as a}from"./liveblocks-C_WAhyd7.js";import{a as p}from"./sentry-lC29HHPj.js";import{H as c,I as r,a9 as m,ad as f,ae as h}from"./index-DXVI9ztu.js";import"./mui-BAsIRnB1.js";import{i as y}from"./core-1xnf2RtE.js";import"./zeni-epic-state-BVNUxmav.js";import"./recharts-C2rsrRI6.js";import"./analytics-N153TuwK.js";import"./plaid-dW1_MCaE.js";import"./dnd-DsH8jkrb.js";import"./stripe-cKAAJElX.js";import"./lottie-NIzYzhlS.js";import"./lexical-d2so_3As.js";import"./pdf-BKNPlqtE.js";import"./utils-BBaMea9r.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]="a04db822-8766-4f56-9a88-ff18fc054a0c",e._sentryDebugIdIdentifier="sentry-dbid-a04db822-8766-4f56-9a88-ff18fc054a0c")}catch{}})();const g=c("div")`
2
2
  display: flex;
3
3
  flex-direction: column;
4
4
  width: 100%;
@@ -1,4 +1,4 @@
1
- import{j as a}from"./liveblocks-C_WAhyd7.js";import{UF as re,fE as Q,l_ as G,dY as N,dX as le,Rx as Y,U2 as ce,Cf as Pe,UG as X,C4 as je,Cp as Le,Cj as de,C8 as pe,Cn as ve,Ck as Te,UH as ue,rL as Re,g5 as Ae,gC as Fe,UI as H,Cc as me,Cb as ge,Cs as Ve,c8 as Oe}from"./zeni-epic-state-BVNUxmav.js";import{a1 as fe,M as J,y as _,z as K,g as Ce,$ as he,af as ye,az as be,aA as Ue,ab as Se,I as V,ag as we,G as W,aB as Ze,aq as Be,as as $e,a8 as ze,h as xe,R as He,p as _e,aC as Ge,V as Ke}from"./index-nXM19luG.js";import{D as De,n as M,S as Ie}from"./mui-BAsIRnB1.js";import ae from"./NotFoundScreen-BHK2wcy4.js";import{a as c}from"./sentry-lC29HHPj.js";import{u as ee,i as We,j as g,h as Me,g as qe,l as Xe,n as se,o as z}from"./core-1xnf2RtE.js";import{u as Qe}from"./useAskAiCfoHostNavButtonProps-CRADLi0_.js";import{M as Ne}from"./MobileAppDrawer-ezuGFNmX.js";import"./recharts-C2rsrRI6.js";import"./analytics-N153TuwK.js";import"./plaid-dW1_MCaE.js";import"./dnd-DsH8jkrb.js";import"./stripe-cKAAJElX.js";import"./lottie-NIzYzhlS.js";import"./lexical-d2so_3As.js";import"./pdf-BKNPlqtE.js";import"./utils-BBaMea9r.js";import"./InboxNotificationsProvider-BU6hQETc.js";import"./useTaskManagerAccess-CCKD6ndI.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]="b15951b0-25fe-4327-adc2-f2523725c87e",e._sentryDebugIdIdentifier="sentry-dbid-b15951b0-25fe-4327-adc2-f2523725c87e")}catch{}})();const Ye={overlayWidth:new Se(100,100,48)},te=W.getLocalizedStrings().peoplePage.invitePage,ne=W.getLocalizedStrings().common,Je=({companyId:e,managersListView:t,companyPassportView:d,classListView:n,mode:f,isEditPeopleDrawerOpen:i,closeDrawerHandler:b})=>{const C=fe(),m=ee(),[O,U]=c.useState(!1),[k,S]=c.useState(!1),{userId:w}=We(),r=g((l=>re(l))),p=g((l=>Q(l))),E=g((l=>G(l))),{useFeatureGate:D}=J(),{isFeatureEnabled:I}=D(_.isDebitCardFeatureEnabled),P=N(I,p),v=le(p),T=Y(p),Z=ce(p),B=!!p.company?.featuresActivationInfo?.isReimbursementFeatureEnabled,x=!P&&E&&n.fetchState!=="Completed"||t.fetchState!=="Completed"||d.fetchState!=="Completed"||e==null;if(K.getSignedInUser()==null)throw Error("Can't access invite people page without signing in...");const h=()=>{m(X()),b()},R=()=>{O===!0?S(!0):h()},$=d.companyView?.controllers?.map((l=>l.user)),u=!!p.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:j}=D(_.isChargeCardFeatureEnabled),L=Ce(p,j,I),{isCardsHidden:A}=he(p?.tenantId),y=!L||A,F=p.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",s={peopleDetails:r,classList:n.classes,managersList:t.users,controllersList:$,mode:f,isZeniTenant:T,isAccountingClassesEnabled:E,isReimbursementDisabled:B===!1,isZeniAccountsDisabled:u===!1,isChargeCardDisabled:y,isTreasuryDisabled:F===!1,isLiteRoleDisabled:Z===!1,isBankingOnlyTenant:P,isCardsOnlyTenant:v,onResetClick:h,onDeleteUser:l=>{m(pe(l.userId,l.userRole.userRoleId))},onPeopleLocalDataUpdated:l=>{m(de({peopleLocalData:l})),U(!0)},onSaveClick:()=>{m(f==="zeni_only"?je(e):Le(T))},onCloseClick:R,isLoading:x||r.person==null},o={onOkClick:()=>{S(!1),h()},onCancelClick:()=>{S(!1)}};return c.useEffect((()=>{x===!1&&w!=null&&m(Pe(w))}),[x,w]),c.useEffect((()=>{r.updatePersonState.fetchState==="Completed"&&h()}),[r.updatePersonState.fetchState]),a.jsx(De,{anchor:"right",open:i,PaperProps:{style:{width:Ye.overlayWidth.valuePercentage(C),boxShadow:"none"}},slotProps:{backdrop:{style:{backgroundColor:ye.overlayDark,cursor:"pointer"}}},onClose:R,children:a.jsxs(ea,{onClick:l=>l.stopPropagation(),children:[k===!0?a.jsx(be,{titleComponent:a.jsx(ke,{children:te.discardTitle}),descriptionComponent:a.jsx(Ee,{children:te.discardDescription}),primaryButtonText:ne.yes,secondaryButtonText:ne.no,action:o,isEditPopup:!0}):null,a.jsx(Ue,{...s})]})})},ea=M(Ie)`
1
+ import{j as a}from"./liveblocks-C_WAhyd7.js";import{UF as re,fE as Q,l_ as G,dY as N,dX as le,Rx as Y,U2 as ce,Cf as Pe,UG as X,C4 as je,Cp as Le,Cj as de,C8 as pe,Cn as ve,Ck as Te,UH as ue,rL as Re,g5 as Ae,gC as Fe,UI as H,Cc as me,Cb as ge,Cs as Ve,c8 as Oe}from"./zeni-epic-state-BVNUxmav.js";import{a1 as fe,M as J,y as _,z as K,g as Ce,$ as he,af as ye,az as be,aA as Ue,ab as Se,I as V,ag as we,G as W,aB as Ze,aq as Be,as as $e,a8 as ze,h as xe,R as He,p as _e,aC as Ge,V as Ke}from"./index-DXVI9ztu.js";import{D as De,n as M,S as Ie}from"./mui-BAsIRnB1.js";import ae from"./NotFoundScreen-BF2gJW91.js";import{a as c}from"./sentry-lC29HHPj.js";import{u as ee,i as We,j as g,h as Me,g as qe,l as Xe,n as se,o as z}from"./core-1xnf2RtE.js";import{u as Qe}from"./useAskAiCfoHostNavButtonProps-C4hcJx1x.js";import{M as Ne}from"./MobileAppDrawer-DH0tVOfv.js";import"./recharts-C2rsrRI6.js";import"./analytics-N153TuwK.js";import"./plaid-dW1_MCaE.js";import"./dnd-DsH8jkrb.js";import"./stripe-cKAAJElX.js";import"./lottie-NIzYzhlS.js";import"./lexical-d2so_3As.js";import"./pdf-BKNPlqtE.js";import"./utils-BBaMea9r.js";import"./InboxNotificationsProvider-BU6hQETc.js";import"./useTaskManagerAccess-B7YJLgDK.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]="b15951b0-25fe-4327-adc2-f2523725c87e",e._sentryDebugIdIdentifier="sentry-dbid-b15951b0-25fe-4327-adc2-f2523725c87e")}catch{}})();const Ye={overlayWidth:new Se(100,100,48)},te=W.getLocalizedStrings().peoplePage.invitePage,ne=W.getLocalizedStrings().common,Je=({companyId:e,managersListView:t,companyPassportView:d,classListView:n,mode:f,isEditPeopleDrawerOpen:i,closeDrawerHandler:b})=>{const C=fe(),m=ee(),[O,U]=c.useState(!1),[k,S]=c.useState(!1),{userId:w}=We(),r=g((l=>re(l))),p=g((l=>Q(l))),E=g((l=>G(l))),{useFeatureGate:D}=J(),{isFeatureEnabled:I}=D(_.isDebitCardFeatureEnabled),P=N(I,p),v=le(p),T=Y(p),Z=ce(p),B=!!p.company?.featuresActivationInfo?.isReimbursementFeatureEnabled,x=!P&&E&&n.fetchState!=="Completed"||t.fetchState!=="Completed"||d.fetchState!=="Completed"||e==null;if(K.getSignedInUser()==null)throw Error("Can't access invite people page without signing in...");const h=()=>{m(X()),b()},R=()=>{O===!0?S(!0):h()},$=d.companyView?.controllers?.map((l=>l.user)),u=!!p.company?.companyZeniAccountInfo?.isZeniAccountEnabled,{isFeatureEnabled:j}=D(_.isChargeCardFeatureEnabled),L=Ce(p,j,I),{isCardsHidden:A}=he(p?.tenantId),y=!L||A,F=p.companyTreasuryInfo?.info?.businessVerificationStatus?.code==="verified",s={peopleDetails:r,classList:n.classes,managersList:t.users,controllersList:$,mode:f,isZeniTenant:T,isAccountingClassesEnabled:E,isReimbursementDisabled:B===!1,isZeniAccountsDisabled:u===!1,isChargeCardDisabled:y,isTreasuryDisabled:F===!1,isLiteRoleDisabled:Z===!1,isBankingOnlyTenant:P,isCardsOnlyTenant:v,onResetClick:h,onDeleteUser:l=>{m(pe(l.userId,l.userRole.userRoleId))},onPeopleLocalDataUpdated:l=>{m(de({peopleLocalData:l})),U(!0)},onSaveClick:()=>{m(f==="zeni_only"?je(e):Le(T))},onCloseClick:R,isLoading:x||r.person==null},o={onOkClick:()=>{S(!1),h()},onCancelClick:()=>{S(!1)}};return c.useEffect((()=>{x===!1&&w!=null&&m(Pe(w))}),[x,w]),c.useEffect((()=>{r.updatePersonState.fetchState==="Completed"&&h()}),[r.updatePersonState.fetchState]),a.jsx(De,{anchor:"right",open:i,PaperProps:{style:{width:Ye.overlayWidth.valuePercentage(C),boxShadow:"none"}},slotProps:{backdrop:{style:{backgroundColor:ye.overlayDark,cursor:"pointer"}}},onClose:R,children:a.jsxs(ea,{onClick:l=>l.stopPropagation(),children:[k===!0?a.jsx(be,{titleComponent:a.jsx(ke,{children:te.discardTitle}),descriptionComponent:a.jsx(Ee,{children:te.discardDescription}),primaryButtonText:ne.yes,secondaryButtonText:ne.no,action:o,isEditPopup:!0}):null,a.jsx(Ue,{...s})]})})},ea=M(Ie)`
2
2
  display: flex;
3
3
  min-height: 100%;
4
4
  flex-direction: column;